App.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  1. /*!
  2. * Author: Abdullah A Almsaeed
  3. * Date: 4 Jan 2014
  4. * Description:
  5. * This file should be included in all pages
  6. !**/
  7. /*!
  8. * Author: Hugo Briand
  9. * Date: 4 Apr 2014
  10. * Description:
  11. * Removed demo button from original AdmineLTE app.js file
  12. !**/
  13. $(function() {
  14. "use strict";
  15. //Enable sidebar toggle
  16. $("[data-toggle='offcanvas']").click(function(e) {
  17. e.preventDefault();
  18. //If window is small enough, enable sidebar push menu
  19. if ($(window).width() <= 992) {
  20. $('.row-offcanvas').toggleClass('active');
  21. $('.left-side').removeClass("collapse-left");
  22. $(".right-side").removeClass("strech");
  23. $('.row-offcanvas').toggleClass("relative");
  24. } else {
  25. //Else, enable content streching
  26. $('.left-side').toggleClass("collapse-left");
  27. $(".right-side").toggleClass("strech");
  28. }
  29. });
  30. //Add hover support for touch devices
  31. $('.btn').bind('touchstart', function() {
  32. $(this).addClass('hover');
  33. }).bind('touchend', function() {
  34. $(this).removeClass('hover');
  35. });
  36. //Activate tooltips
  37. $("[data-toggle='tooltip']").tooltip();
  38. /*
  39. * Add collapse and remove events to boxes
  40. */
  41. $("[data-widget='collapse']").click(function() {
  42. //Find the box parent
  43. var box = $(this).parents(".box").first();
  44. //Find the body and the footer
  45. var bf = box.find(".box-body, .box-footer");
  46. if (!box.hasClass("collapsed-box")) {
  47. box.addClass("collapsed-box");
  48. //Convert minus into plus
  49. $(this).children(".fa-minus").removeClass("fa-minus").addClass("fa-plus");
  50. bf.slideUp();
  51. } else {
  52. box.removeClass("collapsed-box");
  53. //Convert plus into minus
  54. $(this).children(".fa-plus").removeClass("fa-plus").addClass("fa-minus");
  55. bf.slideDown();
  56. }
  57. });
  58. /*
  59. * ADD SLIMSCROLL TO THE TOP NAV DROPDOWNS
  60. * ---------------------------------------
  61. */
  62. $(".navbar .menu").slimscroll({
  63. height: "200px",
  64. alwaysVisible: false,
  65. size: "3px"
  66. }).css("width", "100%");
  67. /*
  68. * INITIALIZE BUTTON TOGGLE
  69. * ------------------------
  70. */
  71. $('.btn-group[data-toggle="btn-toggle"]').each(function() {
  72. var group = $(this);
  73. $(this).find(".btn").click(function(e) {
  74. group.find(".btn.active").removeClass("active");
  75. $(this).addClass("active");
  76. e.preventDefault();
  77. });
  78. });
  79. $("[data-widget='remove']").click(function() {
  80. //Find the box parent
  81. var box = $(this).parents(".box").first();
  82. box.slideUp();
  83. });
  84. /* Sidebar tree view */
  85. $(".sidebar .treeview").tree();
  86. /*
  87. * Make sure that the sidebar is streched full height
  88. * ---------------------------------------------
  89. * We are gonna assign a min-height value every time the
  90. * wrapper gets resized and upon page load. We will use
  91. * Ben Alman's method for detecting the resize event.
  92. **/
  93. function _fix() {
  94. //Get window height and the wrapper height
  95. var height = $(window).height() - $("body > .header").height() - ($("body > .footer").outerHeight() || 0);
  96. $(".wrapper").css("min-height", height + "px");
  97. var content = $(".wrapper").height();
  98. //If the wrapper height is greater than the window
  99. if (content > height)
  100. //then set sidebar height to the wrapper
  101. $(".left-side, html, body").css("min-height", content + "px");
  102. else {
  103. //Otherwise, set the sidebar to the height of the window
  104. $(".left-side, html, body").css("min-height", height + "px");
  105. }
  106. }
  107. //Let disable stretch behavior if not needed
  108. if (false === $("html").hasClass('no-stretch')) {
  109. //Fire upon load
  110. _fix();
  111. //Fire when wrapper is resized
  112. $(".wrapper").resize(function () {
  113. _fix();
  114. fix_sidebar();
  115. });
  116. //Fix the fixed layout sidebar scroll bug
  117. fix_sidebar();
  118. }
  119. });
  120. function fix_sidebar() {
  121. //Make sure the body tag has the .fixed class
  122. if (!$("body").hasClass("fixed")) {
  123. return;
  124. }
  125. //Add slimscroll
  126. $(".sidebar").slimscroll({
  127. height: ($(window).height() - $(".header").height()) + "px",
  128. color: "rgba(0,0,0,0.2)"
  129. });
  130. }
  131. /*
  132. * BOX REFRESH BUTTON
  133. * ------------------
  134. * This is a custom plugin to use with the compenet BOX. It allows you to add
  135. * a refresh button to the box. It converts the box's state to a loading state.
  136. *
  137. * USAGE:
  138. * $("#box-widget").boxRefresh( options );
  139. * */
  140. (function($) {
  141. "use strict";
  142. $.fn.boxRefresh = function(options) {
  143. // Render options
  144. var settings = $.extend({
  145. //Refressh button selector
  146. trigger: ".refresh-btn",
  147. //File source to be loaded (e.g: ajax/src.php)
  148. source: "",
  149. //Callbacks
  150. onLoadStart: function(box) {
  151. }, //Right after the button has been clicked
  152. onLoadDone: function(box) {
  153. } //When the source has been loaded
  154. }, options);
  155. //The overlay
  156. var overlay = $('<div class="overlay"></div><div class="loading-img"></div>');
  157. return this.each(function() {
  158. //if a source is specified
  159. if (settings.source === "") {
  160. if (console) {
  161. console.log("Please specify a source first - boxRefresh()");
  162. }
  163. return;
  164. }
  165. //the box
  166. var box = $(this);
  167. //the button
  168. var rBtn = box.find(settings.trigger).first();
  169. //On trigger click
  170. rBtn.click(function(e) {
  171. e.preventDefault();
  172. //Add loading overlay
  173. start(box);
  174. //Perform ajax call
  175. box.find(".box-body").load(settings.source, function() {
  176. done(box);
  177. });
  178. });
  179. });
  180. function start(box) {
  181. //Add overlay and loading img
  182. box.append(overlay);
  183. settings.onLoadStart.call(box);
  184. }
  185. function done(box) {
  186. //Remove overlay and loading img
  187. box.find(overlay).remove();
  188. settings.onLoadDone.call(box);
  189. }
  190. };
  191. })(jQuery);
  192. /*
  193. * SIDEBAR MENU
  194. * ------------
  195. * This is a custom plugin for the sidebar menu. It provides a tree view.
  196. *
  197. * Usage:
  198. * $(".sidebar).tree();
  199. *
  200. * Note: This plugin does not accept any options. Instead, it only requires a class
  201. * added to the element that contains a sub-menu.
  202. *
  203. * When used with the sidebar, for example, it would look something like this:
  204. * <ul class='sidebar-menu'>
  205. * <li class="treeview active">
  206. * <a href="#>Menu</a>
  207. * <ul class='treeview-menu'>
  208. * <li class='active'><a href=#>Level 1</a></li>
  209. * </ul>
  210. * </li>
  211. * </ul>
  212. *
  213. * Add .active class to <li> elements if you want the menu to be open automatically
  214. * on page load. See above for an example.
  215. */
  216. (function($) {
  217. "use strict";
  218. $.fn.tree = function() {
  219. return this.each(function() {
  220. var btn = $(this).children("a").first();
  221. var menu = $(this).children(".treeview-menu").first();
  222. var isActive = $(this).hasClass('active');
  223. //initialize already active menus
  224. if (isActive) {
  225. menu.show();
  226. btn.children(".fa-angle-left").first().removeClass("fa-angle-left").addClass("fa-angle-down");
  227. }
  228. //Slide open or close the menu on link click
  229. btn.click(function(e) {
  230. e.preventDefault();
  231. if (isActive) {
  232. //Slide up to close menu
  233. menu.slideUp();
  234. isActive = false;
  235. btn.children(".fa-angle-down").first().removeClass("fa-angle-down").addClass("fa-angle-left");
  236. btn.parent("li").removeClass("active");
  237. } else {
  238. //Slide down to open menu
  239. menu.slideDown();
  240. isActive = true;
  241. btn.children(".fa-angle-left").first().removeClass("fa-angle-left").addClass("fa-angle-down");
  242. btn.parent("li").addClass("active");
  243. }
  244. });
  245. /* Add margins to submenu elements to give it a tree look */
  246. menu.find("li > a").each(function() {
  247. var pad = parseInt($(this).css("margin-left")) + 10;
  248. $(this).css({"margin-left": pad + "px"});
  249. });
  250. });
  251. };
  252. }(jQuery));
  253. /*
  254. * TODO LIST CUSTOM PLUGIN
  255. * -----------------------
  256. * This plugin depends on iCheck plugin for checkbox and radio inputs
  257. */
  258. (function($) {
  259. "use strict";
  260. $.fn.todolist = function(options) {
  261. // Render options
  262. var settings = $.extend({
  263. //When the user checks the input
  264. onCheck: function(ele) {
  265. },
  266. //When the user unchecks the input
  267. onUncheck: function(ele) {
  268. }
  269. }, options);
  270. return this.each(function() {
  271. $('input', this).on('ifChecked', function(event) {
  272. var ele = $(this).parents("li").first();
  273. ele.toggleClass("done");
  274. settings.onCheck.call(ele);
  275. });
  276. $('input', this).on('ifUnchecked', function(event) {
  277. var ele = $(this).parents("li").first();
  278. ele.toggleClass("done");
  279. settings.onUncheck.call(ele);
  280. });
  281. });
  282. };
  283. }(jQuery));
  284. /* CENTER ELEMENTS */
  285. (function($) {
  286. "use strict";
  287. jQuery.fn.center = function(parent) {
  288. if (parent) {
  289. parent = this.parent();
  290. } else {
  291. parent = window;
  292. }
  293. this.css({
  294. "position": "absolute",
  295. "top": ((($(parent).height() - this.outerHeight()) / 2) + $(parent).scrollTop() + "px"),
  296. "left": ((($(parent).width() - this.outerWidth()) / 2) + $(parent).scrollLeft() + "px")
  297. });
  298. return this;
  299. }
  300. }(jQuery));
  301. /*
  302. * jQuery resize event - v1.1 - 3/14/2010
  303. * http://benalman.com/projects/jquery-resize-plugin/
  304. *
  305. * Copyright (c) 2010 "Cowboy" Ben Alman
  306. * Dual licensed under the MIT and GPL licenses.
  307. * http://benalman.com/about/license/
  308. */
  309. (function($, h, c) {
  310. var a = $([]), e = $.resize = $.extend($.resize, {}), i, k = "setTimeout", j = "resize", d = j + "-special-event", b = "delay", f = "throttleWindow";
  311. e[b] = 250;
  312. e[f] = true;
  313. $.event.special[j] = {setup: function() {
  314. if (!e[f] && this[k]) {
  315. return false;
  316. }
  317. var l = $(this);
  318. a = a.add(l);
  319. $.data(this, d, {w: l.width(), h: l.height()});
  320. if (a.length === 1) {
  321. g();
  322. }
  323. }, teardown: function() {
  324. if (!e[f] && this[k]) {
  325. return false
  326. }
  327. var l = $(this);
  328. a = a.not(l);
  329. l.removeData(d);
  330. if (!a.length) {
  331. clearTimeout(i);
  332. }
  333. }, add: function(l) {
  334. if (!e[f] && this[k]) {
  335. return false
  336. }
  337. var n;
  338. function m(s, o, p) {
  339. var q = $(this), r = $.data(this, d);
  340. r.w = o !== c ? o : q.width();
  341. r.h = p !== c ? p : q.height();
  342. n.apply(this, arguments)
  343. }
  344. if ($.isFunction(l)) {
  345. n = l;
  346. return m
  347. } else {
  348. n = l.handler;
  349. l.handler = m
  350. }
  351. }};
  352. function g() {
  353. i = h[k](function() {
  354. a.each(function() {
  355. var n = $(this), m = n.width(), l = n.height(), o = $.data(this, d);
  356. if (m !== o.w || l !== o.h) {
  357. n.trigger(j, [o.w = m, o.h = l])
  358. }
  359. });
  360. g()
  361. }, e[b])
  362. }}
  363. )(jQuery, this);
  364. /*!
  365. * SlimScroll https://github.com/rochal/jQuery-slimScroll
  366. * =======================================================
  367. *
  368. * Copyright (c) 2011 Piotr Rochala (http://rocha.la) Dual licensed under the MIT
  369. */
  370. (function(f) {
  371. jQuery.fn.extend({slimScroll: function(h) {
  372. var a = f.extend({width: "auto", height: "250px", size: "7px", color: "#000", position: "right", distance: "1px", start: "top", opacity: 0.4, alwaysVisible: !1, disableFadeOut: !1, railVisible: !1, railColor: "#333", railOpacity: 0.2, railDraggable: !0, railClass: "slimScrollRail", barClass: "slimScrollBar", wrapperClass: "slimScrollDiv", allowPageScroll: !1, wheelStep: 20, touchScrollStep: 200, borderRadius: "0px", railBorderRadius: "0px"}, h);
  373. this.each(function() {
  374. function r(d) {
  375. if (s) {
  376. d = d ||
  377. window.event;
  378. var c = 0;
  379. d.wheelDelta && (c = -d.wheelDelta / 120);
  380. d.detail && (c = d.detail / 3);
  381. f(d.target || d.srcTarget || d.srcElement).closest("." + a.wrapperClass).is(b.parent()) && m(c, !0);
  382. d.preventDefault && !k && d.preventDefault();
  383. k || (d.returnValue = !1)
  384. }
  385. }
  386. function m(d, f, h) {
  387. k = !1;
  388. var e = d, g = b.outerHeight() - c.outerHeight();
  389. f && (e = parseInt(c.css("top")) + d * parseInt(a.wheelStep) / 100 * c.outerHeight(), e = Math.min(Math.max(e, 0), g), e = 0 < d ? Math.ceil(e) : Math.floor(e), c.css({top: e + "px"}));
  390. l = parseInt(c.css("top")) / (b.outerHeight() - c.outerHeight());
  391. e = l * (b[0].scrollHeight - b.outerHeight());
  392. h && (e = d, d = e / b[0].scrollHeight * b.outerHeight(), d = Math.min(Math.max(d, 0), g), c.css({top: d + "px"}));
  393. b.scrollTop(e);
  394. b.trigger("slimscrolling", ~~e);
  395. v();
  396. p()
  397. }
  398. function C() {
  399. window.addEventListener ? (this.addEventListener("DOMMouseScroll", r, !1), this.addEventListener("mousewheel", r, !1), this.addEventListener("MozMousePixelScroll", r, !1)) : document.attachEvent("onmousewheel", r)
  400. }
  401. function w() {
  402. u = Math.max(b.outerHeight() / b[0].scrollHeight * b.outerHeight(), D);
  403. c.css({height: u + "px"});
  404. var a = u == b.outerHeight() ? "none" : "block";
  405. c.css({display: a})
  406. }
  407. function v() {
  408. w();
  409. clearTimeout(A);
  410. l == ~~l ? (k = a.allowPageScroll, B != l && b.trigger("slimscroll", 0 == ~~l ? "top" : "bottom")) : k = !1;
  411. B = l;
  412. u >= b.outerHeight() ? k = !0 : (c.stop(!0, !0).fadeIn("fast"), a.railVisible && g.stop(!0, !0).fadeIn("fast"))
  413. }
  414. function p() {
  415. a.alwaysVisible || (A = setTimeout(function() {
  416. a.disableFadeOut && s || (x || y) || (c.fadeOut("slow"), g.fadeOut("slow"))
  417. }, 1E3))
  418. }
  419. var s, x, y, A, z, u, l, B, D = 30, k = !1, b = f(this);
  420. if (b.parent().hasClass(a.wrapperClass)) {
  421. var n = b.scrollTop(),
  422. c = b.parent().find("." + a.barClass), g = b.parent().find("." + a.railClass);
  423. w();
  424. if (f.isPlainObject(h)) {
  425. if ("height"in h && "auto" == h.height) {
  426. b.parent().css("height", "auto");
  427. b.css("height", "auto");
  428. var q = b.parent().parent().height();
  429. b.parent().css("height", q);
  430. b.css("height", q)
  431. }
  432. if ("scrollTo"in h)
  433. n = parseInt(a.scrollTo);
  434. else if ("scrollBy"in h)
  435. n += parseInt(a.scrollBy);
  436. else if ("destroy"in h) {
  437. c.remove();
  438. g.remove();
  439. b.unwrap();
  440. return
  441. }
  442. m(n, !1, !0)
  443. }
  444. } else {
  445. a.height = "auto" == a.height ? b.parent().height() : a.height;
  446. n = f("<div></div>").addClass(a.wrapperClass).css({position: "relative",
  447. overflow: "hidden", width: a.width, height: a.height});
  448. b.css({overflow: "hidden", width: a.width, height: a.height});
  449. var g = f("<div></div>").addClass(a.railClass).css({width: a.size, height: "100%", position: "absolute", top: 0, display: a.alwaysVisible && a.railVisible ? "block" : "none", "border-radius": a.railBorderRadius, background: a.railColor, opacity: a.railOpacity, zIndex: 90}), c = f("<div></div>").addClass(a.barClass).css({background: a.color, width: a.size, position: "absolute", top: 0, opacity: a.opacity, display: a.alwaysVisible ?
  450. "block" : "none", "border-radius": a.borderRadius, BorderRadius: a.borderRadius, MozBorderRadius: a.borderRadius, WebkitBorderRadius: a.borderRadius, zIndex: 99}), q = "right" == a.position ? {right: a.distance} : {left: a.distance};
  451. g.css(q);
  452. c.css(q);
  453. b.wrap(n);
  454. b.parent().append(c);
  455. b.parent().append(g);
  456. a.railDraggable && c.bind("mousedown", function(a) {
  457. var b = f(document);
  458. y = !0;
  459. t = parseFloat(c.css("top"));
  460. pageY = a.pageY;
  461. b.bind("mousemove.slimscroll", function(a) {
  462. currTop = t + a.pageY - pageY;
  463. c.css("top", currTop);
  464. m(0, c.position().top, !1)
  465. });
  466. b.bind("mouseup.slimscroll", function(a) {
  467. y = !1;
  468. p();
  469. b.unbind(".slimscroll")
  470. });
  471. return!1
  472. }).bind("selectstart.slimscroll", function(a) {
  473. a.stopPropagation();
  474. a.preventDefault();
  475. return!1
  476. });
  477. g.hover(function() {
  478. v()
  479. }, function() {
  480. p()
  481. });
  482. c.hover(function() {
  483. x = !0
  484. }, function() {
  485. x = !1
  486. });
  487. b.hover(function() {
  488. s = !0;
  489. v();
  490. p()
  491. }, function() {
  492. s = !1;
  493. p()
  494. });
  495. b.bind("touchstart", function(a, b) {
  496. a.originalEvent.touches.length && (z = a.originalEvent.touches[0].pageY)
  497. });
  498. b.bind("touchmove", function(b) {
  499. k || b.originalEvent.preventDefault();
  500. b.originalEvent.touches.length &&
  501. (m((z - b.originalEvent.touches[0].pageY) / a.touchScrollStep, !0), z = b.originalEvent.touches[0].pageY)
  502. });
  503. w();
  504. "bottom" === a.start ? (c.css({top: b.outerHeight() - c.outerHeight()}), m(0, !0)) : "top" !== a.start && (m(f(a.start).position().top, null, !0), a.alwaysVisible || c.hide());
  505. C()
  506. }
  507. });
  508. return this
  509. }});
  510. jQuery.fn.extend({slimscroll: jQuery.fn.slimScroll})
  511. })(jQuery);
  512. /*! iCheck v1.0.1 by Damir Sultanov, http://git.io/arlzeA, MIT Licensed */
  513. (function(h) {
  514. function F(a, b, d) {
  515. var c = a[0], e = /er/.test(d) ? m : /bl/.test(d) ? s : l, f = d == H ? {checked: c[l], disabled: c[s], indeterminate: "true" == a.attr(m) || "false" == a.attr(w)} : c[e];
  516. if (/^(ch|di|in)/.test(d) && !f)
  517. D(a, e);
  518. else if (/^(un|en|de)/.test(d) && f)
  519. t(a, e);
  520. else if (d == H)
  521. for (e in f)
  522. f[e] ? D(a, e, !0) : t(a, e, !0);
  523. else if (!b || "toggle" == d) {
  524. if (!b)
  525. a[p]("ifClicked");
  526. f ? c[n] !== u && t(a, e) : D(a, e)
  527. }
  528. }
  529. function D(a, b, d) {
  530. var c = a[0], e = a.parent(), f = b == l, A = b == m, B = b == s, K = A ? w : f ? E : "enabled", p = k(a, K + x(c[n])), N = k(a, b + x(c[n]));
  531. if (!0 !== c[b]) {
  532. if (!d &&
  533. b == l && c[n] == u && c.name) {
  534. var C = a.closest("form"), r = 'input[name="' + c.name + '"]', r = C.length ? C.find(r) : h(r);
  535. r.each(function() {
  536. this !== c && h(this).data(q) && t(h(this), b)
  537. })
  538. }
  539. A ? (c[b] = !0, c[l] && t(a, l, "force")) : (d || (c[b] = !0), f && c[m] && t(a, m, !1));
  540. L(a, f, b, d)
  541. }
  542. c[s] && k(a, y, !0) && e.find("." + I).css(y, "default");
  543. e[v](N || k(a, b) || "");
  544. B ? e.attr("aria-disabled", "true") : e.attr("aria-checked", A ? "mixed" : "true");
  545. e[z](p || k(a, K) || "")
  546. }
  547. function t(a, b, d) {
  548. var c = a[0], e = a.parent(), f = b == l, h = b == m, q = b == s, p = h ? w : f ? E : "enabled", t = k(a, p + x(c[n])),
  549. u = k(a, b + x(c[n]));
  550. if (!1 !== c[b]) {
  551. if (h || !d || "force" == d)
  552. c[b] = !1;
  553. L(a, f, p, d)
  554. }
  555. !c[s] && k(a, y, !0) && e.find("." + I).css(y, "pointer");
  556. e[z](u || k(a, b) || "");
  557. q ? e.attr("aria-disabled", "false") : e.attr("aria-checked", "false");
  558. e[v](t || k(a, p) || "")
  559. }
  560. function M(a, b) {
  561. if (a.data(q)) {
  562. a.parent().html(a.attr("style", a.data(q).s || ""));
  563. if (b)
  564. a[p](b);
  565. a.off(".i").unwrap();
  566. h(G + '[for="' + a[0].id + '"]').add(a.closest(G)).off(".i")
  567. }
  568. }
  569. function k(a, b, d) {
  570. if (a.data(q))
  571. return a.data(q).o[b + (d ? "" : "Class")]
  572. }
  573. function x(a) {
  574. return a.charAt(0).toUpperCase() +
  575. a.slice(1)
  576. }
  577. function L(a, b, d, c) {
  578. if (!c) {
  579. if (b)
  580. a[p]("ifToggled");
  581. a[p]("ifChanged")[p]("if" + x(d))
  582. }
  583. }
  584. var q = "iCheck", I = q + "-helper", u = "radio", l = "checked", E = "un" + l, s = "disabled", w = "determinate", m = "in" + w, H = "update", n = "type", v = "addClass", z = "removeClass", p = "trigger", G = "label", y = "cursor", J = /ipad|iphone|ipod|android|blackberry|windows phone|opera mini|silk/i.test(navigator.userAgent);
  585. h.fn[q] = function(a, b) {
  586. var d = 'input[type="checkbox"], input[type="' + u + '"]', c = h(), e = function(a) {
  587. a.each(function() {
  588. var a = h(this);
  589. c = a.is(d) ?
  590. c.add(a) : c.add(a.find(d))
  591. })
  592. };
  593. if (/^(check|uncheck|toggle|indeterminate|determinate|disable|enable|update|destroy)$/i.test(a))
  594. return a = a.toLowerCase(), e(this), c.each(function() {
  595. var c = h(this);
  596. "destroy" == a ? M(c, "ifDestroyed") : F(c, !0, a);
  597. h.isFunction(b) && b()
  598. });
  599. if ("object" != typeof a && a)
  600. return this;
  601. var f = h.extend({checkedClass: l, disabledClass: s, indeterminateClass: m, labelHover: !0, aria: !1}, a), k = f.handle, B = f.hoverClass || "hover", x = f.focusClass || "focus", w = f.activeClass || "active", y = !!f.labelHover, C = f.labelHoverClass ||
  602. "hover", r = ("" + f.increaseArea).replace("%", "") | 0;
  603. if ("checkbox" == k || k == u)
  604. d = 'input[type="' + k + '"]';
  605. -50 > r && (r = -50);
  606. e(this);
  607. return c.each(function() {
  608. var a = h(this);
  609. M(a);
  610. var c = this, b = c.id, e = -r + "%", d = 100 + 2 * r + "%", d = {position: "absolute", top: e, left: e, display: "block", width: d, height: d, margin: 0, padding: 0, background: "#fff", border: 0, opacity: 0}, e = J ? {position: "absolute", visibility: "hidden"} : r ? d : {position: "absolute", opacity: 0}, k = "checkbox" == c[n] ? f.checkboxClass || "icheckbox" : f.radioClass || "i" + u, m = h(G + '[for="' + b + '"]').add(a.closest(G)),
  611. A = !!f.aria, E = q + "-" + Math.random().toString(36).replace("0.", ""), g = '<div class="' + k + '" ' + (A ? 'role="' + c[n] + '" ' : "");
  612. m.length && A && m.each(function() {
  613. g += 'aria-labelledby="';
  614. this.id ? g += this.id : (this.id = E, g += E);
  615. g += '"'
  616. });
  617. g = a.wrap(g + "/>")[p]("ifCreated").parent().append(f.insert);
  618. d = h('<ins class="' + I + '"/>').css(d).appendTo(g);
  619. a.data(q, {o: f, s: a.attr("style")}).css(e);
  620. f.inheritClass && g[v](c.className || "");
  621. f.inheritID && b && g.attr("id", q + "-" + b);
  622. "static" == g.css("position") && g.css("position", "relative");
  623. F(a, !0, H);
  624. if (m.length)
  625. m.on("click.i mouseover.i mouseout.i touchbegin.i touchend.i", function(b) {
  626. var d = b[n], e = h(this);
  627. if (!c[s]) {
  628. if ("click" == d) {
  629. if (h(b.target).is("a"))
  630. return;
  631. F(a, !1, !0)
  632. } else
  633. y && (/ut|nd/.test(d) ? (g[z](B), e[z](C)) : (g[v](B), e[v](C)));
  634. if (J)
  635. b.stopPropagation();
  636. else
  637. return!1
  638. }
  639. });
  640. a.on("click.i focus.i blur.i keyup.i keydown.i keypress.i", function(b) {
  641. var d = b[n];
  642. b = b.keyCode;
  643. if ("click" == d)
  644. return!1;
  645. if ("keydown" == d && 32 == b)
  646. return c[n] == u && c[l] || (c[l] ? t(a, l) : D(a, l)), !1;
  647. if ("keyup" == d && c[n] == u)
  648. !c[l] && D(a, l);
  649. else if (/us|ur/.test(d))
  650. g["blur" ==
  651. d ? z : v](x)
  652. });
  653. d.on("click mousedown mouseup mouseover mouseout touchbegin.i touchend.i", function(b) {
  654. var d = b[n], e = /wn|up/.test(d) ? w : B;
  655. if (!c[s]) {
  656. if ("click" == d)
  657. F(a, !1, !0);
  658. else {
  659. if (/wn|er|in/.test(d))
  660. g[v](e);
  661. else
  662. g[z](e + " " + w);
  663. if (m.length && y && e == B)
  664. m[/ut|nd/.test(d) ? z : v](C)
  665. }
  666. if (J)
  667. b.stopPropagation();
  668. else
  669. return!1
  670. }
  671. })
  672. })
  673. }
  674. })(window.jQuery || window.Zepto);