adminlte.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910
  1. /*!
  2. * AdminLTE v3.0.0-beta.1 (https://adminlte.io)
  3. * Copyright 2014-2019 Abdullah Almsaeed <abdullah@almsaeedstudio.com>
  4. * Licensed under MIT (https://github.com/almasaeed2010/AdminLTE/blob/master/LICENSE)
  5. */
  6. (function (global, factory) {
  7. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
  8. typeof define === 'function' && define.amd ? define(['exports'], factory) :
  9. (factory((global.adminlte = {})));
  10. }(this, (function (exports) { 'use strict';
  11. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
  12. return typeof obj;
  13. } : function (obj) {
  14. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  15. };
  16. var classCallCheck = function (instance, Constructor) {
  17. if (!(instance instanceof Constructor)) {
  18. throw new TypeError("Cannot call a class as a function");
  19. }
  20. };
  21. /**
  22. * --------------------------------------------
  23. * AdminLTE ControlSidebar.js
  24. * License MIT
  25. * --------------------------------------------
  26. */
  27. var ControlSidebar = function ($) {
  28. /**
  29. * Constants
  30. * ====================================================
  31. */
  32. var NAME = 'ControlSidebar';
  33. var DATA_KEY = 'lte.control.sidebar';
  34. var JQUERY_NO_CONFLICT = $.fn[NAME];
  35. var Selector = {
  36. CONTROL_SIDEBAR: '.control-sidebar',
  37. DATA_TOGGLE: '[data-widget="control-sidebar"]',
  38. MAIN_HEADER: '.main-header'
  39. };
  40. var ClassName = {
  41. CONTROL_SIDEBAR_OPEN: 'control-sidebar-open',
  42. CONTROL_SIDEBAR_SLIDE: 'control-sidebar-slide-open'
  43. };
  44. var Default = {
  45. slide: true
  46. /**
  47. * Class Definition
  48. * ====================================================
  49. */
  50. };
  51. var ControlSidebar = function () {
  52. function ControlSidebar(element, config) {
  53. classCallCheck(this, ControlSidebar);
  54. this._element = element;
  55. this._config = this._getConfig(config);
  56. }
  57. // Public
  58. ControlSidebar.prototype.show = function show() {
  59. // Show the control sidebar
  60. if (this._config.slide) {
  61. $('body').removeClass(ClassName.CONTROL_SIDEBAR_SLIDE);
  62. } else {
  63. $('body').removeClass(ClassName.CONTROL_SIDEBAR_OPEN);
  64. }
  65. };
  66. ControlSidebar.prototype.collapse = function collapse() {
  67. // Collapse the control sidebar
  68. if (this._config.slide) {
  69. $('body').addClass(ClassName.CONTROL_SIDEBAR_SLIDE);
  70. } else {
  71. $('body').addClass(ClassName.CONTROL_SIDEBAR_OPEN);
  72. }
  73. };
  74. ControlSidebar.prototype.toggle = function toggle() {
  75. this._setMargin();
  76. var shouldOpen = $('body').hasClass(ClassName.CONTROL_SIDEBAR_OPEN) || $('body').hasClass(ClassName.CONTROL_SIDEBAR_SLIDE);
  77. if (shouldOpen) {
  78. // Open the control sidebar
  79. this.show();
  80. } else {
  81. // Close the control sidebar
  82. this.collapse();
  83. }
  84. };
  85. // Private
  86. ControlSidebar.prototype._getConfig = function _getConfig(config) {
  87. return $.extend({}, Default, config);
  88. };
  89. ControlSidebar.prototype._setMargin = function _setMargin() {
  90. $(Selector.CONTROL_SIDEBAR).css({
  91. top: $(Selector.MAIN_HEADER).innerHeight()
  92. });
  93. };
  94. // Static
  95. ControlSidebar._jQueryInterface = function _jQueryInterface(operation) {
  96. return this.each(function () {
  97. var data = $(this).data(DATA_KEY);
  98. if (!data) {
  99. data = new ControlSidebar(this, $(this).data());
  100. $(this).data(DATA_KEY, data);
  101. }
  102. if (data[operation] === 'undefined') {
  103. throw new Error(operation + ' is not a function');
  104. }
  105. data[operation]();
  106. });
  107. };
  108. return ControlSidebar;
  109. }();
  110. /**
  111. *
  112. * Data Api implementation
  113. * ====================================================
  114. */
  115. $(document).on('click', Selector.DATA_TOGGLE, function (event) {
  116. event.preventDefault();
  117. ControlSidebar._jQueryInterface.call($(this), 'toggle');
  118. });
  119. /**
  120. * jQuery API
  121. * ====================================================
  122. */
  123. $.fn[NAME] = ControlSidebar._jQueryInterface;
  124. $.fn[NAME].Constructor = ControlSidebar;
  125. $.fn[NAME].noConflict = function () {
  126. $.fn[NAME] = JQUERY_NO_CONFLICT;
  127. return ControlSidebar._jQueryInterface;
  128. };
  129. return ControlSidebar;
  130. }(jQuery);
  131. /**
  132. * --------------------------------------------
  133. * AdminLTE Layout.js
  134. * License MIT
  135. * --------------------------------------------
  136. */
  137. var Layout = function ($) {
  138. /**
  139. * Constants
  140. * ====================================================
  141. */
  142. var NAME = 'Layout';
  143. var DATA_KEY = 'lte.layout';
  144. var JQUERY_NO_CONFLICT = $.fn[NAME];
  145. var Selector = {
  146. HEADER: '.main-header',
  147. SIDEBAR: '.main-sidebar .sidebar',
  148. CONTENT: '.content-wrapper',
  149. BRAND: '.brand-link',
  150. CONTENT_HEADER: '.content-header',
  151. WRAPPER: '.wrapper',
  152. CONTROL_SIDEBAR: '.control-sidebar',
  153. LAYOUT_FIXED: '.layout-fixed',
  154. FOOTER: '.main-footer'
  155. };
  156. var ClassName = {
  157. HOLD: 'hold-transition',
  158. SIDEBAR: 'main-sidebar',
  159. LAYOUT_FIXED: 'layout-fixed',
  160. NAVBAR_FIXED: 'layout-navbar-fixed',
  161. FOOTER_FIXED: 'layout-footer-fixed'
  162. };
  163. var Default = {
  164. scrollbarTheme: 'os-theme-light',
  165. scrollbarAutoHide: 'l'
  166. /**
  167. * Class Definition
  168. * ====================================================
  169. */
  170. };
  171. var Layout = function () {
  172. function Layout(element, config) {
  173. classCallCheck(this, Layout);
  174. this._config = config;
  175. this._element = element;
  176. this._init();
  177. }
  178. // Public
  179. Layout.prototype.fixLayoutHeight = function fixLayoutHeight() {
  180. var heights = {
  181. window: $(window).height(),
  182. header: $(Selector.HEADER).outerHeight(),
  183. footer: $(Selector.FOOTER).outerHeight(),
  184. sidebar: $(Selector.SIDEBAR).height()
  185. };
  186. var max = this._max(heights);
  187. if ($('body').hasClass(ClassName.LAYOUT_FIXED)) {
  188. $(Selector.CONTENT).css('min-height', max - heights.header - heights.footer);
  189. // $(Selector.SIDEBAR).css('min-height', max - heights.header)
  190. $(Selector.CONTROL_SIDEBAR + ' .control-sidebar-content').css('height', max - heights.header);
  191. if (typeof $.fn.overlayScrollbars !== 'undefined') {
  192. $(Selector.SIDEBAR).overlayScrollbars({
  193. className: this._config.scrollbarTheme,
  194. sizeAutoCapable: true,
  195. scrollbars: {
  196. autoHide: this._config.scrollbarAutoHide,
  197. clickScrolling: true
  198. }
  199. });
  200. $(Selector.CONTROL_SIDEBAR + ' .control-sidebar-content').overlayScrollbars({
  201. className: this._config.scrollbarTheme,
  202. sizeAutoCapable: true,
  203. scrollbars: {
  204. autoHide: this._config.scrollbarAutoHide,
  205. clickScrolling: true
  206. }
  207. });
  208. }
  209. } else {
  210. if (heights.window > heights.sidebar) {
  211. $(Selector.CONTENT).css('min-height', heights.window - heights.header - heights.footer);
  212. } else {
  213. $(Selector.CONTENT).css('min-height', heights.sidebar - heights.header);
  214. }
  215. }
  216. if ($('body').hasClass(ClassName.NAVBAR_FIXED)) {
  217. $(Selector.BRAND).css('height', heights.header);
  218. $(Selector.SIDEBAR).css('margin-top', heights.header);
  219. $(Selector.SIDEBAR).css('margin-top', heights.header);
  220. }
  221. if ($('body').hasClass(ClassName.FOOTER_FIXED)) {
  222. $(Selector.CONTENT).css('margin-bottom', heights.footer);
  223. }
  224. };
  225. // Private
  226. Layout.prototype._init = function _init() {
  227. var _this = this;
  228. // Enable transitions
  229. $('body').removeClass(ClassName.HOLD);
  230. // Activate layout height watcher
  231. this.fixLayoutHeight();
  232. $(Selector.SIDEBAR).on('collapsed.lte.treeview expanded.lte.treeview collapsed.lte.pushmenu expanded.lte.pushmenu', function () {
  233. _this.fixLayoutHeight();
  234. });
  235. $(window).resize(function () {
  236. _this.fixLayoutHeight();
  237. });
  238. $('body, html').css('height', 'auto');
  239. };
  240. Layout.prototype._max = function _max(numbers) {
  241. // Calculate the maximum number in a list
  242. var max = 0;
  243. Object.keys(numbers).forEach(function (key) {
  244. if (numbers[key] > max) {
  245. max = numbers[key];
  246. }
  247. });
  248. return max;
  249. };
  250. // Static
  251. Layout._jQueryInterface = function _jQueryInterface(config) {
  252. return this.each(function () {
  253. var data = $(this).data(DATA_KEY);
  254. var _config = $.extend({}, Default, $(this).data());
  255. if (!data) {
  256. data = new Layout($(this), _config);
  257. $(this).data(DATA_KEY, data);
  258. }
  259. if (config === 'init') {
  260. data[config]();
  261. }
  262. });
  263. };
  264. return Layout;
  265. }();
  266. /**
  267. * Data API
  268. * ====================================================
  269. */
  270. $(window).on('load', function () {
  271. Layout._jQueryInterface.call($('body'));
  272. });
  273. /**
  274. * jQuery API
  275. * ====================================================
  276. */
  277. $.fn[NAME] = Layout._jQueryInterface;
  278. $.fn[NAME].Constructor = Layout;
  279. $.fn[NAME].noConflict = function () {
  280. $.fn[NAME] = JQUERY_NO_CONFLICT;
  281. return Layout._jQueryInterface;
  282. };
  283. return Layout;
  284. }(jQuery);
  285. /**
  286. * --------------------------------------------
  287. * AdminLTE PushMenu.js
  288. * License MIT
  289. * --------------------------------------------
  290. */
  291. var PushMenu = function ($) {
  292. /**
  293. * Constants
  294. * ====================================================
  295. */
  296. var NAME = 'PushMenu';
  297. var DATA_KEY = 'lte.pushmenu';
  298. var EVENT_KEY = '.' + DATA_KEY;
  299. var JQUERY_NO_CONFLICT = $.fn[NAME];
  300. var Event = {
  301. COLLAPSED: 'collapsed' + EVENT_KEY,
  302. SHOWN: 'shown' + EVENT_KEY
  303. };
  304. var Default = {
  305. autoCollapseSize: false,
  306. screenCollapseSize: 768
  307. };
  308. var Selector = {
  309. TOGGLE_BUTTON: '[data-widget="pushmenu"]',
  310. SIDEBAR_MINI: '.sidebar-mini',
  311. SIDEBAR_COLLAPSED: '.sidebar-collapse',
  312. BODY: 'body',
  313. OVERLAY: '#sidebar-overlay',
  314. WRAPPER: '.wrapper'
  315. };
  316. var ClassName = {
  317. SIDEBAR_OPEN: 'sidebar-open',
  318. COLLAPSED: 'sidebar-collapse',
  319. OPEN: 'sidebar-open',
  320. SIDEBAR_MINI: 'sidebar-mini'
  321. /**
  322. * Class Definition
  323. * ====================================================
  324. */
  325. };
  326. var PushMenu = function () {
  327. function PushMenu(element, options) {
  328. classCallCheck(this, PushMenu);
  329. this._element = element;
  330. this._options = $.extend({}, Default, options);
  331. this._init();
  332. if (!$(Selector.OVERLAY).length) {
  333. this._addOverlay();
  334. }
  335. }
  336. // Public
  337. PushMenu.prototype.show = function show() {
  338. $(Selector.BODY).addClass(ClassName.OPEN).removeClass(ClassName.COLLAPSED);
  339. var shownEvent = $.Event(Event.SHOWN);
  340. $(this._element).trigger(shownEvent);
  341. };
  342. PushMenu.prototype.collapse = function collapse() {
  343. $(Selector.BODY).removeClass(ClassName.OPEN).addClass(ClassName.COLLAPSED);
  344. var collapsedEvent = $.Event(Event.COLLAPSED);
  345. $(this._element).trigger(collapsedEvent);
  346. };
  347. PushMenu.prototype.isShown = function isShown() {
  348. if ($(window).width() >= this._options.screenCollapseSize) {
  349. return !$(Selector.BODY).hasClass(ClassName.COLLAPSED);
  350. } else {
  351. return $(Selector.BODY).hasClass(ClassName.OPEN);
  352. }
  353. };
  354. PushMenu.prototype.toggle = function toggle() {
  355. if (this.isShown()) {
  356. this.collapse();
  357. } else {
  358. this.show();
  359. }
  360. };
  361. PushMenu.prototype.autoCollapse = function autoCollapse() {
  362. console.log(this._options);
  363. if (this._options.autoCollapseSize) {
  364. if ($(window).width() <= this._options.autoCollapseSize) {
  365. if (this.isShown()) {
  366. this.toggle();
  367. }
  368. } else {
  369. if (!this.isShown()) {
  370. this.toggle();
  371. }
  372. }
  373. }
  374. };
  375. // Private
  376. PushMenu.prototype._init = function _init() {
  377. var _this = this;
  378. this.autoCollapse();
  379. $(window).resize(function () {
  380. _this.autoCollapse();
  381. });
  382. };
  383. PushMenu.prototype._addOverlay = function _addOverlay() {
  384. var _this2 = this;
  385. var overlay = $('<div />', {
  386. id: 'sidebar-overlay'
  387. });
  388. overlay.on('click', function () {
  389. _this2.collapse();
  390. });
  391. $(Selector.WRAPPER).append(overlay);
  392. };
  393. // Static
  394. PushMenu._jQueryInterface = function _jQueryInterface(operation) {
  395. return this.each(function () {
  396. var data = $(this).data(DATA_KEY);
  397. var _options = $.extend({}, Default, $(this).data());
  398. if (!data) {
  399. data = new PushMenu(this, _options);
  400. $(this).data(DATA_KEY, data);
  401. }
  402. if (operation === 'init') {
  403. data[operation]();
  404. }
  405. });
  406. };
  407. return PushMenu;
  408. }();
  409. /**
  410. * Data API
  411. * ====================================================
  412. */
  413. $(document).on('click', Selector.TOGGLE_BUTTON, function (event) {
  414. event.preventDefault();
  415. var button = event.currentTarget;
  416. if ($(button).data('widget') !== 'pushmenu') {
  417. button = $(button).closest(Selector.TOGGLE_BUTTON);
  418. }
  419. PushMenu._jQueryInterface.call($(button), 'toggle');
  420. });
  421. $(window).on('load', function () {
  422. PushMenu._jQueryInterface.call($(Selector.TOGGLE_BUTTON));
  423. });
  424. /**
  425. * jQuery API
  426. * ====================================================
  427. */
  428. $.fn[NAME] = PushMenu._jQueryInterface;
  429. $.fn[NAME].Constructor = PushMenu;
  430. $.fn[NAME].noConflict = function () {
  431. $.fn[NAME] = JQUERY_NO_CONFLICT;
  432. return PushMenu._jQueryInterface;
  433. };
  434. return PushMenu;
  435. }(jQuery);
  436. /**
  437. * --------------------------------------------
  438. * AdminLTE Treeview.js
  439. * License MIT
  440. * --------------------------------------------
  441. */
  442. var Treeview = function ($) {
  443. /**
  444. * Constants
  445. * ====================================================
  446. */
  447. var NAME = 'Treeview';
  448. var DATA_KEY = 'lte.treeview';
  449. var EVENT_KEY = '.' + DATA_KEY;
  450. var JQUERY_NO_CONFLICT = $.fn[NAME];
  451. var Event = {
  452. SELECTED: 'selected' + EVENT_KEY,
  453. EXPANDED: 'expanded' + EVENT_KEY,
  454. COLLAPSED: 'collapsed' + EVENT_KEY,
  455. LOAD_DATA_API: 'load' + EVENT_KEY
  456. };
  457. var Selector = {
  458. LI: '.nav-item',
  459. LINK: '.nav-link',
  460. TREEVIEW_MENU: '.nav-treeview',
  461. OPEN: '.menu-open',
  462. DATA_WIDGET: '[data-widget="treeview"]'
  463. };
  464. var ClassName = {
  465. LI: 'nav-item',
  466. LINK: 'nav-link',
  467. TREEVIEW_MENU: 'nav-treeview',
  468. OPEN: 'menu-open'
  469. };
  470. var Default = {
  471. trigger: Selector.DATA_WIDGET + ' ' + Selector.LINK,
  472. animationSpeed: 300,
  473. accordion: true
  474. /**
  475. * Class Definition
  476. * ====================================================
  477. */
  478. };
  479. var Treeview = function () {
  480. function Treeview(element, config) {
  481. classCallCheck(this, Treeview);
  482. this._config = config;
  483. this._element = element;
  484. }
  485. // Public
  486. Treeview.prototype.init = function init() {
  487. this._setupListeners();
  488. };
  489. Treeview.prototype.expand = function expand(treeviewMenu, parentLi) {
  490. var _this = this;
  491. var expandedEvent = $.Event(Event.EXPANDED);
  492. if (this._config.accordion) {
  493. var openMenuLi = parentLi.siblings(Selector.OPEN).first();
  494. var openTreeview = openMenuLi.find(Selector.TREEVIEW_MENU).first();
  495. this.collapse(openTreeview, openMenuLi);
  496. }
  497. treeviewMenu.slideDown(this._config.animationSpeed, function () {
  498. parentLi.addClass(ClassName.OPEN);
  499. $(_this._element).trigger(expandedEvent);
  500. });
  501. };
  502. Treeview.prototype.collapse = function collapse(treeviewMenu, parentLi) {
  503. var _this2 = this;
  504. var collapsedEvent = $.Event(Event.COLLAPSED);
  505. treeviewMenu.slideUp(this._config.animationSpeed, function () {
  506. parentLi.removeClass(ClassName.OPEN);
  507. $(_this2._element).trigger(collapsedEvent);
  508. treeviewMenu.find(Selector.OPEN + ' > ' + Selector.TREEVIEW_MENU).slideUp();
  509. treeviewMenu.find(Selector.OPEN).removeClass(ClassName.OPEN);
  510. });
  511. };
  512. Treeview.prototype.toggle = function toggle(event) {
  513. var $relativeTarget = $(event.currentTarget);
  514. var treeviewMenu = $relativeTarget.next();
  515. if (!treeviewMenu.is(Selector.TREEVIEW_MENU)) {
  516. return;
  517. }
  518. event.preventDefault();
  519. var parentLi = $relativeTarget.parents(Selector.LI).first();
  520. var isOpen = parentLi.hasClass(ClassName.OPEN);
  521. if (isOpen) {
  522. this.collapse($(treeviewMenu), parentLi);
  523. } else {
  524. this.expand($(treeviewMenu), parentLi);
  525. }
  526. };
  527. // Private
  528. Treeview.prototype._setupListeners = function _setupListeners() {
  529. var _this3 = this;
  530. $(document).on('click', this._config.trigger, function (event) {
  531. _this3.toggle(event);
  532. });
  533. };
  534. // Static
  535. Treeview._jQueryInterface = function _jQueryInterface(config) {
  536. return this.each(function () {
  537. var data = $(this).data(DATA_KEY);
  538. var _config = $.extend({}, Default, $(this).data());
  539. if (!data) {
  540. data = new Treeview($(this), _config);
  541. $(this).data(DATA_KEY, data);
  542. }
  543. if (config === 'init') {
  544. data[config]();
  545. }
  546. });
  547. };
  548. return Treeview;
  549. }();
  550. /**
  551. * Data API
  552. * ====================================================
  553. */
  554. $(window).on(Event.LOAD_DATA_API, function () {
  555. $(Selector.DATA_WIDGET).each(function () {
  556. Treeview._jQueryInterface.call($(this), 'init');
  557. });
  558. });
  559. /**
  560. * jQuery API
  561. * ====================================================
  562. */
  563. $.fn[NAME] = Treeview._jQueryInterface;
  564. $.fn[NAME].Constructor = Treeview;
  565. $.fn[NAME].noConflict = function () {
  566. $.fn[NAME] = JQUERY_NO_CONFLICT;
  567. return Treeview._jQueryInterface;
  568. };
  569. return Treeview;
  570. }(jQuery);
  571. /**
  572. * --------------------------------------------
  573. * AdminLTE Widget.js
  574. * License MIT
  575. * --------------------------------------------
  576. */
  577. var Widget = function ($) {
  578. /**
  579. * Constants
  580. * ====================================================
  581. */
  582. var NAME = 'Widget';
  583. var DATA_KEY = 'lte.widget';
  584. var EVENT_KEY = '.' + DATA_KEY;
  585. var JQUERY_NO_CONFLICT = $.fn[NAME];
  586. var Event = {
  587. EXPANDED: 'expanded' + EVENT_KEY,
  588. COLLAPSED: 'collapsed' + EVENT_KEY,
  589. REMOVED: 'removed' + EVENT_KEY
  590. };
  591. var Selector = {
  592. DATA_REMOVE: '[data-widget="remove"]',
  593. DATA_COLLAPSE: '[data-widget="collapse"]',
  594. CARD: '.card',
  595. CARD_HEADER: '.card-header',
  596. CARD_BODY: '.card-body',
  597. CARD_FOOTER: '.card-footer',
  598. COLLAPSED: '.collapsed-card',
  599. COLLAPSE_ICON: '.fa-minus',
  600. EXPAND_ICON: '.fa-plus'
  601. };
  602. var ClassName = {
  603. COLLAPSED: 'collapsed-card',
  604. COLLAPSE_ICON: 'fa-minus',
  605. EXPAND_ICON: 'fa-plus'
  606. };
  607. var Default = {
  608. animationSpeed: 'normal',
  609. collapseTrigger: Selector.DATA_COLLAPSE,
  610. removeTrigger: Selector.DATA_REMOVE
  611. };
  612. var Widget = function () {
  613. function Widget(element, settings) {
  614. classCallCheck(this, Widget);
  615. this._element = element;
  616. this._parent = element.parents(Selector.CARD).first();
  617. this._settings = $.extend({}, Default, settings);
  618. }
  619. Widget.prototype.collapse = function collapse() {
  620. var _this = this;
  621. this._parent.children(Selector.CARD_BODY + ', ' + Selector.CARD_FOOTER).slideUp(this._settings.animationSpeed, function () {
  622. _this._parent.addClass(ClassName.COLLAPSED);
  623. });
  624. this._element.children(Selector.COLLAPSE_ICON).addClass(ClassName.EXPAND_ICON).removeClass(ClassName.COLLAPSE_ICON);
  625. var collapsed = $.Event(Event.COLLAPSED);
  626. this._element.trigger(collapsed, this._parent);
  627. };
  628. Widget.prototype.expand = function expand() {
  629. var _this2 = this;
  630. this._parent.children(Selector.CARD_BODY + ', ' + Selector.CARD_FOOTER).slideDown(this._settings.animationSpeed, function () {
  631. _this2._parent.removeClass(ClassName.COLLAPSED);
  632. });
  633. this._element.children(Selector.EXPAND_ICON).addClass(ClassName.COLLAPSE_ICON).removeClass(ClassName.EXPAND_ICON);
  634. var expanded = $.Event(Event.EXPANDED);
  635. this._element.trigger(expanded, this._parent);
  636. };
  637. Widget.prototype.remove = function remove() {
  638. this._parent.slideUp();
  639. var removed = $.Event(Event.REMOVED);
  640. this._element.trigger(removed, this._parent);
  641. };
  642. Widget.prototype.toggle = function toggle() {
  643. if (this._parent.hasClass(ClassName.COLLAPSED)) {
  644. this.expand();
  645. return;
  646. }
  647. this.collapse();
  648. };
  649. // Private
  650. Widget.prototype._init = function _init(card) {
  651. var _this3 = this;
  652. this._parent = card;
  653. $(this).find(this._settings.collapseTrigger).click(function () {
  654. _this3.toggle();
  655. });
  656. $(this).find(this._settings.removeTrigger).click(function () {
  657. _this3.remove();
  658. });
  659. };
  660. // Static
  661. Widget._jQueryInterface = function _jQueryInterface(config) {
  662. return this.each(function () {
  663. var data = $(this).data(DATA_KEY);
  664. if (!data) {
  665. data = new Widget($(this), data);
  666. $(this).data(DATA_KEY, typeof config === 'string' ? data : config);
  667. }
  668. if (typeof config === 'string' && config.match(/remove|toggle/)) {
  669. data[config]();
  670. } else if ((typeof config === 'undefined' ? 'undefined' : _typeof(config)) === 'object') {
  671. data._init($(this));
  672. }
  673. });
  674. };
  675. return Widget;
  676. }();
  677. /**
  678. * Data API
  679. * ====================================================
  680. */
  681. $(document).on('click', Selector.DATA_COLLAPSE, function (event) {
  682. if (event) {
  683. event.preventDefault();
  684. }
  685. Widget._jQueryInterface.call($(this), 'toggle');
  686. });
  687. $(document).on('click', Selector.DATA_REMOVE, function (event) {
  688. if (event) {
  689. event.preventDefault();
  690. }
  691. Widget._jQueryInterface.call($(this), 'remove');
  692. });
  693. /**
  694. * jQuery API
  695. * ====================================================
  696. */
  697. $.fn[NAME] = Widget._jQueryInterface;
  698. $.fn[NAME].Constructor = Widget;
  699. $.fn[NAME].noConflict = function () {
  700. $.fn[NAME] = JQUERY_NO_CONFLICT;
  701. return Widget._jQueryInterface;
  702. };
  703. return Widget;
  704. }(jQuery);
  705. exports.ControlSidebar = ControlSidebar;
  706. exports.Layout = Layout;
  707. exports.PushMenu = PushMenu;
  708. exports.Treeview = Treeview;
  709. exports.Widget = Widget;
  710. Object.defineProperty(exports, '__esModule', { value: true });
  711. })));
  712. //# sourceMappingURL=adminlte.js.map