You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

app.js 29 kB

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