对google个性主页的拖拽效果的js的完整注释[转]

2019-06-02 23:22:44丽君

         // remote call to save the change 
    }
     return   true ;
};
// 拖拽后的执行钩子 
function  after_Drag() {
     var  returnValue  =   false ;
     // 防止闪烁 
    Util.hide();
     // 把拖拽时的position=absolute和相关的那些style都消除 
     this .elm.style.position  =   "" ;
     this .elm.style.width  =   "" ;
     this .elm.style.zIndex  =   "" ;
     this .elm.style.filter  =   "" ;
     this .elm.style.opacity  =   "" ;
     // 获取灰框 
     var  ele  =  getGhostElement();
     // 如果现在的邻居不是原来的邻居了 
     if  (ele.nextSibling  !=   this .origNextSibling) {
         // 把被拖拽的这个节点插到灰框的前面 
        ele.parentNode.insertBefore( this .elm, ele.nextSibling);
         // 标明被拖拽了新的地方 
        returnValue  =   true ;
    }
     // 移除灰框,这是这个灰框的生命周期应该就结束了 
    ele.parentNode.removeChild(ele);
     // 修改完毕,显示 
    Util.show();
     if  (Util.isOpera) {
         // Opera的现实问题,要隐藏/显示后才能刷新出变化 
        document.body.style.display  =   " none " ;
        document.body.style.display  =   "" ;
    }
     return  returnValue;
};
// 可拖拽Element的原形,用来将event绑定到各个钩子,这部分市比较通用的,netvibes也是基本完全相同的实现 
// 这部分推荐看dindin的这个,也会帮助理解,http://www.jroller.com/page/dindin/?anchor=pro_javascript_12