123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893 |
- if (typeof jQuery === "undefined") {
- throw new Error("AdminLTE requires jQuery");
- }
- $.AdminLTE = {};
- $.AdminLTE.options = {
-
-
-
- navbarMenuSlimscroll: true,
- navbarMenuSlimscrollWidth: "3px",
- navbarMenuHeight: "200px",
-
-
-
- animationSpeed: 300,
-
- sidebarToggleSelector: "[data-toggle='offcanvas']",
-
- sidebarPushMenu: true,
-
- sidebarSlimScroll: true,
-
-
-
- sidebarExpandOnHover: false,
-
- enableBoxRefresh: true,
-
- enableBSToppltip: true,
- BSTooltipSelector: "[data-toggle='tooltip']",
-
-
-
-
- enableFastclick: false,
-
- enableControlTreeView: true,
-
- enableControlSidebar: true,
- controlSidebarOptions: {
-
- toggleBtnSelector: "[data-toggle='control-sidebar']",
-
- selector: ".control-sidebar",
-
- slide: true
- },
-
-
- enableBoxWidget: true,
-
- boxWidgetOptions: {
- boxWidgetIcons: {
-
- collapse: 'fa-minus',
-
- open: 'fa-plus',
-
- remove: 'fa-times'
- },
- boxWidgetSelectors: {
-
- remove: '[data-widget="remove"]',
-
- collapse: '[data-widget="collapse"]'
- }
- },
-
- directChat: {
-
- enable: true,
-
- contactToggleSelector: '[data-widget="chat-pane-toggle"]'
- },
-
- colors: {
- lightBlue: "#3c8dbc",
- red: "#f56954",
- green: "#00a65a",
- aqua: "#00c0ef",
- yellow: "#f39c12",
- blue: "#0073b7",
- navy: "#001F3F",
- teal: "#39CCCC",
- olive: "#3D9970",
- lime: "#01FF70",
- orange: "#FF851B",
- fuchsia: "#F012BE",
- purple: "#8E24AA",
- maroon: "#D81B60",
- black: "#222222",
- gray: "#d2d6de"
- },
-
-
-
- screenSizes: {
- xs: 480,
- sm: 768,
- md: 992,
- lg: 1200
- }
- };
- $(function () {
- "use strict";
-
- $("body").removeClass("hold-transition");
-
- if (typeof AdminLTEOptions !== "undefined") {
- $.extend(true,
- $.AdminLTE.options,
- AdminLTEOptions);
- }
- if ('ontouchstart' in document.documentElement) {
- $.AdminLTE.options.sidebarSlimScroll = false;
- $(".main-sidebar").css({height: ($(window).height() - $(".main-header").height()) + "px", overflow: "scroll"});
- }
-
- var o = $.AdminLTE.options;
-
- _init();
-
- $.AdminLTE.layout.activate();
-
- if (o.enableControlTreeView) {
- $.AdminLTE.tree('.sidebar');
- }
-
- if (o.enableControlSidebar) {
- $.AdminLTE.controlSidebar.activate();
- }
-
- if (o.navbarMenuSlimscroll && typeof $.fn.slimscroll != 'undefined') {
- $(".navbar .menu").slimscroll({
- height: o.navbarMenuHeight,
- alwaysVisible: false,
- size: o.navbarMenuSlimscrollWidth
- }).css("width", "100%");
- }
-
- if (o.sidebarPushMenu) {
- $.AdminLTE.pushMenu.activate(o.sidebarToggleSelector);
- }
-
- if (o.enableBSToppltip) {
- $('body').tooltip({
- selector: o.BSTooltipSelector,
- container: 'body'
- });
- }
-
- if (o.enableBoxWidget) {
- $.AdminLTE.boxWidget.activate();
- }
-
- if (o.enableFastclick && typeof FastClick != 'undefined') {
- FastClick.attach(document.body);
- }
-
- if (o.directChat.enable) {
- $(document).on('click', o.directChat.contactToggleSelector, function () {
- var box = $(this).parents('.direct-chat').first();
- box.toggleClass('direct-chat-contacts-open');
- });
- }
-
- $('.btn-group[data-toggle="btn-toggle"]').each(function () {
- var group = $(this);
- $(this).find(".btn").on('click', function (e) {
- group.find(".btn.active").removeClass("active");
- $(this).addClass("active");
- e.preventDefault();
- });
- });
- });
- function _init() {
- 'use strict';
-
- $.AdminLTE.layout = {
- activate: function () {
- var _this = this;
-
- _this.fixSidebar();
-
- $(window, ".wrapper").resize(function () {
-
- _this.fixSidebar();
- });
- },
- fix: function () {
-
- $(".layout-boxed > .wrapper").css('overflow', 'hidden');
-
- var footer_height = $('.main-footer').outerHeight() || 0;
- var neg = $('.main-header').outerHeight() + footer_height;
- var window_height = $(window).height();
- var sidebar_height = $(".sidebar").height() || 0;
-
-
- if ($("body").hasClass("fixed")) {
- $(".content-wrapper, .right-side").css('min-height', window_height - footer_height);
- } else {
- var postSetWidth;
- if (window_height >= sidebar_height) {
- $(".content-wrapper, .right-side").css('min-height', window_height - neg);
- postSetWidth = window_height - neg;
- } else {
- $(".content-wrapper, .right-side").css('min-height', sidebar_height);
- postSetWidth = sidebar_height;
- }
-
- var controlSidebar = $($.AdminLTE.options.controlSidebarOptions.selector);
- if (typeof controlSidebar !== "undefined") {
- if (controlSidebar.height() > postSetWidth)
- $(".content-wrapper, .right-side").css('min-height', controlSidebar.height());
- }
- }
- },
- fixSidebar: function () {
-
- if (!$("body").hasClass("fixed")) {
- if (typeof $.fn.slimScroll != 'undefined') {
- $(".sidebar").slimScroll({destroy: true}).height("auto");
- }
- return;
- } else if (typeof $.fn.slimScroll == 'undefined' && window.console) {
- window.console.error("Error: the fixed layout requires the slimscroll plugin!");
- }
-
- if ($.AdminLTE.options.sidebarSlimScroll) {
- if (typeof $.fn.slimScroll != 'undefined') {
-
- $(".sidebar").slimScroll({destroy: true}).height("auto").css("overflow", "inherit");
- if (!$("body").hasClass('sidebar-collapse')) {
- $(".sidebar").off("mousewheel").css("margin-top", 0);
- $('.sidebar .treeview-menu').off('mousewheel').removeAttr("style");
-
- $(".sidebar").slimscroll({
- height: ($(window).height() - $(".main-header").height()) + "px",
- color: "rgba(0,0,0,0.2)",
- size: "8px"
- });
- $(".sidebar").trigger("mouseover");
- } else {
- var sidebarHeight = $(".sidebar").height();
- var maxHeight = $(window).height() - $(".main-header").height();
- var overflowHeight = sidebarHeight + $(".main-header").height() - $(window).height();
- if (overflowHeight > 0) {
- $(".sidebar").height(maxHeight);
- $(".sidebar").on("mousewheel", function (e) {
- e.preventDefault();
- if (e.originalEvent.pageX < $(".sidebar").width()) {
- var marginTop = parseInt($(".sidebar").css("margin-top").replace("px", "")) + e.originalEvent.wheelDelta;
- if (marginTop < 0 && Math.abs(marginTop) > overflowHeight) {
- marginTop = Math.min(overflowHeight, marginTop);
- marginTop = -overflowHeight;
- }
- marginTop = Math.min(0, marginTop);
- $(".sidebar").css("margin-top", marginTop);
- }
- });
- $('.sidebar .treeview-menu').on('mousewheel', function (e) {
- e.stopPropagation();
- });
- }
- }
- }
- }
- }
- };
-
- $.AdminLTE.pushMenu = {
- activate: function (toggleBtn) {
-
- var screenSizes = $.AdminLTE.options.screenSizes;
-
- $(document).on('click', toggleBtn, function (e) {
- e.preventDefault();
-
- if ($(window).width() > (screenSizes.sm - 1)) {
- if ($("body").hasClass('sidebar-collapse')) {
- $("body").removeClass('sidebar-collapse').trigger('expanded.pushMenu');
- } else {
- $("body").addClass('sidebar-collapse').trigger('collapsed.pushMenu');
- }
- }
-
- else {
- if ($("body").hasClass('sidebar-open')) {
- $("body").removeClass('sidebar-open').removeClass('sidebar-collapse').trigger('collapsed.pushMenu');
- } else {
- $("body").addClass('sidebar-open').trigger('expanded.pushMenu');
- }
- }
- $.AdminLTE.layout.fixSidebar();
- });
- $(".content-wrapper").click(function () {
-
- if ($(window).width() <= (screenSizes.sm - 1) && $("body").hasClass("sidebar-open")) {
- $("body").removeClass('sidebar-open');
- }
- });
-
- if ($.AdminLTE.options.sidebarExpandOnHover) {
- this.expandOnHover();
- }
- },
- expandOnHover: function () {
- var _this = this;
- var screenWidth = $.AdminLTE.options.screenSizes.sm - 1;
-
- $('.main-sidebar').hover(function () {
- if ($.AdminLTE.options.sidebarExpandOnHover) {
- if ($('body').hasClass('sidebar-mini')
- && $("body").hasClass('sidebar-collapse')
- && $(window).width() > screenWidth) {
- _this.expand();
- }
- }
- }, function () {
- if ($('body').hasClass('sidebar-mini')
- && $('body').hasClass('sidebar-expanded-on-hover')
- && $(window).width() > screenWidth) {
- _this.collapse();
- }
- });
- },
- expand: function () {
- $("body").removeClass('sidebar-collapse').addClass('sidebar-expanded-on-hover');
- $.AdminLTE.layout.fixSidebar();
- },
- collapse: function () {
- if ($('body').hasClass('sidebar-expanded-on-hover')) {
- $('body').removeClass('sidebar-expanded-on-hover').addClass('sidebar-collapse');
-
- }
- }
- };
-
- $.AdminLTE.tree = function (menu) {
- var _this = this;
- var animationSpeed = $.AdminLTE.options.animationSpeed;
- $(document).off('mouseenter', menu + ' .sidebar-menu > li')
- .on('mouseenter', menu + ' .sidebar-menu > li', function () {
- var treemenu = $(this).find("> .treeview-menu");
- if (treemenu.length > 0) {
- if ($("body").hasClass("sidebar-collapse")) {
- var liHeight = $(this).height();
- var headerHeight = $(".main-header").height();
- var maxBottomHeight = $(window).height() - ($(this).offset().top + headerHeight);
- var maxTopHeight = $(window).height() - maxBottomHeight - liHeight;
- var maxHeight = maxBottomHeight;
- if (maxBottomHeight < 300 || maxTopHeight > maxBottomHeight) {
- treemenu.css("top", "unset").css("bottom", liHeight);
- maxHeight = maxTopHeight;
- }
- treemenu.css("max-height", maxHeight).css("overflow-y", "auto");
- } else {
- treemenu.css("max-height", "inherit").css("overflow-y", "unset");
- }
- }
- });
- $(document).off('click', menu + ' li a')
- .on('click', menu + ' li a', function (e) {
-
- var $this = $(this);
- var checkElement = $this.next();
-
- if ((checkElement.is('.treeview-menu')) && (checkElement.is(':visible'))) {
- if ($("body").hasClass("sidebar-collapse") && $this.parent().parent().hasClass("sidebar-menu")) {
- return false;
- }
-
- checkElement.slideUp(animationSpeed, function () {
- checkElement.removeClass('menu-open');
-
-
- });
-
- checkElement.parent("li").removeClass('treeview-open');
- }
-
- else if ((checkElement.is('.treeview-menu')) && (!checkElement.is(':visible'))) {
-
- var parent = $this.parents('ul').first();
-
- if ($(".show-submenu", menu).length == 0) {
-
- var ul = parent.find('ul:visible').slideUp(animationSpeed);
-
- ul.removeClass('menu-open');
- parent.find('li.treeview').removeClass("treeview-open");
- }
-
- var parent_li = $this.parent("li");
-
- checkElement.slideDown(animationSpeed, function () {
-
- checkElement.addClass('menu-open');
-
-
-
-
- });
- parent_li.addClass('treeview-open');
- } else {
- if (!$this.parent().hasClass("active")) {
-
- }
-
- if ($(".show-submenu", menu).length == 0 && $this.parent().parent().hasClass("sidebar-menu")) {
- $this.parent().siblings().find("ul.menu-open").slideUp();
- $this.parent().siblings("li.treeview-open").removeClass("treeview-open");
- }
- }
-
- if (checkElement.is('.treeview-menu')) {
- e.preventDefault();
- }
- });
- };
-
- $.AdminLTE.controlSidebar = {
-
- activate: function () {
-
- var _this = this;
-
- var o = $.AdminLTE.options.controlSidebarOptions;
-
- var sidebar = $(o.selector);
-
- var btn = $(o.toggleBtnSelector);
-
- btn.on('click', function (e) {
- e.preventDefault();
-
- if (!sidebar.hasClass('control-sidebar-open')
- && !$('body').hasClass('control-sidebar-open')) {
-
- _this.open(sidebar, o.slide);
- } else {
- _this.close(sidebar, o.slide);
- }
- });
-
- var bg = $(".control-sidebar-bg");
- _this._fix(bg);
-
- if ($('body').hasClass('fixed')) {
- _this._fixForFixed(sidebar);
- } else {
-
- if ($('.content-wrapper, .right-side').height() < sidebar.height()) {
- _this._fixForContent(sidebar);
- }
- }
- },
-
- open: function (sidebar, slide) {
-
- if (slide) {
- sidebar.addClass('control-sidebar-open');
- } else {
-
-
- $('body').addClass('control-sidebar-open');
- }
- },
-
- close: function (sidebar, slide) {
- if (slide) {
- sidebar.removeClass('control-sidebar-open');
- } else {
- $('body').removeClass('control-sidebar-open');
- }
- },
- _fix: function (sidebar) {
- var _this = this;
- if ($("body").hasClass('layout-boxed')) {
- sidebar.css('position', 'absolute');
- sidebar.height($(".wrapper").height());
- if (_this.hasBindedResize) {
- return;
- }
- $(window).resize(function () {
- _this._fix(sidebar);
- });
- _this.hasBindedResize = true;
- } else {
- sidebar.css({
- 'position': 'fixed',
- 'height': 'auto'
- });
- }
- },
- _fixForFixed: function (sidebar) {
- sidebar.css({
- 'position': 'fixed',
- 'max-height': '100%',
- 'overflow': 'auto',
- });
- },
- _fixForContent: function (sidebar) {
- $(".content-wrapper, .right-side").css('min-height', sidebar.height());
- }
- };
-
- $.AdminLTE.boxWidget = {
- selectors: $.AdminLTE.options.boxWidgetOptions.boxWidgetSelectors,
- icons: $.AdminLTE.options.boxWidgetOptions.boxWidgetIcons,
- animationSpeed: $.AdminLTE.options.animationSpeed,
- activate: function (_box) {
- var _this = this;
- if (!_box) {
- _box = document;
- }
-
- $(_box).on('click', _this.selectors.collapse, function (e) {
- e.preventDefault();
- _this.collapse($(this));
- });
-
- $(_box).on('click', _this.selectors.remove, function (e) {
- e.preventDefault();
- _this.remove($(this));
- });
- },
- collapse: function (element) {
- var _this = this;
-
- var box = element.parents(".box").first();
-
- var box_content = box.find("> .box-body, > .box-footer, > form >.box-body, > form > .box-footer");
- if (!box.hasClass("collapsed-box")) {
-
- element.children(":first")
- .removeClass(_this.icons.collapse)
- .addClass(_this.icons.open);
-
- box_content.slideUp(_this.animationSpeed, function () {
- box.addClass("collapsed-box");
- });
- } else {
-
- element.children(":first")
- .removeClass(_this.icons.open)
- .addClass(_this.icons.collapse);
-
- box_content.slideDown(_this.animationSpeed, function () {
- box.removeClass("collapsed-box");
- });
- }
- },
- remove: function (element) {
-
- var box = element.parents(".box").first();
- box.slideUp(this.animationSpeed);
- }
- };
- }
- (function ($) {
- "use strict";
- $.fn.boxRefresh = function (options) {
-
- var settings = $.extend({
-
- trigger: ".refresh-btn",
-
- source: "",
-
- onLoadStart: function (box) {
- return box;
- },
- onLoadDone: function (box) {
- return box;
- }
- }, options);
-
- var overlay = $('<div class="overlay"><div class="fa fa-refresh fa-spin"></div></div>');
- return this.each(function () {
-
- if (settings.source === "") {
- if (window.console) {
- window.console.log("Please specify a source first - boxRefresh()");
- }
- return;
- }
-
- var box = $(this);
-
- var rBtn = box.find(settings.trigger).first();
-
- rBtn.on('click', function (e) {
- e.preventDefault();
-
- start(box);
-
- box.find(".box-body").load(settings.source, function () {
- done(box);
- });
- });
- });
- function start(box) {
-
- box.append(overlay);
- settings.onLoadStart.call(box);
- }
- function done(box) {
-
- box.find(overlay).remove();
- settings.onLoadDone.call(box);
- }
- };
- })(jQuery);
- (function ($) {
- 'use strict';
- $.fn.activateBox = function () {
- $.AdminLTE.boxWidget.activate(this);
- };
- $.fn.toggleBox = function () {
- var button = $($.AdminLTE.boxWidget.selectors.collapse, this);
- $.AdminLTE.boxWidget.collapse(button);
- };
- $.fn.removeBox = function () {
- var button = $($.AdminLTE.boxWidget.selectors.remove, this);
- $.AdminLTE.boxWidget.remove(button);
- };
- })(jQuery);
- (function ($) {
- 'use strict';
- $.fn.todolist = function (options) {
-
- var settings = $.extend({
-
- onCheck: function (ele) {
- return ele;
- },
-
- onUncheck: function (ele) {
- return ele;
- }
- }, options);
- return this.each(function () {
- if (typeof $.fn.iCheck != 'undefined') {
- $('input', this).on('ifChecked', function () {
- var ele = $(this).parents("li").first();
- ele.toggleClass("done");
- settings.onCheck.call(ele);
- });
- $('input', this).on('ifUnchecked', function () {
- var ele = $(this).parents("li").first();
- ele.toggleClass("done");
- settings.onUncheck.call(ele);
- });
- } else {
- $('input', this).on('change', function () {
- var ele = $(this).parents("li").first();
- ele.toggleClass("done");
- if ($('input', ele).is(":checked")) {
- settings.onCheck.call(ele);
- } else {
- settings.onUncheck.call(ele);
- }
- });
- }
- });
- };
-
- $.fn.field = function (name, value) {
- if (typeof name !== "string")
- return false;
- var element = $(this).find("[name='" + name + "']");
- if (typeof value === "undefined" && element.length >= 1) {
- switch (element.attr("type")) {
- case "checkbox":
- var result = new Array();
- element.each(function (i, val) {
- if ($(this).is(":checked")) {
- result.push($(this).val());
- }
- });
- return result;
- break;
- case "radio":
- var result;
- element.each(function (i, val) {
- if ($(this).is(":checked")) {
- result = $(this).val();
- }
- });
- return result;
- break;
- default:
- return element.val();
- break;
- }
- } else {
- switch (element.attr("type")) {
- case "checkbox":
- case "radio":
- value = $.isArray(value) ? value : [value];
- element.each(function (i) {
- $(this).prop({
- checked: $.inArray($(this).val(), value) > -1
- });
- });
- break;
- case undefined:
- default:
- element.val(value);
- break;
- }
- return element;
- }
- };
- }(jQuery));
|