app.js 21 KB

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