AdminLTE/dist/js/adminlte.js

911 lines
22 KiB
JavaScript
Raw Normal View History

2018-03-17 18:07:55 +01:00
/*!
2018-07-15 16:56:30 +02:00
* AdminLTE v3.0.0-beta.1 (https://adminlte.io)
2019-03-24 17:58:28 +01:00
* Copyright 2014-2019 Abdullah Almsaeed <abdullah@almsaeedstudio.com>
2018-03-17 18:07:55 +01:00
* Licensed under MIT (https://github.com/almasaeed2010/AdminLTE/blob/master/LICENSE)
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.adminlte = {})));
}(this, (function (exports) { 'use strict';
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
2016-01-16 17:27:23 +01:00
2018-02-04 00:45:19 +01:00
/**
* --------------------------------------------
* AdminLTE ControlSidebar.js
* License MIT
* --------------------------------------------
2015-11-11 20:29:54 +01:00
*/
2018-02-04 00:45:19 +01:00
var ControlSidebar = function ($) {
2016-01-16 17:27:23 +01:00
/**
* Constants
* ====================================================
*/
2015-11-11 20:29:54 +01:00
2018-02-04 00:45:19 +01:00
var NAME = 'ControlSidebar';
var DATA_KEY = 'lte.control.sidebar';
2016-01-16 17:27:23 +01:00
var JQUERY_NO_CONFLICT = $.fn[NAME];
var Selector = {
CONTROL_SIDEBAR: '.control-sidebar',
2018-03-17 18:07:55 +01:00
DATA_TOGGLE: '[data-widget="control-sidebar"]',
MAIN_HEADER: '.main-header'
2016-01-16 17:27:23 +01:00
};
var ClassName = {
2018-02-04 00:45:19 +01:00
CONTROL_SIDEBAR_OPEN: 'control-sidebar-open',
CONTROL_SIDEBAR_SLIDE: 'control-sidebar-slide-open'
2016-01-16 17:27:23 +01:00
};
2018-02-04 00:45:19 +01:00
var Default = {
slide: true
2016-01-16 17:27:23 +01:00
2018-02-04 00:45:19 +01:00
/**
* Class Definition
* ====================================================
*/
2016-01-16 17:27:23 +01:00
2018-02-04 00:45:19 +01:00
};
var ControlSidebar = function () {
function ControlSidebar(element, config) {
2018-03-17 18:07:55 +01:00
classCallCheck(this, ControlSidebar);
2016-01-16 17:27:23 +01:00
2018-02-04 00:45:19 +01:00
this._element = element;
this._config = this._getConfig(config);
2016-01-16 17:27:23 +01:00
}
// Public
2018-03-17 18:07:55 +01:00
ControlSidebar.prototype.show = function show() {
// Show the control sidebar
if (this._config.slide) {
$('body').removeClass(ClassName.CONTROL_SIDEBAR_SLIDE);
} else {
$('body').removeClass(ClassName.CONTROL_SIDEBAR_OPEN);
2016-01-16 17:27:23 +01:00
}
2018-03-17 18:07:55 +01:00
};
ControlSidebar.prototype.collapse = function collapse() {
// Collapse the control sidebar
if (this._config.slide) {
$('body').addClass(ClassName.CONTROL_SIDEBAR_SLIDE);
} else {
$('body').addClass(ClassName.CONTROL_SIDEBAR_OPEN);
2016-01-16 17:27:23 +01:00
}
2018-03-17 18:07:55 +01:00
};
ControlSidebar.prototype.toggle = function toggle() {
this._setMargin();
var shouldOpen = $('body').hasClass(ClassName.CONTROL_SIDEBAR_OPEN) || $('body').hasClass(ClassName.CONTROL_SIDEBAR_SLIDE);
if (shouldOpen) {
// Open the control sidebar
this.show();
} else {
// Close the control sidebar
this.collapse();
2018-02-04 00:45:19 +01:00
}
2018-03-17 18:07:55 +01:00
};
2016-01-16 17:27:23 +01:00
2018-03-17 18:07:55 +01:00
// Private
2016-01-16 17:27:23 +01:00
2018-03-17 18:07:55 +01:00
ControlSidebar.prototype._getConfig = function _getConfig(config) {
return $.extend({}, Default, config);
};
ControlSidebar.prototype._setMargin = function _setMargin() {
$(Selector.CONTROL_SIDEBAR).css({
top: $(Selector.MAIN_HEADER).innerHeight()
2018-03-17 18:07:55 +01:00
});
};
2016-01-16 17:27:23 +01:00
2018-03-17 18:07:55 +01:00
// Static
2016-01-16 17:27:23 +01:00
2018-03-17 18:07:55 +01:00
ControlSidebar._jQueryInterface = function _jQueryInterface(operation) {
return this.each(function () {
var data = $(this).data(DATA_KEY);
2016-01-16 17:27:23 +01:00
2018-03-17 18:07:55 +01:00
if (!data) {
data = new ControlSidebar(this, $(this).data());
$(this).data(DATA_KEY, data);
}
2016-01-16 17:27:23 +01:00
2018-03-17 18:07:55 +01:00
if (data[operation] === 'undefined') {
throw new Error(operation + ' is not a function');
}
2018-02-04 00:45:19 +01:00
2018-03-17 18:07:55 +01:00
data[operation]();
});
};
2016-01-16 17:27:23 +01:00
2018-02-04 00:45:19 +01:00
return ControlSidebar;
}();
2016-01-16 17:27:23 +01:00
/**
2018-02-04 00:45:19 +01:00
*
* Data Api implementation
* ====================================================
*/
2018-03-17 18:07:55 +01:00
2018-02-04 00:45:19 +01:00
$(document).on('click', Selector.DATA_TOGGLE, function (event) {
event.preventDefault();
2018-02-04 00:45:19 +01:00
ControlSidebar._jQueryInterface.call($(this), 'toggle');
});
2016-01-16 17:27:23 +01:00
/**
* jQuery API
* ====================================================
*/
2018-02-04 00:45:19 +01:00
$.fn[NAME] = ControlSidebar._jQueryInterface;
$.fn[NAME].Constructor = ControlSidebar;
2016-01-16 17:27:23 +01:00
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
2018-02-04 00:45:19 +01:00
return ControlSidebar._jQueryInterface;
2016-01-16 17:27:23 +01:00
};
2018-02-04 00:45:19 +01:00
return ControlSidebar;
}(jQuery);
2015-11-11 20:29:54 +01:00
2018-02-04 00:45:19 +01:00
/**
* --------------------------------------------
* AdminLTE Layout.js
* License MIT
* --------------------------------------------
*/
var Layout = function ($) {
2015-11-11 20:29:54 +01:00
/**
* Constants
* ====================================================
*/
2018-02-04 00:45:19 +01:00
var NAME = 'Layout';
var DATA_KEY = 'lte.layout';
2015-11-11 20:29:54 +01:00
var JQUERY_NO_CONFLICT = $.fn[NAME];
var Selector = {
2018-02-04 00:45:19 +01:00
HEADER: '.main-header',
2019-03-24 17:58:28 +01:00
SIDEBAR: '.main-sidebar .sidebar',
2018-02-04 00:45:19 +01:00
CONTENT: '.content-wrapper',
BRAND: '.brand-link',
2018-02-04 00:45:19 +01:00
CONTENT_HEADER: '.content-header',
WRAPPER: '.wrapper',
CONTROL_SIDEBAR: '.control-sidebar',
LAYOUT_FIXED: '.layout-fixed',
FOOTER: '.main-footer'
2015-11-11 20:29:54 +01:00
};
2016-01-16 17:27:23 +01:00
var ClassName = {
2018-02-04 00:45:19 +01:00
HOLD: 'hold-transition',
SIDEBAR: 'main-sidebar',
LAYOUT_FIXED: 'layout-fixed',
NAVBAR_FIXED: 'layout-navbar-fixed',
FOOTER_FIXED: 'layout-footer-fixed'
};
var Default = {
scrollbarTheme: 'os-theme-light',
scrollbarAutoHide: 'l'
2016-01-16 17:27:23 +01:00
2018-02-04 00:45:19 +01:00
/**
* Class Definition
* ====================================================
*/
2016-01-16 17:27:23 +01:00
2018-02-04 00:45:19 +01:00
};
var Layout = function () {
function Layout(element, config) {
2018-03-17 18:07:55 +01:00
classCallCheck(this, Layout);
2015-11-11 20:29:54 +01:00
this._config = config;
2015-11-11 20:29:54 +01:00
this._element = element;
2018-02-04 00:45:19 +01:00
this._init();
2015-11-11 20:29:54 +01:00
}
// Public
2018-03-17 18:07:55 +01:00
Layout.prototype.fixLayoutHeight = function fixLayoutHeight() {
var heights = {
window: $(window).height(),
header: $(Selector.HEADER).outerHeight(),
footer: $(Selector.FOOTER).outerHeight(),
sidebar: $(Selector.SIDEBAR).height()
};
2019-03-24 17:58:28 +01:00
2018-03-17 18:07:55 +01:00
var max = this._max(heights);
2016-01-16 17:27:23 +01:00
if ($('body').hasClass(ClassName.LAYOUT_FIXED)) {
$(Selector.CONTENT).css('min-height', max - heights.header - heights.footer);
// $(Selector.SIDEBAR).css('min-height', max - heights.header)
$(Selector.CONTROL_SIDEBAR + ' .control-sidebar-content').css('height', max - heights.header);
if (typeof $.fn.overlayScrollbars !== 'undefined') {
$(Selector.SIDEBAR).overlayScrollbars({
className: this._config.scrollbarTheme,
sizeAutoCapable: true,
scrollbars: {
autoHide: this._config.scrollbarAutoHide,
clickScrolling: true
}
});
$(Selector.CONTROL_SIDEBAR + ' .control-sidebar-content').overlayScrollbars({
className: this._config.scrollbarTheme,
sizeAutoCapable: true,
scrollbars: {
autoHide: this._config.scrollbarAutoHide,
clickScrolling: true
}
});
}
} else {
if (heights.window > heights.sidebar) {
$(Selector.CONTENT).css('min-height', heights.window - heights.header - heights.footer);
} else {
$(Selector.CONTENT).css('min-height', heights.sidebar - heights.header);
2019-03-24 17:58:28 +01:00
}
}
if ($('body').hasClass(ClassName.NAVBAR_FIXED)) {
$(Selector.BRAND).css('height', heights.header);
$(Selector.SIDEBAR).css('margin-top', heights.header);
$(Selector.SIDEBAR).css('margin-top', heights.header);
}
if ($('body').hasClass(ClassName.FOOTER_FIXED)) {
$(Selector.CONTENT).css('margin-bottom', heights.footer);
}
2018-03-17 18:07:55 +01:00
};
2016-01-16 17:27:23 +01:00
2018-03-17 18:07:55 +01:00
// Private
2016-01-16 17:27:23 +01:00
2018-03-17 18:07:55 +01:00
Layout.prototype._init = function _init() {
var _this = this;
2016-01-16 17:27:23 +01:00
2018-03-17 18:07:55 +01:00
// Enable transitions
$('body').removeClass(ClassName.HOLD);
2016-01-16 17:27:23 +01:00
2018-03-17 18:07:55 +01:00
// Activate layout height watcher
this.fixLayoutHeight();
$(Selector.SIDEBAR).on('collapsed.lte.treeview expanded.lte.treeview collapsed.lte.pushmenu expanded.lte.pushmenu', function () {
_this.fixLayoutHeight();
});
2016-01-16 17:27:23 +01:00
2018-03-17 18:07:55 +01:00
$(window).resize(function () {
_this.fixLayoutHeight();
});
2016-01-16 17:27:23 +01:00
2018-03-17 18:07:55 +01:00
$('body, html').css('height', 'auto');
};
2016-01-16 17:27:23 +01:00
2018-03-17 18:07:55 +01:00
Layout.prototype._max = function _max(numbers) {
// Calculate the maximum number in a list
var max = 0;
2016-01-16 17:27:23 +01:00
2018-03-17 18:07:55 +01:00
Object.keys(numbers).forEach(function (key) {
if (numbers[key] > max) {
max = numbers[key];
}
});
2016-01-16 17:27:23 +01:00
2018-03-17 18:07:55 +01:00
return max;
};
// Static
Layout._jQueryInterface = function _jQueryInterface(config) {
2018-03-17 18:07:55 +01:00
return this.each(function () {
var data = $(this).data(DATA_KEY);
var _config = $.extend({}, Default, $(this).data());
2018-03-17 18:07:55 +01:00
if (!data) {
data = new Layout($(this), _config);
2018-03-17 18:07:55 +01:00
$(this).data(DATA_KEY, data);
}
if (config === 'init') {
data[config]();
2018-03-17 18:07:55 +01:00
}
});
};
2015-11-11 20:29:54 +01:00
2018-02-04 00:45:19 +01:00
return Layout;
}();
2015-11-11 20:29:54 +01:00
2016-01-16 17:27:23 +01:00
/**
* Data API
* ====================================================
*/
2018-02-04 00:45:19 +01:00
$(window).on('load', function () {
Layout._jQueryInterface.call($('body'));
2016-01-16 17:27:23 +01:00
});
2015-11-11 20:29:54 +01:00
/**
* jQuery API
* ====================================================
*/
2018-02-04 00:45:19 +01:00
$.fn[NAME] = Layout._jQueryInterface;
$.fn[NAME].Constructor = Layout;
2015-11-11 20:29:54 +01:00
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
2018-02-04 00:45:19 +01:00
return Layout._jQueryInterface;
2015-11-11 20:29:54 +01:00
};
2018-02-04 00:45:19 +01:00
return Layout;
}(jQuery);
2015-11-11 20:29:54 +01:00
2018-02-04 00:45:19 +01:00
/**
* --------------------------------------------
* AdminLTE PushMenu.js
* License MIT
* --------------------------------------------
*/
var PushMenu = function ($) {
2015-11-11 20:29:54 +01:00
/**
* Constants
* ====================================================
*/
var NAME = 'PushMenu';
var DATA_KEY = 'lte.pushmenu';
var EVENT_KEY = '.' + DATA_KEY;
var JQUERY_NO_CONFLICT = $.fn[NAME];
var Event = {
COLLAPSED: 'collapsed' + EVENT_KEY,
2016-01-16 17:27:23 +01:00
SHOWN: 'shown' + EVENT_KEY
2015-11-11 20:29:54 +01:00
};
2018-03-17 18:07:55 +01:00
var Default = {
autoCollapseSize: false,
2018-03-17 18:07:55 +01:00
screenCollapseSize: 768
};
2015-11-11 20:29:54 +01:00
var Selector = {
2018-03-17 18:07:55 +01:00
TOGGLE_BUTTON: '[data-widget="pushmenu"]',
SIDEBAR_MINI: '.sidebar-mini',
SIDEBAR_COLLAPSED: '.sidebar-collapse',
BODY: 'body',
OVERLAY: '#sidebar-overlay',
WRAPPER: '.wrapper'
};
var ClassName = {
SIDEBAR_OPEN: 'sidebar-open',
2015-11-11 20:29:54 +01:00
COLLAPSED: 'sidebar-collapse',
2018-03-17 18:07:55 +01:00
OPEN: 'sidebar-open',
SIDEBAR_MINI: 'sidebar-mini'
2015-11-11 20:29:54 +01:00
2018-02-04 00:45:19 +01:00
/**
* Class Definition
* ====================================================
*/
2015-11-11 20:29:54 +01:00
2018-02-04 00:45:19 +01:00
};
var PushMenu = function () {
2018-03-17 18:07:55 +01:00
function PushMenu(element, options) {
classCallCheck(this, PushMenu);
2015-11-11 20:29:54 +01:00
2016-01-16 17:27:23 +01:00
this._element = element;
2018-03-17 18:07:55 +01:00
this._options = $.extend({}, Default, options);
this._init();
2018-03-17 18:07:55 +01:00
if (!$(Selector.OVERLAY).length) {
this._addOverlay();
}
2016-01-16 17:27:23 +01:00
}
2015-11-11 20:29:54 +01:00
2016-01-16 17:27:23 +01:00
// Public
2015-11-11 20:29:54 +01:00
2018-03-17 18:07:55 +01:00
PushMenu.prototype.show = function show() {
$(Selector.BODY).addClass(ClassName.OPEN).removeClass(ClassName.COLLAPSED);
2016-01-16 17:27:23 +01:00
2018-03-17 18:07:55 +01:00
var shownEvent = $.Event(Event.SHOWN);
$(this._element).trigger(shownEvent);
};
2015-11-11 20:29:54 +01:00
2018-03-17 18:07:55 +01:00
PushMenu.prototype.collapse = function collapse() {
$(Selector.BODY).removeClass(ClassName.OPEN).addClass(ClassName.COLLAPSED);
2016-01-16 17:27:23 +01:00
2018-03-17 18:07:55 +01:00
var collapsedEvent = $.Event(Event.COLLAPSED);
$(this._element).trigger(collapsedEvent);
};
2015-11-11 20:29:54 +01:00
PushMenu.prototype.isShown = function isShown() {
2018-03-17 18:07:55 +01:00
if ($(window).width() >= this._options.screenCollapseSize) {
return !$(Selector.BODY).hasClass(ClassName.COLLAPSED);
2018-03-17 18:07:55 +01:00
} else {
return $(Selector.BODY).hasClass(ClassName.OPEN);
2015-11-11 20:29:54 +01:00
}
};
2015-11-11 20:29:54 +01:00
PushMenu.prototype.toggle = function toggle() {
if (this.isShown()) {
2018-03-17 18:07:55 +01:00
this.collapse();
} else {
this.show();
2015-11-11 20:29:54 +01:00
}
2018-03-17 18:07:55 +01:00
};
2015-11-11 20:29:54 +01:00
PushMenu.prototype.autoCollapse = function autoCollapse() {
console.log(this._options);
if (this._options.autoCollapseSize) {
if ($(window).width() <= this._options.autoCollapseSize) {
if (this.isShown()) {
this.toggle();
}
} else {
if (!this.isShown()) {
this.toggle();
}
}
}
};
2018-03-17 18:07:55 +01:00
// Private
2015-11-11 20:29:54 +01:00
PushMenu.prototype._init = function _init() {
var _this = this;
this.autoCollapse();
$(window).resize(function () {
_this.autoCollapse();
});
};
2015-11-11 20:29:54 +01:00
2018-03-17 18:07:55 +01:00
PushMenu.prototype._addOverlay = function _addOverlay() {
var _this2 = this;
2015-11-11 20:29:54 +01:00
2018-03-17 18:07:55 +01:00
var overlay = $('<div />', {
id: 'sidebar-overlay'
});
overlay.on('click', function () {
_this2.collapse();
2018-03-17 18:07:55 +01:00
});
$(Selector.WRAPPER).append(overlay);
};
// Static
PushMenu._jQueryInterface = function _jQueryInterface(operation) {
return this.each(function () {
var data = $(this).data(DATA_KEY);
var _options = $.extend({}, Default, $(this).data());
2018-03-17 18:07:55 +01:00
if (!data) {
data = new PushMenu(this, _options);
2018-03-17 18:07:55 +01:00
$(this).data(DATA_KEY, data);
}
if (operation === 'init') {
2018-03-17 18:07:55 +01:00
data[operation]();
}
});
};
2015-11-11 20:29:54 +01:00
return PushMenu;
}();
2015-11-11 20:29:54 +01:00
/**
* Data API
* ====================================================
*/
$(document).on('click', Selector.TOGGLE_BUTTON, function (event) {
event.preventDefault();
2016-01-16 17:27:23 +01:00
var button = event.currentTarget;
2015-11-11 20:29:54 +01:00
if ($(button).data('widget') !== 'pushmenu') {
button = $(button).closest(Selector.TOGGLE_BUTTON);
}
PushMenu._jQueryInterface.call($(button), 'toggle');
});
$(window).on('load', function () {
PushMenu._jQueryInterface.call($(Selector.TOGGLE_BUTTON));
});
2015-11-11 20:29:54 +01:00
/**
* jQuery API
* ====================================================
*/
$.fn[NAME] = PushMenu._jQueryInterface;
$.fn[NAME].Constructor = PushMenu;
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
2018-02-04 00:45:19 +01:00
return PushMenu._jQueryInterface;
};
2018-02-04 00:45:19 +01:00
return PushMenu;
}(jQuery);
2016-10-26 15:30:59 +02:00
2018-02-04 00:45:19 +01:00
/**
* --------------------------------------------
2018-03-17 18:07:55 +01:00
* AdminLTE Treeview.js
2018-02-04 00:45:19 +01:00
* License MIT
* --------------------------------------------
*/
2018-03-17 18:07:55 +01:00
var Treeview = function ($) {
2016-10-26 15:30:59 +02:00
/**
* Constants
* ====================================================
*/
2018-03-17 18:07:55 +01:00
var NAME = 'Treeview';
var DATA_KEY = 'lte.treeview';
2016-10-26 15:30:59 +02:00
var EVENT_KEY = '.' + DATA_KEY;
var JQUERY_NO_CONFLICT = $.fn[NAME];
var Event = {
2018-03-17 18:07:55 +01:00
SELECTED: 'selected' + EVENT_KEY,
EXPANDED: 'expanded' + EVENT_KEY,
COLLAPSED: 'collapsed' + EVENT_KEY,
2016-10-26 15:30:59 +02:00
LOAD_DATA_API: 'load' + EVENT_KEY
};
var Selector = {
LI: '.nav-item',
LINK: '.nav-link',
2018-03-17 18:07:55 +01:00
TREEVIEW_MENU: '.nav-treeview',
2016-10-26 15:30:59 +02:00
OPEN: '.menu-open',
2018-03-17 18:07:55 +01:00
DATA_WIDGET: '[data-widget="treeview"]'
2016-10-26 15:30:59 +02:00
};
var ClassName = {
LI: 'nav-item',
LINK: 'nav-link',
2018-03-17 18:07:55 +01:00
TREEVIEW_MENU: 'nav-treeview',
2016-10-26 15:30:59 +02:00
OPEN: 'menu-open'
};
var Default = {
2018-03-17 18:07:55 +01:00
trigger: Selector.DATA_WIDGET + ' ' + Selector.LINK,
animationSpeed: 300,
accordion: true
2016-10-26 15:30:59 +02:00
2018-02-04 00:45:19 +01:00
/**
* Class Definition
* ====================================================
*/
};
2018-03-17 18:07:55 +01:00
var Treeview = function () {
function Treeview(element, config) {
classCallCheck(this, Treeview);
2016-10-26 15:30:59 +02:00
this._config = config;
this._element = element;
}
// Public
2018-03-17 18:07:55 +01:00
Treeview.prototype.init = function init() {
this._setupListeners();
};
2016-10-26 15:30:59 +02:00
2018-03-17 18:07:55 +01:00
Treeview.prototype.expand = function expand(treeviewMenu, parentLi) {
var _this = this;
2016-10-26 15:30:59 +02:00
2018-03-17 18:07:55 +01:00
var expandedEvent = $.Event(Event.EXPANDED);
2016-10-26 15:30:59 +02:00
2018-03-17 18:07:55 +01:00
if (this._config.accordion) {
var openMenuLi = parentLi.siblings(Selector.OPEN).first();
var openTreeview = openMenuLi.find(Selector.TREEVIEW_MENU).first();
this.collapse(openTreeview, openMenuLi);
2016-10-26 15:30:59 +02:00
}
2018-03-17 18:07:55 +01:00
treeviewMenu.slideDown(this._config.animationSpeed, function () {
parentLi.addClass(ClassName.OPEN);
$(_this._element).trigger(expandedEvent);
});
};
2016-10-26 15:30:59 +02:00
2018-03-17 18:07:55 +01:00
Treeview.prototype.collapse = function collapse(treeviewMenu, parentLi) {
var _this2 = this;
2016-10-26 15:30:59 +02:00
2018-03-17 18:07:55 +01:00
var collapsedEvent = $.Event(Event.COLLAPSED);
2018-02-04 00:45:19 +01:00
2018-03-17 18:07:55 +01:00
treeviewMenu.slideUp(this._config.animationSpeed, function () {
parentLi.removeClass(ClassName.OPEN);
$(_this2._element).trigger(collapsedEvent);
treeviewMenu.find(Selector.OPEN + ' > ' + Selector.TREEVIEW_MENU).slideUp();
treeviewMenu.find(Selector.OPEN).removeClass(ClassName.OPEN);
});
};
2017-01-03 16:42:20 +01:00
2018-03-17 18:07:55 +01:00
Treeview.prototype.toggle = function toggle(event) {
var $relativeTarget = $(event.currentTarget);
var treeviewMenu = $relativeTarget.next();
2017-01-03 16:42:20 +01:00
2018-03-17 18:07:55 +01:00
if (!treeviewMenu.is(Selector.TREEVIEW_MENU)) {
return;
}
2017-01-03 16:42:20 +01:00
2018-03-17 18:07:55 +01:00
event.preventDefault();
2017-01-03 16:42:20 +01:00
2018-03-17 18:07:55 +01:00
var parentLi = $relativeTarget.parents(Selector.LI).first();
var isOpen = parentLi.hasClass(ClassName.OPEN);
2017-01-03 16:42:20 +01:00
2018-03-17 18:07:55 +01:00
if (isOpen) {
this.collapse($(treeviewMenu), parentLi);
} else {
this.expand($(treeviewMenu), parentLi);
}
};
2017-01-03 16:42:20 +01:00
2018-03-17 18:07:55 +01:00
// Private
2017-01-03 16:42:20 +01:00
2018-03-17 18:07:55 +01:00
Treeview.prototype._setupListeners = function _setupListeners() {
var _this3 = this;
2017-01-03 16:42:20 +01:00
2018-03-17 18:07:55 +01:00
$(document).on('click', this._config.trigger, function (event) {
_this3.toggle(event);
});
};
2017-01-03 16:42:20 +01:00
2018-03-17 18:07:55 +01:00
// Static
2017-01-03 16:42:20 +01:00
2018-03-17 18:07:55 +01:00
Treeview._jQueryInterface = function _jQueryInterface(config) {
return this.each(function () {
var data = $(this).data(DATA_KEY);
var _config = $.extend({}, Default, $(this).data());
2017-01-03 16:42:20 +01:00
2018-03-17 18:07:55 +01:00
if (!data) {
data = new Treeview($(this), _config);
$(this).data(DATA_KEY, data);
2017-01-03 16:42:20 +01:00
}
2018-03-17 18:07:55 +01:00
if (config === 'init') {
data[config]();
}
});
};
2017-01-03 16:42:20 +01:00
2018-03-17 18:07:55 +01:00
return Treeview;
2017-01-03 16:42:20 +01:00
}();
/**
* Data API
* ====================================================
*/
2018-03-17 18:07:55 +01:00
$(window).on(Event.LOAD_DATA_API, function () {
$(Selector.DATA_WIDGET).each(function () {
Treeview._jQueryInterface.call($(this), 'init');
});
2017-01-03 16:42:20 +01:00
});
/**
* jQuery API
* ====================================================
*/
2018-03-17 18:07:55 +01:00
$.fn[NAME] = Treeview._jQueryInterface;
$.fn[NAME].Constructor = Treeview;
2017-01-03 16:42:20 +01:00
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
2018-03-17 18:07:55 +01:00
return Treeview._jQueryInterface;
2017-01-03 16:42:20 +01:00
};
2018-03-17 18:07:55 +01:00
return Treeview;
2017-01-03 16:42:20 +01:00
}(jQuery);
2018-02-04 00:45:19 +01:00
/**
* --------------------------------------------
2018-03-17 18:07:55 +01:00
* AdminLTE Widget.js
2018-02-04 00:45:19 +01:00
* License MIT
* --------------------------------------------
*/
2018-03-17 18:07:55 +01:00
var Widget = function ($) {
2018-02-04 00:45:19 +01:00
/**
* Constants
* ====================================================
*/
2018-03-17 18:07:55 +01:00
var NAME = 'Widget';
var DATA_KEY = 'lte.widget';
2018-02-04 00:45:19 +01:00
var EVENT_KEY = '.' + DATA_KEY;
var JQUERY_NO_CONFLICT = $.fn[NAME];
var Event = {
EXPANDED: 'expanded' + EVENT_KEY,
COLLAPSED: 'collapsed' + EVENT_KEY,
2018-03-17 18:07:55 +01:00
REMOVED: 'removed' + EVENT_KEY
2018-02-04 00:45:19 +01:00
};
var Selector = {
2018-03-17 18:07:55 +01:00
DATA_REMOVE: '[data-widget="remove"]',
DATA_COLLAPSE: '[data-widget="collapse"]',
CARD: '.card',
CARD_HEADER: '.card-header',
CARD_BODY: '.card-body',
CARD_FOOTER: '.card-footer',
2019-03-24 17:58:28 +01:00
COLLAPSED: '.collapsed-card',
COLLAPSE_ICON: '.fa-minus',
EXPAND_ICON: '.fa-plus'
2018-02-04 00:45:19 +01:00
};
var ClassName = {
2019-03-24 17:58:28 +01:00
COLLAPSED: 'collapsed-card',
COLLAPSE_ICON: 'fa-minus',
EXPAND_ICON: 'fa-plus'
2018-02-04 00:45:19 +01:00
};
var Default = {
2018-03-17 18:07:55 +01:00
animationSpeed: 'normal',
collapseTrigger: Selector.DATA_COLLAPSE,
removeTrigger: Selector.DATA_REMOVE
2018-02-04 00:45:19 +01:00
};
2018-03-17 18:07:55 +01:00
var Widget = function () {
function Widget(element, settings) {
classCallCheck(this, Widget);
2018-02-04 00:45:19 +01:00
this._element = element;
2018-03-17 18:07:55 +01:00
this._parent = element.parents(Selector.CARD).first();
this._settings = $.extend({}, Default, settings);
2018-02-04 00:45:19 +01:00
}
2018-03-17 18:07:55 +01:00
Widget.prototype.collapse = function collapse() {
var _this = this;
2018-02-04 00:45:19 +01:00
2018-03-17 18:07:55 +01:00
this._parent.children(Selector.CARD_BODY + ', ' + Selector.CARD_FOOTER).slideUp(this._settings.animationSpeed, function () {
_this._parent.addClass(ClassName.COLLAPSED);
});
2018-02-04 00:45:19 +01:00
2019-03-24 17:58:28 +01:00
this._element.children(Selector.COLLAPSE_ICON).addClass(ClassName.EXPAND_ICON).removeClass(ClassName.COLLAPSE_ICON);
2018-03-17 18:07:55 +01:00
var collapsed = $.Event(Event.COLLAPSED);
2018-02-04 00:45:19 +01:00
2018-03-17 18:07:55 +01:00
this._element.trigger(collapsed, this._parent);
};
2018-02-04 00:45:19 +01:00
2018-03-17 18:07:55 +01:00
Widget.prototype.expand = function expand() {
var _this2 = this;
2018-02-04 00:45:19 +01:00
2018-03-17 18:07:55 +01:00
this._parent.children(Selector.CARD_BODY + ', ' + Selector.CARD_FOOTER).slideDown(this._settings.animationSpeed, function () {
_this2._parent.removeClass(ClassName.COLLAPSED);
});
2018-02-04 00:45:19 +01:00
2019-03-24 17:58:28 +01:00
this._element.children(Selector.EXPAND_ICON).addClass(ClassName.COLLAPSE_ICON).removeClass(ClassName.EXPAND_ICON);
2018-03-17 18:07:55 +01:00
var expanded = $.Event(Event.EXPANDED);
2018-02-04 00:45:19 +01:00
2018-03-17 18:07:55 +01:00
this._element.trigger(expanded, this._parent);
};
Widget.prototype.remove = function remove() {
this._parent.slideUp();
2018-02-04 00:45:19 +01:00
2018-03-17 18:07:55 +01:00
var removed = $.Event(Event.REMOVED);
2018-02-04 00:45:19 +01:00
2018-03-17 18:07:55 +01:00
this._element.trigger(removed, this._parent);
};
2018-02-04 00:45:19 +01:00
2018-03-17 18:07:55 +01:00
Widget.prototype.toggle = function toggle() {
if (this._parent.hasClass(ClassName.COLLAPSED)) {
this.expand();
return;
2018-02-04 00:45:19 +01:00
}
2018-03-17 18:07:55 +01:00
this.collapse();
};
2018-02-04 00:45:19 +01:00
2018-03-17 18:07:55 +01:00
// Private
2018-02-04 00:45:19 +01:00
2018-03-17 18:07:55 +01:00
Widget.prototype._init = function _init(card) {
var _this3 = this;
2018-02-04 00:45:19 +01:00
2018-03-17 18:07:55 +01:00
this._parent = card;
2018-02-04 00:45:19 +01:00
2018-03-17 18:07:55 +01:00
$(this).find(this._settings.collapseTrigger).click(function () {
_this3.toggle();
});
$(this).find(this._settings.removeTrigger).click(function () {
_this3.remove();
});
};
// Static
Widget._jQueryInterface = function _jQueryInterface(config) {
return this.each(function () {
var data = $(this).data(DATA_KEY);
if (!data) {
data = new Widget($(this), data);
$(this).data(DATA_KEY, typeof config === 'string' ? data : config);
}
if (typeof config === 'string' && config.match(/remove|toggle/)) {
data[config]();
} else if ((typeof config === 'undefined' ? 'undefined' : _typeof(config)) === 'object') {
data._init($(this));
}
});
};
return Widget;
2018-02-04 00:45:19 +01:00
}();
/**
* Data API
* ====================================================
*/
2018-03-17 18:07:55 +01:00
$(document).on('click', Selector.DATA_COLLAPSE, function (event) {
if (event) {
event.preventDefault();
}
Widget._jQueryInterface.call($(this), 'toggle');
});
$(document).on('click', Selector.DATA_REMOVE, function (event) {
if (event) {
event.preventDefault();
}
Widget._jQueryInterface.call($(this), 'remove');
2018-02-04 00:45:19 +01:00
});
/**
* jQuery API
* ====================================================
*/
2018-03-17 18:07:55 +01:00
$.fn[NAME] = Widget._jQueryInterface;
$.fn[NAME].Constructor = Widget;
2018-02-04 00:45:19 +01:00
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
2018-03-17 18:07:55 +01:00
return Widget._jQueryInterface;
2018-02-04 00:45:19 +01:00
};
return Widget;
}(jQuery);
2018-03-17 18:07:55 +01:00
exports.ControlSidebar = ControlSidebar;
exports.Layout = Layout;
exports.PushMenu = PushMenu;
exports.Treeview = Treeview;
exports.Widget = Widget;
Object.defineProperty(exports, '__esModule', { value: true });
2018-02-04 00:45:19 +01:00
2018-03-17 18:07:55 +01:00
})));
//# sourceMappingURL=adminlte.js.map