var Layout=function(){var layoutImgPath=sys_theme+"layouts/layout/img/";var layoutCssPath=sys_theme+"layouts/layout/css/";var resBreakpointMd=App.getResponsiveBreakpoint("md");var handleSidebarAndContentHeight=function(){var content=$(".page-content");var sidebar=$(".page-sidebar");var body=$("body");var height;if(body.hasClass("page-footer-fixed")===true&&body.hasClass("page-sidebar-fixed")===false){var available_height=App.getViewPort().height-$(".page-footer").outerHeight()-$(".page-header").outerHeight();if(content.height() a").each(function(){var path=$(this).attr("href").toLowerCase();if(path.length>1&&url.substr(1,path.length-1)==path.substr(1)){el=$(this);return}})}}if(!el||el.size()==0){return}if(el.attr("href").toLowerCase()==="javascript:;"||el.attr("href").toLowerCase()==="#"){return}var slideSpeed=parseInt(menu.data("slide-speed"));var keepExpand=menu.data("keep-expanded");menu.find("li.active").removeClass("active");menu.find("li > a > .selected").remove();if(menu.hasClass("page-sidebar-menu-hover-submenu")===false){menu.find("li.open").each(function(){if($(this).children(".sub-menu").size()===0){$(this).removeClass("open");$(this).find("> a > .arrow.open").removeClass("open")}})}else{menu.find("li.open").removeClass("open")}el.parents("li").each(function(){$(this).addClass("active");$(this).find("> a > span.arrow").addClass("open");if($(this).parent("ul.page-sidebar-menu").size()===1){$(this).find("> a").append('')}if($(this).children("ul.sub-menu").size()===1){$(this).addClass("open")}});if(mode==="click"){if(App.getViewPort().width a.nav-toggle, li > a > span.nav-toggle",function(e){var that=$(this).closest(".nav-item").children(".nav-link");if(App.getViewPort().width>=resBreakpointMd&&!$(".page-sidebar-menu").attr("data-initialized")&&$("body").hasClass("page-sidebar-closed")&&that.parent("li").parent(".page-sidebar-menu").size()===1){return}var hasSubMenu=that.next().hasClass("sub-menu");if(App.getViewPort().width>=resBreakpointMd&&that.parents(".page-sidebar-menu-hover-submenu").size()===1){return}if(hasSubMenu===false){if(App.getViewPort().width a").on("click",function(e){if(App.getViewPort().width a.ajaxify",function(e){e.preventDefault();App.scrollTop();var url=$(this).attr("href");var menuContainer=$(".page-sidebar ul");var pageContent=$(".page-content");var pageContentBody=$(".page-content .page-content-body");menuContainer.children("li.active").removeClass("active"); menuContainer.children("arrow.open").removeClass("open");$(this).parents("li").each(function(){$(this).addClass("active");$(this).children("a > span.arrow").addClass("open")});$(this).parents("li").addClass("active");if(App.getViewPort().width li.open > a").click()}App.stopPageLoading();pageContentBody.html(res);Layout.fixContentHeight();App.initAjax()},error:function(xhr,ajaxOptions,thrownError){App.stopPageLoading();pageContentBody.html("

404 页面不存在!

")}})});$(".page-content").on("click",".ajaxify",function(e){e.preventDefault();App.scrollTop();var url=$(this).attr("href");var pageContent=$(".page-content");var pageContentBody=$(".page-content .page-content-body");App.startPageLoading();if(App.getViewPort().widthCould not load the requested content.");App.stopPageLoading()}})});$(document).on("click",".page-header-fixed-mobile .page-header .responsive-toggler",function(){App.scrollTop()});handleFixedSidebarHoverEffect();$(".page-sidebar").on("click",".sidebar-search .remove",function(e){e.preventDefault();$(".sidebar-search").removeClass("open")});$(".page-sidebar .sidebar-search").on("keypress","input.form-control",function(e){if(e.which==13){$(".sidebar-search").submit();return false}});$(".sidebar-search .submit").on("click",function(e){e.preventDefault();if($("body").hasClass("page-sidebar-closed")){if($(".sidebar-search").hasClass("open")===false){if($(".page-sidebar-fixed").size()===1){$(".page-sidebar .sidebar-toggler").click()}$(".sidebar-search").addClass("open")}else{$(".sidebar-search").submit()}}else{$(".sidebar-search").submit()}});if($(".sidebar-search").size()!==0){$(".sidebar-search .input-group").on("click",function(e){e.stopPropagation()});$("body").on("click",function(){if($(".sidebar-search").hasClass("open")){$(".sidebar-search").removeClass("open")}})}};var _calculateFixedSidebarViewportHeight=function(){var sidebarHeight=App.getViewPort().height-$(".page-header").outerHeight(true);if($("body").hasClass("page-footer-fixed")){sidebarHeight=sidebarHeight-$(".page-footer").outerHeight()}return sidebarHeight};var handleFixedSidebar=function(){var menu=$(".page-sidebar-menu");App.destroySlimScroll(menu);if($(".page-sidebar-fixed").size()===0){handleSidebarAndContentHeight();return}if(App.getViewPort().width>=resBreakpointMd){menu.attr("data-height",_calculateFixedSidebarViewportHeight());App.initSlimScroll(menu);handleSidebarAndContentHeight()}};var handleFixedSidebarHoverEffect=function(){var body=$("body");if(body.hasClass("page-sidebar-fixed")){$(".page-sidebar").on("mouseenter",function(){if(body.hasClass("page-sidebar-closed")){$(this).find(".page-sidebar-menu").removeClass("page-sidebar-menu-closed")}}).on("mouseleave",function(){if(body.hasClass("page-sidebar-closed")){$(this).find(".page-sidebar-menu").addClass("page-sidebar-menu-closed")}})}};var handleSidebarToggler=function(){var body=$("body");if(body.attr("index")!="nheader"&&$.cookie&&$.cookie("sidebar_closed")==="1"&&App.getViewPort().width>=resBreakpointMd){$("body").addClass("page-sidebar-closed");$(".page-sidebar-menu").addClass("page-sidebar-menu-closed")}$("body").on("click",".sidebar-toggler",function(e){var sidebar=$(".page-sidebar");var sidebarMenu=$(".page-sidebar-menu");$(".sidebar-search",sidebar).removeClass("open");if(body.hasClass("page-sidebar-closed")){body.removeClass("page-sidebar-closed");sidebarMenu.removeClass("page-sidebar-menu-closed");if($.cookie){$.cookie("sidebar_closed","0")}}else{body.addClass("page-sidebar-closed");sidebarMenu.addClass("page-sidebar-menu-closed");if(body.hasClass("page-sidebar-fixed")){sidebarMenu.trigger("mouseleave")}if($.cookie){$.cookie("sidebar_closed","1")}}})};var handleHorizontalMenu=function(){$(".page-header").on("click",'.hor-menu a[data-toggle="tab"]',function(e){e.preventDefault();var nav=$(".hor-menu .nav");var active_link=nav.find("li.current");$("li.active",active_link).removeClass("active");$(".selected",active_link).remove();var new_link=$(this).parents("li").last();new_link.addClass("current");new_link.find("a:first").append('')});$(".page-header").on("click",".search-form",function(e){$(this).addClass("open");$(this).find(".form-control").focus();$(".page-header .search-form .form-control").on("blur",function(e){$(this).closest(".search-form").removeClass("open");$(this).unbind("blur") })});$(".page-header").on("keypress",".hor-menu .search-form .form-control",function(e){if(e.which==13){$(this).closest(".search-form").submit();return false}});$(".page-header").on("mousedown",".search-form.open .submit",function(e){e.preventDefault();e.stopPropagation();$(this).closest(".search-form").submit()});$('[data-hover="megamenu-dropdown"]').not(".hover-initialized").each(function(){$(this).dropdownHover();$(this).addClass("hover-initialized")});$(document).on("click",".mega-menu-dropdown .dropdown-menu",function(e){e.stopPropagation()})};var handleTabs=function(){$("body").on("shown.bs.tab",'a[data-toggle="tab"]',function(){handleSidebarAndContentHeight()})};var handleGoTop=function(){var offset=300;var duration=500;if(navigator.userAgent.match(/iPhone|iPad|iPod/i)){$(window).bind("touchend touchcancel touchleave",function(e){if($(this).scrollTop()>offset){$(".scroll-to-top").fadeIn(duration)}else{$(".scroll-to-top").fadeOut(duration)}})}else{$(window).scroll(function(){if($(this).scrollTop()>offset){$(".scroll-to-top").fadeIn(duration)}else{$(".scroll-to-top").fadeOut(duration)}})}$(".scroll-to-top").click(function(e){e.preventDefault();$("html, body").animate({scrollTop:0},duration);return false})};var handle100HeightContent=function(){$(".full-height-content").each(function(){var target=$(this);var height;height=App.getViewPort().height-$(".page-header").outerHeight(true)-$(".page-footer").outerHeight(true)-$(".page-title").outerHeight(true)-$(".page-bar").outerHeight(true);if(target.hasClass("portlet")){var portletBody=target.find(".portlet-body");App.destroySlimScroll(portletBody.find(".full-height-content-body"));height=height-target.find(".portlet-title").outerHeight(true)-parseInt(target.find(".portlet-body").css("padding-top"))-parseInt(target.find(".portlet-body").css("padding-bottom"))-5;if(App.getViewPort().width>=resBreakpointMd&&target.hasClass("full-height-content-scrollable")){height=height-35;portletBody.find(".full-height-content-body").css("height",height);App.initSlimScroll(portletBody.find(".full-height-content-body"))}else{portletBody.css("min-height",height)}}else{App.destroySlimScroll(target.find(".full-height-content-body"));if(App.getViewPort().width>=resBreakpointMd&&target.hasClass("full-height-content-scrollable")){height=height-35;target.find(".full-height-content-body").css("height",height);App.initSlimScroll(target.find(".full-height-content-body"))}else{target.css("min-height",height)}}})};return{initHeader:function(){handleHorizontalMenu()},setSidebarMenuActiveLink:function(mode,el){handleSidebarMenuActiveLink(mode,el)},initSidebar:function(){handleFixedSidebar();handleSidebarMenu();handleSidebarToggler();if(App.isAngularJsApp()){handleSidebarMenuActiveLink("match")}App.addResizeHandler(handleFixedSidebar)},initContent:function(){handle100HeightContent();handleTabs();App.addResizeHandler(handleSidebarAndContentHeight);App.addResizeHandler(handle100HeightContent)},initFooter:function(){handleGoTop()},init:function(){this.initHeader();this.initSidebar();this.initContent();this.initFooter()},fixContentHeight:function(){handleSidebarAndContentHeight()},initFixedSidebarHoverEffect:function(){handleFixedSidebarHoverEffect()},initFixedSidebar:function(){handleFixedSidebar()},getLayoutImgPath:function(){return layoutImgPath},getLayoutCssPath:function(){return layoutCssPath}}}();if(App.isAngularJsApp()===false){jQuery(document).ready(function(){Layout.init()})};