/** 处理整个主题和核心功能的核心脚本 **/ var App = function() { // IE mode var isRTL = false; var resizeHandlers = []; // 初始化主设置 var handleInit = function() { if ($('body').css('direction') === 'rtl') { isRTL = true; } }; var handleGoTop = function () { var offset = 100; var duration = 500; if (navigator.userAgent.match(/iPhone|iPad|iPod/i)) { // ios supported $(window).bind("touchend touchcancel touchleave", function(e){ if ($(this).scrollTop() > offset) { $('.scroll-to-top').fadeIn(duration); } else { $('.scroll-to-top').fadeOut(duration); } }); } else { // general $(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; }); }; // 运行由设置的回调函数 App.addResponsiveHandler(). var _runResizeHandlers = function() { // 初始化其他订阅元素 for (var i = 0; i < resizeHandlers.length; i++) { var each = resizeHandlers[i]; each.call(); } }; //在调整窗口大小时处理布局重新初始化 var handleOnResize = function() { var resize; $(window).resize(function() { if (resize) { clearTimeout(resize); } resize = setTimeout(function() { _runResizeHandlers(); }, 50); // wait 50ms until window resize finishes. }); }; //处理portlet工具和操作 var handlePortletTools = function() { // handle portlet fullscreen $('body').on('click', '.portlet > .portlet-title .fullscreen', function(e) { e.preventDefault(); var portlet = $(this).closest(".portlet"); if (portlet.hasClass('portlet-fullscreen')) { $(this).removeClass('on'); portlet.removeClass('portlet-fullscreen'); $('body').removeClass('page-portlet-fullscreen'); portlet.children('.portlet-body').css('height', 'auto'); } else { var height = App.getViewPort().height - portlet.children('.portlet-title').outerHeight() - parseInt(portlet.children('.portlet-body').css('padding-top')) - parseInt(portlet.children('.portlet-body').css('padding-bottom')); $(this).addClass('on'); portlet.addClass('portlet-fullscreen'); $('body').addClass('page-portlet-fullscreen'); portlet.children('.portlet-body').css('height', height); } }); }; // 复选框选择控制 var handleMaterialDesign = function() { // Material design ckeckbox and radio effects $('body').on('click', '.md-checkbox > label, .md-radio > label', function() { var the = $(this); // find the first span which is our circle/bubble var el = $(this).children('span:first-child'); // add the bubble class (we do this so it doesnt show on page load) el.addClass('inc'); // clone it var newone = el.clone(true); // add the cloned version before our original el.before(newone); // remove the original so that it is ready to run on next click $("." + el.attr("class") + ":last", the).remove(); }); if ($('body').hasClass('page-md')) { // Material design click effect // credit where credit's due; http://thecodeplayer.com/walkthrough/ripple-click-effect-google-material-design var element, circle, d, x, y; $('body').on('click', 'a.btn, button.btn, input.btn, label.btn', function(e) { element = $(this); if(element.find(".md-click-circle").length == 0) { element.prepend(""); } circle = element.find(".md-click-circle"); circle.removeClass("md-click-animate"); if(!circle.height() && !circle.width()) { d = Math.max(element.outerWidth(), element.outerHeight()); circle.css({height: d, width: d}); } x = e.pageX - element.offset().left - circle.width()/2; y = e.pageY - element.offset().top - circle.height()/2; circle.css({top: y+'px', left: x+'px'}).addClass("md-click-animate"); setTimeout(function() { circle.remove(); }, 1000); }); } // Floating labels var handleInput = function(el) { if (el.val() != "") { el.addClass('edited'); } else { el.removeClass('edited'); } } $('body').on('keydown', '.form-md-floating-label .form-control', function(e) { handleInput($(this)); }); $('body').on('blur', '.form-md-floating-label .form-control', function(e) { handleInput($(this)); }); $('.form-md-floating-label .form-control').each(function(){ if ($(this).val().length > 0) { $(this).addClass('edited'); } }); } // 滑动选择组件 var handleBootstrapSwitch = function() { if (!$().bootstrapSwitch) { return; } $('.make-switch').bootstrapSwitch(); }; // Handles Bootstrap Accordions. var handleAccordions = function() { $('body').on('shown.bs.collapse', '.accordion.scrollable', function(e) { App.scrollTo($(e.target)); }); }; // Tab切换 var handleTabs = function() { //activate tab if tab id provided in the URL if (encodeURI(location.hash)) { var tabid = encodeURI(location.hash.substr(1)); $('a[href="#' + tabid + '"]').parents('.tab-pane:hidden').each(function() { var tabid = $(this).attr("id"); $('a[href="#' + tabid + '"]').click(); }); $('a[href="#' + tabid + '"]').click(); } if ($().tabdrop) { $('.tabbable-tabdrop .nav-pills, .tabbable-tabdrop .nav-tabs').tabdrop({ text: ' ' }); } }; // 提示信息显示 var handleTooltips = function() { // global tooltips $('.tooltips').tooltip(); // portlet tooltips $('.portlet > .portlet-title .fullscreen').tooltip({ trigger: 'hover', container: 'body', title: 'Fullscreen' }); $('.portlet > .portlet-title > .tools > .reload').tooltip({ trigger: 'hover', container: 'body', title: 'Reload' }); $('.portlet > .portlet-title > .tools > .remove').tooltip({ trigger: 'hover', container: 'body', title: 'Remove' }); $('.portlet > .portlet-title > .tools > .config').tooltip({ trigger: 'hover', container: 'body', title: 'Settings' }); $('.portlet > .portlet-title > .tools > .collapse, .portlet > .portlet-title > .tools > .expand').tooltip({ trigger: 'hover', container: 'body', title: 'Collapse/Expand' }); }; // Handles Bootstrap Dropdowns var handleDropdowns = function() { /* Hold dropdown on click */ $('body').on('click', '.dropdown-menu.hold-on-click', function(e) { e.stopPropagation(); }); }; // Handle Hower Dropdowns var handleDropdownHover = function() { $('[data-hover="dropdown"]').not('.hover-initialized').each(function() { $(this).dropdownHover(); $(this).addClass('hover-initialized'); }); }; // Handle textarea autosize var handleTextareaAutosize = function() { if (typeof(autosize) == "function") { autosize(document.querySelector('textarea.autosizeme')); } } // Handles Bootstrap Popovers // last popep popover var lastPopedPopover; var handlePopovers = function() { $('.popovers').popover(); // close last displayed popover $(document).on('click.bs.popover.data-api', function(e) { if (lastPopedPopover) { lastPopedPopover.popover('hide'); } }); }; // 區域滾動 var handleScrollers = function() { App.initSlimScroll('.scroller'); }; // Handles counterup plugin wrapper var handleCounterup = function() { if (!$().counterUp) { return; } $("[data-counter='counterup']").counterUp({ delay: 10, time: 1000 }); }; // handle group element heights var handleHeight = function() { $('[data-auto-height]').each(function() { var parent = $(this); var items = $('[data-height]', parent); var height = 0; var mode = parent.attr('data-mode'); var offset = parseInt(parent.attr('data-offset') ? parent.attr('data-offset') : 0); items.each(function() { if ($(this).attr('data-height') == "height") { $(this).css('height', ''); } else { $(this).css('min-height', ''); } var height_ = (mode == 'base-height' ? $(this).outerHeight() : $(this).outerHeight(true)); if (height_ > height) { height = height_; } }); height = height + offset; items.each(function() { if ($(this).attr('data-height') == "height") { $(this).css('height', height); } else { $(this).css('min-height', height); } }); if(parent.attr('data-related')) { $(parent.attr('data-related')).css('height', parent.height()); } }); } //* END:CORE HANDLERS *// return { //main function to initiate the theme init: function() { //IMPORTANT!!!: Do not modify the core handlers call order. //Core handlersww handleInit(); // initialize core variables handleOnResize(); // set and handle responsive handleGoTop(); // set and handle responsive //UI Component handlerss handleMaterialDesign(); //复选框选择控制w handleBootstrapSwitch(); // handle bootstrap switch plugin handleScrollers(); // handles slim scrolling contents handlePortletTools(); // handles portlet action bar functionality(refresh, configure, toggle, remove) handleDropdowns(); // handle dropdowns handleTabs(); // handle tabs handleTooltips(); // handle bootstrap tooltips handlePopovers(); // handles bootstrap popovers handleAccordions(); //handles accordions handleTextareaAutosize(); // handle autosize textareas handleCounterup(); // handle counterup instances //Handle group element heights this.addResizeHandler(handleHeight); // handle auto calculating height on window resize }, //main function to initiate core javascript after ajax complete initAjax: function() { //handleUniform(); // handles custom radio & checkboxes handleBootstrapSwitch(); // handle bootstrap switch plugin handleDropdownHover(); // handles dropdown hover handleScrollers(); // handles slim scrolling contents handleDropdowns(); // handle dropdowns handleTooltips(); // handle bootstrap tooltips handlePopovers(); // handles bootstrap popovers handleAccordions(); //handles accordions }, //init main components initComponents: function() { this.initAjax(); }, //public function to remember last opened popover that needs to be closed on click setLastPopedPopover: function(el) { lastPopedPopover = el; }, //public function to add callback a function which will be called on window resize addResizeHandler: function(func) { resizeHandlers.push(func); }, //public functon to call _runresizeHandlers runResizeHandlers: function() { _runResizeHandlers(); }, // wrApper function to scroll(focus) to an element scrollTo: function(el, offeset) { var pos = (el && el.length > 0) ? el.offset().top : 0; if (el) { if ($('body').hasClass('page-header-fixed')) { pos = pos - $('.page-header').height(); } else if ($('body').hasClass('page-header-top-fixed')) { pos = pos - $('.page-header-top').height(); } else if ($('body').hasClass('page-header-menu-fixed')) { pos = pos - $('.page-header-menu').height(); } pos = pos + (offeset ? offeset : -1 * el.height()); } $('html,body').animate({ scrollTop: pos }, 'slow'); }, initSlimScroll: function(el) { if (!$().slimScroll) { return; } $(el).each(function() { if ($(this).attr("data-initialized")) { return; // exit } var height; if ($(this).attr("data-height")) { height = $(this).attr("data-height"); } else { height = $(this).css('height'); } $(this).slimScroll({ allowPageScroll: true, // allow page scroll when the element scroll is ended size: '7px', color: ($(this).attr("data-handle-color") ? $(this).attr("data-handle-color") : '#bbb'), wrapperClass: ($(this).attr("data-wrapper-class") ? $(this).attr("data-wrapper-class") : 'slimScrollDiv'), railColor: ($(this).attr("data-rail-color") ? $(this).attr("data-rail-color") : '#eaeaea'), position: isRTL ? 'left' : 'right', height: height, alwaysVisible: ($(this).attr("data-always-visible") == "1" ? true : false), railVisible: ($(this).attr("data-rail-visible") == "1" ? true : false), disableFadeOut: true }); $(this).attr("data-initialized", "1"); }); }, destroySlimScroll: function(el) { if (!$().slimScroll) { return; } $(el).each(function() { if ($(this).attr("data-initialized") === "1") { // destroy existing instance before updating the height $(this).removeAttr("data-initialized"); $(this).removeAttr("style"); var attrList = {}; // store the custom attribures so later we will reassign. if ($(this).attr("data-handle-color")) { attrList["data-handle-color"] = $(this).attr("data-handle-color"); } if ($(this).attr("data-wrapper-class")) { attrList["data-wrapper-class"] = $(this).attr("data-wrapper-class"); } if ($(this).attr("data-rail-color")) { attrList["data-rail-color"] = $(this).attr("data-rail-color"); } if ($(this).attr("data-always-visible")) { attrList["data-always-visible"] = $(this).attr("data-always-visible"); } if ($(this).attr("data-rail-visible")) { attrList["data-rail-visible"] = $(this).attr("data-rail-visible"); } $(this).slimScroll({ wrapperClass: ($(this).attr("data-wrapper-class") ? $(this).attr("data-wrapper-class") : 'slimScrollDiv'), destroy: true }); var the = $(this); // reassign custom attributes $.each(attrList, function(key, value) { the.attr(key, value); }); } }); }, // function to scroll to the top scrollTop: function() { App.scrollTo(); }, //public helper function to get actual input value(used in IE9 and IE8 due to placeholder attribute not supported) getActualVal: function(el) { el = $(el); if (el.val() === el.attr("placeholder")) { return ""; } return el.val(); }, //public function to get a paremeter by name from URL getURLParameter: function(paramName) { var searchString = window.location.search.substring(1), i, val, params = searchString.split("&"); for (i = 0; i < params.length; i++) { val = params[i].split("="); if (val[0] == paramName) { return unescape(val[1]); } } return null; }, // check for device touch support isTouchDevice: function() { try { document.createEvent("TouchEvent"); return true; } catch (e) { return false; } }, // To get the correct viewport width based on http://andylangton.co.uk/articles/javascript/get-viewport-size-javascript/ getViewPort: function() { var e = window, a = 'inner'; if (!('innerWidth' in window)) { a = 'client'; e = document.documentElement || document.body; } return { width: e[a + 'Width'], height: e[a + 'Height'] }; }, getUniqueID: function(prefix) { return 'prefix_' + Math.floor(Math.random() * (new Date()).getTime()); }, //check RTL mode isRTL: function() { return isRTL; }, // check IE8 mode isAngularJsApp: function() { return (typeof angular == 'undefined') ? false : true; }, getResponsiveBreakpoint: function(size) { // bootstrap responsive breakpoints var sizes = { 'xs' : 480, // extra small 'sm' : 768, // small 'md' : 992, // medium 'lg' : 1200 // large }; return sizes[size] ? sizes[size] : 0; } }; }(); jQuery(document).ready(function() { App.init(); //初始化核心组件 }); /** 处理整个主题和核心功能的核心脚本 **/ var Layout = function () { var resBreakpointMd = App.getResponsiveBreakpoint('md'); var ajaxContentSuccessCallbacks = []; var ajaxContentErrorCallbacks = []; //* 开始:核心处理程序*// //此函数处理屏幕大小调整或移动设备旋转时的响应布局。 //为边栏和内容设置适当的高度。内容和侧边栏高度必须始终同步。 var handleSidebarAndContentHeight = function () { }; // 手柄式提要栏菜单 var handleSidebarMenu = function () { // offcanvas mobile menu $('.page-sidebar-mobile-offcanvas .responsive-toggler').click(function() { $('body').toggleClass('page-sidebar-mobile-offcanvas-open'); e.preventDefault(); e.stopPropagation(); }); if ($('body').hasClass('page-sidebar-mobile-offcanvas')) { $(document).on('click', function(e) { if ($('body').hasClass('page-sidebar-mobile-offcanvas-open')) { if ($(e.target).closest('.page-sidebar-mobile-offcanvas .responsive-toggler').length === 0 && $(e.target).closest('.page-sidebar-wrapper').length === 0) { $('body').removeClass('page-sidebar-mobile-offcanvas-open'); e.preventDefault(); e.stopPropagation(); } } }); } // handle sidebar link click $('.page-sidebar-menu').on('click', 'li > 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').length === 1) { return; } var hasSubMenu = that.next().hasClass('sub-menu'); if (App.getViewPort().width >= resBreakpointMd && that.parents('.page-sidebar-menu-hover-submenu').length === 1) { // exit of hover sidebar menu return; } if (hasSubMenu === false) { if (App.getViewPort().width < resBreakpointMd && $('.page-sidebar').hasClass("in")) { // close the menu on mobile view while laoding a page $('.page-header .responsive-toggler').click(); } return; } var parent =that.parent().parent(); var the = that; var menu = $('.page-sidebar-menu'); var sub = that.next(); var autoScroll = menu.data("auto-scroll"); var slideSpeed = parseInt(menu.data("slide-speed")); var keepExpand = menu.data("keep-expanded"); if (!keepExpand) { parent.children('li.open').children('a').children('.arrow').removeClass('open'); parent.children('li.open').children('.sub-menu:not(.always-open)').slideUp(slideSpeed); parent.children('li.open').removeClass('open active'); } var slideOffeset = -200; if (sub.is(":visible")) { $('.arrow', the).removeClass("open"); the.parent().removeClass("open active"); sub.slideUp(slideSpeed, function () { if (autoScroll === true && $('body').hasClass('page-sidebar-closed') === false) { if ($('body').hasClass('page-sidebar-fixed')) { menu.slimScroll({ 'scrollTo': (the.position()).top }); } else { App.scrollTo(the, slideOffeset); } } handleSidebarAndContentHeight(); }); } else if (hasSubMenu) { parent.children('li').removeClass('active'); $('.arrow', the).addClass("open"); the.parent().addClass("open active"); sub.slideDown(slideSpeed, function () { if (autoScroll === true && $('body').hasClass('page-sidebar-closed') === false) { if ($('body').hasClass('page-sidebar-fixed')) { menu.slimScroll({ 'scrollTo': (the.position()).top }); } else { App.scrollTo(the, slideOffeset); } } handleSidebarAndContentHeight(); }); } e.preventDefault(); }); // handle menu close for angularjs version if (App.isAngularJsApp()) { $(".page-sidebar-menu li > a").on("click", function(e) { if (App.getViewPort().width < resBreakpointMd && $(this).next().hasClass('sub-menu') === false) { $('.page-header .responsive-toggler').click(); } }); } // handle ajax links within sidebar menu $('.page-sidebar').on('click', ' li > a.ajaxify', function (e) { }); // handle ajax link within main content $('.page-content').on('click', '.ajaxify', function (e) { }); // handle scrolling to top on responsive menu toggler click when header is fixed for mobile view $(document).on('click', '.page-header-fixed-mobile .page-header .responsive-toggler', function(){ App.scrollTop(); }); // handle the search bar close $('.page-sidebar').on('click', '.sidebar-search .remove', function (e) { e.preventDefault(); $('.sidebar-search').removeClass("open"); }); // handle the search query submit on enter press $('.page-sidebar .sidebar-search').on('keypress', 'input.form-control', function (e) { if (e.which == 13) { dr_search_help(); return false; //<---- Add this line } }); // handle the search submit(for sidebar search and responsive mode of the header search) $('.sidebar-search .submit').on('click', function (e) { dr_search_help(); }); // handle close on body click if ($('.sidebar-search').length !== 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; }; // Handles fixed sidebar var handleFixedSidebar = function () { var menu = $('.page-sidebar-menu'); handleSidebarAndContentHeight(); if ($('.page-sidebar-fixed').length === 0) { return; } if (App.getViewPort().width >= resBreakpointMd && !$('body').hasClass('page-sidebar-menu-not-fixed')) { menu.attr("data-height", _calculateFixedSidebarViewportHeight()); App.destroySlimScroll(menu); App.initSlimScroll(menu); handleSidebarAndContentHeight(); } }; // Hanles sidebar toggler var handleSidebarToggler = function () { if ( typeof is_min != "undefined" && is_min == 1) { var body = $('body'); if ($.cookie && $.cookie('sidebar_closed') === '1' && App.getViewPort().width >= resBreakpointMd) { $('body').addClass('page-sidebar-closed'); $('.page-sidebar-menu').addClass('page-sidebar-menu-closed'); } // handle sidebar show/hide $('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'); } } $(window).trigger('resize'); }); } }; return { // Main init methods to initialize the layout //IMPORTANT!!!: Do not modify the core handlers call order. initSidebar: function() { //layout handlers handleFixedSidebar(); // handles fixed sidebar menu handleSidebarMenu(); // handles main menu handleSidebarToggler(); // handles sidebar hide/show App.addResizeHandler(handleFixedSidebar); // reinitialize fixed sidebar on window resize }, initContent: function() { App.addResizeHandler(handleSidebarAndContentHeight); // recalculate sidebar & content height on window resize }, init: function () { this.initSidebar(); this.initContent(); }, //public function to fix the sidebar and content height accordingly fixContentHeight: function () { handleSidebarAndContentHeight(); }, initFixedSidebar: function() { handleFixedSidebar(); }, }; }(); if (App.isAngularJsApp() === false) { jQuery(document).ready(function() { Layout.init(); }); } // 显示用户资料信息 function dr_show_member(name) { if (is_mobile_cms == 1) { width = height = '90%'; } else { width = '50%'; height = '70%'; } var url = admin_file+"?c=api&m=member&name="+$("#dr_"+name).val(); layer.open({ type: 2, title: ' ' + lang['member'], shadeClose: true, shade: 0, scrollbar: false, area: [width, width], success: function(layero, index){ // 主要用于后台权限验证 dr_iframe_error(layer, index, 0); }, content: url+'&is_iframe=1' }); } jQuery(document).ready(function() { $('.onloading').click(function(){ var index = layer.load(2, { time: 5000 }); }); $(document).on('click', '.fc_member_show', function() { var uid = $(this).attr("uid"); var name = $(this).attr("member"); var url = admin_file+"?c=api&m=member&name="+name+"&uid="+uid; if (is_mobile_cms == 1) { width = height = '90%'; } else { width = '50%'; height = '70%'; } layer.open({ type: 2, title: ' ' + lang['member'], shadeClose: true, shade: 0, area: [width, width], success: function(layero, index){ // 主要用于后台权限验证 dr_iframe_error(layer, index, 0); }, content: url+'&is_iframe=1' }); }); // 当存在隐藏时单击显示区域 $(document).on('click', '.table td,.table th', function() { var td = $(this); if (dr_isEllipsis(td[0]) == true) { var text = td.html(); if (text.indexOf("checkbox") != -1) { return; } else if (text.indexOf("=40 || event.keyCode == 0) { blnCheckUnload = true; }; if (event.keyCode == 16 || event.keyCode == 82 || event.keyCode==91) { blnCheckUnload = false; } }); } // 宽度小时 if ($(document).width() < 900) { $(".fc-all-menu-top").remove(); $(".fc-mini-menu-top").show(); // 缩小table /* $('.page-breadcrumb a').each(function () { var name = $(this).html(); re =new RegExp(/'); $(this).attr('title', result[2].replace('> ', '')); } });*/ // 缩小table下方按钮 $('.fc-list-select button').each(function () { var name = $(this).html(); re =new RegExp(/'); $(this).attr('title', result[2].replace('> ', '')); } }); // 缩小后台导航面包屑 $('a[data-toggle="tab"]').each(function () { var name = $(this).html(); re =new RegExp(/'); $(this).attr('title', result[2].replace('> ', '')); } }); // 大挪移logo $('.my-top-left').html('
'+json.msg+''); } else { $("#sql_result").html('
',s+='",s+="