app.js 23 KB

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