app.js 29 KB

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