Zhiqim Console(管理控制台)是知启蒙框架中最简洁的管理控制台组件,没有数据库,只保留一个账号,非常适用于后端程序嵌入WEB控制台模式,包括首页、登录、主界面、左侧菜单和欢迎页功能,依赖该组件实现基本的账号验证,通过覆盖原则增加自有功能。

森中灵 最后提交于19天前 替换lib
elegant_20190528.js3KB
/*
 * 版权所有 (C) 2015 知启蒙(ZHIQIM) 保留所有权利。[遇见知启蒙,邂逅框架梦]
 * 
 * https://zhiqim.org/project/zhiqim_components/zhiqim_console.htm
 *
 * Zhiqim Console is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *          http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */
+(function(Z)
{//BEGIN

/**************************************************/
//定义全局的对象,便于所有的页面调用
/**************************************************/
var Zmr = window.Zmr = {};

Zmr.containerFrame = function()
{//框架主页容器全屏(topnav高度55,iframenav高度40)
    var height = Z(document).clientHeight();
    Z("#container").css("height", height-55);
    Z("#mainbody").css("height", height-55-40);
};

Zmr.containerInclude = function()
{//框架内容器最小高度为全屏
    var height = Z(document).clientHeight();
    Z("#container-include").css("min-height", height);
};

Zmr.sidebar = function()
{//边导航打开&关闭
    var $sidebar = Z("#sidebar");
    if ($sidebar.isHide())
    {
        $sidebar.show();
        Z("#logo").show();
        Z("#iframenav").css("margin-left", 201);
        Z("#mainbody").css("margin-left", 201);
    }
    else
    {
        $sidebar.hide();
        Z("#logo").hide();
        Z("#iframenav").css("margin-left", 0);
        Z("#mainbody").css("margin-left", 0);
    }
    
    Z.ajax("sessionUser", "setSidebar").addParam(!$sidebar.isHide()).execute();
};

Zmr.iframenav = function(elem, url)
{//标签导航页选中
    var nav = parent.Z("li[onclick*='"+url+"']");
    if (nav.length == 0)
    {//再查topnaviframe
        nav = parent.Z("#topnaviframe div[onclick*='"+url+"']");
    }

    if (nav.length == 0)
    {//菜单和标签都没有,则增加到标签中
        var $elem = Z(elem);
        var clickText = $elem.attr("data-text") || $elem.text() || "未命名";
        url = Z.rootPath(parent.Z.cp, url);
        nav = parent.Z("<div onclick='Zin.doClickChildMenu(this, \""+url+"\");' data-text='"+clickText+"'></div>").appendTo("#topnaviframe")
    }
    
    nav.click();
};

Zmr.iframenavF5 = function(isWelcome, includeUrl)
{//标签导航页刷新恢复
    if (isWelcome)
        return;
        
    var $elem = Z(".onloadmenu");
    if ($elem.length > 0)
    {//用于在浏览器上点刷新回到当前打开的页面
        Zin.doClickChildMenu($elem[0], includeUrl);
    }
};

Zmr.tabnavmain = function()
{//主导航缩放
    var height = Z(".z-tabnav-main").scrollHeight();
    if (height <= 50)
    {//正常
        Z(".z-tabnav-main").css("margin-bottom", height-30);
        Z(".z-tabnav-main .z-float-right").addClass("z-mg-r5");
    }
    else
    {//换行
        Z(".z-tabnav-main").css("margin-bottom", height-45);
        Z(".z-tabnav-main .z-float-right").removeClass("z-mg-r5");
    }
};

Zmr.treeExpand = function(code)
{//树菜单展开和关闭
    var $menu = Z("#menu-"+code);
    var $ico = Z("#ico-"+code);
    
    if (!$menu.isHide())
    {
        $menu.hide();
        if ($ico.hasClass("z-mlastnode"))
            $ico.removeClass("z-mlastnode").addClass("z-plastnode");
        else
            $ico.removeClass("z-mnode").addClass("z-pnode");
    }
    else
    {
        $menu.show();
        if ($ico.hasClass("z-plastnode"))
            $ico.removeClass("z-plastnode").addClass("z-mlastnode");
        else
            $ico.removeClass("z-pnode").addClass("z-mnode");
    }
};

//END
})(zhiqim);