本帖最后由 gengxin_914 于 2010-02-07 18:18:02 编辑

解决方案 »

  1.   

    跟上:
    <script type="text/javascript">
    var CoolDrag={
        obj : null, //目标对象
        cloneobj : null, //拖动对象
        container : null, //容器
        dragged : false, //拖动标志
        shadow: null, //阴影
       
        init:function(id){
            CoolDrag.container = $(id);
            var cooldrag = CoolDrag.read("cooldrag");
            if(cooldrag != ""){//读取cookie
                var subcontainer = cooldrag.split("|");
                for(var i=0 ; i < subcontainer.length; i++){
                    var subcontainerItem = subcontainer[i].split(":");
                    if($(subcontainerItem[0])){
                        var items = subcontainerItem[1].split(",");
                        for(var j=0; j< items.length; j++){
                            if($(items[j])) $(subcontainerItem[0]).appendChild($(items[j]));
                        }
                    }
                }
            }
            cleanWhitespace(CoolDrag.container)//清除空白节点
            var collection = CoolDrag.container.getElementsByTagName("DIV");
            for(var i = 0; i < collection.length; i++){
                if(collection[i].className == "dragLayer"){
                    var o = collection[i].firstChild;           
                    SavedObject.push([o.parentNode.id,1,o.parentNode.style.height]);
                    o.onmousedown = CoolDrag.start;
                }
            }
            document.onmousemove = CoolDrag.drag;
            document.onmouseup = CoolDrag.end;
        },
       
        start:function(e){
            if(!e) e = window.event;
            var obj = getT(e);
            if(obj.className == "min"){
                CoolDrag.min(e);
                return;
            }else if(obj.className == "close"){
                CoolDrag.close(e);
                return;
            }else{
                if(obj.className != "dragHeader") obj = obj.parentNode;
            }
            CoolDrag.dragged = true;
            CoolDrag.obj = obj.parentNode;
            CoolDrag.cloneobj = CoolDrag.obj.cloneNode(true);
            document.body.appendChild(CoolDrag.cloneobj);
            CoolDrag.shadow = document.createElement("DIV");
            document.body.appendChild(CoolDrag.shadow);
            with(CoolDrag.cloneobj.style){
                position = "absolute";
                zIndex = 1000;
                left = getRealLeft(CoolDrag.obj) + "px";
                top = getRealTop(CoolDrag.obj) + "px";
            }
            with(CoolDrag.shadow.style){
                position = "absolute";
                zIndex = 999;
                left = getRealLeft(CoolDrag.obj) + 4 + "px";
                top = getRealTop(CoolDrag.obj) + 4 + "px";
                width = CoolDrag.obj.offsetWidth + "px";
                height = CoolDrag.obj.offsetHeight + "px";
                backgroundColor = "#ccc";
                if(navigator.userAgent.indexOf("Gecko") != -1)
                    MozOpacity = "0.5";
                else if(navigator.userAgent.indexOf("MSIE") != -1)
                    filter = "alpha(opacity=50)";
            }       
            CoolDrag.cloneobj.initMouseX = getMouseX(e);
            CoolDrag.cloneobj.initMouseY    = getMouseY(e);
            CoolDrag.cloneobj.initoffsetL = getRealLeft(CoolDrag.obj);
            CoolDrag.cloneobj.initoffsetY = getRealTop(CoolDrag.obj);
            //change style
            CoolDrag.cloneobj.firstChild.className="dragHeader_over";
            CoolDrag.cloneobj.className = "dragLayer_over";
            CoolDrag.obj.className="clone_dragLayer_over";
        },
       
      

  2.   


        drag:function(e){
            if(!CoolDrag.dragged||CoolDrag.obj==null)return;
            if(!e) e = window.event;
            var currenX = getMouseX(e);
            var currenY = getMouseY(e);
           
            if(CoolDrag.cloneobj.initoffsetL +  currenX - CoolDrag.cloneobj.initMouseX > getRealLeft(CoolDrag.container))
                CoolDrag.cloneobj.style.left = (CoolDrag.cloneobj.initoffsetL +  currenX - CoolDrag.cloneobj.initMouseX) + "px";
            else
                CoolDrag.cloneobj.style.left = getRealLeft(CoolDrag.container) + "px";
            if(CoolDrag.cloneobj.initoffsetY +  currenY - CoolDrag.cloneobj.initMouseY > getRealTop(CoolDrag.container))
                CoolDrag.cloneobj.style.top = (CoolDrag.cloneobj.initoffsetY +  currenY - CoolDrag.cloneobj.initMouseY) + "px";
            else
                CoolDrag.cloneobj.style.top = getRealTop(CoolDrag.container) + "px";        var collection = CoolDrag.container.getElementsByTagName("DIV");
            var finded = false;
            for(var i = 0; i < collection.length; i++){
                var o = collection[i];
                if(o.className == "dragLayer"){
                    if(((getRealLeft(o) <= CoolDrag.cloneobj.offsetLeft &&  getRealLeft(o) + o.offsetWidth >= CoolDrag.cloneobj.offsetLeft) ||         
                    (getRealLeft(o) <= CoolDrag.cloneobj.offsetLeft + CoolDrag.cloneobj.offsetWidth &&
                    getRealLeft(o) + o.offsetWidth >= CoolDrag.cloneobj.offsetLeft + CoolDrag.cloneobj.offsetWidth)) &&
                       getRealTop(o) <= CoolDrag.cloneobj.offsetTop && getRealTop(o) + o.offsetHeight >= CoolDrag.cloneobj.offsetTop)
                    {
                        //window.status = getRealTop(o.parentNode)+"|"+(CoolDrag.cloneobj.offsetTop - 8);
                        if(getRealTop(o.parentNode) >= CoolDrag.cloneobj.offsetTop - 8){
                            o.parentNode.insertBefore(CoolDrag.obj,o);
                        }else{
                            if(o.nextSibling)
                                o.parentNode.insertBefore(CoolDrag.obj,o.nextSibling);
                            else
                                o.parentNode.appendChild(CoolDrag.obj);
                        }   
                        finded = true;
                        break;
                    }   
                }
            }        if(!finded){
                for(var i = 0; i < CoolDrag.container.childNodes.length; i++){
                    var o = CoolDrag.container.childNodes[i];
                    if(getRealLeft(o) <= CoolDrag.cloneobj.offsetLeft &&  getRealLeft(o) + o.offsetWidth >= CoolDrag.cloneobj.offsetLeft)
                        o.appendChild(CoolDrag.obj);
                }
            }
            with(CoolDrag.shadow.style){
                left = (CoolDrag.cloneobj.offsetLeft + 4) + "px";
                top = (CoolDrag.cloneobj.offsetTop + 4) + "px";
            }
            //document.title = CoolDrag.cloneobj.style.left + "|" + CoolDrag.shadow.style.left;
        },
       
        end:function(e){
            if(!CoolDrag.dragged)return;
            CoolDrag.obj.className = "dragLayer";
            CoolDrag.dragged = false;
            CoolDrag.shadow.parentNode.removeChild(CoolDrag.shadow);
            CoolDrag.timer = CoolDrag.repos(150,15);        //保存cookie
            var str="";
            for(var i=0; i<CoolDrag.container.childNodes.length; i++){
                var o = CoolDrag.container.childNodes[i];
                if(i>0)str += "|";
                str += o.id + ":";
                for(var j=0; j < o.childNodes.length; j++){
                    if(j>0)str += ",";
                    str += o.childNodes[j].id ;
                }
            }
            CoolDrag.save("cooldrag",str,24);    },
        repos:function(aa,ab){
            //var f=CoolDrag.obj.filters.alpha.opacity;
            var tl=getRealLeft(CoolDrag.cloneobj);
            var tt=getRealTop(CoolDrag.cloneobj);
            var kl=(tl-getRealLeft(CoolDrag.obj))/ab;
            var kt=(tt-getRealTop(CoolDrag.obj))/ab;
            //var kf=f/ab;
            return setInterval(function(){if(ab<1){
                                    clearInterval(CoolDrag.timer);
                                    CoolDrag.cloneobj.parentNode.removeChild(CoolDrag.cloneobj);
                                    CoolDrag.obj=null;
                                    return;
                                }
                            ab--;
                            tl-=kl;
                            tt-=kt;
                            //f-=kf;
                            CoolDrag.cloneobj.style.left=parseInt(tl)+"px";
                            CoolDrag.cloneobj.style.top=parseInt(tt)+"px";
                            //CoolDrag.tdiv.filters.alpha.opacity=f;
                        }
        ,aa/ab)
        },
        min:function(e){
            if(!e) e = window.event;
            var obj = getT(e);
            var rootObj = obj.parentNode.parentNode.parentNode;
            var id = rootObj.id;
            if(SavedObject.getStatus(id)[1]){   
                SavedObject.setStatus(id,0); 
                rootObj.style.height = "20px";
                rootObj.childNodes[1].style.display = 'none';   
            }else{
                SavedObject.setStatus(id,1); 
                rootObj.lastChild.style.display = '';   
                rootObj.style.height = SavedObject.getStatus(id)[2];
            }
            obj.innerHTML = obj.innerHTML==0 ? 2 :0;
        },    close:function(e){
            if(!e) e = window.event;
            var obj = getT(e);
            var rootObj = obj.parentNode.parentNode.parentNode;
            rootObj.parentNode.removeChild(rootObj);    },
        save:function(name, value, hours){
            var expire = "";
            if(hours != null)
            {
            expire = new Date((new Date()).getTime() + hours * 3600000);
            expire = "; expires=" + expire.toGMTString();
            }
            document.cookie = name  + "=" + escape(value) + expire;
        },
        read:function(name){
            var cookieValue = "";
            var search = name + "=";
            if(document.cookie.length > 0)
            {
            offset = document.cookie.indexOf(search);
            if (offset != -1)
            {
              offset += search.length;
              end = document.cookie.indexOf(";", offset);
              if (end == -1) end = document.cookie.length;
              cookieValue = unescape(document.cookie.substring(offset, end))
            }
            }
            return cookieValue;
        }
    }function $(id){
        return document.getElementById(id);
    }function getT(e){
        return e.target || e.srcElement;
    }function getMouseX(e){
        return e.pageX ? e.pageX : e.clientX + document.body.scrollLeft - document.body.clientLeft;
    }function getMouseY(e){
        return e.pageY ? e.pageY : e.clientY + document.body.scrollTop  - document.body.clientTop;
    }function getRealLeft(o){
        var l = 0;
        while(o){
            l += o.offsetLeft - o.scrollLeft;
            o = o.offsetParent;
        }
        return(l);
    }function getRealTop(o){
        var t = 0;
        while(o){
            t += o.offsetTop - o.scrollTop;
            o = o.offsetParent;
        }
        return(t);
    }function cleanWhitespace(node) {
         var notWhitespace = /\S/;
         for (var i=0; i < node.childNodes.length; i++) {
             var childNode = node.childNodes[i];
             if ((childNode.nodeType == 3)&&(!notWhitespace.test(childNode.nodeValue))) {
                 node.removeChild(node.childNodes[i]);
                 i--;
             }
             if (childNode.nodeType == 1) {
                 cleanWhitespace(childNode);
             }
         }
    }var SavedObject={
        elements : new Array(),
        setStatus : function(id,s){
            for(var i=0;i<SavedObject.elements.length;i++){
                if(SavedObject.elements[i][0]==id){
                    SavedObject.elements[i][1]=s;
                    break;
                }
            }
        },
        getStatus : function(id){
            for(var i=0;i<SavedObject.elements.length;i++){
                if(SavedObject.elements[i][0]==id)return SavedObject.elements[i];
            }
        },
        push : function(o){
            SavedObject.elements[SavedObject.elements.length]=o;
        }
    }
    </script>
    </head>
      

  3.   


    <body onLoad="CoolDrag.init('container');">
    <br />
    <div id="container">
    <div id="leftcontainer">
        <div style="height:100px; width:200px; " class="dragLayer" id="win1">
            <div class="dragHeader">
                <div style="float:left">第一个窗口</div>
                <div style="float:right; "><span class="min">0</span><span class="close">r</span></div>
            </div>
            <div class="content">window 1</div>
        </div>
        <div style="height:100px; width:200px; " class="dragLayer" id="win2">
            <div class="dragHeader">
                <div style="float:left">第二个窗口</div>
                <div style="float:right; "><span class="min">0</span><span class="close">r</span></div>
            </div>
            <div class="content">window 2</div>
        </div>
    </div>
    <div id="middlecontainer">
        <div style="height:100px; width:200px; " class="dragLayer" id="win3">
            <div class="dragHeader">
                <div style="float:left">第三个窗口</div>
                <div style="float:right; "><span class="min">0</span><span class="close">r</span></div>
            </div>
            <div class="content">window 3</div>
        </div>
        <div style="height:100px; width:200px; " class="dragLayer" id="win4">
            <div class="dragHeader">
                <div style="float:left">第四个窗口</div>
                <div style="float:right; "><span class="min">0</span><span class="close">r</span></div>
            </div>
            <div class="content">window 4</div>
        </div>
    </div>
    <div id="rightcontainer">
        <div style="height:100px; width:200px; " class="dragLayer" id="win5">
            <div class="dragHeader">
                <div style="float:left">第五个窗口</div>
                <div style="float:right; "><span class="min">0</span><span class="close">r</span></div>
            </div>
            <div class="content">window 5</div>
        </div>
        <div style="height:100px; width:200px; " class="dragLayer" id="win6">
            <div class="dragHeader">
                <div style="float:left">第六个窗口</div>
                <div style="float:right; "><span class="min">0</span><span class="close">r</span></div>
            </div>
            <div class="content">window 6</div>
        </div>
        <div style="height:100px; width:200px; " class="dragLayer" id="win7">
            <div class="dragHeader">
                <div style="float:left">第七个窗口</div>
                <div style="float:right; "><span class="min">0</span><span class="close">r</span></div>
            </div>
            <div class="content">window 7</div>
        </div>
    </div>
    </div>
    </body>
    </html>
      

  4.   

    楼主怎么连续发了4贴啊?应该最多3贴吧?
    帮你顶一下,优化接着说:)我自己的帖子早就顶不动了:http://hi.csdn.net/link.php?url=http://topic.csdn.net%2Fu%2F20100125%2F22%2Fc0c0a3bb-d7ab-43a1-b210-2b05ae1b1d97.html
      

  5.   

    我做过类似功能,只不过位置保存数据库中了。其实改起来也应该挺容易的,在进入页面后,重新load这些portlet的时候记住他们是否关闭,要一个重新绘制的过程就OK了。
      

  6.   

    save:function(name, value, hours){ 
            var expire = ""; 
            if(hours != null) 
            { 
            expire = new Date((new Date()).getTime() + hours * 3600000); 
            expire = "; expires=" + expire.toGMTString(); 
            } 
            document.cookie = name  + "=" + escape(value) + expire; 
        },
    没有设置保存路径?
      

  7.   

    http://files.cnblogs.com/wf5360308/DivDrag.rar
      

  8.   

    ASP.NET有类似的自定义控件,具体什么名字忘了
      

  9.   

    //完整的配置信息eg:
    var configJSON = [
    {
    tabId:'1',
    title:'我的首页',
    layoutId:'1',
    columns:[
    {
    columnId:'column1',
    width:'30%',
    widgets:[ 
    {
    id:'100306',
    title:'待办事项',
    url:'/sm/toBeDoneEventsAction.do?method=loadToBeDoneEventsMain',
    autoLoadFlag:false,
    object:''
    },{
    id:'100304',
    title:'我的通知',
    url:'/sm/sMBulletinAction.do?method=loadMyNoticeWidget',
    autoLoadFlag:true,
    object:''//小模块对应的jQuery DOM对象
    }
    ]
    },
    {
    columnId:'column2',
    width:'40%',
    widgets:[
    {
    id:'100308',
    title:'短信快速通道',
    autoLoadFlag:true,
    url:'/cm/messSendInfoAction.do?method=loadMyMessSendWidget',
    object:''
    }
    ]
    },
    {
    columnId:'column3',
    width:'30%',
    widgets:[
    {
    id:'100305',
    title:'客户卡片速查',
    autoLoadFlag:true,
    url:'/cm/messSendInfoAction.do?method=loadMyMessSendWidget',
    object:''
    }
    ]
    }
    ]
    },
    {
    tabId:'2',
    title:'我的信息',
    layoutId:'1',
    columns:[
    {
    columnId:'column1',
    width:'50%',
    widgets:[
    {
    id:'100305',
    title:'客户卡片速查',
    autoLoadFlag:true,
    url:'/sm/myUserCardAction.do?method=loadMyUserCardWidget',
    object:''
    },
    {
    id:'100309',
    title:'工作信息汇总',
    autoLoadFlag:true,
    url:'/cm/comTaskManageAction.do?method=loadMyWorkInfoWidget',
    object:''
    }
    ]
    },
    {
    columnId:'column2',
    width:'50%',
    widgets:[
    {
    id:'100308',
    title:'短信快速通道',
    autoLoadFlag:true,
    url:'/cm/messSendInfoAction.do?method=loadMyMessSendWidget',
    object:''
    }
    ]
    }
    ]
    }
    ];
      

  10.   

    /**
     * 首页定制布局数据集控制类
     */
    var DataController = Class.create();DataController.prototype = {
    /**
     * 初始化
     */
    initialize:function(){ 
    this.data = new Array();
    },
    /**
     * 增加标签数据
     * @param tabId:标签标示
     * @param tabTitle:标签名称
     * @param layoutId:布局标识
     */
    addTab:function(tabId,tabTitle,layoutId){
    this.data.push({
    tabId:tabId,
    title:tabTitle, 
    layoutId:layoutId,
    columns:[]
    });
    },
    /**
     * 为指定标签页下增加布局
     * @param tabId:指定标签标示
     * @param columnId:新增布局列ID
     * @param width:新增布局列宽度百分比
     */
    addLayout:function(tabId,columnId,width){
    /**获取指定标签ID的标签JSON对象*/
    var el=this.getTabObject(tabId);
    /**获取标签JSON对象的columns的值*/
    var columns= el.columns;
    /**为它增加新的列数据*/
    columns.push({
    columnId:columnId,
    width:width,
    widgets:[]
    }); 
    },
    /**
     * 往指定标签页中指定布局列中新增控件
     * @param tabId:指定标签
     * @param columnId:指定布局列
     * @param widgetId:新增的模块标示
     * @param widgetTitle:新增的模块标题 
     * @param widgetURI:新增的模块URL
     * @param autoLoadFlag:是否默认加载
     */
    addWidget:function(tabId,columnId,widgetId,widgetTitle,widgetURI,autoLoadFlag){
    /**获取指定列的JSON对象*/
    var e = this.getLayoutColumnObject(tabId,columnId);
    /**追加到新的小模块*/
    e.widgets.push({
    id:widgetId,
    title:widgetTitle,
    url:widgetURI,
    object:'',
    columnId:columnId,
    autoLoadFlag:autoLoadFlag,//是否自动加载
    loadFlag:false//是否加载到UI,默认为否
    });
    },
    /**
     * 在指定标签下批量追加小模块
     * @param tabId:指定标签页
     * @param data:[{}]小模块JSON数组
     */
    batchAddWidgets:function(tabId,data){
    var _this = this;
    data.each(function(widget,index){
    var widgetId = widget.id;
    var widgetTitle = widget.title;
    var widgetURI = widget.url;
    var columnId = widget.columnId;
    var autoLoadFlag = widget.autoLoadFlag;
    _this.addWidget(tabId,columnId,widgetId,widgetTitle,widgetURI,autoLoadFlag);
    });
    },
    /**
     * 获取指定标签对象
     * @param tabId:指定的标签标示
     */
    getTabObject:function(tabId){
    var el=this.data.detect(function(tab,index){
    return tab.tabId == tabId;
    });
    return el;
    },
    /**
     * 获取指定标签下的布局列JSON数组
     */
    getLayoutColumns:function(tabId){
    /**获取指定标签JSON对象*/
    var e = this.getTabObject(tabId); 
    /**获取指定布局列数组*/
    return e.columns;
    },
    /**
     * 获取指定布局列的JSON对象
     * @param tabId:指定标签
     * @param colunmId:指定布局列
     */
    getLayoutColumnObject:function(tabId,colunmId){
    /**获取指定标签JSON对象*/
    var e = this.getLayoutColumns(tabId);
    /**获取指定布局列*/
    var el= e.detect(function(column,index){ 
    return column.columnId == colunmId;
    });
    return el;
    },
    /**
     * 获取指定标签页下指定列的小模块信息
     * @param tabId:指定标签标识
     * @param columnId:指定列标识
     */
    getWidgets:function(tabId,columnId){ 
    var e = this.getLayoutColumnObject(tabId,columnId);
    e.widgets.each(function(w,index){
    w.columnId = columnId; 
    });
    return e.widgets;
    },
    /**
     * 获取指定标签页下的所有小模块信息
     * @param tabId:指定标签标识
     */
    getAllWidgets:function(tabId){
    var _this = this;
    /**1.获取所有列信息*/
    var e = this.getLayoutColumns(tabId); 
    /**2.循环列信息,找出列对应的小模块*/
    var widgets= new Array();
    e.each(function(el,index){
    widgets.push(_this.getWidgets(tabId,el.columnId));
    });
    return widgets.flatten();
    },
    /**
     * 从指定标签页中获取指定的小模块
     * @param tabId:指定的标签页
     * @param widgetId:指定的小模块
     */
    getWidgetObject:function(tabId,widgetId){
    /**获取指定标签JSON对象*/
    var e = this.getTabObject(tabId);
    var el;
    /**循环所有列,找到当前的指定的小模块对象*/
    e.columns.each(function(column,index){
    el=column.widgets.detect(function(widget,index){
    return widget.id == widgetId;
    });
    if(el){
    throw $break;
    }
    }); 
    return el;
    },
    /**
     * 判断指定的小模块是否已经存在配置中
     * @param widgetId:指定小模块
     */
    validateWidget:function(widgetId){
    var _this = this;
    var exist = false;
    _this.data.each(function(tab,index){
    var e = _this.getWidgetObject(tab.tabId,widgetId);
    if(e){
    exist =true;
    throw $break;
    }
    });
    return exist;
    },
    /**
     * 获取指定标签中的指定key值
     * @param tabId:指定标签标识
     * @param key:指定key值
     */
    get:function(tabId,key){
    var e = this.getTabObject(tabId);
    return e[key];
    },
    /**
     * 设定指定标签中的指定key的指定value值
     * @param tabId:指定标签标识
     * @param key:指定key值
     * @param value:新设定值
     */
    set:function(tabId,key,value){
    var e = this.getTabObject(tabId);
    e[key] = value;
    }, 
    /**
     * 获取指定标签页下指定列中指定key的值
     * @param tabId:指定标签页
     * @param columnId:指定列
     * @param key:指定键值
     */
    getColumn:function(tabId,columnId,key){
    var e = this.getLayoutColumnObject(tabId,columnId);
    return e[key];
    },
    /**
     * 设定指定标签页下指定列中指定key的值
     * @param tabId:指定标签页
     * @param columnId:指定列
     * @param key:指定键值
     * @param value:设定值
     */
    setColumn:function(tabId,columnId,key,value){
    var e = this.getLayoutColumnObject(tabId,columnId);
    e[key]=value;
    },
    /**
     * 获取指定标签页下指定小模块的指定key的值
     * @param tabId:指定标签
     * @param widgetId:指定小模块
     * @param key:指定键值
     */
    getWidget:function(tabId,widgetId,key){
    var e = this.getWidgetObject(tabId,widgetId);
    return e[key];
    },
    /**
     * 获取指定标签页下指定小模块的指定key的值
     * @param tabId:指定标签
     * @param widgetId:指定小模块
     * @param key:指定键值
     * @param value:设定值
     */
    setWidget:function(tabId,widgetId,key,value){
    var e = this.getWidgetObject(tabId,widgetId);
    e[key] = value;
    },
    /**
     * 移动模块
     * 将模块JSON数据插入到指定列的指定位置上,同时删除原有位置的对象
     * @param activityTabId:当前活动的标签
     * @param activityWidgetId:当前移动的模块标示
     * @param targetColumnId:移动到的目标列标识
     * @param postion:移动到的目标列的位置
     */
    moveWidget:function(activityTabId,activityWidgetId,targetColumnId,position){
    var tab=this.getTabObject(activityTabId);
    /**首先从当前布局中查找到活动的小模块*/
    var e = this.getWidgetObject(activityTabId,activityWidgetId);
    /**将小模块从原有列中删除掉*/
    tab.columns.each(function(column,index){
    var widgets = column.widgets;
    var index = widgets.indexOf(e); 
    if(index!=-1)
    widgets.splice(index, 1); 
    });
    /**将小模块保存到模板列的指定位置*/
    var el = this.getLayoutColumnObject(activityTabId,targetColumnId);
    e.columnId = targetColumnId;
    el.widgets.splice(position,0,e);
    },
    /**
     * 将小模块转移到目标标签页中的默认位置
     * @param activityTabId:当前活动的标签
     * @param activityWidgetId:当前移动的模块标示
     * @param targetTabId:目标标签页
     */
    moveWidgetToTargetTab:function(activityTabId,activityWidgetId,targetTabId){
    var tab=this.getTabObject(activityTabId);
    /**首先从当前布局中查找到活动的小模块*/
    var e = this.getWidgetObject(activityTabId,activityWidgetId);
    /**将小模块从原有列中删除掉*/
    tab.columns.each(function(column,index){
    var widgets = column.widgets;
    var index = widgets.indexOf(e); 
    if(index!=-1)
    widgets.splice(index, 1); 
    });
    /**将小模块保存到模板列的指定位置*/
    var targetColumnId = this.getFirstColumn(targetTabId).columnId;
    var el = this.getLayoutColumnObject(targetTabId,targetColumnId);
    e.columnId = targetColumnId;
    el.widgets.splice(0,0,e);
    },
    /**
     * 批量将源列中的所有小模块全部转移到目标列中
     * @param tabId:指定标签
     * @param srcColumnId:源列
     * @param descColumnId:目标列
     */
    moveWidgets:function(tabId,srcColumnId,descColumnId){
    /**1.获取指定列下的所有小模块*/
    var widgets = this.getWidgets(tabId,srcColumnId);
    /**2.将这些小模块追加到指定列中去*/
    var el = this.getLayoutColumnObject(tabId,descColumnId);
    widgets.each(function(e,index){
    e.columnId = descColumnId;
    el.widgets.push(e);
    });
    /**3.清空指定列中的所有小模块*/
    widgets.clear();
    },
    /**
     * 删除指定标签页下的指定小模块
     * @param activityWidgetId:当前活动的小模块标示
     * @param tabId:指定的标签
     */
    deleteWidget:function(activityWidgetId,tabId){
    /*1.获取当前被删除的小模块*/
    var e = this.getWidgetObject(tabId,activityWidgetId);
    /*2.获取当前标签信息*/
    var tab=this.getTabObject(tabId);
    /*3.从标签布局中查找到小模块信息,并删除*/
    tab.columns.each(function(column,index){
    var widgets = column.widgets;
    var index = widgets.indexOf(e); 
    if(index!=-1)
    widgets.splice(index, 1); 
    });
    },
    /**
     * 删除指定标签布局中的指定列
     * @param tabId:指定标签
     * @param columnId:指定列
     */
    deleteColumn:function(tabId,columnId){
    /**1.根据标签获取列数组信息*/
    var e = this.getLayoutColumns(tabId);
    /**2.获取指定列*/
    var el = this.getLayoutColumnObject(tabId,columnId)
    /**3.查找并删除*/
    var index = e.indexOf(el);
    if(index!=-1)e.splice(index,1);
    },
    /**
     * 将指定标签下的列转换成hashTable
     * @param tabId:指定标签
     */
    columnToHash:function(tabId){
    var hashTable = new Hashtable();
    /**1.获取所有列信息*/
    var e = this.getLayoutColumns(tabId);
    /**2.循环所有列,将其转成hashTable*/
    e.each(function(el,index){
    hashTable.add(el.columnId,el);
    });
    return hashTable;
    },
    /**
     * 获取指定标签页下的第一列
     */
    getFirstColumn:function(tabId){
    /**1.获取所有列信息*/
    var e = this.getLayoutColumns(tabId);
    /**2.获取第一列*/
    return e.first();
    },
    /**
     * 删除指定的标签
     * @param tabId:指定的标签
     */
    deleteTab:function(tabId){
    /**1.首先查找当前标签信息*/
    var e = this.getTabObject(tabId);
    /**2.查找标签在数据集合中的位置*/
    var index = this.data.indexOf(e);
    /**3.如果能找到,则删除*/
    if(index!=-1)this.data.splice(index,1);
    },
    /**
     * 将JSON数组其转变成字符串
     */
    stringify:function(){
    var string =JSON.stringify(this.data);
    return string;
    }
    };/**
     * 布局数据控制类
     * 用来存储和处理布局信息.
     * 单个布局JSON描述:
     * var LayoutJSON = {
     * layoutId:'1',
     * columns:[{
     * columnId:'column1',
     * width:'50%'
     * },{
     * columnId:'column2',
     * width:'50%'
     * }]
     *}
     * @author zhangchao
     */
      

  11.   

    var DataLayoutController = Class.create();DataLayoutController.prototype = {
    /**
     * 初始化
     */
    initialize:function(){
    this.data = new Array();
    },
    /**
     * 创建布局数据
     * @param layoutId:布局标识
     */
    add:function(layoutId){
    /**1.首先查找是否已经存在*/
    var e = this.get(layoutId);
    /**2.如果已经存在,则不增加*/
    if(e)return;
    /**3.如果不存在,则新增*/
    this.data.push({
    layoutId:layoutId,
    columns:[]
    });
    },
    /**
     * 获取布局数据
     * @param layoutId:布局标识
     */
    get:function(layoutId){
    var el=this.data.detect(function(option,index){
    return option.layoutId == layoutId;
    });
    return el;
    },
    /**
     * 新增布局列
     * @param layoutId:指定标签
     * @param columnId:指定列
     * @param width:列框
     */
    addColumn:function(layoutId,columnId,width){
    /**1.判断指定列是否已经存在*/
    var el = this.getColumn(layoutId,columnId);
    if(el)return;
    /**2.查找布局信息*/
    var e = this.get(layoutId);
    /**3.为布局列数组新增布局列*/
    e.columns.push({
    columnId:columnId,
    width:width
    });
    },
    /**
     * 从指定标签中查找指定列
     * @param layoutId:指定标签
     * @param columnId:指定列
     */
    getColumn:function(layoutId,columnId){
    /**1.查找布局信息*/
    var e = this.get(layoutId);
    /**2.遍历布局列信息,查找指定列*/
    var el=e.columns.detect(function(option,index){
    return option.columnId==columnId;
    });
    return el;
    },
    /**
     * 获取指定布局的指定列的指定属性
     * @param layoutId:指定布局
     * @param columnId:指定列
     * @param key:指定键值
     */
    getColumnValue:function(layoutId,columnId,key){
    /**1.获取指定列*/
    var e = this.getColumn(layoutId,columnId);
    return e[key];
    },
    /**
     * 将指定布局的列转成hashtable
     * @param layoutId:布局标识
     */
    columnToHash:function(layoutId){
    var hashTable = new Hashtable();
    /**1.查找布局信息*/
    var e = this.get(layoutId);
    /**2.循环列,转换成hashtable*/
    e.columns.each(function(el,index){
    hashTable.add(el.columnId,el);
    });
    return hashTable;
    },
    /**
     * 将JSON数组其转变成字符串
     */
    stringify:function(){
    var string =JSON.stringify(this.data);
    return string;
    }
    }/**
     * 消息控制类
     * 主要用于显示保存布局消息
     */
    var NoticeController = Class.create();NoticeController.prototype = {
    /**
     * 初始化
     */
    initialize:function(){
     
    },
    /**
     * 显示消息框
     */
    show:function(){   
    jQuery("#ui-notice-container").show();
    },
    /**
     * 隐藏消息框
     */
    hide:function(){
    jQuery("#ui-notice-container").hide();
    }
    }/**
     * 自定义HaskTable类
     * 调用方式:var hashTable = new Hashtable();hashTable.add(key,value);
     */
    var Hashtable = function(){
    this._hash = new Object();
    /**将key,value键值对存入hashTable*/
    this.add = function(key,value){
    if(typeof(key)!="undefined"){
    if(this.contains(key)==false){
    this._hash[key]=typeof(value)=="undefined"?null:value;
    return true;
    } else{
    return false;
    }
    } else{
    return false;
    }
    }
    /**从hashTable中移除指定key值的对象*/
    this.remove = function(key){
    delete this._hash[key];
    }
    /**统计hashTable中对象的个数*/
    this.count = function(){
    var i=0;
    for(var k in this._hash){
    i++;

    return i;
    }
    /**根据键值获取指定的key值的对象*/
    this.items = function(key){
    return this._hash[key];
    }
    /**判断hashTable中是否已经包含指定键值*/
    this.contains = function(key){ 
    return typeof(this._hash[key])!="undefined";
    }
    /**删除hashTable中所有对象*/
    this.clear = function(){
    for(var k in this._hash){
    delete this._hash[k];
    }
    }
    /**将HashTable转换成数组*/
    this.toArray = function(){
    var array = new Array();
    for(var k in this._hash){
    array.push(this._hash[k]);
    }
    return array;
    }
    /**将HashTable中的key值转换成数组*/
    this.keyToArray = function(){
    var array = new Array();
    for(var k in this._hash){
    array.push(k);
    }
    return array;
    }
    } ; 
      

  12.   

    to:choaryzhang  能给个完整的示例吗,先谢了