app.js 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050
  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. bf.slideUp();
  48. } else {
  49. box.removeClass("collapsed-box");
  50. bf.slideDown();
  51. }
  52. });
  53. /*
  54. * ADD SLIMSCROLL TO THE TOP NAV DROPDOWNS
  55. * ---------------------------------------
  56. */
  57. $(".navbar .menu").slimscroll({
  58. height: "200px",
  59. alwaysVisible: false,
  60. size: "3px"
  61. }).css("width", "100%");
  62. /*
  63. * INITIALIZE BUTTON TOGGLE
  64. * ------------------------
  65. */
  66. $('.btn-group[data-toggle="btn-toggle"]').each(function() {
  67. var group = $(this);
  68. $(this).find(".btn").click(function(e) {
  69. group.find(".btn.active").removeClass("active");
  70. $(this).addClass("active");
  71. e.preventDefault();
  72. });
  73. });
  74. $("[data-widget='remove']").click(function() {
  75. //Find the box parent
  76. var box = $(this).parents(".box").first();
  77. box.slideUp();
  78. });
  79. /* Sidebar tree view */
  80. $(".sidebar .treeview").tree();
  81. /*
  82. * Make sure that the sidebar is streched full height
  83. * ---------------------------------------------
  84. * We are gonna assign a min-height value every time the
  85. * wrapper gets resized and upon page load. We will use
  86. * Ben Alman's method for detecting the resize event.
  87. *
  88. **/
  89. function _fix() {
  90. //Get window height and the wrapper height
  91. var height = $(window).height() - $("body > .header").height() - ($("body > .footer").outerHeight() || 0);
  92. $(".wrapper").css("min-height", height + "px");
  93. var content = $(".wrapper").height();
  94. //If the wrapper height is greater than the window
  95. if (content > height)
  96. //then set sidebar height to the wrapper
  97. $(".left-side, html, body").css("min-height", content + "px");
  98. else {
  99. //Otherwise, set the sidebar to the height of the window
  100. $(".left-side, html, body").css("min-height", height + "px");
  101. }
  102. }
  103. //Fire upon load
  104. _fix();
  105. //Fire when wrapper is resized
  106. $(".wrapper").resize(function() {
  107. _fix();
  108. fix_sidebar();
  109. });
  110. //Fix the fixed layout sidebar scroll bug
  111. fix_sidebar();
  112. /*
  113. * We are gonna initialize all checkbox and radio inputs to
  114. * iCheck plugin in.
  115. * You can find the documentation at http://fronteed.com/iCheck/
  116. */
  117. $("input[type='checkbox']:not(.simple), input[type='radio']:not(.simple)").iCheck({
  118. checkboxClass: 'icheckbox_minimal',
  119. radioClass: 'iradio_minimal'
  120. });
  121. });
  122. function fix_sidebar() {
  123. //Make sure the body tag has the .fixed class
  124. if (!$("body").hasClass("fixed")) {
  125. return;
  126. }
  127. //Add slimscroll
  128. $(".sidebar").slimscroll({
  129. height: ($(window).height() - $(".header").height()) + "px",
  130. color: "rgba(0,0,0,0.2)"
  131. });
  132. }
  133. /*END DEMO*/
  134. $(window).load(function() {
  135. /*! pace 0.4.17 */
  136. (function() {
  137. var a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V = [].slice, W = {}.hasOwnProperty, X = function(a, b) {
  138. function c() {
  139. this.constructor = a
  140. }
  141. for (var d in b)
  142. W.call(b, d) && (a[d] = b[d]);
  143. return c.prototype = b.prototype, a.prototype = new c, a.__super__ = b.prototype, a
  144. }, Y = [].indexOf || function(a) {
  145. for (var b = 0, c = this.length; c > b; b++)
  146. if (b in this && this[b] === a)
  147. return b;
  148. return-1
  149. };
  150. for (t = {catchupTime:500, initialRate:.03, minTime:500, ghostTime:500, maxProgressPerFrame:10, easeFactor:1.25, startOnPageLoad:!0, restartOnPushState:!0, restartOnRequestAfter:500, target:"body", elements:{checkInterval:100, selectors:["body"]}, eventLag:{minSamples:10, sampleCount:3, lagThreshold:3}, ajax:{trackMethods:["GET"], trackWebSockets:!1}}, B = function() {
  151. var a;
  152. return null != (a = "undefined" != typeof performance && null !== performance ? "function" == typeof performance.now ? performance.now() : void 0 : void 0) ? a : +new Date
  153. }, D = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame, s = window.cancelAnimationFrame || window.mozCancelAnimationFrame, null == D && (D = function(a) {
  154. return setTimeout(a, 50)
  155. }, s = function(a) {
  156. return clearTimeout(a)
  157. }), F = function(a) {
  158. var b, c;
  159. return b = B(), (c = function() {
  160. var d;
  161. return d = B() - b, d >= 33 ? (b = B(), a(d, function() {
  162. return D(c)
  163. })) : setTimeout(c, 33 - d)
  164. })()
  165. }, E = function() {
  166. var a, b, c;
  167. return c = arguments[0], b = arguments[1], a = 3 <= arguments.length ? V.call(arguments, 2) : [], "function" == typeof c[b] ? c[b].apply(c, a) : c[b]
  168. }, u = function() {
  169. var a, b, c, d, e, f, g;
  170. for (b = arguments[0], d = 2 <= arguments.length?V.call(arguments, 1):[], f = 0, g = d.length; g > f; f++)
  171. if (c = d[f])
  172. for (a in c)
  173. W.call(c, a) && (e = c[a], null != b[a] && "object" == typeof b[a] && null != e && "object" == typeof e ? u(b[a], e) : b[a] = e);
  174. return b
  175. }, p = function(a) {
  176. var b, c, d, e, f;
  177. for (c = b = 0, e = 0, f = a.length; f > e; e++)
  178. d = a[e], c += Math.abs(d), b++;
  179. return c / b
  180. }, w = function(a, b) {
  181. var c, d, e;
  182. if (null == a && (a = "options"), null == b && (b = !0), e = document.querySelector("[data-pace-" + a + "]")) {
  183. if (c = e.getAttribute("data-pace-" + a), !b)
  184. return c;
  185. try {
  186. return JSON.parse(c)
  187. } catch (f) {
  188. return d = f, "undefined" != typeof console && null !== console ? console.error("Error parsing inline pace options", d) : void 0
  189. }
  190. }
  191. }, g = function() {
  192. function a() {
  193. }
  194. return a.prototype.on = function(a, b, c, d) {
  195. var e;
  196. return null == d && (d = !1), null == this.bindings && (this.bindings = {}), null == (e = this.bindings)[a] && (e[a] = []), this.bindings[a].push({handler: b, ctx: c, once: d})
  197. }, a.prototype.once = function(a, b, c) {
  198. return this.on(a, b, c, !0)
  199. }, a.prototype.off = function(a, b) {
  200. var c, d, e;
  201. if (null != (null != (d = this.bindings) ? d[a] : void 0)) {
  202. if (null == b)
  203. return delete this.bindings[a];
  204. for (c = 0, e = []; c < this.bindings[a].length; )
  205. this.bindings[a][c].handler === b ? e.push(this.bindings[a].splice(c, 1)) : e.push(c++);
  206. return e
  207. }
  208. }, a.prototype.trigger = function() {
  209. var a, b, c, d, e, f, g, h, i;
  210. if (c = arguments[0], a = 2 <= arguments.length ? V.call(arguments, 1) : [], null != (g = this.bindings) ? g[c] : void 0) {
  211. for (e = 0, i = []; e < this.bindings[c].length; )
  212. h = this.bindings[c][e], d = h.handler, b = h.ctx, f = h.once, d.apply(null != b ? b : this, a), f ? i.push(this.bindings[c].splice(e, 1)) : i.push(e++);
  213. return i
  214. }
  215. }, a
  216. }(), null == window.Pace && (window.Pace = {}), u(Pace, g.prototype), C = Pace.options = u({}, t, window.paceOptions, w()), S = ["ajax", "document", "eventLag", "elements"], O = 0, Q = S.length; Q > O; O++)
  217. I = S[O], C[I] === !0 && (C[I] = t[I]);
  218. i = function(a) {
  219. function b() {
  220. return T = b.__super__.constructor.apply(this, arguments)
  221. }
  222. return X(b, a), b
  223. }(Error), b = function() {
  224. function a() {
  225. this.progress = 0
  226. }
  227. return a.prototype.getElement = function() {
  228. var a;
  229. if (null == this.el) {
  230. if (a = document.querySelector(C.target), !a)
  231. throw new i;
  232. this.el = document.createElement("div"), this.el.className = "pace pace-active", document.body.className = document.body.className.replace("pace-done", ""), document.body.className += " pace-running", this.el.innerHTML = '<div class="pace-progress">\n <div class="pace-progress-inner"></div>\n</div>\n<div class="pace-activity"></div>', null != a.firstChild ? a.insertBefore(this.el, a.firstChild) : a.appendChild(this.el)
  233. }
  234. return this.el
  235. }, a.prototype.finish = function() {
  236. var a;
  237. return a = this.getElement(), a.className = a.className.replace("pace-active", ""), a.className += " pace-inactive", document.body.className = document.body.className.replace("pace-running", ""), document.body.className += " pace-done"
  238. }, a.prototype.update = function(a) {
  239. return this.progress = a, this.render()
  240. }, a.prototype.destroy = function() {
  241. try {
  242. this.getElement().parentNode.removeChild(this.getElement())
  243. } catch (a) {
  244. i = a
  245. }
  246. return this.el = void 0
  247. }, a.prototype.render = function() {
  248. var a, b;
  249. return null == document.querySelector(C.target) ? !1 : (a = this.getElement(), a.children[0].style.width = "" + this.progress + "%", (!this.lastRenderedProgress || this.lastRenderedProgress | 0 !== this.progress | 0) && (a.children[0].setAttribute("data-progress-text", "" + (0 | this.progress) + "%"), this.progress >= 100 ? b = "99" : (b = this.progress < 10 ? "0" : "", b += 0 | this.progress), a.children[0].setAttribute("data-progress", "" + b)), this.lastRenderedProgress = this.progress)
  250. }, a.prototype.done = function() {
  251. return this.progress >= 100
  252. }, a
  253. }(), h = function() {
  254. function a() {
  255. this.bindings = {}
  256. }
  257. return a.prototype.trigger = function(a, b) {
  258. var c, d, e, f, g;
  259. if (null != this.bindings[a]) {
  260. for (f = this.bindings[a], g = [], d = 0, e = f.length; e > d; d++)
  261. c = f[d], g.push(c.call(this, b));
  262. return g
  263. }
  264. }, a.prototype.on = function(a, b) {
  265. var c;
  266. return null == (c = this.bindings)[a] && (c[a] = []), this.bindings[a].push(b)
  267. }, a
  268. }(), N = window.XMLHttpRequest, M = window.XDomainRequest, L = window.WebSocket, v = function(a, b) {
  269. var c, d, e, f;
  270. f = [];
  271. for (d in b.prototype)
  272. try {
  273. e = b.prototype[d], null == a[d] && "function" != typeof e ? f.push(a[d] = e) : f.push(void 0)
  274. } catch (g) {
  275. c = g
  276. }
  277. return f
  278. }, z = [], Pace.ignore = function() {
  279. var a, b, c;
  280. return b = arguments[0], a = 2 <= arguments.length ? V.call(arguments, 1) : [], z.unshift("ignore"), c = b.apply(null, a), z.shift(), c
  281. }, Pace.track = function() {
  282. var a, b, c;
  283. return b = arguments[0], a = 2 <= arguments.length ? V.call(arguments, 1) : [], z.unshift("track"), c = b.apply(null, a), z.shift(), c
  284. }, H = function(a) {
  285. var b;
  286. if (null == a && (a = "GET"), "track" === z[0])
  287. return"force";
  288. if (!z.length && C.ajax) {
  289. if ("socket" === a && C.ajax.trackWebSockets)
  290. return!0;
  291. if (b = a.toUpperCase(), Y.call(C.ajax.trackMethods, b) >= 0)
  292. return!0
  293. }
  294. return!1
  295. }, j = function(a) {
  296. function b() {
  297. var a, c = this;
  298. b.__super__.constructor.apply(this, arguments), a = function(a) {
  299. var b;
  300. return b = a.open, a.open = function(d, e) {
  301. return H(d) && c.trigger("request", {type: d, url: e, request: a}), b.apply(a, arguments)
  302. }
  303. }, window.XMLHttpRequest = function(b) {
  304. var c;
  305. return c = new N(b), a(c), c
  306. }, v(window.XMLHttpRequest, N), null != M && (window.XDomainRequest = function() {
  307. var b;
  308. return b = new M, a(b), b
  309. }, v(window.XDomainRequest, M)), null != L && C.ajax.trackWebSockets && (window.WebSocket = function(a, b) {
  310. var d;
  311. return d = new L(a, b), H("socket") && c.trigger("request", {type: "socket", url: a, protocols: b, request: d}), d
  312. }, v(window.WebSocket, L))
  313. }
  314. return X(b, a), b
  315. }(h), P = null, x = function() {
  316. return null == P && (P = new j), P
  317. }, x().on("request", function(b) {
  318. var c, d, e, f;
  319. return f = b.type, e = b.request, Pace.running || C.restartOnRequestAfter === !1 && "force" !== H(f) ? void 0 : (d = arguments, c = C.restartOnRequestAfter || 0, "boolean" == typeof c && (c = 0), setTimeout(function() {
  320. var b, c, g, h, i, j;
  321. if (b = "socket" === f ? e.readyState < 2 : 0 < (h = e.readyState) && 4 > h) {
  322. for (Pace.restart(), i = Pace.sources, j = [], c = 0, g = i.length; g > c; c++) {
  323. if (I = i[c], I instanceof a) {
  324. I.watch.apply(I, d);
  325. break
  326. }
  327. j.push(void 0)
  328. }
  329. return j
  330. }
  331. }, c))
  332. }), a = function() {
  333. function a() {
  334. var a = this;
  335. this.elements = [], x().on("request", function() {
  336. return a.watch.apply(a, arguments)
  337. })
  338. }
  339. return a.prototype.watch = function(a) {
  340. var b, c, d;
  341. return d = a.type, b = a.request, c = "socket" === d ? new m(b) : new n(b), this.elements.push(c)
  342. }, a
  343. }(), n = function() {
  344. function a(a) {
  345. var b, c, d, e, f, g, h = this;
  346. if (this.progress = 0, null != window.ProgressEvent)
  347. for (c = null, a.addEventListener("progress", function(a) {
  348. return h.progress = a.lengthComputable ? 100 * a.loaded / a.total : h.progress + (100 - h.progress) / 2
  349. }), g = ["load", "abort", "timeout", "error"], d = 0, e = g.length; e > d; d++)
  350. b = g[d], a.addEventListener(b, function() {
  351. return h.progress = 100
  352. });
  353. else
  354. f = a.onreadystatechange, a.onreadystatechange = function() {
  355. var b;
  356. return 0 === (b = a.readyState) || 4 === b ? h.progress = 100 : 3 === a.readyState && (h.progress = 50), "function" == typeof f ? f.apply(null, arguments) : void 0
  357. }
  358. }
  359. return a
  360. }(), m = function() {
  361. function a(a) {
  362. var b, c, d, e, f = this;
  363. for (this.progress = 0, e = ["error", "open"], c = 0, d = e.length; d > c; c++)
  364. b = e[c], a.addEventListener(b, function() {
  365. return f.progress = 100
  366. })
  367. }
  368. return a
  369. }(), d = function() {
  370. function a(a) {
  371. var b, c, d, f;
  372. for (null == a && (a = {}), this.elements = [], null == a.selectors && (a.selectors = []), f = a.selectors, c = 0, d = f.length; d > c; c++)
  373. b = f[c], this.elements.push(new e(b))
  374. }
  375. return a
  376. }(), e = function() {
  377. function a(a) {
  378. this.selector = a, this.progress = 0, this.check()
  379. }
  380. return a.prototype.check = function() {
  381. var a = this;
  382. return document.querySelector(this.selector) ? this.done() : setTimeout(function() {
  383. return a.check()
  384. }, C.elements.checkInterval)
  385. }, a.prototype.done = function() {
  386. return this.progress = 100
  387. }, a
  388. }(), c = function() {
  389. function a() {
  390. var a, b, c = this;
  391. this.progress = null != (b = this.states[document.readyState]) ? b : 100, a = document.onreadystatechange, document.onreadystatechange = function() {
  392. return null != c.states[document.readyState] && (c.progress = c.states[document.readyState]), "function" == typeof a ? a.apply(null, arguments) : void 0
  393. }
  394. }
  395. return a.prototype.states = {loading: 0, interactive: 50, complete: 100}, a
  396. }(), f = function() {
  397. function a() {
  398. var a, b, c, d, e, f = this;
  399. this.progress = 0, a = 0, e = [], d = 0, c = B(), b = setInterval(function() {
  400. var g;
  401. return g = B() - c - 50, c = B(), e.push(g), e.length > C.eventLag.sampleCount && e.shift(), a = p(e), ++d >= C.eventLag.minSamples && a < C.eventLag.lagThreshold ? (f.progress = 100, clearInterval(b)) : f.progress = 100 * (3 / (a + 3))
  402. }, 50)
  403. }
  404. return a
  405. }(), l = function() {
  406. function a(a) {
  407. this.source = a, this.last = this.sinceLastUpdate = 0, this.rate = C.initialRate, this.catchup = 0, this.progress = this.lastProgress = 0, null != this.source && (this.progress = E(this.source, "progress"))
  408. }
  409. return a.prototype.tick = function(a, b) {
  410. var c;
  411. return null == b && (b = E(this.source, "progress")), b >= 100 && (this.done = !0), b === this.last ? this.sinceLastUpdate += a : (this.sinceLastUpdate && (this.rate = (b - this.last) / this.sinceLastUpdate), this.catchup = (b - this.progress) / C.catchupTime, this.sinceLastUpdate = 0, this.last = b), b > this.progress && (this.progress += this.catchup * a), c = 1 - Math.pow(this.progress / 100, C.easeFactor), this.progress += c * this.rate * a, this.progress = Math.min(this.lastProgress + C.maxProgressPerFrame, this.progress), this.progress = Math.max(0, this.progress), this.progress = Math.min(100, this.progress), this.lastProgress = this.progress, this.progress
  412. }, a
  413. }(), J = null, G = null, q = null, K = null, o = null, r = null, Pace.running = !1, y = function() {
  414. return C.restartOnPushState ? Pace.restart() : void 0
  415. }, null != window.history.pushState && (R = window.history.pushState, window.history.pushState = function() {
  416. return y(), R.apply(window.history, arguments)
  417. }), null != window.history.replaceState && (U = window.history.replaceState, window.history.replaceState = function() {
  418. return y(), U.apply(window.history, arguments)
  419. }), k = {ajax: a, elements: d, document: c, eventLag: f}, (A = function() {
  420. var a, c, d, e, f, g, h, i;
  421. for (Pace.sources = J = [], g = ["ajax", "elements", "document", "eventLag"], c = 0, e = g.length; e > c; c++)
  422. a = g[c], C[a] !== !1 && J.push(new k[a](C[a]));
  423. for (i = null != (h = C.extraSources)?h:[], d = 0, f = i.length; f > d; d++)
  424. I = i[d], J.push(new I(C));
  425. return Pace.bar = q = new b, G = [], K = new l
  426. })(), Pace.stop = function() {
  427. return Pace.trigger("stop"), Pace.running = !1, q.destroy(), r = !0, null != o && ("function" == typeof s && s(o), o = null), A()
  428. }, Pace.restart = function() {
  429. return Pace.trigger("restart"), Pace.stop(), Pace.start()
  430. }, Pace.go = function() {
  431. return Pace.running = !0, q.render(), r = !1, o = F(function(a, b) {
  432. var c, d, e, f, g, h, i, j, k, m, n, o, p, s, t, u, v;
  433. for (j = 100 - q.progress, d = o = 0, e = !0, h = p = 0, t = J.length; t > p; h = ++p)
  434. for (I = J[h], m = null != G[h]?G[h]:G[h] = [], g = null != (v = I.elements)?v:[I], i = s = 0, u = g.length; u > s; i = ++s)
  435. f = g[i], k = null != m[i] ? m[i] : m[i] = new l(f), e &= k.done, k.done || (d++, o += k.tick(a));
  436. return c = o / d, q.update(K.tick(a, c)), n = B(), q.done() || e || r ? (q.update(100), Pace.trigger("done"), setTimeout(function() {
  437. return q.finish(), Pace.running = !1, Pace.trigger("hide")
  438. }, Math.max(C.ghostTime, Math.min(C.minTime, B() - n)))) : b()
  439. })
  440. }, Pace.start = function(a) {
  441. u(C, a), Pace.running = !0;
  442. try {
  443. q.render()
  444. } catch (b) {
  445. i = b
  446. }
  447. return document.querySelector(".pace") ? (Pace.trigger("start"), Pace.go()) : setTimeout(Pace.start, 50)
  448. }, "function" == typeof define && define.amd ? define('theme-app', [], function() {
  449. return Pace
  450. }) : "object" == typeof exports ? module.exports = Pace : C.startOnPageLoad && Pace.start()
  451. }).call(this);
  452. });
  453. /*
  454. * BOX REFRESH BUTTON
  455. * ------------------
  456. * This is a custom plugin to use with the compenet BOX. It allows you to add
  457. * a refresh button to the box. It converts the box's state to a loading state.
  458. *
  459. * USAGE:
  460. * $("#box-widget").boxRefresh( options );
  461. * */
  462. (function($) {
  463. "use strict";
  464. $.fn.boxRefresh = function(options) {
  465. // Render options
  466. var settings = $.extend({
  467. //Refressh button selector
  468. trigger: ".refresh-btn",
  469. //File source to be loaded (e.g: ajax/src.php)
  470. source: "",
  471. //Callbacks
  472. onLoadStart: function(box) {
  473. }, //Right after the button has been clicked
  474. onLoadDone: function(box) {
  475. } //When the source has been loaded
  476. }, options);
  477. //The overlay
  478. var overlay = $('<div class="overlay"></div><div class="loading-img"></div>');
  479. return this.each(function() {
  480. //if a source is specified
  481. if (settings.source === "") {
  482. if (console) {
  483. console.log("Please specify a source first - boxRefresh()");
  484. }
  485. return;
  486. }
  487. //the box
  488. var box = $(this);
  489. //the button
  490. var rBtn = box.find(settings.trigger).first();
  491. //On trigger click
  492. rBtn.click(function(e) {
  493. e.preventDefault();
  494. //Add loading overlay
  495. start(box);
  496. //Perform ajax call
  497. box.find(".box-body").load(settings.source, function() {
  498. done(box);
  499. });
  500. });
  501. });
  502. function start(box) {
  503. //Add overlay and loading img
  504. box.append(overlay);
  505. settings.onLoadStart.call(box);
  506. }
  507. function done(box) {
  508. //Remove overlay and loading img
  509. box.find(overlay).remove();
  510. settings.onLoadDone.call(box);
  511. }
  512. };
  513. })(jQuery);
  514. /*
  515. * SIDEBAR MENU
  516. * ------------
  517. * This is a custom plugin for the sidebar menu. It provides a tree view.
  518. *
  519. * Usage:
  520. * $(".sidebar).tree();
  521. *
  522. * Note: This plugin does not accept any options. Instead, it only requires a class
  523. * added to the element that contains a sub-menu.
  524. *
  525. * When used with the sidebar, for example, it would look something like this:
  526. * <ul class='sidebar-menu'>
  527. * <li class="treeview active">
  528. * <a href="#>Menu</a>
  529. * <ul class='treeview-menu'>
  530. * <li class='active'><a href=#>Level 1</a></li>
  531. * </ul>
  532. * </li>
  533. * </ul>
  534. *
  535. * Add .active class to <li> elements if you want the menu to be open automatically
  536. * on page load. See above for an example.
  537. */
  538. (function($) {
  539. "use strict";
  540. $.fn.tree = function() {
  541. return this.each(function() {
  542. var btn = $(this).children("a").first();
  543. var menu = $(this).children(".treeview-menu").first();
  544. var isActive = $(this).hasClass('active');
  545. //initialize already active menus
  546. if (isActive) {
  547. menu.show();
  548. btn.children(".fa-angle-left").first().removeClass("fa-angle-left").addClass("fa-angle-down");
  549. }
  550. //Slide open or close the menu on link click
  551. btn.click(function(e) {
  552. e.preventDefault();
  553. if (isActive) {
  554. //Slide up to close menu
  555. menu.slideUp();
  556. isActive = false;
  557. btn.children(".fa-angle-down").first().removeClass("fa-angle-down").addClass("fa-angle-left");
  558. btn.parent("li").removeClass("active");
  559. } else {
  560. //Slide down to open menu
  561. menu.slideDown();
  562. isActive = true;
  563. btn.children(".fa-angle-left").first().removeClass("fa-angle-left").addClass("fa-angle-down");
  564. btn.parent("li").addClass("active");
  565. }
  566. });
  567. /* Add margins to submenu elements to give it a tree look */
  568. menu.find("li > a").each(function() {
  569. var pad = parseInt($(this).css("margin-left")) + 10;
  570. $(this).css({"margin-left": pad + "px"});
  571. });
  572. });
  573. };
  574. }(jQuery));
  575. /*
  576. * TODO LIST CUSTOM PLUGIN
  577. * -----------------------
  578. * This plugin depends on iCheck plugin for checkbox and radio inputs
  579. */
  580. (function($) {
  581. "use strict";
  582. $.fn.todolist = function(options) {
  583. // Render options
  584. var settings = $.extend({
  585. //When the user checks the input
  586. onCheck: function(ele) {
  587. },
  588. //When the user unchecks the input
  589. onUncheck: function(ele) {
  590. }
  591. }, options);
  592. return this.each(function() {
  593. $('input', this).on('ifChecked', function(event) {
  594. var ele = $(this).parents("li").first();
  595. ele.toggleClass("done");
  596. settings.onCheck.call(ele);
  597. });
  598. $('input', this).on('ifUnchecked', function(event) {
  599. var ele = $(this).parents("li").first();
  600. ele.toggleClass("done");
  601. settings.onUncheck.call(ele);
  602. });
  603. });
  604. };
  605. }(jQuery));
  606. /* CENTER ELEMENTS */
  607. (function($) {
  608. "use strict";
  609. jQuery.fn.center = function(parent) {
  610. if (parent) {
  611. parent = this.parent();
  612. } else {
  613. parent = window;
  614. }
  615. this.css({
  616. "position": "absolute",
  617. "top": ((($(parent).height() - this.outerHeight()) / 2) + $(parent).scrollTop() + "px"),
  618. "left": ((($(parent).width() - this.outerWidth()) / 2) + $(parent).scrollLeft() + "px")
  619. });
  620. return this;
  621. }
  622. }(jQuery));
  623. /*
  624. * jQuery resize event - v1.1 - 3/14/2010
  625. * http://benalman.com/projects/jquery-resize-plugin/
  626. *
  627. * Copyright (c) 2010 "Cowboy" Ben Alman
  628. * Dual licensed under the MIT and GPL licenses.
  629. * http://benalman.com/about/license/
  630. */
  631. (function($, h, c) {
  632. var a = $([]), e = $.resize = $.extend($.resize, {}), i, k = "setTimeout", j = "resize", d = j + "-special-event", b = "delay", f = "throttleWindow";
  633. e[b] = 250;
  634. e[f] = true;
  635. $.event.special[j] = {setup: function() {
  636. if (!e[f] && this[k]) {
  637. return false;
  638. }
  639. var l = $(this);
  640. a = a.add(l);
  641. $.data(this, d, {w: l.width(), h: l.height()});
  642. if (a.length === 1) {
  643. g();
  644. }
  645. }, teardown: function() {
  646. if (!e[f] && this[k]) {
  647. return false
  648. }
  649. var l = $(this);
  650. a = a.not(l);
  651. l.removeData(d);
  652. if (!a.length) {
  653. clearTimeout(i);
  654. }
  655. }, add: function(l) {
  656. if (!e[f] && this[k]) {
  657. return false
  658. }
  659. var n;
  660. function m(s, o, p) {
  661. var q = $(this), r = $.data(this, d);
  662. r.w = o !== c ? o : q.width();
  663. r.h = p !== c ? p : q.height();
  664. n.apply(this, arguments)
  665. }
  666. if ($.isFunction(l)) {
  667. n = l;
  668. return m
  669. } else {
  670. n = l.handler;
  671. l.handler = m
  672. }
  673. }};
  674. function g() {
  675. i = h[k](function() {
  676. a.each(function() {
  677. var n = $(this), m = n.width(), l = n.height(), o = $.data(this, d);
  678. if (m !== o.w || l !== o.h) {
  679. n.trigger(j, [o.w = m, o.h = l])
  680. }
  681. });
  682. g()
  683. }, e[b])
  684. }}
  685. )(jQuery, this);
  686. /*!
  687. * SlimScroll https://github.com/rochal/jQuery-slimScroll
  688. * =======================================================
  689. *
  690. * Copyright (c) 2011 Piotr Rochala (http://rocha.la) Dual licensed under the MIT
  691. */
  692. (function(f) {
  693. jQuery.fn.extend({slimScroll: function(h) {
  694. 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);
  695. this.each(function() {
  696. function r(d) {
  697. if (s) {
  698. d = d ||
  699. window.event;
  700. var c = 0;
  701. d.wheelDelta && (c = -d.wheelDelta / 120);
  702. d.detail && (c = d.detail / 3);
  703. f(d.target || d.srcTarget || d.srcElement).closest("." + a.wrapperClass).is(b.parent()) && m(c, !0);
  704. d.preventDefault && !k && d.preventDefault();
  705. k || (d.returnValue = !1)
  706. }
  707. }
  708. function m(d, f, h) {
  709. k = !1;
  710. var e = d, g = b.outerHeight() - c.outerHeight();
  711. 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"}));
  712. l = parseInt(c.css("top")) / (b.outerHeight() - c.outerHeight());
  713. e = l * (b[0].scrollHeight - b.outerHeight());
  714. h && (e = d, d = e / b[0].scrollHeight * b.outerHeight(), d = Math.min(Math.max(d, 0), g), c.css({top: d + "px"}));
  715. b.scrollTop(e);
  716. b.trigger("slimscrolling", ~~e);
  717. v();
  718. p()
  719. }
  720. function C() {
  721. window.addEventListener ? (this.addEventListener("DOMMouseScroll", r, !1), this.addEventListener("mousewheel", r, !1), this.addEventListener("MozMousePixelScroll", r, !1)) : document.attachEvent("onmousewheel", r)
  722. }
  723. function w() {
  724. u = Math.max(b.outerHeight() / b[0].scrollHeight * b.outerHeight(), D);
  725. c.css({height: u + "px"});
  726. var a = u == b.outerHeight() ? "none" : "block";
  727. c.css({display: a})
  728. }
  729. function v() {
  730. w();
  731. clearTimeout(A);
  732. l == ~~l ? (k = a.allowPageScroll, B != l && b.trigger("slimscroll", 0 == ~~l ? "top" : "bottom")) : k = !1;
  733. B = l;
  734. u >= b.outerHeight() ? k = !0 : (c.stop(!0, !0).fadeIn("fast"), a.railVisible && g.stop(!0, !0).fadeIn("fast"))
  735. }
  736. function p() {
  737. a.alwaysVisible || (A = setTimeout(function() {
  738. a.disableFadeOut && s || (x || y) || (c.fadeOut("slow"), g.fadeOut("slow"))
  739. }, 1E3))
  740. }
  741. var s, x, y, A, z, u, l, B, D = 30, k = !1, b = f(this);
  742. if (b.parent().hasClass(a.wrapperClass)) {
  743. var n = b.scrollTop(),
  744. c = b.parent().find("." + a.barClass), g = b.parent().find("." + a.railClass);
  745. w();
  746. if (f.isPlainObject(h)) {
  747. if ("height"in h && "auto" == h.height) {
  748. b.parent().css("height", "auto");
  749. b.css("height", "auto");
  750. var q = b.parent().parent().height();
  751. b.parent().css("height", q);
  752. b.css("height", q)
  753. }
  754. if ("scrollTo"in h)
  755. n = parseInt(a.scrollTo);
  756. else if ("scrollBy"in h)
  757. n += parseInt(a.scrollBy);
  758. else if ("destroy"in h) {
  759. c.remove();
  760. g.remove();
  761. b.unwrap();
  762. return
  763. }
  764. m(n, !1, !0)
  765. }
  766. } else {
  767. a.height = "auto" == a.height ? b.parent().height() : a.height;
  768. n = f("<div></div>").addClass(a.wrapperClass).css({position: "relative",
  769. overflow: "hidden", width: a.width, height: a.height});
  770. b.css({overflow: "hidden", width: a.width, height: a.height});
  771. 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 ?
  772. "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};
  773. g.css(q);
  774. c.css(q);
  775. b.wrap(n);
  776. b.parent().append(c);
  777. b.parent().append(g);
  778. a.railDraggable && c.bind("mousedown", function(a) {
  779. var b = f(document);
  780. y = !0;
  781. t = parseFloat(c.css("top"));
  782. pageY = a.pageY;
  783. b.bind("mousemove.slimscroll", function(a) {
  784. currTop = t + a.pageY - pageY;
  785. c.css("top", currTop);
  786. m(0, c.position().top, !1)
  787. });
  788. b.bind("mouseup.slimscroll", function(a) {
  789. y = !1;
  790. p();
  791. b.unbind(".slimscroll")
  792. });
  793. return!1
  794. }).bind("selectstart.slimscroll", function(a) {
  795. a.stopPropagation();
  796. a.preventDefault();
  797. return!1
  798. });
  799. g.hover(function() {
  800. v()
  801. }, function() {
  802. p()
  803. });
  804. c.hover(function() {
  805. x = !0
  806. }, function() {
  807. x = !1
  808. });
  809. b.hover(function() {
  810. s = !0;
  811. v();
  812. p()
  813. }, function() {
  814. s = !1;
  815. p()
  816. });
  817. b.bind("touchstart", function(a, b) {
  818. a.originalEvent.touches.length && (z = a.originalEvent.touches[0].pageY)
  819. });
  820. b.bind("touchmove", function(b) {
  821. k || b.originalEvent.preventDefault();
  822. b.originalEvent.touches.length &&
  823. (m((z - b.originalEvent.touches[0].pageY) / a.touchScrollStep, !0), z = b.originalEvent.touches[0].pageY)
  824. });
  825. w();
  826. "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());
  827. C()
  828. }
  829. });
  830. return this
  831. }});
  832. jQuery.fn.extend({slimscroll: jQuery.fn.slimScroll})
  833. })(jQuery);
  834. /*! iCheck v1.0.1 by Damir Sultanov, http://git.io/arlzeA, MIT Licensed */
  835. (function(h) {
  836. function F(a, b, d) {
  837. 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];
  838. if (/^(ch|di|in)/.test(d) && !f)
  839. D(a, e);
  840. else if (/^(un|en|de)/.test(d) && f)
  841. t(a, e);
  842. else if (d == H)
  843. for (e in f)
  844. f[e] ? D(a, e, !0) : t(a, e, !0);
  845. else if (!b || "toggle" == d) {
  846. if (!b)
  847. a[p]("ifClicked");
  848. f ? c[n] !== u && t(a, e) : D(a, e)
  849. }
  850. }
  851. function D(a, b, d) {
  852. 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]));
  853. if (!0 !== c[b]) {
  854. if (!d &&
  855. b == l && c[n] == u && c.name) {
  856. var C = a.closest("form"), r = 'input[name="' + c.name + '"]', r = C.length ? C.find(r) : h(r);
  857. r.each(function() {
  858. this !== c && h(this).data(q) && t(h(this), b)
  859. })
  860. }
  861. A ? (c[b] = !0, c[l] && t(a, l, "force")) : (d || (c[b] = !0), f && c[m] && t(a, m, !1));
  862. L(a, f, b, d)
  863. }
  864. c[s] && k(a, y, !0) && e.find("." + I).css(y, "default");
  865. e[v](N || k(a, b) || "");
  866. B ? e.attr("aria-disabled", "true") : e.attr("aria-checked", A ? "mixed" : "true");
  867. e[z](p || k(a, K) || "")
  868. }
  869. function t(a, b, d) {
  870. 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])),
  871. u = k(a, b + x(c[n]));
  872. if (!1 !== c[b]) {
  873. if (h || !d || "force" == d)
  874. c[b] = !1;
  875. L(a, f, p, d)
  876. }
  877. !c[s] && k(a, y, !0) && e.find("." + I).css(y, "pointer");
  878. e[z](u || k(a, b) || "");
  879. q ? e.attr("aria-disabled", "false") : e.attr("aria-checked", "false");
  880. e[v](t || k(a, p) || "")
  881. }
  882. function M(a, b) {
  883. if (a.data(q)) {
  884. a.parent().html(a.attr("style", a.data(q).s || ""));
  885. if (b)
  886. a[p](b);
  887. a.off(".i").unwrap();
  888. h(G + '[for="' + a[0].id + '"]').add(a.closest(G)).off(".i")
  889. }
  890. }
  891. function k(a, b, d) {
  892. if (a.data(q))
  893. return a.data(q).o[b + (d ? "" : "Class")]
  894. }
  895. function x(a) {
  896. return a.charAt(0).toUpperCase() +
  897. a.slice(1)
  898. }
  899. function L(a, b, d, c) {
  900. if (!c) {
  901. if (b)
  902. a[p]("ifToggled");
  903. a[p]("ifChanged")[p]("if" + x(d))
  904. }
  905. }
  906. 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);
  907. h.fn[q] = function(a, b) {
  908. var d = 'input[type="checkbox"], input[type="' + u + '"]', c = h(), e = function(a) {
  909. a.each(function() {
  910. var a = h(this);
  911. c = a.is(d) ?
  912. c.add(a) : c.add(a.find(d))
  913. })
  914. };
  915. if (/^(check|uncheck|toggle|indeterminate|determinate|disable|enable|update|destroy)$/i.test(a))
  916. return a = a.toLowerCase(), e(this), c.each(function() {
  917. var c = h(this);
  918. "destroy" == a ? M(c, "ifDestroyed") : F(c, !0, a);
  919. h.isFunction(b) && b()
  920. });
  921. if ("object" != typeof a && a)
  922. return this;
  923. 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 ||
  924. "hover", r = ("" + f.increaseArea).replace("%", "") | 0;
  925. if ("checkbox" == k || k == u)
  926. d = 'input[type="' + k + '"]';
  927. -50 > r && (r = -50);
  928. e(this);
  929. return c.each(function() {
  930. var a = h(this);
  931. M(a);
  932. 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)),
  933. A = !!f.aria, E = q + "-" + Math.random().toString(36).replace("0.", ""), g = '<div class="' + k + '" ' + (A ? 'role="' + c[n] + '" ' : "");
  934. m.length && A && m.each(function() {
  935. g += 'aria-labelledby="';
  936. this.id ? g += this.id : (this.id = E, g += E);
  937. g += '"'
  938. });
  939. g = a.wrap(g + "/>")[p]("ifCreated").parent().append(f.insert);
  940. d = h('<ins class="' + I + '"/>').css(d).appendTo(g);
  941. a.data(q, {o: f, s: a.attr("style")}).css(e);
  942. f.inheritClass && g[v](c.className || "");
  943. f.inheritID && b && g.attr("id", q + "-" + b);
  944. "static" == g.css("position") && g.css("position", "relative");
  945. F(a, !0, H);
  946. if (m.length)
  947. m.on("click.i mouseover.i mouseout.i touchbegin.i touchend.i", function(b) {
  948. var d = b[n], e = h(this);
  949. if (!c[s]) {
  950. if ("click" == d) {
  951. if (h(b.target).is("a"))
  952. return;
  953. F(a, !1, !0)
  954. } else
  955. y && (/ut|nd/.test(d) ? (g[z](B), e[z](C)) : (g[v](B), e[v](C)));
  956. if (J)
  957. b.stopPropagation();
  958. else
  959. return!1
  960. }
  961. });
  962. a.on("click.i focus.i blur.i keyup.i keydown.i keypress.i", function(b) {
  963. var d = b[n];
  964. b = b.keyCode;
  965. if ("click" == d)
  966. return!1;
  967. if ("keydown" == d && 32 == b)
  968. return c[n] == u && c[l] || (c[l] ? t(a, l) : D(a, l)), !1;
  969. if ("keyup" == d && c[n] == u)
  970. !c[l] && D(a, l);
  971. else if (/us|ur/.test(d))
  972. g["blur" ==
  973. d ? z : v](x)
  974. });
  975. d.on("click mousedown mouseup mouseover mouseout touchbegin.i touchend.i", function(b) {
  976. var d = b[n], e = /wn|up/.test(d) ? w : B;
  977. if (!c[s]) {
  978. if ("click" == d)
  979. F(a, !1, !0);
  980. else {
  981. if (/wn|er|in/.test(d))
  982. g[v](e);
  983. else
  984. g[z](e + " " + w);
  985. if (m.length && y && e == B)
  986. m[/ut|nd/.test(d) ? z : v](C)
  987. }
  988. if (J)
  989. b.stopPropagation();
  990. else
  991. return!1
  992. }
  993. })
  994. })
  995. }
  996. })(window.jQuery || window.Zepto);