首页 > 其他 > 详细

Easyui 生成layout

时间:2015-01-23 13:12:54      阅读:302      评论:0      收藏:0      [点我收藏+]

Easyui 生成layout 

var $tabs;

var $body;

var $south;

function appendLayout(title, href) {

    if (!$body)
        $body = $(document.body);

    if (!$body.hasClass(‘layout‘)) {

        var $centerHtml = $("<div>", {

            "id": "center",

            "style": "height:‘100%‘,overflow:auto",

            "data-options": "region:‘center‘,split:true,collapsible:true"

        });

        $body.children().wrapAll($centerHtml); // 页面上的内容用 easyui layout center 包住

        $tabs = $("<div>", {

            "id": ‘tabs‘,

            "data-options": "tools:‘#tab-tools‘"

        });

        $south = $("<div>", {

            "id": "south",

            "style": "height:280px;",

            "data-options": "region:‘south‘,split:true"

        }).append($tabs);

        var aBtn = $("<a>", {

            ‘style‘: ‘‘,

            "href": "javascript:void(0);",

            ‘class‘: ‘layout-button-down‘

        });

        var tools = $("<div>", {

            ‘id‘: ‘tab-tools‘,

            ‘class‘: ‘panel-tool‘

        }).append(aBtn);

        $body.append($south).append(tools).layout();

        aBtn.on(‘click‘, function () {

            closeLayout(true);

        });

        $tabs.tabs({

            fit: true,

            border: false,

            onClose: function (title, index) {

                var num = $(this).tabs(‘tabs‘).length;

                if (num == 0)//所有的tab 都关闭时隐藏面板
                {
                    closeLayout();
                }

            }
        });

        $south.data(‘isExpand‘, true);
    }

    addTab(title, 1, href, null);

}


function addTab(title, id, href, text) {

    if (!$south.data(‘isExpand‘)) {
        openLayout();
    }
    var key = title + "<a  style=‘display:none‘>" + id + "</a>"
    if ($tabs.tabs(‘exists‘, key)) {
        $tabs.tabs(‘select‘, key);
    }
    else {
        var html;
        if (text) {
            html = text;
        }
        else {
            html = ‘<iframe id="zlifm-‘ + id + ‘" src="‘ + href + ‘" width="100%" height="100%" class="main-content-itme"  frameborder="0"  style="border:0px; margin-bottom:-20px"   />‘;
        }
        $tabs.tabs("add", { title: key, content: html, closable: true });
    }
}

function closeAllTab() {

    var tts = $tabs.tabs("tabs");

    var arr = new Array();

    for (var i = 0; i < tts.length; i++) {
        arr.push(tts[i].panel("options").title);
    }
    for (var i = 0; i < arr.length; i++) {
        $tabs.tabs("close", arr[i]);
    }
}

//打开面板
function openLayout() {
    if (!$south.data(‘isExpand‘))
        $body.layout(‘expand‘, ‘south‘);
    $south.data(‘isExpand‘, true);
}

//关闭面板
function closeLayout(close) {

    var isExpand = $south.data(‘isExpand‘) || !!close;

    if (isExpand)
        $body.layout(‘collapse‘, ‘south‘);

    $south.data(‘isExpand‘, !isExpand);
}

 

Easyui 生成layout

原文:http://www.cnblogs.com/klausWang/p/Eayui_layout.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!