app.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770
  1. /*! AdminLTE app.js
  2. * ================
  3. * Main JS application file for AdminLTE v2. This file
  4. * should be included in all pages. It controls some layout
  5. * options and implements exclusive AdminLTE plugins.
  6. *
  7. * @Author Almsaeed Studio
  8. * @Support <http://www.almsaeedstudio.com>
  9. * @Email <abdullah@almsaeedstudio.com>
  10. * @version 2.3.8
  11. * @license MIT <http://opensource.org/licenses/MIT>
  12. */
  13. //Make sure jQuery has been loaded before app.js
  14. if (typeof jQuery === "undefined") {
  15. throw new Error("AdminLTE requires jQuery");
  16. }
  17. /* AdminLTE
  18. *
  19. * @type Object
  20. * @description $.AdminLTE is the main object for the template's app.
  21. * It's used for implementing functions and options related
  22. * to the template. Keeping everything wrapped in an object
  23. * prevents conflict with other plugins and is a better
  24. * way to organize our code.
  25. */
  26. $.AdminLTE = {};
  27. /* --------------------
  28. * - AdminLTE Options -
  29. * --------------------
  30. * Modify these options to suit your implementation
  31. */
  32. $.AdminLTE.options = {
  33. //Add slimscroll to navbar menus
  34. //This requires you to load the slimscroll plugin
  35. //in every page before app.js
  36. navbarMenuSlimscroll: true,
  37. navbarMenuSlimscrollWidth: "3px", //The width of the scroll bar
  38. navbarMenuHeight: "200px", //The height of the inner menu
  39. //General animation speed for JS animated elements such as box collapse/expand and
  40. //sidebar treeview slide up/down. This options accepts an integer as milliseconds,
  41. //'fast', 'normal', or 'slow'
  42. animationSpeed: 500,
  43. //Sidebar push menu toggle button selector
  44. sidebarToggleSelector: "[data-toggle='offcanvas']",
  45. //Activate sidebar push menu
  46. sidebarPushMenu: true,
  47. //Activate sidebar slimscroll if the fixed layout is set (requires SlimScroll Plugin)
  48. sidebarSlimScroll: true,
  49. //Enable sidebar expand on hover effect for sidebar mini
  50. //This option is forced to true if both the fixed layout and sidebar mini
  51. //are used together
  52. sidebarExpandOnHover: false,
  53. //BoxRefresh Plugin
  54. enableBoxRefresh: true,
  55. //Bootstrap.js tooltip
  56. enableBSToppltip: true,
  57. BSTooltipSelector: "[data-toggle='tooltip']",
  58. //Enable Fast Click. Fastclick.js creates a more
  59. //native touch experience with touch devices. If you
  60. //choose to enable the plugin, make sure you load the script
  61. //before AdminLTE's app.js
  62. enableFastclick: false,
  63. //Control Sidebar Tree views
  64. enableControlTreeView: true,
  65. //Control Sidebar Options
  66. enableControlSidebar: true,
  67. controlSidebarOptions: {
  68. //Which button should trigger the open/close event
  69. toggleBtnSelector: "[data-toggle='control-sidebar']",
  70. //The sidebar selector
  71. selector: ".control-sidebar",
  72. //Enable slide over content
  73. slide: true
  74. },
  75. //Box Widget Plugin. Enable this plugin
  76. //to allow boxes to be collapsed and/or removed
  77. enableBoxWidget: true,
  78. //Box Widget plugin options
  79. boxWidgetOptions: {
  80. boxWidgetIcons: {
  81. //Collapse icon
  82. collapse: 'fa-minus',
  83. //Open icon
  84. open: 'fa-plus',
  85. //Remove icon
  86. remove: 'fa-times'
  87. },
  88. boxWidgetSelectors: {
  89. //Remove button selector
  90. remove: '[data-widget="remove"]',
  91. //Collapse button selector
  92. collapse: '[data-widget="collapse"]'
  93. }
  94. },
  95. //Direct Chat plugin options
  96. directChat: {
  97. //Enable direct chat by default
  98. enable: true,
  99. //The button to open and close the chat contacts pane
  100. contactToggleSelector: '[data-widget="chat-pane-toggle"]'
  101. },
  102. //Define the set of colors to use globally around the website
  103. colors: {
  104. lightBlue: "#3c8dbc",
  105. red: "#f56954",
  106. green: "#00a65a",
  107. aqua: "#00c0ef",
  108. yellow: "#f39c12",
  109. blue: "#0073b7",
  110. navy: "#001F3F",
  111. teal: "#39CCCC",
  112. olive: "#3D9970",
  113. lime: "#01FF70",
  114. orange: "#FF851B",
  115. fuchsia: "#F012BE",
  116. purple: "#8E24AA",
  117. maroon: "#D81B60",
  118. black: "#222222",
  119. gray: "#d2d6de"
  120. },
  121. //The standard screen sizes that bootstrap uses.
  122. //If you change these in the variables.less file, change
  123. //them here too.
  124. screenSizes: {
  125. xs: 480,
  126. sm: 768,
  127. md: 992,
  128. lg: 1200
  129. }
  130. };
  131. /* ------------------
  132. * - Implementation -
  133. * ------------------
  134. * The next block of code implements AdminLTE's
  135. * functions and plugins as specified by the
  136. * options above.
  137. */
  138. $(function () {
  139. "use strict";
  140. //Fix for IE page transitions
  141. $("body").removeClass("hold-transition");
  142. //Extend options if external options exist
  143. if (typeof AdminLTEOptions !== "undefined") {
  144. $.extend(true,
  145. $.AdminLTE.options,
  146. AdminLTEOptions);
  147. }
  148. //Easy access to options
  149. var o = $.AdminLTE.options;
  150. //Set up the object
  151. _init();
  152. //Activate the layout maker
  153. $.AdminLTE.layout.activate();
  154. //Enable sidebar tree view controls
  155. if (o.enableControlTreeView) {
  156. $.AdminLTE.tree('.sidebar');
  157. }
  158. //Enable control sidebar
  159. if (o.enableControlSidebar) {
  160. $.AdminLTE.controlSidebar.activate();
  161. }
  162. //Add slimscroll to navbar dropdown
  163. if (o.navbarMenuSlimscroll && typeof $.fn.slimscroll != 'undefined') {
  164. $(".navbar .menu").slimscroll({
  165. height: o.navbarMenuHeight,
  166. alwaysVisible: false,
  167. size: o.navbarMenuSlimscrollWidth
  168. }).css("width", "100%");
  169. }
  170. //Activate sidebar push menu
  171. if (o.sidebarPushMenu) {
  172. $.AdminLTE.pushMenu.activate(o.sidebarToggleSelector);
  173. }
  174. //Activate Bootstrap tooltip
  175. if (o.enableBSToppltip) {
  176. $('body').tooltip({
  177. selector: o.BSTooltipSelector
  178. });
  179. }
  180. //Activate box widget
  181. if (o.enableBoxWidget) {
  182. $.AdminLTE.boxWidget.activate();
  183. }
  184. //Activate fast click
  185. if (o.enableFastclick && typeof FastClick != 'undefined') {
  186. FastClick.attach(document.body);
  187. }
  188. //Activate direct chat widget
  189. if (o.directChat.enable) {
  190. $(document).on('click', o.directChat.contactToggleSelector, function () {
  191. var box = $(this).parents('.direct-chat').first();
  192. box.toggleClass('direct-chat-contacts-open');
  193. });
  194. }
  195. /*
  196. * INITIALIZE BUTTON TOGGLE
  197. * ------------------------
  198. */
  199. $('.btn-group[data-toggle="btn-toggle"]').each(function () {
  200. var group = $(this);
  201. $(this).find(".btn").on('click', function (e) {
  202. group.find(".btn.active").removeClass("active");
  203. $(this).addClass("active");
  204. e.preventDefault();
  205. });
  206. });
  207. });
  208. /* ----------------------------------
  209. * - Initialize the AdminLTE Object -
  210. * ----------------------------------
  211. * All AdminLTE functions are implemented below.
  212. */
  213. function _init() {
  214. 'use strict';
  215. /* Layout
  216. * ======
  217. * Fixes the layout height in case min-height fails.
  218. *
  219. * @type Object
  220. * @usage $.AdminLTE.layout.activate()
  221. * $.AdminLTE.layout.fix()
  222. * $.AdminLTE.layout.fixSidebar()
  223. */
  224. $.AdminLTE.layout = {
  225. activate: function () {
  226. var _this = this;
  227. _this.fix();
  228. _this.fixSidebar();
  229. $('body, html, .wrapper').css('height', 'auto');
  230. $(window, ".wrapper").resize(function () {
  231. _this.fix();
  232. _this.fixSidebar();
  233. });
  234. },
  235. fix: function () {
  236. // Remove overflow from .wrapper if layout-boxed exists
  237. $(".layout-boxed > .wrapper").css('overflow', 'hidden');
  238. //Get window height and the wrapper height
  239. var neg = $('.main-header').outerHeight() + $('.main-footer').outerHeight();
  240. var window_height = $(window).height();
  241. var sidebar_height = $(".sidebar").height();
  242. //Set the min-height of the content and sidebar based on the
  243. //the height of the document.
  244. if ($("body").hasClass("fixed")) {
  245. $(".content-wrapper, .right-side").css('min-height', window_height - $('.main-footer').outerHeight());
  246. } else {
  247. var postSetWidth;
  248. if (window_height >= sidebar_height) {
  249. $(".content-wrapper, .right-side").css('min-height', window_height - neg);
  250. postSetWidth = window_height - neg;
  251. } else {
  252. $(".content-wrapper, .right-side").css('min-height', sidebar_height);
  253. postSetWidth = sidebar_height;
  254. }
  255. //Fix for the control sidebar height
  256. var controlSidebar = $($.AdminLTE.options.controlSidebarOptions.selector);
  257. if (typeof controlSidebar !== "undefined") {
  258. if (controlSidebar.height() > postSetWidth)
  259. $(".content-wrapper, .right-side").css('min-height', controlSidebar.height());
  260. }
  261. }
  262. },
  263. fixSidebar: function () {
  264. //Make sure the body tag has the .fixed class
  265. if (!$("body").hasClass("fixed")) {
  266. if (typeof $.fn.slimScroll != 'undefined') {
  267. $(".sidebar").slimScroll({destroy: true}).height("auto");
  268. }
  269. return;
  270. } else if (typeof $.fn.slimScroll == 'undefined' && window.console) {
  271. window.console.error("Error: the fixed layout requires the slimscroll plugin!");
  272. }
  273. //Enable slimscroll for fixed layout
  274. if ($.AdminLTE.options.sidebarSlimScroll) {
  275. if (typeof $.fn.slimScroll != 'undefined') {
  276. //Destroy if it exists
  277. $(".sidebar").slimScroll({destroy: true}).height("auto");
  278. //Add slimscroll
  279. $(".sidebar").slimscroll({
  280. height: ($(window).height() - $(".main-header").height()) + "px",
  281. color: "rgba(0,0,0,0.2)",
  282. size: "3px"
  283. });
  284. }
  285. }
  286. }
  287. };
  288. /* PushMenu()
  289. * ==========
  290. * Adds the push menu functionality to the sidebar.
  291. *
  292. * @type Function
  293. * @usage: $.AdminLTE.pushMenu("[data-toggle='offcanvas']")
  294. */
  295. $.AdminLTE.pushMenu = {
  296. activate: function (toggleBtn) {
  297. //Get the screen sizes
  298. var screenSizes = $.AdminLTE.options.screenSizes;
  299. //Enable sidebar toggle
  300. $(document).on('click', toggleBtn, function (e) {
  301. e.preventDefault();
  302. //Enable sidebar push menu
  303. if ($(window).width() > (screenSizes.sm - 1)) {
  304. if ($("body").hasClass('sidebar-collapse')) {
  305. $("body").removeClass('sidebar-collapse').trigger('expanded.pushMenu');
  306. } else {
  307. $("body").addClass('sidebar-collapse').trigger('collapsed.pushMenu');
  308. }
  309. }
  310. //Handle sidebar push menu for small screens
  311. else {
  312. if ($("body").hasClass('sidebar-open')) {
  313. $("body").removeClass('sidebar-open').removeClass('sidebar-collapse').trigger('collapsed.pushMenu');
  314. } else {
  315. $("body").addClass('sidebar-open').trigger('expanded.pushMenu');
  316. }
  317. }
  318. });
  319. $(".content-wrapper").click(function () {
  320. //Enable hide menu when clicking on the content-wrapper on small screens
  321. if ($(window).width() <= (screenSizes.sm - 1) && $("body").hasClass("sidebar-open")) {
  322. $("body").removeClass('sidebar-open');
  323. }
  324. });
  325. //Enable expand on hover for sidebar mini
  326. if ($.AdminLTE.options.sidebarExpandOnHover
  327. || ($('body').hasClass('fixed')
  328. && $('body').hasClass('sidebar-mini'))) {
  329. this.expandOnHover();
  330. }
  331. },
  332. expandOnHover: function () {
  333. var _this = this;
  334. var screenWidth = $.AdminLTE.options.screenSizes.sm - 1;
  335. //Expand sidebar on hover
  336. $('.main-sidebar').hover(function () {
  337. if ($('body').hasClass('sidebar-mini')
  338. && $("body").hasClass('sidebar-collapse')
  339. && $(window).width() > screenWidth) {
  340. _this.expand();
  341. }
  342. }, function () {
  343. if ($('body').hasClass('sidebar-mini')
  344. && $('body').hasClass('sidebar-expanded-on-hover')
  345. && $(window).width() > screenWidth) {
  346. _this.collapse();
  347. }
  348. });
  349. },
  350. expand: function () {
  351. $("body").removeClass('sidebar-collapse').addClass('sidebar-expanded-on-hover');
  352. },
  353. collapse: function () {
  354. if ($('body').hasClass('sidebar-expanded-on-hover')) {
  355. $('body').removeClass('sidebar-expanded-on-hover').addClass('sidebar-collapse');
  356. }
  357. }
  358. };
  359. /* Tree()
  360. * ======
  361. * Converts the sidebar into a multilevel
  362. * tree view menu.
  363. *
  364. * @type Function
  365. * @Usage: $.AdminLTE.tree('.sidebar')
  366. */
  367. $.AdminLTE.tree = function (menu) {
  368. var _this = this;
  369. var animationSpeed = $.AdminLTE.options.animationSpeed;
  370. $(document).off('click', menu + ' li a')
  371. .on('click', menu + ' li a', function (e) {
  372. //Get the clicked link and the next element
  373. var $this = $(this);
  374. var checkElement = $this.next();
  375. //Check if the next element is a menu and is visible
  376. if ((checkElement.is('.treeview-menu')) && (checkElement.is(':visible')) && (!$('body').hasClass('sidebar-collapse'))) {
  377. //Close the menu
  378. checkElement.slideUp(animationSpeed, function () {
  379. checkElement.removeClass('menu-open');
  380. //Fix the layout in case the sidebar stretches over the height of the window
  381. //_this.layout.fix();
  382. });
  383. checkElement.parent("li").removeClass("active");
  384. }
  385. //If the menu is not visible
  386. else if ((checkElement.is('.treeview-menu')) && (!checkElement.is(':visible'))) {
  387. //Get the parent menu
  388. var parent = $this.parents('ul').first();
  389. //Close all open menus within the parent
  390. var ul = parent.find('ul:visible').slideUp(animationSpeed);
  391. //Remove the menu-open class from the parent
  392. ul.removeClass('menu-open');
  393. //Get the parent li
  394. var parent_li = $this.parent("li");
  395. //Open the target menu and add the menu-open class
  396. checkElement.slideDown(animationSpeed, function () {
  397. //Add the class active to the parent li
  398. checkElement.addClass('menu-open');
  399. parent.find('li.active').removeClass('active');
  400. parent_li.addClass('active');
  401. //Fix the layout in case the sidebar stretches over the height of the window
  402. _this.layout.fix();
  403. });
  404. }
  405. //if this isn't a link, prevent the page from being redirected
  406. if (checkElement.is('.treeview-menu')) {
  407. e.preventDefault();
  408. }
  409. });
  410. };
  411. /* ControlSidebar
  412. * ==============
  413. * Adds functionality to the right sidebar
  414. *
  415. * @type Object
  416. * @usage $.AdminLTE.controlSidebar.activate(options)
  417. */
  418. $.AdminLTE.controlSidebar = {
  419. //instantiate the object
  420. activate: function () {
  421. //Get the object
  422. var _this = this;
  423. //Update options
  424. var o = $.AdminLTE.options.controlSidebarOptions;
  425. //Get the sidebar
  426. var sidebar = $(o.selector);
  427. //The toggle button
  428. var btn = $(o.toggleBtnSelector);
  429. //Listen to the click event
  430. btn.on('click', function (e) {
  431. e.preventDefault();
  432. //If the sidebar is not open
  433. if (!sidebar.hasClass('control-sidebar-open')
  434. && !$('body').hasClass('control-sidebar-open')) {
  435. //Open the sidebar
  436. _this.open(sidebar, o.slide);
  437. } else {
  438. _this.close(sidebar, o.slide);
  439. }
  440. });
  441. //If the body has a boxed layout, fix the sidebar bg position
  442. var bg = $(".control-sidebar-bg");
  443. _this._fix(bg);
  444. //If the body has a fixed layout, make the control sidebar fixed
  445. if ($('body').hasClass('fixed')) {
  446. _this._fixForFixed(sidebar);
  447. } else {
  448. //If the content height is less than the sidebar's height, force max height
  449. if ($('.content-wrapper, .right-side').height() < sidebar.height()) {
  450. _this._fixForContent(sidebar);
  451. }
  452. }
  453. },
  454. //Open the control sidebar
  455. open: function (sidebar, slide) {
  456. //Slide over content
  457. if (slide) {
  458. sidebar.addClass('control-sidebar-open');
  459. } else {
  460. //Push the content by adding the open class to the body instead
  461. //of the sidebar itself
  462. $('body').addClass('control-sidebar-open');
  463. }
  464. },
  465. //Close the control sidebar
  466. close: function (sidebar, slide) {
  467. if (slide) {
  468. sidebar.removeClass('control-sidebar-open');
  469. } else {
  470. $('body').removeClass('control-sidebar-open');
  471. }
  472. },
  473. _fix: function (sidebar) {
  474. var _this = this;
  475. if ($("body").hasClass('layout-boxed')) {
  476. sidebar.css('position', 'absolute');
  477. sidebar.height($(".wrapper").height());
  478. if (_this.hasBindedResize) {
  479. return;
  480. }
  481. $(window).resize(function () {
  482. _this._fix(sidebar);
  483. });
  484. _this.hasBindedResize = true;
  485. } else {
  486. sidebar.css({
  487. 'position': 'fixed',
  488. 'height': 'auto'
  489. });
  490. }
  491. },
  492. _fixForFixed: function (sidebar) {
  493. sidebar.css({
  494. 'position': 'fixed',
  495. 'max-height': '100%',
  496. 'overflow': 'auto',
  497. 'padding-bottom': '50px'
  498. });
  499. },
  500. _fixForContent: function (sidebar) {
  501. $(".content-wrapper, .right-side").css('min-height', sidebar.height());
  502. }
  503. };
  504. /* BoxWidget
  505. * =========
  506. * BoxWidget is a plugin to handle collapsing and
  507. * removing boxes from the screen.
  508. *
  509. * @type Object
  510. * @usage $.AdminLTE.boxWidget.activate()
  511. * Set all your options in the main $.AdminLTE.options object
  512. */
  513. $.AdminLTE.boxWidget = {
  514. selectors: $.AdminLTE.options.boxWidgetOptions.boxWidgetSelectors,
  515. icons: $.AdminLTE.options.boxWidgetOptions.boxWidgetIcons,
  516. animationSpeed: $.AdminLTE.options.animationSpeed,
  517. activate: function (_box) {
  518. var _this = this;
  519. if (!_box) {
  520. _box = document; // activate all boxes per default
  521. }
  522. //Listen for collapse event triggers
  523. $(_box).on('click', _this.selectors.collapse, function (e) {
  524. e.preventDefault();
  525. _this.collapse($(this));
  526. });
  527. //Listen for remove event triggers
  528. $(_box).on('click', _this.selectors.remove, function (e) {
  529. e.preventDefault();
  530. _this.remove($(this));
  531. });
  532. },
  533. collapse: function (element) {
  534. var _this = this;
  535. //Find the box parent
  536. var box = element.parents(".box").first();
  537. //Find the body and the footer
  538. var box_content = box.find("> .box-body, > .box-footer, > form >.box-body, > form > .box-footer");
  539. if (!box.hasClass("collapsed-box")) {
  540. //Convert minus into plus
  541. element.children(":first")
  542. .removeClass(_this.icons.collapse)
  543. .addClass(_this.icons.open);
  544. //Hide the content
  545. box_content.slideUp(_this.animationSpeed, function () {
  546. box.addClass("collapsed-box");
  547. });
  548. } else {
  549. //Convert plus into minus
  550. element.children(":first")
  551. .removeClass(_this.icons.open)
  552. .addClass(_this.icons.collapse);
  553. //Show the content
  554. box_content.slideDown(_this.animationSpeed, function () {
  555. box.removeClass("collapsed-box");
  556. });
  557. }
  558. },
  559. remove: function (element) {
  560. //Find the box parent
  561. var box = element.parents(".box").first();
  562. box.slideUp(this.animationSpeed);
  563. }
  564. };
  565. }
  566. /* ------------------
  567. * - Custom Plugins -
  568. * ------------------
  569. * All custom plugins are defined below.
  570. */
  571. /*
  572. * BOX REFRESH BUTTON
  573. * ------------------
  574. * This is a custom plugin to use with the component BOX. It allows you to add
  575. * a refresh button to the box. It converts the box's state to a loading state.
  576. *
  577. * @type plugin
  578. * @usage $("#box-widget").boxRefresh( options );
  579. */
  580. (function ($) {
  581. "use strict";
  582. $.fn.boxRefresh = function (options) {
  583. // Render options
  584. var settings = $.extend({
  585. //Refresh button selector
  586. trigger: ".refresh-btn",
  587. //File source to be loaded (e.g: ajax/src.php)
  588. source: "",
  589. //Callbacks
  590. onLoadStart: function (box) {
  591. return box;
  592. }, //Right after the button has been clicked
  593. onLoadDone: function (box) {
  594. return box;
  595. } //When the source has been loaded
  596. }, options);
  597. //The overlay
  598. var overlay = $('<div class="overlay"><div class="fa fa-refresh fa-spin"></div></div>');
  599. return this.each(function () {
  600. //if a source is specified
  601. if (settings.source === "") {
  602. if (window.console) {
  603. window.console.log("Please specify a source first - boxRefresh()");
  604. }
  605. return;
  606. }
  607. //the box
  608. var box = $(this);
  609. //the button
  610. var rBtn = box.find(settings.trigger).first();
  611. //On trigger click
  612. rBtn.on('click', function (e) {
  613. e.preventDefault();
  614. //Add loading overlay
  615. start(box);
  616. //Perform ajax call
  617. box.find(".box-body").load(settings.source, function () {
  618. done(box);
  619. });
  620. });
  621. });
  622. function start(box) {
  623. //Add overlay and loading img
  624. box.append(overlay);
  625. settings.onLoadStart.call(box);
  626. }
  627. function done(box) {
  628. //Remove overlay and loading img
  629. box.find(overlay).remove();
  630. settings.onLoadDone.call(box);
  631. }
  632. };
  633. })(jQuery);
  634. /*
  635. * EXPLICIT BOX CONTROLS
  636. * -----------------------
  637. * This is a custom plugin to use with the component BOX. It allows you to activate
  638. * a box inserted in the DOM after the app.js was loaded, toggle and remove box.
  639. *
  640. * @type plugin
  641. * @usage $("#box-widget").activateBox();
  642. * @usage $("#box-widget").toggleBox();
  643. * @usage $("#box-widget").removeBox();
  644. */
  645. (function ($) {
  646. 'use strict';
  647. $.fn.activateBox = function () {
  648. $.AdminLTE.boxWidget.activate(this);
  649. };
  650. $.fn.toggleBox = function () {
  651. var button = $($.AdminLTE.boxWidget.selectors.collapse, this);
  652. $.AdminLTE.boxWidget.collapse(button);
  653. };
  654. $.fn.removeBox = function () {
  655. var button = $($.AdminLTE.boxWidget.selectors.remove, this);
  656. $.AdminLTE.boxWidget.remove(button);
  657. };
  658. })(jQuery);
  659. /*
  660. * TODO LIST CUSTOM PLUGIN
  661. * -----------------------
  662. * This plugin depends on iCheck plugin for checkbox and radio inputs
  663. *
  664. * @type plugin
  665. * @usage $("#todo-widget").todolist( options );
  666. */
  667. (function ($) {
  668. 'use strict';
  669. $.fn.todolist = function (options) {
  670. // Render options
  671. var settings = $.extend({
  672. //When the user checks the input
  673. onCheck: function (ele) {
  674. return ele;
  675. },
  676. //When the user unchecks the input
  677. onUncheck: function (ele) {
  678. return ele;
  679. }
  680. }, options);
  681. return this.each(function () {
  682. if (typeof $.fn.iCheck != 'undefined') {
  683. $('input', this).on('ifChecked', function () {
  684. var ele = $(this).parents("li").first();
  685. ele.toggleClass("done");
  686. settings.onCheck.call(ele);
  687. });
  688. $('input', this).on('ifUnchecked', function () {
  689. var ele = $(this).parents("li").first();
  690. ele.toggleClass("done");
  691. settings.onUncheck.call(ele);
  692. });
  693. } else {
  694. $('input', this).on('change', function () {
  695. var ele = $(this).parents("li").first();
  696. ele.toggleClass("done");
  697. if ($('input', ele).is(":checked")) {
  698. settings.onCheck.call(ele);
  699. } else {
  700. settings.onUncheck.call(ele);
  701. }
  702. });
  703. }
  704. });
  705. };
  706. }(jQuery));