You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
AdminLTE/dist/js/adminlte.js

824 lines
19 KiB

7 years ago
/*!
* AdminLTE v3.0.0-beta.1 (https://adminlte.io)
7 years ago
* Copyright 2014-2018 Abdullah Almsaeed <abdullah@almsaeedstudio.com>
* 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");
}
};
9 years ago
7 years ago
/**
* --------------------------------------------
* AdminLTE ControlSidebar.js
* License MIT
* --------------------------------------------
*/
7 years ago
var ControlSidebar = function ($) {
9 years ago
/**
* Constants
* ====================================================
*/
7 years ago
var NAME = 'ControlSidebar';
var DATA_KEY = 'lte.control.sidebar';
9 years ago
var JQUERY_NO_CONFLICT = $.fn[NAME];
var Selector = {
CONTROL_SIDEBAR: '.control-sidebar',
7 years ago
DATA_TOGGLE: '[data-widget="control-sidebar"]',
MAIN_HEADER: '.main-header'
9 years ago
};
var ClassName = {
7 years ago
CONTROL_SIDEBAR_OPEN: 'control-sidebar-open',
CONTROL_SIDEBAR_SLIDE: 'control-sidebar-slide-open'
9 years ago
};
7 years ago
var Default = {
slide: true
9 years ago
7 years ago
/**
* Class Definition
* ====================================================
*/
9 years ago
7 years ago
};
var ControlSidebar = function () {
function ControlSidebar(element, config) {
7 years ago
classCallCheck(this, ControlSidebar);
9 years ago
7 years ago
this._element = element;
this._config = this._getConfig(config);
9 years ago
}
// Public
7 years ago
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);
9 years ago
}
7 years ago
};
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);
9 years ago
}
7 years ago
};
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();
7 years ago
}
7 years ago
};
9 years ago
7 years ago
// Private
9 years ago
7 years ago
ControlSidebar.prototype._getConfig = function _getConfig(config) {
return $.extend({}, Default, config);
};
ControlSidebar.prototype._setMargin = function _setMargin() {
$(Selector.CONTROL_SIDEBAR).css({
top: $(Selector.MAIN_HEADER).outerHeight()
});
};
9 years ago
7 years ago
// Static
9 years ago
7 years ago
ControlSidebar._jQueryInterface = function _jQueryInterface(operation) {
return this.each(function () {
var data = $(this).data(DATA_KEY);
9 years ago
7 years ago
if (!data) {
data = new ControlSidebar(this, $(this).data());
$(this).data(DATA_KEY, data);
}
9 years ago
7 years ago
if (data[operation] === 'undefined') {
throw new Error(operation + ' is not a function');
}
7 years ago
7 years ago
data[operation]();
});
};
9 years ago
7 years ago
return ControlSidebar;
}();
9 years ago
/**
7 years ago
*
* Data Api implementation
* ====================================================
*/
7 years ago
7 years ago
$(document).on('click', Selector.DATA_TOGGLE, function (event) {
event.preventDefault();
7 years ago
ControlSidebar._jQueryInterface.call($(this), 'toggle');
});
9 years ago
/**
* jQuery API
* ====================================================
*/
7 years ago
$.fn[NAME] = ControlSidebar._jQueryInterface;
$.fn[NAME].Constructor = ControlSidebar;
9 years ago
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
7 years ago
return ControlSidebar._jQueryInterface;
9 years ago
};
7 years ago
return ControlSidebar;
}(jQuery);
7 years ago
/**
* --------------------------------------------
* AdminLTE Layout.js
* License MIT
* --------------------------------------------
*/
var Layout = function ($) {
/**
* Constants
* ====================================================
*/
7 years ago
var NAME = 'Layout';
var DATA_KEY = 'lte.layout';
var JQUERY_NO_CONFLICT = $.fn[NAME];
var Selector = {
7 years ago
SIDEBAR: '.main-sidebar',
HEADER: '.main-header',
CONTENT: '.content-wrapper',
CONTENT_HEADER: '.content-header',
WRAPPER: '.wrapper',
CONTROL_SIDEBAR: '.control-sidebar',
LAYOUT_FIXED: '.layout-fixed',
FOOTER: '.main-footer'
};
9 years ago
var ClassName = {
7 years ago
HOLD: 'hold-transition',
SIDEBAR: 'main-sidebar',
LAYOUT_FIXED: 'layout-fixed'
9 years ago
7 years ago
/**
* Class Definition
* ====================================================
*/
9 years ago
7 years ago
};
var Layout = function () {
function Layout(element) {
7 years ago
classCallCheck(this, Layout);
this._element = element;
7 years ago
this._init();
}
// Public
7 years ago
Layout.prototype.fixLayoutHeight = function fixLayoutHeight() {
var heights = {
window: $(window).height(),
header: $(Selector.HEADER).outerHeight(),
footer: $(Selector.FOOTER).outerHeight(),
sidebar: $(Selector.SIDEBAR).height()
};
var max = this._max(heights);
9 years ago
7 years ago
$(Selector.CONTENT).css('min-height', max - heights.header);
$(Selector.SIDEBAR).css('min-height', max - heights.header);
};
9 years ago
7 years ago
// Private
9 years ago
7 years ago
Layout.prototype._init = function _init() {
var _this = this;
9 years ago
7 years ago
// Enable transitions
$('body').removeClass(ClassName.HOLD);
9 years ago
7 years ago
// Activate layout height watcher
this.fixLayoutHeight();
$(Selector.SIDEBAR).on('collapsed.lte.treeview expanded.lte.treeview collapsed.lte.pushmenu expanded.lte.pushmenu', function () {
_this.fixLayoutHeight();
});
9 years ago
7 years ago
$(window).resize(function () {
_this.fixLayoutHeight();
});
9 years ago
7 years ago
$('body, html').css('height', 'auto');
};
9 years ago
7 years ago
Layout.prototype._max = function _max(numbers) {
// Calculate the maximum number in a list
var max = 0;
9 years ago
7 years ago
Object.keys(numbers).forEach(function (key) {
if (numbers[key] > max) {
max = numbers[key];
}
});
9 years ago
7 years ago
return max;
};
// Static
Layout._jQueryInterface = function _jQueryInterface(operation) {
return this.each(function () {
var data = $(this).data(DATA_KEY);
if (!data) {
data = new Layout(this);
$(this).data(DATA_KEY, data);
}
if (operation) {
data[operation]();
}
});
};
7 years ago
return Layout;
}();
9 years ago
/**
* Data API
* ====================================================
*/
7 years ago
$(window).on('load', function () {
Layout._jQueryInterface.call($('body'));
9 years ago
});
/**
* jQuery API
* ====================================================
*/
7 years ago
$.fn[NAME] = Layout._jQueryInterface;
$.fn[NAME].Constructor = Layout;
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
7 years ago
return Layout._jQueryInterface;
};
7 years ago
return Layout;
}(jQuery);
7 years ago
/**
* --------------------------------------------
* AdminLTE PushMenu.js
* License MIT
* --------------------------------------------
*/
var PushMenu = function ($) {
/**
* 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,
9 years ago
SHOWN: 'shown' + EVENT_KEY
};
7 years ago
var Default = {
screenCollapseSize: 768
};
var Selector = {
7 years ago
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',
COLLAPSED: 'sidebar-collapse',
7 years ago
OPEN: 'sidebar-open',
SIDEBAR_MINI: 'sidebar-mini'
7 years ago
/**
* Class Definition
* ====================================================
*/
7 years ago
};
var PushMenu = function () {
7 years ago
function PushMenu(element, options) {
classCallCheck(this, PushMenu);
9 years ago
this._element = element;
7 years ago
this._options = $.extend({}, Default, options);
if (!$(Selector.OVERLAY).length) {
this._addOverlay();
}
9 years ago
}
9 years ago
// Public
7 years ago
PushMenu.prototype.show = function show() {
$(Selector.BODY).addClass(ClassName.OPEN).removeClass(ClassName.COLLAPSED);
9 years ago
7 years ago
var shownEvent = $.Event(Event.SHOWN);
$(this._element).trigger(shownEvent);
};
7 years ago
PushMenu.prototype.collapse = function collapse() {
$(Selector.BODY).removeClass(ClassName.OPEN).addClass(ClassName.COLLAPSED);
9 years ago
7 years ago
var collapsedEvent = $.Event(Event.COLLAPSED);
$(this._element).trigger(collapsedEvent);
};
7 years ago
PushMenu.prototype.toggle = function toggle() {
var isShown = void 0;
if ($(window).width() >= this._options.screenCollapseSize) {
isShown = !$(Selector.BODY).hasClass(ClassName.COLLAPSED);
} else {
isShown = $(Selector.BODY).hasClass(ClassName.OPEN);
}
7 years ago
if (isShown) {
this.collapse();
} else {
this.show();
}
7 years ago
};
7 years ago
// Private
7 years ago
PushMenu.prototype._addOverlay = function _addOverlay() {
var _this = this;
7 years ago
var overlay = $('<div />', {
id: 'sidebar-overlay'
});
overlay.on('click', function () {
_this.collapse();
});
$(Selector.WRAPPER).append(overlay);
};
// Static
PushMenu._jQueryInterface = function _jQueryInterface(operation) {
return this.each(function () {
var data = $(this).data(DATA_KEY);
if (!data) {
data = new PushMenu(this);
$(this).data(DATA_KEY, data);
}
if (operation) {
data[operation]();
}
});
};
return PushMenu;
}();
/**
* Data API
* ====================================================
*/
$(document).on('click', Selector.TOGGLE_BUTTON, function (event) {
event.preventDefault();
9 years ago
var button = event.currentTarget;
if ($(button).data('widget') !== 'pushmenu') {
button = $(button).closest(Selector.TOGGLE_BUTTON);
}
PushMenu._jQueryInterface.call($(button), 'toggle');
});
/**
* jQuery API
* ====================================================
*/
$.fn[NAME] = PushMenu._jQueryInterface;
$.fn[NAME].Constructor = PushMenu;
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
7 years ago
return PushMenu._jQueryInterface;
};
7 years ago
return PushMenu;
}(jQuery);
7 years ago
/**
* --------------------------------------------
7 years ago
* AdminLTE Treeview.js
7 years ago
* License MIT
* --------------------------------------------
*/
7 years ago
var Treeview = function ($) {
/**
* Constants
* ====================================================
*/
7 years ago
var NAME = 'Treeview';
var DATA_KEY = 'lte.treeview';
var EVENT_KEY = '.' + DATA_KEY;
var JQUERY_NO_CONFLICT = $.fn[NAME];
var Event = {
7 years ago
SELECTED: 'selected' + EVENT_KEY,
EXPANDED: 'expanded' + EVENT_KEY,
COLLAPSED: 'collapsed' + EVENT_KEY,
LOAD_DATA_API: 'load' + EVENT_KEY
};
var Selector = {
LI: '.nav-item',
LINK: '.nav-link',
7 years ago
TREEVIEW_MENU: '.nav-treeview',
OPEN: '.menu-open',
7 years ago
DATA_WIDGET: '[data-widget="treeview"]'
};
var ClassName = {
LI: 'nav-item',
LINK: 'nav-link',
7 years ago
TREEVIEW_MENU: 'nav-treeview',
OPEN: 'menu-open'
};
var Default = {
7 years ago
trigger: Selector.DATA_WIDGET + ' ' + Selector.LINK,
animationSpeed: 300,
accordion: true
7 years ago
/**
* Class Definition
* ====================================================
*/
};
7 years ago
var Treeview = function () {
function Treeview(element, config) {
classCallCheck(this, Treeview);
this._config = config;
this._element = element;
}
// Public
7 years ago
Treeview.prototype.init = function init() {
this._setupListeners();
};
7 years ago
Treeview.prototype.expand = function expand(treeviewMenu, parentLi) {
var _this = this;
7 years ago
var expandedEvent = $.Event(Event.EXPANDED);
7 years ago
if (this._config.accordion) {
var openMenuLi = parentLi.siblings(Selector.OPEN).first();
var openTreeview = openMenuLi.find(Selector.TREEVIEW_MENU).first();
this.collapse(openTreeview, openMenuLi);
}
7 years ago
treeviewMenu.slideDown(this._config.animationSpeed, function () {
parentLi.addClass(ClassName.OPEN);
$(_this._element).trigger(expandedEvent);
});
};
7 years ago
Treeview.prototype.collapse = function collapse(treeviewMenu, parentLi) {
var _this2 = this;
7 years ago
var collapsedEvent = $.Event(Event.COLLAPSED);
7 years ago
7 years ago
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);
});
};
7 years ago
Treeview.prototype.toggle = function toggle(event) {
var $relativeTarget = $(event.currentTarget);
var treeviewMenu = $relativeTarget.next();
7 years ago
if (!treeviewMenu.is(Selector.TREEVIEW_MENU)) {
return;
}
7 years ago
event.preventDefault();
7 years ago
var parentLi = $relativeTarget.parents(Selector.LI).first();
var isOpen = parentLi.hasClass(ClassName.OPEN);
7 years ago
if (isOpen) {
this.collapse($(treeviewMenu), parentLi);
} else {
this.expand($(treeviewMenu), parentLi);
}
};
7 years ago
// Private
7 years ago
Treeview.prototype._setupListeners = function _setupListeners() {
var _this3 = this;
7 years ago
$(document).on('click', this._config.trigger, function (event) {
_this3.toggle(event);
});
};
7 years ago
// Static
7 years ago
Treeview._jQueryInterface = function _jQueryInterface(config) {
return this.each(function () {
var data = $(this).data(DATA_KEY);
var _config = $.extend({}, Default, $(this).data());
7 years ago
if (!data) {
data = new Treeview($(this), _config);
$(this).data(DATA_KEY, data);
}
7 years ago
if (config === 'init') {
data[config]();
}
});
};
7 years ago
return Treeview;
}();
/**
* Data API
* ====================================================
*/
7 years ago
$(window).on(Event.LOAD_DATA_API, function () {
$(Selector.DATA_WIDGET).each(function () {
Treeview._jQueryInterface.call($(this), 'init');
});
});
/**
* jQuery API
* ====================================================
*/
7 years ago
$.fn[NAME] = Treeview._jQueryInterface;
$.fn[NAME].Constructor = Treeview;
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
7 years ago
return Treeview._jQueryInterface;
};
7 years ago
return Treeview;
}(jQuery);
7 years ago
/**
* --------------------------------------------
7 years ago
* AdminLTE Widget.js
7 years ago
* License MIT
* --------------------------------------------
*/
7 years ago
var Widget = function ($) {
7 years ago
/**
* Constants
* ====================================================
*/
7 years ago
var NAME = 'Widget';
var DATA_KEY = 'lte.widget';
7 years ago
var EVENT_KEY = '.' + DATA_KEY;
var JQUERY_NO_CONFLICT = $.fn[NAME];
var Event = {
EXPANDED: 'expanded' + EVENT_KEY,
COLLAPSED: 'collapsed' + EVENT_KEY,
7 years ago
REMOVED: 'removed' + EVENT_KEY
7 years ago
};
var Selector = {
7 years ago
DATA_REMOVE: '[data-widget="remove"]',
DATA_COLLAPSE: '[data-widget="collapse"]',
CARD: '.card',
CARD_HEADER: '.card-header',
CARD_BODY: '.card-body',
CARD_FOOTER: '.card-footer',
COLLAPSED: '.collapsed-card'
7 years ago
};
var ClassName = {
7 years ago
COLLAPSED: 'collapsed-card'
7 years ago
};
var Default = {
7 years ago
animationSpeed: 'normal',
collapseTrigger: Selector.DATA_COLLAPSE,
removeTrigger: Selector.DATA_REMOVE
7 years ago
};
7 years ago
var Widget = function () {
function Widget(element, settings) {
classCallCheck(this, Widget);
7 years ago
this._element = element;
7 years ago
this._parent = element.parents(Selector.CARD).first();
this._settings = $.extend({}, Default, settings);
7 years ago
}
7 years ago
Widget.prototype.collapse = function collapse() {
var _this = this;
7 years ago
7 years ago
this._parent.children(Selector.CARD_BODY + ', ' + Selector.CARD_FOOTER).slideUp(this._settings.animationSpeed, function () {
_this._parent.addClass(ClassName.COLLAPSED);
});
7 years ago
7 years ago
var collapsed = $.Event(Event.COLLAPSED);
7 years ago
7 years ago
this._element.trigger(collapsed, this._parent);
};
7 years ago
7 years ago
Widget.prototype.expand = function expand() {
var _this2 = this;
7 years ago
7 years ago
this._parent.children(Selector.CARD_BODY + ', ' + Selector.CARD_FOOTER).slideDown(this._settings.animationSpeed, function () {
_this2._parent.removeClass(ClassName.COLLAPSED);
});
7 years ago
7 years ago
var expanded = $.Event(Event.EXPANDED);
7 years ago
7 years ago
this._element.trigger(expanded, this._parent);
};
Widget.prototype.remove = function remove() {
this._parent.slideUp();
7 years ago
7 years ago
var removed = $.Event(Event.REMOVED);
7 years ago
7 years ago
this._element.trigger(removed, this._parent);
};
7 years ago
7 years ago
Widget.prototype.toggle = function toggle() {
if (this._parent.hasClass(ClassName.COLLAPSED)) {
this.expand();
return;
7 years ago
}
7 years ago
this.collapse();
};
7 years ago
7 years ago
// Private
7 years ago
7 years ago
Widget.prototype._init = function _init(card) {
var _this3 = this;
7 years ago
7 years ago
this._parent = card;
7 years ago
7 years ago
$(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;
7 years ago
}();
/**
* Data API
* ====================================================
*/
7 years ago
$(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');
7 years ago
});
/**
* jQuery API
* ====================================================
*/
7 years ago
$.fn[NAME] = Widget._jQueryInterface;
$.fn[NAME].Constructor = Widget;
7 years ago
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
7 years ago
return Widget._jQueryInterface;
7 years ago
};
return Widget;
}(jQuery);
7 years ago
exports.ControlSidebar = ControlSidebar;
exports.Layout = Layout;
exports.PushMenu = PushMenu;
exports.Treeview = Treeview;
exports.Widget = Widget;
Object.defineProperty(exports, '__esModule', { value: true });
7 years ago
7 years ago
})));
//# sourceMappingURL=adminlte.js.map