(function ($, zou) { "use strict"; //初始化菜单和tab页的属性Id var iframeIdList = {}; zou.frameTab = { iframeId: '', init: function () { zou.frameTab.bind(); }, bind: function () { $(".z-frame-tabs-wrap").mCustomScrollbar({ // 优化滚动条 axis: "x", theme: "minimal-dark" }); }, setCurrentIframeId: function (iframeId) { zou.iframeId = iframeId; }, open: function (module, notAllowClosed) { var $tabsUl = $('#lr_frame_tabs_ul'); var $frameMain = $('#lr_frame_main'); if (iframeIdList[module.F_ModuleId] == undefined || iframeIdList[module.F_ModuleId] == null) { // 隐藏之前的tab和窗口 if (zou.frameTab.iframeId != '') { $tabsUl.find('#lr_tab_' + zou.frameTab.iframeId).removeClass('active'); $frameMain.find('#lr_iframe_' + zou.frameTab.iframeId).removeClass('active'); iframeIdList[zou.frameTab.iframeId] = 0; } var parentId = zou.frameTab.iframeId; zou.frameTab.iframeId = module.F_ModuleId; iframeIdList[zou.frameTab.iframeId] = 1; // 打开一个功能模块tab_iframe页面 var $tabItem = $('
  •  ' + module.F_FullName + '
  • '); if (!notAllowClosed) { $tabItem.append(''); } var $iframe = $(''); $tabsUl.append($tabItem); $frameMain.append($iframe); $(".z-frame-tabs-wrap").mCustomScrollbar("update"); $(".z-frame-tabs-wrap").mCustomScrollbar("scrollTo", $tabItem); //绑定一个点击事件 $tabItem.on('click', function () { var id = $(this).attr('id').replace('lr_tab_', ''); zou.frameTab.focus(id); }); $tabItem.find('.reomve').on('click', function () { var id = $(this).parent().attr('id').replace('lr_tab_', ''); zou.frameTab.close(id); return false; }); if (!!zou.frameTab.opencallback) { zou.frameTab.opencallback(); } if (!notAllowClosed) { $.ajax({ url: top.$.rootUrl + "/Home/VisitModule", data: { moduleName: module.F_FullName, moduleUrl: module.F_UrlAddress }, type: "post", dataType: "text" }); } } else { zou.frameTab.focus(module.F_ModuleId); } }, focus: function (moduleId) { if (iframeIdList[moduleId] == 0) { // 定位焦点tab页 $('#lr_tab_' + zou.frameTab.iframeId).removeClass('active'); $('#lr_iframe_' + zou.frameTab.iframeId).removeClass('active'); iframeIdList[zou.frameTab.iframeId] = 0; $('#lr_tab_' + moduleId).addClass('active'); $('#lr_iframe_' + moduleId).addClass('active'); zou.frameTab.iframeId = moduleId; iframeIdList[moduleId] = 1; $(".z-frame-tabs-wrap").mCustomScrollbar("scrollTo", $('#lr_tab_' + moduleId)); if (!!zou.frameTab.opencallback) { zou.frameTab.opencallback(); } } }, leaveFocus: function () { $('#lr_tab_' + zou.frameTab.iframeId).removeClass('active'); $('#lr_iframe_' + zou.frameTab.iframeId).removeClass('active'); iframeIdList[zou.frameTab.iframeId] = 0; zou.frameTab.iframeId = ''; }, close: function (moduleId) { delete iframeIdList[moduleId]; var $this = $('#lr_tab_' + moduleId); var $prev = $this.prev();// 获取它的上一个节点数据; if ($prev.length < 1) { $prev = $this.next(); } $this.remove(); $('#lr_iframe_' + moduleId).remove(); if (moduleId == zou.frameTab.iframeId && $prev.length > 0) { var prevId = $prev.attr('id').replace('lr_tab_', ''); $prev.addClass('active'); $('#lr_iframe_' + prevId).addClass('active'); zou.frameTab.iframeId = prevId; iframeIdList[prevId] = 1; $('.z-frame-tabs').css('width', '10000px'); $(".z-frame-tabs-wrap").mCustomScrollbar("update"); $('.z-frame-tabs').css('width', '100%'); $(".z-frame-tabs-wrap").mCustomScrollbar("scrollTo", $prev); } else { if ($prev.length < 1) { zou.frameTab.iframeId = ""; } $('.z-frame-tabs').css('width', '10000px'); $(".z-frame-tabs-wrap").mCustomScrollbar("update"); $('.z-frame-tabs').css('width', '100%'); } if (!!zou.frameTab.closecallback) { zou.frameTab.closecallback(); } } // 获取当前窗口 ,currentIframe: function () { var ifameId = 'lr_iframe_' + zou.frameTab.iframeId; if (top.frames[ifameId].contentWindow != undefined) { return top.frames[ifameId].contentWindow; } else { return top.frames[ifameId]; } } ,parentIframe: function () { var ifameId = 'lr_iframe_' + top.$('#lr_tab_'+zou.frameTab.iframeId).attr('parent-id'); if (top.frames[ifameId].contentWindow != undefined) { return top.frames[ifameId].contentWindow; } else { return top.frames[ifameId]; } } , opencallback: false , closecallback: false }; zou.frameTab.init(); })(window.jQuery, top.zou);