app.js 23 KB

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