zoukankan      html  css  js  c++  java
  • HongYingPanelBox..脚本

      1<script language='JavaScript' type='text/javascript'>
      2    var HYPanelBoxZindex;
      3    
      4    //对话框移动方法
      5    function HongYiMessageBoxDrag(moveObj)
      6    {
      7        var DragObj = moveObj.style;
      8        var DBody = document.body;
      9        var x = event.clientX + DBody.scrollLeft - DragObj.pixelLeft;
     10        var y = event.clientY + DBody.scrollTop - DragObj.pixelTop;
     11        var objMove=moveObj;
     12        var move = function()
     13        {
     14            if (event.button == 1)
     15            {
     16              
     17                DragObj.pixelLeft = event.clientX + DBody.scrollLeft - x;
     18                DragObj.pixelTop = event.clientY + DBody.scrollTop - y;
     19                HongYiPanelBoxPostBack(moveObj);
     20            }

     21            else document.detachEvent('onmousemove', move);
     22        }

     23        document.attachEvent('onmousemove', move)
     24
     25        if (!HYPanelBoxZindex) HYPanelBoxZindex = 999;
     26        DragObj.zIndex = ++HYPanelBoxZindex;
     27        event.cancelBubble = true;
     28    }

     29    
     30    var HongYiPanelBoxObj = null;//存储改变大小的对象,全局对象。
     31    var IsHongYiPanelObjContent = true//用于屏蔽
     32    
     33    
     34    function HongYiPanelBoxContent_OnMouseDown()
     35    {
     36       IsHongYiPanelObjContent=false;
     37    }

     38    
     39     
     40    function PanelBox()   
     41    {   
     42        this.el = null;  
     43        this.dir = ''; //存储当前拖动的方向,resize (n,s,e,w,ne,nw,se,sw)   
     44        this.grabx = null//Some   useful   values   
     45        this.graby = null;   
     46        this.width = null;   
     47        this.height = null;   
     48        this.left = null;   
     49        this.top = null;
     50        
     51        this.BoxWidth=null
     52        this.BoxHeight=null
     53        this.BoxTitleWidth=null
     54        this.BoxTitleHeith=null
     55        this.BoxContentWidth=null
     56        this.BoxContentHeight=null
     57    }
       
     58     
     59     
     60    //获取要拖动的方向
     61    function  HongYiGetDirection(el)   
     62    {   
     63        var xPos,yPos,offset,dir;   
     64        dir = '';   
     65
     66        xPos = window.event.offsetX;   
     67        yPos = window.event.offsetY;   
     68
     69        offset = 8;   //The distance from the edge in pixels   
     70
     71        if(yPos < offset)
     72        {
     73            dir += 'n';   
     74        }

     75        else
     76        {
     77            if(yPos > el.offsetHeight-offset)
     78            {
     79                dir += 's';   
     80            }

     81         }

     82         
     83        if (xPos<offset)
     84        {
     85            dir += 'w';   
     86        }

     87        else
     88        {
     89            if(xPos > el.offsetWidth-offset)
     90            {
     91                dir += 'e';   
     92            }

     93        }

     94        
     95        return dir;   
     96    }
       
     97    
     98    //获取的对象
     99    //HongYiGetReal(事件,属性,值);
    100    function HongYiGetReal(el,type,value)
    101    {   
    102        temp = el;   
    103        while((temp != null&& (temp.tagName != 'BODY'))
    104        {   
    105            if (eval('temp.' + type) == value)
    106            {   
    107                el = temp;   
    108                return el;   
    109            }
       
    110            temp = temp.parentElement;   
    111        }
       
    112        return el;   
    113    }

    114     
    115    function HongYiPanelBox_OnMouseDown()   
    116    {   
    117        if(IsHongYiPanelObjContent)
    118        {
    119            var el = HongYiGetReal(event.srcElement,   'className',   'HongYiPanelBox');   
    120            
    121            if (el == null)   
    122            {   
    123                HongYiPanelBoxObj = null;   
    124                return;   
    125            }
       
    126             
    127            dir = HongYiGetDirection(el);   
    128            if( dir == '' ) 
    129                return;   
    130             
    131            HongYiPanelBoxObj = new PanelBox(); 
    132              
    133            HongYiPanelBoxObj.el = el;   
    134            HongYiPanelBoxObj.dir = dir;   
    135            HongYiPanelBoxObj.grabx = window.event.clientX;   
    136            HongYiPanelBoxObj.graby = window.event.clientY;   
    137            HongYiPanelBoxObj.width = el.offsetWidth;   
    138            HongYiPanelBoxObj.height = el.offsetHeight;   
    139            HongYiPanelBoxObj.left = el.offsetLeft;   
    140            HongYiPanelBoxObj.top = el.offsetTop;  
    141            
    142            var HongYiPanelBoxContent = HongYiPanelBoxObj.el.childNodes(1);
    143            var PanelBoxSize = HongYiGetSize(HongYiPanelBoxObj)
    144            HongYiPanelBoxContent.style.height=(PanelBoxSize.BoxHeight-PanelBoxSize.BoxTitleHeith)+'px'
    145            HongYiPanelBoxContent.style.width=(PanelBoxSize.BoxWidth)+'px';
    146            HongYiPanelBoxContent.style.display='none';
    147            HongYiPanelBoxPostBack(HongYiPanelBoxObj.el);
    148            
    149            window.event.returnValue   =   false;   
    150            window.event.cancelBubble   =   true;  
    151        }

    152        IsHongYiPanelObjContent=true;
    153    }
       
    154    
    155    function HongYiGetSize(obj)
    156    {
    157        var HongYiPanelBoxContent = obj.el.childNodes(1);
    158        var HongYipanelBoxTitle = obj.el.childNodes(0);
    159
    160        obj.BoxWidth=parseFloat(obj.el.style.width);
    161        obj.BoxHeight=parseFloat(obj.el.style.height);
    162        obj.BoxTitleWidth=parseFloat(HongYipanelBoxTitle.style.width);
    163        obj.BoxTitleHeith=parseFloat(HongYipanelBoxTitle.style.height);
    164        obj.BoxContentWidth=parseFloat(HongYiPanelBoxContent.style.width);
    165        obj.BoxContentHeight=parseFloat(HongYiPanelBoxContent.style.width);
    166        return obj;
    167    }

    168     
    169    function HongYiPanelBox_OnMouseUp()   
    170    {   
    171        if (HongYiPanelBoxObj != null)   
    172        {   
    173            var HongYiPanelBoxContent = HongYiPanelBoxObj.el.childNodes(1);
    174            HongYiPanelBoxContent.style.display='';
    175            HongYiPanelBoxObj = null;  
    176             
    177        }
       
    178    }
       
    179     
    180    function HongYiPanelBox_OnMouseMove()   
    181    {   
    182        var el,xPos,yPos,str,xMin,yMin;   
    183        xMin = 8;   //The smallest width possible   
    184        yMin = 8;   //height   
    185
    186        el = HongYiGetReal(event.srcElement, 'className', 'HongYiPanelBox');   
    187
    188        if(el.className == 'HongYiPanelBox')
    189        {   
    190            str = HongYiGetDirection(el);   
    191            //Fix   the   cursor   
    192            if (str == '')
    193            {  
    194                str = 'default';   
    195            }

    196            else
    197            {   
    198                str += '-resize'; 
    199            }

    200            el.style.cursor   =   str;   
    201        }
       
    202     
    203        //Dragging   starts   here   
    204        if(HongYiPanelBoxObj != null)
    205        {   
    206            HongYiPanelBoxPostBack(HongYiPanelBoxObj.el);
    207            if (dir.indexOf('e') != -1)
    208            {
    209                HongYiPanelBoxObj.el.style.width = Math.max(xMin, HongYiPanelBoxObj.width + window.event.clientX - HongYiPanelBoxObj.grabx) + 'px';  
    210            }

    211         
    212            if (dir.indexOf('s') != -1)
    213            {
    214                HongYiPanelBoxObj.el.style.height = Math.max(yMin, HongYiPanelBoxObj.height + window.event.clientY - HongYiPanelBoxObj.graby) + 'px';   
    215            }

    216         
    217            if (dir.indexOf('w') != -1)   
    218            {   
    219                HongYiPanelBoxObj.el.style.left = Math.min(HongYiPanelBoxObj.left + window.event.clientX - HongYiPanelBoxObj.grabx,
    220                HongYiPanelBoxObj.left + HongYiPanelBoxObj.width - xMin) + 'px';   
    221                HongYiPanelBoxObj.el.style.width  =  Math.max(xMin, HongYiPanelBoxObj.width - window.event.clientX + HongYiPanelBoxObj.grabx) + 'px';   
    222            }
       
    223            if   (dir.indexOf('n')   !=   -1)
    224            {   
    225                HongYiPanelBoxObj.el.style.top = Math.min(HongYiPanelBoxObj.top + window.event.clientY - HongYiPanelBoxObj.graby, 
    226                HongYiPanelBoxObj.top + HongYiPanelBoxObj.height - yMin) + 'px';   
    227                HongYiPanelBoxObj.el.style.height = Math.max(yMin, HongYiPanelBoxObj.height - window.event.clientY + HongYiPanelBoxObj.graby) + 'px';   
    228            }
     
    229        
    230            var HongYiPanelBoxContent = HongYiPanelBoxObj.el.childNodes(1);
    231            var HongYiPanelBoxTitle = HongYiPanelBoxObj.el.childNodes(0);
    232            var PanelBoxSize = HongYiGetSize(HongYiPanelBoxObj)
    233            HongYiPanelBoxContent.style.height=(PanelBoxSize.BoxHeight-PanelBoxSize.BoxTitleHeith)+'px'
    234            HongYiPanelBoxContent.style.width=(PanelBoxSize.BoxWidth)+'px';
    235            HongYiPanelBoxTitle.style.width=(PanelBoxSize.BoxWidth)+'px';
    236      
    237        
    238            window.event.returnValue   =   false;   
    239            window.event.cancelBubble   =   true;  
    240        }
         
    241  }
       
    242    document.onmouseup = HongYiPanelBox_OnMouseUp;   
    243    document.onmousemove = HongYiPanelBox_OnMouseMove;
    244//    document.onmousedown   =   doDown;  
    245
    246    function HongYiPanelBox_OnClose(obj)
    247    {
    248        obj.style.display='none';
    249        obj.nextSibling.style.display='none';
    250    }
     
    251
    252    function HongYiPanelBox_Show(obj)
    253    {
    254        obj.style.display='none';
    255        obj.previousSibling.style.display='';
    256        HongYiPanelBoxActiveIndex(obj.previousSibling)
    257      
    258        
    259    }

    260
    261    function HongYiPanelBox_ShowSelf(obj)
    262    {
    263        obj.previousSibling.style.display='';
    264        HongYiPanelBoxActiveIndex(obj.previousSibling)
    265    }

    266
    267    function HongYiPanelBox_MinState(obj)
    268    {
    269      obj.style.display='none';
    270      obj.nextSibling.style.display='';
    271    }

    272
    273    function HongYiPanelBox_MinStateSelf(obj)
    274    {
    275      obj.style.display='none';
    276    }

    277
    278    function HongYingPanelBoxTaskItem_OnMouseMoveCss(obj,cssName)
    279    {
    280        obj.className=cssName;
    281    }

    282
    283    function HongYingPanelBoxTaskItem_OnMouseMoveOutCss(obj,cssName)
    284    {
    285        obj.className=cssName;
    286    }

    287
    288    function HongYiPanelBox_OnMaxState(obj)
    289    {
    290        obj.style.width='99%';
    291        obj.style.height='99%';
    292        obj.style.top='0px';
    293        obj.style.left='0px'
    294        var HongYiPanelBoxContent = obj.childNodes(1);
    295        var HongYiPanelBoxTitle = obj.childNodes(0);
    296        HongYiPanelBoxContent.style.width='100%';
    297        HongYiPanelBoxContent.style.height='96%';
    298        HongYiPanelBoxTitle.style.width='100%';
    299    }

    300
    301    function HongYiPanelBox_ShowById(objId)
    302    {
    303        var obj = document.getElementById(objId);
    304        obj.style.display='';
    305    }

    306    
    307    function HongYiPanelBox_CenterSize(obj)
    308    {
    309        obj.style.width=(window.screen.width/2)+'px';
    310        obj.style.height=(window.screen.height/2)+'px';
    311        obj.style.top='100px';
    312        obj.style.left='300px';
    313        
    314        var HongYiPanelBoxContent = obj.childNodes(1);
    315        var HongYiPanelBoxTitle = obj.childNodes(0);
    316        HongYiPanelBoxContent.style.width=obj.style.width;
    317        HongYiPanelBoxContent.style.height=(parseFloat(obj.style.height)-parseFloat(HongYiPanelBoxTitle.style.height))+'px';
    318        HongYiPanelBoxTitle.style.width=obj.style.width;
    319    }

    320    
    321    function HongYiPanelBoxActiveIndex(obj)
    322    {
    323        if (!HYPanelBoxZindex) HYPanelBoxZindex = 999;
    324        obj.style.zIndex= ++HYPanelBoxZindex;
    325    }

    326    
    327    function HongYiPanelBoxActiveIndexByobjId(objId)
    328    {
    329        var obj = document.getElementById(objId);
    330        if (!HYPanelBoxZindex) HYPanelBoxZindex = 999;
    331        obj.style.zIndex= ++HYPanelBoxZindex;
    332    }

    333    
    334    function HongYiPanelBoxPostBack(obj) 
    335    {
    336        var DataContainer = document.getElementById(obj.id+'Hidden');
    337        DataContainer.value= parseFloat(obj.style.top)+'~'+ parseFloat(obj.style.left)+'~'+parseFloat(obj.style.width)+'~'+parseFloat(obj.style.height);
    338    }

    339    </script>
  • 相关阅读:
    ORACLE B-TREE(B树)索引
    安装CentOS 6.4 64 位操作系统
    环境搭建(一)——linux 安装tomcat
    Linux基础
    sql必知必会
    Mysql基础
    shell编程基础
    Allpairs 正交分析工具的使用(测试用例设计)
    Sublime Text3配置SublimeREPL快捷键的方法(Python)
    XSS攻击及预防
  • 原文地址:https://www.cnblogs.com/wubiyu/p/841759.html
Copyright © 2011-2022 走看看