vendor: 5,800 bytes, lines 1-170
1/*! 2 * Materialize v0.100.1 (http://materializecss.com) 3 * Copyright 2014-2017 Materialize 4 * MIT License (https://raw.githubusercontent.com/Dogfalo/materialize/master/LICENSE) 5 */ 6var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 7 8function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 9 10// Check for jQuery. 11if (typeof jQuery === 'undefined') { 12 var jQuery; 13 // Check if require is a defined function. 14 if (typeof require === 'function') { 15 jQuery = $ = require('jquery'); 16 // Else use the dollar sign alias. 17 } else { 18 jQuery = $; 19 } 20} 21; /* 22 * jQuery Easing v1.4.0 - http://gsgd.co.uk/sandbox/jquery/easing/ 23 * Open source under the BSD License. 24 * Copyright © 2008 George McGinley Smith 25 * All rights reserved. 26 * https://raw.github.com/gdsmith/jquery-easing/master/LICENSE 27 */ 28 29(function (factory) { 30 if (typeof define === "function" && define.amd) { 31 define(['jquery'], function ($) { 32 return factory($); 33 }); 34 } else if (typeof module === "object" && typeof module.exports === "object") { 35 exports = factory(require('jquery')); 36 } else { 37 factory(jQuery); 38 } 39})(function ($) { 40 41 // Preserve the original jQuery "swing" easing as "jswing" 42 $.easing['jswing'] = $.easing['swing']; 43 44 var pow = Math.pow, 45 sqrt = Math.sqrt, 46 sin = Math.sin, 47 cos = Math.cos, 48 PI = Math.PI, 49 c1 = 1.70158, 50 c2 = c1 * 1.525, 51 c3 = c1 + 1, 52 c4 = 2 * PI / 3, 53 c5 = 2 * PI / 4.5; 54 55 // x is the fraction of animation progress, in the range 0..1 56 function bounceOut(x) { 57 var n1 = 7.5625, 58 d1 = 2.75; 59 if (x < 1 / d1) { 60 return n1 * x * x; 61 } else if (x < 2 / d1) { 62 return n1 * (x -= 1.5 / d1) * x + .75; 63 } else if (x < 2.5 / d1) { 64 return n1 * (x -= 2.25 / d1) * x + .9375; 65 } else { 66 return n1 * (x -= 2.625 / d1) * x + .984375; 67 } 68 } 69 70 $.extend($.easing, { 71 def: 'easeOutQuad', 72 swing: function (x) { 73 return $.easing[$.easing.def](x); 74 }, 75 easeInQuad: function (x) { 76 return x * x; 77 }, 78 easeOutQuad: function (x) { 79 return 1 - (1 - x) * (1 - x); 80 }, 81 easeInOutQuad: function (x) { 82 return x < 0.5 ? 2 * x * x : 1 - pow(-2 * x + 2, 2) / 2; 83 }, 84 easeInCubic: function (x) { 85 return x * x * x; 86 }, 87 easeOutCubic: function (x) { 88 return 1 - pow(1 - x, 3); 89 }, 90 easeInOutCubic: function (x) { 91 return x < 0.5 ? 4 * x * x * x : 1 - pow(-2 * x + 2, 3) / 2; 92 }, 93 easeInQuart: function (x) { 94 return x * x * x * x; 95 }, 96 easeOutQuart: function (x) { 97 return 1 - pow(1 - x, 4); 98 }, 99 easeInOutQuart: function (x) { 100 return x < 0.5 ? 8 * x * x * x * x : 1 - pow(-2 * x + 2, 4) / 2; 101 }, 102 easeInQuint: function (x) { 103 return x * x * x * x * x; 104 }, 105 easeOutQuint: function (x) { 106 return 1 - pow(1 - x, 5); 107 }, 108 easeInOutQuint: function (x) { 109 return x < 0.5 ? 16 * x * x * x * x * x : 1 - pow(-2 * x + 2, 5) / 2; 110 }, 111 easeInSine: function (x) { 112 return 1 - cos(x * PI / 2); 113 }, 114 easeOutSine: function (x) { 115 return sin(x * PI / 2); 116 }, 117 easeInOutSine: function (x) { 118 return -(cos(PI * x) - 1) / 2; 119 }, 120 easeInExpo: function (x) { 121 return x === 0 ? 0 : pow(2, 10 * x - 10); 122 }, 123 easeOutExpo: function (x) { 124 return x === 1 ? 1 : 1 - pow(2, -10 * x); 125 }, 126 easeInOutExpo: function (x) { 127 return x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ? pow(2, 20 * x - 10) / 2 : (2 - pow(2, -20 * x + 10)) / 2; 128 }, 129 easeInCirc: function (x) { 130 return 1 - sqrt(1 - pow(x, 2)); 131 }, 132 easeOutCirc: function (x) { 133 return sqrt(1 - pow(x - 1, 2)); 134 }, 135 easeInOutCirc: function (x) { 136 return x < 0.5 ? (1 - sqrt(1 - pow(2 * x, 2))) / 2 : (sqrt(1 - pow(-2 * x + 2, 2)) + 1) / 2; 137 }, 138 easeInElastic: function (x) { 139 return x === 0 ? 0 : x === 1 ? 1 : -pow(2, 10 * x - 10) * sin((x * 10 - 10.75) * c4); 140 }, 141 easeOutElastic: function (x) { 142 return x === 0 ? 0 : x === 1 ? 1 : pow(2, -10 * x) * sin((x * 10 - 0.75) * c4) + 1; 143 }, 144 easeInOutElastic: function (x) { 145 return x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ? -(pow(2, 20 * x - 10) * sin((20 * x - 11.125) * c5)) / 2 : pow(2, -20 * x + 10) * sin((20 * x - 11.125) * c5) / 2 + 1; 146 }, 147 easeInBack: function (x) { 148 return c3 * x * x * x - c1 * x * x; 149 }, 150 easeOutBack: function (x) { 151 return 1 + c3 * pow(x - 1, 3) + c1 * pow(x - 1, 2); 152 }, 153 easeInOutBack: function (x) { 154 return x < 0.5 ? pow(2 * x, 2) * ((c2 + 1) * 2 * x - c2) / 2 : (pow(2 * x - 2, 2) * ((c2 + 1) * (x * 2 - 2) + c2) + 2) / 2; 155 }, 156 easeInBounce: function (x) { 157 return 1 - bounceOut(1 - x); 158 }, 159 easeOutBounce: bounceOut, 160 easeInOutBounce: function (x) { 161 return x < 0.5 ? (1 - bounceOut(1 - 2 * x)) / 2 : (1 + bounceOut(2 * x - 1)) / 2; 162 } 163 }); 164});; // Custom Easing 165jQuery.extend(jQuery.easing, { 166 easeInOutMaterial: function (x, t, b, c, d) { 167 if ((t /= d / 2) < 1) return c / 2 * t * t + b; 168 return c / 4 * ((t -= 2) * t * t + 2) + b; 169 } 170});; /*! VelocityJS.org (1.2.3). (C) 2014 Julian Shapiro. MIT @license: en.wikipedia.org/wiki/MIT_License */
171/*! VelocityJS.org jQuery Shim (1.0.1). (C) 2014 The jQuery Foundation. MIT @license: en.wikipedia.org/wiki/MIT_License. */ 172/*! Note that this has been modified by Materialize to confirm that Velocity is not already being imported. */ 173jQuery.Velocity ? console.log("Velocity is already loaded. You may be needlessly importing Velocity again; note that Materialize includes Velocity.") : (!function (e) { 174 function t(e) { 175 var t = e.length, 176 a = r.type(e);return "function" === a || r.isWindow(e) ? !1 : 1 === e.nodeType && t ? !0 : "array" === a || 0 === t || "number" == typeof t && t > 0 && t - 1 in e; 177 }if (!e.jQuery) { 178 var r = function (e, t) { 179 return new r.fn.init(e, t); 180 };r.isWindow = function (e) { 181 return null != e && e == e.window; 182 }, r.type = function (e) { 183 return null == e ? e + "" : "object" == typeof e || "function" == typeof e ? n[i.call(e)] || "object" : typeof e; 184 }, r.isArray = Array.isArray || function (e) { 185 return "array" === r.type(e); 186 }, r.isPlainObject = function (e) { 187 var t;if (!e || "object" !== r.type(e) || e.nodeType || r.isWindow(e)) return !1;try { 188 if (e.constructor && !o.call(e, "constructor") && !o.call(e.constructor.prototype, "isPrototypeOf")) return !1; 189 } catch (a) { 190 return !1; 191 }for (t in e) {}return void 0 === t || o.call(e, t); 192 }, r.each = function (e, r, a) { 193 var n, 194 o = 0, 195 i = e.length, 196 s = t(e);if (a) { 197 if (s) for (; i > o && (n = r.apply(e[o], a), n !== !1); o++) {} else for (o in e) { 198 if (n = r.apply(e[o], a), n === !1) break; 199 } 200 } else if (s) for (; i > o && (n = r.call(e[o], o, e[o]), n !== !1); o++) {} else for (o in e) { 201 if (n = r.call(e[o], o, e[o]), n === !1) break; 202 }return e; 203 }, r.data = function (e, t, n) { 204 if (void 0 === n) { 205 var o = e[r.expando], 206 i = o && a[o];if (void 0 === t) return i;if (i && t in i) return i[t]; 207 } else if (void 0 !== t) { 208 var o = e[r.expando] || (e[r.expando] = ++r.uuid);return a[o] = a[o] || {}, a[o][t] = n, n; 209 } 210 }, r.removeData = function (e, t) { 211 var n = e[r.expando], 212 o = n && a[n];o && r.each(t, function (e, t) { 213 delete o[t]; 214 }); 215 }, r.extend = function () { 216 var e, 217 t, 218 a, 219 n, 220 o, 221 i, 222 s = arguments[0] || {}, 223 l = 1, 224 u = arguments.length, 225 c = !1;for ("boolean" == typeof s && (c = s, s = arguments[l] || {}, l++), "object" != typeof s && "function" !== r.type(s) && (s = {}), l === u && (s = this, l--); u > l; l++) { 226 if (null != (o = arguments[l])) for (n in o) { 227 e = s[n], a = o[n], s !== a && (c && a && (r.isPlainObject(a) || (t = r.isArray(a))) ? (t ? (t = !1, i = e && r.isArray(e) ? e : []) : i = e && r.isPlainObject(e) ? e : {}, s[n] = r.extend(c, i, a)) : void 0 !== a && (s[n] = a)); 228 } 229 }return s; 230 }, r.queue = function (e, a, n) { 231 function o(e, r) { 232 var a = r || [];return null != e && (t(Object(e)) ? !function (e, t) { 233 for (var r = +t.length, a = 0, n = e.length; r > a;) { 234 e[n++] = t[a++]; 235 }if (r !== r) for (; void 0 !== t[a];) { 236 e[n++] = t[a++]; 237 }return e.length = n, e; 238 }(a, "string" == typeof e ? [e] : e) : [].push.call(a, e)), a; 239 }if (e) { 240 a = (a || "fx") + "queue";var i = r.data(e, a);return n ? (!i || r.isArray(n) ? i = r.data(e, a, o(n)) : i.push(n), i) : i || []; 241 } 242 }, r.dequeue = function (e, t) { 243 r.each(e.nodeType ? [e] : e, function (e, a) { 244 t = t || "fx";var n = r.queue(a, t), 245 o = n.shift();"inprogress" === o && (o = n.shift()), o && ("fx" === t && n.unshift("inprogress"), o.call(a, function () { 246 r.dequeue(a, t); 247 })); 248 }); 249 }, r.fn = r.prototype = { init: function (e) { 250 if (e.nodeType) return this[0] = e, this;throw new Error("Not a DOM node."); 251 }, offset: function () { 252 var t = this[0].getBoundingClientRect ? this[0].getBoundingClientRect() : { top: 0, left: 0 };return { top: t.top + (e.pageYOffset || document.scrollTop || 0) - (document.clientTop || 0), left: t.left + (e.pageXOffset || document.scrollLeft || 0) - (document.clientLeft || 0) }; 253 }, position: function () { 254 function e() { 255 for (var e = this.offsetParent || document; e && "html" === !e.nodeType.toLowerCase && "static" === e.style.position;) { 256 e = e.offsetParent; 257 }return e || document; 258 }var t = this[0], 259 e = e.apply(t), 260 a = this.offset(), 261 n = /^(?:body|html)$/i.test(e.nodeName) ? { top: 0, left: 0 } : r(e).offset();return a.top -= parseFloat(t.style.marginTop) || 0, a.left -= parseFloat(t.style.marginLeft) || 0, e.style && (n.top += parseFloat(e.style.borderTopWidth) || 0, n.left += parseFloat(e.style.borderLeftWidth) || 0), { top: a.top - n.top, left: a.left - n.left }; 262 } };var a = {};r.expando = "velocity" + new Date().getTime(), r.uuid = 0;for (var n = {}, o = n.hasOwnProperty, i = n.toString, s = "Boolean Number String Function Array Date RegExp Object Error".split(" "), l = 0; l < s.length; l++) { 263 n["[object " + s[l] + "]"] = s[l].toLowerCase(); 264 }r.fn.init.prototype = r.fn, e.Velocity = { Utilities: r }; 265 } 266}(window), function (e) { 267 "object" == typeof module && "object" == typeof module.exports ? module.exports = e() : "function" == typeof define && define.amd ? define(e) : e(); 268}(function () { 269 return function (e, t, r, a) { 270 function n(e) { 271 for (var t = -1, r = e ? e.length : 0, a = []; ++t < r;) { 272 var n = e[t];n && a.push(n); 273 }return a; 274 }function o(e) { 275 return m.isWrapped(e) ? e = [].slice.call(e) : m.isNode(e) && (e = [e]), e; 276 }function i(e) { 277 var t = f.data(e, "velocity");return null === t ? a : t; 278 }function s(e) { 279 return function (t) { 280 return Math.round(t * e) * (1 / e); 281 }; 282 }function l(e, r, a, n) { 283 function o(e, t) { 284 return 1 - 3 * t + 3 * e; 285 }function i(e, t) { 286 return 3 * t - 6 * e; 287 }function s(e) { 288 return 3 * e; 289 }function l(e, t, r) { 290 return ((o(t, r) * e + i(t, r)) * e + s(t)) * e; 291 }function u(e, t, r) { 292 return 3 * o(t, r) * e * e + 2 * i(t, r) * e + s(t); 293 }function c(t, r) { 294 for (var n = 0; m > n; ++n) { 295 var o = u(r, e, a);if (0 === o) return r;var i = l(r, e, a) - t;r -= i / o; 296 }return r; 297 }function p() { 298 for (var t = 0; b > t; ++t) { 299 w[t] = l(t * x, e, a); 300 } 301 }function f(t, r, n) { 302 var o, 303 i, 304 s = 0;do { 305 i = r + (n - r) / 2, o = l(i, e, a) - t, o > 0 ? n = i : r = i; 306 } while (Math.abs(o) >
vendor: 37,943 bytes, lines 306-751
306 h && ++s < v);return i; 307 }function d(t) { 308 for (var r = 0, n = 1, o = b - 1; n != o && w[n] <= t; ++n) { 309 r += x; 310 }--n;var i = (t - w[n]) / (w[n + 1] - w[n]), 311 s = r + i * x, 312 l = u(s, e, a);return l >= y ? c(t, s) : 0 == l ? s : f(t, r, r + x); 313 }function g() { 314 V = !0, (e != r || a != n) && p(); 315 }var m = 4, 316 y = .001, 317 h = 1e-7, 318 v = 10, 319 b = 11, 320 x = 1 / (b - 1), 321 S = "Float32Array" in t;if (4 !== arguments.length) return !1;for (var P = 0; 4 > P; ++P) { 322 if ("number" != typeof arguments[P] || isNaN(arguments[P]) || !isFinite(arguments[P])) return !1; 323 }e = Math.min(e, 1), a = Math.min(a, 1), e = Math.max(e, 0), a = Math.max(a, 0);var w = S ? new Float32Array(b) : new Array(b), 324 V = !1, 325 C = function (t) { 326 return V || g(), e === r && a === n ? t : 0 === t ? 0 : 1 === t ? 1 : l(d(t), r, n); 327 };C.getControlPoints = function () { 328 return [{ x: e, y: r }, { x: a, y: n }]; 329 };var T = "generateBezier(" + [e, r, a, n] + ")";return C.toString = function () { 330 return T; 331 }, C; 332 }function u(e, t) { 333 var r = e;return m.isString(e) ? b.Easings[e] || (r = !1) : r = m.isArray(e) && 1 === e.length ? s.apply(null, e) : m.isArray(e) && 2 === e.length ? x.apply(null, e.concat([t])) : m.isArray(e) && 4 === e.length ? l.apply(null, e) : !1, r === !1 && (r = b.Easings[b.defaults.easing] ? b.defaults.easing : v), r; 334 }function c(e) { 335 if (e) { 336 var t = new Date().getTime(), 337 r = b.State.calls.length;r > 1e4 && (b.State.calls = n(b.State.calls));for (var o = 0; r > o; o++) { 338 if (b.State.calls[o]) { 339 var s = b.State.calls[o], 340 l = s[0], 341 u = s[2], 342 d = s[3], 343 g = !!d, 344 y = null;d || (d = b.State.calls[o][3] = t - 16);for (var h = Math.min((t - d) / u.duration, 1), v = 0, x = l.length; x > v; v++) { 345 var P = l[v], 346 V = P.element;if (i(V)) { 347 var C = !1;if (u.display !== a && null !== u.display && "none" !== u.display) { 348 if ("flex" === u.display) { 349 var T = ["-webkit-box", "-moz-box", "-ms-flexbox", "-webkit-flex"];f.each(T, function (e, t) { 350 S.setPropertyValue(V, "display", t); 351 }); 352 }S.setPropertyValue(V, "display", u.display); 353 }u.visibility !== a && "hidden" !== u.visibility && S.setPropertyValue(V, "visibility", u.visibility);for (var k in P) { 354 if ("element" !== k) { 355 var A, 356 F = P[k], 357 j = m.isString(F.easing) ? b.Easings[F.easing] : F.easing;if (1 === h) A = F.endValue;else { 358 var E = F.endValue - F.startValue;if (A = F.startValue + E * j(h, u, E), !g && A === F.currentValue) continue; 359 }if (F.currentValue = A, "tween" === k) y = A;else { 360 if (S.Hooks.registered[k]) { 361 var H = S.Hooks.getRoot(k), 362 N = i(V).rootPropertyValueCache[H];N && (F.rootPropertyValue = N); 363 }var L = S.setPropertyValue(V, k, F.currentValue + (0 === parseFloat(A) ? "" : F.unitType), F.rootPropertyValue, F.scrollData);S.Hooks.registered[k] && (i(V).rootPropertyValueCache[H] = S.Normalizations.registered[H] ? S.Normalizations.registered[H]("extract", null, L[1]) : L[1]), "transform" === L[0] && (C = !0); 364 } 365 } 366 }u.mobileHA && i(V).transformCache.translate3d === a && (i(V).transformCache.translate3d = "(0px, 0px, 0px)", C = !0), C && S.flushTransformCache(V); 367 } 368 }u.display !== a && "none" !== u.display && (b.State.calls[o][2].display = !1), u.visibility !== a && "hidden" !== u.visibility && (b.State.calls[o][2].visibility = !1), u.progress && u.progress.call(s[1], s[1], h, Math.max(0, d + u.duration - t), d, y), 1 === h && p(o); 369 } 370 } 371 }b.State.isTicking && w(c); 372 }function p(e, t) { 373 if (!b.State.calls[e]) return !1;for (var r = b.State.calls[e][0], n = b.State.calls[e][1], o = b.State.calls[e][2], s = b.State.calls[e][4], l = !1, u = 0, c = r.length; c > u; u++) { 374 var p = r[u].element;if (t || o.loop || ("none" === o.display && S.setPropertyValue(p, "display", o.display), "hidden" === o.visibility && S.setPropertyValue(p, "visibility", o.visibility)), o.loop !== !0 && (f.queue(p)[1] === a || !/\.velocityQueueEntryFlag/i.test(f.queue(p)[1])) && i(p)) { 375 i(p).isAnimating = !1, i(p).rootPropertyValueCache = {};var d = !1;f.each(S.Lists.transforms3D, function (e, t) { 376 var r = /^scale/.test(t) ? 1 : 0, 377 n = i(p).transformCache[t];i(p).transformCache[t] !== a && new RegExp("^\\(" + r + "[^.]").test(n) && (d = !0, delete i(p).transformCache[t]); 378 }), o.mobileHA && (d = !0, delete i(p).transformCache.translate3d), d && S.flushTransformCache(p), S.Values.removeClass(p, "velocity-animating"); 379 }if (!t && o.complete && !o.loop && u === c - 1) try { 380 o.complete.call(n, n); 381 } catch (g) { 382 setTimeout(function () { 383 throw g; 384 }, 1); 385 }s && o.loop !== !0 && s(n), i(p) && o.loop === !0 && !t && (f.each(i(p).tweensContainer, function (e, t) { 386 /^rotate/.test(e) && 360 === parseFloat(t.endValue) && (t.endValue = 0, t.startValue = 360), /^backgroundPosition/.test(e) && 100 === parseFloat(t.endValue) && "%" === t.unitType && (t.endValue = 0, t.startValue = 100); 387 }), b(p, "reverse", { loop: !0, delay: o.delay })), o.queue !== !1 && f.dequeue(p, o.queue); 388 }b.State.calls[e] = !1;for (var m = 0, y = b.State.calls.length; y > m; m++) { 389 if (b.State.calls[m] !== !1) { 390 l = !0;break; 391 } 392 }l === !1 && (b.State.isTicking = !1, delete b.State.calls, b.State.calls = []); 393 }var f, 394 d = function () { 395 if (r.documentMode) return r.documentMode;for (var e = 7; e > 4; e--) { 396 var t = r.createElement("div");if (t.innerHTML = "<!--[if IE " + e + "]><span></span><![endif]-->", t.getElementsByTagName("span").length) return t = null, e; 397 }return a; 398 }(), 399 g = function () { 400 var e = 0;return t.webkitRequestAnimationFrame || t.mozRequestAnimationFrame || function (t) { 401 var r, 402 a = new Date().getTime();return r = Math.max(0, 16 - (a - e)), e = a + r, setTimeout(function () { 403 t(a + r); 404 }, r); 405 }; 406 }(), 407 m = { isString: function (e) { 408 return "string" == typeof e; 409 }, isArray: Array.isArray || function (e) { 410 return "[object Array]" === Object.prototype.toString.call(e); 411 }, isFunction: function (e) { 412 return "[object Function]" === Object.prototype.toString.call(e); 413 }, isNode: function (e) { 414 return e && e.nodeType; 415 }, isNodeList: function (e) { 416 return "object" == typeof e && /^\[object (HTMLCollection|NodeList|Object)\]$/.test(Object.prototype.toString.call(e)) && e.length !== a && (0 === e.length || "object" == typeof e[0] && e[0].nodeType > 0); 417 }, isWrapped: function (e) { 418 return e && (e.jquery || t.Zepto && t.Zepto.zepto.isZ(e)); 419 }, isSVG: function (e) { 420 return t.SVGElement && e instanceof t.SVGElement; 421 }, isEmptyObject: function (e) { 422 for (var t in e) { 423 return !1; 424 }return !0; 425 } }, 426 y = !1;if (e.fn && e.fn.jquery ? (f = e, y = !0) : f = t.Velocity.Utilities, 8 >= d && !y) throw new Error("Velocity: IE8 and below require jQuery to be loaded before Velocity.");if (7 >= d) return void (jQuery.fn.velocity = jQuery.fn.animate);var h = 400, 427 v = "swing", 428 b = { State: { isMobile: /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent), isAndroid: /Android/i.test(navigator.userAgent), isGingerbread: /Android 2\.3\.[3-7]/i.test(navigator.userAgent), isChrome: t.chrome, isFirefox: /Firefox/i.test(navigator.userAgent), prefixElement: r.createElement("div"), prefixMatches: {}, scrollAnchor: null, scrollPropertyLeft: null, scrollPropertyTop: null, isTicking: !1, calls: [] }, CSS: {}, Utilities: f, Redirects: {}, Easings: {}, Promise: t.Promise, defaults: { queue: "", duration: h, easing: v, begin: a, complete: a, progress: a, display: a, visibility: a, loop: !1, delay: !1, mobileHA: !0, _cacheValues: !0 }, init: function (e) { 429 f.data(e, "velocity", { isSVG: m.isSVG(e), isAnimating: !1, computedStyle: null, tweensContainer: null, rootPropertyValueCache: {}, transformCache: {} }); 430 }, hook: null, mock: !1, version: { major: 1, minor: 2, patch: 2 }, debug: !1 };t.pageYOffset !== a ? (b.State.scrollAnchor = t, b.State.scrollPropertyLeft = "pageXOffset", b.State.scrollPropertyTop = "pageYOffset") : (b.State.scrollAnchor = r.documentElement || r.body.parentNode || r.body, b.State.scrollPropertyLeft = "scrollLeft", b.State.scrollPropertyTop = "scrollTop");var x = function () { 431 function e(e) { 432 return -e.tension * e.x - e.friction * e.v; 433 }function t(t, r, a) { 434 var n = { x: t.x + a.dx * r, v: t.v + a.dv * r, tension: t.tension, friction: t.friction };return { dx: n.v, dv: e(n) }; 435 }function r(r, a) { 436 var n = { dx: r.v, dv: e(r) }, 437 o = t(r, .5 * a, n), 438 i = t(r, .5 * a, o), 439 s = t(r, a, i), 440 l = 1 / 6 * (n.dx + 2 * (o.dx + i.dx) + s.dx), 441 u = 1 / 6 * (n.dv + 2 * (o.dv + i.dv) + s.dv);return r.x = r.x + l * a, r.v = r.v + u * a, r; 442 }return function a(e, t, n) { 443 var o, 444 i, 445 s, 446 l = { x: -1, v: 0, tension: null, friction: null }, 447 u = [0], 448 c = 0, 449 p = 1e-4, 450 f = .016;for (e = parseFloat(e) || 500, t = parseFloat(t) || 20, n = n || null, l.tension = e, l.friction = t, o = null !== n, o ? (c = a(e, t), i = c / n * f) : i = f; s = r(s || l, i), u.push(1 + s.x), c += 16, Math.abs(s.x) > p && Math.abs(s.v) > p;) {}return o ? function (e) { 451 return u[e * (u.length - 1) | 0]; 452 } : c; 453 }; 454 }();b.Easings = { linear: function (e) { 455 return e; 456 }, swing: function (e) { 457 return .5 - Math.cos(e * Math.PI) / 2; 458 }, spring: function (e) { 459 return 1 - Math.cos(4.5 * e * Math.PI) * Math.exp(6 * -e); 460 } }, f.each([["ease", [.25, .1, .25, 1]], ["ease-in", [.42, 0, 1, 1]], ["ease-out", [0, 0, .58, 1]], ["ease-in-out", [.42, 0, .58, 1]], ["easeInSine", [.47, 0, .745, .715]], ["easeOutSine", [.39, .575, .565, 1]], ["easeInOutSine", [.445, .05, .55, .95]], ["easeInQuad", [.55, .085, .68, .53]], ["easeOutQuad", [.25, .46, .45, .94]], ["easeInOutQuad", [.455, .03, .515, .955]], ["easeInCubic", [.55, .055, .675, .19]], ["easeOutCubic", [.215, .61, .355, 1]], ["easeInOutCubic", [.645, .045, .355, 1]], ["easeInQuart", [.895, .03, .685, .22]], ["easeOutQuart", [.165, .84, .44, 1]], ["easeInOutQuart", [.77, 0, .175, 1]], ["easeInQuint", [.755, .05, .855, .06]], ["easeOutQuint", [.23, 1, .32, 1]], ["easeInOutQuint", [.86, 0, .07, 1]], ["easeInExpo", [.95, .05, .795, .035]], ["easeOutExpo", [.19, 1, .22, 1]], ["easeInOutExpo", [1, 0, 0, 1]], ["easeInCirc", [.6, .04, .98, .335]], ["easeOutCirc", [.075, .82, .165, 1]], ["easeInOutCirc", [.785, .135, .15, .86]]], function (e, t) { 461 b.Easings[t[0]] = l.apply(null, t[1]); 462 });var S = b.CSS = { RegEx: { isHex: /^#([A-f\d]{3}){1,2}$/i, valueUnwrap: /^[A-z]+\((.*)\)$/i, wrappedValueAlreadyExtracted: /[0-9.]+ [0-9.]+ [0-9.]+( [0-9.]+)?/, valueSplit: /([A-z]+\(.+\))|(([A-z0-9#-.]+?)(?=\s|$))/gi }, Lists: { colors: ["fill", "stroke", "stopColor", "color", "backgroundColor", "borderColor", "borderTopColor", "borderRightColor", "borderBottomColor", "borderLeftColor", "outlineColor"], transformsBase: ["translateX", "translateY", "scale", "scaleX", "scaleY", "skewX", "skewY", "rotateZ"], transforms3D: ["transformPerspective", "translateZ", "scaleZ", "rotateX", "rotateY"] }, Hooks: { templates: { textShadow: ["Color X Y Blur", "black 0px 0px 0px"], boxShadow: ["Color X Y Blur Spread", "black 0px 0px 0px 0px"], clip: ["Top Right Bottom Left", "0px 0px 0px 0px"], backgroundPosition: ["X Y", "0% 0%"], transformOrigin: ["X Y Z", "50% 50% 0px"], perspectiveOrigin: ["X Y", "50% 50%"] }, registered: {}, register: function () { 463 for (var e = 0; e < S.Lists.colors.length; e++) { 464 var t = "color" === S.Lists.colors[e] ? "0 0 0 1" : "255 255 255 1";S.Hooks.templates[S.Lists.colors[e]] = ["Red Green Blue Alpha", t]; 465 }var r, a, n;if (d) for (r in S.Hooks.templates) { 466 a = S.Hooks.templates[r], n = a[0].split(" ");var o = a[1].match(S.RegEx.valueSplit);"Color" === n[0] && (n.push(n.shift()), o.push(o.shift()), S.Hooks.templates[r] = [n.join(" "), o.join(" ")]); 467 }for (r in S.Hooks.templates) { 468 a = S.Hooks.templates[r], n = a[0].split(" ");for (var e in n) { 469 var i = r + n[e], 470 s = e;S.Hooks.registered[i] = [r, s]; 471 } 472 } 473 }, getRoot: function (e) { 474 var t = S.Hooks.registered[e];return t ? t[0] : e; 475 }, cleanRootPropertyValue: function (e, t) { 476 return S.RegEx.valueUnwrap.test(t) && (t = t.match(S.RegEx.valueUnwrap)[1]), S.Values.isCSSNullValue(t) && (t = S.Hooks.templates[e][1]), t; 477 }, extractValue: function (e, t) { 478 var r = S.Hooks.registered[e];if (r) { 479 var a = r[0], 480 n = r[1];return t = S.Hooks.cleanRootPropertyValue(a, t), t.toString().match(S.RegEx.valueSplit)[n]; 481 }return t; 482 }, injectValue: function (e, t, r) { 483 var a = S.Hooks.registered[e];if (a) { 484 var n, 485 o, 486 i = a[0], 487 s = a[1];return r = S.Hooks.cleanRootPropertyValue(i, r), n = r.toString().match(S.RegEx.valueSplit), n[s] = t, o = n.join(" "); 488 }return r; 489 } }, Normalizations: { registered: { clip: function (e, t, r) { 490 switch (e) {case "name": 491 return "clip";case "extract": 492 var a;return S.RegEx.wrappedValueAlreadyExtracted.test(r) ? a = r : (a = r.toString().match(S.RegEx.valueUnwrap), a = a ? a[1].replace(/,(\s+)?/g, " ") : r), a;case "inject": 493 return "rect(" + r + ")";} 494 }, blur: function (e, t, r) { 495 switch (e) {case "name": 496 return b.State.isFirefox ? "filter" : "-webkit-filter";case "extract": 497 var a = parseFloat(r);if (!a && 0 !== a) { 498 var n = r.toString().match(/blur\(([0-9]+[A-z]+)\)/i);a = n ? n[1] : 0; 499 }return a;case "inject": 500 return parseFloat(r) ? "blur(" + r + ")" : "none";} 501 }, opacity: function (e, t, r) { 502 if (8 >= d) switch (e) {case "name": 503 return "filter";case "extract": 504 var a = r.toString().match(/alpha\(opacity=(.*)\)/i);return r = a ? a[1] / 100 : 1;case "inject": 505 return t.style.zoom = 1, parseFloat(r) >= 1 ? "" : "alpha(opacity=" + parseInt(100 * parseFloat(r), 10) + ")";} else switch (e) {case "name": 506 return "opacity";case "extract": 507 return r;case "inject": 508 return r;} 509 } }, register: function () { 510 9 >= d || b.State.isGingerbread || (S.Lists.transformsBase = S.Lists.transformsBase.concat(S.Lists.transforms3D));for (var e = 0; e < S.Lists.transformsBase.length; e++) { 511 !function () { 512 var t = S.Lists.transformsBase[e];S.Normalizations.registered[t] = function (e, r, n) { 513 switch (e) {case "name": 514 return "transform";case "extract": 515 return i(r) === a || i(r).transformCache[t] === a ? /^scale/i.test(t) ? 1 : 0 : i(r).transformCache[t].replace(/[()]/g, "");case "inject": 516 var o = !1;switch (t.substr(0, t.length - 1)) {case "translate": 517 o = !/(%|px|em|rem|vw|vh|\d)$/i.test(n);break;case "scal":case "scale": 518 b.State.isAndroid && i(r).transformCache[t] === a && 1 > n && (n = 1), o = !/(\d)$/i.test(n);break;case "skew": 519 o = !/(deg|\d)$/i.test(n);break;case "rotate": 520 o = !/(deg|\d)$/i.test(n);}return o || (i(r).transformCache[t] = "(" + n + ")"), i(r).transformCache[t];} 521 }; 522 }(); 523 }for (var e = 0; e < S.Lists.colors.length; e++) { 524 !function () { 525 var t = S.Lists.colors[e];S.Normalizations.registered[t] = function (e, r, n) { 526 switch (e) {case "name": 527 return t;case "extract": 528 var o;if (S.RegEx.wrappedValueAlreadyExtracted.test(n)) o = n;else { 529 var i, 530 s = { black: "rgb(0, 0, 0)", blue: "rgb(0, 0, 255)", gray: "rgb(128, 128, 128)", green: "rgb(0, 128, 0)", red: "rgb(255, 0, 0)", white: "rgb(255, 255, 255)" };/^[A-z]+$/i.test(n) ? i = s[n] !== a ? s[n] : s.black : S.RegEx.isHex.test(n) ? i = "rgb(" + S.Values.hexToRgb(n).join(" ") + ")" : /^rgba?\(/i.test(n) || (i = s.black), o = (i || n).toString().match(S.RegEx.valueUnwrap)[1].replace(/,(\s+)?/g, " "); 531 }return 8 >= d || 3 !== o.split(" ").length || (o += " 1"), o;case "inject": 532 return 8 >= d ? 4 === n.split(" ").length && (n = n.split(/\s+/).slice(0, 3).join(" ")) : 3 === n.split(" ").length && (n += " 1"), (8 >= d ? "rgb" : "rgba") + "(" + n.replace(/\s+/g, ",").replace(/\.(\d)+(?=,)/g, "") + ")";} 533 }; 534 }(); 535 } 536 } }, Names: { camelCase: function (e) { 537 return e.replace(/-(\w)/g, function (e, t) { 538 return t.toUpperCase(); 539 }); 540 }, SVGAttribute: function (e) { 541 var t = "width|height|x|y|cx|cy|r|rx|ry|x1|x2|y1|y2";return (d || b.State.isAndroid && !b.State.isChrome) && (t += "|transform"), new RegExp("^(" + t + ")$", "i").test(e); 542 }, prefixCheck: function (e) { 543 if (b.State.prefixMatches[e]) return [b.State.prefixMatches[e], !0];for (var t = ["", "Webkit", "Moz", "ms", "O"], r = 0, a = t.length; a > r; r++) { 544 var n;if (n = 0 === r ? e : t[r] + e.replace(/^\w/, function (e) { 545 return e.toUpperCase(); 546 }), m.isString(b.State.prefixElement.style[n])) return b.State.prefixMatches[e] = n, [n, !0]; 547 }return [e, !1]; 548 } }, Values: { hexToRgb: function (e) { 549 var t, 550 r = /^#?([a-f\d])([a-f\d])([a-f\d])$/i, 551 a = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i;return e = e.replace(r, function (e, t, r, a) { 552 return t + t + r + r + a + a; 553 }), t = a.exec(e), t ? [parseInt(t[1], 16), parseInt(t[2], 16), parseInt(t[3], 16)] : [0, 0, 0]; 554 }, isCSSNullValue: function (e) { 555 return 0 == e || /^(none|auto|transparent|(rgba\(0, ?0, ?0, ?0\)))$/i.test(e); 556 }, getUnitType: function (e) { 557 return (/^(rotate|skew)/i.test(e) ? "deg" : /(^(scale|scaleX|scaleY|scaleZ|alpha|flexGrow|flexHeight|zIndex|fontWeight)$)|((opacity|red|green|blue|alpha)$)/i.test(e) ? "" : "px" 558 ); 559 }, getDisplayType: function (e) { 560 var t = e && e.tagName.toString().toLowerCase();return (/^(b|big|i|small|tt|abbr|acronym|cite|code|dfn|em|kbd|strong|samp|var|a|bdo|br|img|map|object|q|script|span|sub|sup|button|input|label|select|textarea)$/i.test(t) ? "inline" : /^(li)$/i.test(t) ? "list-item" : /^(tr)$/i.test(t) ? "table-row" : /^(table)$/i.test(t) ? "table" : /^(tbody)$/i.test(t) ? "table-row-group" : "block" 561 ); 562 }, addClass: function (e, t) { 563 e.classList ? e.classList.add(t) : e.className += (e.className.length ? " " : "") + t; 564 }, removeClass: function (e, t) { 565 e.classList ? e.classList.remove(t) : e.className = e.className.toString().replace(new RegExp("(^|\\s)" + t.split(" ").join("|") + "(\\s|$)", "gi"), " "); 566 } }, getPropertyValue: function (e, r, n, o) { 567 function s(e, r) { 568 function n() { 569 u && S.setPropertyValue(e, "display", "none"); 570 }var l = 0;if (8 >= d) l = f.css(e, r);else { 571 var u = !1;if (/^(width|height)$/.test(r) && 0 === S.getPropertyValue(e, "display") && (u = !0, S.setPropertyValue(e, "display", S.Values.getDisplayType(e))), !o) { 572 if ("height" === r && "border-box" !== S.getPropertyValue(e, "boxSizing").toString().toLowerCase()) { 573 var c = e.offsetHeight - (parseFloat(S.getPropertyValue(e, "borderTopWidth")) || 0) - (parseFloat(S.getPropertyValue(e, "borderBottomWidth")) || 0) - (parseFloat(S.getPropertyValue(e, "paddingTop")) || 0) - (parseFloat(S.getPropertyValue(e, "paddingBottom")) || 0);return n(), c; 574 }if ("width" === r && "border-box" !== S.getPropertyValue(e, "boxSizing").toString().toLowerCase()) { 575 var p = e.offsetWidth - (parseFloat(S.getPropertyValue(e, "borderLeftWidth")) || 0) - (parseFloat(S.getPropertyValue(e, "borderRightWidth")) || 0) - (parseFloat(S.getPropertyValue(e, "paddingLeft")) || 0) - (parseFloat(S.getPropertyValue(e, "paddingRight")) || 0);return n(), p; 576 } 577 }var g;g = i(e) === a ? t.getComputedStyle(e, null) : i(e).computedStyle ? i(e).computedStyle : i(e).computedStyle = t.getComputedStyle(e, null), "borderColor" === r && (r = "borderTopColor"), l = 9 === d && "filter" === r ? g.getPropertyValue(r) : g[r], ("" === l || null === l) && (l = e.style[r]), n(); 578 }if ("auto" === l && /^(top|right|bottom|left)$/i.test(r)) { 579 var m = s(e, "position");("fixed" === m || "absolute" === m && /top|left/i.test(r)) && (l = f(e).position()[r] + "px"); 580 }return l; 581 }var l;if (S.Hooks.registered[r]) { 582 var u = r, 583 c = S.Hooks.getRoot(u);n === a && (n = S.getPropertyValue(e, S.Names.prefixCheck(c)[0])), S.Normalizations.registered[c] && (n = S.Normalizations.registered[c]("extract", e, n)), l = S.Hooks.extractValue(u, n); 584 } else if (S.Normalizations.registered[r]) { 585 var p, g;p = S.Normalizations.registered[r]("name", e), "transform" !== p && (g = s(e, S.Names.prefixCheck(p)[0]), S.Values.isCSSNullValue(g) && S.Hooks.templates[r] && (g = S.Hooks.templates[r][1])), l = S.Normalizations.registered[r]("extract", e, g); 586 }if (!/^[\d-]/.test(l)) if (i(e) && i(e).isSVG && S.Names.SVGAttribute(r)) { 587 if (/^(height|width)$/i.test(r)) try { 588 l = e.getBBox()[r]; 589 } catch (m) { 590 l = 0; 591 } else l = e.getAttribute(r); 592 } else l = s(e, S.Names.prefixCheck(r)[0]);return S.Values.isCSSNullValue(l) && (l = 0), b.debug >= 2 && console.log("Get " + r + ": " + l), l; 593 }, setPropertyValue: function (e, r, a, n, o) { 594 var s = r;if ("scroll" === r) o.container ? o.container["scroll" + o.direction] = a : "Left" === o.direction ? t.scrollTo(a, o.alternateValue) : t.scrollTo(o.alternateValue, a);else if (S.Normalizations.registered[r] && "transform" === S.Normalizations.registered[r]("name", e)) S.Normalizations.registered[r]("inject", e, a), s = "transform", a = i(e).transformCache[r];else { 595 if (S.Hooks.registered[r]) { 596 var l = r, 597 u = S.Hooks.getRoot(r);n = n || S.getPropertyValue(e, u), a = S.Hooks.injectValue(l, a, n), r = u; 598 }if (S.Normalizations.registered[r] && (a = S.Normalizations.registered[r]("inject", e, a), r = S.Normalizations.registered[r]("name", e)), s = S.Names.prefixCheck(r)[0], 8 >= d) try { 599 e.style[s] = a; 600 } catch (c) { 601 b.debug && console.log("Browser does not support [" + a + "] for [" + s + "]"); 602 } else i(e) && i(e).isSVG && S.Names.SVGAttribute(r) ? e.setAttribute(r, a) : e.style[s] = a;b.debug >= 2 && console.log("Set " + r + " (" + s + "): " + a); 603 }return [s, a]; 604 }, flushTransformCache: function (e) { 605 function t(t) { 606 return parseFloat(S.getPropertyValue(e, t)); 607 }var r = "";if ((d || b.State.isAndroid && !b.State.isChrome) && i(e).isSVG) { 608 var a = { translate: [t("translateX"), t("translateY")], skewX: [t("skewX")], skewY: [t("skewY")], scale: 1 !== t("scale") ? [t("scale"), t("scale")] : [t("scaleX"), t("scaleY")], rotate: [t("rotateZ"), 0, 0] };f.each(i(e).transformCache, function (e) { 609 /^translate/i.test(e) ? e = "translate" : /^scale/i.test(e) ? e = "scale" : /^rotate/i.test(e) && (e = "rotate"), a[e] && (r += e + "(" + a[e].join(" ") + ") ", delete a[e]); 610 }); 611 } else { 612 var n, o;f.each(i(e).transformCache, function (t) { 613 return n = i(e).transformCache[t], "transformPerspective" === t ? (o = n, !0) : (9 === d && "rotateZ" === t && (t = "rotate"), void (r += t + n + " ")); 614 }), o && (r = "perspective" + o + " " + r); 615 }S.setPropertyValue(e, "transform", r); 616 } };S.Hooks.register(), S.Normalizations.register(), b.hook = function (e, t, r) { 617 var n = a;return e = o(e), f.each(e, function (e, o) { 618 if (i(o) === a && b.init(o), r === a) n === a && (n = b.CSS.getPropertyValue(o, t));else { 619 var s = b.CSS.setPropertyValue(o, t, r);"transform" === s[0] && b.CSS.flushTransformCache(o), n = s; 620 } 621 }), n; 622 };var P = function () { 623 function e() { 624 return s ? k.promise || null : l; 625 }function n() { 626 function e(e) { 627 function p(e, t) { 628 var r = a, 629 n = a, 630 i = a;return m.isArray(e) ? (r = e[0], !m.isArray(e[1]) && /^[\d-]/.test(e[1]) || m.isFunction(e[1]) || S.RegEx.isHex.test(e[1]) ? i = e[1] : (m.isString(e[1]) && !S.RegEx.isHex.test(e[1]) || m.isArray(e[1])) && (n = t ? e[1] : u(e[1], s.duration), e[2] !== a && (i = e[2]))) : r = e, t || (n = n || s.easing), m.isFunction(r) && (r = r.call(o, V, w)), m.isFunction(i) && (i = i.call(o, V, w)), [r || 0, n, i]; 631 }function d(e, t) { 632 var r, a;return a = (t || "0").toString().toLowerCase().replace(/[%A-z]+$/, function (e) { 633 return r = e, ""; 634 }), r || (r = S.Values.getUnitType(e)), [a, r]; 635 }function h() { 636 var e = { myParent: o.parentNode || r.body, position: S.getPropertyValue(o, "position"), fontSize: S.getPropertyValue(o, "fontSize") }, 637 a = e.position === L.lastPosition && e.myParent === L.lastParent, 638 n = e.fontSize === L.lastFontSize;L.lastParent = e.myParent, L.lastPosition = e.position, L.lastFontSize = e.fontSize;var s = 100, 639 l = {};if (n && a) l.emToPx = L.lastEmToPx, l.percentToPxWidth = L.lastPercentToPxWidth, l.percentToPxHeight = L.lastPercentToPxHeight;else { 640 var u = i(o).isSVG ? r.createElementNS("http://www.w3.org/2000/svg", "rect") : r.createElement("div");b.init(u), e.myParent.appendChild(u), f.each(["overflow", "overflowX", "overflowY"], function (e, t) { 641 b.CSS.setPropertyValue(u, t, "hidden"); 642 }), b.CSS.setPropertyValue(u, "position", e.position), b.CSS.setPropertyValue(u, "fontSize", e.fontSize), b.CSS.setPropertyValue(u, "boxSizing", "content-box"), f.each(["minWidth", "maxWidth", "width", "minHeight", "maxHeight", "height"], function (e, t) { 643 b.CSS.setPropertyValue(u, t, s + "%"); 644 }), b.CSS.setPropertyValue(u, "paddingLeft", s + "em"), l.percentToPxWidth = L.lastPercentToPxWidth = (parseFloat(S.getPropertyValue(u, "width", null, !0)) || 1) / s, l.percentToPxHeight = L.lastPercentToPxHeight = (parseFloat(S.getPropertyValue(u, "height", null, !0)) || 1) / s, l.emToPx = L.lastEmToPx = (parseFloat(S.getPropertyValue(u, "paddingLeft")) || 1) / s, e.myParent.removeChild(u); 645 }return null === L.remToPx && (L.remToPx = parseFloat(S.getPropertyValue(r.body, "fontSize")) || 16), null === L.vwToPx && (L.vwToPx = parseFloat(t.innerWidth) / 100, L.vhToPx = parseFloat(t.innerHeight) / 100), l.remToPx = L.remToPx, l.vwToPx = L.vwToPx, l.vhToPx = L.vhToPx, b.debug >= 1 && console.log("Unit ratios: " + JSON.stringify(l), o), l; 646 }if (s.begin && 0 === V) try { 647 s.begin.call(g, g); 648 } catch (x) { 649 setTimeout(function () { 650 throw x; 651 }, 1); 652 }if ("scroll" === A) { 653 var P, 654 C, 655 T, 656 F = /^x$/i.test(s.axis) ? "Left" : "Top", 657 j = parseFloat(s.offset) || 0;s.container ? m.isWrapped(s.container) || m.isNode(s.container) ? (s.container = s.container[0] || s.container, P = s.container["scroll" + F], T = P + f(o).position()[F.toLowerCase()] + j) : s.container = null : (P = b.State.scrollAnchor[b.State["scrollProperty" + F]], C = b.State.scrollAnchor[b.State["scrollProperty" + ("Left" === F ? "Top" : "Left")]], T = f(o).offset()[F.toLowerCase()] + j), l = { scroll: { rootPropertyValue: !1, startValue: P, currentValue: P, endValue: T, unitType: "", easing: s.easing, scrollData: { container: s.container, direction: F, alternateValue: C } }, element: o }, b.debug && console.log("tweensContainer (scroll): ", l.scroll, o); 658 } else if ("reverse" === A) { 659 if (!i(o).tweensContainer) return void f.dequeue(o, s.queue);"none" === i(o).opts.display && (i(o).opts.display = "auto"), "hidden" === i(o).opts.visibility && (i(o).opts.visibility = "visible"), i(o).opts.loop = !1, i(o).opts.begin = null, i(o).opts.complete = null, v.easing || delete s.easing, v.duration || delete s.duration, s = f.extend({}, i(o).opts, s);var E = f.extend(!0, {}, i(o).tweensContainer);for (var H in E) { 660 if ("element" !== H) { 661 var N = E[H].startValue;E[H].startValue = E[H].currentValue = E[H].endValue, E[H].endValue = N, m.isEmptyObject(v) || (E[H].easing = s.easing), b.debug && console.log("reverse tweensContainer (" + H + "): " + JSON.stringify(E[H]), o); 662 } 663 }l = E; 664 } else if ("start" === A) { 665 var E;i(o).tweensContainer && i(o).isAnimating === !0 && (E = i(o).tweensContainer), f.each(y, function (e, t) { 666 if (RegExp("^" + S.Lists.colors.join("$|^") + "$").test(e)) { 667 var r = p(t, !0), 668 n = r[0], 669 o = r[1], 670 i = r[2];if (S.RegEx.isHex.test(n)) { 671 for (var s = ["Red", "Green", "Blue"], l = S.Values.hexToRgb(n), u = i ? S.Values.hexToRgb(i) : a, c = 0; c < s.length; c++) { 672 var f = [l[c]];o && f.push(o), u !== a && f.push(u[c]), y[e + s[c]] = f; 673 }delete y[e]; 674 } 675 } 676 });for (var z in y) { 677 var O = p(y[z]), 678 q = O[0], 679 $ = O[1], 680 M = O[2];z = S.Names.camelCase(z);var I = S.Hooks.getRoot(z), 681 B = !1;if (i(o).isSVG || "tween" === I || S.Names.prefixCheck(I)[1] !== !1 || S.Normalizations.registered[I] !== a) { 682 (s.display !== a && null !== s.display && "none" !== s.display || s.visibility !== a && "hidden" !== s.visibility) && /opacity|filter/.test(z) && !M && 0 !== q && (M = 0), s._cacheValues && E && E[z] ? (M === a && (M = E[z].endValue + E[z].unitType), B = i(o).rootPropertyValueCache[I]) : S.Hooks.registered[z] ? M === a ? (B = S.getPropertyValue(o, I), M = S.getPropertyValue(o, z, B)) : B = S.Hooks.templates[I][1] : M === a && (M = S.getPropertyValue(o, z));var W, 683 G, 684 Y, 685 D = !1;if (W = d(z, M), M = W[0], Y = W[1], W = d(z, q), q = W[0].replace(/^([+-\/*])=/, function (e, t) { 686 return D = t, ""; 687 }), G = W[1], M = parseFloat(M) || 0, q = parseFloat(q) || 0, "%" === G && (/^(fontSize|lineHeight)$/.test(z) ? (q /= 100, G = "em") : /^scale/.test(z) ? (q /= 100, G = "") : /(Red|Green|Blue)$/i.test(z) && (q = q / 100 * 255, G = "")), /[\/*]/.test(D)) G = Y;else if (Y !== G && 0 !== M) if (0 === q) G = Y;else { 688 n = n || h();var Q = /margin|padding|left|right|width|text|word|letter/i.test(z) || /X$/.test(z) || "x" === z ? "x" : "y";switch (Y) {case "%": 689 M *= "x" === Q ? n.percentToPxWidth : n.percentToPxHeight;break;case "px": 690 break;default: 691 M *= n[Y + "ToPx"];}switch (G) {case "%": 692 M *= 1 / ("x" === Q ? n.percentToPxWidth : n.percentToPxHeight);break;case "px": 693 break;default: 694 M *= 1 / n[G + "ToPx"];} 695 }switch (D) {case "+": 696 q = M + q;break;case "-": 697 q = M - q;break;case "*": 698 q = M * q;break;case "/": 699 q = M / q;}l[z] = { rootPropertyValue: B, startValue: M, currentValue: M, endValue: q, unitType: G, easing: $ }, b.debug && console.log("tweensContainer (" + z + "): " + JSON.stringify(l[z]), o); 700 } else b.debug && console.log("Skipping [" + I + "] due to a lack of browser support."); 701 }l.element = o; 702 }l.element && (S.Values.addClass(o, "velocity-animating"), R.push(l), "" === s.queue && (i(o).tweensContainer = l, i(o).opts = s), i(o).isAnimating = !0, V === w - 1 ? (b.State.calls.push([R, g, s, null, k.resolver]), b.State.isTicking === !1 && (b.State.isTicking = !0, c())) : V++); 703 }var n, 704 o = this, 705 s = f.extend({}, b.defaults, v), 706 l = {};switch (i(o) === a && b.init(o), parseFloat(s.delay) && s.queue !== !1 && f.queue(o, s.queue, function (e) { 707 b.velocityQueueEntryFlag = !0, i(o).delayTimer = { setTimeout: setTimeout(e, parseFloat(s.delay)), next: e }; 708 }), s.duration.toString().toLowerCase()) {case "fast": 709 s.duration = 200;break;case "normal": 710 s.duration = h;break;case "slow": 711 s.duration = 600;break;default: 712 s.duration = parseFloat(s.duration) || 1;}b.mock !== !1 && (b.mock === !0 ? s.duration = s.delay = 1 : (s.duration *= parseFloat(b.mock) || 1, s.delay *= parseFloat(b.mock) || 1)), s.easing = u(s.easing, s.duration), s.begin && !m.isFunction(s.begin) && (s.begin = null), s.progress && !m.isFunction(s.progress) && (s.progress = null), s.complete && !m.isFunction(s.complete) && (s.complete = null), s.display !== a && null !== s.display && (s.display = s.display.toString().toLowerCase(), "auto" === s.display && (s.display = b.CSS.Values.getDisplayType(o))), s.visibility !== a && null !== s.visibility && (s.visibility = s.visibility.toString().toLowerCase()), s.mobileHA = s.mobileHA && b.State.isMobile && !b.State.isGingerbread, s.queue === !1 ? s.delay ? setTimeout(e, s.delay) : e() : f.queue(o, s.queue, function (t, r) { 713 return r === !0 ? (k.promise && k.resolver(g), !0) : (b.velocityQueueEntryFlag = !0, void e(t)); 714 }), "" !== s.queue && "fx" !== s.queue || "inprogress" === f.queue(o)[0] || f.dequeue(o); 715 }var s, 716 l, 717 d, 718 g, 719 y, 720 v, 721 x = arguments[0] && (arguments[0].p || f.isPlainObject(arguments[0].properties) && !arguments[0].properties.names || m.isString(arguments[0].properties));if (m.isWrapped(this) ? (s = !1, d = 0, g = this, l = this) : (s = !0, d = 1, g = x ? arguments[0].elements || arguments[0].e : arguments[0]), g = o(g)) { 722 x ? (y = arguments[0].properties || arguments[0].p, v = arguments[0].options || arguments[0].o) : (y = arguments[d], v = arguments[d + 1]);var w = g.length, 723 V = 0;if (!/^(stop|finish)$/i.test(y) && !f.isPlainObject(v)) { 724 var C = d + 1;v = {};for (var T = C; T < arguments.length; T++) { 725 m.isArray(arguments[T]) || !/^(fast|normal|slow)$/i.test(arguments[T]) && !/^\d/.test(arguments[T]) ? m.isString(arguments[T]) || m.isArray(arguments[T]) ? v.easing = arguments[T] : m.isFunction(arguments[T]) && (v.complete = arguments[T]) : v.duration = arguments[T]; 726 } 727 }var k = { promise: null, resolver: null, rejecter: null };s && b.Promise && (k.promise = new b.Promise(function (e, t) { 728 k.resolver = e, k.rejecter = t; 729 }));var A;switch (y) {case "scroll": 730 A = "scroll";break;case "reverse": 731 A = "reverse";break;case "finish":case "stop": 732 f.each(g, function (e, t) { 733 i(t) && i(t).delayTimer && (clearTimeout(i(t).delayTimer.setTimeout), i(t).delayTimer.next && i(t).delayTimer.next(), delete i(t).delayTimer); 734 });var F = [];return f.each(b.State.calls, function (e, t) { 735 t && f.each(t[1], function (r, n) { 736 var o = v === a ? "" : v;return o === !0 || t[2].queue === o || v === a && t[2].queue === !1 ? void f.each(g, function (r, a) { 737 a === n && ((v === !0 || m.isString(v)) && (f.each(f.queue(a, m.isString(v) ? v : ""), function (e, t) { 738 m.isFunction(t) && t(null, !0); 739 }), f.queue(a, m.isString(v) ? v : "", [])), "stop" === y ? (i(a) && i(a).tweensContainer && o !== !1 && f.each(i(a).tweensContainer, function (e, t) { 740 t.endValue = t.currentValue; 741 }), F.push(e)) : "finish" === y && (t[2].duration = 1)); 742 }) : !0; 743 }); 744 }), "stop" === y && (f.each(F, function (e, t) { 745 p(t, !0); 746 }), k.promise && k.resolver(g)), e();default: 747 if (!f.isPlainObject(y) || m.isEmptyObject(y)) { 748 if (m.isString(y) && b.Redirects[y]) { 749 var j = f.extend({}, v), 750 E = j.duration, 751 H = j.delay || 0;return j.backwards === !0 && (g = f.extend(!0, [], g).reverse()), f.each(g, function (e, t) {
752 parseFloat(j.stagger) ? j.delay = H + parseFloat(j.stagger) * e : m.isFunction(j.stagger) && (j.delay = H + j.stagger.call(t, e, w)), j.drag && (j.duration = parseFloat(E) || (/^(callout|transition)/.test(y) ? 1e3 : h), j.duration = Math.max(j.duration * (j.backwards ? 1 - e / w : (e + 1) / w), .75 * j.duration, 200)), b.Redirects[y].call(t, t, j || {}, e, w, g, k.promise ? k : a); 753 }), e(); 754 }var N = "Velocity: First argument (" + y + ") was not a property map, a known action, or a registered redirect. Aborting.";return k.promise ? k.rejecter(new Error(N)) : console.log(N), e(); 755 }A = "start";}var L = { lastParent: null, lastPosition: null, lastFontSize: null, lastPercentToPxWidth: null, lastPercentToPxHeight: null, lastEmToPx: null, remToPx: null, vwToPx: null, vhToPx: null }, 756 R = [];f.each(g, function (e, t) { 757 m.isNode(t) && n.call(t); 758 });var z, 759 j = f.extend({}, b.defaults, v);if (j.loop = parseInt(j.loop), z = 2 * j.loop - 1, j.loop) for (var O = 0; z > O; O++) { 760 var q = { delay: j.delay, progress: j.progress };O === z - 1 && (q.display = j.display, q.visibility = j.visibility, q.complete = j.complete), P(g, "reverse", q); 761 }return e(); 762 } 763 };b = f.extend(P, b), b.animate = P;var w = t.requestAnimationFrame || g;return b.State.isMobile || r.hidden === a || r.addEventListener("visibilitychange", function () { 764 r.hidden ? (w = function (e) { 765 return setTimeout(function () { 766 e(!0); 767 }, 16); 768 }, c()) : w = t.requestAnimationFrame || g; 769 }), e.Velocity = b, e !== t && (e.fn.velocity = P, e.fn.velocity.defaults = b.defaults), f.each(["Down", "Up"], function (e, t) { 770 b.Redirects["slide" + t] = function (e, r, n, o, i, s) { 771 var l = f.extend({}, r), 772 u = l.begin, 773 c = l.complete, 774 p = { height: "", marginTop: "", marginBottom: "", paddingTop: "", paddingBottom: "" }, 775 d = {};l.display === a && (l.display = "Down" === t ? "inline" === b.CSS.Values.getDisplayType(e) ? "inline-block" : "block" : "none"), l.begin = function () { 776 u && u.call(i, i);for (var r in p) { 777 d[r] = e.style[r];var a = b.CSS.getPropertyValue(e, r);p[r] = "Down" === t ? [a, 0] : [0, a]; 778 }d.overflow = e.style.overflow, e.style.overflow = "hidden"; 779 }, l.complete = function () { 780 for (var t in d) { 781 e.style[t] = d[t]; 782 }c && c.call(i, i), s && s.resolver(i); 783 }, b(e, p, l); 784 }; 785 }), f.each(["In", "Out"], function (e, t) { 786 b.Redirects["fade" + t] = function (e, r, n, o, i, s) { 787 var l = f.extend({}, r), 788 u = { opacity: "In" === t ? 1 : 0 }, 789 c = l.complete;l.complete = n !== o - 1 ? l.begin = null : function () { 790 c && c.call(i, i), s && s.resolver(i); 791 }, l.display === a && (l.display = "In" === t ? "auto" : "none"), b(this, u, l); 792 }; 793 }), b; 794 }(window.jQuery || window.Zepto || window, window, document); 795})); 796;!function (a, b, c, d) { 797 "use strict"; 798 function k(a, b, c) { 799 return setTimeout(q(a, c), b); 800 }function l(a, b, c) { 801 return Array.isArray(a) ? (m(a, c[b], c), !0) : !1; 802 }function m(a, b, c) { 803 var e;if (a) if (a.forEach) a.forEach(b, c);else if (a.length !== d) for (e = 0; e < a.length;) { 804 b.call(c, a[e], e, a), e++; 805 } else for (e in a) { 806 a.hasOwnProperty(e) && b.call(c, a[e], e, a); 807 } 808 }function n(a, b, c) { 809 for (var e = Object.keys(b), f = 0; f < e.length;) { 810 (!c || c && a[e[f]] === d) && (a[e[f]] = b[e[f]]), f++; 811 }return a; 812 }function o(a, b) { 813 return n(a, b, !0); 814 }function p(a, b, c) { 815 var e, 816 d = b.prototype;e = a.prototype = Object.create(d), e.constructor = a, e._super = d, c && n(e, c); 817 }function q(a, b) { 818 return function () { 819 return a.apply(b, arguments); 820 }; 821 }function r(a, b) { 822 return typeof a == g ? a.apply(b ? b[0] || d : d, b) : a; 823 }function s(a, b) { 824 return a === d ? b : a; 825 }function t(a, b, c) { 826 m(x(b), function (b) { 827 a.addEventListener(b, c, !1); 828 }); 829 }function u(a, b, c) { 830 m(x(b), function (b) { 831 a.removeEventListener(b, c, !1); 832 }); 833 }function v(a, b) { 834 for (; a;) { 835 if (a == b) return !0;a = a.parentNode; 836 }return !1; 837 }function w(a, b) { 838 return a.indexOf(b) > -1; 839 }function x(a) { 840 return a.trim().split(/\s+/g); 841 }function y(a, b, c) { 842 if (a.indexOf && !c) return a.indexOf(b);for (var d = 0; d < a.length;) { 843 if (c && a[d][c] == b || !c && a[d] === b) return d;d++; 844 }return -1; 845 }function z(a) {
846 return Array.prototype.slice.call(a, 0); 847 }function A(a, b, c) { 848 for (var d = [], e = [], f = 0; f < a.length;) { 849 var g = b ? a[f][b] : a[f];y(e, g) < 0 && d.push(a[f]), e[f] = g, f++; 850 }return c && (d = b ? d.sort(function (a, c) { 851 return a[b] > c[b]; 852 }) : d.sort()), d; 853 }function B(a, b) { 854 for (var c, f, g = b[0].toUpperCase() + b.slice(1), h = 0; h < e.length;) { 855 if (c = e[h], f = c ? c + g : b, f in a) return f;h++; 856 }return d; 857 }function D() { 858 return C++; 859 }function E(a) { 860 var b = a.ownerDocument;return b.defaultView || b.parentWindow; 861 }function ab(a, b) { 862 var c = this;this.manager = a, this.callback = b, this.element = a.element, this.target = a.options.inputTarget, this.domHandler = function (b) { 863 r(a.options.enable, [a]) && c.handler(b); 864 }, this.init(); 865 }function bb(a) { 866 var b, 867 c = a.options.inputClass;return b = c ? c : H ? wb : I ? Eb : G ? Gb : rb, new b(a, cb); 868 }function cb(a, b, c) { 869 var d = c.pointers.length, 870 e = c.changedPointers.length, 871 f = b & O && 0 === d - e, 872 g = b & (Q | R) && 0 === d - e;c.isFirst = !!f, c.isFinal = !!g, f && (a.session = {}), c.eventType = b, db(a, c), a.emit("hammer.input", c), a.recognize(c), a.session.prevInput = c; 873 }function db(a, b) { 874 var c = a.session, 875 d = b.pointers, 876 e = d.length;c.firstInput || (c.firstInput = gb(b)), e > 1 && !c.firstMultiple ? c.firstMultiple = gb(b) : 1 === e && (c.firstMultiple = !1);var f = c.firstInput, 877 g = c.firstMultiple, 878 h = g ? g.center : f.center, 879 i = b.center = hb(d);b.timeStamp = j(), b.deltaTime = b.timeStamp - f.timeStamp, b.angle = lb(h, i), b.distance = kb(h, i), eb(c, b), b.offsetDirection = jb(b.deltaX, b.deltaY), b.scale = g ? nb(g.pointers, d) : 1, b.rotation = g ? mb(g.pointers, d) : 0, fb(c, b);var k = a.element;v(b.srcEvent.target, k) && (k = b.srcEvent.target), b.target = k; 880 }function eb(a, b) { 881 var c = b.center, 882 d = a.offsetDelta || {}, 883 e = a.prevDelta || {}, 884 f = a.prevInput || {};(b.eventType === O || f.eventType === Q) && (e = a.prevDelta = { x: f.deltaX || 0, y: f.deltaY || 0 }, d = a.offsetDelta = { x: c.x, y: c.y }), b.deltaX = e.x + (c.x - d.x), b.deltaY = e.y + (c.y - d.y); 885 }function fb(a, b) { 886 var f, 887 g, 888 h, 889 j, 890 c = a.lastInterval || b, 891 e = b.timeStamp - c.timeStamp;if (b.eventType != R && (e > N || c.velocity === d)) { 892 var k = c.deltaX - b.deltaX, 893 l = c.deltaY - b.deltaY, 894 m = ib(e, k, l);g = m.x, h = m.y, f = i(m.x) > i(m.y) ? m.x : m.y, j = jb(k, l), a.lastInterval = b; 895 } else f = c.velocity, g = c.velocityX, h = c.velocityY, j = c.direction;b.velocity = f, b.velocityX = g, b.velocityY = h, b.direction = j; 896 }function gb(a) { 897 for (var b = [], c = 0; c < a.pointers.length;) { 898 b[c] = { clientX: h(a.pointers[c].clientX), clientY: h(a.pointers[c].clientY) }, c++; 899 }return { timeStamp: j(), pointers: b, center: hb(b), deltaX: a.deltaX, deltaY: a.deltaY }; 900 }function hb(a) { 901 var b = a.length;if (1 === b) return { x: h(a[0].clientX), y: h(a[0].clientY) };for (var c = 0, d = 0, e = 0; b > e;) { 902 c += a[e].clientX, d += a[e].clientY, e++; 903 }return { x: h(c / b), y: h(d / b) }; 904 }function ib(a, b, c) { 905 return { x: b / a || 0, y: c / a || 0 }; 906 }function jb(a, b) { 907 return a === b ? S : i(a) >= i(b) ? a > 0 ? T : U : b > 0 ? V : W; 908 }function kb(a, b, c) { 909 c || (c = $);var d = b[c[0]] - a[c[0]], 910 e = b[c[1]] - a[c[1]];return Math.sqrt(d * d + e * e); 911 }function lb(a, b, c) { 912 c || (c = $);var d = b[c[0]] - a[c[0]], 913 e = b[c[1]] - a[c[1]];return 180 * Math.atan2(e, d) / Math.PI; 914 }function mb(a, b) { 915 return lb(b[1], b[0], _) - lb(a[1], a[0], _); 916 }function nb(a, b) { 917 return kb(b[0], b[1], _) / kb(a[0], a[1], _); 918 }function rb() { 919 this.evEl = pb, this.evWin = qb, this.allow = !0, this.pressed = !1, ab.apply(this, arguments); 920 }function wb() { 921 this.evEl = ub, this.evWin = vb, ab.apply(this, arguments), this.store = this.manager.session.pointerEvents = []; 922 }function Ab() { 923 this.evTarget = yb, this.evWin = zb, this.started = !1, ab.apply(this, arguments); 924 }function Bb(a, b) { 925 var c = z(a.touches), 926 d = z(a.changedTouches);return b & (Q | R) && (c = A(c.concat(d), "identifier", !0)), [c, d]; 927 }function Eb() { 928 this.evTarget = Db, this.targetIds = {}, ab.apply(this, arguments); 929 }function Fb(a, b) { 930 var c = z(a.touches), 931 d = this.targetIds;if (b & (O | P) && 1 === c.length) return d[c[0].identifier] = !0, [c, c];var e, 932 f, 933 g = z(a.changedTouches), 934 h = [], 935 i = this.target;if (f = c.filter(function (a) { 936 return v(a.target, i); 937 }), b === O) for (e = 0; e < f.length;) { 938 d[f[e].identifier] = !0, e++; 939 }for (e = 0; e < g.length;) { 940 d[g[e].identifier] && h.push(g[e]), b & (Q | R) && delete d[g[e].identifier], e++; 941 }return h.length ? [A(f.concat(h), "identifier", !0), h] : void 0; 942 }function Gb() { 943 ab.apply(this, arguments);var a = q(this.handler, this);this.touch = new Eb(this.manager, a), this.mouse = new rb(this.manager, a); 944 }function Pb(a, b) { 945 this.manager = a, this.set(b); 946 }function Qb(a) { 947 if (w(a, Mb)) return Mb;var b = w(a, Nb), 948 c = w(a, Ob);return b && c ? Nb + " " + Ob : b || c ? b ? Nb : Ob : w(a, Lb) ? Lb : Kb; 949 }function Yb(a) { 950 this.id = D(), this.manager = null, this.options = o(a || {}, this.defaults), this.options.enable = s(this.options.enable, !0), this.state = Rb, this.simultaneous = {}, this.requireFail = []; 951 }function Zb(a) { 952 return a & Wb ? "cancel" : a & Ub ? "end" : a & Tb ? "move" : a & Sb ? "start" : ""; 953 }
953function $b(a) { 954 return a == W ? "down" : a == V ? "up" : a == T ? "left" : a == U ? "right" : ""; 955 }function _b(a, b) { 956 var c = b.manager;return c ? c.get(a) : a; 957 }function ac() { 958 Yb.apply(this, arguments); 959 }function bc() { 960 ac.apply(this, arguments), this.pX = null, this.pY = null; 961 }function cc() { 962 ac.apply(this, arguments); 963 }function dc() { 964 Yb.apply(this, arguments), this._timer = null, this._input = null; 965 }function ec() { 966 ac.apply(this, arguments); 967 }function fc() { 968 ac.apply(this, arguments); 969 }function gc() { 970 Yb.apply(this, arguments), this.pTime = !1, this.pCenter = !1, this._timer = null, this._input = null, this.count = 0; 971 }function hc(a, b) { 972 return b = b || {}, b.recognizers = s(b.recognizers, hc.defaults.preset), new kc(a, b); 973 }function kc(a, b) { 974 b = b || {}, this.options = o(b, hc.defaults), this.options.inputTarget = this.options.inputTarget || a, this.handlers = {}, this.session = {}, this.recognizers = [], this.element = a, this.input = bb(this), this.touchAction = new Pb(this, this.options.touchAction), lc(this, !0), m(b.recognizers, function (a) { 975 var b = this.add(new a[0](a[1]));a[2] && b.recognizeWith(a[2]), a[3] && b.requireFailure(a[3]); 976 }, this); 977 }function lc(a, b) { 978 var c = a.element;m(a.options.cssProps, function (a, d) { 979 c.style[B(c.style, d)] = b ? a : ""; 980 }); 981 }function mc(a, c) { 982 var d = b.createEvent("Event");d.initEvent(a, !0, !0), d.gesture = c, c.target.dispatchEvent(d); 983 }var e = ["", "webkit", "moz", "MS", "ms", "o"], 984 f = b.createElement("div"), 985 g = "function", 986 h = Math.round, 987 i = Math.abs, 988 j = Date.now, 989 C = 1, 990 F = /mobile|tablet|ip(ad|hone|od)|android/i, 991 G = "ontouchstart" in a, 992 H = B(a, "PointerEvent") !== d, 993 I = G && F.test(navigator.userAgent), 994 J = "touch", 995 K = "pen", 996 L = "mouse", 997 M = "kinect", 998 N = 25, 999 O = 1, 1000 P = 2, 1001 Q = 4, 1002 R = 8, 1003 S = 1, 1004 T = 2, 1005 U = 4, 1006 V = 8, 1007 W = 16, 1008 X = T | U, 1009 Y = V | W, 1010 Z = X | Y, 1011 $ = ["x", "y"], 1012 _ = ["clientX", "clientY"];ab.prototype = { handler: function () {}, init: function () { 1013 this.evEl && t(this.element, this.evEl, this.domHandler), this.evTarget && t(this.target, this.evTarget, this.domHandler), this.evWin && t(E(this.element), this.evWin, this.domHandler); 1014 }, destroy: function () { 1015 this.evEl && u(this.element, this.evEl, this.domHandler), this.evTarget && u(this.target, this.evTarget, this.domHandler), this.evWin && u(E(this.element), this.evWin, this.domHandler); 1016 } };var ob = { mousedown: O, mousemove: P, mouseup: Q }, 1017 pb = "mousedown", 1018 qb = "mousemove mouseup";p(rb, ab, { handler: function (a) { 1019 var b = ob[a.type];b & O && 0 === a.button && (this.pressed = !0), b & P && 1 !== a.which && (b = Q), this.pressed && this.allow && (b & Q && (this.pressed = !1), this.callback(this.manager, b, { pointers: [a], changedPointers: [a], pointerType: L, srcEvent: a })); 1020 } });var sb = { pointerdown: O, pointermove: P, pointerup: Q, pointercancel: R, pointerout: R }, 1021 tb = { 2: J, 3: K, 4: L, 5: M }, 1022 ub = "pointerdown", 1023 vb = "pointermove pointerup pointercancel";a.MSPointerEvent && (ub = "MSPointerDown", vb = "MSPointerMove MSPointerUp MSPointerCancel"), p(wb, ab, { handler: function (a) { 1024 var b = this.store, 1025 c = !1, 1026 d = a.type.toLowerCase().replace("ms", ""), 1027 e = sb[d], 1028 f = tb[a.pointerType] || a.pointerType, 1029 g = f == J, 1030 h = y(b, a.pointerId, "pointerId");e & O && (0 === a.button || g) ? 0 > h && (b.push(a), h = b.length - 1) : e & (Q | R) && (c = !0), 0 > h || (b[h] = a, this.callback(this.manager, e, { pointers: b, changedPointers: [a], pointerType: f, srcEvent: a }), c && b.splice(h, 1)); 1031 } });var xb = { touchstart: O, touchmove: P, touchend: Q, touchcancel: R }, 1032 yb = "touchstart", 1033 zb = "touchstart touchmove touchend touchcancel";p(Ab, ab, { handler: function (a) { 1034 var b = xb[a.type];if (b === O && (this.started = !0), this.started) { 1035 var c = Bb.call(this, a, b);b & (Q | R) && 0 === c[0].length - c[1].length && (this.started = !1), this.callback(this.manager, b, { pointers: c[0], changedPointers: c[1], pointerType: J, srcEvent: a }); 1036 } 1037 } });var Cb = { touchstart: O, touchmove: P, touchend: Q, touchcancel: R },
1038 Db = "touchstart touchmove touchend touchcancel";p(Eb, ab, { handler: function (a) { 1039 var b = Cb[a.type], 1040 c = Fb.call(this, a, b);c && this.callback(this.manager, b, { pointers: c[0], changedPointers: c[1], pointerType: J, srcEvent: a }); 1041 } }), p(Gb, ab, { handler: function (a, b, c) { 1042 var d = c.pointerType == J, 1043 e = c.pointerType == L;if (d) this.mouse.allow = !1;else if (e && !this.mouse.allow) return;b & (Q | R) && (this.mouse.allow = !0), this.callback(a, b, c); 1044 }, destroy: function () { 1045 this.touch.destroy(), this.mouse.destroy(); 1046 } });var Hb = B(f.style, "touchAction"), 1047 Ib = Hb !== d, 1048 Jb = "compute", 1049 Kb = "auto", 1050 Lb = "manipulation", 1051 Mb = "none", 1052 Nb = "pan-x", 1053 Ob = "pan-y";Pb.prototype = { set: function (a) { 1054 a == Jb && (a = this.compute()), Ib && (this.manager.element.style[Hb] = a), this.actions = a.toLowerCase().trim(); 1055 }, update: function () { 1056 this.set(this.manager.options.touchAction); 1057 }, compute: function () { 1058 var a = [];return m(this.manager.recognizers, function (b) { 1059 r(b.options.enable, [b]) && (a = a.concat(b.getTouchAction())); 1060 }), Qb(a.join(" ")); 1061 }, preventDefaults: function (a) { 1062 if (!Ib) { 1063 var b = a.srcEvent, 1064 c = a.offsetDirection;if (this.manager.session.prevented) return b.preventDefault(), void 0;var d = this.actions, 1065 e = w(d, Mb), 1066 f = w(d, Ob), 1067 g = w(d, Nb);return e || f && c & X || g && c & Y ? this.preventSrc(b) : void 0; 1068 } 1069 }, preventSrc: function (a) { 1070 this.manager.session.prevented = !0, a.preventDefault(); 1071 } };var Rb = 1, 1072 Sb = 2, 1073 Tb = 4, 1074 Ub = 8, 1075 Vb = Ub, 1076 Wb = 16, 1077 Xb = 32;Yb.prototype = { defaults: {}, set: function (a) { 1078 return n(this.options, a), this.manager && this.manager.touchAction.update(), this; 1079 }, recognizeWith: function (a) { 1080 if (l(a, "recognizeWith", this)) return this;var b = this.simultaneous;return a = _b(a, this), b[a.id] || (b[a.id] = a, a.recognizeWith(this)), this; 1081 }, dropRecognizeWith: function (a) { 1082 return l(a, "dropRecognizeWith", this) ? this : (a = _b(a, this), delete this.simultaneous[a.id], this); 1083 }, requireFailure: function (a) { 1084 if (l(a, "requireFailure", this)) return this;var b = this.requireFail;return a = _b(a, this), -1 === y(b, a) && (b.push(a), a.requireFailure(this)), this; 1085 }, dropRequireFailure: function (a) { 1086 if (l(a, "dropRequireFailure", this)) return this;a = _b(a, this);var b = y(this.requireFail, a);return b > -1 && this.requireFail.splice(b, 1), this; 1087 }, hasRequireFailures: function () { 1088 return this.requireFail.length > 0; 1089 }, canRecognizeWith: function (a) { 1090 return !!this.simultaneous[a.id]; 1091 }, emit: function (a) { 1092 function d(d) { 1093 b.manager.emit(b.options.event + (d ? Zb(c) : ""), a); 1094 }var b = this, 1095 c = this.state;Ub > c && d(!0), d(), c >= Ub && d(!0); 1096 }, tryEmit: function (a) { 1097 return this.canEmit() ? this.emit(a) : (this.state = Xb, void 0); 1098 }, canEmit: function () { 1099 for (var a = 0; a < this.requireFail.length;) { 1100 if (!(this.requireFail[a].state & (Xb | Rb))) return !1;a++; 1101 }return !0; 1102 }, recognize: function (a) { 1103 var b = n({}, a);return r(this.options.enable, [this, b]) ? (this.state & (Vb | Wb | Xb) && (this.state = Rb), this.state = this.process(b), this.state & (Sb | Tb | Ub | Wb) && this.tryEmit(b), void 0) : (this.reset(), this.state = Xb, void 0); 1104 }, process: function () {}, getTouchAction: function () {}, reset: function () {} }, p(ac, Yb, { defaults: { pointers: 1 }, attrTest: function (a) { 1105 var b = this.options.pointers;return 0 === b || a.pointers.length === b; 1106 }, process: function (a) { 1107 var b = this.state, 1108 c = a.eventType, 1109 d = b & (Sb | Tb), 1110 e = this.attrTest(a);return d && (c & R || !e) ? b | Wb : d || e ? c & Q ? b | Ub : b & Sb ? b | Tb : Sb : Xb; 1111 } }), p(bc, ac, { defaults: { event: "pan", threshold: 10, pointers: 1, direction: Z }, getTouchAction: function () { 1112 var a = this.options.direction, 1113 b = [];return a & X && b.push(Ob), a & Y && b.push(Nb), b; 1114 }, directionTest: function (a) { 1115 var b = this.options, 1116 c = !0, 1117 d = a.distance, 1118 e = a.direction, 1119 f = a.deltaX,
1120 g = a.deltaY;return e & b.direction || (b.direction & X ? (e = 0 === f ? S : 0 > f ? T : U, c = f != this.pX, d = Math.abs(a.deltaX)) : (e = 0 === g ? S : 0 > g ? V : W, c = g != this.pY, d = Math.abs(a.deltaY))), a.direction = e, c && d > b.threshold && e & b.direction; 1121 }, attrTest: function (a) { 1122 return ac.prototype.attrTest.call(this, a) && (this.state & Sb || !(this.state & Sb) && this.directionTest(a)); 1123 }, emit: function (a) { 1124 this.pX = a.deltaX, this.pY = a.deltaY;var b = $b(a.direction);b && this.manager.emit(this.options.event + b, a), this._super.emit.call(this, a); 1125 } }), p(cc, ac, { defaults: { event: "pinch", threshold: 0, pointers: 2 }, getTouchAction: function () { 1126 return [Mb]; 1127 }, attrTest: function (a) { 1128 return this._super.attrTest.call(this, a) && (Math.abs(a.scale - 1) > this.options.threshold || this.state & Sb); 1129 }, emit: function (a) { 1130 if (this._super.emit.call(this, a), 1 !== a.scale) { 1131 var b = a.scale < 1 ? "in" : "out";this.manager.emit(this.options.event + b, a); 1132 } 1133 } }), p(dc, Yb, { defaults: { event: "press", pointers: 1, time: 500, threshold: 5 }, getTouchAction: function () { 1134 return [Kb]; 1135 }, process: function (a) { 1136 var b = this.options, 1137 c = a.pointers.length === b.pointers, 1138 d = a.distance < b.threshold, 1139 e = a.deltaTime > b.time;if (this._input = a, !d || !c || a.eventType & (Q | R) && !e) this.reset();else if (a.eventType & O) this.reset(), this._timer = k(function () { 1140 this.state = Vb, this.tryEmit(); 1141 }, b.time, this);else if (a.eventType & Q) return Vb;return Xb; 1142 }, reset: function () { 1143 clearTimeout(this._timer); 1144 }, emit: function (a) { 1145 this.state === Vb && (a && a.eventType & Q ? this.manager.emit(this.options.event + "up", a) : (this._input.timeStamp = j(), this.manager.emit(this.options.event, this._input))); 1146 } }), p(ec, ac, { defaults: { event: "rotate", threshold: 0, pointers: 2 }, getTouchAction: function () { 1147 return [Mb]; 1148 }, attrTest: function (a) { 1149 return this._super.attrTest.call(this, a) && (Math.abs(a.rotation) > this.options.threshold || this.state & Sb); 1150 } }), p(fc, ac, { defaults: { event: "swipe", threshold: 10, velocity: .65, direction: X | Y, pointers: 1 }, getTouchAction: function () { 1151 return bc.prototype.getTouchAction.call(this); 1152 }, attrTest: function (a) { 1153 var c, 1154 b = this.options.direction;return b & (X | Y) ? c = a.velocity : b & X ? c = a.velocityX : b & Y && (c = a.velocityY), this._super.attrTest.call(this, a) && b & a.direction && a.distance > this.options.threshold && i(c) > this.options.velocity && a.eventType & Q; 1155 }, emit: function (a) { 1156 var b = $b(a.direction);b && this.manager.emit(this.options.event + b, a), this.manager.emit(this.options.event, a); 1157 } }), p(gc, Yb, { defaults: { event: "tap", pointers: 1, taps: 1, interval: 300, time: 250, threshold: 2, posThreshold: 10 }, getTouchAction: function () { 1158 return [Lb]; 1159 }, process: function (a) { 1160 var b = this.options, 1161 c = a.pointers.length === b.pointers, 1162 d = a.distance < b.threshold, 1163 e = a.deltaTime < b.time;if (this.reset(), a.eventType & O && 0 === this.count) return this.failTimeout();if (d && e && c) { 1164 if (a.eventType != Q) return this.failTimeout();var f = this.pTime ? a.timeStamp - this.pTime < b.interval : !0, 1165 g = !this.pCenter || kb(this.pCenter, a.center) < b.posThreshold;this.pTime = a.timeStamp, this.pCenter = a.center, g && f ? this.count += 1 : this.count = 1, this._input = a;var h = this.count % b.taps;if (0 === h) return this.hasRequireFailures() ? (this._timer = k(function () { 1166 this.state = Vb, this.tryEmit(); 1167 }, b.interval, this), Sb) : Vb; 1168 }return Xb; 1169 }, failTimeout: function () { 1170 return this._timer = k(function () { 1171 this.state = Xb; 1172 }, this.options.interval, this), Xb; 1173 }, reset: function () { 1174 clearTimeout(this._timer); 1175 }, emit: function () { 1176 this.state == Vb && (this._input.tapCount = this.count, this.manager.emit(this.options.event, this._input)); 1177 } }), hc.VERSION = "2.0.4", hc.defaults = { domEvents: !1, touchAction: Jb, enable: !0, inputTarget: null, inputClass: null, preset
1177: [[ec, { enable: !1 }], [cc, { enable: !1 }, ["rotate"]], [fc, { direction: X }], [bc, { direction: X }, ["swipe"]], [gc], [gc, { event: "doubletap", taps: 2 }, ["tap"]], [dc]], cssProps: { userSelect: "default", touchSelect: "none", touchCallout: "none", contentZooming: "none", userDrag: "none", tapHighlightColor: "rgba(0,0,0,0)" } };var ic = 1, 1178 jc = 2;kc.prototype = { set: function (a) { 1179 return n(this.options, a), a.touchAction && this.touchAction.update(), a.inputTarget && (this.input.destroy(), this.input.target = a.inputTarget, this.input.init()), this; 1180 }, stop: function (a) { 1181 this.session.stopped = a ? jc : ic; 1182 }, recognize: function (a) { 1183 var b = this.session;if (!b.stopped) { 1184 this.touchAction.preventDefaults(a);var c, 1185 d = this.recognizers, 1186 e = b.curRecognizer;(!e || e && e.state & Vb) && (e = b.curRecognizer = null);for (var f = 0; f < d.length;) { 1187 c = d[f], b.stopped === jc || e && c != e && !c.canRecognizeWith(e) ? c.reset() : c.recognize(a), !e && c.state & (Sb | Tb | Ub) && (e = b.curRecognizer = c), f++; 1188 } 1189 } 1190 }, get: function (a) { 1191 if (a instanceof Yb) return a;for (var b = this.recognizers, c = 0; c < b.length; c++) { 1192 if (b[c].options.event == a) return b[c]; 1193 }return null; 1194 }, add: function (a) { 1195 if (l(a, "add", this)) return this;var b = this.get(a.options.event);return b && this.remove(b), this.recognizers.push(a), a.manager = this, this.touchAction.update(), a; 1196 }, remove: function (a) { 1197 if (l(a, "remove", this)) return this;var b = this.recognizers;return a = this.get(a), b.splice(y(b, a), 1), this.touchAction.update(), this; 1198 }, on: function (a, b) { 1199 var c = this.handlers;return m(x(a), function (a) { 1200 c[a] = c[a] || [], c[a].push(b); 1201 }), this; 1202 }, off: function (a, b) { 1203 var c = this.handlers;return m(x(a), function (a) { 1204 b ? c[a].splice(y(c[a], b), 1) : delete c[a]; 1205 }), this; 1206 }, emit: function (a, b) { 1207 this.options.domEvents && mc(a, b);var c = this.handlers[a] && this.handlers[a].slice();if (c && c.length) { 1208 b.type = a, b.preventDefault = function () { 1209 b.srcEvent.preventDefault(); 1210 };for (var d = 0; d < c.length;) { 1211 c[d](b), d++; 1212 } 1213 } 1214 }, destroy: function () { 1215 this.element && lc(this, !1), this.handlers = {}, this.session = {}, this.input.destroy(), this.element = null; 1216 } }, n(hc, { INPUT_START: O, INPUT_MOVE: P, INPUT_END: Q, INPUT_CANCEL: R, STATE_POSSIBLE: Rb, STATE_BEGAN: Sb, STATE_CHANGED: Tb, STATE_ENDED: Ub, STATE_RECOGNIZED: Vb, STATE_CANCELLED: Wb, STATE_FAILED: Xb, DIRECTION_NONE: S, DIRECTION_LEFT: T, DIRECTION_RIGHT: U, DIRECTION_UP: V, DIRECTION_DOWN: W, DIRECTION_HORIZONTAL: X, DIRECTION_VERTICAL: Y, DIRECTION_ALL: Z, Manager: kc, Input: ab, TouchAction: Pb, TouchInput: Eb, MouseInput: rb, PointerEventInput: wb, TouchMouseInput: Gb, SingleTouchInput: Ab, Recognizer: Yb, AttrRecognizer: ac, Tap: gc, Pan: bc, Swipe: fc, Pinch: cc, Rotate: ec, Press: dc, on: t, off: u, each: m, merge: o, extend: n, inherit: p, bindFn: q, prefixed: B }), typeof define == g && define.amd ? define(function () { 1217 return hc; 1218 }) : "undefined" != typeof module && module.exports ? module.exports = hc : a[c] = hc; 1219}(window, document, "Hammer");;(function (factory) { 1220 if (typeof define === 'function' && define.amd) { 1221 define(['jquery', 'hammerjs'], factory); 1222 } else if (typeof exports === 'object') { 1223 factory(require('jquery'), require('hammerjs')); 1224 } else { 1225 factory(jQuery, Hammer); 1226 } 1227})(function ($, Hammer) { 1228 function hammerify(el, options) { 1229 var $el = $(el); 1230 if (!$el.data("hammer")) { 1231 $el.data("hammer", new Hammer($el[0], options)); 1232 } 1233 } 1234 1235 $.fn.hammer = function (options) { 1236 return this.each(function () { 1237 hammerify(this, options); 1238 }); 1239 }; 1240 1241 // extend the emit method to also trigger jQuery events 1242 Hammer.Manager.prototype.emit = function (originalEmit) { 1243 return function (type, data) { 1244 originalEmit.call(this, type, data); 1245 $(this.element).trigger({ 1246 type: type, 1247 gesture: data 1248 }); 1249 }; 1250 }(Hammer.Manager.prototype.emit); 1251}); 1252; // Required for Meteor package, the use of window prevents export by Meteor 1253(function (window) { 1254 if (window.Package) { 1255 Materialize = {}; 1256 } else { 1257 window.Materialize = {}; 1258 } 1259})(window); 1260 1261/* 1262 * raf.js 1263 * https://github.com/ngryman/raf.js 1264 * 1265 * original requestAnimationFrame polyfill by Erik Möller 1266 * inspired from paul_irish gist and post 1267 * 1268 * Copyright (c) 2013 ngryman 1269 * Licensed under the MIT license. 1270 */ 1271(function (window) { 1272 var lastTime = 0, 1273 vendors = ['webkit', 'moz'], 1274 requestAnimationFrame = window.requestAnimationFrame, 1275 cancelAnimationFrame = window.cancelAnimationFrame,
1276 i = vendors.length; 1277 1278 // try to un-prefix existing raf 1279 while (--i >= 0 && !requestAnimationFrame) { 1280 requestAnimationFrame = window[vendors[i] + 'RequestAnimationFrame']; 1281 cancelAnimationFrame = window[vendors[i] + 'CancelRequestAnimationFrame']; 1282 } 1283 1284 // polyfill with setTimeout fallback 1285 // heavily inspired from @darius gist mod: https://gist.github.com/paulirish/1579671#comment-837945 1286 if (!requestAnimationFrame || !cancelAnimationFrame) { 1287 requestAnimationFrame = function (callback) { 1288 var now = +Date.now(), 1289 nextTime = Math.max(lastTime + 16, now); 1290 return setTimeout(function () { 1291 callback(lastTime = nextTime); 1292 }, nextTime - now); 1293 }; 1294 1295 cancelAnimationFrame = clearTimeout; 1296 } 1297 1298 // export to window 1299 window.requestAnimationFrame = requestAnimationFrame; 1300 window.cancelAnimationFrame = cancelAnimationFrame; 1301})(window); 1302 1303/** 1304 * Generate approximated selector string for a jQuery object 1305 * @param {jQuery} obj jQuery object to be parsed 1306 * @returns {string} 1307 */ 1308Materialize.objectSelectorString = function (obj) { 1309 var tagStr = obj.prop('tagName') || ''; 1310 var idStr = obj.attr('id') || ''; 1311 var classStr = obj.attr('class') || ''; 1312 return (tagStr + idStr + classStr).replace(/\s/g, ''); 1313}; 1314 1315// Unique Random ID 1316Materialize.guid = function () { 1317 function s4() { 1318 return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1); 1319 } 1320 return function () { 1321 return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4(); 1322 }; 1323}(); 1324 1325/** 1326 * Escapes hash from special characters 1327 * @param {string} hash String returned from this.hash 1328 * @returns {string} 1329 */ 1330Materialize.escapeHash = function (hash) { 1331 return hash.replace(/(:|\.|\[|\]|,|=)/g, "\\$1"); 1332}; 1333 1334Materialize.elementOrParentIsFixed = function (element) { 1335 var $element = $(element); 1336 var $checkElements = $element.add($element.parents()); 1337 var isFixed = false; 1338 $checkElements.each(function () { 1339 if ($(this).css("position") === "fixed") { 1340 isFixed = true; 1341 return false; 1342 } 1343 }); 1344 return isFixed; 1345}; 1346 1347/** 1348 * Get time in ms 1349 * @license https://raw.github.com/jashkenas/underscore/master/LICENSE 1350 * @type {function} 1351 * @return {number} 1352 */ 1353var getTime = Date.now || function () { 1354 return new Date().getTime(); 1355}; 1356 1357/** 1358 * Returns a function, that, when invoked, will only be triggered at most once 1359 * during a given window of time. Normally, the throttled function will run 1360 * as much as it can, without ever going more than once per `wait` duration; 1361 * but if you'd like to disable the execution on the leading edge, pass 1362 * `{leading: false}`. To disable execution on the trailing edge, ditto. 1363 * @license https://raw.github.com/jashkenas/underscore/master/LICENSE 1364 * @param {function} func 1365 * @param {number} wait 1366 * @param {Object=} options 1367 * @returns {Function} 1368 */ 1369Materialize.throttle = function (func, wait, options) { 1370 var context, args, result; 1371 var timeout = null; 1372 var previous = 0; 1373 options || (options = {}); 1374 var later = function () { 1375 previous = options.leading === false ? 0 : getTime(); 1376 timeout = null; 1377 result = func.apply(context, args); 1378 context = args = null; 1379 }; 1380 return function () { 1381 var now = getTime(); 1382 if (!previous && options.leading === false) previous = now; 1383 var remaining = wait - (now - previous); 1384 context = this; 1385 args = arguments; 1386 if (remaining <= 0) { 1387 clearTimeout(timeout); 1388 timeout = null; 1389 previous = now; 1390 result = func.apply(context, args); 1391 context = args = null; 1392 } else if (!timeout && options.trailing !== false) { 1393 timeout = setTimeout(later, remaining); 1394 } 1395 return result; 1396 }; 1397}; 1398 1399// Velocity has conflicts when loaded with jQuery, this will check for it 1400// First, check if in noConflict mode 1401var Vel; 1402if (jQuery) { 1403 Vel = jQuery.Velocity; 1404} else if ($) { 1405 Vel = $.Velocity; 1406} else { 1407 Vel = Velocity; 1408} 1409;(function ($) { 1410 $.fn.collapsible = function (options, methodParam) { 1411 var defaults = { 1412 accordion: undefined, 1413 onOpen: undefined, 1414 onClose: undefined 1415 }; 1416 1417 var methodName = options; 1418 options = $.extend(defaults, options); 1419 1420 return this.each(function () { 1421 1422 var $this = $(this); 1423 1424 var $panel_headers = $(this).find('> li > .collapsible-header'); 1425
1426 var collapsible_type = $this.data("collapsible"); 1427 1428 /**************** 1429 Helper Functions 1430 ****************/ 1431 1432 // Accordion Open 1433 function accordionOpen(object) { 1434 $panel_headers = $this.find('> li > .collapsible-header'); 1435 if (object.hasClass('active')) { 1436 object.parent().addClass('active'); 1437 } else { 1438 object.parent().removeClass('active'); 1439 } 1440 if (object.parent().hasClass('active')) { 1441 object.siblings('.collapsible-body').stop(true, false).slideDown({ duration: 350, easing: "easeOutQuart", queue: false, complete: function () { 1442 $(this).css('height', ''); 1443 } }); 1444 } else { 1445 object.siblings('.collapsible-body').stop(true, false).slideUp({ duration: 350, easing: "easeOutQuart", queue: false, complete: function () { 1446 $(this).css('height', ''); 1447 } }); 1448 } 1449 1450 $panel_headers.not(object).removeClass('active').parent().removeClass('active'); 1451 1452 // Close previously open accordion elements. 1453 $panel_headers.not(object).parent().children('.collapsible-body').stop(true, false).each(function () { 1454 if ($(this).is(':visible')) { 1455 $(this).slideUp({ 1456 duration: 350, 1457 easing: "easeOutQuart", 1458 queue: false, 1459 complete: function () { 1460 $(this).css('height', ''); 1461 execCallbacks($(this).siblings('.collapsible-header')); 1462 } 1463 }); 1464 } 1465 }); 1466 } 1467 1468 // Expandable Open 1469 function expandableOpen(object) { 1470 if (object.hasClass('active')) { 1471 object.parent().addClass('active'); 1472 } else { 1473 object.parent().removeClass('active'); 1474 } 1475 if (object.parent().hasClass('active')) { 1476 object.siblings('.collapsible-body').stop(true, false).slideDown({ duration: 350, easing: "easeOutQuart", queue: false, complete: function () { 1477 $(this).css('height', ''); 1478 } }); 1479 } else { 1480 object.siblings('.collapsible-body').stop(true, false).slideUp({ duration: 350, easing: "easeOutQuart", queue: false, complete: function () { 1481 $(this).css('height', ''); 1482 } }); 1483 } 1484 } 1485 1486 // Open collapsible. object: .collapsible-header 1487 function collapsibleOpen(object, noToggle) { 1488 if (!noToggle) { 1489 object.toggleClass('active'); 1490 } 1491 1492 if (options.accordion || collapsible_type === "accordion" || collapsible_type === undefined) { 1493 // Handle Accordion 1494 accordionOpen(object); 1495 } else { 1496 // Handle Expandables 1497 expandableOpen(object); 1498 } 1499 1500 execCallbacks(object); 1501 } 1502 1503 // Handle callbacks 1504 function execCallbacks(object) { 1505 if (object.hasClass('active')) { 1506 if (typeof options.onOpen === "function") { 1507 options.onOpen.call(this, object.parent()); 1508 } 1509 } else { 1510 if (typeof options.onClose === "function") { 1511 options.onClose.call(this, object.parent()); 1512 } 1513 } 1514 } 1515 1516 /** 1517 * Check if object is children of panel header 1518 * @param {Object} object Jquery object 1519 * @return {Boolean} true if it is children 1520 */ 1521 function isChildrenOfPanelHeader(object) { 1522 1523 var panelHeader = getPanelHeader(object); 1524 1525 return panelHeader.length > 0; 1526 } 1527 1528 /** 1529 * Get panel header from a children element 1530 * @param {Object} object Jquery object 1531 * @return {Object} panel header object 1532 */ 1533 function getPanelHeader(object) { 1534 1535 return object.closest('li > .collapsible-header'); 1536 } 1537 1538 // Turn off any existing event handlers 1539 function removeEventHandlers() { 1540 $this.off('click.collapse', '> li > .collapsible-header'); 1541 } 1542 1543 /***** End Helper Functions *****/ 1544 1545 // Methods 1546 if (methodName === 'destroy') { 1547 removeEventHandlers(); 1548 return; 1549 } else if (methodParam >= 0 && methodParam < $panel_headers.length) { 1550 var $curr_header = $panel_headers.eq(methodParam); 1551 if ($curr_header.length && (methodName === 'open' || methodName === 'close' && $curr_header.hasClass('active'))) { 1552 collapsibleOpen($curr_header); 1553 } 1554 return; 1555 } 1556 1557 removeEventHandlers(); 1558 1559 // Add click handler to only direct collapsible header children 1560 $this.on('click.collapse', '> li > .collapsible-header', function (e) { 1561 var element = $(e.target); 1562 1563 if (isChildrenOfPanelHeader(element)) { 1564 element = getPanelHeader(element); 1565 } 1566 1567 collapsibleOpen(element); 1568 }); 1569 1570 // Open first active 1571 if (options.accordion || collapsible_type === "accordion" || collapsible_type === undefined) { 1572 // Handle Accordion 1573 collapsibleOpen($panel_headers.filter('.active').first(), true); 1574 } else { 1575 // Handle Expandables 1576 $panel_headers.filter('.active').each(function () { 1577 collapsibleOpen($(this), true); 1578 }); 1579 } 1580 }); 1581 }; 1582 1583 $(document).ready(function () { 1584 $('.collapsible').collapsible(); 1585 }); 1586})(jQuery);;(function ($) { 1587 1588 // Add posibility to scroll to selected option 1589 // usefull for select for example 1590 $.fn.scrollTo = function (elem) { 1591 $(this).scrollTop($(this).scrollTop() - $(this).offset().top + $(elem).offset().top); 1592 return this; 1593 }; 1594 1595 $.fn.dropdown = function (options) { 1596 var defaults = { 1597 inDuration: 300, 1598 outDuration: 225, 1599 constrainWidth: true, // Constrains width of dropdown to the activator
1600 hover: false, 1601 gutter: 0, // Spacing from edge 1602 belowOrigin: false, 1603 alignment: 'left', 1604 stopPropagation: false 1605 }; 1606 1607 // Open dropdown. 1608 if (options === "open") { 1609 this.each(function () { 1610 $(this).trigger('open'); 1611 }); 1612 return false; 1613 } 1614 1615 // Close dropdown. 1616 if (options === "close") { 1617 this.each(function () { 1618 $(this).trigger('close'); 1619 }); 1620 return false; 1621 } 1622 1623 this.each(function () { 1624 var origin = $(this); 1625 var curr_options = $.extend({}, defaults, options); 1626 var isFocused = false; 1627 1628 // Dropdown menu 1629 var activates = $("#" + origin.attr('data-activates')); 1630 1631 function updateOptions() { 1632 if (origin.data('induration') !== undefined) curr_options.inDuration = origin.data('induration'); 1633 if (origin.data('outduration') !== undefined) curr_options.outDuration = origin.data('outduration'); 1634 if (origin.data('constrainwidth') !== undefined) curr_options.constrainWidth = origin.data('constrainwidth'); 1635 if (origin.data('hover') !== undefined) curr_options.hover = origin.data('hover'); 1636 if (origin.data('gutter') !== undefined) curr_options.gutter = origin.data('gutter'); 1637 if (origin.data('beloworigin') !== undefined) curr_options.belowOrigin = origin.data('beloworigin'); 1638 if (origin.data('alignment') !== undefined) curr_options.alignment = origin.data('alignment'); 1639 if (origin.data('stoppropagation') !== undefined) curr_options.stopPropagation = origin.data('stoppropagation'); 1640 } 1641 1642 updateOptions(); 1643 1644 // Attach dropdown to its activator 1645 origin.after(activates); 1646 1647 /* 1648 Helper function to position and resize dropdown. 1649 Used in hover and click handler. 1650 */ 1651 function placeDropdown(eventType) { 1652 // Check for simultaneous focus and click events. 1653 if (eventType === 'focus') { 1654 isFocused = true; 1655 } 1656 1657 // Check html data attributes 1658 updateOptions(); 1659 1660 // Set Dropdown state 1661 activates.addClass('active'); 1662 origin.addClass('active'); 1663 1664 var originWidth = origin[0].getBoundingClientRect().width; 1665 1666 // Constrain width 1667 if (curr_options.constrainWidth === true) { 1668 activates.css('width', originWidth); 1669 } else { 1670 activates.css('white-space', 'nowrap'); 1671 } 1672 1673 // Offscreen detection 1674 var windowHeight = window.innerHeight; 1675 var originHeight = origin.innerHeight(); 1676 var offsetLeft = origin.offset().left; 1677 var offsetTop = origin.offset().top - $(window).scrollTop(); 1678 var currAlignment = curr_options.alignment; 1679 var gutterSpacing = 0; 1680 var leftPosition = 0; 1681 1682 // Below Origin 1683 var verticalOffset = 0; 1684 if (curr_options.belowOrigin === true) { 1685 verticalOffset = originHeight; 1686 } 1687 1688 // Check for scrolling positioned container. 1689 var scrollYOffset = 0; 1690 var scrollXOffset = 0; 1691 var wrapper = origin.parent(); 1692 if (!wrapper.is('body')) { 1693 if (wrapper[0].scrollHeight > wrapper[0].clientHeight) { 1694 scrollYOffset = wrapper[0].scrollTop; 1695 } 1696 if (wrapper[0].scrollWidth > wrapper[0].clientWidth) { 1697 scrollXOffset = wrapper[0].scrollLeft; 1698 } 1699 } 1700 1701 if (offsetLeft + activates.innerWidth() > $(window).width()) { 1702 // Dropdown goes past screen on right, force right alignment 1703 currAlignment = 'right'; 1704 } else if (offsetLeft - activates.innerWidth() + origin.innerWidth() < 0) { 1705 // Dropdown goes past screen on left, force left alignment 1706 currAlignment = 'left'; 1707 } 1708 // Vertical bottom offscreen detection 1709 if (offsetTop + activates.innerHeight() > windowHeight) { 1710 // If going upwards still goes offscreen, just crop height of dropdown. 1711 if (offsetTop + originHeight - activates.innerHeight() < 0) { 1712 var adjustedHeight = windowHeight - offsetTop - verticalOffset; 1713 activates.css('max-height', adjustedHeight); 1714 } else { 1715 // Flow upwards. 1716 if (!verticalOffset) { 1717 verticalOffset += originHeight; 1718 } 1719 verticalOffset -= activates.innerHeight(); 1720 } 1721 } 1722 1723 // Handle edge alignment 1724 if (currAlignment === 'left') { 1725 gutterSpacing = curr_options.gutter; 1726 leftPosition = origin.position().left + gutterSpacing; 1727 } else if (currAlignment === 'right') { 1728 // Material icons fix 1729 activates.stop(true, true).css({ 1730 opacity: 0, 1731 left: 0 1732 }); 1733 1734 var offsetRight = origin.position().left + originWidth - activates.width(); 1735 gutterSpacing = -curr_options.gutter; 1736 leftPosition = offsetRight + gutterSpacing; 1737 } 1738 1739 // Position dropdown 1740 activates.css({ 1741 position: 'absolute', 1742 top: origin.position().top + verticalOffset + scrollYOffset, 1743 left: leftPosition + scrollXOffset 1744 }); 1745 1746 // Show dropdown 1747 activates.slideDown({ 1748 queue: false, 1749 duration: curr_options.inDuration, 1750 easing: 'easeOutCubic', 1751 complete: function () { 1752 $(this).css('height', ''); 1753 } 1754 }).animate({ opacity: 1 }, { queue: false, duration: curr_options.inDuration, easing: 'easeOutSine' }); 1755 1756 // Add click close handler to document 1757 1758 setTimeout(function () { 1759 $(document).on('click.' + activates.attr('id'), function (e) { 1760 if ($(e.target).closest( 1761 '.btn-modal-appstore, .btn-modal-googleplay, #modal-google-play ,#modal-app-store, .modal-overlay' 1762 ).length) { 1763 e.stopImmediatePropagation(); 1764 return; 1765 } 1766 1767 hideDropdown(); 1768 $(document).off('click.' + activates.attr('id')); 1769 }); 1770 }, 0); 1771 1772 1773 1774 1775 } 1776 1777 function hideDropdown() { 1778 // Check for simultaneous focus and click events. 1779 isFocused = false;
1780 activates.fadeOut(curr_options.outDuration); 1781 activates.removeClass('active'); 1782 origin.removeClass('active'); 1783 $(document).off('click.' + activates.attr('id')); 1784 setTimeout(function () { 1785 activates.css('max-height', ''); 1786 }, curr_options.outDuration); 1787 } 1788 1789 // Hover 1790 if (curr_options.hover) { 1791 var open = false; 1792 origin.off('click.' + origin.attr('id')); 1793 // Hover handler to show dropdown 1794 origin.on('mouseenter', function (e) { 1795 // Mouse over 1796 if (open === false) { 1797 placeDropdown(); 1798 open = true; 1799 } 1800 }); 1801 origin.on('mouseleave', function (e) { 1802 // If hover on origin then to something other than dropdown content, then close 1803 var toEl = e.toElement || e.relatedTarget; // added browser compatibility for target element 1804 if (!$(toEl).closest('.dropdown-content').is(activates)) { 1805 activates.stop(true, true); 1806 hideDropdown(); 1807 open = false; 1808 } 1809 }); 1810 1811 activates.on('mouseleave', function (e) { 1812 // Mouse out 1813 var toEl = e.toElement || e.relatedTarget; 1814 if (!$(toEl).closest('.dropdown-button').is(origin)) { 1815 activates.stop(true, true); 1816 hideDropdown(); 1817 open = false; 1818 } 1819 }); 1820 1821 // Click 1822 } else { 1823 // Click handler to show dropdown 1824 origin.off('click.' + origin.attr('id')); 1825 origin.on('click.' + origin.attr('id'), function (e) { 1826 if (!isFocused) { 1827 if (origin[0] == e.currentTarget && !origin.hasClass('active') && $(e.target).closest('.dropdown-content').length === 0) { 1828 e.preventDefault(); // Prevents button click from moving window 1829 if (curr_options.stopPropagation) { 1830 e.stopPropagation(); 1831 } 1832 placeDropdown('click'); 1833 } 1834 // If origin is clicked and menu is open, close menu 1835 else if (origin.hasClass('active')) { 1836 hideDropdown(); 1837 $(document).off('click.' + activates.attr('id')); 1838 } 1839 } 1840 }); 1841 } // End else 1842 1843 // Listen to open and close event - useful for select component 1844 origin.on('open', function (e, eventType) { 1845 placeDropdown(eventType); 1846 }); 1847 origin.on('close', hideDropdown); 1848 }); 1849 }; // End dropdown plugin 1850 1851 $(document).ready(function () { 1852 $('.dropdown-button').dropdown(); 1853 }); 1854})(jQuery); 1855;(function ($) { 1856 'use strict'; 1857 1858 var _defaults = { 1859 opacity: 0.5, 1860 inDuration: 250, 1861 outDuration: 250, 1862 ready: undefined, 1863 complete: undefined, 1864 dismissible: true, 1865 startingTop: '4%', 1866 endingTop: '10%' 1867 }; 1868 1869 /** 1870 * @class 1871 * 1872 */ 1873 1874 var Modal = function () { 1875 /** 1876 * Construct Modal instance and set up overlay 1877 * @constructor 1878 * @param {jQuery} $el 1879 * @param {Object} options 1880 */ 1881 function Modal($el, options) { 1882 _classCallCheck(this, Modal); 1883 1884 // If exists, destroy and reinitialize 1885 if (!!$el[0].M_Modal) { 1886 $el[0].M_Modal.destroy(); 1887 } 1888 1889 /** 1890 * The jQuery element 1891 * @type {jQuery} 1892 */ 1893 this.$el = $el; 1894 1895 /** 1896 * Options for the modal 1897 * @member Modal#options 1898 * @prop {Number} [opacity=0.5] - Opacity of the modal overlay 1899 * @prop {Number} [inDuration=250] - Length in ms of enter transition 1900 * @prop {Number} [outDuration=250] - Length in ms of exit transition 1901 * @prop {Function} ready - Callback function called when modal is finished entering 1902 * @prop {Function} complete - Callback function called when modal is finished exiting 1903 * @prop {Boolean} [dismissible=true] - Allow modal to be dismissed by keyboard or overlay click 1904 * @prop {String} [startingTop='4%'] - startingTop 1905 * @prop {String} [endingTop='10%'] - endingTop 1906 */ 1907 this.options = $.extend({}, Modal.defaults, options); 1908 1909 /** 1910 * Describes open/close state of modal 1911 * @type {Boolean} 1912 */ 1913 this.isOpen = false;
1914 1915 this.$el[0].M_Modal = this; 1916 this.id = $el.attr('id'); 1917 this.openingTrigger = undefined; 1918 this.$overlay = $('<div class="modal-overlay"></div>'); 1919 1920 Modal._increment++; 1921 Modal._count++; 1922 this.$overlay[0].style.zIndex = 1000 + Modal._increment * 2; 1923 this.$el[0].style.zIndex = 1000 + Modal._increment * 2 + 1; 1924 this.setupEventHandlers(); 1925 } 1926 1927 _createClass(Modal, [{ 1928 key: 'getInstance', 1929 1930 1931 /** 1932 * Get Instance 1933 */ 1934 value: function getInstance() { 1935 return this; 1936 } 1937 1938 /** 1939 * Teardown component 1940 */ 1941 1942 }, { 1943 key: 'destroy', 1944 value: function destroy() { 1945 this.removeEventHandlers(); 1946 this.$el[0].removeAttribute('style'); 1947 if (!!this.$overlay[0].parentNode) { 1948 this.$overlay[0].parentNode.removeChild(this.$overlay[0]); 1949 } 1950 this.$el[0].M_Modal = undefined; 1951 Modal._count--; 1952 } 1953 1954 /** 1955 * Setup Event Handlers 1956 */ 1957 1958 }, { 1959 key: 'setupEventHandlers', 1960 value: function setupEventHandlers() { 1961 this.handleOverlayClickBound = this.handleOverlayClick.bind(this); 1962 this.handleModalCloseClickBound = this.handleModalCloseClick.bind(this); 1963 1964 if (Modal._count === 1) { 1965 document.addEventListener('click', this.handleTriggerClick); 1966 } 1967 this.$overlay[0].addEventListener('click', this.handleOverlayClickBound); 1968 this.$el[0].addEventListener('click', this.handleModalCloseClickBound); 1969 } 1970 1971 /** 1972 * Remove Event Handlers 1973 */ 1974 1975 }, { 1976 key: 'removeEventHandlers', 1977 value: function removeEventHandlers() { 1978 if (Modal._count === 0) { 1979 document.removeEventListener('click', this.handleTriggerClick); 1980 } 1981 this.$overlay[0].removeEventListener('click', this.handleOverlayClickBound); 1982 this.$el[0].removeEventListener('click', this.handleModalCloseClickBound); 1983 } 1984 1985 /** 1986 * Handle Trigger Click 1987 * @param {Event} e 1988 */ 1989 1990 }, { 1991 key: 'handleTriggerClick', 1992 value: function handleTriggerClick(e) { 1993 var $trigger = $(e.target).closest('.modal-trigger'); 1994 if (e.target && $trigger.length) { 1995 var modalId = $trigger[0].getAttribute('href'); 1996 if (modalId) { 1997 modalId = modalId.slice(1); 1998 } else { 1999 modalId = $trigger[0].getAttribute('data-target'); 2000 } 2001 var modalInstance = document.getElementById(modalId).M_Modal; 2002 if (modalInstance) { 2003 modalInstance.open($trigger); 2004 } 2005 e.preventDefault(); 2006 } 2007 } 2008 2009 /** 2010 * Handle Overlay Click 2011 */ 2012 2013 }, { 2014 key: 'handleOverlayClick', 2015 value: function handleOverlayClick() { 2016 if (this.options.dismissible) { 2017 this.close(); 2018 } 2019 } 2020 2021 /** 2022 * Handle Modal Close Click 2023 * @param {Event} e 2024 */ 2025 2026 }, { 2027 key: 'handleModalCloseClick', 2028 value: function handleModalCloseClick(e) { 2029 var $closeTrigger = $(e.target).closest('.modal-close'); 2030 if (e.target && $closeTrigger.length) { 2031 this.close(); 2032 } 2033 } 2034 2035 /** 2036 * Handle Keydown 2037 * @param {Event} e 2038 */ 2039 2040 }, { 2041 key: 'handleKeydown', 2042 value: function handleKeydown(e) { 2043 // ESC key 2044 if (e.keyCode === 27 && this.options.dismissible) { 2045 this.close(); 2046 } 2047 } 2048 2049 /** 2050 * Animate in modal 2051 */ 2052 2053 }, { 2054 key: 'animateIn', 2055 value: function animateIn() { 2056 var _this = this; 2057 2058 // Set initial styles 2059 $.extend(this.$el[0].style, { 2060 display: 'block', 2061 opacity: 0 2062 }); 2063 $.extend(this.$overlay[0].style, { 2064 display: 'block', 2065 opacity: 0 2066 }); 2067 2068 // Animate overlay 2069 Vel(this.$overlay[0], { opacity: this.options.opacity }, { duration: this.options.inDuration, queue: false, ease: 'easeOutCubic' }); 2070 2071 // Define modal animation options 2072 var enterVelocityOptions = { 2073 duration: this.options.inDuration, 2074 queue: false, 2075 ease: 'easeOutCubic', 2076 // Handle modal ready callback 2077 complete: function () { 2078 if (typeof _this.options.ready === 'function') { 2079 _this.options.ready.call(_this, _this.$el, _this.openingTrigger); 2080 } 2081 } 2082 }; 2083 2084 // Bottom sheet animation 2085 if (this.$el[0].classList.contains('bottom-sheet')) { 2086 Vel(this.$el[0], { bottom: 0, opacity: 1 }, enterVelocityOptions); 2087 2088 // Normal modal animation 2089 } else { 2090 Vel.hook(this.$el[0], 'scaleX', 0.7); 2091 this.$el[0].style.top = this.options.startingTop; 2092 Vel(this.$el[0], { top: this.options.endingTop, opacity: 1, scaleX: 1 }, enterVelocityOptions); 2093 } 2094 } 2095 2096 /** 2097 * Animate out modal 2098 */ 2099 2100 }, {
2101 key: 'animateOut', 2102 value: function animateOut() { 2103 var _this2 = this; 2104 2105 // Animate overlay 2106 Vel(this.$overlay[0], { opacity: 0 }, { duration: this.options.outDuration, queue: false, ease: 'easeOutQuart' }); 2107 2108 // Define modal animation options 2109 var exitVelocityOptions = { 2110 duration: this.options.outDuration, 2111 queue: false, 2112 ease: 'easeOutCubic', 2113 // Handle modal ready callback 2114 complete: function () { 2115 _this2.$el[0].style.display = 'none'; 2116 // Call complete callback 2117 if (typeof _this2.options.complete === 'function') { 2118 _this2.options.complete.call(_this2, _this2.$el); 2119 } 2120 _this2.$overlay[0].remove(); 2121 } 2122 }; 2123 2124 // Bottom sheet animation 2125 if (this.$el[0].classList.contains('bottom-sheet')) { 2126 Vel(this.$el[0], { bottom: '-100%', opacity: 0 }, exitVelocityOptions); 2127 2128 // Normal modal animation 2129 } else { 2130 Vel(this.$el[0], { top: this.options.startingTop, opacity: 0, scaleX: 0.7 }, exitVelocityOptions); 2131 } 2132 } 2133 2134 /** 2135 * Open Modal 2136 * @param {jQuery} [$trigger] 2137 */ 2138 2139 }, { 2140 key: 'open', 2141 value: function open($trigger) { 2142 if (this.isOpen) { 2143 return; 2144 } 2145 2146 this.isOpen = true; 2147 var body = document.body; 2148 body.style.overflow = 'hidden'; 2149 this.$el[0].classList.add('open'); 2150 body.appendChild(this.$overlay[0]); 2151 2152 // Set opening trigger, undefined indicates modal was opened by javascript 2153 this.openingTrigger = !!$trigger ? $trigger : undefined; 2154 2155 if (this.options.dismissible) { 2156 this.handleKeydownBound = this.handleKeydown.bind(this); 2157 document.addEventListener('keydown', this.handleKeydownBound); 2158 } 2159 2160 this.animateIn(); 2161 2162 return this; 2163 } 2164 2165 /** 2166 * Close Modal 2167 */ 2168 2169 }, { 2170 key: 'close', 2171 value: function close() { 2172 if (!this.isOpen) { 2173 return; 2174 } 2175 2176 this.isOpen = false; 2177 this.$el[0].classList.remove('open'); 2178 document.body.style.overflow = null; 2179 2180 if (this.options.dismissible) { 2181 document.removeEventListener('keydown', this.handleKeydownBound); 2182 } 2183 2184 this.animateOut(); 2185 2186 return this; 2187 } 2188 }], [{ 2189 key: 'init', 2190 value: function init($els, options) { 2191 var arr = []; 2192 $els.each(function () { 2193 arr.push(new Modal($(this), options)); 2194 }); 2195 return arr; 2196 } 2197 }, { 2198 key: 'defaults', 2199 get: function () { 2200 return _defaults; 2201 } 2202 }]); 2203 2204 return Modal; 2205 }(); 2206 2207 /** 2208 * @static 2209 * @memberof Modal 2210 */ 2211 2212 2213 Modal._increment = 0; 2214 2215 /** 2216 * @static 2217 * @memberof Modal 2218 */ 2219 Modal._count = 0; 2220 2221 window.Materialize.Modal = Modal; 2222 2223 $.fn.modal = function (methodOrOptions) { 2224 // Call plugin method if valid method name is passed in 2225 if (Modal.prototype[methodOrOptions]) { 2226 // Getter methods 2227 if (methodOrOptions.slice(0, 3) === 'get') { 2228 return this.first()[0].M_Modal[methodOrOptions](); 2229 2230 // Void methods 2231 } else { 2232 return this.each(function () { 2233 this.M_Modal[methodOrOptions](); 2234 }); 2235 } 2236 2237 // Initialize plugin if options or no argument is passed in 2238 } else if (typeof methodOrOptions === 'object' || !methodOrOptions) { 2239 Modal.init(this, arguments[0]); 2240 return this; 2241 2242 // Return error if an unrecognized method name is passed in 2243 } else { 2244 $.error('Method ' + methodOrOptions + ' does not exist on jQuery.modal'); 2245 } 2246 }; 2247})(jQuery); 2248;(function ($) { 2249 2250 $.fn.materialbox = function () { 2251 2252 return this.each(function () { 2253 2254 if ($(this).hasClass('initialized')) { 2255 return; 2256 } 2257 2258 $(this).addClass('initialized'); 2259 2260 var overlayActive = false; 2261 var doneAnimating = true; 2262 var inDuration = 275; 2263 var outDuration = 200; 2264 var origin = $(this);
2265 var placeholder = $('<div></div>').addClass('material-placeholder'); 2266 var originalWidth = 0; 2267 var originalHeight = 0; 2268 var ancestorsChanged; 2269 var ancestor; 2270 var originInlineStyles = origin.attr('style'); 2271 origin.wrap(placeholder); 2272 2273 // Start click handler 2274 origin.on('click', function () { 2275 var placeholder = origin.parent('.material-placeholder'); 2276 var windowWidth = window.innerWidth; 2277 var windowHeight = window.innerHeight; 2278 var originalWidth = origin.width(); 2279 var originalHeight = origin.height(); 2280 2281 // If already modal, return to original 2282 if (doneAnimating === false) { 2283 returnToOriginal(); 2284 return false; 2285 } else if (overlayActive && doneAnimating === true) { 2286 returnToOriginal(); 2287 return false; 2288 } 2289 2290 // Set states 2291 doneAnimating = false; 2292 origin.addClass('active'); 2293 overlayActive = true; 2294 2295 // Set positioning for placeholder 2296 placeholder.css({ 2297 width: placeholder[0].getBoundingClientRect().width, 2298 height: placeholder[0].getBoundingClientRect().height, 2299 position: 'relative', 2300 top: 0, 2301 left: 0 2302 }); 2303 2304 // Find ancestor with overflow: hidden; and remove it 2305 ancestorsChanged = undefined; 2306 ancestor = placeholder[0].parentNode; 2307 var count = 0; 2308 while (ancestor !== null && !$(ancestor).is(document)) { 2309 var curr = $(ancestor); 2310 if (curr.css('overflow') !== 'visible') { 2311 curr.css('overflow', 'visible'); 2312 if (ancestorsChanged === undefined) { 2313 ancestorsChanged = curr; 2314 } else { 2315 ancestorsChanged = ancestorsChanged.add(curr); 2316 } 2317 } 2318 ancestor = ancestor.parentNode; 2319 } 2320 2321 // Set css on origin 2322 origin.css({ 2323 position: 'absolute', 2324 'z-index': 1000, 2325 'will-change': 'left, top, width, height' 2326 }).data('width', originalWidth).data('height', originalHeight); 2327 2328 // Add overlay 2329 var overlay = $('<div id="materialbox-overlay"></div>').css({ 2330 opacity: 0 2331 }).click(function () { 2332 if (doneAnimating === true) returnToOriginal(); 2333 }); 2334 2335 // Put before in origin image to preserve z-index layering. 2336 origin.before(overlay); 2337 2338 // Set dimensions if needed 2339 var overlayOffset = overlay[0].getBoundingClientRect(); 2340 overlay.css({ 2341 width: windowWidth, 2342 height: windowHeight, 2343 left: -1 * overlayOffset.left, 2344 top: -1 * overlayOffset.top 2345 }); 2346 2347 // Animate Overlay 2348 overlay.velocity({ opacity: 1 }, { duration: inDuration, queue: false, easing: 'easeOutQuad' }); 2349 2350 // Add and animate caption if it exists 2351 if (origin.data('caption') !== "") { 2352 var $photo_caption = $('<div class="materialbox-caption"></div>'); 2353 $photo_caption.text(origin.data('caption')); 2354 $('body').append($photo_caption); 2355 $photo_caption.css({ "display": "inline" }); 2356 $photo_caption.velocity({ opacity: 1 }, { duration: inDuration, queue: false, easing: 'easeOutQuad' }); 2357 } 2358 2359 // Resize Image 2360 var ratio = 0; 2361 var widthPercent = originalWidth / windowWidth; 2362 var heightPercent = originalHeight / windowHeight; 2363 var newWidth = 0; 2364 var newHeight = 0; 2365 2366 if (widthPercent > heightPercent) { 2367 ratio = originalHeight / originalWidth; 2368 newWidth = windowWidth * 0.9; 2369 newHeight = windowWidth * 0.9 * ratio; 2370 } else { 2371 ratio = originalWidth / originalHeight; 2372 newWidth = windowHeight * 0.9 * ratio; 2373 newHeight = windowHeight * 0.9; 2374 } 2375 2376 // Animate image + set z-index 2377 if (origin.hasClass('responsive-img')) { 2378 origin.velocity({ 'max-width': newWidth, 'width': originalWidth }, { duration: 0, queue: false, 2379 complete: function () { 2380 origin.css({ left: 0, top: 0 }).velocity({ 2381 height: newHeight, 2382 width: newWidth, 2383 left: $(document).scrollLeft() + windowWidth / 2 - origin.parent('.material-placeholder').offset().left - newWidth / 2, 2384 top: $(document).scrollTop() + windowHeight / 2 - origin.parent('.material-placeholder').offset().top - newHeight / 2 2385 }, { 2386 duration: inDuration, 2387 queue: false, 2388 easing: 'easeOutQuad', 2389 complete: function () { 2390 doneAnimating = true; 2391 } 2392 }); 2393 } // End Complete 2394 }); // End Velocity 2395 } else { 2396 origin.css('left', 0).css('top', 0).velocity({ 2397 height: newHeight, 2398 width: newWidth, 2399 left: $(document).scrollLeft() + windowWidth / 2 - origin.parent('.material-placeholder').offset().left - newWidth / 2, 2400 top: $(document).scrollTop() + windowHeight / 2 - origin.parent('.material-placeholder').offset().top - newHeight / 2 2401 }, { 2402 duration: inDuration, 2403 queue: false, 2404 easing: 'easeOutQuad', 2405 complete: function () { 2406 doneAnimating = true; 2407 } 2408 }); // End Velocity 2409 } 2410 2411 // Handle Exit triggers 2412 $(window).on('scroll.materialbox', function () { 2413 if (overlayActive) { 2414 returnToOriginal(); 2415 } 2416 }); 2417 2418 $(window).on('resize.materialbox', function () { 2419 if (overlayActive) { 2420 returnToOriginal(); 2421 } 2422 }); 2423 2424 $(document).on('keyup.materialbox', function (e) { 2425 // ESC key 2426 if (e.keyCode === 27 && doneAnimating === true && overlayActive) { 2427 returnToOriginal(); 2428 } 2429 }); 2430 }); // End click handler 2431 2432 2433 // This function returns the modaled image to the original spot 2434 function returnToOriginal() { 2435 2436 doneAnimating = false;
2437 2438 var placeholder = origin.parent('.material-placeholder'); 2439 var windowWidth = window.innerWidth; 2440 var windowHeight = window.innerHeight; 2441 var originalWidth = origin.data('width'); 2442 var originalHeight = origin.data('height'); 2443 2444 origin.velocity("stop", true); 2445 $('#materialbox-overlay').velocity("stop", true); 2446 $('.materialbox-caption').velocity("stop", true); 2447 2448 // disable exit handlers 2449 $(window).off('scroll.materialbox'); 2450 $(document).off('keyup.materialbox'); 2451 $(window).off('resize.materialbox'); 2452 2453 $('#materialbox-overlay').velocity({ opacity: 0 }, { 2454 duration: outDuration, // Delay prevents animation overlapping 2455 queue: false, easing: 'easeOutQuad', 2456 complete: function () { 2457 // Remove Overlay 2458 overlayActive = false; 2459 $(this).remove(); 2460 } 2461 }); 2462 2463 // Resize Image 2464 origin.velocity({ 2465 width: originalWidth, 2466 height: originalHeight, 2467 left: 0, 2468 top: 0 2469 }, { 2470 duration: outDuration, 2471 queue: false, easing: 'easeOutQuad', 2472 complete: function () { 2473 placeholder.css({ 2474 height: '', 2475 width: '', 2476 position: '', 2477 top: '', 2478 left: '' 2479 }); 2480 2481 origin.removeAttr('style'); 2482 origin.attr('style', originInlineStyles); 2483 2484 // Remove class 2485 origin.removeClass('active'); 2486 doneAnimating = true; 2487 2488 // Remove overflow overrides on ancestors 2489 if (ancestorsChanged) { 2490 ancestorsChanged.css('overflow', ''); 2491 } 2492 } 2493 }); 2494 2495 // Remove Caption + reset css settings on image 2496 $('.materialbox-caption').velocity({ opacity: 0 }, { 2497 duration: outDuration, // Delay prevents animation overlapping 2498 queue: false, easing: 'easeOutQuad', 2499 complete: function () { 2500 $(this).remove(); 2501 } 2502 }); 2503 } 2504 }); 2505 }; 2506 2507 $(document).ready(function () { 2508 $('.materialboxed').materialbox(); 2509 }); 2510})(jQuery); 2511;(function ($) { 2512 2513 $.fn.parallax = function () { 2514 var window_width = $(window).width(); 2515 // Parallax Scripts 2516 return this.each(function (i) { 2517 var $this = $(this); 2518 $this.addClass('parallax'); 2519 2520 function updateParallax(initial) { 2521 var container_height; 2522 if (window_width < 601) { 2523 container_height = $this.height() > 0 ? $this.height() : $this.children("img").height(); 2524 } else { 2525 container_height = $this.height() > 0 ? $this.height() : 500; 2526 } 2527 var $img = $this.children("img").first(); 2528 var img_height = $img.height(); 2529 var parallax_dist = img_height - container_height; 2530 var bottom = $this.offset().top + container_height; 2531 var top = $this.offset().top; 2532 var scrollTop = $(window).scrollTop(); 2533 var windowHeight = window.innerHeight; 2534 var windowBottom = scrollTop + windowHeight; 2535 var percentScrolled = (windowBottom - top) / (container_height + windowHeight); 2536 var parallax = Math.round(parallax_dist * percentScrolled); 2537 2538 if (initial) { 2539 $img.css('display', 'block'); 2540 } 2541 if (bottom > scrollTop && top < scrollTop + windowHeight) { 2542 $img.css('transform', "translate3D(-50%," + parallax + "px, 0)"); 2543 } 2544 } 2545 2546 // Wait for image load 2547 $this.children("img").one("load", function () { 2548 updateParallax(true); 2549 }).each(function () { 2550 if (this.complete) $(this).trigger("load"); 2551 }); 2552 2553 $(window).scroll(function () { 2554 window_width = $(window).width(); 2555 updateParallax(false); 2556 }); 2557 2558 $(window).resize(function () { 2559 window_width = $(window).width(); 2560 updateParallax(false); 2561 }); 2562 }); 2563 }; 2564})(jQuery); 2565;(function ($) { 2566 2567 var methods = { 2568 init: function (options) { 2569 var defaults = { 2570 onShow: null, 2571 swipeable: false, 2572 responsiveThreshold: Infinity // breakpoint for swipeable 2573 }; 2574 options = $.extend(defaults, options);
2575 var namespace = Materialize.objectSelectorString($(this)); 2576 2577 return this.each(function (i) { 2578 2579 var uniqueNamespace = namespace + i; 2580 2581 // For each set of tabs, we want to keep track of 2582 // which tab is active and its associated content 2583 var $this = $(this), 2584 window_width = $(window).width(); 2585 2586 var $active, 2587 $content, 2588 $links = $this.find('li.tab a'), 2589 $tabs_width = $this.width(), 2590 $tabs_content = $(), 2591 $tabs_wrapper, 2592 $tab_width = Math.max($tabs_width, $this[0].scrollWidth) / $links.length, 2593 $indicator, 2594 index = prev_index = 0, 2595 clicked = false, 2596 clickedTimeout, 2597 transition = 300; 2598 2599 // Finds right attribute for indicator based on active tab. 2600 // el: jQuery Object 2601 var calcRightPos = function (el) { 2602 return Math.ceil($tabs_width - el.position().left - el[0].getBoundingClientRect().width - $this.scrollLeft()); 2603 }; 2604 2605 // Finds left attribute for indicator based on active tab. 2606 // el: jQuery Object 2607 var calcLeftPos = function (el) { 2608 return Math.floor(el.position().left + $this.scrollLeft()); 2609 }; 2610 2611 // Animates Indicator to active tab. 2612 // prev_index: Number 2613 var animateIndicator = function (prev_index) { 2614 if (index - prev_index >= 0) { 2615 $indicator.velocity({ "right": calcRightPos($active) }, { duration: transition, queue: false, easing: 'easeOutQuad' }); 2616 $indicator.velocity({ "left": calcLeftPos($active) }, { duration: transition, queue: false, easing: 'easeOutQuad', delay: 90 }); 2617 } else { 2618 $indicator.velocity({ "left": calcLeftPos($active) }, { duration: transition, queue: false, easing: 'easeOutQuad' }); 2619 $indicator.velocity({ "right": calcRightPos($active) }, { duration: transition, queue: false, easing: 'easeOutQuad', delay: 90 }); 2620 } 2621 }; 2622 2623 // Change swipeable according to responsive threshold 2624 if (options.swipeable) { 2625 if (window_width > options.responsiveThreshold) { 2626 options.swipeable = false; 2627 } 2628 } 2629 2630 // If the location.hash matches one of the links, use that as the active tab. 2631 $active = $($links.filter('[href="' + location.hash + '"]')); 2632 2633 // If no match is found, use the first link or any with class 'active' as the initial active tab. 2634 if ($active.length === 0) { 2635 $active = $(this).find('li.tab a.active').first(); 2636 } 2637 if ($active.length === 0) { 2638 $active = $(this).find('li.tab a').first(); 2639 } 2640 2641 $active.addClass('active'); 2642 index = $links.index($active); 2643 if (index < 0) { 2644 index = 0; 2645 } 2646 2647 if ($active[0] !== undefined) { 2648 $content = $($active[0].hash); 2649 $content.addClass('active'); 2650 } 2651 2652 // append indicator then set indicator width to tab width 2653 if (!$this.find('.indicator').length) { 2654 $this.append('<li class="indicator"></li>'); 2655 } 2656 $indicator = $this.find('.indicator'); 2657 2658 // we make sure that the indicator is at the end of the tabs 2659 $this.append($indicator); 2660 2661 if ($this.is(":visible")) { 2662 // $indicator.css({"right": $tabs_width - ((index + 1) * $tab_width)}); 2663 // $indicator.css({"left": index * $tab_width}); 2664 setTimeout(function () { 2665 $indicator.css({ "right": calcRightPos($active) }); 2666 $indicator.css({ "left": calcLeftPos($active) }); 2667 }, 0); 2668 } 2669 $(window).off('resize.tabs-' + uniqueNamespace).on('resize.tabs-' + uniqueNamespace, function () { 2670 $tabs_width = $this.width(); 2671 $tab_width = Math.max($tabs_width, $this[0].scrollWidth) / $links.length; 2672 if (index < 0) { 2673 index = 0; 2674 } 2675 if ($tab_width !== 0 && $tabs_width !== 0) { 2676 $indicator.css({ "right": calcRightPos($active) });
2677 $indicator.css({ "left": calcLeftPos($active) }); 2678 } 2679 }); 2680 2681 // Initialize Tabs Content. 2682 if (options.swipeable) { 2683 // TODO: Duplicate calls with swipeable? handle multiple div wrapping. 2684 $links.each(function () { 2685 var $curr_content = $(Materialize.escapeHash(this.hash)); 2686 $curr_content.addClass('carousel-item'); 2687 $tabs_content = $tabs_content.add($curr_content); 2688 }); 2689 $tabs_wrapper = $tabs_content.wrapAll('<div class="tabs-content carousel"></div>'); 2690 $tabs_content.css('display', ''); 2691 $('.tabs-content.carousel').carousel({ 2692 fullWidth: true, 2693 noWrap: true, 2694 onCycleTo: function (item) { 2695 if (!clicked) { 2696 var prev_index = index; 2697 index = $tabs_wrapper.index(item); 2698 $active.removeClass('active'); 2699 $active = $links.eq(index); 2700 $active.addClass('active'); 2701 animateIndicator(prev_index); 2702 if (typeof options.onShow === "function") { 2703 options.onShow.call($this[0], $content); 2704 } 2705 } 2706 } 2707 }); 2708 } else { 2709 // Hide the remaining content 2710 $links.not($active).each(function () { 2711 $(Materialize.escapeHash(this.hash)).hide(); 2712 }); 2713 } 2714 2715 // Bind the click event handler 2716 $this.off('click.tabs').on('click.tabs', 'a', function (e) { 2717 if ($(this).parent().hasClass('disabled')) { 2718 e.preventDefault(); 2719 return; 2720 } 2721 2722 // Act as regular link if target attribute is specified. 2723 if (!!$(this).attr("target")) { 2724 return; 2725 } 2726 2727 clicked = true; 2728 $tabs_width = $this.width(); 2729 $tab_width = Math.max($tabs_width, $this[0].scrollWidth) / $links.length; 2730 2731 // Make the old tab inactive. 2732 $active.removeClass('active'); 2733 var $oldContent = $content; 2734 2735 // Update the variables with the new link and content 2736 $active = $(this); 2737 $content = $(Materialize.escapeHash(this.hash)); 2738 $links = $this.find('li.tab a'); 2739 var activeRect = $active.position(); 2740 2741 // Make the tab active. 2742 $active.addClass('active'); 2743 prev_index = index; 2744 index = $links.index($(this)); 2745 if (index < 0) { 2746 index = 0; 2747 } 2748 // Change url to current tab 2749 // window.location.hash = $active.attr('href'); 2750 2751 // Swap content 2752 if (options.swipeable) { 2753 if ($tabs_content.length) { 2754 $tabs_content.carousel('set', index, function () { 2755 if (typeof options.onShow === "function") { 2756 options.onShow.call($this[0], $content); 2757 } 2758 }); 2759 } 2760 } else { 2761 if ($content !== undefined) { 2762 $content.show(); 2763 $content.addClass('active'); 2764 if (typeof options.onShow === "function") { 2765 options.onShow.call(this, $content); 2766 } 2767 } 2768 2769 if ($oldContent !== undefined && !$oldContent.is($content)) { 2770 $oldContent.hide(); 2771 $oldContent.removeClass('active'); 2772 } 2773 } 2774 2775 // Reset clicked state 2776 clickedTimeout = setTimeout(function () { 2777 clicked = false; 2778 }, transition); 2779 2780 // Update indicator 2781 animateIndicator(prev_index); 2782 2783 // Prevent the anchor's default click action 2784 e.preventDefault(); 2785 }); 2786 }); 2787 }, 2788 select_tab: function (id) { 2789 this.find('a[href="#' + id + '"]').trigger('click'); 2790 } 2791 }; 2792 2793 $.fn.tabs = function (methodOrOptions) { 2794 if (methods[methodOrOptions]) { 2795 return methods[methodOrOptions].apply(this, Array.prototype.slice.call(arguments, 1)); 2796 } else if (typeof methodOrOptions === 'object' || !methodOrOptions) { 2797 // Default to "init" 2798 return methods.init.apply(this, arguments); 2799 } else { 2800 $.error('Method ' + methodOrOptions + ' does not exist on jQuery.tabs'); 2801 } 2802 }; 2803 2804 $(document).ready(function () { 2805 $('ul.tabs').tabs(); 2806 }); 2807})(jQuery); 2808;(function ($) { 2809 $.fn.tooltip = function (options) { 2810 var timeout = null, 2811 margin = 5; 2812 2813 // Defaults 2814 var defaults = { 2815 delay: 350, 2816 tooltip: '', 2817 position: 'bottom', 2818 html: false 2819 }; 2820 2821 // Remove tooltip from the activator
2822 if (options === "remove") { 2823 this.each(function () { 2824 $('#' + $(this).attr('data-tooltip-id')).remove(); 2825 $(this).removeAttr('data-tooltip-id'); 2826 $(this).off('mouseenter.tooltip mouseleave.tooltip'); 2827 }); 2828 return false; 2829 } 2830 2831 options = $.extend(defaults, options); 2832 2833 return this.each(function () { 2834 var tooltipId = Materialize.guid(); 2835 var origin = $(this); 2836 2837 // Destroy old tooltip 2838 if (origin.attr('data-tooltip-id')) { 2839 $('#' + origin.attr('data-tooltip-id')).remove(); 2840 } 2841 2842 origin.attr('data-tooltip-id', tooltipId); 2843 2844 // Get attributes. 2845 var allowHtml, tooltipDelay, tooltipPosition, tooltipText, tooltipEl, backdrop; 2846 var setAttributes = function () { 2847 allowHtml = origin.attr('data-html') ? origin.attr('data-html') === 'true' : options.html; 2848 tooltipDelay = origin.attr('data-delay'); 2849 tooltipDelay = tooltipDelay === undefined || tooltipDelay === '' ? options.delay : tooltipDelay; 2850 tooltipPosition = origin.attr('data-position'); 2851 tooltipPosition = tooltipPosition === undefined || tooltipPosition === '' ? options.position : tooltipPosition; 2852 tooltipText = origin.attr('data-tooltip'); 2853 tooltipText = tooltipText === undefined || tooltipText === '' ? options.tooltip : tooltipText; 2854 }; 2855 setAttributes(); 2856 2857 var renderTooltipEl = function () { 2858 var tooltip = $('<div class="material-tooltip"></div>'); 2859 2860 // Create Text span 2861 if (allowHtml) { 2862 tooltipText = $('<span></span>').html(tooltipText); 2863 } else { 2864 tooltipText = $('<span></span>').text(tooltipText); 2865 } 2866 2867 // Create tooltip 2868 tooltip.append(tooltipText).appendTo($('body')).attr('id', tooltipId); 2869 2870 // Create backdrop 2871 backdrop = $('<div class="backdrop"></div>'); 2872 backdrop.appendTo(tooltip); 2873 return tooltip; 2874 }; 2875 tooltipEl = renderTooltipEl(); 2876 2877 // Destroy previously binded events 2878 origin.off('mouseenter.tooltip mouseleave.tooltip'); 2879 // Mouse In 2880 var started = false, 2881 timeoutRef; 2882 origin.on({ 'mouseenter.tooltip': function (e) { 2883 var showTooltip = function () { 2884 setAttributes(); 2885 started = true; 2886 tooltipEl.velocity('stop'); 2887 backdrop.velocity('stop'); 2888 tooltipEl.css({ visibility: 'visible', left: '0px', top: '0px' }); 2889 2890 // Tooltip positioning 2891 var originWidth = origin.outerWidth(); 2892 var originHeight = origin.outerHeight(); 2893 var tooltipHeight = tooltipEl.outerHeight(); 2894 var tooltipWidth = tooltipEl.outerWidth(); 2895 var tooltipVerticalMovement = '0px'; 2896 var tooltipHorizontalMovement = '0px'; 2897 var backdropOffsetWidth = backdrop[0].offsetWidth; 2898 var backdropOffsetHeight = backdrop[0].offsetHeight; 2899 var scaleXFactor = 8; 2900 var scaleYFactor = 8; 2901 var scaleFactor = 0; 2902 var targetTop, targetLeft, newCoordinates; 2903 2904 if (tooltipPosition === "top") { 2905 // Top Position 2906 targetTop = origin.offset().top - tooltipHeight - margin; 2907 targetLeft = origin.offset().left + originWidth / 2 - tooltipWidth / 2; 2908 newCoordinates = repositionWithinScreen(targetLeft, targetTop, tooltipWidth, tooltipHeight); 2909 tooltipVerticalMovement = '-10px'; 2910 backdrop.css({ 2911 bottom: 0, 2912 left: 0, 2913 borderRadius: '14px 14px 0 0', 2914 transformOrigin: '50% 100%', 2915 marginTop: tooltipHeight, 2916 marginLeft: tooltipWidth / 2 - backdropOffsetWidth / 2 2917 }); 2918 } 2919 // Left Position 2920 else if (tooltipPosition === "left") { 2921 targetTop = origin.offset().top + originHeight / 2 - tooltipHeight / 2; 2922 targetLeft = origin.offset().left - tooltipWidth - margin; 2923 newCoordinates = repositionWithinScreen(targetLeft, targetTop, tooltipWidth, tooltipHeight); 2924 2925 tooltipHorizontalMovement = '-10px'; 2926 backdrop.css({ 2927 top: '-7px', 2928 right: 0, 2929 width: '14px', 2930 height: '14px', 2931 borderRadius: '14px 0 0 14px', 2932 transformOrigin: '95% 50%', 2933 marginTop: tooltipHeight / 2, 2934 marginLeft: tooltipWidth 2935 }); 2936 } 2937 // Right Position 2938 else if (tooltipPosition === "right") { 2939 targetTop = origin.offset().top + originHeight / 2 - tooltipHeight / 2; 2940 targetLeft = origin.offset().left + originWidth + margin; 2941 newCoordinates = repositionWithinScreen(targetLeft, targetTop, tooltipWidth, tooltipHeight); 2942 2943 tooltipHorizontalMovement = '+10px'; 2944 backdrop.css({ 2945 top: '-7px', 2946 left: 0, 2947 width: '14px', 2948 height: '14px', 2949 borderRadius: '0 14px 14px 0', 2950 transformOrigin: '5% 50%', 2951 marginTop: tooltipHeight / 2, 2952 marginLeft: '0px' 2953 }); 2954 } else { 2955 // Bottom Position 2956 targetTop = origin.offset().top + origin.outerHeight() + margin; 2957 targetLeft = origin.offset().left + originWidth / 2 - tooltipWidth / 2; 2958 newCoordinates = repositionWithinScreen(targetLeft, targetTop, tooltipWidth, tooltipHeight); 2959 tooltipVerticalMovement = '+10px'; 2960 backdrop.css({ 2961 top: 0, 2962 left: 0, 2963 marginLeft: tooltipWidth / 2 - backdropOffsetWidth / 2 2964 }); 2965 } 2966 2967 // Set tooptip css placement 2968 tooltipEl.css({ 2969 top: newCoordinates.y, 2970 left: newCoordinates.x 2971 }); 2972 2973 // Calculate Scale to fill 2974 scaleXFactor = Math.SQRT2 * tooltipWidth / parseInt(backdropOffsetWidth); 2975 scaleYFactor = Math.SQRT2 * tooltipHeight / parseInt(backdropOffsetHeight); 2976 scaleFactor = Math.max(scaleXFactor, scaleYFactor); 2977 2978 tooltipEl.velocity({ translateY: tooltipVerticalMovement, translateX: tooltipHorizontalMovement }, { duration: 350, queue: false }).velocity({ opacity: 1 }, { duration: 300, delay: 50, queue: false }); 2979 backdrop.css({ visibility: 'visible' }).velocity({ opacity: 1 }, { duration: 55, delay: 0, queue: false }).velocity({ scaleX: scaleFactor, scaleY: scaleFactor }, { duration: 300, delay: 0, queue: false, easing: 'easeInOutQuad' }); 2980 }; 2981 2982 timeoutRef = setTimeout(showTooltip, tooltipDelay); // End Interval 2983 2984 // Mouse Out 2985 }, 2986 'mouseleave.tooltip': function () { 2987 // Reset State 2988 started = false;
2989 clearTimeout(timeoutRef); 2990 2991 // Animate back 2992 setTimeout(function () { 2993 if (started !== true) { 2994 tooltipEl.velocity({ 2995 opacity: 0, translateY: 0, translateX: 0 }, { duration: 225, queue: false }); 2996 backdrop.velocity({ opacity: 0, scaleX: 1, scaleY: 1 }, { 2997 duration: 225, 2998 queue: false, 2999 complete: function () { 3000 backdrop.css({ visibility: 'hidden' }); 3001 tooltipEl.css({ visibility: 'hidden' }); 3002 started = false; 3003 } 3004 }); 3005 } 3006 }, 225); 3007 } 3008 }); 3009 }); 3010 }; 3011 3012 var repositionWithinScreen = function (x, y, width, height) { 3013 var newX = x; 3014 var newY = y; 3015 3016 if (newX < 0) { 3017 newX = 4; 3018 } else if (newX + width > window.innerWidth) { 3019 newX -= newX + width - window.innerWidth; 3020 } 3021 3022 if (newY < 0) { 3023 newY = 4; 3024 } else if (newY + height > window.innerHeight + $(window).scrollTop) { 3025 newY -= newY + height - window.innerHeight; 3026 } 3027 3028 return { x: newX, y: newY }; 3029 }; 3030 3031 $(document).ready(function () { 3032 $('.tooltipped').tooltip(); 3033 }); 3034})(jQuery); 3035; /*! 3036 * Waves v0.6.4 3037 * http://fian.my.id/Waves 3038 * 3039 * Copyright 2014 Alfiana E. Sibuea and other contributors 3040 * Released under the MIT license 3041 * https://github.com/fians/Waves/blob/master/LICENSE 3042 */ 3043 3044;(function (window) { 3045 'use strict'; 3046 3047 var Waves = Waves || {}; 3048 var $$ = document.querySelectorAll.bind(document); 3049 3050 // Find exact position of element 3051 function isWindow(obj) { 3052 return obj !== null && obj === obj.window; 3053 } 3054 3055 function getWindow(elem) { 3056 return isWindow(elem) ? elem : elem.nodeType === 9 && elem.defaultView; 3057 } 3058 3059 function offset(elem) { 3060 var docElem, 3061 win, 3062 box = { top: 0, left: 0 }, 3063 doc = elem && elem.ownerDocument; 3064 3065 docElem = doc.documentElement; 3066 3067 if (typeof elem.getBoundingClientRect !== typeof undefined) { 3068 box = elem.getBoundingClientRect(); 3069 } 3070 win = getWindow(doc); 3071 return { 3072 top: box.top + win.pageYOffset - docElem.clientTop, 3073 left: box.left + win.pageXOffset - docElem.clientLeft 3074 }; 3075 } 3076 3077 function convertStyle(obj) { 3078 var style = ''; 3079 3080 for (var a in obj) { 3081 if (obj.hasOwnProperty(a)) { 3082 style += a + ':' + obj[a] + ';'; 3083 } 3084 } 3085 3086 return style; 3087 } 3088 3089 var Effect = { 3090 3091 // Effect delay 3092 duration: 750, 3093 3094 show: function (e, element) { 3095 3096 // Disable right click 3097 if (e.button === 2) { 3098 return false; 3099 } 3100 3101 var el = element || this; 3102 3103 // Create ripple 3104 var ripple = document.createElement('div'); 3105 ripple.className = 'waves-ripple'; 3106 el.appendChild(ripple); 3107 3108 // Get click coordinate and element witdh 3109 var pos = offset(el); 3110 var relativeY = e.pageY - pos.top; 3111 var relativeX = e.pageX - pos.left; 3112 var scale = 'scale(' + el.clientWidth / 100 * 10 + ')'; 3113 3114 // Support for touch devices 3115 if ('touches' in e) { 3116 relativeY = e.touches[0].pageY - pos.top; 3117 relativeX = e.touches[0].pageX - pos.left; 3118 } 3119 3120 // Attach data to element 3121 ripple.setAttribute('data-hold', Date.now()); 3122 ripple.setAttribute('data-scale', scale); 3123 ripple.setAttribute('data-x', relativeX); 3124 ripple.setAttribute('data-y', relativeY); 3125 3126 // Set ripple position 3127 var rippleStyle = { 3128 'top': relativeY + 'px', 3129 'left': relativeX + 'px' 3130 }; 3131 3132 ripple.className = ripple.className + ' waves-notransition'; 3133 ripple.setAttribute('style', convertStyle(rippleStyle)); 3134 ripple.className = ripple.className.replace('waves-notransition', ''); 3135 3136 // Scale the ripple 3137 rippleStyle['-webkit-transform'] = scale; 3138 rippleStyle['-moz-transform'] = scale; 3139 rippleStyle['-ms-transform'] = scale;
3140 rippleStyle['-o-transform'] = scale; 3141 rippleStyle.transform = scale; 3142 rippleStyle.opacity = '1'; 3143 3144 rippleStyle['-webkit-transition-duration'] = Effect.duration + 'ms'; 3145 rippleStyle['-moz-transition-duration'] = Effect.duration + 'ms'; 3146 rippleStyle['-o-transition-duration'] = Effect.duration + 'ms'; 3147 rippleStyle['transition-duration'] = Effect.duration + 'ms'; 3148 3149 rippleStyle['-webkit-transition-timing-function'] = 'cubic-bezier(0.250, 0.460, 0.450, 0.940)'; 3150 rippleStyle['-moz-transition-timing-function'] = 'cubic-bezier(0.250, 0.460, 0.450, 0.940)'; 3151 rippleStyle['-o-transition-timing-function'] = 'cubic-bezier(0.250, 0.460, 0.450, 0.940)'; 3152 rippleStyle['transition-timing-function'] = 'cubic-bezier(0.250, 0.460, 0.450, 0.940)'; 3153 3154 ripple.setAttribute('style', convertStyle(rippleStyle)); 3155 }, 3156 3157 hide: function (e) { 3158 TouchHandler.touchup(e); 3159 3160 var el = this; 3161 var width = el.clientWidth * 1.4; 3162 3163 // Get first ripple 3164 var ripple = null; 3165 var ripples = el.getElementsByClassName('waves-ripple'); 3166 if (ripples.length > 0) { 3167 ripple = ripples[ripples.length - 1]; 3168 } else { 3169 return false; 3170 } 3171 3172 var relativeX = ripple.getAttribute('data-x'); 3173 var relativeY = ripple.getAttribute('data-y'); 3174 var scale = ripple.getAttribute('data-scale'); 3175 3176 // Get delay beetween mousedown and mouse leave 3177 var diff = Date.now() - Number(ripple.getAttribute('data-hold')); 3178 var delay = 350 - diff; 3179 3180 if (delay < 0) { 3181 delay = 0; 3182 } 3183 3184 // Fade out ripple after delay 3185 setTimeout(function () { 3186 var style = { 3187 'top': relativeY + 'px', 3188 'left': relativeX + 'px', 3189 'opacity': '0', 3190 3191 // Duration 3192 '-webkit-transition-duration': Effect.duration + 'ms', 3193 '-moz-transition-duration': Effect.duration + 'ms', 3194 '-o-transition-duration': Effect.duration + 'ms', 3195 'transition-duration': Effect.duration + 'ms', 3196 '-webkit-transform': scale, 3197 '-moz-transform': scale, 3198 '-ms-transform': scale, 3199 '-o-transform': scale, 3200 'transform': scale 3201 }; 3202 3203 ripple.setAttribute('style', convertStyle(style)); 3204 3205 setTimeout(function () { 3206 try { 3207 el.removeChild(ripple); 3208 } catch (e) { 3209 return false; 3210 } 3211 }, Effect.duration); 3212 }, delay); 3213 }, 3214 3215 // Little hack to make <input> can perform waves effect 3216 wrapInput: function (elements) { 3217 for (var a = 0; a < elements.length; a++) { 3218 var el = elements[a]; 3219 3220 if (el.tagName.toLowerCase() === 'input') { 3221 var parent = el.parentNode; 3222 3223 // If input already have parent just pass through 3224 if (parent.tagName.toLowerCase() === 'i' && parent.className.indexOf('waves-effect') !== -1) { 3225 continue; 3226 } 3227 3228 // Put element class and style to the specified parent 3229 var wrapper = document.createElement('i'); 3230 wrapper.className = el.className + ' waves-input-wrapper'; 3231 3232 var elementStyle = el.getAttribute('style'); 3233 3234 if (!elementStyle) { 3235 elementStyle = ''; 3236 } 3237 3238 wrapper.setAttribute('style', elementStyle); 3239 3240 el.className = 'waves-button-input'; 3241 el.removeAttribute('style'); 3242 3243 // Put element as child 3244 parent.replaceChild(wrapper, el); 3245 wrapper.appendChild(el); 3246 } 3247 } 3248 } 3249 }; 3250 3251 /** 3252 * Disable mousedown event for 500ms during and after touch 3253 */ 3254 var TouchHandler = { 3255 /* uses an integer rather than bool so there's no issues with 3256 * needing to clear timeouts if another touch event occurred 3257 * within the 500ms. Cannot mouseup between touchstart and 3258 * touchend, nor in the 500ms after touchend. */ 3259 touches: 0, 3260 allowEvent: function (e) { 3261 var allow = true; 3262 3263 if (e.type === 'touchstart') { 3264 TouchHandler.touches += 1; //push 3265 } else if (e.type === 'touchend' || e.type === 'touchcancel') { 3266 setTimeout(function () { 3267 if (TouchHandler.touches > 0) { 3268 TouchHandler.touches -= 1; //pop after 500ms 3269 } 3270 }, 500); 3271 } else if (e.type === 'mousedown' && TouchHandler.touches > 0) { 3272 allow = false;
3273 } 3274 3275 return allow; 3276 }, 3277 touchup: function (e) { 3278 TouchHandler.allowEvent(e); 3279 } 3280 }; 3281 3282 /** 3283 * Delegated click handler for .waves-effect element. 3284 * returns null when .waves-effect element not in "click tree" 3285 */ 3286 function getWavesEffectElement(e) { 3287 if (TouchHandler.allowEvent(e) === false) { 3288 return null; 3289 } 3290 3291 var element = null; 3292 var target = e.target || e.srcElement; 3293 3294 while (target.parentNode !== null) { 3295 if (!(target instanceof SVGElement) && target.className.indexOf('waves-effect') !== -1) { 3296 element = target; 3297 break; 3298 } 3299 target = target.parentNode; 3300 } 3301 return element; 3302 } 3303 3304 /** 3305 * Bubble the click and show effect if .waves-effect elem was found 3306 */ 3307 function showEffect(e) { 3308 var element = getWavesEffectElement(e); 3309 3310 if (element !== null) { 3311 Effect.show(e, element); 3312 3313 if ('ontouchstart' in window) { 3314 element.addEventListener('touchend', Effect.hide, false); 3315 element.addEventListener('touchcancel', Effect.hide, false); 3316 } 3317 3318 element.addEventListener('mouseup', Effect.hide, false); 3319 element.addEventListener('mouseleave', Effect.hide, false); 3320 element.addEventListener('dragend', Effect.hide, false); 3321 } 3322 } 3323 3324 Waves.displayEffect = function (options) { 3325 options = options || {}; 3326 3327 if ('duration' in options) { 3328 Effect.duration = options.duration; 3329 } 3330 3331 //Wrap input inside <i> tag 3332 Effect.wrapInput($$('.waves-effect')); 3333 3334 if ('ontouchstart' in window) { 3335 document.body.addEventListener('touchstart', showEffect, false); 3336 } 3337 3338 document.body.addEventListener('mousedown', showEffect, false); 3339 }; 3340 3341 /** 3342 * Attach Waves to an input element (or any element which doesn't 3343 * bubble mouseup/mousedown events). 3344 * Intended to be used with dynamically loaded forms/inputs, or 3345 * where the user doesn't want a delegated click handler. 3346 */ 3347 Waves.attach = function (element) { 3348 //FUTURE: automatically add waves classes and allow users 3349 // to specify them with an options param? Eg. light/classic/button 3350 if (element.tagName.toLowerCase() === 'input') { 3351 Effect.wrapInput([element]); 3352 element = element.parentNode; 3353 } 3354 3355 if ('ontouchstart' in window) { 3356 element.addEventListener('touchstart', showEffect, false); 3357 } 3358 3359 element.addEventListener('mousedown', showEffect, false); 3360 }; 3361 3362 window.Waves = Waves; 3363 3364 document.addEventListener('DOMContentLoaded', function () { 3365 Waves.displayEffect(); 3366 }, false); 3367})(window); 3368;(function ($) { 3369 'use strict'; 3370 3371 var _defaults = { 3372 displayLength: Infinity, 3373 inDuration: 300, 3374 outDuration: 375, 3375 className: undefined, 3376 completeCallback: undefined, 3377 activationPercent: 0.8 3378 }; 3379 3380 var Toast = function () { 3381 function Toast(message, displayLength, className, completeCallback) { 3382 _classCallCheck(this, Toast); 3383 3384 if (!message) { 3385 return; 3386 } 3387 3388 /** 3389 * Options for the toast 3390 * @member Toast#options 3391 */ 3392 this.options = { 3393 displayLength: displayLength, 3394 className: className, 3395 completeCallback: completeCallback 3396 }; 3397 3398 this.options = $.extend({}, Toast.defaults, this.options); 3399 this.message = message; 3400 3401 /** 3402 * Describes current pan state toast 3403 * @type {Boolean} 3404 */ 3405 this.panning = false; 3406 3407 /** 3408 * Time remaining until toast is removed 3409 */ 3410 this.timeRemaining = this.options.displayLength; 3411 3412 if (Toast._toasts.length === 0) { 3413 Toast._createContainer(); 3414 } 3415 3416 // Create new toast 3417 Toast._toasts.push(this); 3418 var toastElement = this.createToast(); 3419 toastElement.M_Toast = this; 3420 this.el = toastElement; 3421 this._animateIn(); 3422 this.setTimer(); 3423 } 3424 3425 _createClass(Toast, [{ 3426 key: 'createToast', 3427 3428 3429 /** 3430 * Create toast and append it to toast container 3431 */ 3432 value: function createToast() { 3433 var toast = document.createElement('div'); 3434 toast.classList.add('toast'); 3435 3436 // Add custom classes onto toast 3437 if (this.options.className) { 3438 var classes = this.options.className.split(' '); 3439 var i = void 0, 3440 count = void 0; 3441 for (i = 0, count = classes.length; i < count; i++) { 3442 toast.classList.add(classes[i]); 3443 } 3444 } 3445 3446 // Set content 3447 if (typeof HTMLElement === 'object' ? this.message instanceof HTMLElement : this.message && typeof this.message === 'object' && this.message !== null && this.message.nodeType === 1 && typeof this.message.nodeName === 'string') { 3448 toast.appendChild(this.message); 3449 3450 // Check if it is jQuery object 3451 } else if (this.message instanceof jQuery) { 3452 $(toast).append(this.message); 3453 3454 // Insert as text; 3455 } else { 3456 toast.innerHTML = this.message; 3457 } 3458 3459 // Append toasft 3460 Toast._container.appendChild(toast); 3461 return toast; 3462 } 3463 3464 /** 3465 * Animate in toast 3466 */ 3467 3468 }, {
3469 key: '_animateIn', 3470 value: function _animateIn() { 3471 // Animate toast in 3472 Vel(this.el, { top: 0, opacity: 1 }, { 3473 duration: 300, 3474 easing: 'easeOutCubic', 3475 queue: false 3476 }); 3477 } 3478 3479 /** 3480 * Create setInterval which automatically removes toast when timeRemaining >= 0 3481 * has been reached 3482 */ 3483 3484 }, { 3485 key: 'setTimer', 3486 value: function setTimer() { 3487 var _this3 = this; 3488 3489 if (this.timeRemaining !== Infinity) { 3490 this.counterInterval = setInterval(function () { 3491 // If toast is not being dragged, decrease its time remaining 3492 if (!_this3.panning) { 3493 _this3.timeRemaining -= 20; 3494 } 3495 3496 // Animate toast out 3497 if (_this3.timeRemaining <= 0) { 3498 _this3.remove(); 3499 } 3500 }, 20); 3501 } 3502 } 3503 3504 /** 3505 * Dismiss toast with animation 3506 */ 3507 3508 }, { 3509 key: 'remove', 3510 value: function remove() { 3511 var _this4 = this; 3512 3513 window.clearInterval(this.counterInterval); 3514 var activationDistance = this.el.offsetWidth * this.options.activationPercent; 3515 3516 if (this.wasSwiped) { 3517 this.el.style.transition = 'transform .05s, opacity .05s'; 3518 this.el.style.transform = 'translateX(' + activationDistance + 'px)'; 3519 this.el.style.opacity = 0; 3520 } 3521 3522 Vel(this.el, { opacity: 0, marginTop: '-40px' }, { 3523 duration: this.options.outDuration, 3524 easing: 'easeOutExpo', 3525 queue: false, 3526 complete: function () { 3527 // Call the optional callback 3528 if (typeof _this4.options.completeCallback === 'function') { 3529 _this4.options.completeCallback(); 3530 } 3531 // Remove toast from DOM 3532 _this4.el.parentNode.removeChild(_this4.el); 3533 Toast._toasts.splice(Toast._toasts.indexOf(_this4), 1); 3534 if (Toast._toasts.length === 0) { 3535 Toast._removeContainer(); 3536 } 3537 } 3538 }); 3539 } 3540 }], [{ 3541 key: '_createContainer', 3542 3543 3544 /** 3545 * Append toast container and add event handlers 3546 */ 3547 value: function _createContainer() { 3548 var container = document.createElement('div'); 3549 container.setAttribute('id', 'toast-container'); 3550 3551 // Add event handler 3552 container.addEventListener('touchstart', Toast._onDragStart); 3553 container.addEventListener('touchmove', Toast._onDragMove); 3554 container.addEventListener('touchend', Toast._onDragEnd); 3555 3556 container.addEventListener('mousedown', Toast._onDragStart); 3557 document.addEventListener('mousemove', Toast._onDragMove); 3558 document.addEventListener('mouseup', Toast._onDragEnd); 3559 3560 document.body.appendChild(container); 3561 Toast._container = container; 3562 } 3563 3564 /** 3565 * Remove toast container and event handlers 3566 */ 3567 3568 }, { 3569 key: '_removeContainer', 3570 value: function _removeContainer() { 3571 // Add event handler 3572 document.removeEventListener('mousemove', Toast._onDragMove); 3573 document.removeEventListener('mouseup', Toast._onDragEnd); 3574 3575 Toast._container.parentNode.removeChild(Toast._container); 3576 Toast._container = null; 3577 } 3578 3579 /** 3580 * Begin drag handler 3581 * @param {Event} e 3582 */ 3583 3584 }, { 3585 key: '_onDragStart', 3586 value: function _onDragStart(e) { 3587 if (e.target && $(e.target).closest('.toast').length) { 3588 var $toast = $(e.target).closest('.toast'); 3589 var toast = $toast[0].M_Toast; 3590 toast.panning = true; 3591 Toast._draggedToast = toast; 3592 toast.el.classList.add('panning'); 3593 toast.el.style.transition = null; 3594 toast.startingXPos = Toast._xPos(e); 3595 toast.time = Date.now(); 3596 toast.xPos = Toast._xPos(e); 3597 } 3598 } 3599 3600 /** 3601 * Drag move handler 3602 * @param {Event} e 3603 */ 3604 3605 }, { 3606 key: '_onDragMove', 3607 value: function _onDragMove(e) { 3608 if (!!Toast._draggedToast) { 3609 e.preventDefault(); 3610 var toast = Toast._draggedToast; 3611 toast.deltaX = Math.abs(toast.xPos - Toast._xPos(e)); 3612 toast.xPos = Toast._xPos(e); 3613 toast.velocityX = toast.deltaX / (Date.now() - toast.time); 3614 toast.time = Date.now(); 3615 3616 var totalDeltaX = toast.xPos - toast.startingXPos; 3617 var activationDistance = toast.el.offsetWidth * toast.options.activationPercent; 3618 toast.el.style.transform = 'translateX(' + totalDeltaX + 'px)'; 3619 toast.el.style.opacity = 1 - Math.abs(totalDeltaX / activationDistance); 3620 } 3621 } 3622 3623 /** 3624 * End drag handler 3625 * @param {Event} e 3626 */ 3627 3628 }, {
3629 key: '_onDragEnd', 3630 value: function _onDragEnd(e) { 3631 if (!!Toast._draggedToast) { 3632 var toast = Toast._draggedToast; 3633 toast.panning = false; 3634 toast.el.classList.remove('panning'); 3635 3636 var totalDeltaX = toast.xPos - toast.startingXPos; 3637 var activationDistance = toast.el.offsetWidth * toast.options.activationPercent; 3638 var shouldBeDismissed = Math.abs(totalDeltaX) > activationDistance || toast.velocityX > 1; 3639 3640 // Remove toast 3641 if (shouldBeDismissed) { 3642 toast.wasSwiped = true; 3643 toast.remove(); 3644 3645 // Animate toast back to original position 3646 } else { 3647 toast.el.style.transition = 'transform .2s, opacity .2s'; 3648 toast.el.style.transform = null; 3649 toast.el.style.opacity = null; 3650 } 3651 Toast._draggedToast = null; 3652 } 3653 } 3654 3655 /** 3656 * Get x position of mouse or touch event 3657 * @param {Event} e 3658 */ 3659 3660 }, { 3661 key: '_xPos', 3662 value: function _xPos(e) { 3663 if (e.targetTouches && e.targetTouches.length >= 1) { 3664 return e.targetTouches[0].clientX; 3665 } 3666 // mouse event 3667 return e.clientX; 3668 } 3669 3670 /** 3671 * Remove all toasts 3672 */ 3673 3674 }, { 3675 key: 'removeAll', 3676 value: function removeAll() { 3677 for (var toastIndex in Toast._toasts) { 3678 Toast._toasts[toastIndex].remove(); 3679 } 3680 } 3681 }, { 3682 key: 'defaults', 3683 get: function () { 3684 return _defaults; 3685 } 3686 }]); 3687 3688 return Toast; 3689 }(); 3690 3691 /** 3692 * @static 3693 * @memberof Toast 3694 * @type {Array.<Toast>} 3695 */ 3696 3697 3698 Toast._toasts = []; 3699 3700 /** 3701 * @static 3702 * @memberof Toast 3703 */ 3704 Toast._container = null; 3705 3706 /** 3707 * @static 3708 * @memberof Toast 3709 * @type {Toast} 3710 */ 3711 Toast._draggedToast = null; 3712 3713 window.Materialize.Toast = Toast; 3714 window.Materialize.toast = function (message, displayLength, className, completeCallback) { 3715 return new Toast(message, displayLength, className, completeCallback); 3716 }; 3717})(jQuery); 3718;(function ($) { 3719 3720 var methods = { 3721 init: function (options) { 3722 var defaults = { 3723 menuWidth: 300, 3724 edge: 'left', 3725 closeOnClick: false, 3726 draggable: true, 3727 onOpen: null, 3728 onClose: null 3729 }; 3730 options = $.extend(defaults, options); 3731 3732 $(this).each(function () { 3733 var $this = $(this); 3734 var menuId = $this.attr('data-activates'); 3735 var menu = $("#" + menuId); 3736 3737 // Set to width 3738 if (options.menuWidth != 300) { 3739 menu.css('width', options.menuWidth); 3740 } 3741 3742 // Add Touch Area 3743 var $dragTarget = $('.drag-target[data-sidenav="' + menuId + '"]'); 3744 if (options.draggable) { 3745 // Regenerate dragTarget 3746 if ($dragTarget.length) { 3747 $dragTarget.remove(); 3748 } 3749 3750 $dragTarget = $('<div class="drag-target"></div>').attr('data-sidenav', menuId); 3751 $('body').append($dragTarget); 3752 } else { 3753 $dragTarget = $(); 3754 } 3755 3756 if (options.edge == 'left') { 3757 menu.css('transform', 'translateX(-100%)'); 3758 $dragTarget.css({ 'left': 0 }); // Add Touch Area 3759 } else { 3760 menu.addClass('right-aligned') // Change text-alignment to right 3761 .css('transform', 'translateX(100%)'); 3762 $dragTarget.css({ 'right': 0 }); // Add Touch Area 3763 } 3764 3765 // If fixed sidenav, bring menu out 3766 if (menu.hasClass('fixed')) { 3767 if (window.innerWidth > 992) { 3768 menu.css('transform', 'translateX(0)'); 3769 } 3770 } 3771 3772 // Window resize to reset on large screens fixed 3773 if (menu.hasClass('fixed')) { 3774 $(window).resize(function () { 3775 if (window.innerWidth > 992) { 3776 // Close menu if window is resized bigger than 992 and user has fixed sidenav 3777 if ($('#sidenav-overlay').length !== 0 && menuOut) { 3778 removeMenu(true); 3779 } else { 3780 // menu.removeAttr('style'); 3781 menu.css('transform', 'translateX(0%)'); 3782 // menu.css('width', options.menuWidth); 3783 } 3784 } else if (menuOut === false) { 3785 if (options.edge === 'left') { 3786 menu.css('transform', 'translateX(-100%)'); 3787 } else { 3788 menu.css('transform', 'translateX(100%)'); 3789 } 3790 } 3791 }); 3792 } 3793 3794 // if closeOnClick, then add close event for all a tags in side sideNav 3795 if (options.closeOnClick === true) { 3796 menu.on("click.itemclick", "a:not(.collapsible-header)", function () { 3797 if (!(window.innerWidth > 992 && menu.hasClass('fixed'))) { 3798 removeMenu(); 3799 } 3800 }); 3801 } 3802 3803 var removeMenu = function (restoreNav) { 3804 panning = false;
3805 menuOut = false; 3806 // Reenable scrolling 3807 $('body').css({ 3808 overflow: '', 3809 width: '' 3810 }); 3811 3812 $('#sidenav-overlay').velocity({ opacity: 0 }, { duration: 200, 3813 queue: false, easing: 'easeOutQuad', 3814 complete: function () { 3815 $(this).remove(); 3816 } }); 3817 if (options.edge === 'left') { 3818 // Reset phantom div 3819 $dragTarget.css({ width: '', right: '', left: '0' }); 3820 menu.velocity({ 'translateX': '-100%' }, { duration: 200, 3821 queue: false, 3822 easing: 'easeOutCubic', 3823 complete: function () { 3824 if (restoreNav === true) { 3825 // Restore Fixed sidenav 3826 menu.removeAttr('style'); 3827 menu.css('width', options.menuWidth); 3828 } 3829 } 3830 3831 }); 3832 } else { 3833 // Reset phantom div 3834 $dragTarget.css({ width: '', right: '0', left: '' }); 3835 menu.velocity({ 'translateX': '100%' }, { duration: 200, 3836 queue: false, 3837 easing: 'easeOutCubic', 3838 complete: function () { 3839 if (restoreNav === true) { 3840 // Restore Fixed sidenav 3841 menu.removeAttr('style'); 3842 menu.css('width', options.menuWidth); 3843 } 3844 } 3845 }); 3846 } 3847 3848 // Callback 3849 if (typeof options.onClose === 'function') { 3850 options.onClose.call(this, menu); 3851 } 3852 }; 3853 3854 // Touch Event 3855 var panning = false; 3856 var menuOut = false;
3857 3858 if (options.draggable) { 3859 $dragTarget.on('click', function () { 3860 if (menuOut) { 3861 removeMenu(); 3862 } 3863 }); 3864 3865 $dragTarget.hammer({ 3866 prevent_default: false 3867 }).on('pan', function (e) { 3868 3869 if (e.gesture.pointerType == "touch") { 3870 3871 var direction = e.gesture.direction; 3872 var x = e.gesture.center.x; 3873 var y = e.gesture.center.y; 3874 var velocityX = e.gesture.velocityX; 3875 3876 // Vertical scroll bugfix 3877 if (x === 0 && y === 0) { 3878 return; 3879 } 3880 3881 // Disable Scrolling 3882 var $body = $('body'); 3883 var $overlay = $('#sidenav-overlay'); 3884 var oldWidth = $body.innerWidth(); 3885 $body.css('overflow', 'hidden'); 3886 $body.width(oldWidth); 3887 3888 // If overlay does not exist, create one and if it is clicked, close menu 3889 if ($overlay.length === 0) { 3890 $overlay = $('<div id="sidenav-overlay"></div>'); 3891 $overlay.css('opacity', 0).click(function () { 3892 removeMenu(); 3893 }); 3894 3895 // Run 'onOpen' when sidenav is opened via touch/swipe if applicable 3896 if (typeof options.onOpen === 'function') { 3897 options.onOpen.call(this, menu); 3898 } 3899 3900 $('body').append($overlay); 3901 } 3902 3903 // Keep within boundaries 3904 if (options.edge === 'left') { 3905 if (x > options.menuWidth) { 3906 x = options.menuWidth; 3907 } else if (x < 0) { 3908 x = 0; 3909 } 3910 } 3911 3912 if (options.edge === 'left') { 3913 // Left Direction 3914 if (x < options.menuWidth / 2) { 3915 menuOut = false;
3916 } 3917 // Right Direction 3918 else if (x >= options.menuWidth / 2) { 3919 menuOut = true; 3920 } 3921 menu.css('transform', 'translateX(' + (x - options.menuWidth) + 'px)'); 3922 } else { 3923 // Left Direction 3924 if (x < window.innerWidth - options.menuWidth / 2) { 3925 menuOut = true; 3926 } 3927 // Right Direction 3928 else if (x >= window.innerWidth - options.menuWidth / 2) { 3929 menuOut = false; 3930 } 3931 var rightPos = x - options.menuWidth / 2; 3932 if (rightPos < 0) { 3933 rightPos = 0; 3934 } 3935 3936 menu.css('transform', 'translateX(' + rightPos + 'px)'); 3937 } 3938 3939 // Percentage overlay 3940 var overlayPerc; 3941 if (options.edge === 'left') { 3942 overlayPerc = x / options.menuWidth; 3943 $overlay.velocity({ opacity: overlayPerc }, { duration: 10, queue: false, easing: 'easeOutQuad' }); 3944 } else { 3945 overlayPerc = Math.abs((x - window.innerWidth) / options.menuWidth); 3946 $overlay.velocity({ opacity: overlayPerc }, { duration: 10, queue: false, easing: 'easeOutQuad' }); 3947 } 3948 } 3949 }).on('panend', function (e) { 3950 3951 if (e.gesture.pointerType == "touch") {
3952 var $overlay = $('#sidenav-overlay'); 3953 var velocityX = e.gesture.velocityX; 3954 var x = e.gesture.center.x; 3955 var leftPos = x - options.menuWidth; 3956 var rightPos = x - options.menuWidth / 2; 3957 if (leftPos > 0) { 3958 leftPos = 0; 3959 } 3960 if (rightPos < 0) { 3961 rightPos = 0; 3962 } 3963 panning = false; 3964 3965 if (options.edge === 'left') { 3966 // If velocityX <= 0.3 then the user is flinging the menu closed so ignore menuOut 3967 if (menuOut && velocityX <= 0.3 || velocityX < -0.5) { 3968 // Return menu to open 3969 if (leftPos !== 0) { 3970 menu.velocity({ 'translateX': [0, leftPos] }, { duration: 300, queue: false, easing: 'easeOutQuad' }); 3971 } 3972 3973 $overlay.velocity({ opacity: 1 }, { duration: 50, queue: false, easing: 'easeOutQuad' }); 3974 $dragTarget.css({ width: '50%', right: 0, left: '' }); 3975 menuOut = true; 3976 } else if (!menuOut || velocityX > 0.3) { 3977 // Enable Scrolling 3978 $('body').css({ 3979 overflow: '', 3980 width: '' 3981 }); 3982 // Slide menu closed 3983 menu.velocity({ 'translateX': [-1 * options.menuWidth - 10, leftPos] }, { duration: 200, queue: false, easing: 'easeOutQuad' }); 3984 $overlay.velocity({ opacity: 0 }, { duration: 200, queue: false, easing: 'easeOutQuad', 3985 complete: function () { 3986 // Run 'onClose' when sidenav is closed via touch/swipe if applicable 3987 if (typeof options.onClose === 'function') { 3988 options.onClose.call(this, menu); 3989 } 3990 3991 $(this).remove(); 3992 } }); 3993 $dragTarget.css({ width: '10px', right: '', left: 0 }); 3994 } 3995 } else { 3996 if (menuOut && velocityX >= -0.3 || velocityX > 0.5) { 3997 // Return menu to open 3998 if (rightPos !== 0) { 3999 menu.velocity({ 'translateX': [0, rightPos] }, { duration: 300, queue: false, easing: 'easeOutQuad' }); 4000 } 4001 4002 $overlay.velocity({ opacity: 1 }, { duration: 50, queue: false, easing: 'easeOutQuad' }); 4003 $dragTarget.css({ width: '50%', right: '', left: 0 }); 4004 menuOut = true; 4005 } else if (!menuOut || velocityX < -0.3) { 4006 // Enable Scrolling 4007 $('body').css({ 4008 overflow: '', 4009 width: '' 4010 }); 4011 4012 // Slide menu closed 4013 menu.velocity({ 'translateX': [options.menuWidth + 10, rightPos] }, { duration: 200, queue: false, easing: 'easeOutQuad' }); 4014 $overlay.velocity({ opacity: 0 }, { duration: 200, queue: false, easing: 'easeOutQuad', 4015 complete: function () { 4016 // Run 'onClose' when sidenav is closed via touch/swipe if applicable 4017 if (typeof options.onClose === 'function') { 4018 options.onClose.call(this, menu); 4019 } 4020 4021 $(this).remove(); 4022 } }); 4023 $dragTarget.css({ width: '10px', right: 0, left: '' }); 4024 } 4025 } 4026 } 4027 }); 4028 } 4029 4030 $this.off('click.sidenav').on('click.sidenav', function () { 4031 if (menuOut === true) { 4032 menuOut = false;
4033 panning = false; 4034 removeMenu(); 4035 } else { 4036 4037 // Disable Scrolling 4038 var $body = $('body'); 4039 var $overlay = $('<div id="sidenav-overlay"></div>'); 4040 var oldWidth = $body.innerWidth(); 4041 $body.css('overflow', 'hidden'); 4042 $body.width(oldWidth); 4043 4044 // Push current drag target on top of DOM tree 4045 $('body').append($dragTarget); 4046 4047 if (options.edge === 'left') { 4048 $dragTarget.css({ width: '50%', right: 0, left: '' }); 4049 menu.velocity({ 'translateX': [0, -1 * options.menuWidth] }, { duration: 300, queue: false, easing: 'easeOutQuad' }); 4050 } else { 4051 $dragTarget.css({ width: '50%', right: '', left: 0 }); 4052 menu.velocity({ 'translateX': [0, options.menuWidth] }, { duration: 300, queue: false, easing: 'easeOutQuad' }); 4053 } 4054 4055 // Overlay close on click 4056 $overlay.css('opacity', 0).click(function () { 4057 menuOut = false;
4058 panning = false; 4059 removeMenu(); 4060 $overlay.velocity({ opacity: 0 }, { duration: 300, queue: false, easing: 'easeOutQuad', 4061 complete: function () { 4062 $(this).remove(); 4063 } 4064 }); 4065 }); 4066 4067 // Append body 4068 $('body').append($overlay); 4069 $overlay.velocity({ opacity: 1 }, { duration: 300, queue: false, easing: 'easeOutQuad', 4070 complete: function () { 4071 menuOut = true; 4072 panning = false; 4073 } 4074 }); 4075 4076 // Callback 4077 if (typeof options.onOpen === 'function') { 4078 options.onOpen.call(this, menu); 4079 } 4080 } 4081 4082 return false; 4083 }); 4084 }); 4085 }, 4086 destroy: function () { 4087 var $overlay = $('#sidenav-overlay'); 4088 var $dragTarget = $('.drag-target[data-sidenav="' + $(this).attr('data-activates') + '"]'); 4089 $overlay.trigger('click'); 4090 $dragTarget.remove(); 4091 $(this).off('click'); 4092 $overlay.remove(); 4093 }, 4094 show: function () { 4095 this.trigger('click'); 4096 }, 4097 hide: function () { 4098 $('#sidenav-overlay').trigger('click'); 4099 } 4100 }; 4101 4102 $.fn.sideNav = function (methodOrOptions) { 4103 if (methods[methodOrOptions]) { 4104 return methods[methodOrOptions].apply(this, Array.prototype.slice.call(arguments, 1)); 4105 } else if (typeof methodOrOptions === 'object' || !methodOrOptions) { 4106 // Default to "init" 4107 return methods.init.apply(this, arguments); 4108 } else { 4109 $.error('Method ' + methodOrOptions + ' does not exist on jQuery.sideNav'); 4110 } 4111 }; // Plugin end 4112})(jQuery); 4113; /** 4114 * Extend jquery with a scrollspy plugin. 4115 * This watches the window scroll and fires events when elements are scrolled into viewport. 4116 * 4117 * throttle() and getTime() taken from Underscore.js 4118 * https://github.com/jashkenas/underscore 4119 * 4120 * @author Copyright 2013 John Smart 4121 * @license https://raw.github.com/thesmart/jquery-scrollspy/master/LICENSE 4122 * @see https://github.com/thesmart 4123 * @version 0.1.2 4124 */ 4125(function ($) { 4126 4127 var jWindow = $(window); 4128 var elements = []; 4129 var elementsInView = []; 4130 var isSpying = false; 4131 var ticks = 0; 4132 var unique_id = 1; 4133 var offset = { 4134 top: 0, 4135 right: 0, 4136 bottom: 0, 4137 left: 0 4138 4139 /** 4140 * Find elements that are within the boundary 4141 * @param {number} top 4142 * @param {number} right 4143 * @param {number} bottom 4144 * @param {number} left 4145 * @return {jQuery} A collection of elements 4146 */ 4147 };function findElements(top, right, bottom, left) { 4148 var hits = $(); 4149 $.each(elements, function (i, element) { 4150 if (element.height() > 0) { 4151 var elTop = element.offset().top, 4152 elLeft = element.offset().left, 4153 elRight = elLeft + element.width(), 4154 elBottom = elTop + element.height(); 4155 4156 var isIntersect = !(elLeft > right || elRight < left || elTop > bottom || elBottom < top); 4157 4158 if (isIntersect) { 4159 hits.push(element); 4160 } 4161 } 4162 }); 4163 4164 return hits; 4165 } 4166 4167 /** 4168 * Called when the user scrolls the window 4169 */ 4170 function onScroll(scrollOffset) { 4171 // unique tick id 4172 ++ticks; 4173 4174 // viewport rectangle 4175 var top = jWindow.scrollTop(), 4176 left = jWindow.scrollLeft(), 4177 right = left + jWindow.width(), 4178 bottom = top + jWindow.height(); 4179 4180 // determine which elements are in view 4181 var intersections = findElements(top + offset.top + scrollOffset || 200, right + offset.right, bottom + offset.bottom, left + offset.left); 4182 $.each(intersections, function (i, element) { 4183 4184 var lastTick = element.data('scrollSpy:ticks'); 4185 if (typeof lastTick != 'number') { 4186 // entered into view 4187 element.triggerHandler('scrollSpy:enter'); 4188 } 4189 4190 // update tick id 4191 element.data('scrollSpy:ticks', ticks); 4192 }); 4193 4194 // determine which elements are no longer in view 4195 $.each(elementsInView, function (i, element) { 4196 var lastTick = element.data('scrollSpy:ticks'); 4197 if (typeof lastTick == 'number' && lastTick !== ticks) { 4198 // exited from view 4199 element.triggerHandler('scrollSpy:exit'); 4200 element.data('scrollSpy:ticks', null); 4201 } 4202 }); 4203 4204 // remember elements in view for next tick 4205 elementsInView = intersections; 4206 } 4207 4208 /** 4209 * Called when window is resized 4210 */ 4211 function onWinSize() { 4212 jWindow.trigger('scrollSpy:winSize'); 4213 } 4214 4215 /** 4216 * Enables ScrollSpy using a selector 4217 * @param {jQuery|string} selector The elements collection, or a selector 4218 * @param {Object=} options Optional. 4219 throttle : number -> scrollspy throttling. Default: 100 ms 4220 offsetTop : number -> offset from top. Default: 0 4221 offsetRight : number -> offset from right. Default: 0 4222 offsetBottom : number -> offset from bottom. Default: 0 4223 offsetLeft : number -> offset from left. Default: 0 4224 activeClass : string -> Class name to be added to the active link. Default: active 4225 * @returns {jQuery} 4226 */ 4227 $.scrollSpy = function (selector, options) { 4228 var defaults = { 4229 throttle: 100, 4230 scrollOffset: 200, // offset - 200 allows elements near bottom of page to scroll 4231 activeClass: 'active', 4232 getActiveElement: function (id) { 4233 return 'a[href="#' + id + '"]'; 4234 } 4235 }; 4236 options = $.extend(defaults, options); 4237 4238 var visible = []; 4239 selector = $(selector); 4240 selector.each(function (i, element) { 4241 elements.push($(element)); 4242 $(element).data("scrollSpy:id", i); 4243 // Smooth scroll to section 4244 $('a[href="#' + $(element).attr('id') + '"]').click(function (e) { 4245 e.preventDefault(); 4246 var offset = $(Materialize.escapeHash(this.hash)).offset().top + 1; 4247 $('html, body').animate({ scrollTop: offset - options.scrollOffset }, { duration: 400, queue: false, easing: 'easeOutCubic' }); 4248 }); 4249 }); 4250 4251 offset.top = options.offsetTop || 0; 4252 offset.right = options.offsetRight || 0; 4253 offset.bottom = options.offsetBottom || 0; 4254 offset.left = options.offsetLeft || 0; 4255 4256 var throttledScroll = Materialize.throttle(function () { 4257 onScroll(options.scrollOffset); 4258 }, options.throttle || 100); 4259 var readyScroll = function () { 4260 $(document).ready(throttledScroll); 4261 }; 4262 4263 if (!isSpying) { 4264 jWindow.on('scroll', readyScroll); 4265 jWindow.on('resize', readyScroll); 4266 isSpying = true; 4267 } 4268 4269 // perform a scan once, after current execution context, and after dom is ready 4270 setTimeout(readyScroll, 0); 4271 4272 selector.on('scrollSpy:enter', function () { 4273 visible = $.grep(visible, function (value) { 4274 return value.height() != 0; 4275 }); 4276 4277 var $this = $(this); 4278 4279 if (visible[0]) { 4280 $(options.getActiveElement(visible[0].attr('id'))).removeClass(options.activeClass); 4281 if ($this.data('scrollSpy:id') < visible[0].data('scrollSpy:id')) { 4282 visible.unshift($(this)); 4283 } else { 4284 visible.push($(this)); 4285 } 4286 } else { 4287 visible.push($(this)); 4288 } 4289 4290 $(options.getActiveElement(visible[0].attr('id'))).addClass(options.activeClass); 4291 }); 4292 selector.on('scrollSpy:exit', function () { 4293 visible = $.grep(visible, function (value) { 4294 return value.height() != 0; 4295 }); 4296 4297 if (visible[0]) { 4298 $(options.getActiveElement(visible[0].attr('id'))).removeClass(options.activeClass); 4299 var $this = $(this); 4300 visible = $.grep(visible, function (value) { 4301 return value.attr('id') != $this.attr('id'); 4302 }); 4303 if (visible[0]) { 4304 // Check if empty 4305 $(options.getActiveElement(visible[0].attr('id'))).addClass(options.activeClass); 4306 } 4307 } 4308 }); 4309 4310 return selector; 4311 }; 4312 4313 /** 4314 * Listen for window resize events 4315 * @param {Object=} options Optional. Set { throttle: number } to change throttling. Default: 100 ms 4316 * @returns {jQuery} $(window) 4317 */ 4318 $.winSizeSpy = function (options) { 4319 $.winSizeSpy = function () { 4320 return jWindow; 4321 }; // lock from multiple calls 4322 options = options || { 4323 throttle: 100 4324 }; 4325 return jWindow.on('resize', Materialize.throttle(onWinSize, options.throttle || 100)); 4326 }; 4327 4328 /** 4329 * Enables ScrollSpy on a collection of elements 4330 * e.g. $('.scrollSpy').scrollSpy() 4331 * @param {Object=} options Optional. 4332 throttle : number -> scrollspy throttling. Default: 100 ms 4333 offsetTop : number -> offset from top. Default: 0 4334 offsetRight : number -> offset from right. Default: 0 4335 offsetBottom : number -> offset from bottom. Default: 0 4336 offsetLeft : number -> offset from left. Default: 0 4337 * @returns {jQuery} 4338 */ 4339 $.fn.scrollSpy = function (options) { 4340 return $.scrollSpy($(this), options); 4341 }; 4342})(jQuery); 4343;(function ($) { 4344 $(document).ready(function () { 4345 4346 // Function to update labels of text fields 4347 Materialize.updateTextFields = function () { 4348 var input_selector = 'input[type=text], input[type=password], input[type=email], input[type=url], input[type=tel], input[type=number], input[type=search], textarea'; 4349 $(input_selector).each(function (index, element) { 4350 var $this = $(this); 4351 if ($(element).val().length > 0 || $(element).is(':focus') || element.autofocus || $this.attr('placeholder') !== undefined) { 4352 $this.siblings('label').addClass('active'); 4353 } else if ($(element)[0].validity) { 4354 $this.siblings('label').toggleClass('active', $(element)[0].validity.badInput === true); 4355 } else { 4356 $this.siblings('label').removeClass('active'); 4357 } 4358 }); 4359 }; 4360 4361 // Text based inputs 4362 var input_selector = 'input[type=text], input[type=password], input[type=email], input[type=url], input[type=tel], input[type=number], input[type=search], textarea'; 4363 4364 // Add active if form auto complete 4365 $(document).on('change', input_selector, function () { 4366 if ($(this).val().length !== 0 || $(this).attr('placeholder') !== undefined) { 4367 $(this).siblings('label').addClass('active'); 4368 } 4369 validate_field($(this)); 4370 }); 4371 4372 // Add active if input element has been pre-populated on document ready 4373 $(document).ready(function () { 4374 Materialize.updateTextFields(); 4375 }); 4376 4377 // HTML DOM FORM RESET handling 4378 $(document).on('reset', function (e) { 4379 var formReset = $(e.target); 4380 if (formReset.is('form')) { 4381 formReset.find(input_selector).removeClass('valid').removeClass('invalid'); 4382 formReset.find(input_selector).each(function () { 4383 if ($(this).attr('value') === '') { 4384 $(this).siblings('label').removeClass('active'); 4385 } 4386 }); 4387 4388 // Reset select 4389 formReset.find('select.initialized').each(function () { 4390 var reset_text = formReset.find('option[selected]').text(); 4391 formReset.siblings('input.select-dropdown').val(reset_text); 4392 }); 4393 } 4394 }); 4395 4396 // Add active when element has focus 4397 $(document).on('focus', input_selector, function () { 4398 $(this).siblings('label, .prefix').addClass('active'); 4399 }); 4400 4401 $(document).on('blur', input_selector, function () { 4402 var $inputElement = $(this); 4403 var selector = ".prefix"; 4404 4405 if ($inputElement.val().length === 0 && $inputElement[0].validity.badInput !== true && $inputElement.attr('placeholder')
4405=== undefined) { 4406 selector += ", label"; 4407 } 4408 4409 $inputElement.siblings(selector).removeClass('active'); 4410 4411 validate_field($inputElement); 4412 }); 4413 4414 window.validate_field = function (object) { 4415 var hasLength = object.attr('data-length') !== undefined; 4416 var lenAttr = parseInt(object.attr('data-length')); 4417 var len = object.val().length; 4418 4419 if (object.val().length === 0 && object[0].validity.badInput === false && !object.is(':required')) { 4420 if (object.hasClass('validate')) { 4421 object.removeClass('valid'); 4422 object.removeClass('invalid'); 4423 } 4424 } else { 4425 if (object.hasClass('validate')) { 4426 // Check for character counter attributes 4427 if (object.is(':valid') && hasLength && len <= lenAttr || object.is(':valid') && !hasLength) { 4428 object.removeClass('invalid'); 4429 object.addClass('valid'); 4430 } else { 4431 object.removeClass('valid'); 4432 object.addClass('invalid'); 4433 } 4434 } 4435 } 4436 }; 4437 4438 // Radio and Checkbox focus class 4439 var radio_checkbox = 'input[type=radio], input[type=checkbox]'; 4440 $(document).on('keyup.radio', radio_checkbox, function (e) { 4441 // TAB, check if tabbing to radio or checkbox. 4442 if (e.which === 9) { 4443 $(this).addClass('tabbed'); 4444 var $this = $(this); 4445 $this.one('blur', function (e) { 4446 4447 $(this).removeClass('tabbed'); 4448 }); 4449 return; 4450 } 4451 }); 4452 4453 // Textarea Auto Resize 4454 var hiddenDiv = $('.hiddendiv').first(); 4455 if (!hiddenDiv.length) { 4456 hiddenDiv = $('<div class="hiddendiv common"></div>'); 4457 $('body').append(hiddenDiv); 4458 } 4459 var text_area_selector = '.materialize-textarea'; 4460 4461 function textareaAutoResize($textarea) { 4462 // Set font properties of hiddenDiv 4463 4464 var fontFamily = $textarea.css('font-family'); 4465 var fontSize = $textarea.css('font-size'); 4466 var lineHeight = $textarea.css('line-height'); 4467 var padding = $textarea.css('padding'); 4468 4469 if (fontSize) { 4470 hiddenDiv.css('font-size', fontSize); 4471 } 4472 if (fontFamily) { 4473 hiddenDiv.css('font-family', fontFamily); 4474 } 4475 if (lineHeight) { 4476 hiddenDiv.css('line-height', lineHeight); 4477 } 4478 if (padding) { 4479 hiddenDiv.css('padding', padding); 4480 } 4481 4482 // Set original-height, if none 4483 if (!$textarea.data('original-height')) { 4484 $textarea.data('original-height', $textarea.height()); 4485 } 4486 4487 if ($textarea.attr('wrap') === 'off') { 4488 hiddenDiv.css('overflow-wrap', 'normal').css('white-space', 'pre'); 4489 } 4490 4491 hiddenDiv.text($textarea.val() + '\n'); 4492 var content = hiddenDiv.html().replace(/\n/g, '<br>'); 4493 hiddenDiv.html(content); 4494 4495 // When textarea is hidden, width goes crazy. 4496 // Approximate with half of window size 4497 4498 if ($textarea.is(':visible')) { 4499 hiddenDiv.css('width', $textarea.width()); 4500 } else { 4501 hiddenDiv.css('width', $(window).width() / 2); 4502 } 4503 4504 /** 4505 * Resize if the new height is greater than the 4506 * original height of the textarea 4507 */ 4508 if ($textarea.data('original-height') <= hiddenDiv.height()) { 4509 $textarea.css('height', hiddenDiv.height()); 4510 } else if ($textarea.val().length < $textarea.data('previous-length')) { 4511 /** 4512 * In case the new height is less than original height, it 4513 * means the textarea has less text than before 4514 * So we set the height to the original one 4515 */ 4516 $textarea.css('height', $textarea.data('original-height')); 4517 } 4518 $textarea.data('previous-length', $textarea.val().length); 4519 } 4520 4521 $(text_area_selector).each(function () { 4522 var $textarea = $(this); 4523 /** 4524 * Instead of resizing textarea on document load, 4525 * store the original height and the original length 4526 */ 4527 $textarea.data('original-height', $textarea.height()); 4528 $textarea.data('previous-length', $textarea.val().length); 4529 }); 4530 4531 $('body').on('keyup keydown autoresize', text_area_selector, function () { 4532 textareaAutoResize($(this)); 4533 }); 4534 4535 // File Input Path 4536 $(document).on('change', '.file-field input[type="file"]', function () { 4537 var file_field = $(this).closest('.file-field'); 4538 var path_input = file_field.find('input.file-path'); 4539 var files = $(this)[0].files; 4540 var file_names = []; 4541 for (var i = 0; i < files.length; i++) { 4542 file_names.push(files[i].name); 4543 } 4544 path_input.val(file_names.join(", ")); 4545 path_input.trigger('change'); 4546 }); 4547 4548 /**************** 4549 * Range Input * 4550 ****************/ 4551 4552 var range_type = 'input[type=range]'; 4553 var range_mousedown = false;
4554 var left; 4555 4556 $(range_type).each(function () { 4557 var thumb = $('<span class="thumb"><span class="value"></span></span>'); 4558 $(this).after(thumb); 4559 }); 4560 4561 var showRangeBubble = function (thumb) { 4562 var paddingLeft = parseInt(thumb.parent().css('padding-left')); 4563 var marginLeft = -7 + paddingLeft + 'px'; 4564 thumb.velocity({ height: "30px", width: "30px", top: "-30px", marginLeft: marginLeft }, { duration: 300, easing: 'easeOutExpo' }); 4565 }; 4566 4567 var calcRangeOffset = function (range) { 4568 var width = range.width() - 15; 4569 var max = parseFloat(range.attr('max')); 4570 var min = parseFloat(range.attr('min')); 4571 var percent = (parseFloat(range.val()) - min) / (max - min); 4572 return percent * width; 4573 }; 4574 4575 var range_wrapper = '.range-field'; 4576 $(document).on('change', range_type, function (e) { 4577 var thumb = $(this).siblings('.thumb'); 4578 thumb.find('.value').html($(this).val()); 4579 4580 if (!thumb.hasClass('active')) { 4581 showRangeBubble(thumb); 4582 } 4583 4584 var offsetLeft = calcRangeOffset($(this)); 4585 thumb.addClass('active').css('left', offsetLeft); 4586 }); 4587 4588 $(document).on('mousedown touchstart', range_type, function (e) { 4589 var thumb = $(this).siblings('.thumb'); 4590 4591 // If thumb indicator does not exist yet, create it 4592 if (thumb.length <= 0) { 4593 thumb = $('<span class="thumb"><span class="value"></span></span>'); 4594 $(this).after(thumb); 4595 } 4596 4597 // Set indicator value 4598 thumb.find('.value').html($(this).val()); 4599 4600 range_mousedown = true; 4601 $(this).addClass('active'); 4602 4603 if (!thumb.hasClass('active')) { 4604 showRangeBubble(thumb); 4605 } 4606 4607 if (e.type !== 'input') { 4608 var offsetLeft = calcRangeOffset($(this)); 4609 thumb.addClass('active').css('left', offsetLeft); 4610 } 4611 }); 4612 4613 $(document).on('mouseup touchend', range_wrapper, function () { 4614 range_mousedown = false; 4615 $(this).removeClass('active'); 4616 }); 4617 4618 $(document).on('input mousemove touchmove', range_wrapper, function (e) { 4619 var thumb = $(this).children('.thumb'); 4620 var left; 4621 var input = $(this).find(range_type); 4622 4623 if (range_mousedown) { 4624 if (!thumb.hasClass('active')) { 4625 showRangeBubble(thumb); 4626 } 4627 4628 var offsetLeft = calcRangeOffset(input); 4629 thumb.addClass('active').css('left', offsetLeft); 4630 thumb.find('.value').html(thumb.siblings(range_type).val()); 4631 } 4632 }); 4633 4634 $(document).on('mouseout touchleave', range_wrapper, function () { 4635 if (!range_mousedown) { 4636 4637 var thumb = $(this).children('.thumb'); 4638 var paddingLeft = parseInt($(this).css('padding-left')); 4639 var marginLeft = 7 + paddingLeft + 'px'; 4640 4641 if (thumb.hasClass('active')) { 4642 thumb.velocity({ height: '0', width: '0', top: '10px', marginLeft: marginLeft }, { duration: 100 }); 4643 } 4644 thumb.removeClass('active'); 4645 } 4646 }); 4647 4648 /************************** 4649 * Auto complete plugin * 4650 *************************/ 4651 $.fn.autocomplete = function (options) { 4652 // Defaults 4653 var defaults = { 4654 data: {}, 4655 limit: Infinity, 4656 onAutocomplete: null, 4657 minLength: 1 4658 }; 4659 4660 options = $.extend(defaults, options); 4661 4662 return this.each(function () { 4663 var $input = $(this); 4664 var data = options.data, 4665 count = 0, 4666 activeIndex = -1, 4667 oldVal, 4668 $inputDiv = $input.closest('.input-field'); // Div to append on 4669 4670 // Check if data isn't empty 4671 if (!$.isEmptyObject(data)) { 4672 var $autocomplete = $('<ul class="autocomplete-content dropdown-content"></ul>'); 4673 var $oldAutocomplete; 4674 4675 // Append autocomplete element. 4676 // Prevent double structure init. 4677 if ($inputDiv.length) { 4678 $oldAutocomplete = $inputDiv.children('.autocomplete-content.dropdown-content').first(); 4679 if (!$oldAutocomplete.length) { 4680 $inputDiv.append($autocomplete); // Set ul in body 4681 } 4682 } else { 4683 $oldAutocomplete = $input.next('.autocomplete-content.dropdown-content'); 4684 if (!$oldAutocomplete.length) { 4685 $input.after($autocomplete); 4686 } 4687 } 4688 if ($oldAutocomplete.length) { 4689 $autocomplete = $oldAutocomplete; 4690 } 4691 4692 // Highlight partial match. 4693 var highlight = function (string, $el) { 4694 var img = $el.find('img'); 4695 var matchStart = $el.text().toLowerCase().indexOf("" + string.toLowerCase() + ""), 4696 matchEnd = matchStart + string.length - 1, 4697 beforeMatch = $el.text().slice(0, matchStart), 4698 matchText = $el.text().slice(matchStart, matchEnd + 1), 4699 afterMatch = $el.text().slice(matchEnd + 1); 4700 $el.html("<span>" + beforeMatch + "<span class='highlight'>" + matchText + "</span>" + afterMatch + "</span>"); 4701 if (img.length) { 4702 $el.prepend(img); 4703 } 4704 }; 4705 4706 // Reset current element position 4707 var resetCurrentElement = function () { 4708 activeIndex = -1; 4709 $autocomplete.find('.active').removeClass('active'); 4710 }; 4711 4712 // Remove autocomplete elements 4713 var removeAutocomplete = function () { 4714 $autocomplete.empty(); 4715 resetCurrentElement(); 4716 oldVal = undefined; 4717 }; 4718 4719 $input.off('blur.autocomplete').on('blur.autocomplete', function () { 4720 removeAutocomplete(); 4721 }); 4722 4723 // Perform search 4724 $input.off('keyup.autocomplete focus.autocomplete').on('keyup.autocomplete focus.autocomplete', function (e) { 4725 // Reset count. 4726 count = 0; 4727 var val = $input.val().toLowerCase(); 4728 4729 // Don't capture enter or arrow key usage. 4730 if (e.which === 13 || e.which === 38 || e.which === 40) { 4731 return; 4732 } 4733 4734 // Check if the input isn't empty 4735 if (oldVal !== val) { 4736 removeAutocomplete(); 4737 4738 if (val.length >= options.minLength) { 4739 for (var key in data) { 4740 if (data.hasOwnProperty(key) && key.toLowerCase().indexOf(val) !== -1) { 4741 // Break if past limit 4742 if (count >= options.limit) { 4743 break; 4744 } 4745 4746 var autocompleteOption = $('<li></li>'); 4747 if (!!data[key]) { 4748 autocompleteOption.append('<img src="' + data[key] + '" class="right circle"><span>' + key + '</span>'); 4749 } else { 4750 autocompleteOption.append('<span>' + key + '</span>'); 4751 } 4752 4753 $autocomplete.append(autocompleteOption); 4754 highlight(val, autocompleteOption); 4755 count++; 4756 } 4757 } 4758 } 4759 } 4760 4761 // Update oldVal 4762 oldVal = val; 4763 }); 4764 4765 $input.off('keydown.autocomplete').on('keydown.autocomplete', function (e) { 4766 // Arrow keys and enter key usage 4767 var keyCode = e.which, 4768 liElement, 4769 numItems = $autocomplete.children('li').length, 4770 $active = $autocomplete.children('.active').first(); 4771 4772 // select element on Enter 4773 if (keyCode === 13 && activeIndex >= 0) { 4774 liElement = $autocomplete.children('li').eq(activeIndex); 4775 if (liElement.length) { 4776 liElement.trigger('mousedown.autocomplete'); 4777 e.preventDefault(); 4778 } 4779 return; 4780 } 4781 4782 // Capture up and down key 4783 if (keyCode === 38 || keyCode === 40) { 4784 e.preventDefault(); 4785 4786 if (keyCode === 38 && activeIndex > 0) { 4787 activeIndex--; 4788 } 4789 4790 if (keyCode === 40 && activeIndex < numItems - 1) { 4791 activeIndex++; 4792 } 4793 4794 $active.removeClass('active'); 4795 if (activeIndex >= 0) { 4796 $autocomplete.children('li').eq(activeIndex).addClass('active'); 4797 } 4798 } 4799 }); 4800 4801 // Set input value 4802 $autocomplete.off('mousedown.autocomplete touchstart.autocomplete').on('mousedown.autocomplete touchstart.autocomplete', 'li', function () { 4803 var text = $(this).text().trim(); 4804 $input.val(text); 4805 $input.trigger('change'); 4806 removeAutocomplete(); 4807 4808 // Handle onAutocomplete callback. 4809 if (typeof options.onAutocomplete === "function") { 4810 options.onAutocomplete.call(this, text); 4811 } 4812 }); 4813 4814 // Empty data 4815 } else { 4816 $input.off('keyup.autocomplete focus.autocomplete'); 4817 } 4818 }); 4819 }; 4820 }); // End of $(document).ready 4821 4822 /******************* 4823 * Select Plugin * 4824 ******************/ 4825 $.fn.material_select = function (callback) { 4826 $(this).each(function () { 4827 var $select = $(this); 4828 4829 if ($select.hasClass('browser-default')) { 4830 return; // Continue to next (return false breaks out of entire loop) 4831 } 4832 4833 var multiple = $select.attr('multiple') ? true : false, 4834 lastID = $select.attr('data-select-id'); // Tear down structure if Select needs to be rebuilt 4835 4836 if (lastID) { 4837 $select.parent().find('span.caret').remove(); 4838 $select.parent().find('input').remove(); 4839 4840 $select.unwrap(); 4841 $('ul#select-options-' + lastID).remove(); 4842 } 4843 4844 // If destroying the select, remove the selelct-id and reset it to it's uninitialized state. 4845 if (callback === 'destroy') { 4846 $select.removeAttr('data-select-id').removeClass('initialized'); 4847 $(window).off('click.select'); 4848 return; 4849 } 4850 4851 var uniqueID = Materialize.guid(); 4852 $select.attr('data-select-id', uniqueID);
4853 var wrapper = $('<div class="select-wrapper"></div>'); 4854 wrapper.addClass($select.attr('class')); 4855 if ($select.is(':disabled')) wrapper.addClass('disabled'); 4856 var options = $('<ul id="select-options-' + uniqueID + '" class="dropdown-content select-dropdown ' + (multiple ? 'multiple-select-dropdown' : '') + '"></ul>'), 4857 selectChildren = $select.children('option, optgroup'), 4858 valuesSelected = [], 4859 optionsHover = false; 4860 4861 var label = $select.find('option:selected').html() || $select.find('option:first').html() || ""; 4862 4863 // Function that renders and appends the option taking into 4864 // account type and possible image icon. 4865 var appendOptionWithIcon = function (select, option, type) { 4866 // Add disabled attr if disabled 4867 var disabledClass = option.is(':disabled') ? 'disabled ' : ''; 4868 var optgroupClass = type === 'optgroup-option' ? 'optgroup-option ' : ''; 4869 var multipleCheckbox = multiple ? '<input type="checkbox"' + disabledClass + '/><label></label>' : ''; 4870 4871 // add icons 4872 var icon_url = option.data('icon'); 4873 var classes = option.attr('class'); 4874 if (!!icon_url) { 4875 var classString = ''; 4876 if (!!classes) classString = ' class="' + classes + '"'; 4877 4878 // Check for multiple type. 4879 options.append($('<li class="' + disabledClass + optgroupClass + '"><img alt="" src="' + icon_url + '"' + classString + '><span>' + multipleCheckbox + option.html() + '</span></li>')); 4880 return true; 4881 } 4882 4883 // Check for multiple type. 4884 options.append($('<li class="' + disabledClass + optgroupClass + '"><span>' + multipleCheckbox + option.html() + '</span></li>')); 4885 }; 4886 4887 /* Create dropdown structure. */ 4888 if (selectChildren.length) { 4889 selectChildren.each(function () { 4890 if ($(this).is('option')) { 4891 // Direct descendant option. 4892 if (multiple) { 4893 appendOptionWithIcon($select, $(this), 'multiple'); 4894 } else { 4895 appendOptionWithIcon($select, $(this)); 4896 } 4897 } else if ($(this).is('optgroup')) { 4898 // Optgroup. 4899 var selectOptions = $(this).children('option'); 4900 options.append($('<li class="optgroup"><span>' + $(this).attr('label') + '</span></li>')); 4901 4902 selectOptions.each(function () { 4903 appendOptionWithIcon($select, $(this), 'optgroup-option'); 4904 }); 4905 } 4906 }); 4907 } 4908 4909 options.find('li:not(.optgroup)').each(function (i) { 4910 $(this).click(function (e) { 4911 // Check if option element is disabled 4912 if (!$(this).hasClass('disabled') && !$(this).hasClass('optgroup')) { 4913 var selected = true; 4914 4915 if (multiple) { 4916 $('input[type="checkbox"]', this).prop('checked', function (i, v) { 4917 return !v; 4918 }); 4919 selected = toggleEntryFromArray(valuesSelected, i, $select); 4920 $newSelect.trigger('focus'); 4921 } else { 4922 options.find('li').removeClass('active'); 4923 $(this).toggleClass('active'); 4924 $newSelect.val($(this).text()); 4925 } 4926 4927 activateOption(options, $(this)); 4928 $select.find('option').eq(i).prop('selected', selected); 4929 // Trigger onchange() event 4930 $select.trigger('change'); 4931 if (typeof callback !== 'undefined') callback(); 4932 } 4933 4934 e.stopPropagation(); 4935 }); 4936 }); 4937 4938 // Wrap Elements 4939 $select.wrap(wrapper); 4940 // Add Select Display Element 4941 var dropdownIcon = $('<span class="caret">▼</span>'); 4942 4943 // escape double quotes 4944 var sanitizedLabelHtml = label.replace(/"/g, '"'); 4945 4946 var $newSelect = $('<input type="text" class="select-dropdown" readonly="true" ' + ($select.is(':disabled') ? 'disabled' : '') + ' data-activates="select-options-' + uniqueID + '" value="' + sanitizedLabelHtml + '"/>'); 4947 $select.before($newSelect); 4948 $newSelect.before(dropdownIcon); 4949 4950 $newSelect.after(options); 4951 // Check if section element is disabled 4952 if (!$select.is(':disabled')) { 4953 $newSelect.dropdown({ 'hover': false }); 4954 } 4955 4956 // Copy tabindex 4957 if ($select.attr('tabindex')) { 4958 $($newSelect[0]).attr('tabindex', $select.attr('tabindex')); 4959 } 4960 4961 $select.addClass('initialized'); 4962 4963 $newSelect.on({
4964 'focus': function () { 4965 if ($('ul.select-dropdown').not(options[0]).is(':visible')) { 4966 $('input.select-dropdown').trigger('close'); 4967 $(window).off('click.select'); 4968 } 4969 if (!options.is(':visible')) { 4970 $(this).trigger('open', ['focus']); 4971 var label = $(this).val(); 4972 if (multiple && label.indexOf(',') >= 0) { 4973 label = label.split(',')[0]; 4974 } 4975 4976 var selectedOption = options.find('li').filter(function () { 4977 return $(this).text().toLowerCase() === label.toLowerCase(); 4978 })[0]; 4979 activateOption(options, selectedOption, true); 4980 4981 $(window).off('click.select').on('click.select', function () { 4982 multiple && (optionsHover || $newSelect.trigger('close')); 4983 $(window).off('click.select'); 4984 }); 4985 } 4986 }, 4987 'click': function (e) { 4988 e.stopPropagation(); 4989 } 4990 }); 4991 4992 $newSelect.on('blur', function () { 4993 if (!multiple) { 4994 $(this).trigger('close'); 4995 $(window).off('click.select'); 4996 } 4997 options.find('li.selected').removeClass('selected'); 4998 }); 4999 5000 options.hover(function () { 5001 optionsHover = true; 5002 }, function () { 5003 optionsHover = false; 5004 }); 5005 5006 // Add initial multiple selections. 5007 if (multiple) { 5008 $select.find("option:selected:not(:disabled)").each(function () { 5009 var index = $(this).index(); 5010 5011 toggleEntryFromArray(valuesSelected, index, $select); 5012 options.find("li").eq(index).find(":checkbox").prop("checked", true); 5013 }); 5014 } 5015 5016 /** 5017 * Make option as selected and scroll to selected position 5018 * @param {jQuery} collection Select options jQuery element 5019 * @param {Element} newOption element of the new option 5020 * @param {Boolean} firstActivation If on first activation of select 5021 */ 5022 var activateOption = function (collection, newOption, firstActivation) { 5023 if (newOption) { 5024 collection.find('li.selected').removeClass('selected'); 5025 var option = $(newOption); 5026 option.addClass('selected'); 5027 if (!multiple || !!firstActivation) { 5028 options.scrollTo(option); 5029 } 5030 } 5031 }; 5032 5033 // Allow user to search by typing 5034 // this array is cleared after 1 second 5035 var filterQuery = [], 5036 onKeyDown = function (e) { 5037 // TAB - switch to another input 5038 if (e.which == 9) { 5039 $newSelect.trigger('close'); 5040 return; 5041 } 5042 5043 // ARROW DOWN WHEN SELECT IS CLOSED - open select options 5044 if (e.which == 40 && !options.is(':visible')) { 5045 $newSelect.trigger('open'); 5046 return; 5047 } 5048 5049 // ENTER WHEN SELECT IS CLOSED - submit form 5050 if (e.which == 13 && !options.is(':visible')) { 5051 return; 5052 } 5053 5054 e.preventDefault(); 5055 5056 // CASE WHEN USER TYPE LETTERS 5057 var letter = String.fromCharCode(e.which).toLowerCase(), 5058 nonLetters = [9, 13, 27, 38, 40]; 5059 if (letter && nonLetters.indexOf(e.which) === -1) { 5060 filterQuery.push(letter); 5061 5062 var string = filterQuery.join(''), 5063 newOption = options.find('li').filter(function () { 5064 return $(this).text().toLowerCase().indexOf(string) === 0; 5065 })[0]; 5066 5067 if (newOption) { 5068 activateOption(options, newOption); 5069 } 5070 } 5071 5072 // ENTER - select option and close when select options are opened 5073 if (e.which == 13) { 5074 var activeOption = options.find('li.selected:not(.disabled)')[0]; 5075 if (activeOption) { 5076 $(activeOption).trigger('click'); 5077 if (!multiple) { 5078 $newSelect.trigger('close'); 5079 } 5080 } 5081 } 5082 5083 // ARROW DOWN - move to next not disabled option 5084 if (e.which == 40) { 5085 if (options.find('li.selected').length) { 5086 newOption = options.find('li.selected').next('li:not(.disabled)')[0]; 5087 } else { 5088 newOption = options.find('li:not(.disabled)')[0]; 5089 } 5090 activateOption(options, newOption); 5091 } 5092 5093 // ESC - close options 5094 if (e.which == 27) { 5095 $newSelect.trigger('close'); 5096 } 5097 5098 // ARROW UP - move to previous not disabled option 5099 if (e.which == 38) { 5100 newOption = options.find('li.selected').prev('li:not(.disabled)')[0]; 5101 if (newOption) activateOption(options, newOption); 5102 } 5103 5104 // Automaticaly clean filter query so user can search again by starting letters 5105 setTimeout(function () { 5106 filterQuery = []; 5107 }, 1000); 5108 }; 5109
5110 $newSelect.on('keydown', onKeyDown); 5111 }); 5112 5113 function toggleEntryFromArray(entriesArray, entryIndex, select) { 5114 var index = entriesArray.indexOf(entryIndex), 5115 notAdded = index === -1; 5116 5117 if (notAdded) { 5118 entriesArray.push(entryIndex); 5119 } else { 5120 entriesArray.splice(index, 1); 5121 } 5122 5123 select.siblings('ul.dropdown-content').find('li:not(.optgroup)').eq(entryIndex).toggleClass('active'); 5124 5125 // use notAdded instead of true (to detect if the option is selected or not) 5126 select.find('option').eq(entryIndex).prop('selected', notAdded); 5127 setValueToInput(entriesArray, select); 5128 5129 return notAdded; 5130 } 5131 5132 function setValueToInput(entriesArray, select) { 5133 var value = ''; 5134 5135 for (var i = 0, count = entriesArray.length; i < count; i++) { 5136 var text = select.find('option').eq(entriesArray[i]).text(); 5137 5138 i === 0 ? value += text : value += ', ' + text; 5139 } 5140 5141 if (value === '') { 5142 value = select.find('option:disabled').eq(0).text(); 5143 } 5144 5145 select.siblings('input.select-dropdown').val(value); 5146 } 5147 }; 5148})(jQuery); 5149;(function ($) { 5150 5151 var methods = { 5152 5153 init: function (options) { 5154 var defaults = { 5155 indicators: true, 5156 height: 400, 5157 transition: 500, 5158 interval: 6000 5159 }; 5160 options = $.extend(defaults, options); 5161 5162 return this.each(function () { 5163 5164 // For each slider, we want to keep track of 5165 // which slide is active and its associated content 5166 var $this = $(this); 5167 var $slider = $this.find('ul.slides').first(); 5168 var $slides = $slider.find('> li'); 5169 var $active_index = $slider.find('.active').index(); 5170 var $active, $indicators, $interval; 5171 if ($active_index != -1) { 5172 $active = $slides.eq($active_index); 5173 } 5174 5175 // Transitions the caption depending on alignment 5176 function captionTransition(caption, duration) { 5177 if (caption.hasClass("center-align")) { 5178 caption.velocity({ opacity: 0, translateY: -100 }, { duration: duration, queue: false }); 5179 } else if (caption.hasClass("right-align")) { 5180 caption.velocity({ opacity: 0, translateX: 100 }, { duration: duration, queue: false }); 5181 } else if (caption.hasClass("left-align")) { 5182 caption.velocity({ opacity: 0, translateX: -100 }, { duration: duration, queue: false }); 5183 } 5184 } 5185 5186 // This function will transition the slide to any index of the next slide 5187 function moveToSlide(index) { 5188 // Wrap around indices. 5189 if (index >= $slides.length) index = 0;else if (index < 0) index = $slides.length - 1; 5190 5191 $active_index = $slider.find('.active').index(); 5192 5193 // Only do if index changes 5194 if ($active_index != index) { 5195 $active = $slides.eq($active_index); 5196 $caption = $active.find('.caption'); 5197 5198 $active.removeClass('active'); 5199 $active.velocity({ opacity: 0 }, { duration: options.transition, queue: false, easing: 'easeOutQuad', 5200 complete: function () { 5201 $slides.not('.active').velocity({ opacity: 0, translateX: 0, translateY: 0 }, { duration: 0, queue: false }); 5202 } }); 5203 captionTransition($caption, options.transition); 5204 5205 // Update indicators 5206 if (options.indicators) { 5207 $indicators.eq($active_index).removeClass('active'); 5208 } 5209 5210 $slides.eq(index).velocity({ opacity: 1 }, { duration: options.transition, queue: false, easing: 'easeOutQuad' }); 5211 $slides.eq(index).find('.caption').velocity({ opacity: 1, translateX: 0, translateY: 0 }, { duration: options.transition, delay: options.transition, queue: false, easing: 'easeOutQuad' }); 5212 $slides.eq(index).addClass('active'); 5213 5214 // Update indicators 5215 if (options.indicators) { 5216 $indicators.eq(index).addClass('active'); 5217 } 5218 } 5219 } 5220 5221 // Set height of slider 5222 // If fullscreen, do nothing 5223 if (!$this.hasClass('fullscreen')) { 5224 if (options.indicators) { 5225 // Add height if indicators are present 5226 $this.height(options.height + 13); 5227 } else { 5228 $this.height(options.height); 5229 } 5230 $slider.height(options.height); 5231 } 5232 5233 // Set initial positions of captions 5234 $slides.find('.caption').each(function () { 5235 captionTransition($(this), 0); 5236 }); 5237 5238 // Move img src into background-image 5239 $slides.find('img').each(function () { 5240 var placeholderBase64 = 'data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='; 5241 if ($(this).attr('src') !== placeholderBase64) { 5242 $(this).css('background-image', 'url("' + $(this).attr('src') + '")'); 5243 $(this).attr('src', placeholderBase64); 5244 } 5245 }); 5246 5247 // dynamically add indicators 5248 if (options.indicators) { 5249 $indicators = $('<ul class="indicators"></ul>'); 5250 $slides.each(function (index) { 5251 var $indicator = $('<li class="indicator-item"></li>'); 5252 5253 // Handle clicks on indicators 5254 $indicator.click(function () { 5255 var $parent = $slider.parent(); 5256 var curr_index = $parent.find($(this)).index(); 5257 moveToSlide(curr_index); 5258 5259 // reset interval 5260 clearInterval($interval); 5261 $interval = setInterval(function () { 5262 $active_index = $slider.find('.active').index(); 5263 if ($slides.length == $active_index + 1) $active_index = 0; // loop to start 5264 else $active_index += 1; 5265 5266 moveToSlide($active_index); 5267 }, options.transition + options.interval); 5268 }); 5269 $indicators.append($indicator); 5270 }); 5271 $this.append($indicators); 5272 $indicators = $this.find('ul.indicators').find('li.indicator-item'); 5273 } 5274 5275 if ($active) { 5276 $active.show(); 5277 } else { 5278 $slides.first().addClass('active').velocity({ opacity: 1 }, { duration: options.transition, queue: false, easing: 'easeOutQuad' }); 5279 5280 $active_index = 0; 5281 $active = $slides.eq($active_index); 5282 5283 // Update indicators 5284 if (options.indicators) { 5285 $indicators.eq($active_index).addClass('active'); 5286 } 5287 } 5288 5289 // Adjust height to current slide 5290 $active.find('img').each(function () { 5291 $active.find('.caption').velocity({ opacity: 1, translateX: 0, translateY: 0 }, { duration: options.transition, queue: false, easing: 'easeOutQuad' }); 5292 }); 5293 5294 // auto scroll 5295 $interval = setInterval(function () { 5296 $active_index = $slider.find('.active').index(); 5297 moveToSlide($active_index + 1); 5298 }, options.transition + options.interval); 5299 5300 // HammerJS, Swipe navigation 5301 5302 // Touch Event 5303 var panning = false;
5304 var swipeLeft = false; 5305 var swipeRight = false; 5306 5307 $this.hammer({ 5308 prevent_default: false 5309 }).on('pan', function (e) { 5310 if (e.gesture.pointerType === "touch") { 5311 5312 // reset interval 5313 clearInterval($interval); 5314 5315 var direction = e.gesture.direction; 5316 var x = e.gesture.deltaX; 5317 var velocityX = e.gesture.velocityX; 5318 var velocityY = e.gesture.velocityY; 5319 5320 $curr_slide = $slider.find('.active'); 5321 if (Math.abs(velocityX) > Math.abs(velocityY)) { 5322 $curr_slide.velocity({ translateX: x 5323 }, { duration: 50, queue: false, easing: 'easeOutQuad' }); 5324 } 5325 5326 // Swipe Left 5327 if (direction === 4 && (x > $this.innerWidth() / 2 || velocityX < -0.65)) { 5328 swipeRight = true; 5329 } 5330 // Swipe Right 5331 else if (direction === 2 && (x < -1 * $this.innerWidth() / 2 || velocityX > 0.65)) { 5332 swipeLeft = true; 5333 } 5334 5335 // Make Slide Behind active slide visible 5336 var next_slide; 5337 if (swipeLeft) { 5338 next_slide = $curr_slide.next(); 5339 if (next_slide.length === 0) { 5340 next_slide = $slides.first(); 5341 } 5342 next_slide.velocity({ opacity: 1 5343 }, { duration: 300, queue: false, easing: 'easeOutQuad' }); 5344 } 5345 if (swipeRight) { 5346 next_slide = $curr_slide.prev(); 5347 if (next_slide.length === 0) { 5348 next_slide = $slides.last(); 5349 } 5350 next_slide.velocity({ opacity: 1 5351 }, { duration: 300, queue: false, easing: 'easeOutQuad' }); 5352 } 5353 } 5354 }).on('panend', function (e) { 5355 if (e.gesture.pointerType === "touch") { 5356 5357 $curr_slide = $slider.find('.active'); 5358 panning = false; 5359 curr_index = $slider.find('.active').index(); 5360 5361 if (!swipeRight && !swipeLeft || $slides.length <= 1) { 5362 // Return to original spot 5363 $curr_slide.velocity({ translateX: 0 5364 }, { duration: 300, queue: false, easing: 'easeOutQuad' }); 5365 } else if (swipeLeft) { 5366 moveToSlide(curr_index + 1); 5367 $curr_slide.velocity({ translateX: -1 * $this.innerWidth() }, { duration: 300, queue: false, easing: 'easeOutQuad', 5368 complete: function () { 5369 $curr_slide.velocity({ opacity: 0, translateX: 0 }, { duration: 0, queue: false }); 5370 } }); 5371 } else if (swipeRight) { 5372 moveToSlide(curr_index - 1); 5373 $curr_slide.velocity({ translateX: $this.innerWidth() }, { duration: 300, queue: false, easing: 'easeOutQuad', 5374 complete: function () { 5375 $curr_slide.velocity({ opacity: 0, translateX: 0 }, { duration: 0, queue: false }); 5376 } }); 5377 } 5378 swipeLeft = false; 5379 swipeRight = false; 5380 5381 // Restart interval 5382 clearInterval($interval); 5383 $interval = setInterval(function () { 5384 $active_index = $slider.find('.active').index(); 5385 if ($slides.length == $active_index + 1) $active_index = 0; // loop to start 5386 else $active_index += 1; 5387 5388 moveToSlide($active_index); 5389 }, options.transition + options.interval); 5390 } 5391 }); 5392 5393 $this.on('sliderPause', function () { 5394 clearInterval($interval); 5395 }); 5396 5397 $this.on('sliderStart', function () { 5398 clearInterval($interval); 5399 $interval = setInterval(function () { 5400 $active_index = $slider.find('.active').index(); 5401 if ($slides.length == $active_index + 1) $active_index = 0; // loop to start 5402 else $active_index += 1; 5403 5404 moveToSlide($active_index); 5405 }, options.transition + options.interval); 5406 }); 5407 5408 $this.on('sliderNext', function () { 5409 $active_index = $slider.find('.active').index(); 5410 moveToSlide($active_index + 1); 5411 }); 5412 5413 $this.on('sliderPrev', function () { 5414 $active_index = $slider.find('.active').index(); 5415 moveToSlide($active_index - 1); 5416 }); 5417 }); 5418 }, 5419 pause: function () { 5420 $(this).trigger('sliderPause'); 5421 }, 5422 start: function () { 5423 $(this).trigger('sliderStart'); 5424 }, 5425 next: function () { 5426 $(this).trigger('sliderNext'); 5427 }, 5428 prev: function () { 5429 $(this).trigger('sliderPrev'); 5430 } 5431 }; 5432 5433 $.fn.slider = function (methodOrOptions) { 5434 if (methods[methodOrOptions]) { 5435 return methods[methodOrOptions].apply(this, Array.prototype.slice.call(arguments, 1)); 5436 } else if (typeof methodOrOptions === 'object' || !methodOrOptions) { 5437 // Default to "init" 5438 return methods.init.apply(this, arguments); 5439 } else { 5440 $.error('Method ' + methodOrOptions + ' does not exist on jQuery.tooltip'); 5441 } 5442 }; // Plugin end 5443})(jQuery); 5444;(function ($) { 5445 $(document).ready(function () { 5446 5447 $(document).on('click.card', '.card', function (e) { 5448 if ($(this).find('> .card-reveal').length) { 5449 var $card = $(e.target).closest('.card'); 5450 if ($card.data('initialOverflow') === undefined) { 5451 $card.data('initialOverflow', $card.css('overflow') === undefined ? '' : $card.css('overflow')); 5452 } 5453 if ($(e.target).is($('.card-reveal .card-title')) || $(e.target).is($('.card-reveal .card-title i'))) { 5454 // Make Reveal animate down and display none 5455 $(this).find('.card-reveal').velocity({ translateY: 0 }, { 5456 duration: 225, 5457 queue: false, 5458 easing: 'easeInOutQuad', 5459 complete: function () { 5460 $(this).css({ display: 'none' }); 5461 $card.css('overflow', $card.data('initialOverflow')); 5462 } 5463 }); 5464 } else if ($(e.target).is($('.card .activator')) || $(e.target).is($('.card .activator i'))) { 5465 $card.css('overflow', 'hidden'); 5466 $(this).find('.card-reveal').css({ display: 'block' }).velocity("stop", false).velocity({ translateY: '-100%' }, { duration: 300, queue: false, easing: 'easeInOutQuad' }); 5467 } 5468 } 5469 }); 5470 }); 5471})(jQuery); 5472;(function ($) { 5473 var materialChipsDefaults = { 5474 data: [], 5475 placeholder: '', 5476 secondaryPlaceholder: '', 5477 autocompleteOptions: {} 5478 }; 5479 5480 $(document).ready(function () { 5481 // Handle removal of static chips. 5482 $(document).on('click', '.chip .close', function (e) { 5483 var $chips = $(this).closest('.chips'); 5484 if ($chips.attr('data-initialized')) { 5485 return; 5486 } 5487 $(this).closest('.chip').remove(); 5488 }); 5489 }); 5490 5491 $.fn.material_chip = function (options) { 5492 var self = this; 5493 this.$el = $(this); 5494 this.$document = $(document); 5495 this.SELS = { 5496 CHIPS: '.chips', 5497 CHIP: '.chip', 5498 INPUT: 'input', 5499 DELETE: '.material-icons', 5500 SELECTED_CHIP: '.selected' 5501 }; 5502 5503 if ('data' === options) { 5504 return this.$el.data('chips'); 5505 } 5506 5507 var curr_options = $.extend({}, materialChipsDefaults, options); 5508 self.hasAutocomplete = !$.isEmptyObject(curr_options.autocompleteOptions.data); 5509 5510 // Initialize 5511 this.init = function () { 5512 var i = 0; 5513 var chips; 5514 self.$el.each(function () { 5515 var $chips = $(this); 5516 var chipId = Materialize.guid(); 5517 self.chipId = chipId; 5518 5519 if (!curr_options.data || !(curr_options.data instanceof Array)) { 5520 curr_options.data = []; 5521 } 5522 $chips.data('chips', curr_options.data); 5523 $chips.attr('data-index', i); 5524 $chips.attr('data-initialized', true); 5525 5526 if (!$chips.hasClass(self.SELS.CHIPS)) { 5527 $chips.addClass('chips'); 5528 } 5529 5530 self.chips($chips, chipId); 5531 i++; 5532 }); 5533 }; 5534 5535 this.handleEvents = function () { 5536 var SELS = self.SELS; 5537 5538 self.$document.off('click.chips-focus', SELS.CHIPS).on('click.chips-focus', SELS.CHIPS, function (e) { 5539 $(e.target).find(SELS.INPUT).focus(); 5540 }); 5541 5542 self.$document.off('click.chips-select', SELS.CHIP).on('click.chips-select', SELS.CHIP, function (e) { 5543 var $chip = $(e.target); 5544 if ($chip.length) { 5545 var wasSelected = $chip.hasClass('selected'); 5546 var $chips = $chip.closest(SELS.CHIPS); 5547 $(SELS.CHIP).removeClass('selected'); 5548 5549 if (!wasSelected) { 5550 self.selectChip($chip.index(), $chips); 5551 } 5552 } 5553 }); 5554 5555 self.$document.off('keydown.chips').on('keydown.chips', function (e) { 5556 if ($(e.target).is('input, textarea')) { 5557 return; 5558 } 5559 5560 // delete 5561 var $chip = self.$document.find(SELS.CHIP + SELS.SELECTED_CHIP); 5562 var $chips = $chip.closest(SELS.CHIPS); 5563 var length = $chip.siblings(SELS.CHIP).length; 5564 var index; 5565 5566 if (!$chip.length) { 5567 return; 5568 } 5569 5570 if (e.which === 8 || e.which === 46) { 5571 e.preventDefault(); 5572 5573 index = $chip.index(); 5574 self.deleteChip(index, $chips); 5575 5576 var selectIndex = null; 5577 if (index + 1 < length) { 5578 selectIndex = index; 5579 } else if (index === length || index + 1 === length) { 5580 selectIndex = length - 1; 5581 } 5582 5583 if (selectIndex < 0) selectIndex = null; 5584 5585 if (null !== selectIndex) { 5586 self.selectChip(selectIndex, $chips); 5587 } 5588 if (!length) $chips.find('input').focus(); 5589 5590 // left 5591 } else if (e.which === 37) { 5592 index = $chip.index() - 1; 5593 if (index < 0) { 5594 return; 5595 } 5596 $(SELS.CHIP).removeClass('selected'); 5597 self.selectChip(index, $chips); 5598 5599 // right 5600 } else if (e.which === 39) { 5601 index = $chip.index() + 1; 5602 $(SELS.CHIP).removeClass('selected'); 5603 if (index > length) { 5604 $chips.find('input').focus(); 5605 return; 5606 } 5607 self.selectChip(index, $chips); 5608 } 5609 }); 5610 5611 self.$document.off('focusin.chips', SELS.CHIPS + ' ' + SELS.INPUT).on('focusin.chips', SELS.CHIPS + ' ' + SELS.INPUT, function (e) { 5612 var $currChips = $(e.target).closest(SELS.CHIPS); 5613 $currChips.addClass('focus'); 5614 $currChips.siblings('label, .prefix').addClass('active'); 5615 $(SELS.CHIP).removeClass('selected'); 5616 }); 5617 5618 self.$document.off('focusout.chips', SELS.CHIPS + ' ' + SELS.INPUT).on('focusout.chips', SELS.CHIPS + ' ' + SELS.INPUT, function (e) { 5619 var $currChips = $(e.target).closest(SELS.CHIPS); 5620 $currChips.removeClass('focus'); 5621 5622 // Remove active if empty 5623 if ($currChips.data('chips') === undefined || !$currChips.data('chips').length) { 5624 $currChips.siblings('label').removeClass('active'); 5625 } 5626 $currChips.siblings('.prefix').removeClass('active'); 5627 }); 5628 5629 self.$document.off('keydown.chips-add', SELS.CHIPS + ' ' + SELS.INPUT).on('keydown.chips-add', SELS.CHIPS + ' ' + SELS.INPUT, function (e) { 5630 var $target = $(e.target); 5631 var $chips = $target.closest(SELS.CHIPS); 5632 var chipsLength = $chips.children(SELS.CHIP).length; 5633 5634 // enter 5635 if (13 === e.which) { 5636 // Override enter if autocompleting. 5637 if (self.hasAutocomplete && $chips.find('.autocomplete-content.dropdown-content').length && $chips.find('.autocomplete-content.dropdown-content').children().length) { 5638 return; 5639 } 5640 5641 e.preventDefault(); 5642 self.addChip({ tag: $target.val() }, $chips); 5643 $target.val(''); 5644 return; 5645 } 5646 5647 // delete or left 5648 if ((8 === e.keyCode || 37 === e.keyCode) && '' === $target.val() && chipsLength) { 5649 e.preventDefault(); 5650 self.selectChip(chipsLength - 1, $chips); 5651 $target.blur(); 5652 return; 5653 } 5654 }); 5655 5656 // Click on delete icon in chip. 5657 self.$document.off('click.chips-delete', SELS.CHIPS + ' ' + SELS.DELETE).on('click.chips-delete', SELS.CHIPS + ' ' + SELS.DELETE, function (e) { 5658 var $target = $(e.target); 5659 var $chips = $target.closest(SELS.CHIPS); 5660 var $chip = $target.closest(SELS.CHIP); 5661 e.stopPropagation(); 5662 self.deleteChip($chip.index(), $chips); 5663 $chips.find('input').focus(); 5664 }); 5665 }; 5666 5667 this.chips = function ($chips, chipId) { 5668 $chips.empty(); 5669 $chips.data('chips').forEach(function (elem) { 5670 $chips.append(self.renderChip(elem)); 5671 }); 5672 $chips.append($('<input id="' + chipId + '" class="input" placeholder="">')); 5673 self.setPlaceholder($chips); 5674 5675 // Set for attribute for label 5676 var label = $chips.next('label'); 5677 if (label.length) { 5678 label.attr('for', chipId); 5679 5680 if ($chips.data('chips') !== undefined && $chips.data('chips').length) { 5681 label.addClass('active'); 5682 } 5683 } 5684 5685 // Setup autocomplete if needed. 5686 var input = $('#' + chipId); 5687 if (self.hasAutocomplete) { 5688 curr_options.autocompleteOptions.onAutocomplete = function (val) { 5689 self.addChip({ tag: val }, $chips); 5690 input.val(''); 5691 input.focus(); 5692 }; 5693 input.autocomplete(curr_options.autocompleteOptions); 5694 } 5695 }; 5696 5697 /**
5698 * Render chip jQuery element. 5699 * @param {Object} elem 5700 * @return {jQuery} 5701 */ 5702 this.renderChip = function (elem) { 5703 if (!elem.tag) return; 5704 5705 var $renderedChip = $('<div class="chip"></div>'); 5706 $renderedChip.text(elem.tag); 5707 if (elem.image) { 5708 $renderedChip.prepend($('<img />').attr('src', elem.image)); 5709 } 5710 $renderedChip.append($('<i class="material-icons close">close</i>')); 5711 return $renderedChip; 5712 }; 5713 5714 this.setPlaceholder = function ($chips) { 5715 if ($chips.data('chips') !== undefined && !$chips.data('chips').length && curr_options.placeholder) { 5716 $chips.find('input').prop('placeholder', curr_options.placeholder); 5717 } else if (($chips.data('chips') === undefined || !!$chips.data('chips').length) && curr_options.secondaryPlaceholder) { 5718 $chips.find('input').prop('placeholder', curr_options.secondaryPlaceholder); 5719 } 5720 }; 5721 5722 this.isValid = function ($chips, elem) { 5723 var chips = $chips.data('chips'); 5724 var exists = false; 5725 for (var i = 0; i < chips.length; i++) { 5726 if (chips[i].tag === elem.tag) { 5727 exists = true; 5728 return; 5729 } 5730 } 5731 return '' !== elem.tag && !exists; 5732 }; 5733 5734 this.addChip = function (elem, $chips) { 5735 if (!self.isValid($chips, elem)) { 5736 return; 5737 } 5738 var $renderedChip = self.renderChip(elem); 5739 var newData = []; 5740 var oldData = $chips.data('chips'); 5741 for (var i = 0; i < oldData.length; i++) { 5742 newData.push(oldData[i]); 5743 } 5744 newData.push(elem); 5745 5746 $chips.data('chips', newData); 5747 $renderedChip.insertBefore($chips.find('input')); 5748 $chips.trigger('chip.add', elem); 5749 self.setPlaceholder($chips); 5750 }; 5751 5752 this.deleteChip = function (chipIndex, $chips) { 5753 var chip = $chips.data('chips')[chipIndex]; 5754 $chips.find('.chip').eq(chipIndex).remove(); 5755 5756 var newData = []; 5757 var oldData = $chips.data('chips'); 5758 for (var i = 0; i < oldData.length; i++) { 5759 if (i !== chipIndex) { 5760 newData.push(oldData[i]); 5761 } 5762 } 5763 5764 $chips.data('chips', newData); 5765 $chips.trigger('chip.delete', chip); 5766 self.setPlaceholder($chips); 5767 }; 5768 5769 this.selectChip = function (chipIndex, $chips) { 5770 var $chip = $chips.find('.chip').eq(chipIndex); 5771 if ($chip && false === $chip.hasClass('selected')) { 5772 $chip.addClass('selected'); 5773 $chips.trigger('chip.select', $chips.data('chips')[chipIndex]); 5774 } 5775 }; 5776 5777 this.getChipsElement = function (index, $chips) { 5778 return $chips.eq(index); 5779 }; 5780 5781 // init 5782 this.init(); 5783 5784 this.handleEvents(); 5785 }; 5786})(jQuery); 5787;(function ($) { 5788 $.fn.pushpin = function (options) { 5789 // Defaults 5790 var defaults = { 5791 top: 0, 5792 bottom: Infinity, 5793 offset: 0 5794 }; 5795 5796 // Remove pushpin event and classes 5797 if (options === "remove") { 5798 this.each(function () { 5799 if (id = $(this).data('pushpin-id')) { 5800 $(window).off('scroll.' + id); 5801 $(this).removeData('pushpin-id').removeClass('pin-top pinned pin-bottom').removeAttr('style'); 5802 } 5803 }); 5804 return false; 5805 } 5806 5807 options = $.extend(defaults, options); 5808 5809 $index = 0; 5810 return this.each(function () { 5811 var $uniqueId = Materialize.guid(), 5812 $this = $(this), 5813 $original_offset = $(this).offset().top; 5814 5815 function removePinClasses(object) { 5816 object.removeClass('pin-top'); 5817 object.removeClass('pinned'); 5818 object.removeClass('pin-bottom'); 5819 } 5820 5821 function updateElements(objects, scrolled) { 5822 objects.each(function () { 5823 // Add position fixed (because its between top and bottom) 5824 if (options.top <= scrolled && options.bottom >= scrolled && !$(this).hasClass('pinned')) { 5825 removePinClasses($(this)); 5826 $(this).css('top', options.offset); 5827 $(this).addClass('pinned'); 5828 } 5829 5830 // Add pin-top (when scrolled position is above top) 5831 if (scrolled < options.top && !$(this).hasClass('pin-top')) { 5832 removePinClasses($(this)); 5833 $(this).css('top', 0); 5834 $(this).addClass('pin-top'); 5835 } 5836 5837 // Add pin-bottom (when scrolled position is below bottom) 5838 if (scrolled > options.bottom && !$(this).hasClass('pin-bottom')) { 5839 removePinClasses($(this)); 5840 $(this).addClass('pin-bottom'); 5841 $(this).css('top', options.bottom - $original_offset); 5842 } 5843 }); 5844 } 5845 5846 $(this).data('pushpin-id', $uniqueId); 5847 updateElements($this, $(window).scrollTop()); 5848 $(window).on('scroll.' + $uniqueId, function () { 5849 var $scrolled = $(window).scrollTop() + options.offset; 5850 updateElements($this, $scrolled); 5851 }); 5852 }); 5853 }; 5854})(jQuery);;(function ($) { 5855 $(document).ready(function () { 5856 5857 // jQuery reverse 5858 $.fn.reverse = [].reverse; 5859 5860 // Hover behaviour: make sure this doesn't work on .click-to-toggle FABs! 5861 $(document).on('mouseenter.fixedActionBtn', '.fixed-action-btn:not(.click-to-toggle):not(.toolbar)', function (e) { 5862 var $this = $(this); 5863 openFABMenu($this); 5864 }); 5865 $(document).on('mouseleave.fixedActionBtn', '.fixed-action-btn:not(.click-to-toggle):not(.toolbar)', function (e) { 5866 var $this = $(this); 5867 closeFABMenu($this); 5868 }); 5869 5870 // Toggle-on-click behaviour. 5871 $(document).on('click.fabClickToggle', '.fixed-action-btn.click-to-toggle > a', function (e) { 5872 var $this = $(this); 5873 var $menu = $this.parent(); 5874 if ($menu.hasClass('active')) { 5875 closeFABMenu($menu); 5876 } else { 5877 openFABMenu($menu); 5878 } 5879 }); 5880 5881 // Toolbar transition behaviour. 5882 $(document).on('click.fabToolbar', '.fixed-action-btn.toolbar > a', function (e) { 5883 var $this = $(this); 5884 var $menu = $this.parent(); 5885 FABtoToolbar($menu); 5886 }); 5887 }); 5888 5889 $.fn.extend({ 5890 openFAB: function () { 5891 openFABMenu($(this)); 5892 }, 5893 closeFAB: function () { 5894 closeFABMenu($(this)); 5895 }, 5896 openToolbar: function () { 5897 FABtoToolbar($(this)); 5898 }, 5899 closeToolbar: function () { 5900 toolbarToFAB($(this)); 5901 } 5902 }); 5903 5904 var openFABMenu = function (btn) { 5905 var $this = btn; 5906 if ($this.hasClass('active') === false) { 5907 5908 // Get direction option 5909 var horizontal = $this.hasClass('horizontal'); 5910 var offsetY, offsetX; 5911 5912 if (horizontal === true) { 5913 offsetX = 40; 5914 } else { 5915 offsetY = 40; 5916 } 5917 5918 $this.addClass('active'); 5919 $this.find('ul .btn-floating').velocity({ scaleY: ".4", scaleX: ".4", translateY: offsetY + 'px', translateX: offsetX + 'px' }, { duration: 0 }); 5920 5921 var time = 0; 5922 $this.find('ul .btn-floating').reverse().each(function () { 5923 $(this).velocity({ opacity: "1", scaleX: "1", scaleY: "1", translateY: "0", translateX: '0' }
5923, { duration: 80, delay: time }); 5924 time += 40; 5925 }); 5926 } 5927 }; 5928 5929 var closeFABMenu = function (btn) { 5930 var $this = btn; 5931 // Get direction option 5932 var horizontal = $this.hasClass('horizontal'); 5933 var offsetY, offsetX; 5934 5935 if (horizontal === true) { 5936 offsetX = 40; 5937 } else { 5938 offsetY = 40; 5939 } 5940 5941 $this.removeClass('active'); 5942 var time = 0; 5943 $this.find('ul .btn-floating').velocity("stop", true); 5944 $this.find('ul .btn-floating').velocity({ opacity: "0", scaleX: ".4", scaleY: ".4", translateY: offsetY + 'px', translateX: offsetX + 'px' }, { duration: 80 }); 5945 }; 5946 5947 /** 5948 * Transform FAB into toolbar 5949 * @param {Object} object jQuery object 5950 */ 5951 var FABtoToolbar = function (btn) { 5952 if (btn.attr('data-open') === "true") { 5953 return; 5954 } 5955 5956 var offsetX, offsetY, scaleFactor; 5957 var windowWidth = window.innerWidth; 5958 var windowHeight = window.innerHeight; 5959 var btnRect = btn[0].getBoundingClientRect(); 5960 var anchor = btn.find('> a').first(); 5961 var menu = btn.find('> ul').first(); 5962 var backdrop = $('<div class="fab-backdrop"></div>'); 5963 var fabColor = anchor.css('background-color'); 5964 anchor.append(backdrop); 5965 5966 offsetX = btnRect.left - windowWidth / 2 + btnRect.width / 2; 5967 offsetY = windowHeight - btnRect.bottom; 5968 scaleFactor = windowWidth / backdrop.width(); 5969 btn.attr('data-origin-bottom', btnRect.bottom); 5970 btn.attr('data-origin-left', btnRect.left); 5971 btn.attr('data-origin-width', btnRect.width); 5972 5973 // Set initial state 5974 btn.addClass('active'); 5975 btn.attr('data-open', true); 5976 btn.css({ 5977 'text-align': 'center', 5978 width: '100%', 5979 bottom: 0, 5980 left: 0, 5981 transform: 'translateX(' + offsetX + 'px)', 5982 transition: 'none' 5983 }); 5984 anchor.css({ 5985 transform: 'translateY(' + -offsetY + 'px)', 5986 transition: 'none' 5987 }); 5988 backdrop.css({ 5989 'background-color': fabColor 5990 }); 5991 5992 setTimeout(function () { 5993 btn.css({ 5994 transform: '', 5995 transition: 'transform .2s cubic-bezier(0.550, 0.085, 0.680, 0.530), background-color 0s linear .2s' 5996 }); 5997 anchor.css({ 5998 overflow: 'visible', 5999 transform: '', 6000 transition: 'transform .2s' 6001 }); 6002 6003 setTimeout(function () { 6004 btn.css({ 6005 overflow: 'hidden', 6006 'background-color': fabColor 6007 }); 6008 backdrop.css({ 6009 transform: 'scale(' + scaleFactor + ')', 6010 transition: 'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)' 6011 }); 6012 menu.find('> li > a').css({ 6013 opacity: 1 6014 }); 6015 6016 // Scroll to close. 6017 $(window).on('scroll.fabToolbarClose', function () { 6018 toolbarToFAB(btn); 6019 $(window).off('scroll.fabToolbarClose'); 6020 $(document).off('click.fabToolbarClose'); 6021 }); 6022 6023 $(document).on('click.fabToolbarClose', function (e) { 6024 if (!$(e.target).closest(menu).length) { 6025 toolbarToFAB(btn); 6026 $(window).off('scroll.fabToolbarClose'); 6027 $(document).off('click.fabToolbarClose'); 6028 } 6029 }); 6030 }, 100); 6031 }, 0); 6032 }; 6033 6034 /** 6035 * Transform toolbar back into FAB 6036 * @param {Object} object jQuery object 6037 */ 6038 var toolbarToFAB = function (btn) { 6039 if (btn.attr('data-open') !== "true") { 6040 return; 6041 } 6042 6043 var offsetX, offsetY, scaleFactor; 6044 var windowWidth = window.innerWidth; 6045 var windowHeight = window.innerHeight; 6046 var btnWidth = btn.attr('data-origin-width'); 6047 var btnBottom = btn.attr('data-origin-bottom'); 6048 var btnLeft = btn.attr('data-origin-left'); 6049 var anchor = btn.find('> .btn-floating').first(); 6050 var menu = btn.find('> ul').first(); 6051 var backdrop = btn.find('.fab-backdrop'); 6052 var fabColor = anchor.css('background-color'); 6053 6054 offsetX = btnLeft - windowWidth / 2 + btnWidth / 2; 6055 offsetY = windowHeight - btnBottom; 6056 scaleFactor = windowWidth / backdrop.width(); 6057 6058 // Hide backdrop 6059 btn.removeClass('active'); 6060 btn.attr('data-open', false); 6061 btn.css({ 6062 'background-color': 'transparent', 6063 transition: 'none' 6064 }); 6065 anchor.css({ 6066 transition: 'none' 6067 }); 6068 backdrop.css({ 6069 transform: 'scale(0)', 6070 'background-color': fabColor 6071 }); 6072 menu.find('> li > a').css({ 6073 opacity: '' 6074 }); 6075 6076 setTimeout(function () { 6077 backdrop.remove(); 6078 6079 // Set initial state. 6080 btn.css({ 6081 'text-align': '', 6082 width: '', 6083 bottom: '', 6084 left: '', 6085 overflow: '', 6086 'background-color': '', 6087 transform: 'translate3d(' + -offsetX + 'px,0,0)' 6088 }); 6089 anchor.css({ 6090 overflow: '', 6091 transform: 'translate3d(0,' + offsetY + 'px,0)' 6092 }); 6093 6094 setTimeout(function () { 6095 btn.css({
6096 transform: 'translate3d(0,0,0)', 6097 transition: 'transform .2s' 6098 }); 6099 anchor.css({ 6100 transform: 'translate3d(0,0,0)', 6101 transition: 'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)' 6102 }); 6103 }, 20); 6104 }, 200); 6105 }; 6106})(jQuery); 6107;(function ($) { 6108 // Image transition function 6109 Materialize.fadeInImage = function (selectorOrEl) { 6110 var element; 6111 if (typeof selectorOrEl === 'string') { 6112 element = $(selectorOrEl); 6113 } else if (typeof selectorOrEl === 'object') { 6114 element = selectorOrEl; 6115 } else { 6116 return; 6117 } 6118 element.css({ opacity: 0 }); 6119 $(element).velocity({ opacity: 1 }, { 6120 duration: 650, 6121 queue: false, 6122 easing: 'easeOutSine' 6123 }); 6124 $(element).velocity({ opacity: 1 }, { 6125 duration: 1300, 6126 queue: false, 6127 easing: 'swing', 6128 step: function (now, fx) { 6129 fx.start = 100; 6130 var grayscale_setting = now / 100; 6131 var brightness_setting = 150 - (100 - now) / 1.75; 6132 6133 if (brightness_setting < 100) { 6134 brightness_setting = 100; 6135 } 6136 if (now >= 0) { 6137 $(this).css({ 6138 "-webkit-filter": "grayscale(" + grayscale_setting + ")" + "brightness(" + brightness_setting + "%)", 6139 "filter": "grayscale(" + grayscale_setting + ")" + "brightness(" + brightness_setting + "%)" 6140 }); 6141 } 6142 } 6143 }); 6144 }; 6145 6146 // Horizontal staggered list 6147 Materialize.showStaggeredList = function (selectorOrEl) { 6148 var element; 6149 if (typeof selectorOrEl === 'string') { 6150 element = $(selectorOrEl); 6151 } else if (typeof selectorOrEl === 'object') { 6152 element = selectorOrEl; 6153 } else { 6154 return; 6155 } 6156 var time = 0; 6157 element.find('li').velocity({ translateX: "-100px" }, { duration: 0 }); 6158 6159 element.find('li').each(function () { 6160 $(this).velocity({ opacity: "1", translateX: "0" }, { duration: 800, delay: time, easing: [60, 10] }); 6161 time += 120; 6162 }); 6163 }; 6164 6165 $(document).ready(function () { 6166 // Hardcoded .staggered-list scrollFire 6167 // var staggeredListOptions = []; 6168 // $('ul.staggered-list').each(function (i) { 6169 6170 // var label = 'scrollFire-' + i; 6171 // $(this).addClass(label); 6172 // staggeredListOptions.push( 6173 // {selector: 'ul.staggered-list.' + label, 6174 // offset: 200, 6175 // callback: 'showStaggeredList("ul.staggered-list.' + label + '")'}); 6176 // }); 6177 // scrollFire(staggeredListOptions); 6178 6179 // HammerJS, Swipe navigation 6180 6181 // Touch Event 6182 var swipeLeft = false; 6183 var swipeRight = false; 6184 6185 // Dismissible Collections 6186 $('.dismissable').each(function () { 6187 $(this).hammer({ 6188 prevent_default: false 6189 }).on('pan', function (e) { 6190 if (e.gesture.pointerType === "touch") { 6191 var $this = $(this); 6192 var direction = e.gesture.direction; 6193 var x = e.gesture.deltaX; 6194 var velocityX = e.gesture.velocityX; 6195 6196 $this.velocity({ translateX: x 6197 }, { duration: 50, queue: false, easing: 'easeOutQuad' }); 6198 6199 // Swipe Left 6200 if (direction === 4 && (x > $this.innerWidth() / 2 || velocityX < -0.75)) { 6201 swipeLeft = true; 6202 } 6203 6204 // Swipe Right 6205 if (direction === 2 && (x < -1 * $this.innerWidth() / 2 || velocityX > 0.75)) { 6206 swipeRight = true; 6207 } 6208 } 6209 }).on('panend', function (e) { 6210 // Reset if collection is moved back into original position 6211 if (Math.abs(e.gesture.deltaX) < $(this).innerWidth() / 2) { 6212 swipeRight = false; 6213 swipeLeft = false; 6214 } 6215 6216 if (e.gesture.pointerType === "touch") { 6217 var $this = $(this); 6218 if (swipeLeft || swipeRight) { 6219 var fullWidth; 6220 if (swipeLeft) { 6221 fullWidth = $this.innerWidth(); 6222 } else { 6223 fullWidth = -1 * $this.innerWidth(); 6224 } 6225 6226 $this.velocity({ translateX: fullWidth 6227 }, { duration: 100, queue: false, easing: 'easeOutQuad', complete: function () { 6228 $this.css('border', 'none'); 6229 $this.velocity({ height: 0, padding: 0 6230 }, { duration: 200, queue: false, easing: 'easeOutQuad', complete: function () { 6231 $this.remove(); 6232 } 6233 }); 6234 } 6235 }); 6236 } else { 6237 $this.velocity({ translateX: 0 6238 }, { duration: 100, queue: false, easing: 'easeOutQuad' }); 6239 } 6240 swipeLeft = false;
6241 swipeRight = false; 6242 } 6243 }); 6244 }); 6245 6246 // time = 0 6247 // // Vertical Staggered list 6248 // $('ul.staggered-list.vertical li').velocity( 6249 // { translateY: "100px"}, 6250 // { duration: 0 }); 6251 6252 // $('ul.staggered-list.vertical li').each(function() { 6253 // $(this).velocity( 6254 // { opacity: "1", translateY: "0"}, 6255 // { duration: 800, delay: time, easing: [60, 25] }); 6256 // time += 120; 6257 // }); 6258 6259 // // Fade in and Scale 6260 // $('.fade-in.scale').velocity( 6261 // { scaleX: .4, scaleY: .4, translateX: -600}, 6262 // { duration: 0}); 6263 // $('.fade-in').each(function() { 6264 // $(this).velocity( 6265 // { opacity: "1", scaleX: 1, scaleY: 1, translateX: 0}, 6266 // { duration: 800, easing: [60, 10] }); 6267 // }); 6268 }); 6269})(jQuery); 6270;(function ($) { 6271 6272 var scrollFireEventsHandled = false; 6273 6274 // Input: Array of JSON objects {selector, offset, callback} 6275 Materialize.scrollFire = function (options) { 6276 var onScroll = function () { 6277 var windowScroll = window.pageYOffset + window.innerHeight; 6278 6279 for (var i = 0; i < options.length; i++) { 6280 // Get options from each line 6281 var value = options[i]; 6282 var selector = value.selector, 6283 offset = value.offset, 6284 callback = value.callback; 6285 6286 var currentElement = document.querySelector(selector); 6287 if (currentElement !== null) { 6288 var elementOffset = currentElement.getBoundingClientRect().top + window.pageYOffset; 6289 6290 if (windowScroll > elementOffset + offset) { 6291 if (value.done !== true) { 6292 if (typeof callback === 'function') { 6293 callback.call(this, currentElement); 6294 } else if (typeof callback === 'string') { 6295 var callbackFunc = new Function(callback); 6296 callbackFunc(currentElement); 6297 } 6298 value.done = true; 6299 } 6300 } 6301 } 6302 } 6303 }; 6304 6305 var throttledScroll = Materialize.throttle(function () { 6306 onScroll(); 6307 }, options.throttle || 100); 6308 6309 if (!scrollFireEventsHandled) { 6310 window.addEventListener("scroll", throttledScroll); 6311 window.addEventListener("resize", throttledScroll); 6312 scrollFireEventsHandled = true; 6313 } 6314 6315 // perform a scan once, after current execution context, and after dom is ready 6316 setTimeout(throttledScroll, 0); 6317 }; 6318})(jQuery); 6319; /*! 6320 * pickadate.js v3.5.0, 2014/04/13 6321 * By Amsul, http://amsul.ca 6322 * Hosted on http://amsul.github.io/pickadate.js 6323 * Licensed under MIT 6324 */ 6325 6326(function (factory) { 6327 6328 Materialize.Picker = factory(jQuery); 6329})(function ($) { 6330 6331 var $window = $(window); 6332 var $document = $(document); 6333 var $html = $(document.documentElement); 6334 6335 /** 6336 * The picker constructor that creates a blank picker. 6337 */ 6338 function PickerConstructor(ELEMENT, NAME, COMPONENT, OPTIONS) { 6339 6340 // If thereâs no element, return the picker constructor. 6341 if (!ELEMENT) return PickerConstructor; 6342 6343 var IS_DEFAULT_THEME = false, 6344 6345 6346 // The state of the picker. 6347 STATE = { 6348 id: ELEMENT.id || 'P' + Math.abs(~~(Math.random() * new Date())) 6349 }, 6350 6351 6352 // Merge the defaults and options passed. 6353 SETTINGS = COMPONENT ? $.extend(true, {}, COMPONENT.defaults, OPTIONS) : OPTIONS || {}, 6354 6355 6356 // Merge the default classes with the settings classes. 6357 CLASSES = $.extend({}, PickerConstructor.klasses(), SETTINGS.klass), 6358 6359 6360 // The element node wrapper into a jQuery object. 6361 $ELEMENT = $(ELEMENT), 6362 6363 6364 // Pseudo picker constructor. 6365 PickerInstance = function () { 6366 return this.start(); 6367 }, 6368 6369 6370 // The picker prototype. 6371 P = PickerInstance.prototype = { 6372 6373 constructor: PickerInstance, 6374 6375 $node: $ELEMENT, 6376 6377 /** 6378 * Initialize everything 6379 */ 6380 start: function () { 6381 6382 // If itâs already started, do nothing. 6383 if (STATE && STATE.start) return P; 6384 6385 // Update the picker states. 6386 STATE.methods = {}; 6387 STATE.start = true; 6388 STATE.open = false; 6389 STATE.type = ELEMENT.type; 6390 6391 // Confirm focus state, convert into text input to remove UA stylings, 6392 // and set as readonly to prevent keyboard popup. 6393 ELEMENT.autofocus = ELEMENT == getActiveElement(); 6394 ELEMENT.readOnly = !SETTINGS.editable; 6395 ELEMENT.id = ELEMENT.id || STATE.id; 6396 if (ELEMENT.type != 'text') { 6397 ELEMENT.type = 'text'; 6398 } 6399 6400 // Create a new picker component with the settings. 6401 P.component = new COMPONENT(P, SETTINGS); 6402 6403 // Create the picker root with a holder and then prepare it. 6404 P.$root = $(PickerConstructor._.node('div', createWrappedComponent(), CLASSES.picker, 'id="' + ELEMENT.id + '_root" tabindex="0"')); 6405 prepareElementRoot(); 6406 6407 // If thereâs a format for the hidden input element, create the element. 6408 if (SETTINGS.formatSubmit) { 6409 prepareElementHidden(); 6410 } 6411 6412 // Prepare the input element. 6413 prepareElement(); 6414 6415 // Insert the root as specified in the settings. 6416 if (SETTINGS.container) $(SETTINGS.container).append(P.$root);else $ELEMENT.before(P.$root); 6417 6418 // Bind the default component and settings events. 6419 P.on({ 6420 start: P.component.onStart, 6421 render: P.component.onRender, 6422 stop: P.component.onStop, 6423 open: P.component.onOpen, 6424 close: P.component.onClose, 6425 set: P.component.onSet 6426 }).on({ 6427 start: SETTINGS.onStart, 6428 render: SETTINGS.onRender, 6429 stop: SETTINGS.onStop, 6430 open: SETTINGS.onOpen, 6431 close: SETTINGS.onClose, 6432 set: SETTINGS.onSet 6433 }); 6434 6435 // Once weâre all set, check the theme in use. 6436 IS_DEFAULT_THEME = isUsingDefaultTheme(P.$root.children()[0]); 6437 6438 // If the element has autofocus, open the picker. 6439 if (ELEMENT.autofocus) { 6440 P.open(); 6441 } 6442 6443 // Trigger queued the âstartâ and ârenderâ events. 6444 return P.trigger('start').trigger('render'); 6445 }, //start 6446 6447 6448 /**
6449 * Render a new picker 6450 */ 6451 render: function (entireComponent) { 6452 6453 // Insert a new component holder in the root or box. 6454 if (entireComponent) P.$root.html(createWrappedComponent());else P.$root.find('.' + CLASSES.box).html(P.component.nodes(STATE.open)); 6455 6456 // Trigger the queued ârenderâ events. 6457 return P.trigger('render'); 6458 }, //render 6459 6460 6461 /** 6462 * Destroy everything 6463 */ 6464 stop: function () { 6465 6466 // If itâs already stopped, do nothing. 6467 if (!STATE.start) return P; 6468 6469 // Then close the picker. 6470 P.close(); 6471 6472 // Remove the hidden field. 6473 if (P._hidden) { 6474 P._hidden.parentNode.removeChild(P._hidden); 6475 } 6476 6477 // Remove the root. 6478 P.$root.remove(); 6479 6480 // Remove the input class, remove the stored data, and unbind 6481 // the events (after a tick for IE - see `P.close`). 6482 $ELEMENT.removeClass(CLASSES.input).removeData(NAME); 6483 setTimeout(function () { 6484 $ELEMENT.off('.' + STATE.id); 6485 }, 0); 6486 6487 // Restore the element state 6488 ELEMENT.type = STATE.type; 6489 ELEMENT.readOnly = false; 6490 6491 // Trigger the queued âstopâ events. 6492 P.trigger('stop'); 6493 6494 // Reset the picker states. 6495 STATE.methods = {}; 6496 STATE.start = false;
6497 6498 return P; 6499 }, //stop 6500 6501 6502 /** 6503 * Open up the picker 6504 */ 6505 open: function (dontGiveFocus) { 6506 6507 // If itâs already open, do nothing. 6508 if (STATE.open) return P; 6509 6510 // Add the âactiveâ class. 6511 $ELEMENT.addClass(CLASSES.active); 6512 aria(ELEMENT, 'expanded', true); 6513 6514 // * A Firefox bug, when `html` has `overflow:hidden`, results in 6515 // killing transitions :(. So add the âopenedâ state on the next tick. 6516 // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=625289 6517 setTimeout(function () { 6518 6519 // Add the âopenedâ class to the picker root. 6520 P.$root.addClass(CLASSES.opened); 6521 aria(P.$root[0], 'hidden', false); 6522 }, 0); 6523 6524 // If we have to give focus, bind the element and doc events. 6525 if (dontGiveFocus !== false) { 6526 6527 // Set it as open. 6528 STATE.open = true; 6529 6530 // Prevent the page from scrolling. 6531 if (IS_DEFAULT_THEME) { 6532 $html.css('overflow', 'hidden').css('padding-right', '+=' + getScrollbarWidth()); 6533 } 6534 6535 // Pass focus to the root elementâs jQuery object. 6536 // * Workaround for iOS8 to bring the pickerâs root into view. 6537 P.$root.eq(0).focus(); 6538 6539 // Bind the document events. 6540 $document.on('click.' + STATE.id + ' focusin.' + STATE.id, function (event) { 6541 6542 var target = event.target; 6543 6544 // If the target of the event is not the element, close the picker picker. 6545 // * Donât worry about clicks or focusins on the root because those donât bubble up. 6546 // Also, for Firefox, a click on an `option` element bubbles up directly 6547 // to the doc. So make sure the target wasn't the doc. 6548 // * In Firefox stopPropagation() doesnât prevent right-click events from bubbling, 6549 // which causes the picker to unexpectedly close when right-clicking it. So make 6550 // sure the event wasnât a right-click. 6551 if (target != ELEMENT && target != document && event.which != 3) { 6552 6553 // If the target was the holder that covers the screen, 6554 // keep the element focused to maintain tabindex. 6555 P.close(target === P.$root.children()[0]); 6556 } 6557 }).on('keydown.' + STATE.id, function (event) { 6558 6559 var 6560 // Get the keycode. 6561 keycode = event.keyCode, 6562 6563 6564 // Translate that to a selection change. 6565 keycodeToMove = P.component.key[keycode], 6566 6567 6568 // Grab the target. 6569 target = event.target; 6570 6571 // On escape, close the picker and give focus. 6572 if (keycode == 27) { 6573 P.close(true); 6574 } 6575 6576 // Check if there is a key movement or âenterâ keypress on the element. 6577 else if (target == P.$root[0] && (keycodeToMove || keycode == 13)) { 6578 6579 // Prevent the default action to stop page movement. 6580 event.preventDefault(); 6581 6582 // Trigger the key movement action. 6583 if (keycodeToMove) { 6584 PickerConstructor._.trigger(P.component.key.go, P, [PickerConstructor._.trigger(keycodeToMove)]); 6585 } 6586 6587 // On âenterâ, if the highlighted item isnât disabled, set the value and close. 6588 else if (!P.$root.find('.' + CLASSES.highlighted).hasClass(CLASSES.disabled)) { 6589 P.set('select', P.component.item.highlight); 6590 if (SETTINGS.closeOnSelect) { 6591 P.close(true); 6592 } 6593 } 6594 } 6595 6596 // If the target is within the root and âenterâ is pressed, 6597 // prevent the default action and trigger a click on the target instead. 6598 else if ($.contains(P.$root[0], target) && keycode == 13) { 6599 event.preventDefault(); 6600 target.click(); 6601 } 6602 }); 6603 } 6604 6605 // Trigger the queued âopenâ events. 6606 return P.trigger('open'); 6607 }, //open 6608 6609 6610 /** 6611 * Close the picker 6612 */ 6613 close: function (giveFocus) { 6614 6615 // If we need to give focus, do it before changing states. 6616 if (giveFocus) { 6617 // ....ah yes! It wouldâve been incomplete without a crazy workaround for IE :| 6618 // The focus is triggered *after* the close has completed - causing it 6619 // to open again. So unbind and rebind the event at the next tick. 6620 P.$root.off('focus.toOpen').eq(0).focus(); 6621 setTimeout(function () { 6622 P.$root.on('focus.toOpen', handleFocusToOpenEvent); 6623 }, 0); 6624 } 6625 6626 // Remove the âactiveâ class. 6627 $ELEMENT.removeClass(CLASSES.active); 6628 aria(ELEMENT, 'expanded', false); 6629 6630 // * A Firefox bug, when `html` has `overflow:hidden`, results in 6631 // killing transitions :(. So remove the âopenedâ state on the next tick. 6632 // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=625289 6633 setTimeout(function () { 6634 6635 // Remove the âopenedâ and âfocusedâ class from the picker root. 6636 P.$root.removeClass(CLASSES.opened + ' ' + CLASSES.focused); 6637 aria(P.$root[0], 'hidden', true); 6638 }, 0); 6639 6640 // If itâs already closed, do nothing more. 6641 if (!STATE.open) return P; 6642 6643 // Set it as closed. 6644 STATE.open = false;
6645 6646 // Allow the page to scroll. 6647 if (IS_DEFAULT_THEME) { 6648 $html.css('overflow', '').css('padding-right', '-=' + getScrollbarWidth()); 6649 } 6650 6651 // Unbind the document events. 6652 $document.off('.' + STATE.id); 6653 6654 // Trigger the queued âcloseâ events. 6655 return P.trigger('close'); 6656 }, //close 6657 6658 6659 /** 6660 * Clear the values 6661 */ 6662 clear: function (options) { 6663 return P.set('clear', null, options); 6664 }, //clear 6665 6666 6667 /** 6668 * Set something 6669 */ 6670 set: function (thing, value, options) { 6671 6672 var thingItem, 6673 thingValue, 6674 thingIsObject = $.isPlainObject(thing), 6675 thingObject = thingIsObject ? thing : {}; 6676 6677 // Make sure we have usable options. 6678 options = thingIsObject && $.isPlainObject(value) ? value : options || {}; 6679 6680 if (thing) { 6681 6682 // If the thing isnât an object, make it one. 6683 if (!thingIsObject) { 6684 thingObject[thing] = value; 6685 } 6686 6687 // Go through the things of items to set. 6688 for (thingItem in thingObject) { 6689 6690 // Grab the value of the thing. 6691 thingValue = thingObject[thingItem]; 6692 6693 // First, if the item exists and thereâs a value, set it. 6694 if (thingItem in P.component.item) { 6695 if (thingValue === undefined) thingValue = null; 6696 P.component.set(thingItem, thingValue, options); 6697 } 6698 6699 // Then, check to update the element value and broadcast a change. 6700 if (thingItem == 'select' || thingItem == 'clear') { 6701 $ELEMENT.val(thingItem == 'clear' ? '' : P.get(thingItem, SETTINGS.format)).trigger('change'); 6702 } 6703 } 6704 6705 // Render a new picker. 6706 P.render(); 6707 } 6708 6709 // When the method isnât muted, trigger queued âsetâ events and pass the `thingObject`. 6710 return options.muted ? P : P.trigger('set', thingObject); 6711 }, //set 6712 6713 6714 /** 6715 * Get something 6716 */ 6717 get: function (thing, format) { 6718 6719 // Make sure thereâs something to get. 6720 thing = thing || 'value'; 6721 6722 // If a picker state exists, return that. 6723 if (STATE[thing] != null) { 6724 return STATE[thing]; 6725 } 6726 6727 // Return the submission value, if that. 6728 if (thing == 'valueSubmit') { 6729 if (P._hidden) { 6730 return P._hidden.value; 6731 } 6732 thing = 'value'; 6733 } 6734 6735 // Return the value, if that. 6736 if (thing == 'value') { 6737 return ELEMENT.value; 6738 } 6739 6740 // Check if a component item exists, return that. 6741 if (thing in P.component.item) { 6742 if (typeof format == 'string') { 6743 var thingValue = P.component.get(thing); 6744 return thingValue ? PickerConstructor._.trigger(P.component.formats.toString, P.component, [format, thingValue]) : ''; 6745 } 6746 return P.component.get(thing); 6747 } 6748 }, //get 6749 6750 6751 /** 6752 * Bind events on the things. 6753 */ 6754 on: function (thing, method, internal) { 6755 6756 var thingName, 6757 thingMethod, 6758 thingIsObject = $.isPlainObject(thing), 6759 thingObject = thingIsObject ? thing : {}; 6760 6761 if (thing) { 6762 6763 // If the thing isnât an object, make it one. 6764 if (!thingIsObject) { 6765 thingObject[thing] = method; 6766 } 6767 6768 // Go through the things to bind to. 6769 for (thingName in thingObject) { 6770 6771 // Grab the method of the thing. 6772 thingMethod = thingObject[thingName]; 6773 6774 // If it was an internal binding, prefix it. 6775 if (internal) { 6776 thingName = '_' + thingName; 6777 } 6778 6779 // Make sure the thing methods collection exists. 6780 STATE.methods[thingName] = STATE.methods[thingName] || []; 6781 6782 // Add the method to the relative method collection. 6783 STATE.methods[thingName].push(thingMethod); 6784 } 6785 } 6786 6787 return P; 6788 }, //on 6789 6790 6791 /** 6792 * Unbind events on the things. 6793 */ 6794 off: function () { 6795 var i, 6796 thingName, 6797 names = arguments; 6798 for (i = 0, namesCount = names.length; i < namesCount; i += 1) { 6799 thingName = names[i]; 6800 if (thingName in STATE.methods) { 6801 delete STATE.methods[thingName]; 6802 } 6803 } 6804 return P; 6805 }, 6806 6807 /** 6808 * Fire off method events. 6809 */ 6810 trigger: function (name, data) { 6811 var _trigger = function (name) { 6812 var methodList = STATE.methods[name]; 6813 if (methodList) { 6814 methodList.map(function (method) { 6815 PickerConstructor._.trigger(method, P, [data]); 6816 }); 6817 } 6818 }; 6819 _trigger('_' + name); 6820 _trigger(name); 6821 return P; 6822 }
6822 //trigger 6823 //PickerInstance.prototype 6824 6825 6826 /** 6827 * Wrap the picker holder components together. 6828 */ 6829 };function createWrappedComponent() { 6830 6831 // Create a picker wrapper holder 6832 return PickerConstructor._.node('div', 6833 6834 // Create a picker wrapper node 6835 PickerConstructor._.node('div', 6836 6837 // Create a picker frame 6838 PickerConstructor._.node('div', 6839 6840 // Create a picker box node 6841 PickerConstructor._.node('div', 6842 6843 // Create the components nodes. 6844 P.component.nodes(STATE.open), 6845 6846 // The picker box class 6847 CLASSES.box), 6848 6849 // Picker wrap class 6850 CLASSES.wrap), 6851 6852 // Picker frame class 6853 CLASSES.frame), 6854 6855 // Picker holder class 6856 CLASSES.holder); //endreturn 6857 } //createWrappedComponent 6858 6859 6860 /** 6861 * Prepare the input element with all bindings. 6862 */ 6863 function prepareElement() { 6864 6865 $ELEMENT. 6866 6867 // Store the picker data by component name. 6868 data(NAME, P). 6869 6870 // Add the âinputâ class name. 6871 addClass(CLASSES.input). 6872 6873 // Remove the tabindex. 6874 attr('tabindex', -1). 6875 6876 // If thereâs a `data-value`, update the value of the element. 6877 val($ELEMENT.data('value') ? P.get('select', SETTINGS.format) : ELEMENT.value); 6878 6879 // Only bind keydown events if the element isnât editable. 6880 if (!SETTINGS.editable) { 6881 6882 $ELEMENT. 6883 6884 // On focus/click, focus onto the root to open it up. 6885 on('focus.' + STATE.id + ' click.' + STATE.id, function (event) { 6886 event.preventDefault(); 6887 P.$root.eq(0).focus(); 6888 }). 6889 6890 // Handle keyboard event based on the picker being opened or not. 6891 on('keydown.' + STATE.id, handleKeydownEvent); 6892 } 6893 6894 // Update the aria attributes. 6895 aria(ELEMENT, { 6896 haspopup: true, 6897 expanded: false, 6898 readonly: false, 6899 owns: ELEMENT.id + '_root' 6900 }); 6901 } 6902 6903 /** 6904 * Prepare the root picker element with all bindings. 6905 */ 6906 function prepareElementRoot() { 6907 6908 P.$root.on({ 6909 6910 // For iOS8. 6911 keydown: handleKeydownEvent, 6912 6913 // When something within the root is focused, stop from bubbling 6914 // to the doc and remove the âfocusedâ state from the root. 6915 focusin: function (event) { 6916 P.$root.removeClass(CLASSES.focused); 6917 event.stopPropagation(); 6918 }, 6919 6920 // When something within the root holder is clicked, stop it 6921 // from bubbling to the doc. 6922 'mousedown click': function (event) { 6923 6924 var target = event.target; 6925 6926 // Make sure the target isnât the root holder so it can bubble up. 6927 if (target != P.$root.children()[0]) { 6928 6929 event.stopPropagation(); 6930 6931 // * For mousedown events, cancel the default action in order to 6932 // prevent cases where focus is shifted onto external elements 6933 // when using things like jQuery mobile or MagnificPopup (ref: #249 & #120). 6934 // Also, for Firefox, donât prevent action on the `option` element. 6935 if (event.type == 'mousedown' && !$(target).is('input, select, textarea, button, option')) { 6936 6937 event.preventDefault(); 6938 6939 // Re-focus onto the root so that users can click away 6940 // from elements focused within the picker. 6941 P.$root.eq(0).focus(); 6942 } 6943 } 6944 } 6945 }). 6946 6947 // Add/remove the âtargetâ class on focus and blur. 6948 on({ 6949 focus: function () { 6950 $ELEMENT.addClass(CLASSES.target); 6951 }, 6952 blur: function () { 6953 $ELEMENT.removeClass(CLASSES.target); 6954 } 6955 }). 6956 6957 // Open the picker and adjust the root âfocusedâ state 6958 on('focus.toOpen', handleFocusToOpenEvent). 6959 6960 // If thereâs a click on an actionable element, carry out the actions. 6961 on('click', '[data-pick], [data-nav], [data-clear], [data-close]', function () { 6962 6963 var $target = $(this), 6964 targetData = $target.data(), 6965 targetDisabled = $target.hasClass(CLASSES.navDisabled) || $target.hasClass(CLASSES.disabled), 6966 6967 6968 // * For IE, non-focusable elements can be active elements as well 6969 // (http://stackoverflow.com/a/2684561). 6970 activeElement = getActiveElement(); 6971 activeElement = activeElement && (activeElement.type || activeElement.href); 6972 6973 // If itâs disabled or nothing inside is actively focused, re-focus the element. 6974 if (targetDisabled || activeElement && !$.contains(P.$root[0], activeElement)) { 6975 P.$root.eq(0).focus(); 6976 } 6977 6978 // If something is superficially changed, update the `highlight` based on the `nav`. 6979 if (!targetDisabled && targetData.nav) { 6980 P.set('highlight', P.component.item.highlight, { nav: targetData.nav }); 6981 } 6982 6983 // If something is picked, set `select` then close with focus. 6984 else if (!targetDisabled && 'pick' in targetData) { 6985 P.set('select', targetData.pick); 6986 if (SETTINGS.closeOnSelect) { 6987 P.close(true); 6988 } 6989 } 6990 6991 // If a âclearâ button is pressed, empty the values and close with focus. 6992 else if (targetData.clear) { 6993 P.clear(); 6994 if (SETTINGS.closeOnSelect) { 6995 P.close(true); 6996 } 6997 } else if (targetData.close) { 6998 P.close(true); 6999 } 7000 }); //P.$root 7001 7002 aria(P.$root[0], 'hidden', true); 7003 } 7004 7005 /** 7006 * Prepare the hidden input element along with all bindings. 7007 */ 7008 function prepareElementHidden() { 7009 7010 var name; 7011 7012 if (SETTINGS.hiddenName === true) { 7013 name = ELEMENT.name; 7014 ELEMENT.name = ''; 7015 } else { 7016 name = [typeof SETTINGS.hiddenPrefix == 'string' ? SETTINGS.hiddenPrefix : '', typeof SETTINGS.hiddenSuffix == 'string' ? SETTINGS.hiddenSuffix : '_submit']; 7017 name = name[0] + ELEMENT.name + name[1]; 7018 } 7019 7020 P._hidden = $('<input ' + 'type=hidden ' + 7021 7022 // Create the name using the original inputâs with a prefix and suffix. 7023 'name="' + name + '"' + ( 7024 7025 // If the element has a value, set the hidden value as well. 7026 $ELEMENT.data('value') || ELEMENT.value ? ' value="' + P.get('select', SETTINGS.formatSubmit) + '"' : '') + '>')[0]; 7027 7028 $ELEMENT. 7029 7030 // If the value changes, update the hidden input with the correct format. 7031 on('change.' + STATE.id, function () { 7032 P._hidden.value = ELEMENT.value ? P.get('select', SETTINGS.formatSubmit) : ''; 7033 }); 7034 7035 // Insert the hidden input as specified in the settings. 7036 if (SETTINGS.container) $(SETTINGS.container).append(P._hidden);else $ELEMENT.before(P._hidden); 7037 } 7038 7039 // For iOS8. 7040 function handleKeydownEvent(event) { 7041 7042 var keycode = event.keyCode, 7043 7044 7045 // Check if one of the delete keys was pressed. 7046 isKeycodeDelete = /^(8|46)$/.test(keycode); 7047 7048 // For some reason IE clears the input value on âescapeâ. 7049 if (keycode == 27) { 7050 P.close(); 7051 return false;
7052 } 7053 7054 // Check if `space` or `delete` was pressed or the picker is closed with a key movement. 7055 if (keycode == 32 || isKeycodeDelete || !STATE.open && P.component.key[keycode]) { 7056 7057 // Prevent it from moving the page and bubbling to doc. 7058 event.preventDefault(); 7059 event.stopPropagation(); 7060 7061 // If `delete` was pressed, clear the values and close the picker. 7062 // Otherwise open the picker. 7063 if (isKeycodeDelete) { 7064 P.clear().close(); 7065 } else { 7066 P.open(); 7067 } 7068 } 7069 } 7070 7071 // Separated for IE 7072 function handleFocusToOpenEvent(event) { 7073 7074 // Stop the event from propagating to the doc. 7075 event.stopPropagation(); 7076 7077 // If itâs a focus event, add the âfocusedâ class to the root. 7078 if (event.type == 'focus') { 7079 P.$root.addClass(CLASSES.focused); 7080 } 7081 7082 // And then finally open the picker. 7083 P.open(); 7084 } 7085 7086 // Return a new picker instance. 7087 return new PickerInstance(); 7088 } //PickerConstructor 7089 7090 7091 /** 7092 * The default classes and prefix to use for the HTML classes. 7093 */ 7094 PickerConstructor.klasses = function (prefix) { 7095 prefix = prefix || 'picker'; 7096 return { 7097 7098 picker: prefix, 7099 opened: prefix + '--opened', 7100 focused: prefix + '--focused', 7101 7102 input: prefix + '__input', 7103 active: prefix + '__input--active', 7104 target: prefix + '__input--target', 7105 7106 holder: prefix + '__holder', 7107 7108 frame: prefix + '__frame', 7109 wrap: prefix + '__wrap', 7110 7111 box: prefix + '__box' 7112 }; 7113 }; //PickerConstructor.klasses 7114 7115 7116 /** 7117 * Check if the default theme is being used. 7118 */ 7119 function isUsingDefaultTheme(element) { 7120 7121 var theme, 7122 prop = 'position'; 7123 7124 // For IE. 7125 if (element.currentStyle) { 7126 theme = element.currentStyle[prop]; 7127 } 7128 7129 // For normal browsers. 7130 else if (window.getComputedStyle) { 7131 theme = getComputedStyle(element)[prop]; 7132 } 7133 7134 return theme == 'fixed'; 7135 } 7136 7137 /** 7138 * Get the width of the browserâs scrollbar. 7139 * Taken from: https://github.com/VodkaBears/Remodal/blob/master/src/jquery.remodal.js 7140 */ 7141 function getScrollbarWidth() { 7142 7143 if ($html.height() <= $window.height()) { 7144 return 0; 7145 } 7146 7147 var $outer = $('<div style="visibility:hidden;width:100px" />').appendTo('body'); 7148 7149 // Get the width without scrollbars. 7150 var widthWithoutScroll = $outer[0].offsetWidth; 7151 7152 // Force adding scrollbars. 7153 $outer.css('overflow', 'scroll'); 7154 7155 // Add the inner div. 7156 var $inner = $('<div style="width:100%" />').appendTo($outer); 7157 7158 // Get the width with scrollbars. 7159 var widthWithScroll = $inner[0].offsetWidth; 7160 7161 // Remove the divs. 7162 $outer.remove(); 7163 7164 // Return the difference between the widths. 7165 return widthWithoutScroll - widthWithScroll; 7166 } 7167 7168 /** 7169 * PickerConstructor helper methods. 7170 */ 7171 PickerConstructor._ = { 7172 7173 /** 7174 * Create a group of nodes. Expects: 7175 * ` 7176 { 7177 min: {Integer}, 7178 max: {Integer}, 7179 i: {Integer}, 7180 node: {String}, 7181 item: {Function} 7182 } 7183 * ` 7184 */ 7185 group: function (groupObject) { 7186 7187 var 7188 // Scope for the looped object 7189 loopObjectScope, 7190 7191 7192 // Create the nodes list 7193 nodesList = '', 7194 7195 7196 // The counter starts from the `min` 7197 counter = PickerConstructor._.trigger(groupObject.min, groupObject); 7198 7199 // Loop from the `min` to `max`, incrementing by `i` 7200 for (; counter <= PickerConstructor._.trigger(groupObject.max, groupObject, [counter]); counter += groupObject.i) { 7201 7202 // Trigger the `item` function within scope of the object 7203 loopObjectScope = PickerConstructor._.trigger(groupObject.item, groupObject, [counter]); 7204 7205 // Splice the subgroup and create nodes out of the sub nodes 7206 nodesList += PickerConstructor._.node(groupObject.node, loopObjectScope[0], // the node 7207 loopObjectScope[1], // the classes 7208 loopObjectScope[2] // the attributes 7209 ); 7210 } 7211 7212 // Return the list of nodes 7213 return nodesList; 7214 }, //group 7215 7216 7217 /** 7218 * Create a dom node string 7219 */ 7220 node: function (wrapper, item, klass, attribute) { 7221 7222 // If the item is false-y, just return an empty string 7223 if (!item) return ''; 7224 7225 // If the item is an array, do a join 7226 item = $.isArray(item) ? item.join('') : item; 7227 7228 // Check for the class 7229 klass = klass ? ' class="' + klass + '"' : ''; 7230 7231 // Check for any attributes 7232 attribute = attribute ? ' ' + attribute : ''; 7233 7234 // Return the wrapped item 7235 return '<' + wrapper + klass + attribute + '>' + item + '</' + wrapper + '>'; 7236 }, //node 7237 7238 7239 /** 7240 * Lead numbers below 10 with a zero. 7241 */ 7242 lead: function (number) { 7243 return (number < 10 ? '0' : '') + number; 7244 }, 7245 7246 /** 7247 * Trigger a function otherwise return the value. 7248 */ 7249 trigger: function (callback, scope, args) { 7250 return typeof callback == 'function' ? callback.apply(scope, args || []) : callback; 7251 }, 7252 7253 /** 7254 * If the second character is a digit, length is 2 otherwise 1. 7255 */ 7256 digits: function (string) { 7257 return (/\d/.test(string[1]) ? 2 : 1 7258 ); 7259 }, 7260 7261 /** 7262 * Tell if something is a date object. 7263 */ 7264 isDate: function (value) { 7265 return {}.toString.call(value).indexOf('Date') > -1 && this.isInteger(value.getDate()); 7266 }, 7267 7268 /** 7269 * Tell if something is an integer. 7270 */ 7271 isInteger: function (value) { 7272 return {}.toString.call(value).indexOf('Number') > -1 && value % 1 === 0; 7273 }, 7274 7275 /** 7276 * Create ARIA attribute strings. 7277 */ 7278 ariaAttr: ariaAttr //PickerConstructor._ 7279 7280 7281 /** 7282 * Extend the picker with a component and defaults. 7283 */ 7284 };PickerConstructor.extend = function (name, Component) { 7285 7286 // Extend jQuery. 7287 $.fn[name] = function (options, action) { 7288 7289 // Grab the component data. 7290 var componentData = this.data(name); 7291 7292 // If the picker is requested, return the data object. 7293 if (options == 'picker') { 7294 return componentData; 7295 } 7296 7297 // If the component data exists and `options` is a string, carry out the action. 7298 if (componentData && typeof options == 'string') { 7299 return PickerConstructor._.trigger(componentData[options], componentData, [action]); 7300 } 7301 7302 // Otherwise go through each matched element and if the component 7303 // doesnât exist, create a new picker using `this` element 7304 // and merging the defaults and options with a deep copy. 7305 return this.each(function () { 7306 var $this = $(this); 7307 if (!$this.data(name)) { 7308 new PickerConstructor(this, name, Component, options); 7309 } 7310 }); 7311 }; 7312 7313 // Set the defaults. 7314 $.fn[name].defaults = Component.defaults; 7315 }; //PickerConstructor.extend 7316 7317 7318 function aria(element, attribute, value) { 7319 if ($.isPlainObject(attribute)) { 7320 for (var key in attribute) { 7321 ariaSet(element, key, attribute[key]); 7322 } 7323 } else { 7324 ariaSet(element, attribute, value); 7325 } 7326 } 7327 function ariaSet(element, attribute, value) { 7328 element.setAttribute((attribute == 'role' ? '' : 'aria-') + attribute, value); 7329 } 7330 function ariaAttr(attribute, data) { 7331 if (!$.isPlainObject(attribute)) { 7332 attribute = { attribute: data }; 7333 } 7334 data = ''; 7335 for (var key in attribute) { 7336 var attr = (key == 'role' ? '' : 'aria-') + key, 7337 attrVal = attribute[key]; 7338 data += attrVal == null ? '' : attr + '="' + attribute[key] + '"'; 7339 } 7340 return data; 7341 } 7342 7343 // IE8 bug throws an error for activeElements within iframes. 7344 function getActiveElement() { 7345 try { 7346 return document.activeElement; 7347 } catch (err) {} 7348 } 7349 7350 // Expose the picker constructor. 7351 return PickerConstructor; 7352}); 7353; /*! 7354 * Date picker for pickadate.js v3.5.0 7355 * http://amsul.github.io/pickadate.js/date.htm 7356 */ 7357 7358(function (factory) { 7359 factory(Materialize.Picker, jQuery); 7360})(function (Picker, $) { 7361 7362 /** 7363 * Globals and constants 7364 */ 7365 var DAYS_IN_WEEK = 7, 7366 WEEKS_IN_CALENDAR = 6, 7367 _ = Picker._; 7368 7369 /** 7370 * The date picker constructor 7371 */ 7372 function DatePicker(picker, settings) { 7373 7374 var calendar = this, 7375 element = picker.$node[0], 7376 elementValue = element.value, 7377 elementDataValue = picker.$node.data('value'), 7378 valueString = elementDataValue || elementValue, 7379 formatString = elementDataValue ? settings.formatSubmit : settings.format, 7380 isRTL = function () { 7381 7382 return element.currentStyle ? 7383 7384 // For IE. 7385 element.currentStyle.direction == 'rtl' : 7386 7387 // For normal browsers. 7388 getComputedStyle(picker.$root[0]).direction == 'rtl'; 7389 }; 7390 7391 calendar.settings = settings; 7392 calendar.$node = picker.$node; 7393 7394 // The queue of methods that will be used to build item objects. 7395 calendar.queue = { 7396 min: 'measure create', 7397 max: 'measure create', 7398 now: 'now create', 7399 select: 'parse create validate', 7400 highlight: 'parse navigate create validate', 7401 view: 'parse create validate viewset', 7402 disable: 'deactivate', 7403 enable: 'activate' 7404 7405 // The component's item object. 7406 };calendar.item = {}; 7407 7408 calendar.item.clear = null; 7409 calendar.item.disable = (settings.disable || []).slice(0); 7410 calendar.item.enable = -function (collectionDisabled) { 7411 return collectionDisabled[0] === true ? collectionDisabled.shift() : -1; 7412 }(calendar.item.disable); 7413 7414 calendar.set('min', settings.min).set('max', settings.max).set('now'); 7415 7416 // When thereâs a value, set the `select`, which in turn 7417 // also sets the `highlight` and `view`. 7418 if (valueString) { 7419 calendar.set('select', valueString, { format: formatString }); 7420 } 7421 7422 // If thereâs no value, default to highlighting âtodayâ. 7423 else { 7424 calendar.set('select', null).set('highlight', calendar.item.now); 7425 } 7426 7427 // The keycode to movement mapping. 7428 calendar.key = { 7429 40: 7, // Down 7430 38: -7, // Up 7431 39: function () { 7432 return isRTL() ? -1 : 1; 7433 }, // Right 7434 37: function () { 7435 return isRTL() ? 1 : -1; 7436 }, // Left 7437 go: function (timeChange) { 7438 var highlightedObject = calendar.item.highlight, 7439 targetDate = new Date(highlightedObject.year, highlightedObject.month, highlightedObject.date + timeChange); 7440 calendar.set('highlight', targetDate, { interval: timeChange }); 7441 this.render(); 7442 } 7443 7444 // Bind some picker events. 7445 };picker.on('render', function () { 7446 picker.$root.find('.' + settings.klass.selectMonth).on('change', function () { 7447 var value = this.value; 7448 if (value) { 7449 picker.set('highlight', [picker.get('view').year, value, picker.get('highlight').date]); 7450 picker.$root.find('.' + settings.klass.selectMonth).trigger('focus'); 7451 } 7452 }); 7453 picker.$root.find('.' + settings.klass.selectYear).on('change', function () { 7454 var value = this.value; 7455 if (value) { 7456 picker.set('highlight', [value, picker.get('view').month, picker.get('highlight').date]); 7457 picker.$root.find('.' + settings.klass.selectYear).trigger('focus'); 7458 } 7459 }); 7460 }, 1).on('open', function () { 7461 var includeToday = ''; 7462 if (calendar.disabled(calendar.get('now'))) { 7463 includeToday = ':not(.' + settings.klass.buttonToday + ')'; 7464 } 7465 picker.$root.find('button' + includeToday + ', select').attr('disabled', false); 7466 }, 1).on('close', function () { 7467 picker.$root.find('button, select').attr('disabled', true); 7468 }, 1); 7469 } //DatePicker 7470 7471 7472 /** 7473 * Set a datepicker item object. 7474 */ 7475 DatePicker.prototype.set = function (type, value, options) { 7476 7477 var calendar = this, 7478 calendarItem = calendar.item; 7479 7480 // If the value is `null` just set it immediately. 7481 if (value === null) { 7482 if (type == 'clear') type = 'select'; 7483 calendarItem[type] = value; 7484 return calendar; 7485 } 7486 7487 // Otherwise go through the queue of methods, and invoke the functions. 7488 // Update this as the time unit, and set the final value as this item. 7489 // * In the case of `enable`, keep the queue but set `disable` instead. 7490 // And in the case of `flip`, keep the queue but set `enable` instead. 7491 calendarItem[type == 'enable' ? 'disable' : type == 'flip' ? 'enable' : type] = calendar.queue[type].split(' ').map(function (method) { 7492 value = calendar[method](type, value, options); 7493 return value; 7494 }).pop(); 7495 7496 // Check if we need to cascade through more updates. 7497 if (type == 'select') { 7498 calendar.set('highlight', calendarItem.select, options); 7499 } else if (type == 'highlight') { 7500 calendar.set('view', calendarItem.highlight, options); 7501 } else if (type.match(/^(flip|min|max|disable|enable)$/)) { 7502 if (calendarItem.select && calendar.disabled(calendarItem.select)) { 7503 calendar.set('select', calendarItem.select, options); 7504 } 7505 if (calendarItem.highlight && calendar.disabled(calendarItem.highlight)) { 7506 calendar.set('highlight', calendarItem.highlight, options); 7507 } 7508 } 7509 7510 return calendar; 7511 }; //DatePicker.prototype.set 7512 7513 7514 /** 7515 * Get a datepicker item object. 7516 */ 7517 DatePicker.prototype.get = function (type) { 7518 return this.item[type]; 7519 }; //DatePicker.prototype.get 7520 7521 7522 /** 7523 * Create a picker date object. 7524 */ 7525 DatePicker.prototype.create = function (type, value, options) { 7526 7527 var isInfiniteValue, 7528 calendar = this; 7529 7530 // If thereâs no value, use the type as the value. 7531 value = value === undefined ? type : value; 7532 7533 // If itâs infinity, update the value. 7534 if (value == -Infinity || value == Infinity) { 7535 isInfiniteValue = value; 7536 } 7537 7538 // If itâs an object, use the native date object. 7539 else if ($.isPlainObject(value) && _.isInteger(value.pick)) { 7540 value = value.obj; 7541 } 7542 7543 // If itâs an array, convert it into a date and make sure 7544 // that itâs a valid date â otherwise default to today. 7545 else if ($.isArray(value)) { 7546 value = new Date(value[0], value[1], value[2]); 7547 value = _.isDate(value) ? value : calendar.create().obj; 7548 } 7549 7550 // If itâs a number or date object, make a normalized date. 7551 else if (_.isInteger(value) || _.isDate(value)) { 7552 value = calendar.normalize(new Date(value), options); 7553 } 7554 7555 // If itâs a literal true or any other case, set it to now. 7556 else /*if ( value === true )*/{ 7557 value = calendar.now(type, value, options); 7558 } 7559 7560 // Return the compiled object. 7561 return { 7562 year: isInfiniteValue || value.getFullYear(), 7563 month: isInfiniteValue || value.getMonth(), 7564 date: isInfiniteValue || value.getDate(), 7565 day: isInfiniteValue || value.getDay(), 7566 obj: isInfiniteValue || value, 7567 pick: isInfiniteValue || value.getTime() 7568 }; 7569 }; //DatePicker.prototype.create 7570 7571 7572 /** 7573 * Create a range limit object using an array, date object, 7574 * literal âtrueâ, or integer relative to another time. 7575 */ 7576 DatePicker.prototype.createRange = function (from, to) { 7577 7578 var calendar = this, 7579 createDate = function (date) { 7580 if (date === true || $.isArray(date) || _.isDate(date)) { 7581 return calendar.create(date); 7582 } 7583 return date; 7584 }; 7585 7586 // Create objects if possible. 7587 if (!_.isInteger(from)) { 7588 from = createDate(from); 7589 } 7590 if (!_.isInteger(to)) { 7591 to = createDate(to); 7592 } 7593 7594 // Create relative dates. 7595 if (_.isInteger(from) && $.isPlainObject(to)) { 7596 from = [to.year, to.month, to.date + from]; 7597 } else if (_.isInteger(to) && $.isPlainObject(from)) { 7598 to = [from.year, from.month, from.date + to]; 7599 } 7600 7601 return { 7602 from: createDate(from), 7603 to: createDate(to) 7604 }; 7605 }; //DatePicker.prototype.createRange 7606 7607 7608 /** 7609 * Check if a date unit falls within a date range object. 7610 */ 7611 DatePicker.prototype.withinRange = function (range, dateUnit) { 7612 range = this.createRange(range.from, range.to); 7613 return dateUnit.pick >= range.from.pick && dateUnit.pick <= range.to.pick; 7614 }; 7615 7616 /** 7617 * Check if two date range objects overlap. 7618 */ 7619 DatePicker.prototype.overlapRanges = func
7619tion (one, two) { 7620 7621 var calendar = this; 7622 7623 // Convert the ranges into comparable dates. 7624 one = calendar.createRange(one.from, one.to); 7625 two = calendar.createRange(two.from, two.to); 7626 7627 return calendar.withinRange(one, two.from) || calendar.withinRange(one, two.to) || calendar.withinRange(two, one.from) || calendar.withinRange(two, one.to); 7628 }; 7629 7630 /** 7631 * Get the date today. 7632 */ 7633 DatePicker.prototype.now = function (type, value, options) { 7634 value = new Date(); 7635 if (options && options.rel) { 7636 value.setDate(value.getDate() + options.rel); 7637 } 7638 return this.normalize(value, options); 7639 }; 7640 7641 /** 7642 * Navigate to next/prev month. 7643 */ 7644 DatePicker.prototype.navigate = function (type, value, options) { 7645 7646 var targetDateObject, 7647 targetYear, 7648 targetMonth, 7649 targetDate, 7650 isTargetArray = $.isArray(value), 7651 isTargetObject = $.isPlainObject(value), 7652 viewsetObject = this.item.view; /*, 7653 safety = 100*/ 7654 7655 if (isTargetArray || isTargetObject) { 7656 7657 if (isTargetObject) { 7658 targetYear = value.year; 7659 targetMonth = value.month; 7660 targetDate = value.date; 7661 } else { 7662 targetYear = +value[0]; 7663 targetMonth = +value[1]; 7664 targetDate = +value[2]; 7665 } 7666 7667 // If weâre navigating months but the view is in a different 7668 // month, navigate to the viewâs year and month. 7669 if (options && options.nav && viewsetObject && viewsetObject.month !== targetMonth) { 7670 targetYear = viewsetObject.year; 7671 targetMonth = viewsetObject.month; 7672 } 7673 7674 // Figure out the expected target year and month. 7675 targetDateObject = new Date(targetYear, targetMonth + (options && options.nav ? options.nav : 0), 1); 7676 targetYear = targetDateObject.getFullYear(); 7677 targetMonth = targetDateObject.getMonth(); 7678 7679 // If the month weâre going to doesnât have enough days, 7680 // keep decreasing the date until we reach the monthâs last date. 7681 while ( /*safety &&*/new Date(targetYear, targetMonth, targetDate).getMonth() !== targetMonth) { 7682 targetDate -= 1; 7683 /*safety -= 1 7684 if ( !safety ) { 7685 throw 'Fell into an infinite loop while navigating to ' + new Date( targetYear, targetMonth, targetDate ) + '.' 7686 }*/ 7687 } 7688 7689 value = [targetYear, targetMonth, targetDate]; 7690 } 7691 7692 return value; 7693 }; //DatePicker.prototype.navigate 7694 7695 7696 /** 7697 * Normalize a date by setting the hours to midnight. 7698 */ 7699 DatePicker.prototype.normalize = function (value /*, options*/) { 7700 value.setHours(0, 0, 0, 0); 7701 return value; 7702 }; 7703 7704 /** 7705 * Measure the range of dates. 7706 */ 7707 DatePicker.prototype.measure = function (type, value /*, options*/) { 7708 7709 var calendar = this; 7710 7711 // If itâs anything false-y, remove the limits. 7712 if (!value) { 7713 value = type == 'min' ? -Infinity : Infinity; 7714 } 7715 7716 // If itâs a string, parse it. 7717 else if (typeof value == 'string') { 7718 value = calendar.parse(type, value); 7719 } 7720 7721 // If it's an integer, get a date relative to today. 7722 else if (_.isInteger(value)) { 7723 value = calendar.now(type, value, { rel: value }); 7724 } 7725 7726 return value; 7727 }; ///DatePicker.prototype.measure 7728 7729 7730 /** 7731 * Create a viewset object based on navigation. 7732 */ 7733 DatePicker.prototype.viewset = function (type, dateObject /*, options*/) { 7734 return this.create([dateObject.year, dateObject.month, 1]); 7735 }; 7736 7737 /** 7738 * Validate a date as enabled and shift if needed. 7739 */ 7740 DatePicker.prototype.validate = function (type, dateObject, options) { 7741 7742 var calendar = this, 7743 7744 7745 // Keep a reference to the original date. 7746 originalDateObject = dateObject, 7747 7748 7749 // Make sure we have an interval. 7750 interval = options && options.interval ? options.interval : 1, 7751 7752 7753 // Check if the calendar enabled dates are inverted. 7754 isFlippedBase = calendar.item.enable === -1, 7755 7756 7757 // Check if we have any enabled dates after/before now. 7758 hasEnabledBeforeTarget, 7759 hasEnabledAfterTarget, 7760 7761 7762 // The min & max limits. 7763 minLimitObject = calendar.item.min, 7764 maxLimitObject = calendar.item.max, 7765 7766 7767 // Check if weâve reached the limit during shifting. 7768 reachedMin, 7769 reachedMax, 7770 7771 7772 // Check if the calendar is inverted and at least one weekday is enabled. 7773 hasEnabledWeekdays = isFlippedBase && calendar.item.disable.filter(function (value) { 7774 7775 // If thereâs a date, check where it is relative to the target. 7776 if ($.isArray(value)) { 7777 var dateTime = calendar.create(value).pick; 7778 if (dateTime < dateObject.pick) hasEnabledBeforeTarget = true;else if (dateTime > dateObject.pick) hasEnabledAfterTarget = true; 7779 } 7780 7781 // Return only integers for enabled weekdays. 7782 return _.isInteger(value); 7783 }).length; /*, 7784 safety = 100*/ 7785 7786 // Cases to validate for: 7787 // [1] Not inverted and date disabled. 7788 // [2] Inverted and some dates enabled. 7789 // [3] Not inverted and out of range. 7790 // 7791 // Cases to **not** validate for: 7792 // ⢠Navigating months. 7793 // ⢠Not inverted and date enabled. 7794 // ⢠Inverted and all dates disabled. 7795 // ⢠..and anything else. 7796 if (!options || !options.nav) if ( 7797 /* 1 */!isFlippedBase && calendar.disabled(dateObject) || 7798 /* 2 */isFlippedBase && calendar.disabled(dateObject) && (hasEnabledWeekdays || hasEnabledBeforeTarget || hasEnabledAfterTarget) || 7799 /* 3 */!isFlippedBase && (dateObject.pick <= minLimitObject.pick || dateObject.pick >= maxLimitObject.pick)) { 7800 7801 // When inverted, flip the direction if there arenât any enabled weekdays 7802 // and there are no enabled dates in the direction of the interval. 7803 if (isFlippedBase && !hasEnabledWeekdays && (!hasEnabledAfterTarget && interval > 0 || !hasEnabledBeforeTarget && interval < 0)) { 7804 interval *= -1; 7805 } 7806 7807 // Keep looping until we reach an enabled date. 7808 while ( /*safety &&*/calendar.disabled(dateObject)) { 7809 7810 /*safety -= 1 7811 if ( !safety ) { 7812 throw 'Fell into an infinite loop while validating ' + dateObject.obj + '.' 7813 }*/ 7814 7815 // If weâve looped into the next/prev month with a large interval, return to the original date and flatten the interval. 7816 if (Math.abs(interval) > 1 && (dateObject.month < originalDateObject.month || dateObject.month > originalDateObject.month)) { 7817 dateObject = originalDateObject; 7818 interval = interval > 0 ? 1 : -1; 7819 } 7820 7821 // If weâve reached the min/max limit, reverse the direction, flatten the interval and set it to the limit. 7822 if (dateObject.pick <= minLimitObject.pick) { 7823 reachedMin = true; 7824 interval = 1; 7825 dateObject = calendar.create([minLimitObject.year, minLimitObject.month, minLimitObject.date + (dateObject.pick === minLimitObject.pick ? 0 : -1)]); 7826 } else if (dateObject.pick >= maxLimitObject.pick) { 7827 reachedMax = true; 7828 interval = -1; 7829 dateObject = calendar.create([maxLimitObject.year, maxLimitObject.month, maxLimitObject.date + (dateObject.pick === maxLimitObject.pick ? 0 : 1)]); 7830 } 7831 7832 // If weâve reached both limits, just break out of the loop. 7833 if (reachedMin && reachedMax) { 7834 break; 7835 } 7836 7837 // Finally, create the shifted date using the interval and keep looping. 7838 dateObject = calendar.create([dateObject.year, dateObject.month, dateObject.date + interval]); 7839 } 7840 } //endif 7841 7842 7843 // Return the date object settled on. 7844 return dateObject; 7845 }; //DatePicker.prototype.validate 7846 7847 7848 /** 7849 * Check if a date is disabled. 7850 */ 7851 DatePicker.prototype.disabled = function (dateToVerify) { 7852 7853 var calendar = this, 7854 7855 7856 // Filter through the disabled dates to check if this is one. 7857 isDisabledMatch = calendar.item.disable.filter(function (dateToDisable) { 7858 7859 // If the date is a number, match the weekday with 0index and `firstDay` check. 7860 if (_.isInteger(dateToDisable)) { 7861 return dateToVerify.day === (calendar.settings.firstDay ? dateToDisable : dateToDisable - 1) % 7; 7862 } 7863 7864 // If itâs an array or a native JS date, create and match the exact date. 7865 if ($.isArray(dateToDisable) || _.isDate(dateToDisable)) { 7866 return dateToVerify.pick === calendar.create(dateToDisable).pick; 7867 } 7868 7869 // If itâs an object, match a date within the âfromâ and âtoâ range. 7870 if ($.isPlainObject(dateToDisable)) { 7871 return calendar.withinRange(dateToDisable, dateToVerify); 7872 } 7873 }); 7874 7875 // If this date matches a disabled date, confirm itâs not inverted. 7876 isDisabledMatch = isDisabledMatch.length && !isDisabledMatch.filter(function (dateToDisable) { 7877 return $.isArray(dateToDisable) && dateToDisable[3] == 'inverted' || $.isPlainObject(dateToDisable) && dateToDisable.inverted; 7878 }).length; 7879 7880 // Check the calendar âenabledâ flag and respectively flip the 7881 // disabled state. Then also check if itâs beyond the min/max limits. 7882 return calendar.item.enable === -1 ? !isDisabledMatch : isDisabledMatch || dateToVerify.pick < calendar.item.min.pick || dateToVerify.pick > calendar.item.max.pick; 7883 }; //DatePicker.prototype.disabled 7884 7885 7886 /** 7887 * Parse a string into a usable type. 7888 */ 7889 DatePicker.prototype.parse = function (type, value, options) { 7890 7891 var calendar = this, 7892 parsingObject = {}; 7893 7894 // If itâs already parsed, weâre good. 7895 if (!value || typeof value != 'string') { 7896 return value; 7897 } 7898 7899 // We need a `.format` to parse the value with. 7900 if (!(options && options.format)) { 7901 options = options || {}; 7902 options.format = calendar.settings.format; 7903 } 7904 7905 // Convert the format into an array and then map through it. 7906 calendar.formats.toArray(options.format).map(function (label) { 7907 7908 var 7909 // Grab the formatting label. 7910 formattingLabel = calendar.formats[label], 7911 7912 7913 // The format length is from the formatting label function or the 7914 // label length without the escaping exclamation (!) mark. 7915 formatLength = formattingLabel ? _.trigger(formattingLabel, calendar, [value, parsingObject]) : label.replace(/^!/, '').length; 7916 7917 // If there's a format label, split the value up to the format length. 7918 // Then add it to the parsing object with appropriate label. 7919 if (formattingLabel) { 7920 parsingObject[label] = value.substr(0, formatLength); 7921 } 7922 7923 // Update the value as the substring from format length to end. 7924 value = value.substr(formatLength); 7925 }); 7926 7927 // Compensate for month 0index. 7928 return [parsingObject.yyyy || parsingObject.yy, +(parsingObject.mm || parsingObject.m) - 1, parsingObject.dd || parsingObject.d]; 7929 }; //DatePicker.prototype.parse 7930 7931 7932 /** 7933 * Various formats to display the object in. 7934 */ 7935 DatePicker.prototype.formats = function () { 7936 7937 // Return the length of the first word in a collection. 7938 function getWordLengthFromCollection(string, collection, dateObject) { 7939 7940 // Grab the first word from the string. 7941 var word = string.match(/\w+/)[0]; 7942 7943 // If there's no month index, add it to the date object 7944 if (!dateObject.mm && !dateObject.m) { 7945 dateObject.m = collection.indexOf(word) + 1; 7946 } 7947 7948 // Return the length of the word. 7949 return word.length; 7950 } 7951 7952 // Get the length of the first word in a string. 7953 function getFirstWordLength(string) { 7954 return string.match(/\w+/)[0].length; 7955 } 7956 7957 return { 7958 7959 d: function (string, dateObject) { 7960 7961 // If there's string, then get the digits length. 7962 // Otherwise return the selected date. 7963 return string ? _.digits(string) : dateObject.date; 7964 }, 7965 dd: function (string, dateObject) { 7966 7967 // If there's a string, then the length is always 2. 7968 // Otherwise return the selected date with a leading zero. 7969 return string ? 2 : _.lead(dateObject.date); 7970 }, 7971 ddd: function (string, dateObject) { 7972 7973 // If there's a string, then get the length of the first word. 7974 // Otherwise return the short selected weekday. 7975 return string ? getFirstWordLength(string) : this.settings.weekdaysShort[dateObject.day]; 7976 }, 7977 dddd: function (string, dateObject) { 7978 7979 // If there's a string, then get the length of the first word. 7980 // Otherwise return the full selected weekday. 7981 return string ? getFirstWordLength(string) : this.settings.weekdaysFull[dateObject.day]; 7982 }, 7983 m: function (string, dateObject) { 7984 7985 // If there's a string, then get the length of the digits 7986 // Otherwise return the selected month with 0index compensation. 7987 return string ? _.digits(string) : dateObject.month + 1; 7988 }, 7989 mm: function (string, dateObject) { 7990 7991 // If there's a string, then the length is always 2. 7992 // Otherwise return the selected month with 0index and leading zero. 7993 return string ? 2 : _.lead(dateObject.month + 1); 7994 }, 7995 mmm: function (string, dateObject) { 7996 7997 var collection = this.settings.monthsShort; 7998 7999 // If there's a string, get length of the relevant month from the short 8000 // months collection. Otherwise return the selected month from that c
8000ollection. 8001 return string ? getWordLengthFromCollection(string, collection, dateObject) : collection[dateObject.month]; 8002 }, 8003 mmmm: function (string, dateObject) { 8004 8005 var collection = this.settings.monthsFull; 8006 8007 // If there's a string, get length of the relevant month from the full 8008 // months collection. Otherwise return the selected month from that collection. 8009 return string ? getWordLengthFromCollection(string, collection, dateObject) : collection[dateObject.month]; 8010 }, 8011 yy: function (string, dateObject) { 8012 8013 // If there's a string, then the length is always 2. 8014 // Otherwise return the selected year by slicing out the first 2 digits. 8015 return string ? 2 : ('' + dateObject.year).slice(2); 8016 }, 8017 yyyy: function (string, dateObject) { 8018 8019 // If there's a string, then the length is always 4. 8020 // Otherwise return the selected year. 8021 return string ? 4 : dateObject.year; 8022 }, 8023 8024 // Create an array by splitting the formatting string passed. 8025 toArray: function (formatString) { 8026 return formatString.split(/(d{1,4}|m{1,4}|y{4}|yy|!.)/g); 8027 }, 8028 8029 // Format an object into a string using the formatting options. 8030 toString: function (formatString, itemObject) { 8031 var calendar = this; 8032 return calendar.formats.toArray(formatString).map(function (label) { 8033 return _.trigger(calendar.formats[label], calendar, [0, itemObject]) || label.replace(/^!/, ''); 8034 }).join(''); 8035 } 8036 }; 8037 }(); //DatePicker.prototype.formats 8038 8039 8040 /** 8041 * Check if two date units are the exact. 8042 */ 8043 DatePicker.prototype.isDateExact = function (one, two) { 8044 8045 var calendar = this; 8046 8047 // When weâre working with weekdays, do a direct comparison. 8048 if (_.isInteger(one) && _.isInteger(two) || typeof one == 'boolean' && typeof two == 'boolean') { 8049 return one === two; 8050 } 8051 8052 // When weâre working with date representations, compare the âpickâ value. 8053 if ((_.isDate(one) || $.isArray(one)) && (_.isDate(two) || $.isArray(two))) { 8054 return calendar.create(one).pick === calendar.create(two).pick; 8055 } 8056 8057 // When weâre working with range objects, compare the âfromâ and âtoâ. 8058 if ($.isPlainObject(one) && $.isPlainObject(two)) { 8059 return calendar.isDateExact(one.from, two.from) && calendar.isDateExact(one.to, two.to); 8060 } 8061 8062 return false; 8063 }; 8064 8065 /** 8066 * Check if two date units overlap. 8067 */ 8068 DatePicker.prototype.isDateOverlap = function (one, two) { 8069 8070 var calendar = this, 8071 firstDay = calendar.settings.firstDay ? 1 : 0; 8072 8073 // When weâre working with a weekday index, compare the days. 8074 if (_.isInteger(one) && (_.isDate(two) || $.isArray(two))) { 8075 one = one % 7 + firstDay; 8076 return one === calendar.create(two).day + 1; 8077 } 8078 if (_.isInteger(two) && (_.isDate(one) || $.isArray(one))) { 8079 two = two % 7 + firstDay; 8080 return two === calendar.create(one).day + 1; 8081 } 8082 8083 // When weâre working with range objects, check if the ranges overlap. 8084 if ($.isPlainObject(one) && $.isPlainObject(two)) { 8085 return calendar.overlapRanges(one, two); 8086 } 8087 8088 return false; 8089 }; 8090 8091 /** 8092 * Flip the âenabledâ state. 8093 */ 8094 DatePicker.prototype.flipEnable = function (val) { 8095 var itemObject = this.item; 8096 itemObject.enable = val || (itemObject.enable == -1 ? 1 : -1); 8097 }; 8098 8099 /** 8100 * Mark a collection of dates as âdisabledâ. 8101 */ 8102 DatePicker.prototype.deactivate = function (type, datesToDisable) { 8103 8104 var calendar = this, 8105 disabledItems = calendar.item.disable.slice(0); 8106 8107 // If weâre flipping, thatâs all we need to do. 8108 if (datesToDisable == 'flip') { 8109 calendar.flipEnable(); 8110 } else if (datesToDisable === false) { 8111 calendar.flipEnable(1); 8112 disabledItems = []; 8113 } else if (datesToDisable === true) { 8114 calendar.flipEnable(-1); 8115 disabledItems = []; 8116 } 8117 8118 // Otherwise go through the dates to disable. 8119 else { 8120 8121 datesToDisable.map(function (unitToDisable) { 8122 8123 var matchFound; 8124 8125 // When we have disabled items, check for matches. 8126 // If something is matched, immediately break out. 8127 for (var index = 0; index < disabledItems.length; index += 1) { 8128 if (calendar.isDateExact(unitToDisable, disabledItems[index])) { 8129 matchFound = true; 8130 break; 8131 } 8132 } 8133 8134 // If nothing was found, add the validated unit to the collection. 8135 if (!matchFound) { 8136 if (_.isInteger(unitToDisable) || _.isDate(unitToDisable) || $.isArray(unitToDisable) || $.isPlainObject(unitToDisable) && unitToDisable.from && unitToDisable.to) { 8137 disabledItems.push(unitToDisable); 8138 } 8139 } 8140 }); 8141 } 8142 8143 // Return the updated collection. 8144 return disabledItems; 8145 }; //DatePicker.prototype.deactivate 8146 8147 8148 /** 8149 * Mark a collection of dates as âenabledâ. 8150 */ 8151 DatePicker.prototype.activate = function (type, datesToEnable) { 8152 8153 var calendar = this, 8154 disabledItems = calendar.item.disable, 8155 disabledItemsCount = disabledItems.length; 8156 8157 // If weâre flipping, thatâs all we need to do. 8158 if (datesToEnable == 'flip') { 8159 calendar.flipEnable(); 8160 } else if (datesToEnable === true) { 8161 calendar.flipEnable(1); 8162 disabledItems = []; 8163 } else if (datesToEnable === false) { 8164 calendar.flipEnable(-1); 8165 disabledItems = []; 8166 } 8167 8168 // Otherwise go through the disabled dates. 8169 else { 8170 8171 datesToEnable.map(function (unitToEnable) { 8172 8173 var matchFound, disabledUnit, index, isExactRange; 8174 8175 // Go through the disabled items and try to find a match. 8176 for (index = 0; index < disabledItemsCount; index += 1) { 8177 8178 disabledUnit = disabledItems[index]; 8179 8180 // When an exact match is found, remove it from the collection. 8181 if (calendar.isDateExact(disabledUnit, unitToEnable)) { 8182 matchFound = disabledItems[index] = null; 8183 isExactRange = true; 8184 break; 8185 } 8186 8187 // When an overlapped match is found, add the âinvertedâ state to it. 8188 else if (calendar.isDateOverlap(disabledUnit, unitToEnable)) { 8189 if ($.isPlainObject(unitToEnable)) { 8190 unitToEnable.inverted = true; 8191 matchFound = unitToEnable; 8192 } else if ($.isArray(unitToEnable)) { 8193 matchFound = unitToEnable; 8194 if (!matchFound[3]) matchFound.push('inverted'); 8195 } else if (_.isDate(unitToEnable)) { 8196 matchFound = [unitToEnable.getFullYear(), unitToEnable.getMonth(), unitToEnable.getDate(), 'inverted']; 8197 } 8198 break; 8199 } 8200 } 8201 8202 // If a match was found, remove a previous duplicate entry. 8203 if (matchFound) for (index = 0; index < disabledItemsCount; index += 1) { 8204 if (calendar.isDateExact(disabledItems[index], unitToEnable)) { 8205 disabledItems[index] = null; 8206 break; 8207 } 8208 } 8209 8210 // In the event that weâre dealing with an exact range of dates, 8211 // make sure there are no âinvertedâ dates because of it. 8212 if (isExactRange) for (index = 0; index < disabledItemsCount; index += 1) { 8213 if (calendar.isDateOverlap(disabledItems[index], unitToEnable)) { 8214 disabledItems[index] = null; 8215 break; 8216 } 8217 } 8218 8219 // If something is still matched, add it into the collection. 8220 if (matchFound) { 8221 disabledItems.push(matchFound); 8222 } 8223 }); 8224 } 8225 8226 // Return the updated collection. 8227 return disabledItems.filter(function (val) { 8228 return val != null; 8229 }); 8230 }; //DatePicker.prototype.activate 8231 8232 8233 /** 8234 * Create a string for the nodes in the picker. 8235 */ 8236 DatePicker.prototype.nodes = function (isOpen) { 8237 8238 var calendar = this, 8239 settings = calendar.settings, 8240 calendarItem = calendar.item, 8241 nowObject = calendarItem.now, 8242 selectedObject = calendarItem.select, 8243 highlightedObject = calendarItem.highlight, 8244 viewsetObject = calendarItem.view, 8245 disabledCollection = calendarItem.disable, 8246 minLimitObject = calendarItem.min, 8247 maxLimitObject = calendarItem.max, 8248 8249 8250 // Create the calendar table head using a copy of weekday labels collection. 8251 // * We do a copy so we don't mutate the original array. 8252 tableHead = function (collection, fullCollection) { 8253 8254 // If the first day should be Monday, move Sunday to the end. 8255 if (settings.firstDay) { 8256 collection.push(collection.shift()); 8257 fullCollection.push(fullCollection.shift()); 8258 } 8259 8260 // Create and return the table head group.
8261 return _.node('thead', _.node('tr', _.group({ 8262 min: 0, 8263 max: DAYS_IN_WEEK - 1, 8264 i: 1, 8265 node: 'th', 8266 item: function (counter) { 8267 return [collection[counter], settings.klass.weekdays, 'scope=col title="' + fullCollection[counter] + '"']; 8268 } 8269 }))); //endreturn 8270 8271 // Materialize modified 8272 }((settings.showWeekdaysFull ? settings.weekdaysFull : settings.weekdaysLetter).slice(0), settings.weekdaysFull.slice(0)), 8273 //tableHead 8274 8275 8276 // Create the nav for next/prev month. 8277 createMonthNav = function (next) { 8278 8279 // Otherwise, return the created month tag. 8280 return _.node('div', ' ', settings.klass['nav' + (next ? 'Next' : 'Prev')] + ( 8281 8282 // If the focused month is outside the range, disabled the button. 8283 next && viewsetObject.year >= maxLimitObject.year && viewsetObject.month >= maxLimitObject.month || !next && viewsetObject.year <= minLimitObject.year && viewsetObject.month <= minLimitObject.month ? ' ' + settings.klass.navDisabled : ''), 'data-nav=' + (next || -1) + ' ' + _.ariaAttr({ 8284 role: 'button', 8285 controls: calendar.$node[0].id + '_table' 8286 }) + ' ' + 'title="' + (next ? settings.labelMonthNext : settings.labelMonthPrev) + '"'); //endreturn 8287 }, 8288 //createMonthNav 8289 8290 8291 // Create the month label. 8292 //Materialize modified 8293 createMonthLabel = function (override) { 8294 8295 var monthsCollection = settings.showMonthsShort ? settings.monthsShort : settings.monthsFull; 8296 8297 // Materialize modified 8298 if (override == "short_months") { 8299 monthsCollection = settings.monthsShort; 8300 } 8301 8302 // If there are months to select, add a dropdown menu. 8303 if (settings.selectMonths && override == undefined) { 8304 8305 return _.node('select', _.group({ 8306 min: 0, 8307 max: 11, 8308 i: 1, 8309 node: 'option', 8310 item: function (loopedMonth) { 8311 8312 return [ 8313 8314 // The looped month and no classes. 8315 monthsCollection[loopedMonth], 0, 8316 8317 // Set the value and selected index. 8318 'value=' + loopedMonth + (viewsetObject.month == loopedMonth ? ' selected' : '') + (viewsetObject.year == minLimitObject.year && loopedMonth < minLimitObject.month || viewsetObject.year == maxLimitObject.year && loopedMonth > maxLimitObject.month ? ' disabled' : '')]; 8319 } 8320 }), settings.klass.selectMonth + ' browser-default', (isOpen ? '' : 'disabled') + ' ' + _.ariaAttr({ controls: calendar.$node[0].id + '_table' }) + ' ' + 'title="' + settings.labelMonthSelect + '"'); 8321 } 8322 8323 // Materialize modified 8324 if (override == "short_months") if (selectedObject != null) return monthsCollection[selectedObject.month];else return monthsCollection[viewsetObject.month]; 8325 8326 // If there's a need for a month selector 8327 return _.node('div', monthsCollection[viewsetObject.month], settings.klass.month); 8328 }, 8329 //createMonthLabel 8330 8331 8332 // Create the year label. 8333 // Materialize modified 8334 createYearLabel = function (override) { 8335 8336 var focusedYear = viewsetObject.year, 8337 8338 8339 // If years selector is set to a literal "true", set it to 5. Otherwise 8340 // divide in half to get half before and half after focused year. 8341 numberYears = settings.selectYears === true ? 5 : ~~(settings.selectYears / 2); 8342 8343 // If there are years to select, add a dropdown menu. 8344 if (numberYears) { 8345 8346 var minYear = minLimitObject.year, 8347 maxYear = maxLimitObject.year, 8348 lowestYear = focusedYear - numberYears, 8349 highestYear = focusedYear + numberYears; 8350 8351 // If the min year is greater than the lowest year, increase the highest year 8352 // by the difference and set the lowest year to the min year. 8353 if (minYear > lowestYear) { 8354 highestYear += minYear - lowestYear; 8355 lowestYear = minYear; 8356 } 8357 8358 // If the max year is less than the highest year, decrease the lowest year 8359 // by the lower of the two: available and needed years. Then set the 8360 // highest year to the max year. 8361 if (maxYear < highestYear) { 8362 8363 var availableYears = lowestYear - minYear, 8364 neededYears = highestYear - maxYear; 8365 8366 lowestYear -= availableYears > neededYears ? neededYears : availableYears;
8367 highestYear = maxYear; 8368 } 8369 8370 if (settings.selectYears && override == undefined) { 8371 return _.node('select', _.group({ 8372 min: lowestYear, 8373 max: highestYear, 8374 i: 1, 8375 node: 'option', 8376 item: function (loopedYear) { 8377 return [ 8378 8379 // The looped year and no classes. 8380 loopedYear, 0, 8381 8382 // Set the value and selected index. 8383 'value=' + loopedYear + (focusedYear == loopedYear ? ' selected' : '')]; 8384 } 8385 }), settings.klass.selectYear + ' browser-default', (isOpen ? '' : 'disabled') + ' ' + _.ariaAttr({ controls: calendar.$node[0].id + '_table' }) + ' ' + 'title="' + settings.labelYearSelect + '"'); 8386 } 8387 } 8388 8389 // Materialize modified 8390 if (override == "raw") return _.node('div', focusedYear); 8391 8392 // Otherwise just return the year focused 8393 return _.node('div', focusedYear, settings.klass.year); 8394 }; //createYearLabel 8395 8396 8397 // Materialize modified 8398 createDayLabel = function () { 8399 if (selectedObject != null) return selectedObject.date;else return nowObject.date; 8400 }; 8401 createWeekdayLabel = function () { 8402 var display_day; 8403 8404 if (selectedObject != null) display_day = selectedObject.day;else display_day = nowObject.day; 8405 var weekday = settings.weekdaysShort[display_day]; 8406 return weekday; 8407 }; 8408 8409 // Create and return the entire calendar. 8410 8411 return _.node( 8412 // Date presentation View 8413 'div', _.node( 8414 // Div for Year 8415 'div', createYearLabel("raw"), settings.klass.year_display) + _.node('span', createWeekdayLabel() + ', ', "picker__weekday-display") + _.node( 8416 // Div for short Month 8417 'span', createMonthLabel("short_months") + ' ', settings.klass.month_display) + _.node( 8418 // Div for Day 8419 'span', createDayLabel(), settings.klass.day_display), settings.klass.date_display) + 8420 // Calendar container 8421 _.node('div', _.node('div', _.node('div', (settings.selectYears ? createMonthLabel() + createYearLabel() : createMonthLabel() + createYearLabel()) + createMonthNav() + createMonthNav(1), settings.klass.header) + _.node('table', tableHead + _.node('tbody', _.group({ 8422 min: 0, 8423 max: WEEKS_IN_CALENDAR - 1, 8424 i: 1, 8425 node: 'tr', 8426 item: function (rowCounter) { 8427 8428 // If Monday is the first day and the month starts on Sunday, shift the date back a week. 8429 var shiftDateBy = settings.firstDay && calendar.create([viewsetObject.year, viewsetObject.month, 1]).day === 0 ? -7 : 0; 8430 8431 return [_.group({ 8432 min: DAYS_IN_WEEK * rowCounter - viewsetObject.day + shiftDateBy + 1, // Add 1 for weekday 0index 8433 max: function () { 8434 return this.min + DAYS_IN_WEEK - 1; 8435 }, 8436 i: 1, 8437 node: 'td', 8438 item: function (targetDate) { 8439 8440 // Convert the time date from a relative date to a target date. 8441 targetDate = calendar.create([viewsetObject.year, viewsetObject.month, targetDate + (settings.firstDay ? 1 : 0)]); 8442 8443 var isSelected = selectedObject && selectedObject.pick == targetDate.pick, 8444 isHighlighted = highlightedObject && highlightedObject.pick == targetDate.pick, 8445 isDisabled = disabledCollection && calendar.disabled(targetDate) || targetDate.pick < minLimitObject.pick || targetDate.pick > maxLimitObject.pick, 8446 formattedDate = _.trigger(calendar.formats.toString, calendar, [settings.format, targetDate]); 8447 8448 return [_.node('div', targetDate.date, function (klasses) { 8449 8450 // Add the `infocus` or `outfocus` classes based on month in view. 8451 klasses.push(viewsetObject.month == targetDate.month ? settings.klass.infocus : settings.klass.outfocus); 8452 8453 // Add the `today` class if needed. 8454 if (nowObject.pick == targetDate.pick) { 8455 klasses.push(settings.klass.now); 8456 } 8457 8458 // Add the `selected` class if something's selected and the time matches. 8459 if (isSelected) { 8460 klasses.push(settings.klass.selected); 8461 } 8462 8463 // Add the `highlighted` class if something's highlighted and the time matches. 8464 if (isHighlighted) { 8465 klasses.push(settings.klass.highlighted); 8466 } 8467 8468 // Add the `disabled` class if something's disabled and the object matches. 8469 if (isDisabled) { 8470 klasses.push(settings.klass.disabled); 8471 } 8472 8473 return klasses.join(' '); 8474 }([settings.klass.day]), 'data-pick=' + targetDate.pick + ' ' + _.ariaAttr({ 8475 role: 'gridcell', 8476 label: formattedDate, 8477 selected: isSelected && calendar.$node.val() === formattedDate ? true : null, 8478 activedescendant: isHighlighted ? true : null, 8479 disabled: isDisabled ? true : null 8480 }) + ' ' + (isDisabled ? '' : 'tabindex="0"')), '', _.ariaAttr({ role: 'presentation' })]; //endreturn 8481 } 8482 })]; //endreturn 8483 } 8484 })), settings.klass.table, 'id="' + calendar.$node[0].id + '_table' + '" ' + _.ariaAttr({ 8485 role: 'grid', 8486 controls: calendar.$node[0].id, 8487 readonly: true 8488 })), settings.klass.calendar_container) // end calendar 8489 8490 + 8491 8492 // * For Firefox forms to submit, make sure to set the buttonsâ `type` attributes as âbuttonâ. 8493 _.node('div', _.node('button', settings.today, "btn-flat picker__today waves-effect", 'type=button data-
8493pick=' + nowObject.pick + (isOpen && !calendar.disabled(nowObject) ? '' : ' disabled') + ' ' + _.ariaAttr({ controls: calendar.$node[0].id })) + _.node('button', settings.clear, "btn-flat picker__clear waves-effect", 'type=button data-clear=1' + (isOpen ? '' : ' disabled') + ' ' + _.ariaAttr({ controls: calendar.$node[0].id })) + _.node('button', settings.close, "btn-flat picker__close waves-effect", 'type=button data-close=true ' + (isOpen ? '' : ' disabled') + ' ' + _.ariaAttr({ controls: calendar.$node[0].id })), settings.klass.footer), 'picker__container__wrapper'); //endreturn 8494 }; //DatePicker.prototype.nodes 8495 8496 8497 /** 8498 * The date picker defaults. 8499 */ 8500 DatePicker.defaults = function (prefix) { 8501 8502 return { 8503 8504 // The title label to use for the month nav buttons 8505 labelMonthNext: 'Next month', 8506 labelMonthPrev: 'Previous month', 8507 8508 // The title label to use for the dropdown selectors 8509 labelMonthSelect: 'Select a month', 8510 labelYearSelect: 'Select a year', 8511 8512 // Months and weekdays 8513 monthsFull: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Setiembre', 'Octubre', 'Noviembre', 'Diciembre'], 8514 monthsShort: ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Set', 'Oct', 'Nov', 'Dic'], 8515 weekdaysFull: ['Domingo', 'Lunes', 'Martes', 'Miercoles', 'Jueves', 'Viernes', 'Sabado'], 8516 weekdaysShort: ['Dom', 'Lun', 'Mar', 'Mie', 'Jue', 'Vie', 'Sab'], 8517 8518 // Materialize modified 8519 weekdaysLetter: ['D', 'L', 'M', 'M', 'J', 'V', 'S'], 8520 8521 // Today and clear 8522 today: 'Today', 8523 clear: 'Clear', 8524 close: 'Ok', 8525 8526 // Picker close behavior (Prevent a change in behaviour for backwards compatibility) 8527 closeOnSelect: false, 8528 8529 // The format to show on the `input` element 8530 format: 'd mmmm, yyyy', 8531 8532 // Classes 8533 klass: { 8534 8535 table: prefix + 'table', 8536 8537 header: prefix + 'header', 8538 8539 // Materialize Added klasses 8540 date_display: prefix + 'date-display', 8541 day_display: prefix + 'day-display', 8542 month_display: prefix + 'month-display', 8543 year_display: prefix + 'year-display', 8544 calendar_container: prefix + 'calendar-container', 8545 // end 8546 8547 8548 navPrev: prefix + 'nav--prev', 8549 navNext: prefix + 'nav--next', 8550 navDisabled: prefix + 'nav--disabled', 8551 8552 month: prefix + 'month', 8553 year: prefix + 'year', 8554 8555 selectMonth: prefix + 'select--month', 8556 selectYear: prefix + 'select--year', 8557 8558 weekdays: prefix + 'weekday', 8559 8560 day: prefix + 'day', 8561 disabled: prefix + 'day--disabled', 8562 selected: prefix + 'day--selected', 8563 highlighted: prefix + 'day--highlighted', 8564 now: prefix + 'day--today', 8565 infocus: prefix + 'day--infocus', 8566 outfocus: prefix + 'day--outfocus', 8567 8568 footer: prefix + 'footer', 8569 8570 buttonClear: prefix + 'button--clear', 8571 buttonToday: prefix + 'button--today', 8572 buttonClose: prefix + 'button--close' 8573 } 8574 }; 8575 }(Picker.klasses().picker + '__'); 8576 8577 /** 8578 * Extend the picker to add the date picker. 8579 */ 8580 Picker.extend('pickadate', DatePicker); 8581}); 8582; /*! 8583 * ClockPicker v0.0.7 (http://weareoutman.github.io/clockpicker/) 8584 * Copyright 2014 Wang Shenwei. 8585 * Licensed under MIT (https://github.com/weareoutman/clockpicker/blob/gh-pages/LICENSE) 8586 * 8587 * Further modified 8588 * Copyright 2015 Ching Yaw Hao. 8589 */ 8590 8591(function () { 8592 var $ = window.jQuery, 8593 $win = $(window), 8594 $doc = $(document); 8595 8596 // Can I use inline svg ? 8597 var svgNS = 'http://www.w3.org/2000/svg', 8598 svgSupported = 'SVGAngle' in window && function () { 8599 var supported, 8600 el = document.createElement('div'); 8601 el.innerHTML = '<svg/>'; 8602 supported = (el.firstChild && el.firstChild.namespaceURI) == svgNS; 8603 el.innerHTML = ''; 8604 return supported; 8605 }(); 8606 8607 // Can I use transition ? 8608 var transitionSupported = function () { 8609 var style = document.createElement('div').style; 8610 return 'transition' in style || 'WebkitTransition' in style || 'MozTransition' in style || 'msTransition' in style || 'OTransition' in style; 8611 }(); 8612 8613 // Listen touch events in touch screen device, instead of mouse events in desktop. 8614 var touchSupported = 'ontouchstart' in window, 8615 mousedownEvent = 'mousedown' + (touchSupported ? ' touchstart' : ''), 8616 mousemoveEvent = 'mousemove.clockpicker' + (touchSupported ? ' touchmove.clockpicker' : ''), 8617 mouseupEvent = 'mouseup.clockpicker' + (touchSupported ? ' touchend.clockpicker' : ''); 8618 8619 // Vibrate the device if supported 8620 var vibrate = navigator.vibrate ? 'vibrate' : navigator.webkitVibrate ? 'webkitVibrate' : null; 8621 8622 function createSvgElement(name) { 8623 return document.createElementNS(svgNS, name); 8624 } 8625 8626 function leadingZero(num) { 8627 return (num < 10 ? '0' : '') + num; 8628 } 8629 8630 // Get a unique id 8631 var idCounter = 0; 8632 function uniqueId(prefix) { 8633 var id = ++idCounter + ''; 8634 return prefix ? prefix + id : id; 8635 } 8636 8637 // Clock size 8638 var dialRadius = 135, 8639 outerRadius = 105, 8640 8641 // innerRadius = 80 on 12 hour clock 8642 innerRadius = 80, 8643 tickRadius = 20, 8644 diameter = dialRadius * 2, 8645 duration = transitionSupported ? 350 : 1; 8646 8647 // Popover template 8648 var tpl = ['<div class="clockpicker picker">', '<div class="picker__holder">', '<div class="picker__frame">', '<div class="picker__wrap">', '<div class="picker__box">', '<div class="picker__date-display">', '<div class="clockpicker-display">', '<div class="clockpicker-display-column">', '<span class="clockpicker-span-hours text-primary"></span>', ':', '<span class="clockpicker-span-minutes"></span>', '</div>', '<div class="clockpicker-display-column clockpicker-display-am-pm">', '<div class="clockpicker-span-am-pm"></div>', '</div>', '</div>', '</div>', '<div class="picker__container__wrapper">', '<div class="picker__calendar-container">', '<div class="clockpicker-plate">', '<div class="clockpicker-canvas"></div>', '<div class="clockpicker-dial clockpicker-hours"></div>', '<div class="clockpicker-dial clockpicker-minutes clockpicker-dial-out"></div>', '</div>', '<div class="clockpicker-am-pm-block">', '</div>', '</div>', '<div class="picker__footer">', '</div>', '</div>', '</div>', '</div>', '</div>', '</div>', '</div>'].join(''); 8649 8650 // ClockPicker 8651 function ClockPicker(element, options) { 8652 var popover = $(tpl), 8653 plate = popover.find('.clockpicker-plate'), 8654 holder = popover.find('.picker__holder'), 8655 hoursView = popover.find('.clockpicker-hours'), 8656 minutesView = popover.find('.clockpicker-minutes'), 8657 amPmBlock = popover.find('.clockpicker-am-pm-block'), 8658 isInput = element.prop('tagName') === 'INPUT', 8659 input = isInput ? element : element.find('input'), 8660 label = $("label[for=" + input.attr("id") + "]"), 8661 self = this; 8662 8663 this.id = uniqueId('cp'); 8664 this.element = element; 8665 this.holder = holder; 8666 this.options = options; 8667 this.isAppended = false;
8668 this.isShown = false; 8669 this.currentView = 'hours'; 8670 this.isInput = isInput; 8671 this.input = input; 8672 this.label = label; 8673 this.popover = popover; 8674 this.plate = plate; 8675 this.hoursView = hoursView; 8676 this.minutesView = minutesView; 8677 this.amPmBlock = amPmBlock; 8678 this.spanHours = popover.find('.clockpicker-span-hours'); 8679 this.spanMinutes = popover.find('.clockpicker-span-minutes'); 8680 this.spanAmPm = popover.find('.clockpicker-span-am-pm'); 8681 this.footer = popover.find('.picker__footer'); 8682 this.amOrPm = "PM"; 8683 8684 // Setup for for 12 hour clock if option is selected 8685 if (options.twelvehour) { 8686 if (!options.ampmclickable) { 8687 this.spanAmPm.empty(); 8688 $('<div id="click-am">AM</div>').appendTo(this.spanAmPm); 8689 $('<div id="click-pm">PM</div>').appendTo(this.spanAmPm); 8690 } else { 8691 this.spanAmPm.empty(); 8692 $('<div id="click-am">AM</div>').on("click", function () { 8693 self.spanAmPm.children('#click-am').addClass("text-primary"); 8694 self.spanAmPm.children('#click-pm').removeClass("text-primary"); 8695 self.amOrPm = "AM"; 8696 }).appendTo(this.spanAmPm); 8697 $('<div id="click-pm">PM</div>').on("click", function () { 8698 self.spanAmPm.children('#click-pm').addClass("text-primary"); 8699 self.spanAmPm.children('#click-am').removeClass("text-primary"); 8700 self.amOrPm = 'PM'; 8701 }).appendTo(this.spanAmPm); 8702 } 8703 } 8704 8705 // Add buttons to footer 8706 $('<button type="button" class="btn-flat picker__clear" tabindex="' + (options.twelvehour ? '3' : '1') + '">' + options.cleartext + '</button>').click($.proxy(this.clear, this)).appendTo(this.footer); 8707 $('<button type="button" class="btn-flat picker__close" tabindex="' + (options.twelvehour ? '3' : '1') + '">' + options.canceltext + '</button>').click($.proxy(this.hide, this)).appendTo(this.footer); 8708 $('<button type="button" class="btn-flat picker__close" tabindex="' + (options.twelvehour ? '3' : '1') + '">' + options.donetext + '</button>').click($.proxy(this.done, this)).appendTo(this.footer); 8709 8710 this.spanHours.click($.proxy(this.toggleView, this, 'hours')); 8711 this.spanMinutes.click($.proxy(this.toggleView, this, 'minutes')); 8712 8713 // Show or toggle 8714 input.on('focus.clockpicker click.clockpicker', $.proxy(this.show, this)); 8715 8716 // Build ticks 8717 var tickTpl = $('<div class="clockpicker-tick"></div>'), 8718 i, 8719 tick, 8720 radian, 8721 radius; 8722 8723 // Hours view 8724 if (options.twelvehour) { 8725 for (i = 1; i < 13; i += 1) { 8726 tick = tickTpl.clone(); 8727 radian = i / 6 * Math.PI; 8728 radius = outerRadius; 8729 tick.css({ 8730 left: dialRadius + Math.sin(radian) * radius - tickRadius, 8731 top: dialRadius - Math.cos(radian) * radius - tickRadius 8732 }); 8733 tick.html(i === 0 ? '00' : i); 8734 hoursView.append(tick); 8735 tick.on(mousedownEvent, mousedown); 8736 } 8737 } else { 8738 for (i = 0; i < 24; i += 1) { 8739 tick = tickTpl.clone(); 8740 radian = i / 6 * Math.PI; 8741 var inner = i > 0 && i < 13; 8742 radius = inner ? innerRadius : outerRadius; 8743 tick.css({ 8744 left: dialRadius + Math.sin(radian) * radius - tickRadius, 8745 top: dialRadius - Math.cos(radian) * radius - tickRadius 8746 }); 8747 tick.html(i === 0 ? '00' : i); 8748 hoursView.append(tick); 8749 tick.on(mousedownEvent, mousedown); 8750 } 8751 } 8752 8753 // Minutes view 8754 for (i = 0; i < 60; i += 5) { 8755 tick = tickTpl.clone(); 8756 radian = i / 30 * Math.PI; 8757 tick.css({ 8758 left: dialRadius + Math.sin(radian) * outerRadius - tickRadius, 8759 top: dialRadius - Math.cos(radian) * outerRadius - tickRadius 8760 }); 8761 tick.html(leadingZero(i)); 8762 minutesView.append(tick); 8763 tick.on(mousedownEvent, mousedown); 8764 } 8765 8766 // Clicking on minutes view space 8767 plate.on(mousedownEvent, function (e) { 8768 if ($(e.target).closest('.clockpicker-tick').length === 0) { 8769 mousedown(e, true); 8770 } 8771 }); 8772 8773 // Mousedown or touchstart 8774 function mousedown(e, space) { 8775 var offset = plate.offset(), 8776 isTouch = /^touch/.test(e.type), 8777 x0 = offset.left + dialRadius, 8778 y0 = offset.top + dialRadius, 8779 dx = (isTouch ? e.originalEvent.touches[0] : e).pageX
8779- x0, 8780 dy = (isTouch ? e.originalEvent.touches[0] : e).pageY - y0, 8781 z = Math.sqrt(dx * dx + dy * dy), 8782 moved = false; 8783 8784 // When clicking on minutes view space, check the mouse position 8785 if (space && (z < outerRadius - tickRadius || z > outerRadius + tickRadius)) { 8786 return; 8787 } 8788 e.preventDefault(); 8789 8790 // Set cursor style of body after 200ms 8791 var movingTimer = setTimeout(function () { 8792 self.popover.addClass('clockpicker-moving'); 8793 }, 200); 8794 8795 // Clock 8796 self.setHand(dx, dy, !space, true); 8797 8798 // Mousemove on document 8799 $doc.off(mousemoveEvent).on(mousemoveEvent, function (e) { 8800 e.preventDefault(); 8801 var isTouch = /^touch/.test(e.type), 8802 x = (isTouch ? e.originalEvent.touches[0] : e).pageX - x0, 8803 y = (isTouch ? e.originalEvent.touches[0] : e).pageY - y0; 8804 if (!moved && x === dx && y === dy) { 8805 // Clicking in chrome on windows will trigger a mousemove event 8806 return; 8807 } 8808 moved = true; 8809 self.setHand(x, y, false, true); 8810 }); 8811 8812 // Mouseup on document 8813 $doc.off(mouseupEvent).on(mouseupEvent, function (e) { 8814 $doc.off(mouseupEvent); 8815 e.preventDefault(); 8816 var isTouch = /^touch/.test(e.type), 8817 x = (isTouch ? e.originalEvent.changedTouches[0] : e).pageX - x0, 8818 y = (isTouch ? e.originalEvent.changedTouches[0] : e).pageY - y0; 8819 if ((space || moved) && x === dx && y === dy) { 8820 self.setHand(x, y); 8821 } 8822 8823 if (self.currentView === 'hours') { 8824 self.toggleView('minutes', duration / 2); 8825 } else if (options.autoclose) { 8826 self.minutesView.addClass('clockpicker-dial-out'); 8827 setTimeout(function () { 8828 self.done(); 8829 }, duration / 2); 8830 } 8831 plate.prepend(canvas); 8832 8833 // Reset cursor style of body 8834 clearTimeout(movingTimer); 8835 self.popover.removeClass('clockpicker-moving'); 8836 8837 // Unbind mousemove event 8838 $doc.off(mousemoveEvent); 8839 }); 8840 } 8841 8842 if (svgSupported) { 8843 // Draw clock hands and others 8844 var canvas = popover.find('.clockpicker-canvas'), 8845 svg = createSvgElement('svg'); 8846 svg.setAttribute('class', 'clockpicker-svg'); 8847 svg.setAttribute('width', diameter); 8848 svg.setAttribute('height', diameter); 8849 var g = createSvgElement('g'); 8850 g.setAttribute('transform', 'translate(' + dialRadius + ',' + dialRadius + ')'); 8851 var bearing = createSvgElement('circle'); 8852 bearing.setAttribute('class', 'clockpicker-canvas-bearing'); 8853 bearing.setAttribute('cx', 0); 8854 bearing.setAttribute('cy', 0); 8855 bearing.setAttribute('r', 4); 8856 var hand = createSvgElement('line'); 8857 hand.setAttribute('x1', 0); 8858 hand.setAttribute('y1', 0); 8859 var bg = createSvgElement('circle'); 8860 bg.setAttribute('class', 'clockpicker-canvas-bg'); 8861 bg.setAttribute('r', tickRadius); 8862 g.appendChild(hand); 8863 g.appendChild(bg); 8864 g.appendChild(bearing); 8865 svg.appendChild(g); 8866 canvas.append(svg); 8867 8868 this.hand = hand; 8869 this.bg = bg; 8870 this.bearing = bearing; 8871 this.g = g; 8872 this.canvas = canvas; 8873 } 8874 8875 raiseCallback(this.options.init); 8876 } 8877 8878 function raiseCallback(callbackFunction) { 8879 if (callbackFunction && typeof callbackFunction === "function") callbackFunction(); 8880 } 8881 8882 // Default options 8883 ClockPicker.DEFAULTS = { 8884 'default': '', // default time, 'now' or '13:14' e.g. 8885 fromnow: 0, // set default time to * milliseconds from now (using with default = 'now') 8886 donetext: 'Ok', // done button text 8887 cleartext: 'Clear', 8888 canceltext: 'Cancel', 8889 autoclose: false, // auto close when minute is selected 8890 ampmclickable: true, // set am/pm button on itself 8891 darktheme: false, // set to dark theme 8892 twelvehour: true, // change to 12 hour AM/PM clock from 24 hour 8893 vibrate: true // vibrate the device when dragging clock hand 8894 }; 8895 8896 // Show or hide popover 8897 ClockPicker.prototype.toggle = function () { 8898 this[this.isShown ? 'hide' : 'show'](); 8899 }; 8900 8901 // Set popover position 8902 ClockPicker.prototype.locate = function () { 8903 var element = this.element, 8904 popover = this.popover, 8905 offset = element.offset(), 8906 width = element.outerWidth(), 8907 height = element.outerHeight(), 8908 align = this.options.align, 8909 self = this; 8910 8911 popover.show(); 8912 }; 8913 8914 // Show popover 8915 ClockPicker.prototype.show = function (e) { 8916 // Not show again 8917 if (this.isShown) { 8918 return; 8919 } 8920 raiseCallback(this.options.beforeShow); 8921 $(':input').each(function () { 8922 $(this).attr('tabindex', -1); 8923 }); 8924 var self = this; 8925 // Initialize 8926 this.input.blur(); 8927 this.popover.addClass('picker--opened'); 8928 this.input.addClass('picker__input picker__input--active'); 8929 $(document.body).css('overflow', 'hidden'); 8930 // Get the time 8931 var value = ((this.input.prop('value') || this.options['default'] || '') + '').split(':'); 8932 if (this.options.twelvehour && !(typeof value[1] === 'undefined')) { 8933 if (value[1].indexOf("AM") > 0) { 8934 this.amOrPm = 'AM'; 8935 } else { 8936 this.amOrPm = 'PM'; 8937 } 8938 value[1] = value[1].replace("AM", "").replace("PM", ""); 8939 } 8940 if (value[0] === 'now') { 8941 var now = new Date(+new Date() + this.options.fromnow); 8942 value = [now.getHours(), now.getMinutes()]; 8943 if (this.options.twelvehour) { 8944 this.amOrPm = value[0] >= 12 && value[0] < 24 ? 'PM' : 'AM'; 8945 } 8946 } 8947 this.hours = +value[0] || 0; 8948 this.minutes = +value[1] || 0; 8949 this.spanHours.html(this.hours); 8950 this.spanMinutes.html(leadingZero(this.minutes)); 8951 if (!this.isAppended) { 8952 // Append popover to body 8953 this.popover.insertAfter(this.input); 8954 if (this.options.twelvehour) { 8955 if (this.amOrPm === 'PM') { 8956 this.spanAmPm.children('#click-pm').addClass("text-primary"); 8957 this.spanAmPm.children('#click-am').removeClass("text-primary"); 8958 } else { 8959 this.spanAmPm.children('#click-am').addClass("text-primary"); 8960 this.spanAmPm.children('#click-pm').removeClass("text-primary"); 8961 } 8962 } 8963 // Reset position when resize 8964 $win.on('resize.clockpicker' + this.id, function () { 8965 if (self.isShown) { 8966 self.locate(); 8967 } 8968 }); 8969 this.isAppended = true; 8970 } 8971 // Toggle to hours view 8972 this.toggleView('hours'); 8973 // Set position 8974 this.locate(); 8975 this.isShown = true; 8976 // Hide when clicking or tabbing on any element except the clock and input 8977 $doc.on('click.clockpicker.' + this.id + ' focusin.clockpicker.' + this.id, function (e) { 8978 var target = $(e.target); 8979 if (target.closest(self.popover.find('.picker__wrap')).length === 0 && target.closest(self.input).length === 0) { 8980 self.hide(); 8981 } 8982 }); 8983 // Hide when ESC is pressed 8984 $doc.on('keyup.clockpicker.' + this.id, function (e) { 8985 if (e.keyCode === 27) { 8986 self.hide(); 8987 } 8988 }); 8989 raiseCallback(this.options.afterShow); 8990 }; 8991 // Hide popover 8992 ClockPicker.prototype.hide = function () { 8993 raiseCallback(this.options.beforeHide); 8994 this.input.removeClass('picker__input picker__input--active'); 8995 this.popover.removeClass('picker--opened'); 8996 $(document.body).css('overflow', 'visible'); 8997 this.isShown = false;
8998 $(':input').each(function (index) { 8999 $(this).attr('tabindex', index + 1); 9000 }); 9001 // Unbinding events on document 9002 $doc.off('click.clockpicker.' + this.id + ' focusin.clockpicker.' + this.id); 9003 $doc.off('keyup.clockpicker.' + this.id); 9004 this.popover.hide(); 9005 raiseCallback(this.options.afterHide); 9006 }; 9007 // Toggle to hours or minutes view 9008 ClockPicker.prototype.toggleView = function (view, delay) { 9009 var raiseAfterHourSelect = false; 9010 if (view === 'minutes' && $(this.hoursView).css("visibility") === "visible") { 9011 raiseCallback(this.options.beforeHourSelect); 9012 raiseAfterHourSelect = true; 9013 } 9014 var isHours = view === 'hours', 9015 nextView = isHours ? this.hoursView : this.minutesView, 9016 hideView = isHours ? this.minutesView : this.hoursView; 9017 this.currentView = view; 9018 9019 this.spanHours.toggleClass('text-primary', isHours); 9020 this.spanMinutes.toggleClass('text-primary', !isHours); 9021 9022 // Let's make transitions 9023 hideView.addClass('clockpicker-dial-out'); 9024 nextView.css('visibility', 'visible').removeClass('clockpicker-dial-out'); 9025 9026 // Reset clock hand 9027 this.resetClock(delay); 9028 9029 // After transitions ended 9030 clearTimeout(this.toggleViewTimer); 9031 this.toggleViewTimer = setTimeout(function () { 9032 hideView.css('visibility', 'hidden'); 9033 }, duration); 9034 9035 if (raiseAfterHourSelect) { 9036 raiseCallback(this.options.afterHourSelect); 9037 } 9038 }; 9039 9040 // Reset clock hand 9041 ClockPicker.prototype.resetClock = function (delay) { 9042 var view = this.currentView, 9043 value = this[view], 9044 isHours = view === 'hours', 9045 unit = Math.PI / (isHours ? 6 : 30), 9046 radian = value * unit, 9047 radius = isHours && value > 0 && value < 13 ? innerRadius : outerRadius, 9048 x = Math.sin(radian) * radius, 9049 y = -Math.cos(radian) * radius, 9050 self = this; 9051 9052 if (svgSupported && delay) { 9053 self.canvas.addClass('clockpicker-canvas-out'); 9054 setTimeout(function () { 9055 self.canvas.removeClass('clockpicker-canvas-out'); 9056 self.setHand(x, y); 9057 }, delay); 9058 } else this.setHand(x, y); 9059 }; 9060 9061 // Set clock hand to (x, y) 9062 ClockPicker.prototype.setHand = function (x, y, roundBy5, dragging) { 9063 var radian = Math.atan2(x, -y), 9064 isHours = this.currentView === 'hours', 9065 unit = Math.PI / (isHours || roundBy5 ? 6 : 30), 9066 z = Math.sqrt(x * x + y * y), 9067 options = this.options, 9068 inner = isHours && z < (outerRadius + innerRadius) / 2, 9069 radius = inner ? innerRadius : outerRadius, 9070 value; 9071 9072 if (options.twelvehour) { 9073 radius = outerRadius; 9074 } 9075 9076 // Radian should in range [0, 2PI] 9077 if (radian < 0) { 9078 radian = Math.PI * 2 + radian; 9079 } 9080 9081 // Get the round value 9082 value = Math.round(radian / unit); 9083 9084 // Get the round radian 9085 radian = value * unit; 9086 9087 // Correct the hours or minutes 9088 if (options.twelvehour) { 9089 if (isHours) { 9090 if (value === 0) value = 12; 9091 } else { 9092 if (roundBy5) value *= 5; 9093 if (value === 60) value = 0; 9094 } 9095 } else { 9096 if (isHours) { 9097 if (value === 12) value = 0; 9098 value = inner ? value === 0 ? 12 : value : value === 0 ? 0 : value + 12; 9099 } else { 9100 if (roundBy5) value *= 5; 9101 if (value === 60) value = 0; 9102 } 9103 } 9104 9105 // Once hours or minutes changed, vibrate the device 9106 if (this[this.currentView] !== value) { 9107 if (vibrate && this.options.vibrate) { 9108 // Do not vibrate too frequently 9109 if (!this.vibrateTimer) { 9110 navigator[vibrate](10); 9111 this.vibrateTimer = setTimeout($.proxy(function () { 9112 this.vibrateTimer = null; 9113 }, this), 100); 9114 } 9115 } 9116 } 9117 9118 this[this.currentView] = value; 9119 if (isHours) { 9120 this['spanHours'].html(value); 9121 } else { 9122 this['spanMinutes'].html(leadingZero(value)); 9123 } 9124 9125 // If svg is not supported, just add an active class to the tick 9126 if (!svgSupported) { 9127 this[isHours ? 'hoursView' : 'minutesView'].find('.clockpicker-tick').each(function () { 9128 var tick = $(this); 9129 tick.toggleClass('active', value === +tick.html()); 9130 }); 9131 return; 9132 } 9133 9134 // Set clock hand and others' position 9135 var cx1 = Math.sin(radian) * (radius - tickRadius),
9136 cy1 = -Math.cos(radian) * (radius - tickRadius), 9137 cx2 = Math.sin(radian) * radius, 9138 cy2 = -Math.cos(radian) * radius; 9139 this.hand.setAttribute('x2', cx1); 9140 this.hand.setAttribute('y2', cy1); 9141 this.bg.setAttribute('cx', cx2); 9142 this.bg.setAttribute('cy', cy2); 9143 }; 9144 9145 // Hours and minutes are selected 9146 ClockPicker.prototype.done = function () { 9147 raiseCallback(this.options.beforeDone); 9148 this.hide(); 9149 this.label.addClass('active'); 9150 9151 var last = this.input.prop('value'), 9152 value = leadingZero(this.hours) + ':' + leadingZero(this.minutes); 9153 if (this.options.twelvehour) { 9154 value = value + this.amOrPm; 9155 } 9156 9157 this.input.prop('value', value); 9158 if (value !== last) { 9159 this.input.triggerHandler('change'); 9160 if (!this.isInput) { 9161 this.element.trigger('change'); 9162 } 9163 } 9164 9165 if (this.options.autoclose) this.input.trigger('blur'); 9166 9167 raiseCallback(this.options.afterDone); 9168 }; 9169 9170 // Clear input field 9171 ClockPicker.prototype.clear = function () { 9172 this.hide(); 9173 this.label.removeClass('active'); 9174 9175 var last = this.input.prop('value'), 9176 value = ''; 9177 9178 this.input.prop('value', value); 9179 if (value !== last) { 9180 this.input.triggerHandler('change'); 9181 if (!this.isInput) { 9182 this.element.trigger('change'); 9183 } 9184 } 9185 9186 if (this.options.autoclose) { 9187 this.input.trigger('blur'); 9188 } 9189 }; 9190 9191 // Remove clockpicker from input 9192 ClockPicker.prototype.remove = function () { 9193 this.element.removeData('clockpicker'); 9194 this.input.off('focus.clockpicker click.clockpicker'); 9195 if (this.isShown) { 9196 this.hide(); 9197 } 9198 if (this.isAppended) { 9199 $win.off('resize.clockpicker' + this.id); 9200 this.popover.remove(); 9201 } 9202 }; 9203 9204 // Extends $.fn.clockpicker 9205 $.fn.pickatime = function (option) { 9206 var args = Array.prototype.slice.call(arguments, 1); 9207 return this.each(function () { 9208 var $this = $(this), 9209 data = $this.data('clockpicker'); 9210 if (!data) { 9211 var options = $.extend({}, ClockPicker.DEFAULTS, $this.data(), typeof option == 'object' && option); 9212 $this.data('clockpicker', new ClockPicker($this, options)); 9213 } else { 9214 // Manual operatsions. show, hide, remove, e.g. 9215 if (typeof data[option] === 'function') { 9216 data[option].apply(data, args); 9217 } 9218 } 9219 }); 9220 }; 9221})(); 9222;(function ($) { 9223 9224 $.fn.characterCounter = function () { 9225 return this.each(function () { 9226 var $input = $(this); 9227 var $counterElement = $input.parent().find('span[class="character-counter"]'); 9228 9229 // character counter has already been added appended to the parent container 9230 if ($counterElement.length) { 9231 return; 9232 } 9233 9234 var itHasLengthAttribute = $input.attr('data-length') !== undefined; 9235 9236 if (itHasLengthAttribute) { 9237 $input.on('input', updateCounter); 9238 $input.on('focus', updateCounter); 9239 $input.on('blur', removeCounterElement); 9240 9241 addCounterElement($input); 9242 } 9243 }); 9244 }; 9245 9246 function updateCounter() { 9247 var maxLength = +$(this).attr('data-length'), 9248 actualLength = +$(this).val().length, 9249 isValidLength = actualLength <= maxLength; 9250 9251 $(this).parent().find('span[class="character-counter"]').html(actualLength + '/' + maxLength); 9252 9253 addInputStyle(isValidLength, $(this)); 9254 } 9255 9256 function addCounterElement($input) { 9257 var $counterElement = $input.parent().find('span[class="character-counter"]'); 9258 9259 if ($counterElement.length) { 9260 return; 9261 } 9262 9263 $counterElement = $('<span/>').addClass('character-counter').css('float', 'right').css('font-size', '12px').css('height', 1); 9264 9265 $input.parent().append($counterElement); 9266 } 9267 9268 function removeCounterElement() { 9269 $(this).parent().find('span[class="character-counter"]').html(''); 9270 } 9271 9272 function addInputStyle(isValidLength, $input) { 9273 var inputHasInvalidClass = $input.hasClass('invalid'); 9274 if (isValidLength && inputHasInvalidClass) { 9275 $input.removeClass('invalid'); 9276 } else if (!isValidLength && !inputHasInvalidClass) { 9277 $input.removeClass('valid'); 9278 $input.addClass('invalid'); 9279 } 9280 } 9281 9282 $(document).ready(function () { 9283 $('input, textarea').characterCounter(); 9284 }); 9285})(jQuery); 9286;(function ($) { 9287 9288 var methods = { 9289 9290 init: function (options) { 9291 var defaults = { 9292 duration: 200, // ms 9293 dist: -100, // zoom scale TODO: make this more intuitive as an option 9294 shift: 0, // spacing for center image 9295 padding: 0, // Padding between non center items 9296 fullWidth: false, // Change to full width styles 9297 indicators: false, // Toggle indicators 9298 noWrap: false, // Don't wrap around and cycle through items. 9299 onCycleTo: null // Callback for when a new slide is cycled to. 9300 }; 9301 options = $.extend(defaults, options);
9302 var namespace = Materialize.objectSelectorString($(this)); 9303 9304 return this.each(function (i) { 9305 9306 var images, item_width, item_height, offset, center, pressed, dim, count, reference, referenceY, amplitude, target, velocity, scrolling, xform, frame, timestamp, ticker, dragged, vertical_dragged; 9307 var $indicators = $('<ul class="indicators"></ul>'); 9308 var scrollingTimeout = null; 9309 var oneTimeCallback = null; 9310 9311 // Initialize 9312 var view = $(this); 9313 var hasMultipleSlides = view.find('.carousel-item').length > 1; 9314 var showIndicators = (view.attr('data-indicators') || options.indicators) && hasMultipleSlides; 9315 var noWrap = view.attr('data-no-wrap') || options.noWrap || !hasMultipleSlides; 9316 var uniqueNamespace = view.attr('data-namespace') || namespace + i; 9317 view.attr('data-namespace', uniqueNamespace); 9318 9319 // Options 9320 var setCarouselHeight = function (imageOnly) { 9321 var firstSlide = view.find('.carousel-item.active').length ? view.find('.carousel-item.active').first() : view.find('.carousel-item').first(); 9322 var firstImage = firstSlide.find('img').first(); 9323 if (firstImage.length) { 9324 if (firstImage[0].complete) { 9325 // If image won't trigger the load event 9326 var imageHeight = firstImage.height(); 9327 if (imageHeight > 0) { 9328 view.css('height', firstImage.height()); 9329 } else { 9330 // If image still has no height, use the natural dimensions to calculate 9331 var naturalWidth = firstImage[0].naturalWidth; 9332 var naturalHeight = firstImage[0].naturalHeight; 9333 var adjustedHeight = view.width() / naturalWidth * naturalHeight; 9334 view.css('height', adjustedHeight); 9335 } 9336 } else { 9337 // Get height when image is loaded normally 9338 firstImage.on('load', function () { 9339 view.css('height', $(this).height()); 9340 }); 9341 } 9342 } else if (!imageOnly) { 9343 var slideHeight = firstSlide.height(); 9344 view.css('height', slideHeight); 9345 } 9346 }; 9347 9348 if (options.fullWidth) { 9349 options.dist = 0; 9350 setCarouselHeight(); 9351 9352 // Offset fixed items when indicators. 9353 if (showIndicators) { 9354 view.find('.carousel-fixed-item').addClass('with-indicators'); 9355 } 9356 } 9357 9358 // Don't double initialize. 9359 if (view.hasClass('initialized')) { 9360 // Recalculate variables 9361 $(window).trigger('resize'); 9362 9363 // Redraw carousel. 9364 view.trigger('carouselNext', [0.000001]); 9365 return true; 9366 } 9367 9368 view.addClass('initialized'); 9369 pressed = false; 9370 offset = target = 0; 9371 images = []; 9372 item_width = view.find('.carousel-item').first().innerWidth(); 9373 item_height = view.find('.carousel-item').first().innerHeight(); 9374 dim = item_width * 2 + options.padding; 9375 9376 view.find('.carousel-item').each(function (i) { 9377 images.push($(this)[0]); 9378 if (showIndicators) { 9379 var $indicator = $('<li class="indicator-item"></li>'); 9380 9381 // Add active to first by default. 9382 if (i === 0) { 9383 $indicator.addClass('active'); 9384 } 9385 9386 // Handle clicks on indicators. 9387 $indicator.click(function (e) { 9388 e.stopPropagation(); 9389 9390 var index = $(this).index(); 9391 cycleTo(index); 9392 }); 9393 $indicators.append($indicator); 9394 } 9395 }); 9396 9397 if (showIndicators) { 9398 view.append($indicators); 9399 } 9400 count = images.length; 9401 9402 function setupEvents() { 9403 if (typeof window.ontouchstart !== 'undefined') { 9404 view.on('touchstart.carousel', tap); 9405 view.on('touchmove.carousel', drag); 9406 view.on('touchend.carousel', release); 9407 } 9408 view.on('mousedown.carousel', tap); 9409 view.on('mousemove.carousel', drag); 9410 view.on('mouseup.carousel', release); 9411 view.on('mouseleave.carousel', release); 9412 view.on('click.carousel', click); 9413 } 9414 9415 function xpos(e) { 9416 // touch event 9417 if (e.targetTouches && e.targetTouches.length >= 1) { 9418 return e.targetTouches[0].clientX; 9419 } 9420 9421 // mouse event 9422 return e.clientX; 9423 } 9424 9425 function ypos(e) { 9426 // touch event 9427 if (e.targetTouches && e.targetTouches.length >= 1) { 9428 return e.targetTouches[0].clientY; 9429 } 9430 9431 // mouse event 9432 return e.clientY; 9433 } 9434 9435 function wrap(x) { 9436 return x >= count ? x % count : x < 0 ? wrap(count + x % count) : x; 9437 } 9438 9439 function scroll(x) { 9440 // Track scrolling state 9441 scrolling = true; 9442 if (!view.hasClass('scrolling')) { 9443 view.addClass('scrolling'); 9444 } 9445 if (scrollingTimeout != null) { 9446 window.clearTimeout(scrollingTimeout); 9447 } 9448 scrollingTimeout = window.setTimeout(function () { 9449 scrolling = false;
9450 view.removeClass('scrolling'); 9451 }, options.duration); 9452 9453 // Start actual scroll 9454 var i, half, delta, dir, tween, el, alignment, xTranslation; 9455 var lastCenter = center; 9456 9457 offset = typeof x === 'number' ? x : offset; 9458 center = Math.floor((offset + dim / 2) / dim); 9459 delta = offset - center * dim; 9460 dir = delta < 0 ? 1 : -1; 9461 tween = -dir * delta * 2 / dim; 9462 half = count >> 1; 9463 9464 if (!options.fullWidth) { 9465 alignment = 'translateX(' + (view[0].clientWidth - item_width) / 2 + 'px) '; 9466 alignment += 'translateY(' + (view[0].clientHeight - item_height) / 2 + 'px)'; 9467 } else { 9468 alignment = 'translateX(0)'; 9469 } 9470 9471 // Set indicator active 9472 if (showIndicators) { 9473 var diff = center % count; 9474 var activeIndicator = $indicators.find('.indicator-item.active'); 9475 if (activeIndicator.index() !== diff) { 9476 activeIndicator.removeClass('active'); 9477 $indicators.find('.indicator-item').eq(diff).addClass('active'); 9478 } 9479 } 9480 9481 // center 9482 // Don't show wrapped items. 9483 if (!noWrap || center >= 0 && center < count) { 9484 el = images[wrap(center)]; 9485 9486 // Add active class to center item. 9487 if (!$(el).hasClass('active')) { 9488 view.find('.carousel-item').removeClass('active'); 9489 $(el).addClass('active'); 9490 } 9491 el.style[xform] = alignment + ' translateX(' + -delta / 2 + 'px)' + ' translateX(' + dir * options.shift * tween * i + 'px)' + ' translateZ(' + options.dist * tween + 'px)'; 9492 el.style.zIndex = 0; 9493 if (options.fullWidth) { 9494 tweenedOpacity = 1; 9495 } else { 9496 tweenedOpacity = 1 - 0.2 * tween; 9497 } 9498 el.style.opacity = tweenedOpacity; 9499 el.style.display = 'block'; 9500 } 9501 9502 for (i = 1; i <= half; ++i) { 9503 // right side 9504 if (options.fullWidth) { 9505 zTranslation = options.dist; 9506 tweenedOpacity = i === half && delta < 0 ? 1 - tween : 1; 9507 } else { 9508 zTranslation = options.dist * (i * 2 + tween * dir); 9509 tweenedOpacity = 1 - 0.2 * (i * 2 + tween * dir); 9510 } 9511 // Don't show wrapped items. 9512 if (!noWrap || center + i < count) { 9513 el = images[wrap(center + i)]; 9514 el.style[xform] = alignment + ' translateX(' + (options.shift + (dim * i - delta) / 2) + 'px)' + ' translateZ(' + zTranslation + 'px)'; 9515 el.style.zIndex = -i; 9516 el.style.opacity = tweenedOpacity; 9517 el.style.display = 'block'; 9518 } 9519 9520 // left side 9521 if (options.fullWidth) { 9522 zTranslation = options.dist; 9523 tweenedOpacity = i === half && delta > 0 ? 1 - tween : 1; 9524 } else { 9525 zTranslation = options.dist * (i * 2 - tween * dir); 9526 tweenedOpacity = 1 - 0.2 * (i * 2 - tween * dir); 9527 } 9528 // Don't show wrapped items. 9529 if (!noWrap || center - i >= 0) { 9530 el = images[wrap(center - i)]; 9531 el.style[xform] = alignment + ' translateX(' + (-options.shift + (-dim * i - delta) / 2) + 'px)' + ' translateZ(' + zTranslation + 'px)'; 9532 el.style.zIndex = -i; 9533 el.style.opacity = tweenedOpacity; 9534 el.style.display = 'block'; 9535 } 9536 } 9537 9538 // center 9539 // Don't show wrapped items. 9540 if (!noWrap || center >= 0 && center < count) { 9541 el = images[wrap(center)]; 9542 el.style[xform] = alignment + ' translateX(' + -delta / 2 + 'px)' + ' translateX(' + dir * options.shift * tween + 'px)' + ' translateZ(' + options.dist * tween + 'px)'; 9543 el.style.zIndex = 0; 9544 if (options.fullWidth) { 9545 tweenedOpacity = 1; 9546 } else { 9547 tweenedOpacity = 1 - 0.2 * tween; 9548 } 9549 el.style.opacity = tweenedOpacity; 9550 el.style.display = 'block'; 9551 } 9552 9553 // onCycleTo callback 9554 if (lastCenter !== center && typeof options.onCycleTo === "function") { 9555 var $curr_item = view.find('.carousel-item').eq(wrap(center)); 9556 options.onCycleTo.call(this, $curr_item, dragged); 9557 } 9558 9559 // One time callback 9560 if (typeof oneTimeCallback === "function") { 9561 oneTimeCallback.call(this, $curr_item, dragged); 9562 oneTimeCallback = null; 9563 } 9564 } 9565 9566 function track() { 9567 var now, elapsed, delta, v; 9568 9569 now = Date.now();
9570 elapsed = now - timestamp; 9571 timestamp = now; 9572 delta = offset - frame; 9573 frame = offset; 9574 9575 v = 1000 * delta / (1 + elapsed); 9576 velocity = 0.8 * v + 0.2 * velocity; 9577 } 9578 9579 function autoScroll() { 9580 var elapsed, delta; 9581 9582 if (amplitude) { 9583 elapsed = Date.now() - timestamp; 9584 delta = amplitude * Math.exp(-elapsed / options.duration); 9585 if (delta > 2 || delta < -2) { 9586 scroll(target - delta); 9587 requestAnimationFrame(autoScroll); 9588 } else { 9589 scroll(target); 9590 } 9591 } 9592 } 9593 9594 function click(e) { 9595 // Disable clicks if carousel was dragged. 9596 if (dragged) { 9597 e.preventDefault(); 9598 e.stopPropagation(); 9599 return false; 9600 } else if (!options.fullWidth) { 9601 var clickedIndex = $(e.target).closest('.carousel-item').index(); 9602 var diff = wrap(center) - clickedIndex; 9603 9604 // Disable clicks if carousel was shifted by click 9605 if (diff !== 0) { 9606 e.preventDefault(); 9607 e.stopPropagation(); 9608 } 9609 cycleTo(clickedIndex); 9610 } 9611 } 9612 9613 function cycleTo(n) { 9614 var diff = center % count - n; 9615 9616 // Account for wraparound. 9617 if (!noWrap) { 9618 if (diff < 0) { 9619 if (Math.abs(diff + count) < Math.abs(diff)) { 9620 diff += count; 9621 } 9622 } else if (diff > 0) { 9623 if (Math.abs(diff - count) < diff) { 9624 diff -= count; 9625 } 9626 } 9627 } 9628 9629 // Call prev or next accordingly. 9630 if (diff < 0) { 9631 view.trigger('carouselNext', [Math.abs(diff)]); 9632 } else if (diff > 0) { 9633 view.trigger('carouselPrev', [diff]); 9634 } 9635 } 9636 9637 function tap(e) { 9638 // Fixes firefox draggable image bug 9639 if (e.type === 'mousedown' && $(e.target).is('img')) { 9640 e.preventDefault(); 9641 } 9642 pressed = true; 9643 dragged = false; 9644 vertical_dragged = false; 9645 reference = xpos(e); 9646 referenceY = ypos(e); 9647 9648 velocity = amplitude = 0; 9649 frame = offset; 9650 timestamp = Date.now(); 9651 clearInterval(ticker); 9652 ticker = setInterval(track, 100); 9653 } 9654 9655 function drag(e) { 9656 var x, delta, deltaY; 9657 if (pressed) { 9658 x = xpos(e); 9659 y = ypos(e); 9660 delta = reference - x; 9661 deltaY = Math.abs(referenceY - y); 9662 if (deltaY < 30 && !vertical_dragged) { 9663 // If vertical scrolling don't allow dragging. 9664 if (delta > 2 || delta < -2) { 9665 dragged = true; 9666 reference = x; 9667 scroll(offset + delta); 9668 } 9669 } else if (dragged) { 9670 // If dragging don't allow vertical scroll. 9671 e.preventDefault(); 9672 e.stopPropagation(); 9673 return false; 9674 } else { 9675 // Vertical scrolling. 9676 vertical_dragged = true; 9677 } 9678 } 9679 9680 if (dragged) { 9681 // If dragging don't allow vertical scroll. 9682 e.preventDefault(); 9683 e.stopPropagation(); 9684 return false; 9685 } 9686 } 9687 9688 function release(e) { 9689 if (pressed) { 9690 pressed = false; 9691 } else { 9692 return; 9693 } 9694 9695 clearInterval(ticker); 9696 target = offset; 9697 if (velocity > 10 || velocity < -10) { 9698 amplitude = 0.9 * velocity; 9699 target = offset + amplitude; 9700 } 9701 target = Math.round(target / dim) * dim; 9702 9703 // No wrap of items. 9704 if (noWrap) { 9705 if (target >= dim * (count - 1)) { 9706 target = dim * (count - 1); 9707 } else if (target < 0) { 9708 target = 0; 9709 } 9710 } 9711 amplitude = target - offset; 9712 timestamp = Date.now(); 9713 requestAnimationFrame(autoScroll); 9714 9715 if (dragged) { 9716 e.preventDefault(); 9717 e.stopPropagation(); 9718 } 9719 return false;
9720 } 9721 9722 xform = 'transform'; 9723 ['webkit', 'Moz', 'O', 'ms'].every(function (prefix) { 9724 var e = prefix + 'Transform'; 9725 if (typeof document.body.style[e] !== 'undefined') { 9726 xform = e; 9727 return false; 9728 } 9729 return true; 9730 }); 9731 9732 var throttledResize = Materialize.throttle(function () { 9733 if (options.fullWidth) { 9734 item_width = view.find('.carousel-item').first().innerWidth(); 9735 var imageHeight = view.find('.carousel-item.active').height(); 9736 dim = item_width * 2 + options.padding; 9737 offset = center * 2 * item_width; 9738 target = offset; 9739 setCarouselHeight(true); 9740 } else { 9741 scroll(); 9742 } 9743 }, 200); 9744 $(window).off('resize.carousel-' + uniqueNamespace).on('resize.carousel-' + uniqueNamespace, throttledResize); 9745 9746 setupEvents(); 9747 scroll(offset); 9748 9749 $(this).on('carouselNext', function (e, n, callback) { 9750 if (n === undefined) { 9751 n = 1; 9752 } 9753 if (typeof callback === "function") { 9754 oneTimeCallback = callback; 9755 } 9756 9757 target = dim * Math.round(offset / dim) + dim * n; 9758 if (offset !== target) { 9759 amplitude = target - offset; 9760 timestamp = Date.now(); 9761 requestAnimationFrame(autoScroll); 9762 } 9763 }); 9764 9765 $(this).on('carouselPrev', function (e, n, callback) { 9766 if (n === undefined) { 9767 n = 1; 9768 } 9769 if (typeof callback === "function") { 9770 oneTimeCallback = callback; 9771 } 9772 9773 target = dim * Math.round(offset / dim) - dim * n; 9774 if (offset !== target) { 9775 amplitude = target - offset; 9776 timestamp = Date.now(); 9777 requestAnimationFrame(autoScroll); 9778 } 9779 }); 9780 9781 $(this).on('carouselSet', function (e, n, callback) { 9782 if (n === undefined) { 9783 n = 0; 9784 } 9785 if (typeof callback === "function") { 9786 oneTimeCallback = callback; 9787 } 9788 9789 cycleTo(n); 9790 }); 9791 }); 9792 }, 9793 next: function (n, callback) { 9794 $(this).trigger('carouselNext', [n, callback]); 9795 }, 9796 prev: function (n, callback) { 9797 $(this).trigger('carouselPrev', [n, callback]); 9798 }, 9799 set: function (n, callback) { 9800 $(this).trigger('carouselSet', [n, callback]); 9801 }, 9802 destroy: function () { 9803 var uniqueNamespace = $(this).attr('data-namespace'); 9804 $(this).removeAttr('data-namespace'); 9805 $(this).removeClass('initialized'); 9806 $(this).find('.indicators').remove(); 9807 9808 // Remove event handlers 9809 $(this).off('carouselNext carouselPrev carouselSet'); 9810 $(window).off('resize.carousel-' + uniqueNamespace); 9811 if (typeof window.ontouchstart !== 'undefined') { 9812 $(this).off('touchstart.carousel touchmove.carousel touchend.carousel'); 9813 } 9814 $(this).off('mousedown.carousel mousemove.carousel mouseup.carousel mouseleave.carousel click.carousel'); 9815 } 9816 }; 9817 9818 $.fn.carousel = function (methodOrOptions) { 9819 if (methods[methodOrOptions]) { 9820 return methods[methodOrOptions].apply(this, Array.prototype.slice.call(arguments, 1)); 9821 } else if (typeof methodOrOptions === 'object' || !methodOrOptions) { 9822 // Default to "init" 9823 return methods.init.apply(this, arguments); 9824 } else { 9825 $.error('Method ' + methodOrOptions + ' does not exist on jQuery.carousel'); 9826 } 9827 }; // Plugin end 9828})(jQuery); 9829;(function ($) { 9830 9831 var methods = { 9832 init: function (options) { 9833 return this.each(function () { 9834 var origin = $('#' + $(this).attr('data-activates')); 9835 var screen = $('body'); 9836 9837 // Creating tap target 9838 var tapTargetEl = $(this); 9839 var tapTargetWrapper = tapTargetEl.parent('.tap-target-wrapper'); 9840 var tapTargetWave = tapTargetWrapper.find('.tap-target-wave'); 9841 var tapTargetOriginEl = tapTargetWrapper.find('.tap-target-origin'); 9842 var tapTargetContentEl = tapTargetEl.find('.tap-target-content'); 9843 9844 // Creating wrapper 9845 if (!tapTargetWrapper.length) { 9846 tapTargetWrapper = tapTargetEl.wrap($('<div class="tap-target-wrapper"></div>')).parent(); 9847 } 9848 9849 // Creating content 9850 if (!tapTargetContentEl.length) {
9851 tapTargetContentEl = $('<div class="tap-target-content"></div>'); 9852 tapTargetEl.append(tapTargetContentEl); 9853 } 9854 9855 // Creating foreground wave 9856 if (!tapTargetWave.length) { 9857 tapTargetWave = $('<div class="tap-target-wave"></div>'); 9858 9859 // Creating origin 9860 if (!tapTargetOriginEl.length) { 9861 tapTargetOriginEl = origin.clone(true, true); 9862 tapTargetOriginEl.addClass('tap-target-origin'); 9863 tapTargetOriginEl.removeAttr('id'); 9864 tapTargetOriginEl.removeAttr('style'); 9865 tapTargetWave.append(tapTargetOriginEl); 9866 } 9867 9868 tapTargetWrapper.append(tapTargetWave); 9869 } 9870 9871 // Open 9872 var openTapTarget = function () { 9873 if (tapTargetWrapper.is('.open')) { 9874 return; 9875 } 9876 9877 // Adding open class 9878 tapTargetWrapper.addClass('open'); 9879 9880 setTimeout(function () { 9881 tapTargetOriginEl.off('click.tapTarget').on('click.tapTarget', function (e) { 9882 closeTapTarget(); 9883 tapTargetOriginEl.off('click.tapTarget'); 9884 }); 9885 9886 $(document).off('click.tapTarget').on('click.tapTarget', function (e) { 9887 closeTapTarget(); 9888 $(document).off('click.tapTarget'); 9889 }); 9890 9891 var throttledCalc = Materialize.throttle(function () { 9892 calculateTapTarget(); 9893 }, 200); 9894 $(window).off('resize.tapTarget').on('resize.tapTarget', throttledCalc); 9895 }, 0); 9896 }; 9897 9898 // Close 9899 var closeTapTarget = function () { 9900 if (!tapTargetWrapper.is('.open')) { 9901 return; 9902 } 9903 9904 tapTargetWrapper.removeClass('open'); 9905 tapTargetOriginEl.off('click.tapTarget'); 9906 $(document).off('click.tapTarget'); 9907 $(window).off('resize.tapTarget'); 9908 }; 9909 9910 // Pre calculate 9911 var calculateTapTarget = function () { 9912 // Element or parent is fixed position? 9913 var isFixed = origin.css('position') === 'fixed'; 9914 if (!isFixed) { 9915 var parents = origin.parents(); 9916 for (var i = 0; i < parents.length; i++) { 9917 isFixed = $(parents[i]).css('position') == 'fixed'; 9918 if (isFixed) { 9919 break; 9920 } 9921 } 9922 } 9923 9924 // Calculating origin 9925 var originWidth = origin.outerWidth(); 9926 var originHeight = origin.outerHeight(); 9927 var originTop = isFixed ? origin.offset().top - $(document).scrollTop() : origin.offset().top; 9928 var originLeft = isFixed ? origin.offset().left - $(document).scrollLeft() : origin.offset().left; 9929 9930 // Calculating screen 9931 var windowWidth = $(window).width(); 9932 var windowHeight = $(window).height(); 9933 var centerX = windowWidth / 2; 9934 var centerY = windowHeight / 2; 9935 var isLeft = originLeft <= centerX; 9936 var isRight = originLeft > centerX; 9937 var isTop = originTop <= centerY; 9938 var isBottom = originTop > centerY; 9939 var isCenterX = originLeft >= windowWidth * 0.25 && originLeft <= windowWidth * 0.75; 9940 var isCenterY = originTop >= windowHeight * 0.25 && originTop <= windowHeight * 0.75; 9941 9942 // Calculating tap target 9943 var tapTargetWidth = tapTargetEl.outerWidth(); 9944 var tapTargetHeight = tapTargetEl.outerHeight(); 9945 var tapTargetTop = originTop + originHeight / 2 - tapTargetHeight / 2; 9946 var tapTargetLeft = originLeft + originWidth / 2 - tapTargetWidth / 2; 9947 var tapTargetPosition = isFixed ? 'fixed' : 'absolute'; 9948 9949 // Calculating content 9950 var tapTargetTextWidth = isCenterX ? tapTargetWidth : tapTargetWidth / 2 + originWidth; 9951 var tapTargetTextHeight = tapTargetHeight / 2; 9952 var tapTargetTextTop = isTop ? tapTargetHeight / 2 : 0; 9953 var tapTargetTextBottom = 0; 9954 var tapTargetTextLeft = isLeft && !isCenterX ? tapTargetWidth / 2 - originWidth : 0; 9955 var tapTargetTextRight = 0; 9956 var tapTargetTextPadding = originWidth; 9957 var tapTargetTextAlign = isBottom ? 'bottom' : 'top'; 9958 9959 // Calculating wave 9960 var tapTargetWaveWidth = originWidth > originHeight ? originWidth * 2 : originWidth * 2; 9961 var tapTargetWaveHeight = tapTargetWaveWidth; 9962 var tapTargetWaveTop = tapTargetHeight / 2 - tapTargetWaveHeight / 2; 9963 var tapTargetWaveLeft = tapTargetWidth / 2 - tapTargetWaveWidth / 2; 9964 9965 // Setting tap target 9966 var tapTargetWrapperCssObj = {}; 9967 tapTargetWrapperCssObj.top = isTop ? tapTargetTop : ''; 9968 tapTargetWrapperCssObj.right = isRight ? windowWidth - tapTargetLeft - tapTargetWidth : ''; 9969 tapTargetWrapperCssObj.bottom = isBottom ? windowHeight - tapTargetTop - tapTargetHeight : ''; 9970 tapTargetWrapperCssObj.left = isLeft ? tapTargetLeft : ''; 9971 tapTargetWrapperCssObj.position = tapTargetPosition; 9972 tapTargetWrapper.css(tapTargetWrapperCssObj); 9973 9974 // Setting content 9975 tapTargetContentEl.css({
9976 width: tapTargetTextWidth, 9977 height: tapTargetTextHeight, 9978 top: tapTargetTextTop, 9979 right: tapTargetTextRight, 9980 bottom: tapTargetTextBottom, 9981 left: tapTargetTextLeft, 9982 padding: tapTargetTextPadding, 9983 verticalAlign: tapTargetTextAlign 9984 }); 9985 9986 // Setting wave 9987 tapTargetWave.css({ 9988 top: tapTargetWaveTop, 9989 left: tapTargetWaveLeft, 9990 width: tapTargetWaveWidth, 9991 height: tapTargetWaveHeight 9992 }); 9993 }; 9994 9995 if (options == 'open') { 9996 calculateTapTarget(); 9997 openTapTarget(); 9998 } 9999 10000 if (options == 'close') closeTapTarget(); 10001 }); 10002 }, 10003 open: function () {}, 10004 close: function () {} 10005 }; 10006 10007 $.fn.tapTarget = function (methodOrOptions) { 10008 if (methods[methodOrOptions] || typeof methodOrOptions === 'object') return methods.init.apply(this, arguments); 10009 10010 $.error('Method ' + methodOrOptions + ' does not exist on jQuery.tap-target'); 10011 }; 10012})(jQuery); 10013 10014 10015 10016
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.