vendor: 5,605 bytes, lines 1-164
1var _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; }; }(); 2 3function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 4 5// Check for jQuery. 6if (typeof jQuery === 'undefined') { 7 // Check if require is a defined function. 8 if (typeof require === 'function') { 9 jQuery = $ = require('jquery'); 10 // Else use the dollar sign alias. 11 } else { 12 jQuery = $; 13 } 14} 15; /* 16 * jQuery Easing v1.4.0 - http://gsgd.co.uk/sandbox/jquery/easing/ 17 * Open source under the BSD License. 18 * Copyright © 2008 George McGinley Smith 19 * All rights reserved. 20 * https://raw.github.com/gdsmith/jquery-easing/master/LICENSE 21 */ 22 23(function (factory) { 24 if (typeof define === "function" && define.amd) { 25 define(['jquery'], function ($) { 26 return factory($); 27 }); 28 } else if (typeof module === "object" && typeof module.exports === "object") { 29 exports = factory(require('jquery')); 30 } else { 31 factory(jQuery); 32 } 33})(function ($) { 34 35 // Preserve the original jQuery "swing" easing as "jswing" 36 $.easing['jswing'] = $.easing['swing']; 37 38 var pow = Math.pow, 39 sqrt = Math.sqrt, 40 sin = Math.sin, 41 cos = Math.cos, 42 PI = Math.PI, 43 c1 = 1.70158, 44 c2 = c1 * 1.525, 45 c3 = c1 + 1, 46 c4 = 2 * PI / 3, 47 c5 = 2 * PI / 4.5; 48 49 // x is the fraction of animation progress, in the range 0..1 50 function bounceOut(x) { 51 var n1 = 7.5625, 52 d1 = 2.75; 53 if (x < 1 / d1) { 54 return n1 * x * x; 55 } else if (x < 2 / d1) { 56 return n1 * (x -= 1.5 / d1) * x + .75; 57 } else if (x < 2.5 / d1) { 58 return n1 * (x -= 2.25 / d1) * x + .9375; 59 } else { 60 return n1 * (x -= 2.625 / d1) * x + .984375; 61 } 62 } 63 64 $.extend($.easing, { 65 def: 'easeOutQuad', 66 swing: function (x) { 67 return $.easing[$.easing.def](x); 68 }, 69 easeInQuad: function (x) { 70 return x * x; 71 }, 72 easeOutQuad: function (x) { 73 return 1 - (1 - x) * (1 - x); 74 }, 75 easeInOutQuad: function (x) { 76 return x < 0.5 ? 2 * x * x : 1 - pow(-2 * x + 2, 2) / 2; 77 }, 78 easeInCubic: function (x) { 79 return x * x * x; 80 }, 81 easeOutCubic: function (x) { 82 return 1 - pow(1 - x, 3); 83 }, 84 easeInOutCubic: function (x) { 85 return x < 0.5 ? 4 * x * x * x : 1 - pow(-2 * x + 2, 3) / 2; 86 }, 87 easeInQuart: function (x) { 88 return x * x * x * x; 89 }, 90 easeOutQuart: function (x) { 91 return 1 - pow(1 - x, 4); 92 }, 93 easeInOutQuart: function (x) { 94 return x < 0.5 ? 8 * x * x * x * x : 1 - pow(-2 * x + 2, 4) / 2; 95 }, 96 easeInQuint: function (x) { 97 return x * x * x * x * x; 98 }, 99 easeOutQuint: function (x) { 100 return 1 - pow(1 - x, 5); 101 }, 102 easeInOutQuint: function (x) { 103 return x < 0.5 ? 16 * x * x * x * x * x : 1 - pow(-2 * x + 2, 5) / 2; 104 }, 105 easeInSine: function (x) { 106 return 1 - cos(x * PI / 2); 107 }, 108 easeOutSine: function (x) { 109 return sin(x * PI / 2); 110 }, 111 easeInOutSine: function (x) { 112 return -(cos(PI * x) - 1) / 2; 113 }, 114 easeInExpo: function (x) { 115 return x === 0 ? 0 : pow(2, 10 * x - 10); 116 }, 117 easeOutExpo: function (x) { 118 return x === 1 ? 1 : 1 - pow(2, -10 * x); 119 }, 120 easeInOutExpo: function (x) { 121 return x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ? pow(2, 20 * x - 10) / 2 : (2 - pow(2, -20 * x + 10)) / 2; 122 }, 123 easeInCirc: function (x) { 124 return 1 - sqrt(1 - pow(x, 2)); 125 }, 126 easeOutCirc: function (x) { 127 return sqrt(1 - pow(x - 1, 2)); 128 }, 129 easeInOutCirc: function (x) { 130 return x < 0.5 ? (1 - sqrt(1 - pow(2 * x, 2))) / 2 : (sqrt(1 - pow(-2 * x + 2, 2)) + 1) / 2; 131 }, 132 easeInElastic: function (x) { 133 return x === 0 ? 0 : x === 1 ? 1 : -pow(2, 10 * x - 10) * sin((x * 10 - 10.75) * c4); 134 }, 135 easeOutElastic: function (x) { 136 return x === 0 ? 0 : x === 1 ? 1 : pow(2, -10 * x) * sin((x * 10 - 0.75) * c4) + 1; 137 }, 138 easeInOutElastic: function (x) { 139 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; 140 }, 141 easeInBack: function (x) { 142 return c3 * x * x * x - c1 * x * x; 143 }, 144 easeOutBack: function (x) { 145 return 1 + c3 * pow(x - 1, 3) + c1 * pow(x - 1, 2); 146 }, 147 easeInOutBack: function (x) { 148 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; 149 }, 150 easeInBounce: function (x) { 151 return 1 - bounceOut(1 - x); 152 }, 153 easeOutBounce: bounceOut, 154 easeInOutBounce: function (x) { 155 return x < 0.5 ? (1 - bounceOut(1 - 2 * x)) / 2 : (1 + bounceOut(2 * x - 1)) / 2; 156 } 157 }); 158});; // Custom Easing 159jQuery.extend(jQuery.easing, { 160 easeInOutMaterial: function (x, t, b, c, d) { 161 if ((t /= d / 2) < 1) return c / 2 * t * t + b; 162 return c / 4 * ((t -= 2) * t * t + 2) + b; 163 } 164});; /*! VelocityJS.org (1.2.3). (C) 2014 Julian Shapiro. MIT @license: en.wikipedia.org/wiki/MIT_License */
165/*! VelocityJS.org jQuery Shim (1.0.1). (C) 2014 The jQuery Foundation. MIT @license: en.wikipedia.org/wiki/MIT_License. */ 166/*! Note that this has been modified by Materialize to confirm that Velocity is not already being imported. */ 167jQuery.Velocity ? console.log("Velocity is already loaded. You may be needlessly importing Velocity again; note that Materialize includes Velocity.") : (!function (e) { 168 function t(e) { 169 var t = e.length, 170 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; 171 }if (!e.jQuery) { 172 var r = function (e, t) { 173 return new r.fn.init(e, t); 174 };r.isWindow = function (e) { 175 return null != e && e == e.window; 176 }, r.type = function (e) { 177 return null == e ? e + "" : "object" == typeof e || "function" == typeof e ? n[i.call(e)] || "object" : typeof e; 178 }, r.isArray = Array.isArray || function (e) { 179 return "array" === r.type(e); 180 }, r.isPlainObject = function (e) { 181 var t;if (!e || "object" !== r.type(e) || e.nodeType || r.isWindow(e)) return !1;try { 182 if (e.constructor && !o.call(e, "constructor") && !o.call(e.constructor.prototype, "isPrototypeOf")) return !1; 183 } catch (a) { 184 return !1; 185 }for (t in e) {}return void 0 === t || o.call(e, t); 186 }, r.each = function (e, r, a) { 187 var n, 188 o = 0, 189 i = e.length, 190 s = t(e);if (a) { 191 if (s) for (; i > o && (n = r.apply(e[o], a), n !== !1); o++) {} else for (o in e) { 192 if (n = r.apply(e[o], a), n === !1) break; 193 } 194 } else if (s) for (; i > o && (n = r.call(e[o], o, e[o]), n !== !1); o++) {} else for (o in e) { 195 if (n = r.call(e[o], o, e[o]), n === !1) break; 196 }return e; 197 }, r.data = function (e, t, n) { 198 if (void 0 === n) { 199 var o = e[r.expando], 200 i = o && a[o];if (void 0 === t) return i;if (i && t in i) return i[t]; 201 } else if (void 0 !== t) { 202 var o = e[r.expando] || (e[r.expando] = ++r.uuid);return a[o] = a[o] || {}, a[o][t] = n, n; 203 } 204 }, r.removeData = function (e, t) { 205 var n = e[r.expando], 206 o = n && a[n];o && r.each(t, function (e, t) { 207 delete o[t]; 208 }); 209 }, r.extend = function () { 210 var e, 211 t, 212 a, 213 n, 214 o, 215 i, 216 s = arguments[0] || {}, 217 l = 1, 218 u = arguments.length, 219 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++) { 220 if (null != (o = arguments[l])) for (n in o) { 221 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)); 222 } 223 }return s; 224 }, r.queue = function (e, a, n) { 225 function o(e, r) { 226 var a = r || [];return null != e && (t(Object(e)) ? !function (e, t) { 227 for (var r = +t.length, a = 0, n = e.length; r > a;) { 228 e[n++] = t[a++]; 229 }if (r !== r) for (; void 0 !== t[a];) { 230 e[n++] = t[a++]; 231 }return e.length = n, e; 232 }(a, "string" == typeof e ? [e] : e) : [].push.call(a, e)), a; 233 }if (e) { 234 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 || []; 235 } 236 }, r.dequeue = function (e, t) { 237 r.each(e.nodeType ? [e] : e, function (e, a) { 238 t = t || "fx";var n = r.queue(a, t), 239 o = n.shift();"inprogress" === o && (o = n.shift()), o && ("fx" === t && n.unshift("inprogress"), o.call(a, function () { 240 r.dequeue(a, t); 241 })); 242 }); 243 }, r.fn = r.prototype = { init: function (e) { 244 if (e.nodeType) return this[0] = e, this;throw new Error("Not a DOM node."); 245 }, offset: function () { 246 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) }; 247 }, position: function () { 248 function e() { 249 for (var e = this.offsetParent || document; e && "html" === !e.nodeType.toLowerCase && "static" === e.style.position;) { 250 e = e.offsetParent; 251 }return e || document; 252 }var t = this[0], 253 e = e.apply(t), 254 a = this.offset(), 255 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 }; 256 } };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++) { 257 n["[object " + s[l] + "]"] = s[l].toLowerCase(); 258 }r.fn.init.prototype = r.fn, e.Velocity = { Utilities: r }; 259 } 260}(window), function (e) { 261 "object" == typeof module && "object" == typeof module.exports ? module.exports = e() : "function" == typeof define && define.amd ? define(e) : e(); 262}(function () { 263 return function (e, t, r, a) { 264 function n(e) { 265 for (var t = -1, r = e ? e.length : 0, a = []; ++t < r;) { 266 var n = e[t];n && a.push(n); 267 }return a; 268 }function o(e) { 269 return m.isWrapped(e) ? e = [].slice.call(e) : m.isNode(e) && (e = [e]), e; 270 }function i(e) { 271 var t = f.data(e, "velocity");return null === t ? a : t; 272 }function s(e) { 273 return function (t) { 274 return Math.round(t * e) * (1 / e); 275 }; 276 }function l(e, r, a, n) { 277 function o(e, t) { 278 return 1 - 3 * t + 3 * e; 279 }function i(e, t) { 280 return 3 * t - 6 * e; 281 }function s(e) { 282 return 3 * e; 283 }function l(e, t, r) { 284 return ((o(t, r) * e + i(t, r)) * e + s(t)) * e; 285 }function u(e, t, r) { 286 return 3 * o(t, r) * e * e + 2 * i(t, r) * e + s(t); 287 }function c(t, r) { 288 for (var n = 0; m > n; ++n) { 289 var o = u(r, e, a);if (0 === o) return r;var i = l(r, e, a) - t;r -= i / o; 290 }return r; 291 }function p() { 292 for (var t = 0; b > t; ++t) { 293 w[t] = l(t * x, e, a); 294 } 295 }function f(t, r, n) { 296 var o, 297 i, 298 s = 0;do { 299 i = r + (n - r) / 2, o = l(i, e, a) - t, o > 0 ? n = i : r = i; 300 } while (Math.abs(o) >
vendor: 9,678 bytes, lines 300-435
300 h && ++s < v);return i; 301 }function d(t) { 302 for (var r = 0, n = 1, o = b - 1; n != o && w[n] <= t; ++n) { 303 r += x; 304 }--n;var i = (t - w[n]) / (w[n + 1] - w[n]), 305 s = r + i * x, 306 l = u(s, e, a);return l >= y ? c(t, s) : 0 == l ? s : f(t, r, r + x); 307 }function g() { 308 V = !0, (e != r || a != n) && p(); 309 }var m = 4, 310 y = .001, 311 h = 1e-7, 312 v = 10, 313 b = 11, 314 x = 1 / (b - 1), 315 S = "Float32Array" in t;if (4 !== arguments.length) return !1;for (var P = 0; 4 > P; ++P) { 316 if ("number" != typeof arguments[P] || isNaN(arguments[P]) || !isFinite(arguments[P])) return !1; 317 }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), 318 V = !1, 319 C = function (t) { 320 return V || g(), e === r && a === n ? t : 0 === t ? 0 : 1 === t ? 1 : l(d(t), r, n); 321 };C.getControlPoints = function () { 322 return [{ x: e, y: r }, { x: a, y: n }]; 323 };var T = "generateBezier(" + [e, r, a, n] + ")";return C.toString = function () { 324 return T; 325 }, C; 326 }function u(e, t) { 327 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; 328 }function c(e) { 329 if (e) { 330 var t = new Date().getTime(), 331 r = b.State.calls.length;r > 1e4 && (b.State.calls = n(b.State.calls));for (var o = 0; r > o; o++) { 332 if (b.State.calls[o]) { 333 var s = b.State.calls[o], 334 l = s[0], 335 u = s[2], 336 d = s[3], 337 g = !!d, 338 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++) { 339 var P = l[v], 340 V = P.element;if (i(V)) { 341 var C = !1;if (u.display !== a && null !== u.display && "none" !== u.display) { 342 if ("flex" === u.display) { 343 var T = ["-webkit-box", "-moz-box", "-ms-flexbox", "-webkit-flex"];f.each(T, function (e, t) { 344 S.setPropertyValue(V, "display", t); 345 }); 346 }S.setPropertyValue(V, "display", u.display); 347 }u.visibility !== a && "hidden" !== u.visibility && S.setPropertyValue(V, "visibility", u.visibility);for (var k in P) { 348 if ("element" !== k) { 349 var A, 350 F = P[k], 351 j = m.isString(F.easing) ? b.Easings[F.easing] : F.easing;if (1 === h) A = F.endValue;else { 352 var E = F.endValue - F.startValue;if (A = F.startValue + E * j(h, u, E), !g && A === F.currentValue) continue; 353 }if (F.currentValue = A, "tween" === k) y = A;else { 354 if (S.Hooks.registered[k]) { 355 var H = S.Hooks.getRoot(k), 356 N = i(V).rootPropertyValueCache[H];N && (F.rootPropertyValue = N); 357 }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); 358 } 359 } 360 }u.mobileHA && i(V).transformCache.translate3d === a && (i(V).transformCache.translate3d = "(0px, 0px, 0px)", C = !0), C && S.flushTransformCache(V); 361 } 362 }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); 363 } 364 } 365 }b.State.isTicking && w(c); 366 }function p(e, t) { 367 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++) { 368 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)) { 369 i(p).isAnimating = !1, i(p).rootPropertyValueCache = {};var d = !1;f.each(S.Lists.transforms3D, function (e, t) { 370 var r = /^scale/.test(t) ? 1 : 0, 371 n = i(p).transformCache[t];i(p).transformCache[t] !== a && new RegExp("^\\(" + r + "[^.]").test(n) && (d = !0, delete i(p).transformCache[t]); 372 }), o.mobileHA && (d = !0, delete i(p).transformCache.translate3d), d && S.flushTransformCache(p), S.Values.removeClass(p, "velocity-animating"); 373 }if (!t && o.complete && !o.loop && u === c - 1) try { 374 o.complete.call(n, n); 375 } catch (g) { 376 setTimeout(function () { 377 throw g; 378 }, 1); 379 }s && o.loop !== !0 && s(n), i(p) && o.loop === !0 && !t && (f.each(i(p).tweensContainer, function (e, t) { 380 /^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); 381 }), b(p, "reverse", { loop: !0, delay: o.delay })), o.queue !== !1 && f.dequeue(p, o.queue); 382 }b.State.calls[e] = !1;for (var m = 0, y = b.State.calls.length; y > m; m++) { 383 if (b.State.calls[m] !== !1) { 384 l = !0;break; 385 } 386 }l === !1 && (b.State.isTicking = !1, delete b.State.calls, b.State.calls = []); 387 }var f, 388 d = function () { 389 if (r.documentMode) return r.documentMode;for (var e = 7; e > 4; e--) { 390 var t = r.createElement("div");if (t.innerHTML = "<!--[if IE " + e + "]><span></span><![endif]-->", t.getElementsByTagName("span").length) return t = null, e; 391 }return a; 392 }(), 393 g = function () { 394 var e = 0;return t.webkitRequestAnimationFrame || t.mozRequestAnimationFrame || function (t) { 395 var r, 396 a = new Date().getTime();return r = Math.max(0, 16 - (a - e)), e = a + r, setTimeout(function () { 397 t(a + r); 398 }, r); 399 }; 400 }(), 401 m = { isString: function (e) { 402 return "string" == typeof e; 403 }, isArray: Array.isArray || function (e) { 404 return "[object Array]" === Object.prototype.toString.call(e); 405 }, isFunction: function (e) { 406 return "[object Function]" === Object.prototype.toString.call(e); 407 }, isNode: function (e) { 408 return e && e.nodeType; 409 }, isNodeList: function (e) { 410 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); 411 }, isWrapped: function (e) { 412 return e && (e.jquery || t.Zepto && t.Zepto.zepto.isZ(e)); 413 }, isSVG: function (e) { 414 return t.SVGElement && e instanceof t.SVGElement; 415 }, isEmptyObject: function (e) { 416 for (var t in e) { 417 return !1; 418 }return !0; 419 } }, 420 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, 421 v = "swing", 422 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) { 423 f.data(e, "velocity", { isSVG: m.isSVG(e), isAnimating: !1, computedStyle: null, tweensContainer: null, rootPropertyValueCache: {}, transformCache: {} }); 424 }, 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 () { 425 function e(e) { 426 return -e.tension * e.x - e.friction * e.v; 427 }function t(t, r, a) { 428 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) }; 429 }function r(r, a) { 430 var n = { dx: r.v, dv: e(r) }, 431 o = t(r, .5 * a, n), 432 i = t(r, .5 * a, o), 433 s = t(r, a, i), 434 l = 1 / 6 * (n.dx + 2 * (o.dx + i.dx) + s.dx), 435 u = 1 / 6 * (n.dv + 2 * (o.dv + i.dv) + s.dv);
435return r.x = r.x + l * a, r.v = r.v + u * a, r; 436 }return function a(e, t, n) { 437 var o, 438 i, 439 s, 440 l = { x: -1, v: 0, tension: null, friction: null }, 441 u = [0], 442 c = 0, 443 p = 1e-4, 444 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) { 445 return u[e * (u.length - 1) | 0]; 446 } : c; 447 }; 448 }();b.Easings = { linear: function (e) { 449 return e; 450 }, swing: function (e) { 451 return .5 - Math.cos(e * Math.PI) / 2; 452 }, spring: function (e) { 453 return 1 - Math.cos(4.5 * e * Math.PI) * Math.exp(6 * -e); 454 } }, 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) { 455 b.Easings[t[0]] = l.apply(null, t[1]); 456 });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 () { 457 for (var e = 0; e < S.Lists.colors.length; e++) { 458 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]; 459 }var r, a, n;if (d) for (r in S.Hooks.templates) { 460 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(" ")]); 461 }for (r in S.Hooks.templates) { 462 a = S.Hooks.templates[r], n = a[0].split(" ");for (var e in n) { 463 var i = r + n[e], 464 s = e;S.Hooks.registered[i] = [r, s]; 465 } 466 } 467 }, getRoot: function (e) { 468 var t = S.Hooks.registered[e];return t ? t[0] : e; 469 }, cleanRootPropertyValue: function (e, t) { 470 return S.RegEx.valueUnwrap.test(t) && (t = t.match(S.RegEx.valueUnwrap)[1]), S.Values.isCSSNullValue(t) && (t = S.Hooks.templates[e][1]), t; 471 }, extractValue: function (e, t) { 472 var r = S.Hooks.registered[e];if (r) { 473 var a = r[0], 474 n = r[1];return t = S.Hooks.cleanRootPropertyValue(a, t), t.toString().match(S.RegEx.valueSplit)[n]; 475 }return t; 476 }, injectValue: function (e, t, r) { 477 var a = S.Hooks.registered[e];if (a) { 478 var n, 479 o, 480 i = a[0], 481 s = a[1];return r = S.Hooks.cleanRootPropertyValue(i, r), n = r.toString().match(S.RegEx.valueSplit), n[s] = t, o = n.join(" "); 482 }return r; 483 } }, Normalizations: { registered: { clip: function (e, t, r) {
vendor: 23,754 bytes, lines 484-745
484 switch (e) {case "name": 485 return "clip";case "extract": 486 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": 487 return "rect(" + r + ")";} 488 }, blur: function (e, t, r) { 489 switch (e) {case "name": 490 return b.State.isFirefox ? "filter" : "-webkit-filter";case "extract": 491 var a = parseFloat(r);if (!a && 0 !== a) { 492 var n = r.toString().match(/blur\(([0-9]+[A-z]+)\)/i);a = n ? n[1] : 0; 493 }return a;case "inject": 494 return parseFloat(r) ? "blur(" + r + ")" : "none";} 495 }, opacity: function (e, t, r) { 496 if (8 >= d) switch (e) {case "name": 497 return "filter";case "extract": 498 var a = r.toString().match(/alpha\(opacity=(.*)\)/i);return r = a ? a[1] / 100 : 1;case "inject": 499 return t.style.zoom = 1, parseFloat(r) >= 1 ? "" : "alpha(opacity=" + parseInt(100 * parseFloat(r), 10) + ")";} else switch (e) {case "name": 500 return "opacity";case "extract": 501 return r;case "inject": 502 return r;} 503 } }, register: function () { 504 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++) { 505 !function () { 506 var t = S.Lists.transformsBase[e];S.Normalizations.registered[t] = function (e, r, n) { 507 switch (e) {case "name": 508 return "transform";case "extract": 509 return i(r) === a || i(r).transformCache[t] === a ? /^scale/i.test(t) ? 1 : 0 : i(r).transformCache[t].replace(/[()]/g, "");case "inject": 510 var o = !1;switch (t.substr(0, t.length - 1)) {case "translate": 511 o = !/(%|px|em|rem|vw|vh|\d)$/i.test(n);break;case "scal":case "scale": 512 b.State.isAndroid && i(r).transformCache[t] === a && 1 > n && (n = 1), o = !/(\d)$/i.test(n);break;case "skew": 513 o = !/(deg|\d)$/i.test(n);break;case "rotate": 514 o = !/(deg|\d)$/i.test(n);}return o || (i(r).transformCache[t] = "(" + n + ")"), i(r).transformCache[t];} 515 }; 516 }(); 517 }for (var e = 0; e < S.Lists.colors.length; e++) { 518 !function () { 519 var t = S.Lists.colors[e];S.Normalizations.registered[t] = function (e, r, n) { 520 switch (e) {case "name": 521 return t;case "extract": 522 var o;if (S.RegEx.wrappedValueAlreadyExtracted.test(n)) o = n;else { 523 var i, 524 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, " "); 525 }return 8 >= d || 3 !== o.split(" ").length || (o += " 1"), o;case "inject": 526 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, "") + ")";} 527 }; 528 }(); 529 } 530 } }, Names: { camelCase: function (e) { 531 return e.replace(/-(\w)/g, function (e, t) { 532 return t.toUpperCase(); 533 }); 534 }, SVGAttribute: function (e) { 535 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); 536 }, prefixCheck: function (e) { 537 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++) { 538 var n;if (n = 0 === r ? e : t[r] + e.replace(/^\w/, function (e) { 539 return e.toUpperCase(); 540 }), m.isString(b.State.prefixElement.style[n])) return b.State.prefixMatches[e] = n, [n, !0]; 541 }return [e, !1]; 542 } }, Values: { hexToRgb: function (e) { 543 var t, 544 r = /^#?([a-f\d])([a-f\d])([a-f\d])$/i, 545 a = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i;return e = e.replace(r, function (e, t, r, a) { 546 return t + t + r + r + a + a; 547 }), t = a.exec(e), t ? [parseInt(t[1], 16), parseInt(t[2], 16), parseInt(t[3], 16)] : [0, 0, 0]; 548 }, isCSSNullValue: function (e) { 549 return 0 == e || /^(none|auto|transparent|(rgba\(0, ?0, ?0, ?0\)))$/i.test(e); 550 }, getUnitType: function (e) { 551 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" 552 ); 553 }, getDisplayType: function (e) { 554 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" 555 ); 556 }, addClass: function (e, t) { 557 e.classList ? e.classList.add(t) : e.className += (e.className.length ? " " : "") + t; 558 }, removeClass: function (e, t) { 559 e.classList ? e.classList.remove(t) : e.className = e.className.toString().replace(new RegExp("(^|\\s)" + t.split(" ").join("|") + "(\\s|$)", "gi"), " "); 560 } }, getPropertyValue: function (e, r, n, o) { 561 function s(e, r) { 562 function n() { 563 u && S.setPropertyValue(e, "display", "none"); 564 }var l = 0;if (8 >= d) l = f.css(e, r);else { 565 var u = !1;if (/^(width|height)$/.test(r) && 0 === S.getPropertyValue(e, "display") && (u = !0, S.setPropertyValue(e, "display", S.Values.getDisplayType(e))), !o) { 566 if ("height" === r && "border-box" !== S.getPropertyValue(e, "boxSizing").toString().toLowerCase()) { 567 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; 568 }if ("width" === r && "border-box" !== S.getPropertyValue(e, "boxSizing").toString().toLowerCase()) { 569 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; 570 } 571 }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(); 572 }if ("auto" === l && /^(top|right|bottom|left)$/i.test(r)) { 573 var m = s(e, "position");("fixed" === m || "absolute" === m && /top|left/i.test(r)) && (l = f(e).position()[r] + "px"); 574 }return l; 575 }var l;if (S.Hooks.registered[r]) { 576 var u = r, 577 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); 578 } else if (S.Normalizations.registered[r]) { 579 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); 580 }if (!/^[\d-]/.test(l)) if (i(e) && i(e).isSVG && S.Names.SVGAttribute(r)) { 581 if (/^(height|width)$/i.test(r)) try { 582 l = e.getBBox()[r]; 583 } catch (m) { 584 l = 0; 585 } else l = e.getAttribute(r); 586 } 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; 587 }, setPropertyValue: function (e, r, a, n, o) { 588 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 { 589 if (S.Hooks.registered[r]) { 590 var l = r, 591 u = S.Hooks.getRoot(r);n = n || S.getPropertyValue(e, u), a = S.Hooks.injectValue(l, a, n), r = u; 592 }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 { 593 e.style[s] = a; 594 } catch (c) { 595 b.debug && console.log("Browser does not support [" + a + "] for [" + s + "]"); 596 } 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); 597 }return [s, a]; 598 }, flushTransformCache: function (e) { 599 function t(t) { 600 return parseFloat(S.getPropertyValue(e, t)); 601 }var r = "";if ((d || b.State.isAndroid && !b.State.isChrome) && i(e).isSVG) { 602 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) { 603 /^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]); 604 }); 605 } else { 606 var n, o;f.each(i(e).transformCache, function (t) { 607 return n = i(e).transformCache[t], "transformPerspective" === t ? (o = n, !0) : (9 === d && "rotateZ" === t && (t = "rotate"), void (r += t + n + " ")); 608 }), o && (r = "perspective" + o + " " + r); 609 }S.setPropertyValue(e, "transform", r); 610 } };S.Hooks.register(), S.Normalizations.register(), b.hook = function (e, t, r) { 611 var n = a;return e = o(e), f.each(e, function (e, o) { 612 if (i(o) === a && b.init(o), r === a) n === a && (n = b.CSS.getPropertyValue(o, t));else { 613 var s = b.CSS.setPropertyValue(o, t, r);"transform" === s[0] && b.CSS.flushTransformCache(o), n = s; 614 } 615 }), n; 616 };var P = function () { 617 function e() { 618 return s ? k.promise || null : l; 619 }function n() { 620 function e(e) { 621 function p(e, t) { 622 var r = a, 623 n = a, 624 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]; 625 }function d(e, t) { 626 var r, a;return a = (t || "0").toString().toLowerCase().replace(/[%A-z]+$/, function (e) { 627 return r = e, ""; 628 }), r || (r = S.Values.getUnitType(e)), [a, r]; 629 }function h() { 630 var e = { myParent: o.parentNode || r.body, position: S.getPropertyValue(o, "position"), fontSize: S.getPropertyValue(o, "fontSize") }, 631 a = e.position === L.lastPosition && e.myParent === L.lastParent, 632 n = e.fontSize === L.lastFontSize;L.lastParent = e.myParent, L.lastPosition = e.position, L.lastFontSize = e.fontSize;var s = 100, 633 l = {};if (n && a) l.emToPx = L.lastEmToPx, l.percentToPxWidth = L.lastPercentToPxWidth, l.percentToPxHeight = L.lastPercentToPxHeight;else { 634 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) { 635 b.CSS.setPropertyValue(u, t, "hidden"); 636 }), 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) { 637 b.CSS.setPropertyValue(u, t, s + "%"); 638 }), 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); 639 }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; 640 }if (s.begin && 0 === V) try { 641 s.begin.call(g, g); 642 } catch (x) { 643 setTimeout(function () { 644 throw x; 645 }, 1); 646 }if ("scroll" === A) { 647 var P, 648 C, 649 T, 650 F = /^x$/i.test(s.axis) ? "Left" : "Top", 651 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); 652 } else if ("reverse" === A) { 653 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) { 654 if ("element" !== H) { 655 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); 656 } 657 }l = E; 658 } else if ("start" === A) { 659 var E;i(o).tweensContainer && i(o).isAnimating === !0 && (E = i(o).tweensContainer), f.each(y, function (e, t) { 660 if (RegExp("^" + S.Lists.colors.join("$|^") + "$").test(e)) { 661 var r = p(t, !0), 662 n = r[0], 663 o = r[1], 664 i = r[2];if (S.RegEx.isHex.test(n)) { 665 for (var s = ["Red", "Green", "Blue"], l = S.Values.hexToRgb(n), u = i ? S.Values.hexToRgb(i) : a, c = 0; c < s.length; c++) { 666 var f = [l[c]];o && f.push(o), u !== a && f.push(u[c]), y[e + s[c]] = f; 667 }delete y[e]; 668 } 669 } 670 });for (var z in y) { 671 var O = p(y[z]), 672 q = O[0], 673 $ = O[1], 674 M = O[2];z = S.Names.camelCase(z);var I = S.Hooks.getRoot(z), 675 B = !1;if (i(o).isSVG || "tween" === I || S.Names.prefixCheck(I)[1] !== !1 || S.Normalizations.registered[I] !== a) { 676 (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, 677 G, 678 Y, 679 D = !1;if (W = d(z, M), M = W[0], Y = W[1], W = d(z, q), q = W[0].replace(/^([+-\/*])=/, function (e, t) { 680 return D = t, ""; 681 }), 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 { 682 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 "%": 683 M *= "x" === Q ? n.percentToPxWidth : n.percentToPxHeight;break;case "px": 684 break;default: 685 M *= n[Y + "ToPx"];}switch (G) {case "%": 686 M *= 1 / ("x" === Q ? n.percentToPxWidth : n.percentToPxHeight);break;case "px": 687 break;default: 688 M *= 1 / n[G + "ToPx"];} 689 }switch (D) {case "+": 690 q = M + q;break;case "-": 691 q = M - q;break;case "*": 692 q = M * q;break;case "/": 693 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); 694 } else b.debug && console.log("Skipping [" + I + "] due to a lack of browser support."); 695 }l.element = o; 696 }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++); 697 }var n, 698 o = this, 699 s = f.extend({}, b.defaults, v), 700 l = {};switch (i(o) === a && b.init(o), parseFloat(s.delay) && s.queue !== !1 && f.queue(o, s.queue, function (e) { 701 b.velocityQueueEntryFlag = !0, i(o).delayTimer = { setTimeout: setTimeout(e, parseFloat(s.delay)), next: e }; 702 }), s.duration.toString().toLowerCase()) {case "fast": 703 s.duration = 200;break;case "normal": 704 s.duration = h;break;case "slow": 705 s.duration = 600;break;default: 706 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) { 707 return r === !0 ? (k.promise && k.resolver(g), !0) : (b.velocityQueueEntryFlag = !0, void e(t)); 708 }), "" !== s.queue && "fx" !== s.queue || "inprogress" === f.queue(o)[0] || f.dequeue(o); 709 }var s, 710 l, 711 d, 712 g, 713 y, 714 v, 715 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)) { 716 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, 717 V = 0;if (!/^(stop|finish)$/i.test(y) && !f.isPlainObject(v)) { 718 var C = d + 1;v = {};for (var T = C; T < arguments.length; T++) { 719 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]; 720 } 721 }var k = { promise: null, resolver: null, rejecter: null };s && b.Promise && (k.promise = new b.Promise(function (e, t) { 722 k.resolver = e, k.rejecter = t; 723 }));var A;switch (y) {case "scroll": 724 A = "scroll";break;case "reverse": 725 A = "reverse";break;case "finish":case "stop": 726 f.each(g, function (e, t) { 727 i(t) && i(t).delayTimer && (clearTimeout(i(t).delayTimer.setTimeout), i(t).delayTimer.next && i(t).delayTimer.next(), delete i(t).delayTimer); 728 });var F = [];return f.each(b.State.calls, function (e, t) { 729 t && f.each(t[1], function (r, n) { 730 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) { 731 a === n && ((v === !0 || m.isString(v)) && (f.each(f.queue(a, m.isString(v) ? v : ""), function (e, t) { 732 m.isFunction(t) && t(null, !0); 733 }), f.queue(a, m.isString(v) ? v : "", [])), "stop" === y ? (i(a) && i(a).tweensContainer && o !== !1 && f.each(i(a).tweensContainer, function (e, t) { 734 t.endValue = t.currentValue; 735 }), F.push(e)) : "finish" === y && (t[2].duration = 1)); 736 }) : !0; 737 }); 738 }), "stop" === y && (f.each(F, function (e, t) { 739 p(t, !0); 740 }), k.promise && k.resolver(g)), e();default: 741 if (!f.isPlainObject(y) || m.isEmptyObject(y)) { 742 if (m.isString(y) && b.Redirects[y]) { 743 var j = f.extend({}, v), 744 E = j.duration, 745 H = j.delay || 0;return j.backwards === !0 && (g = f.extend(!0, [], g).reverse()), f.each(g, function (e, t) {
746 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); 747 }), e(); 748 }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(); 749 }A = "start";}var L = { lastParent: null, lastPosition: null, lastFontSize: null, lastPercentToPxWidth: null, lastPercentToPxHeight: null, lastEmToPx: null, remToPx: null, vwToPx: null, vhToPx: null }, 750 R = [];f.each(g, function (e, t) { 751 m.isNode(t) && n.call(t); 752 });var z, 753 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++) { 754 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); 755 }return e(); 756 } 757 };b = f.extend(P, b), b.animate = P;var w = t.requestAnimationFrame || g;return b.State.isMobile || r.hidden === a || r.addEventListener("visibilitychange", function () { 758 r.hidden ? (w = function (e) { 759 return setTimeout(function () { 760 e(!0); 761 }, 16); 762 }, c()) : w = t.requestAnimationFrame || g; 763 }), e.Velocity = b, e !== t && (e.fn.velocity = P, e.fn.velocity.defaults = b.defaults), f.each(["Down", "Up"], function (e, t) { 764 b.Redirects["slide" + t] = function (e, r, n, o, i, s) { 765 var l = f.extend({}, r), 766 u = l.begin, 767 c = l.complete, 768 p = { height: "", marginTop: "", marginBottom: "", paddingTop: "", paddingBottom: "" }, 769 d = {};l.display === a && (l.display = "Down" === t ? "inline" === b.CSS.Values.getDisplayType(e) ? "inline-block" : "block" : "none"), l.begin = function () { 770 u && u.call(i, i);for (var r in p) { 771 d[r] = e.style[r];var a = b.CSS.getPropertyValue(e, r);p[r] = "Down" === t ? [a, 0] : [0, a]; 772 }d.overflow = e.style.overflow, e.style.overflow = "hidden"; 773 }, l.complete = function () { 774 for (var t in d) { 775 e.style[t] = d[t]; 776 }c && c.call(i, i), s && s.resolver(i); 777 }, b(e, p, l); 778 }; 779 }), f.each(["In", "Out"], function (e, t) { 780 b.Redirects["fade" + t] = function (e, r, n, o, i, s) { 781 var l = f.extend({}, r), 782 u = { opacity: "In" === t ? 1 : 0 }, 783 c = l.complete;l.complete = n !== o - 1 ? l.begin = null : function () { 784 c && c.call(i, i), s && s.resolver(i); 785 }, l.display === a && (l.display = "In" === t ? "auto" : "none"), b(this, u, l); 786 }; 787 }), b; 788 }(window.jQuery || window.Zepto || window, window, document); 789})); 790;!function (a, b, c, d) { 791 "use strict"; 792 function k(a, b, c) { 793 return setTimeout(q(a, c), b); 794 }function l(a, b, c) { 795 return Array.isArray(a) ? (m(a, c[b], c), !0) : !1; 796 }function m(a, b, c) { 797 var e;if (a) if (a.forEach) a.forEach(b, c);else if (a.length !== d) for (e = 0; e < a.length;) { 798 b.call(c, a[e], e, a), e++; 799 } else for (e in a) { 800 a.hasOwnProperty(e) && b.call(c, a[e], e, a); 801 } 802 }function n(a, b, c) { 803 for (var e = Object.keys(b), f = 0; f < e.length;) { 804 (!c || c && a[e[f]] === d) && (a[e[f]] = b[e[f]]), f++; 805 }return a; 806 }function o(a, b) { 807 return n(a, b, !0); 808 }function p(a, b, c) { 809 var e, 810 d = b.prototype;e = a.prototype = Object.create(d), e.constructor = a, e._super = d, c && n(e, c); 811 }function q(a, b) { 812 return function () { 813 return a.apply(b, arguments); 814 }; 815 }function r(a, b) { 816 return typeof a == g ? a.apply(b ? b[0] || d : d, b) : a; 817 }function s(a, b) { 818 return a === d ? b : a; 819 }function t(a, b, c) { 820 m(x(b), function (b) { 821 a.addEventListener(b, c, !1); 822 }); 823 }function u(a, b, c) { 824 m(x(b), function (b) { 825 a.removeEventListener(b, c, !1); 826 }); 827 }function v(a, b) { 828 for (; a;) { 829 if (a == b) return !0;a = a.parentNode; 830 }return !1; 831 }function w(a, b) { 832 return a.indexOf(b) > -1; 833 }function x(a) { 834 return a.trim().split(/\s+/g); 835 }function y(a, b, c) { 836 if (a.indexOf && !c) return a.indexOf(b);for (var d = 0; d < a.length;) { 837 if (c && a[d][c] == b || !c && a[d] === b) return d;d++; 838 }return -1; 839 }function z(a) {
840 return Array.prototype.slice.call(a, 0); 841 }function A(a, b, c) { 842 for (var d = [], e = [], f = 0; f < a.length;) { 843 var g = b ? a[f][b] : a[f];y(e, g) < 0 && d.push(a[f]), e[f] = g, f++; 844 }return c && (d = b ? d.sort(function (a, c) { 845 return a[b] > c[b]; 846 }) : d.sort()), d; 847 }function B(a, b) { 848 for (var c, f, g = b[0].toUpperCase() + b.slice(1), h = 0; h < e.length;) { 849 if (c = e[h], f = c ? c + g : b, f in a) return f;h++; 850 }return d; 851 }function D() { 852 return C++; 853 }function E(a) { 854 var b = a.ownerDocument;return b.defaultView || b.parentWindow; 855 }function ab(a, b) { 856 var c = this;this.manager = a, this.callback = b, this.element = a.element, this.target = a.options.inputTarget, this.domHandler = function (b) { 857 r(a.options.enable, [a]) && c.handler(b); 858 }, this.init(); 859 }function bb(a) { 860 var b, 861 c = a.options.inputClass;return b = c ? c : H ? wb : I ? Eb : G ? Gb : rb, new b(a, cb); 862 }function cb(a, b, c) { 863 var d = c.pointers.length, 864 e = c.changedPointers.length, 865 f = b & O && 0 === d - e, 866 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; 867 }function db(a, b) { 868 var c = a.session, 869 d = b.pointers, 870 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, 871 g = c.firstMultiple, 872 h = g ? g.center : f.center, 873 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; 874 }function eb(a, b) { 875 var c = b.center, 876 d = a.offsetDelta || {}, 877 e = a.prevDelta || {}, 878 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); 879 }function fb(a, b) { 880 var f, 881 g, 882 h, 883 j, 884 c = a.lastInterval || b, 885 e = b.timeStamp - c.timeStamp;if (b.eventType != R && (e > N || c.velocity === d)) { 886 var k = c.deltaX - b.deltaX, 887 l = c.deltaY - b.deltaY, 888 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; 889 } 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; 890 }function gb(a) { 891 for (var b = [], c = 0; c < a.pointers.length;) { 892 b[c] = { clientX: h(a.pointers[c].clientX), clientY: h(a.pointers[c].clientY) }, c++; 893 }return { timeStamp: j(), pointers: b, center: hb(b), deltaX: a.deltaX, deltaY: a.deltaY }; 894 }function hb(a) { 895 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;) { 896 c += a[e].clientX, d += a[e].clientY, e++; 897 }return { x: h(c / b), y: h(d / b) }; 898 }function ib(a, b, c) { 899 return { x: b / a || 0, y: c / a || 0 }; 900 }function jb(a, b) { 901 return a === b ? S : i(a) >= i(b) ? a > 0 ? T : U : b > 0 ? V : W; 902 }function kb(a, b, c) { 903 c || (c = $);var d = b[c[0]] - a[c[0]], 904 e = b[c[1]] - a[c[1]];return Math.sqrt(d * d + e * e); 905 }function lb(a, b, c) { 906 c || (c = $);var d = b[c[0]] - a[c[0]], 907 e = b[c[1]] - a[c[1]];return 180 * Math.atan2(e, d) / Math.PI; 908 }function mb(a, b) { 909 return lb(b[1], b[0], _) - lb(a[1], a[0], _); 910 }function nb(a, b) { 911 return kb(b[0], b[1], _) / kb(a[0], a[1], _); 912 }function rb() { 913 this.evEl = pb, this.evWin = qb, this.allow = !0, this.pressed = !1, ab.apply(this, arguments); 914 }function wb() { 915 this.evEl = ub, this.evWin = vb, ab.apply(this, arguments), this.store = this.manager.session.pointerEvents = []; 916 }function Ab() { 917 this.evTarget = yb, this.evWin = zb, this.started = !1, ab.apply(this, arguments); 918 }function Bb(a, b) { 919 var c = z(a.touches), 920 d = z(a.changedTouches);return b & (Q | R) && (c = A(c.concat(d), "identifier", !0)), [c, d]; 921 }function Eb() { 922 this.evTarget = Db, this.targetIds = {}, ab.apply(this, arguments); 923 }function Fb(a, b) { 924 var c = z(a.touches), 925 d = this.targetIds;if (b & (O | P) && 1 === c.length) return d[c[0].identifier] = !0, [c, c];var e, 926 f, 927 g = z(a.changedTouches), 928 h = [], 929 i = this.target;if (f = c.filter(function (a) { 930 return v(a.target, i); 931 }), b === O) for (e = 0; e < f.length;) { 932 d[f[e].identifier] = !0, e++; 933 }for (e = 0; e < g.length;) { 934 d[g[e].identifier] && h.push(g[e]), b & (Q | R) && delete d[g[e].identifier], e++; 935 }return h.length ? [A(f.concat(h), "identifier", !0), h] : void 0; 936 }function Gb() { 937 ab.apply(this, arguments);var a = q(this.handler, this);this.touch = new Eb(this.manager, a), this.mouse = new rb(this.manager, a); 938 }function Pb(a, b) { 939 this.manager = a, this.set(b); 940 }function Qb(a) { 941 if (w(a, Mb)) return Mb;var b = w(a, Nb), 942 c = w(a, Ob);return b && c ? Nb + " " + Ob : b || c ? b ? Nb : Ob : w(a, Lb) ? Lb : Kb; 943 }function Yb(a) { 944 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 = []; 945 }function Zb(a) { 946 return a & Wb ? "cancel" : a & Ub ? "end" : a & Tb ? "move" : a & Sb ? "start" : ""; 947 }
vendor: 4,471 bytes, lines 947-1031
947function $b(a) { 948 return a == W ? "down" : a == V ? "up" : a == T ? "left" : a == U ? "right" : ""; 949 }function _b(a, b) { 950 var c = b.manager;return c ? c.get(a) : a; 951 }function ac() { 952 Yb.apply(this, arguments); 953 }function bc() { 954 ac.apply(this, arguments), this.pX = null, this.pY = null; 955 }function cc() { 956 ac.apply(this, arguments); 957 }function dc() { 958 Yb.apply(this, arguments), this._timer = null, this._input = null; 959 }function ec() { 960 ac.apply(this, arguments); 961 }function fc() { 962 ac.apply(this, arguments); 963 }function gc() { 964 Yb.apply(this, arguments), this.pTime = !1, this.pCenter = !1, this._timer = null, this._input = null, this.count = 0; 965 }function hc(a, b) { 966 return b = b || {}, b.recognizers = s(b.recognizers, hc.defaults.preset), new kc(a, b); 967 }function kc(a, b) { 968 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) { 969 var b = this.add(new a[0](a[1]));a[2] && b.recognizeWith(a[2]), a[3] && b.requireFailure(a[3]); 970 }, this); 971 }function lc(a, b) { 972 var c = a.element;m(a.options.cssProps, function (a, d) { 973 c.style[B(c.style, d)] = b ? a : ""; 974 }); 975 }function mc(a, c) { 976 var d = b.createEvent("Event");d.initEvent(a, !0, !0), d.gesture = c, c.target.dispatchEvent(d); 977 }var e = ["", "webkit", "moz", "MS", "ms", "o"], 978 f = b.createElement("div"), 979 g = "function", 980 h = Math.round, 981 i = Math.abs, 982 j = Date.now, 983 C = 1, 984 F = /mobile|tablet|ip(ad|hone|od)|android/i, 985 G = "ontouchstart" in a, 986 H = B(a, "PointerEvent") !== d, 987 I = G && F.test(navigator.userAgent), 988 J = "touch", 989 K = "pen", 990 L = "mouse", 991 M = "kinect", 992 N = 25, 993 O = 1, 994 P = 2, 995 Q = 4, 996 R = 8, 997 S = 1, 998 T = 2, 999 U = 4, 1000 V = 8, 1001 W = 16, 1002 X = T | U, 1003 Y = V | W, 1004 Z = X | Y, 1005 $ = ["x", "y"], 1006 _ = ["clientX", "clientY"];ab.prototype = { handler: function () {}, init: function () { 1007 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); 1008 }, destroy: function () { 1009 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); 1010 } };var ob = { mousedown: O, mousemove: P, mouseup: Q }, 1011 pb = "mousedown", 1012 qb = "mousemove mouseup";p(rb, ab, { handler: function (a) { 1013 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 })); 1014 } });var sb = { pointerdown: O, pointermove: P, pointerup: Q, pointercancel: R, pointerout: R }, 1015 tb = { 2: J, 3: K, 4: L, 5: M }, 1016 ub = "pointerdown", 1017 vb = "pointermove pointerup pointercancel";a.MSPointerEvent && (ub = "MSPointerDown", vb = "MSPointerMove MSPointerUp MSPointerCancel"), p(wb, ab, { handler: function (a) { 1018 var b = this.store, 1019 c = !1, 1020 d = a.type.toLowerCase().replace("ms", ""), 1021 e = sb[d], 1022 f = tb[a.pointerType] || a.pointerType, 1023 g = f == J, 1024 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)); 1025 } });var xb = { touchstart: O, touchmove: P, touchend: Q, touchcancel: R }, 1026 yb = "touchstart", 1027 zb = "touchstart touchmove touchend touchcancel";p(Ab, ab, { handler: function (a) { 1028 var b = xb[a.type];if (b === O && (this.started = !0), this.started) { 1029 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 }); 1030 } 1031 } });var Cb = { touchstart: O, touchmove: P, touchend: Q, touchcancel: R },
1032 Db = "touchstart touchmove touchend touchcancel";p(Eb, ab, { handler: function (a) { 1033 var b = Cb[a.type], 1034 c = Fb.call(this, a, b);c && this.callback(this.manager, b, { pointers: c[0], changedPointers: c[1], pointerType: J, srcEvent: a }); 1035 } }), p(Gb, ab, { handler: function (a, b, c) { 1036 var d = c.pointerType == J, 1037 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); 1038 }, destroy: function () { 1039 this.touch.destroy(), this.mouse.destroy(); 1040 } });var Hb = B(f.style, "touchAction"), 1041 Ib = Hb !== d, 1042 Jb = "compute", 1043 Kb = "auto", 1044 Lb = "manipulation", 1045 Mb = "none", 1046 Nb = "pan-x", 1047 Ob = "pan-y";Pb.prototype = { set: function (a) { 1048 a == Jb && (a = this.compute()), Ib && (this.manager.element.style[Hb] = a), this.actions = a.toLowerCase().trim(); 1049 }, update: function () { 1050 this.set(this.manager.options.touchAction); 1051 }, compute: function () { 1052 var a = [];return m(this.manager.recognizers, function (b) { 1053 r(b.options.enable, [b]) && (a = a.concat(b.getTouchAction())); 1054 }), Qb(a.join(" ")); 1055 }, preventDefaults: function (a) { 1056 if (!Ib) { 1057 var b = a.srcEvent, 1058 c = a.offsetDirection;if (this.manager.session.prevented) return b.preventDefault(), void 0;var d = this.actions, 1059 e = w(d, Mb), 1060 f = w(d, Ob), 1061 g = w(d, Nb);return e || f && c & X || g && c & Y ? this.preventSrc(b) : void 0; 1062 } 1063 }, preventSrc: function (a) { 1064 this.manager.session.prevented = !0, a.preventDefault(); 1065 } };var Rb = 1, 1066 Sb = 2, 1067 Tb = 4, 1068 Ub = 8, 1069 Vb = Ub, 1070 Wb = 16, 1071 Xb = 32;Yb.prototype = { defaults: {}, set: function (a) { 1072 return n(this.options, a), this.manager && this.manager.touchAction.update(), this; 1073 }, recognizeWith: function (a) { 1074 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; 1075 }, dropRecognizeWith: function (a) { 1076 return l(a, "dropRecognizeWith", this) ? this : (a = _b(a, this), delete this.simultaneous[a.id], this); 1077 }, requireFailure: function (a) { 1078 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; 1079 }, dropRequireFailure: function (a) { 1080 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; 1081 }, hasRequireFailures: function () { 1082 return this.requireFail.length > 0; 1083 }, canRecognizeWith: function (a) { 1084 return !!this.simultaneous[a.id]; 1085 }, emit: function (a) { 1086 function d(d) { 1087 b.manager.emit(b.options.event + (d ? Zb(c) : ""), a); 1088 }var b = this, 1089 c = this.state;Ub > c && d(!0), d(), c >= Ub && d(!0); 1090 }, tryEmit: function (a) { 1091 return this.canEmit() ? this.emit(a) : (this.state = Xb, void 0); 1092 }, canEmit: function () { 1093 for (var a = 0; a < this.requireFail.length;) { 1094 if (!(this.requireFail[a].state & (Xb | Rb))) return !1;a++; 1095 }return !0; 1096 }, recognize: function (a) { 1097 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); 1098 }, process: function () {}, getTouchAction: function () {}, reset: function () {} }, p(ac, Yb, { defaults: { pointers: 1 }, attrTest: function (a) { 1099 var b = this.options.pointers;return 0 === b || a.pointers.length === b; 1100 }, process: function (a) { 1101 var b = this.state, 1102 c = a.eventType, 1103 d = b & (Sb | Tb), 1104 e = this.attrTest(a);return d && (c & R || !e) ? b | Wb : d || e ? c & Q ? b | Ub : b & Sb ? b | Tb : Sb : Xb; 1105 } }), p(bc, ac, { defaults: { event: "pan", threshold: 10, pointers: 1, direction: Z }, getTouchAction: function () { 1106 var a = this.options.direction, 1107 b = [];return a & X && b.push(Ob), a & Y && b.push(Nb), b; 1108 }, directionTest: function (a) { 1109 var b = this.options, 1110 c = !0, 1111 d = a.distance, 1112 e = a.direction, 1113 f = a.deltaX,
vendor: 4,333 bytes, lines 1114-1171
1114 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; 1115 }, attrTest: function (a) { 1116 return ac.prototype.attrTest.call(this, a) && (this.state & Sb || !(this.state & Sb) && this.directionTest(a)); 1117 }, emit: function (a) { 1118 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); 1119 } }), p(cc, ac, { defaults: { event: "pinch", threshold: 0, pointers: 2 }, getTouchAction: function () { 1120 return [Mb]; 1121 }, attrTest: function (a) { 1122 return this._super.attrTest.call(this, a) && (Math.abs(a.scale - 1) > this.options.threshold || this.state & Sb); 1123 }, emit: function (a) { 1124 if (this._super.emit.call(this, a), 1 !== a.scale) { 1125 var b = a.scale < 1 ? "in" : "out";this.manager.emit(this.options.event + b, a); 1126 } 1127 } }), p(dc, Yb, { defaults: { event: "press", pointers: 1, time: 500, threshold: 5 }, getTouchAction: function () { 1128 return [Kb]; 1129 }, process: function (a) { 1130 var b = this.options, 1131 c = a.pointers.length === b.pointers, 1132 d = a.distance < b.threshold, 1133 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 () { 1134 this.state = Vb, this.tryEmit(); 1135 }, b.time, this);else if (a.eventType & Q) return Vb;return Xb; 1136 }, reset: function () { 1137 clearTimeout(this._timer); 1138 }, emit: function (a) { 1139 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))); 1140 } }), p(ec, ac, { defaults: { event: "rotate", threshold: 0, pointers: 2 }, getTouchAction: function () { 1141 return [Mb]; 1142 }, attrTest: function (a) { 1143 return this._super.attrTest.call(this, a) && (Math.abs(a.rotation) > this.options.threshold || this.state & Sb); 1144 } }), p(fc, ac, { defaults: { event: "swipe", threshold: 10, velocity: .65, direction: X | Y, pointers: 1 }, getTouchAction: function () { 1145 return bc.prototype.getTouchAction.call(this); 1146 }, attrTest: function (a) { 1147 var c, 1148 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; 1149 }, emit: function (a) { 1150 var b = $b(a.direction);b && this.manager.emit(this.options.event + b, a), this.manager.emit(this.options.event, a); 1151 } }), p(gc, Yb, { defaults: { event: "tap", pointers: 1, taps: 1, interval: 300, time: 250, threshold: 2, posThreshold: 10 }, getTouchAction: function () { 1152 return [Lb]; 1153 }, process: function (a) { 1154 var b = this.options, 1155 c = a.pointers.length === b.pointers, 1156 d = a.distance < b.threshold, 1157 e = a.deltaTime < b.time;if (this.reset(), a.eventType & O && 0 === this.count) return this.failTimeout();if (d && e && c) { 1158 if (a.eventType != Q) return this.failTimeout();var f = this.pTime ? a.timeStamp - this.pTime < b.interval : !0, 1159 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 () { 1160 this.state = Vb, this.tryEmit(); 1161 }, b.interval, this), Sb) : Vb; 1162 }return Xb; 1163 }, failTimeout: function () { 1164 return this._timer = k(function () { 1165 this.state = Xb; 1166 }, this.options.interval, this), Xb; 1167 }, reset: function () { 1168 clearTimeout(this._timer); 1169 }, emit: function () { 1170 this.state == Vb && (this._input.tapCount = this.count, this.manager.emit(this.options.event, this._input)); 1171 } }), hc.VERSION = "2.0.4", hc.defaults = { domEvents: !1, touchAction: Jb, enable: !0, inputTarget: null, inputClass: null, preset
1171: [[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, 1172 jc = 2;kc.prototype = { set: function (a) { 1173 return n(this.options, a), a.touchAction && this.touchAction.update(), a.inputTarget && (this.input.destroy(), this.input.target = a.inputTarget, this.input.init()), this; 1174 }, stop: function (a) { 1175 this.session.stopped = a ? jc : ic; 1176 }, recognize: function (a) { 1177 var b = this.session;if (!b.stopped) { 1178 this.touchAction.preventDefaults(a);var c, 1179 d = this.recognizers, 1180 e = b.curRecognizer;(!e || e && e.state & Vb) && (e = b.curRecognizer = null);for (var f = 0; f < d.length;) { 1181 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++; 1182 } 1183 } 1184 }, get: function (a) { 1185 if (a instanceof Yb) return a;for (var b = this.recognizers, c = 0; c < b.length; c++) { 1186 if (b[c].options.event == a) return b[c]; 1187 }return null; 1188 }, add: function (a) { 1189 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; 1190 }, remove: function (a) { 1191 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; 1192 }, on: function (a, b) { 1193 var c = this.handlers;return m(x(a), function (a) { 1194 c[a] = c[a] || [], c[a].push(b); 1195 }), this; 1196 }, off: function (a, b) { 1197 var c = this.handlers;return m(x(a), function (a) { 1198 b ? c[a].splice(y(c[a], b), 1) : delete c[a]; 1199 }), this; 1200 }, emit: function (a, b) { 1201 this.options.domEvents && mc(a, b);var c = this.handlers[a] && this.handlers[a].slice();if (c && c.length) { 1202 b.type = a, b.preventDefault = function () { 1203 b.srcEvent.preventDefault(); 1204 };for (var d = 0; d < c.length;) { 1205 c[d](b), d++; 1206 } 1207 } 1208 }, destroy: function () { 1209 this.element && lc(this, !1), this.handlers = {}, this.session = {}, this.input.destroy(), this.element = null; 1210 } }, 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 () { 1211 return hc; 1212 }) : "undefined" != typeof module && module.exports ? module.exports = hc : a[c] = hc; 1213}(window, document, "Hammer");;(function (factory) { 1214 if (typeof define === 'function' && define.amd) { 1215 define(['jquery', 'hammerjs'], factory); 1216 } else if (typeof exports === 'object') { 1217 factory(require('jquery'), require('hammerjs')); 1218 } else { 1219 factory(jQuery, Hammer); 1220 } 1221})(function ($, Hammer) { 1222 function hammerify(el, options) { 1223 var $el = $(el); 1224 if (!$el.data("hammer")) { 1225 $el.data("hammer", new Hammer($el[0], options)); 1226 } 1227 } 1228 1229 $.fn.hammer = function (options) { 1230 return this.each(function () { 1231 hammerify(this, options); 1232 }); 1233 }; 1234 1235 // extend the emit method to also trigger jQuery events 1236 Hammer.Manager.prototype.emit = function (originalEmit) { 1237 return function (type, data) { 1238 originalEmit.call(this, type, data); 1239 $(this.element).trigger({ 1240 type: type, 1241 gesture: data 1242 }); 1243 }; 1244 }(Hammer.Manager.prototype.emit); 1245}); 1246; // Required for Meteor package, the use of window prevents export by Meteor 1247(function (window) { 1248 if (window.Package) { 1249 Materialize = {}; 1250 } else { 1251 window.Materialize = {}; 1252 } 1253})(window); 1254 1255if (typeof exports !== 'undefined' && !exports.nodeType) { 1256 if (typeof module !== 'undefined' && !module.nodeType && module.exports) { 1257 exports = module.exports = Materialize; 1258 } 1259 exports.default = Materialize; 1260} 1261 1262/* 1263 * raf.js 1264 * https://github.com/ngryman/raf.js 1265 * 1266 * original requestAnimationFrame polyfill by Erik Möller 1267 * inspired from paul_irish gist and post 1268 * 1269 * Copyright (c) 2013 ngryman 1270 * Licensed under the MIT license. 1271 */ 1272(function (window) { 1273 var lastTime = 0, 1274 vendors = ['webkit', 'moz'], 1275 requestAnimationFrame = window.requestAnimationFrame, 1276 cancelAnimationFrame = window.cancelAnimationFrame,
1277 i = vendors.length; 1278 1279 // try to un-prefix existing raf 1280 while (--i >= 0 && !requestAnimationFrame) { 1281 requestAnimationFrame = window[vendors[i] + 'RequestAnimationFrame']; 1282 cancelAnimationFrame = window[vendors[i] + 'CancelRequestAnimationFrame']; 1283 } 1284 1285 // polyfill with setTimeout fallback 1286 // heavily inspired from @darius gist mod: https://gist.github.com/paulirish/1579671#comment-837945 1287 if (!requestAnimationFrame || !cancelAnimationFrame) { 1288 requestAnimationFrame = function (callback) { 1289 var now = +Date.now(), 1290 nextTime = Math.max(lastTime + 16, now); 1291 return setTimeout(function () { 1292 callback(lastTime = nextTime); 1293 }, nextTime - now); 1294 }; 1295 1296 cancelAnimationFrame = clearTimeout; 1297 } 1298 1299 // export to window 1300 window.requestAnimationFrame = requestAnimationFrame; 1301 window.cancelAnimationFrame = cancelAnimationFrame; 1302})(window); 1303 1304/** 1305 * Generate approximated selector string for a jQuery object 1306 * @param {jQuery} obj jQuery object to be parsed 1307 * @returns {string} 1308 */ 1309Materialize.objectSelectorString = function (obj) { 1310 var tagStr = obj.prop('tagName') || ''; 1311 var idStr = obj.attr('id') || ''; 1312 var classStr = obj.attr('class') || ''; 1313 return (tagStr + idStr + classStr).replace(/\s/g, ''); 1314}; 1315 1316// Unique Random ID 1317Materialize.guid = function () { 1318 function s4() { 1319 return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1); 1320 } 1321 return function () { 1322 return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4(); 1323 }; 1324}(); 1325 1326/** 1327 * Escapes hash from special characters 1328 * @param {string} hash String returned from this.hash 1329 * @returns {string} 1330 */ 1331Materialize.escapeHash = function (hash) { 1332 return hash.replace(/(:|\.|\[|\]|,|=)/g, "\\$1"); 1333}; 1334 1335Materialize.elementOrParentIsFixed = function (element) { 1336 var $element = $(element); 1337 var $checkElements = $element.add($element.parents()); 1338 var isFixed = false; 1339 $checkElements.each(function () { 1340 if ($(this).css("position") === "fixed") { 1341 isFixed = true; 1342 return false; 1343 } 1344 }); 1345 return isFixed; 1346}; 1347 1348/** 1349 * Get time in ms 1350 * @license https://raw.github.com/jashkenas/underscore/master/LICENSE 1351 * @type {function} 1352 * @return {number} 1353 */ 1354var getTime = Date.now || function () { 1355 return new Date().getTime(); 1356}; 1357 1358/** 1359 * Returns a function, that, when invoked, will only be triggered at most once 1360 * during a given window of time. Normally, the throttled function will run 1361 * as much as it can, without ever going more than once per `wait` duration; 1362 * but if you'd like to disable the execution on the leading edge, pass 1363 * `{leading: false}`. To disable execution on the trailing edge, ditto. 1364 * @license https://raw.github.com/jashkenas/underscore/master/LICENSE 1365 * @param {function} func 1366 * @param {number} wait 1367 * @param {Object=} options 1368 * @returns {Function} 1369 */ 1370Materialize.throttle = function (func, wait, options) { 1371 var context, args, result; 1372 var timeout = null; 1373 var previous = 0; 1374 options || (options = {}); 1375 var later = function () { 1376 previous = options.leading === false ? 0 : getTime(); 1377 timeout = null; 1378 result = func.apply(context, args); 1379 context = args = null; 1380 }; 1381 return function () { 1382 var now = getTime(); 1383 if (!previous && options.leading === false) previous = now; 1384 var remaining = wait - (now - previous); 1385 context = this; 1386 args = arguments; 1387 if (remaining <= 0) { 1388 clearTimeout(timeout); 1389 timeout = null; 1390 previous = now; 1391 result = func.apply(context, args); 1392 context = args = null; 1393 } else if (!timeout && options.trailing !== false) { 1394 timeout = setTimeout(later, remaining); 1395 } 1396 return result; 1397 }; 1398}; 1399 1400// Velocity has conflicts when loaded with jQuery, this will check for it 1401// First, check if in noConflict mode 1402var Vel; 1403if (jQuery) { 1404 Vel = jQuery.Velocity; 1405} else if ($) { 1406 Vel = $.Velocity; 1407} else { 1408 Vel = Velocity; 1409} 1410 1411if (Vel) { 1412 Materialize.Vel = Vel; 1413} else { 1414 Materialize.Vel = Velocity; 1415} 1416;(function ($) { 1417 $.fn.collapsible = function (options, methodParam) { 1418 var defaults = { 1419 accordion: undefined, 1420 onOpen: undefined, 1421 onClose: undefined 1422 }; 1423 1424 var methodName = options; 1425 options = $.extend(defaults, options); 1426 1427 return this.each(function () { 1428 1429 var $this = $(this); 1430 1431 var $panel_headers = $(this).find('> li > .collapsible-header'); 1432
1433 var collapsible_type = $this.data("collapsible"); 1434 1435 /**************** 1436 Helper Functions 1437 ****************/ 1438 1439 // Accordion Open 1440 function accordionOpen(object) { 1441 $panel_headers = $this.find('> li > .collapsible-header'); 1442 if (object.hasClass('active')) { 1443 object.parent().addClass('active'); 1444 } else { 1445 object.parent().removeClass('active'); 1446 } 1447 if (object.parent().hasClass('active')) { 1448 object.siblings('.collapsible-body').stop(true, false).slideDown({ duration: 350, easing: "easeOutQuart", queue: false, complete: function () { 1449 $(this).css('height', ''); 1450 } }); 1451 } else { 1452 object.siblings('.collapsible-body').stop(true, false).slideUp({ duration: 350, easing: "easeOutQuart", queue: false, complete: function () { 1453 $(this).css('height', ''); 1454 } }); 1455 } 1456 1457 $panel_headers.not(object).removeClass('active').parent().removeClass('active'); 1458 1459 // Close previously open accordion elements. 1460 $panel_headers.not(object).parent().children('.collapsible-body').stop(true, false).each(function () { 1461 if ($(this).is(':visible')) { 1462 $(this).slideUp({ 1463 duration: 350, 1464 easing: "easeOutQuart", 1465 queue: false, 1466 complete: function () { 1467 $(this).css('height', ''); 1468 execCallbacks($(this).siblings('.collapsible-header')); 1469 } 1470 }); 1471 } 1472 }); 1473 } 1474 1475 // Expandable Open 1476 function expandableOpen(object) { 1477 if (object.hasClass('active')) { 1478 object.parent().addClass('active'); 1479 } else { 1480 object.parent().removeClass('active'); 1481 } 1482 if (object.parent().hasClass('active')) { 1483 object.siblings('.collapsible-body').stop(true, false).slideDown({ duration: 350, easing: "easeOutQuart", queue: false, complete: function () { 1484 $(this).css('height', ''); 1485 } }); 1486 } else { 1487 object.siblings('.collapsible-body').stop(true, false).slideUp({ duration: 350, easing: "easeOutQuart", queue: false, complete: function () { 1488 $(this).css('height', ''); 1489 } }); 1490 } 1491 } 1492 1493 // Open collapsible. object: .collapsible-header 1494 function collapsibleOpen(object, noToggle) { 1495 if (!noToggle) { 1496 object.toggleClass('active'); 1497 } 1498 1499 if (options.accordion || collapsible_type === "accordion" || collapsible_type === undefined) { 1500 // Handle Accordion 1501 accordionOpen(object); 1502 } else { 1503 // Handle Expandables 1504 expandableOpen(object); 1505 } 1506 1507 execCallbacks(object); 1508 } 1509 1510 // Handle callbacks 1511 function execCallbacks(object) { 1512 if (object.hasClass('active')) { 1513 if (typeof options.onOpen === "function") { 1514 options.onOpen.call(this, object.parent()); 1515 } 1516 } else { 1517 if (typeof options.onClose === "function") { 1518 options.onClose.call(this, object.parent()); 1519 } 1520 } 1521 } 1522 1523 /** 1524 * Check if object is children of panel header 1525 * @param {Object} object Jquery object 1526 * @return {Boolean} true if it is children 1527 */ 1528 function isChildrenOfPanelHeader(object) { 1529 1530 var panelHeader = getPanelHeader(object); 1531 1532 return panelHeader.length > 0; 1533 } 1534 1535 /** 1536 * Get panel header from a children element 1537 * @param {Object} object Jquery object 1538 * @return {Object} panel header object 1539 */ 1540 function getPanelHeader(object) { 1541 1542 return object.closest('li > .collapsible-header'); 1543 } 1544 1545 // Turn off any existing event handlers 1546 function removeEventHandlers() { 1547 $this.off('click.collapse', '> li > .collapsible-header'); 1548 } 1549 1550 /***** End Helper Functions *****/ 1551 1552 // Methods 1553 if (methodName === 'destroy') { 1554 removeEventHandlers(); 1555 return; 1556 } else if (methodParam >= 0 && methodParam < $panel_headers.length) { 1557 var $curr_header = $panel_headers.eq(methodParam); 1558 if ($curr_header.length && (methodName === 'open' || methodName === 'close' && $curr_header.hasClass('active'))) { 1559 collapsibleOpen($curr_header); 1560 } 1561 return; 1562 } 1563 1564 removeEventHandlers(); 1565 1566 // Add click handler to only direct collapsible header children 1567 $this.on('click.collapse', '> li > .collapsible-header', function (e) { 1568 var element = $(e.target); 1569 1570 if (isChildrenOfPanelHeader(element)) { 1571 element = getPanelHeader(element); 1572 } 1573 1574 collapsibleOpen(element); 1575 }); 1576 1577 // Open first active 1578 if (options.accordion || collapsible_type === "accordion" || collapsible_type === undefined) { 1579 // Handle Accordion 1580 collapsibleOpen($panel_headers.filter('.active').first(), true); 1581 } else { 1582 // Handle Expandables 1583 $panel_headers.filter('.active').each(function () { 1584 collapsibleOpen($(this), true); 1585 }); 1586 } 1587 }); 1588 }; 1589 1590 $(document).ready(function () { 1591 $('.collapsible').collapsible(); 1592 }); 1593})(jQuery);;(function ($) { 1594 1595 // Add posibility to scroll to selected option 1596 // usefull for select for example 1597 $.fn.scrollTo = function (elem) { 1598 $(this).scrollTop($(this).scrollTop() - $(this).offset().top + $(elem).offset().top); 1599 return this; 1600 }; 1601 1602 $.fn.dropdown = function (options) { 1603 1604 var defaults = { 1605 inDuration: 300, 1606 outDuration: 225, 1607 constrainWidth: true, // Constrains width of dropdown to the activator
1608 hover: false, 1609 gutter: 0, // Spacing from edge 1610 belowOrigin: false, 1611 alignment: 'left', 1612 stopPropagation: false 1613 }; 1614 1615 // Open dropdown. 1616 if (options === "open") { 1617 this.each(function () { 1618 $(this).trigger('open'); 1619 }); 1620 return false; 1621 } 1622 1623 // Close dropdown. 1624 if (options === "close") { 1625 this.each(function () { 1626 $(this).trigger('close'); 1627 }); 1628 return false; 1629 } 1630 1631 this.each(function () { 1632 var origin = $(this); 1633 var curr_options = $.extend({}, defaults, options); 1634 var isFocused = false; 1635 1636 // Dropdown menu 1637 var activates = $("#" + origin.attr('data-activates')); 1638 1639 function updateOptions() { 1640 if (origin.data('induration') !== undefined) curr_options.inDuration = origin.data('induration'); 1641 if (origin.data('outduration') !== undefined) curr_options.outDuration = origin.data('outduration'); 1642 if (origin.data('constrainwidth') !== undefined) curr_options.constrainWidth = origin.data('constrainwidth'); 1643 if (origin.data('hover') !== undefined) curr_options.hover = origin.data('hover'); 1644 if (origin.data('gutter') !== undefined) curr_options.gutter = origin.data('gutter'); 1645 if (origin.data('beloworigin') !== undefined) curr_options.belowOrigin = origin.data('beloworigin'); 1646 if (origin.data('alignment') !== undefined) curr_options.alignment = origin.data('alignment'); 1647 if (origin.data('stoppropagation') !== undefined) curr_options.stopPropagation = origin.data('stoppropagation'); 1648 } 1649 1650 updateOptions(); 1651 1652 // Attach dropdown to its activator 1653 origin.after(activates); 1654 1655 /* 1656 Helper function to position and resize dropdown. 1657 Used in hover and click handler. 1658 */ 1659 function placeDropdown(eventType) { 1660 // Check for simultaneous focus and click events. 1661 if (eventType === 'focus') { 1662 isFocused = true; 1663 } 1664 1665 // Check html data attributes 1666 updateOptions(); 1667 1668 // Set Dropdown state 1669 activates.addClass('active'); 1670 origin.addClass('active'); 1671 1672 var originWidth = origin[0].getBoundingClientRect().width; 1673 1674 // Constrain width 1675 if (curr_options.constrainWidth === true) { 1676 activates.css('width', originWidth); 1677 } else { 1678 activates.css('white-space', 'nowrap'); 1679 } 1680 1681 // Offscreen detection 1682 var windowHeight = window.innerHeight; 1683 var originHeight = origin.innerHeight(); 1684 var offsetLeft = origin.offset().left; 1685 var offsetTop = origin.offset().top - $(window).scrollTop(); 1686 var currAlignment = curr_options.alignment; 1687 var gutterSpacing = 0; 1688 var leftPosition = 0; 1689 1690 // Below Origin 1691 var verticalOffset = 0; 1692 if (curr_options.belowOrigin === true) { 1693 verticalOffset = originHeight; 1694 } 1695 1696 // Check for scrolling positioned container. 1697 var scrollYOffset = 0; 1698 var scrollXOffset = 0; 1699 var wrapper = origin.parent(); 1700 if (!wrapper.is('body')) { 1701 if (wrapper[0].scrollHeight > wrapper[0].clientHeight) { 1702 scrollYOffset = wrapper[0].scrollTop; 1703 } 1704 if (wrapper[0].scrollWidth > wrapper[0].clientWidth) { 1705 scrollXOffset = wrapper[0].scrollLeft; 1706 } 1707 } 1708 1709 if (offsetLeft + activates.innerWidth() > $(window).width()) { 1710 // Dropdown goes past screen on right, force right alignment 1711 currAlignment = 'right'; 1712 } else if (offsetLeft - activates.innerWidth() + origin.innerWidth() < 0) { 1713 // Dropdown goes past screen on left, force left alignment 1714 currAlignment = 'left'; 1715 } 1716 // Vertical bottom offscreen detection 1717 if (offsetTop + activates.innerHeight() > windowHeight) { 1718 // If going upwards still goes offscreen, just crop height of dropdown. 1719 if (offsetTop + originHeight - activates.innerHeight() < 0) { 1720 var adjustedHeight = windowHeight - offsetTop - verticalOffset; 1721 activates.css('max-height', adjustedHeight); 1722 } else { 1723 // Flow upwards. 1724 if (!verticalOffset) { 1725 verticalOffset += originHeight; 1726 } 1727 verticalOffset -= activates.innerHeight(); 1728 } 1729 } 1730 1731 // Handle edge alignment 1732 if (currAlignment === 'left') { 1733 gutterSpacing = curr_options.gutter; 1734 leftPosition = origin.position().left + gutterSpacing; 1735 } else if (currAlignment === 'right') { 1736 // Material icons fix 1737 activates.stop(true, true).css({ 1738 opacity: 0, 1739 left: 0 1740 }); 1741 1742 var offsetRight = origin.position().left + originWidth - activates.width(); 1743 gutterSpacing = -curr_options.gutter; 1744 leftPosition = offsetRight + gutterSpacing; 1745 } 1746 1747 // Position dropdown 1748 activates.css({ 1749 position: 'absolute', 1750 top: origin.position().top + verticalOffset + scrollYOffset, 1751 left: leftPosition + scrollXOffset 1752 }); 1753 1754 // Show dropdown 1755 activates.slideDown({ 1756 queue: false, 1757 duration: curr_options.inDuration, 1758 easing: 'easeOutCubic', 1759 complete: function () { 1760 $(this).css('height', ''); 1761 } 1762 }).animate({ opacity: 1 }, { queue: false, duration: curr_options.inDuration, easing: 'easeOutSine' }); 1763 1764 // Add click close handler to document 1765 setTimeout(function () { 1766 $(document).on('click.' + activates.attr('id'), function (e) { 1767 hideDropdown(); 1768 $(document).off('click.' + activates.attr('id')); 1769 }); 1770 }, 0); 1771 } 1772 1773 function hideDropdown() { 1774 // Check for simultaneous focus and click events. 1775 isFocused = false;
1776 activates.fadeOut(curr_options.outDuration); 1777 activates.removeClass('active'); 1778 origin.removeClass('active'); 1779 $(document).off('click.' + activates.attr('id')); 1780 setTimeout(function () { 1781 activates.css('max-height', ''); 1782 }, curr_options.outDuration); 1783 } 1784 1785 // Hover 1786 if (curr_options.hover) { 1787 var open = false; 1788 origin.off('click.' + origin.attr('id')); 1789 // Hover handler to show dropdown 1790 origin.on('mouseenter', function (e) { 1791 // Mouse over 1792 if (open === false) { 1793 placeDropdown(); 1794 open = true; 1795 } 1796 }); 1797 origin.on('mouseleave', function (e) { 1798 // If hover on origin then to something other than dropdown content, then close 1799 var toEl = e.toElement || e.relatedTarget; // added browser compatibility for target element 1800 if (!$(toEl).closest('.dropdown-content').is(activates)) { 1801 activates.stop(true, true); 1802 hideDropdown(); 1803 open = false; 1804 } 1805 }); 1806 1807 activates.on('mouseleave', function (e) { 1808 // Mouse out 1809 var toEl = e.toElement || e.relatedTarget; 1810 if (!$(toEl).closest('.dropdown-button').is(origin)) { 1811 activates.stop(true, true); 1812 hideDropdown(); 1813 open = false; 1814 } 1815 }); 1816 1817 // Click 1818 } else { 1819 // Click handler to show dropdown 1820 origin.off('click.' + origin.attr('id')); 1821 origin.on('click.' + origin.attr('id'), function (e) { 1822 if (!isFocused) { 1823 if (origin[0] == e.currentTarget && !origin.hasClass('active') && $(e.target).closest('.dropdown-content').length === 0) { 1824 e.preventDefault(); // Prevents button click from moving window 1825 if (curr_options.stopPropagation) { 1826 e.stopPropagation(); 1827 } 1828 placeDropdown('click'); 1829 } 1830 // If origin is clicked and menu is open, close menu 1831 else if (origin.hasClass('active')) { 1832 hideDropdown(); 1833 $(document).off('click.' + activates.attr('id')); 1834 } 1835 } 1836 }); 1837 } // End else 1838 1839 // Listen to open and close event - useful for select component 1840 origin.on('open', function (e, eventType) { 1841 placeDropdown(eventType); 1842 }); 1843 origin.on('close', hideDropdown); 1844 }); 1845 }; // End dropdown plugin 1846 1847 $(document).ready(function () { 1848 $('.dropdown-button').dropdown(); 1849 }); 1850})(jQuery); 1851;(function ($, Vel) { 1852 'use strict'; 1853 1854 var _defaults = { 1855 opacity: 0.5, 1856 inDuration: 250, 1857 outDuration: 250, 1858 ready: undefined, 1859 complete: undefined, 1860 dismissible: true, 1861 startingTop: '4%', 1862 endingTop: '10%' 1863 }; 1864 1865 /** 1866 * @class 1867 * 1868 */ 1869 1870 var Modal = function () { 1871 /** 1872 * Construct Modal instance and set up overlay 1873 * @constructor 1874 * @param {jQuery} $el 1875 * @param {Object} options 1876 */ 1877 function Modal($el, options) { 1878 _classCallCheck(this, Modal); 1879 1880 // If exists, destroy and reinitialize 1881 if (!!$el[0].M_Modal) { 1882 $el[0].M_Modal.destroy(); 1883 } 1884 1885 /** 1886 * The jQuery element 1887 * @type {jQuery} 1888 */ 1889 this.$el = $el; 1890 1891 /** 1892 * Options for the modal 1893 * @member Modal#options 1894 * @prop {Number} [opacity=0.5] - Opacity of the modal overlay 1895 * @prop {Number} [inDuration=250] - Length in ms of enter transition 1896 * @prop {Number} [outDuration=250] - Length in ms of exit transition 1897 * @prop {Function} ready - Callback function called when modal is finished entering 1898 * @prop {Function} complete - Callback function called when modal is finished exiting 1899 * @prop {Boolean} [dismissible=true] - Allow modal to be dismissed by keyboard or overlay click 1900 * @prop {String} [startingTop='4%'] - startingTop 1901 * @prop {String} [endingTop='10%'] - endingTop 1902 */ 1903 this.options = $.extend({}, Modal.defaults, options); 1904 1905 /** 1906 * Describes open/close state of modal 1907 * @type {Boolean} 1908 */ 1909 this.isOpen = false;
1910 1911 this.$el[0].M_Modal = this; 1912 this.id = $el.attr('id'); 1913 this.openingTrigger = undefined; 1914 this.$overlay = $('<div class="modal-overlay"></div>'); 1915 1916 Modal._increment++; 1917 Modal._count++; 1918 this.$overlay[0].style.zIndex = 1000 + Modal._increment * 2; 1919 this.$el[0].style.zIndex = 1000 + Modal._increment * 2 + 1; 1920 this.setupEventHandlers(); 1921 } 1922 1923 _createClass(Modal, [{ 1924 key: 'getInstance', 1925 1926 1927 /** 1928 * Get Instance 1929 */ 1930 value: function getInstance() { 1931 return this; 1932 } 1933 1934 /** 1935 * Teardown component 1936 */ 1937 1938 }, { 1939 key: 'destroy', 1940 value: function destroy() { 1941 this.removeEventHandlers(); 1942 this.$el[0].removeAttribute('style'); 1943 if (!!this.$overlay[0].parentNode) { 1944 this.$overlay[0].parentNode.removeChild(this.$overlay[0]); 1945 } 1946 this.$el[0].M_Modal = undefined; 1947 Modal._count--; 1948 } 1949 1950 /** 1951 * Setup Event Handlers 1952 */ 1953 1954 }, { 1955 key: 'setupEventHandlers', 1956 value: function setupEventHandlers() { 1957 this.handleOverlayClickBound = this.handleOverlayClick.bind(this); 1958 this.handleModalCloseClickBound = this.handleModalCloseClick.bind(this); 1959 1960 if (Modal._count === 1) { 1961 document.body.addEventListener('click', this.handleTriggerClick); 1962 } 1963 this.$overlay[0].addEventListener('click', this.handleOverlayClickBound); 1964 this.$el[0].addEventListener('click', this.handleModalCloseClickBound); 1965 } 1966 1967 /** 1968 * Remove Event Handlers 1969 */ 1970 1971 }, { 1972 key: 'removeEventHandlers', 1973 value: function removeEventHandlers() { 1974 if (Modal._count === 0) { 1975 document.body.removeEventListener('click', this.handleTriggerClick); 1976 } 1977 this.$overlay[0].removeEventListener('click', this.handleOverlayClickBound); 1978 this.$el[0].removeEventListener('click', this.handleModalCloseClickBound); 1979 } 1980 1981 /** 1982 * Handle Trigger Click 1983 * @param {Event} e 1984 */ 1985 1986 }, { 1987 key: 'handleTriggerClick', 1988 value: function handleTriggerClick(e) { 1989 var $trigger = $(e.target).closest('.modal-trigger'); 1990 if (e.target && $trigger.length) { 1991 var modalId = $trigger[0].getAttribute('href'); 1992 if (modalId) { 1993 modalId = modalId.slice(1); 1994 } else { 1995 modalId = $trigger[0].getAttribute('data-target'); 1996 } 1997 var modalInstance = document.getElementById(modalId).M_Modal; 1998 if (modalInstance) { 1999 modalInstance.open($trigger); 2000 } 2001 e.preventDefault(); 2002 } 2003 } 2004 2005 /** 2006 * Handle Overlay Click 2007 */ 2008 2009 }, { 2010 key: 'handleOverlayClick', 2011 value: function handleOverlayClick() { 2012 if (this.options.dismissible) { 2013 this.close(); 2014 } 2015 } 2016 2017 /** 2018 * Handle Modal Close Click 2019 * @param {Event} e 2020 */ 2021 2022 }, { 2023 key: 'handleModalCloseClick', 2024 value: function handleModalCloseClick(e) { 2025 var $closeTrigger = $(e.target).closest('.modal-close'); 2026 if (e.target && $closeTrigger.length) { 2027 this.close(); 2028 } 2029 } 2030 2031 /** 2032 * Handle Keydown 2033 * @param {Event} e 2034 */ 2035 2036 }, { 2037 key: 'handleKeydown', 2038 value: function handleKeydown(e) { 2039 // ESC key 2040 if (e.keyCode === 27 && this.options.dismissible) { 2041 this.close(); 2042 } 2043 } 2044 2045 /** 2046 * Animate in modal 2047 */ 2048 2049 }, { 2050 key: 'animateIn', 2051 value: function animateIn() { 2052 var _this = this; 2053 2054 // Set initial styles 2055 $.extend(this.$el[0].style, { 2056 display: 'block', 2057 opacity: 0 2058 }); 2059 $.extend(this.$overlay[0].style, { 2060 display: 'block', 2061 opacity: 0 2062 }); 2063 2064 // Animate overlay 2065 Vel(this.$overlay[0], { opacity: this.options.opacity }, { duration: this.options.inDuration, queue: false, ease: 'easeOutCubic' }); 2066 2067 // Define modal animation options 2068 var enterVelocityOptions = { 2069 duration: this.options.inDuration, 2070 queue: false, 2071 ease: 'easeOutCubic', 2072 // Handle modal ready callback 2073 complete: function () { 2074 if (typeof _this.options.ready === 'function') { 2075 _this.options.ready.call(_this, _this.$el, _this.openingTrigger); 2076 } 2077 } 2078 }; 2079 2080 // Bottom sheet animation 2081 if (this.$el[0].classList.contains('bottom-sheet')) { 2082 Vel(this.$el[0], { bottom: 0, opacity: 1 }, enterVelocityOptions); 2083 2084 // Normal modal animation 2085 } else { 2086 Vel.hook(this.$el[0], 'scaleX', 0.7); 2087 this.$el[0].style.top = this.options.startingTop; 2088 Vel(this.$el[0], { top: this.options.endingTop, opacity: 1, scaleX: 1 }, enterVelocityOptions); 2089 } 2090 } 2091 2092 /** 2093 * Animate out modal 2094 */ 2095 2096 }, {
2097 key: 'animateOut', 2098 value: function animateOut() { 2099 var _this2 = this; 2100 2101 // Animate overlay 2102 Vel(this.$overlay[0], { opacity: 0 }, { duration: this.options.outDuration, queue: false, ease: 'easeOutQuart' }); 2103 2104 // Define modal animation options 2105 var exitVelocityOptions = { 2106 duration: this.options.outDuration, 2107 queue: false, 2108 ease: 'easeOutCubic', 2109 // Handle modal ready callback 2110 complete: function () { 2111 _this2.$el[0].style.display = 'none'; 2112 // Call complete callback 2113 if (typeof _this2.options.complete === 'function') { 2114 _this2.options.complete.call(_this2, _this2.$el); 2115 } 2116 _this2.$overlay[0].parentNode.removeChild(_this2.$overlay[0]); 2117 } 2118 }; 2119 2120 // Bottom sheet animation 2121 if (this.$el[0].classList.contains('bottom-sheet')) { 2122 Vel(this.$el[0], { bottom: '-100%', opacity: 0 }, exitVelocityOptions); 2123 2124 // Normal modal animation 2125 } else { 2126 Vel(this.$el[0], { top: this.options.startingTop, opacity: 0, scaleX: 0.7 }, exitVelocityOptions); 2127 } 2128 } 2129 2130 /** 2131 * Open Modal 2132 * @param {jQuery} [$trigger] 2133 */ 2134 2135 }, { 2136 key: 'open', 2137 value: function open($trigger) { 2138 if (this.isOpen) { 2139 return; 2140 } 2141 2142 this.isOpen = true; 2143 var body = document.body; 2144 body.style.overflow = 'hidden'; 2145 this.$el[0].classList.add('open'); 2146 body.appendChild(this.$overlay[0]); 2147 2148 // Set opening trigger, undefined indicates modal was opened by javascript 2149 this.openingTrigger = !!$trigger ? $trigger : undefined; 2150 2151 if (this.options.dismissible) { 2152 this.handleKeydownBound = this.handleKeydown.bind(this); 2153 document.addEventListener('keydown', this.handleKeydownBound); 2154 } 2155 2156 this.animateIn(); 2157 2158 return this; 2159 } 2160 2161 /** 2162 * Close Modal 2163 */ 2164 2165 }, { 2166 key: 'close', 2167 value: function close() { 2168 if (!this.isOpen) { 2169 return; 2170 } 2171 2172 this.isOpen = false; 2173 this.$el[0].classList.remove('open'); 2174 document.body.style.overflow = ''; 2175 2176 if (this.options.dismissible) { 2177 document.removeEventListener('keydown', this.handleKeydownBound); 2178 } 2179 2180 this.animateOut(); 2181 2182 return this; 2183 } 2184 }], [{ 2185 key: 'init', 2186 value: function init($els, options) { 2187 var arr = []; 2188 $els.each(function () { 2189 arr.push(new Modal($(this), options)); 2190 }); 2191 return arr; 2192 } 2193 }, { 2194 key: 'defaults', 2195 get: function () { 2196 return _defaults; 2197 } 2198 }]); 2199 2200 return Modal; 2201 }(); 2202 2203 /** 2204 * @static 2205 * @memberof Modal 2206 */ 2207 2208 2209 Modal._increment = 0; 2210 2211 /** 2212 * @static 2213 * @memberof Modal 2214 */ 2215 Modal._count = 0; 2216 2217 Materialize.Modal = Modal; 2218 2219 $.fn.modal = function (methodOrOptions) { 2220 // Call plugin method if valid method name is passed in 2221 if (Modal.prototype[methodOrOptions]) { 2222 // Getter methods 2223 if (methodOrOptions.slice(0, 3) === 'get') { 2224 return this.first()[0].M_Modal[methodOrOptions](); 2225 2226 // Void methods 2227 } else { 2228 return this.each(function () { 2229 this.M_Modal[methodOrOptions](); 2230 }); 2231 } 2232 2233 // Initialize plugin if options or no argument is passed in 2234 } else if (typeof methodOrOptions === 'object' || !methodOrOptions) { 2235 Modal.init(this, arguments[0]); 2236 return this; 2237 2238 // Return error if an unrecognized method name is passed in 2239 } else { 2240 $.error('Method ' + methodOrOptions + ' does not exist on jQuery.modal'); 2241 } 2242 }; 2243})(jQuery, Materialize.Vel); 2244;(function ($) { 2245 2246 $.fn.materialbox = function () { 2247 2248 return this.each(function () { 2249 2250 if ($(this).hasClass('initialized')) { 2251 return; 2252 } 2253 2254 $(this).addClass('initialized'); 2255 2256 var overlayActive = false; 2257 var doneAnimating = true; 2258 var inDuration = 275; 2259 var outDuration = 200; 2260 var origin = $(this);
2261 var placeholder = $('<div></div>').addClass('material-placeholder'); 2262 var originalWidth = 0; 2263 var originalHeight = 0; 2264 var ancestorsChanged; 2265 var ancestor; 2266 var originInlineStyles = origin.attr('style'); 2267 origin.wrap(placeholder); 2268 2269 // Start click handler 2270 origin.on('click', function () { 2271 var placeholder = origin.parent('.material-placeholder'); 2272 var windowWidth = window.innerWidth; 2273 var windowHeight = window.innerHeight; 2274 var originalWidth = origin.width(); 2275 var originalHeight = origin.height(); 2276 2277 // If already modal, return to original 2278 if (doneAnimating === false) { 2279 returnToOriginal(); 2280 return false; 2281 } else if (overlayActive && doneAnimating === true) { 2282 returnToOriginal(); 2283 return false; 2284 } 2285 2286 // Set states 2287 doneAnimating = false; 2288 origin.addClass('active'); 2289 overlayActive = true; 2290 2291 // Set positioning for placeholder 2292 placeholder.css({ 2293 width: placeholder[0].getBoundingClientRect().width, 2294 height: placeholder[0].getBoundingClientRect().height, 2295 position: 'relative', 2296 top: 0, 2297 left: 0 2298 }); 2299 2300 // Find ancestor with overflow: hidden; and remove it 2301 ancestorsChanged = undefined; 2302 ancestor = placeholder[0].parentNode; 2303 var count = 0; 2304 while (ancestor !== null && !$(ancestor).is(document)) { 2305 var curr = $(ancestor); 2306 if (curr.css('overflow') !== 'visible') { 2307 curr.css('overflow', 'visible'); 2308 if (ancestorsChanged === undefined) { 2309 ancestorsChanged = curr; 2310 } else { 2311 ancestorsChanged = ancestorsChanged.add(curr); 2312 } 2313 } 2314 ancestor = ancestor.parentNode; 2315 } 2316 2317 // Set css on origin 2318 origin.css({ 2319 position: 'absolute', 2320 'z-index': 1000, 2321 'will-change': 'left, top, width, height' 2322 }).data('width', originalWidth).data('height', originalHeight); 2323 2324 // Add overlay 2325 var overlay = $('<div id="materialbox-overlay"></div>').css({ 2326 opacity: 0 2327 }).click(function () { 2328 if (doneAnimating === true) returnToOriginal(); 2329 }); 2330 2331 // Put before in origin image to preserve z-index layering. 2332 origin.before(overlay); 2333 2334 // Set dimensions if needed 2335 var overlayOffset = overlay[0].getBoundingClientRect(); 2336 overlay.css({ 2337 width: windowWidth, 2338 height: windowHeight, 2339 left: -1 * overlayOffset.left, 2340 top: -1 * overlayOffset.top 2341 }); 2342 2343 // Animate Overlay 2344 overlay.velocity({ opacity: 1 }, { duration: inDuration, queue: false, easing: 'easeOutQuad' }); 2345 2346 // Add and animate caption if it exists 2347 if (origin.data('caption') !== "") { 2348 var $photo_caption = $('<div class="materialbox-caption"></div>'); 2349 $photo_caption.text(origin.data('caption')); 2350 $('body').append($photo_caption); 2351 $photo_caption.css({ "display": "inline" }); 2352 $photo_caption.velocity({ opacity: 1 }, { duration: inDuration, queue: false, easing: 'easeOutQuad' }); 2353 } 2354 2355 // Resize Image 2356 var ratio = 0; 2357 var widthPercent = originalWidth / windowWidth; 2358 var heightPercent = originalHeight / windowHeight; 2359 var newWidth = 0; 2360 var newHeight = 0; 2361 2362 if (widthPercent > heightPercent) { 2363 ratio = originalHeight / originalWidth; 2364 newWidth = windowWidth * 0.9; 2365 newHeight = windowWidth * 0.9 * ratio; 2366 } else { 2367 ratio = originalWidth / originalHeight; 2368 newWidth = windowHeight * 0.9 * ratio; 2369 newHeight = windowHeight * 0.9; 2370 } 2371 2372 // Animate image + set z-index 2373 if (origin.hasClass('responsive-img')) { 2374 origin.velocity({ 'max-width': newWidth, 'width': originalWidth }, { duration: 0, queue: false, 2375 complete: function () { 2376 origin.css({ left: 0, top: 0 }).velocity({ 2377 height: newHeight, 2378 width: newWidth, 2379 left: $(document).scrollLeft() + windowWidth / 2 - origin.parent('.material-placeholder').offset().left - newWidth / 2, 2380 top: $(document).scrollTop() + windowHeight / 2 - origin.parent('.material-placeholder').offset().top - newHeight / 2 2381 }, { 2382 duration: inDuration, 2383 queue: false, 2384 easing: 'easeOutQuad', 2385 complete: function () { 2386 doneAnimating = true; 2387 } 2388 }); 2389 } // End Complete 2390 }); // End Velocity 2391 } else { 2392 origin.css('left', 0).css('top', 0).velocity({ 2393 height: newHeight, 2394 width: newWidth, 2395 left: $(document).scrollLeft() + windowWidth / 2 - origin.parent('.material-placeholder').offset().left - newWidth / 2, 2396 top: $(document).scrollTop() + windowHeight / 2 - origin.parent('.material-placeholder').offset().top - newHeight / 2 2397 }, { 2398 duration: inDuration, 2399 queue: false, 2400 easing: 'easeOutQuad', 2401 complete: function () { 2402 doneAnimating = true; 2403 } 2404 }); // End Velocity 2405 } 2406 2407 // Handle Exit triggers 2408 $(window).on('scroll.materialbox', function () { 2409 if (overlayActive) { 2410 returnToOriginal(); 2411 } 2412 }); 2413 2414 $(window).on('resize.materialbox', function () { 2415 if (overlayActive) { 2416 returnToOriginal(); 2417 } 2418 }); 2419 2420 $(document).on('keyup.materialbox', function (e) { 2421 // ESC key 2422 if (e.keyCode === 27 && doneAnimating === true && overlayActive) { 2423 returnToOriginal(); 2424 } 2425 }); 2426 }); // End click handler 2427 2428 2429 // This function returns the modaled image to the original spot 2430 function returnToOriginal() { 2431 2432 doneAnimating = false;
2433 2434 var placeholder = origin.parent('.material-placeholder'); 2435 var windowWidth = window.innerWidth; 2436 var windowHeight = window.innerHeight; 2437 var originalWidth = origin.data('width'); 2438 var originalHeight = origin.data('height'); 2439 2440 origin.velocity("stop", true); 2441 $('#materialbox-overlay').velocity("stop", true); 2442 $('.materialbox-caption').velocity("stop", true); 2443 2444 // disable exit handlers 2445 $(window).off('scroll.materialbox'); 2446 $(document).off('keyup.materialbox'); 2447 $(window).off('resize.materialbox'); 2448 2449 $('#materialbox-overlay').velocity({ opacity: 0 }, { 2450 duration: outDuration, // Delay prevents animation overlapping 2451 queue: false, easing: 'easeOutQuad', 2452 complete: function () { 2453 // Remove Overlay 2454 overlayActive = false; 2455 $(this).remove(); 2456 } 2457 }); 2458 2459 // Resize Image 2460 origin.velocity({ 2461 width: originalWidth, 2462 height: originalHeight, 2463 left: 0, 2464 top: 0 2465 }, { 2466 duration: outDuration, 2467 queue: false, easing: 'easeOutQuad', 2468 complete: function () { 2469 placeholder.css({ 2470 height: '', 2471 width: '', 2472 position: '', 2473 top: '', 2474 left: '' 2475 }); 2476 2477 origin.removeAttr('style'); 2478 origin.attr('style', originInlineStyles); 2479 2480 // Remove class 2481 origin.removeClass('active'); 2482 doneAnimating = true; 2483 2484 // Remove overflow overrides on ancestors 2485 if (ancestorsChanged) { 2486 ancestorsChanged.css('overflow', ''); 2487 } 2488 } 2489 }); 2490 2491 // Remove Caption + reset css settings on image 2492 $('.materialbox-caption').velocity({ opacity: 0 }, { 2493 duration: outDuration, // Delay prevents animation overlapping 2494 queue: false, easing: 'easeOutQuad', 2495 complete: function () { 2496 $(this).remove(); 2497 } 2498 }); 2499 } 2500 }); 2501 }; 2502 2503 $(document).ready(function () { 2504 $('.materialboxed').materialbox(); 2505 }); 2506})(jQuery); 2507;(function ($) { 2508 2509 $.fn.parallax = function () { 2510 var window_width = $(window).width(); 2511 // Parallax Scripts 2512 return this.each(function (i) { 2513 var $this = $(this); 2514 $this.addClass('parallax'); 2515 2516 function updateParallax(initial) { 2517 var container_height; 2518 if (window_width < 601) { 2519 container_height = $this.height() > 0 ? $this.height() : $this.children("img").height(); 2520 } else { 2521 container_height = $this.height() > 0 ? $this.height() : 500; 2522 } 2523 var $img = $this.children("img").first(); 2524 var img_height = $img.height(); 2525 var parallax_dist = img_height - container_height; 2526 var bottom = $this.offset().top + container_height; 2527 var top = $this.offset().top; 2528 var scrollTop = $(window).scrollTop(); 2529 var windowHeight = window.innerHeight; 2530 var windowBottom = scrollTop + windowHeight; 2531 var percentScrolled = (windowBottom - top) / (container_height + windowHeight); 2532 var parallax = Math.round(parallax_dist * percentScrolled); 2533 2534 if (initial) { 2535 $img.css('display', 'block'); 2536 } 2537 if (bottom > scrollTop && top < scrollTop + windowHeight) { 2538 $img.css('transform', "translate3D(-50%," + parallax + "px, 0)"); 2539 } 2540 } 2541 2542 // Wait for image load 2543 $this.children("img").one("load", function () { 2544 updateParallax(true); 2545 }).each(function () { 2546 if (this.complete) $(this).trigger("load"); 2547 }); 2548 2549 $(window).scroll(function () { 2550 window_width = $(window).width(); 2551 updateParallax(false); 2552 }); 2553 2554 $(window).resize(function () { 2555 window_width = $(window).width(); 2556 updateParallax(false); 2557 }); 2558 }); 2559 }; 2560})(jQuery); 2561;(function ($) { 2562 2563 var methods = { 2564 init: function (options) { 2565 var defaults = { 2566 onShow: null, 2567 swipeable: false, 2568 responsiveThreshold: Infinity // breakpoint for swipeable 2569 }; 2570 options = $.extend(defaults, options);
2571 var namespace = Materialize.objectSelectorString($(this)); 2572 2573 return this.each(function (i) { 2574 2575 var uniqueNamespace = namespace + i; 2576 2577 // For each set of tabs, we want to keep track of 2578 // which tab is active and its associated content 2579 var $this = $(this), 2580 window_width = $(window).width(); 2581 2582 var $active, 2583 $content, 2584 $links = $this.find('li.tab a'), 2585 $tabs_width = $this.width(), 2586 $tabs_content = $(), 2587 $tabs_wrapper, 2588 $tab_width = Math.max($tabs_width, $this[0].scrollWidth) / $links.length, 2589 $indicator, 2590 index = 0, 2591 prev_index = 0, 2592 clicked = false, 2593 clickedTimeout, 2594 transition = 300; 2595 2596 // Finds right attribute for indicator based on active tab. 2597 // el: jQuery Object 2598 var calcRightPos = function (el) { 2599 return Math.ceil($tabs_width - el.position().left - el[0].getBoundingClientRect().width - $this.scrollLeft()); 2600 }; 2601 2602 // Finds left attribute for indicator based on active tab. 2603 // el: jQuery Object 2604 var calcLeftPos = function (el) { 2605 return Math.floor(el.position().left + $this.scrollLeft()); 2606 }; 2607 2608 // Animates Indicator to active tab. 2609 // prev_index: Number 2610 var animateIndicator = function (prev_index) { 2611 if (index - prev_index >= 0) { 2612 $indicator.velocity({ "right": calcRightPos($active) }, { duration: transition, queue: false, easing: 'easeOutQuad' }); 2613 $indicator.velocity({ "left": calcLeftPos($active) }, { duration: transition, queue: false, easing: 'easeOutQuad', delay: 90 }); 2614 } else { 2615 $indicator.velocity({ "left": calcLeftPos($active) }, { duration: transition, queue: false, easing: 'easeOutQuad' }); 2616 $indicator.velocity({ "right": calcRightPos($active) }, { duration: transition, queue: false, easing: 'easeOutQuad', delay: 90 }); 2617 } 2618 }; 2619 2620 // Change swipeable according to responsive threshold 2621 if (options.swipeable) { 2622 if (window_width > options.responsiveThreshold) { 2623 options.swipeable = false; 2624 } 2625 } 2626 2627 // If the location.hash matches one of the links, use that as the active tab. 2628 $active = $($links.filter('[href="' + location.hash + '"]')); 2629 2630 // If no match is found, use the first link or any with class 'active' as the initial active tab. 2631 if ($active.length === 0) { 2632 $active = $(this).find('li.tab a.active').first(); 2633 } 2634 if ($active.length === 0) { 2635 $active = $(this).find('li.tab a').first(); 2636 } 2637 2638 $active.addClass('active'); 2639 index = $links.index($active); 2640 if (index < 0) { 2641 index = 0; 2642 } 2643 2644 if ($active[0] !== undefined) { 2645 $content = $($active[0].hash); 2646 $content.addClass('active'); 2647 } 2648 2649 // append indicator then set indicator width to tab width 2650 if (!$this.find('.indicator').length) { 2651 $this.append('<li class="indicator"></li>'); 2652 } 2653 $indicator = $this.find('.indicator'); 2654 2655 // we make sure that the indicator is at the end of the tabs 2656 $this.append($indicator); 2657 2658 if ($this.is(":visible")) { 2659 // $indicator.css({"right": $tabs_width - ((index + 1) * $tab_width)}); 2660 // $indicator.css({"left": index * $tab_width}); 2661 setTimeout(function () { 2662 $indicator.css({ "right": calcRightPos($active) }); 2663 $indicator.css({ "left": calcLeftPos($active) }); 2664 }, 0); 2665 } 2666 $(window).off('resize.tabs-' + uniqueNamespace).on('resize.tabs-' + uniqueNamespace, function () { 2667 $tabs_width = $this.width(); 2668 $tab_width = Math.max($tabs_width, $this[0].scrollWidth) / $links.length; 2669 if (index < 0) { 2670 index = 0; 2671 } 2672 if ($tab_width !== 0 && $tabs_width !== 0) { 2673 $indicator.css({ "right": calcRightPos($active) });
2674 $indicator.css({ "left": calcLeftPos($active) }); 2675 } 2676 }); 2677 2678 // Initialize Tabs Content. 2679 if (options.swipeable) { 2680 // TODO: Duplicate calls with swipeable? handle multiple div wrapping. 2681 $links.each(function () { 2682 var $curr_content = $(Materialize.escapeHash(this.hash)); 2683 $curr_content.addClass('carousel-item'); 2684 $tabs_content = $tabs_content.add($curr_content); 2685 }); 2686 $tabs_wrapper = $tabs_content.wrapAll('<div class="tabs-content carousel"></div>'); 2687 $tabs_content.css('display', ''); 2688 $('.tabs-content.carousel').carousel({ 2689 fullWidth: true, 2690 noWrap: true, 2691 onCycleTo: function (item) { 2692 if (!clicked) { 2693 var prev_index = index; 2694 index = $tabs_wrapper.index(item); 2695 $active.removeClass('active'); 2696 $active = $links.eq(index); 2697 $active.addClass('active'); 2698 animateIndicator(prev_index); 2699 if (typeof options.onShow === "function") { 2700 options.onShow.call($this[0], $content); 2701 } 2702 } 2703 } 2704 }); 2705 } else { 2706 // Hide the remaining content 2707 $links.not($active).each(function () { 2708 $(Materialize.escapeHash(this.hash)).hide(); 2709 }); 2710 } 2711 2712 // Bind the click event handler 2713 $this.off('click.tabs').on('click.tabs', 'a', function (e) { 2714 if ($(this).parent().hasClass('disabled')) { 2715 e.preventDefault(); 2716 return; 2717 } 2718 2719 // Act as regular link if target attribute is specified. 2720 if (!!$(this).attr("target")) { 2721 return; 2722 } 2723 2724 clicked = true; 2725 $tabs_width = $this.width(); 2726 $tab_width = Math.max($tabs_width, $this[0].scrollWidth) / $links.length; 2727 2728 // Make the old tab inactive. 2729 $active.removeClass('active'); 2730 var $oldContent = $content; 2731 2732 // Update the variables with the new link and content 2733 $active = $(this); 2734 $content = $(Materialize.escapeHash(this.hash)); 2735 $links = $this.find('li.tab a'); 2736 var activeRect = $active.position(); 2737 2738 // Make the tab active. 2739 $active.addClass('active'); 2740 prev_index = index; 2741 index = $links.index($(this)); 2742 if (index < 0) { 2743 index = 0; 2744 } 2745 // Change url to current tab 2746 // window.location.hash = $active.attr('href'); 2747 2748 // Swap content 2749 if (options.swipeable) { 2750 if ($tabs_content.length) { 2751 $tabs_content.carousel('set', index, function () { 2752 if (typeof options.onShow === "function") { 2753 options.onShow.call($this[0], $content); 2754 } 2755 }); 2756 } 2757 } else { 2758 if ($content !== undefined) { 2759 $content.show(); 2760 $content.addClass('active'); 2761 if (typeof options.onShow === "function") { 2762 options.onShow.call(this, $content); 2763 } 2764 } 2765 2766 if ($oldContent !== undefined && !$oldContent.is($content)) { 2767 $oldContent.hide(); 2768 $oldContent.removeClass('active'); 2769 } 2770 } 2771 2772 // Reset clicked state 2773 clickedTimeout = setTimeout(function () { 2774 clicked = false; 2775 }, transition); 2776 2777 // Update indicator 2778 animateIndicator(prev_index); 2779 2780 // Prevent the anchor's default click action 2781 e.preventDefault(); 2782 }); 2783 }); 2784 }, 2785 select_tab: function (id) { 2786 this.find('a[href="#' + id + '"]').trigger('click'); 2787 } 2788 }; 2789 2790 $.fn.tabs = function (methodOrOptions) { 2791 if (methods[methodOrOptions]) { 2792 return methods[methodOrOptions].apply(this, Array.prototype.slice.call(arguments, 1)); 2793 } else if (typeof methodOrOptions === 'object' || !methodOrOptions) { 2794 // Default to "init" 2795 return methods.init.apply(this, arguments); 2796 } else { 2797 $.error('Method ' + methodOrOptions + ' does not exist on jQuery.tabs'); 2798 } 2799 }; 2800 2801 $(document).ready(function () { 2802 $('ul.tabs').tabs(); 2803 }); 2804})(jQuery); 2805;(function ($) { 2806 $.fn.tooltip = function (options) { 2807 var timeout = null, 2808 margin = 5; 2809 2810 // Defaults 2811 var defaults = { 2812 delay: 350, 2813 tooltip: '', 2814 position: 'bottom', 2815 html: false 2816 }; 2817 2818 // Remove tooltip from the activator
2819 if (options === "remove") { 2820 this.each(function () { 2821 $('#' + $(this).attr('data-tooltip-id')).remove(); 2822 $(this).removeAttr('data-tooltip-id'); 2823 $(this).off('mouseenter.tooltip mouseleave.tooltip'); 2824 }); 2825 return false; 2826 } 2827 2828 options = $.extend(defaults, options); 2829 2830 return this.each(function () { 2831 var tooltipId = Materialize.guid(); 2832 var origin = $(this); 2833 2834 // Destroy old tooltip 2835 if (origin.attr('data-tooltip-id')) { 2836 $('#' + origin.attr('data-tooltip-id')).remove(); 2837 } 2838 2839 origin.attr('data-tooltip-id', tooltipId); 2840 2841 // Get attributes. 2842 var allowHtml, tooltipDelay, tooltipPosition, tooltipText, tooltipEl, backdrop; 2843 var setAttributes = function () { 2844 allowHtml = origin.attr('data-html') ? origin.attr('data-html') === 'true' : options.html; 2845 tooltipDelay = origin.attr('data-delay'); 2846 tooltipDelay = tooltipDelay === undefined || tooltipDelay === '' ? options.delay : tooltipDelay; 2847 tooltipPosition = origin.attr('data-position'); 2848 tooltipPosition = tooltipPosition === undefined || tooltipPosition === '' ? options.position : tooltipPosition; 2849 tooltipText = origin.attr('data-tooltip'); 2850 tooltipText = tooltipText === undefined || tooltipText === '' ? options.tooltip : tooltipText; 2851 }; 2852 setAttributes(); 2853 2854 var renderTooltipEl = function () { 2855 var tooltip = $('<div class="material-tooltip"></div>'); 2856 2857 // Create Text span 2858 if (allowHtml) { 2859 tooltipText = $('<span></span>').html(tooltipText); 2860 } else { 2861 tooltipText = $('<span></span>').text(tooltipText); 2862 } 2863 2864 // Create tooltip 2865 tooltip.append(tooltipText).appendTo($('body')).attr('id', tooltipId); 2866 2867 // Create backdrop 2868 backdrop = $('<div class="backdrop"></div>'); 2869 backdrop.appendTo(tooltip); 2870 return tooltip; 2871 }; 2872 tooltipEl = renderTooltipEl(); 2873 2874 // Destroy previously binded events 2875 origin.off('mouseenter.tooltip mouseleave.tooltip'); 2876 // Mouse In 2877 var started = false, 2878 timeoutRef; 2879 origin.on({ 'mouseenter.tooltip': function (e) { 2880 var showTooltip = function () { 2881 setAttributes(); 2882 started = true; 2883 tooltipEl.velocity('stop'); 2884 backdrop.velocity('stop'); 2885 tooltipEl.css({ visibility: 'visible', left: '0px', top: '0px' }); 2886 2887 // Tooltip positioning 2888 var originWidth = origin.outerWidth(); 2889 var originHeight = origin.outerHeight(); 2890 var tooltipHeight = tooltipEl.outerHeight(); 2891 var tooltipWidth = tooltipEl.outerWidth(); 2892 var tooltipVerticalMovement = '0px'; 2893 var tooltipHorizontalMovement = '0px'; 2894 var backdropOffsetWidth = backdrop[0].offsetWidth; 2895 var backdropOffsetHeight = backdrop[0].offsetHeight; 2896 var scaleXFactor = 8; 2897 var scaleYFactor = 8; 2898 var scaleFactor = 0; 2899 var targetTop, targetLeft, newCoordinates; 2900 2901 if (tooltipPosition === "top") { 2902 // Top Position 2903 targetTop = origin.offset().top - tooltipHeight - margin; 2904 targetLeft = origin.offset().left + originWidth / 2 - tooltipWidth / 2; 2905 newCoordinates = repositionWithinScreen(targetLeft, targetTop, tooltipWidth, tooltipHeight); 2906 tooltipVerticalMovement = '-10px'; 2907 backdrop.css({ 2908 bottom: 0, 2909 left: 0, 2910 borderRadius: '14px 14px 0 0', 2911 transformOrigin: '50% 100%', 2912 marginTop: tooltipHeight, 2913 marginLeft: tooltipWidth / 2 - backdropOffsetWidth / 2 2914 }); 2915 } 2916 // Left Position 2917 else if (tooltipPosition === "left") { 2918 targetTop = origin.offset().top + originHeight / 2 - tooltipHeight / 2; 2919 targetLeft = origin.offset().left - tooltipWidth - margin; 2920 newCoordinates = repositionWithinScreen(targetLeft, targetTop, tooltipWidth, tooltipHeight); 2921 2922 tooltipHorizontalMovement = '-10px'; 2923 backdrop.css({ 2924 top: '-7px', 2925 right: 0, 2926 width: '14px', 2927 height: '14px', 2928 borderRadius: '14px 0 0 14px', 2929 transformOrigin: '95% 50%', 2930 marginTop: tooltipHeight / 2, 2931 marginLeft: tooltipWidth 2932 }); 2933 } 2934 // Right Position 2935 else if (tooltipPosition === "right") { 2936 targetTop = origin.offset().top + originHeight / 2 - tooltipHeight / 2; 2937 targetLeft = origin.offset().left + originWidth + margin; 2938 newCoordinates = repositionWithinScreen(targetLeft, targetTop, tooltipWidth, tooltipHeight); 2939 2940 tooltipHorizontalMovement = '+10px'; 2941 backdrop.css({ 2942 top: '-7px', 2943 left: 0, 2944 width: '14px', 2945 height: '14px', 2946 borderRadius: '0 14px 14px 0', 2947 transformOrigin: '5% 50%', 2948 marginTop: tooltipHeight / 2, 2949 marginLeft: '0px' 2950 }); 2951 } else { 2952 // Bottom Position 2953 targetTop = origin.offset().top + origin.outerHeight() + margin; 2954 targetLeft = origin.offset().left + originWidth / 2 - tooltipWidth / 2; 2955 newCoordinates = repositionWithinScreen(targetLeft, targetTop, tooltipWidth, tooltipHeight); 2956 tooltipVerticalMovement = '+10px'; 2957 backdrop.css({ 2958 top: 0, 2959 left: 0, 2960 marginLeft: tooltipWidth / 2 - backdropOffsetWidth / 2 2961 }); 2962 } 2963 2964 // Set tooptip css placement 2965 tooltipEl.css({ 2966 top: newCoordinates.y, 2967 left: newCoordinates.x 2968 }); 2969 2970 // Calculate Scale to fill 2971 scaleXFactor = Math.SQRT2 * tooltipWidth / parseInt(backdropOffsetWidth); 2972 scaleYFactor = Math.SQRT2 * tooltipHeight / parseInt(backdropOffsetHeight); 2973 scaleFactor = Math.max(scaleXFactor, scaleYFactor); 2974 2975 tooltipEl.velocity({ translateY: tooltipVerticalMovement, translateX: tooltipHorizontalMovement }, { duration: 350, queue: false }).velocity({ opacity: 1 }, { duration: 300, delay: 50, queue: false }); 2976 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' }); 2977 }; 2978 2979 timeoutRef = setTimeout(showTooltip, tooltipDelay); // End Interval 2980 2981 // Mouse Out 2982 }, 2983 'mouseleave.tooltip': function () { 2984 // Reset State 2985 started = false;
2986 clearTimeout(timeoutRef); 2987 2988 // Animate back 2989 setTimeout(function () { 2990 if (started !== true) { 2991 tooltipEl.velocity({ 2992 opacity: 0, translateY: 0, translateX: 0 }, { duration: 225, queue: false }); 2993 backdrop.velocity({ opacity: 0, scaleX: 1, scaleY: 1 }, { 2994 duration: 225, 2995 queue: false, 2996 complete: function () { 2997 backdrop.css({ visibility: 'hidden' }); 2998 tooltipEl.css({ visibility: 'hidden' }); 2999 started = false; 3000 } 3001 }); 3002 } 3003 }, 225); 3004 } 3005 }); 3006 }); 3007 }; 3008 3009 var repositionWithinScreen = function (x, y, width, height) { 3010 var newX = x; 3011 var newY = y; 3012 3013 if (newX < 0) { 3014 newX = 4; 3015 } else if (newX + width > window.innerWidth) { 3016 newX -= newX + width - window.innerWidth; 3017 } 3018 3019 if (newY < 0) { 3020 newY = 4; 3021 } else if (newY + height > window.innerHeight + $(window).scrollTop) { 3022 newY -= newY + height - window.innerHeight; 3023 } 3024 3025 return { x: newX, y: newY }; 3026 }; 3027 3028 $(document).ready(function () { 3029 $('.tooltipped').tooltip(); 3030 }); 3031})(jQuery
vendor: 9,639 bytes, lines 3031-3365
3031); 3032; /*! 3033 * Waves v0.6.4 3034 * http://fian.my.id/Waves 3035 * 3036 * Copyright 2014 Alfiana E. Sibuea and other contributors 3037 * Released under the MIT license 3038 * https://github.com/fians/Waves/blob/master/LICENSE 3039 */ 3040 3041;(function (window) { 3042 'use strict'; 3043 3044 var Waves = Waves || {}; 3045 var $$ = document.querySelectorAll.bind(document); 3046 3047 // Find exact position of element 3048 function isWindow(obj) { 3049 return obj !== null && obj === obj.window; 3050 } 3051 3052 function getWindow(elem) { 3053 return isWindow(elem) ? elem : elem.nodeType === 9 && elem.defaultView; 3054 } 3055 3056 function offset(elem) { 3057 var docElem, 3058 win, 3059 box = { top: 0, left: 0 }, 3060 doc = elem && elem.ownerDocument; 3061 3062 docElem = doc.documentElement; 3063 3064 if (typeof elem.getBoundingClientRect !== typeof undefined) { 3065 box = elem.getBoundingClientRect(); 3066 } 3067 win = getWindow(doc); 3068 return { 3069 top: box.top + win.pageYOffset - docElem.clientTop, 3070 left: box.left + win.pageXOffset - docElem.clientLeft 3071 }; 3072 } 3073 3074 function convertStyle(obj) { 3075 var style = ''; 3076 3077 for (var a in obj) { 3078 if (obj.hasOwnProperty(a)) { 3079 style += a + ':' + obj[a] + ';'; 3080 } 3081 } 3082 3083 return style; 3084 } 3085 3086 var Effect = { 3087 3088 // Effect delay 3089 duration: 750, 3090 3091 show: function (e, element) { 3092 3093 // Disable right click 3094 if (e.button === 2) { 3095 return false; 3096 } 3097 3098 var el = element || this; 3099 3100 // Create ripple 3101 var ripple = document.createElement('div'); 3102 ripple.className = 'waves-ripple'; 3103 el.appendChild(ripple); 3104 3105 // Get click coordinate and element witdh 3106 var pos = offset(el); 3107 var relativeY = e.pageY - pos.top; 3108 var relativeX = e.pageX - pos.left; 3109 var scale = 'scale(' + el.clientWidth / 100 * 10 + ')'; 3110 3111 // Support for touch devices 3112 if ('touches' in e) { 3113 relativeY = e.touches[0].pageY - pos.top; 3114 relativeX = e.touches[0].pageX - pos.left; 3115 } 3116 3117 // Attach data to element 3118 ripple.setAttribute('data-hold', Date.now()); 3119 ripple.setAttribute('data-scale', scale); 3120 ripple.setAttribute('data-x', relativeX); 3121 ripple.setAttribute('data-y', relativeY); 3122 3123 // Set ripple position 3124 var rippleStyle = { 3125 'top': relativeY + 'px', 3126 'left': relativeX + 'px' 3127 }; 3128 3129 ripple.className = ripple.className + ' waves-notransition'; 3130 ripple.setAttribute('style', convertStyle(rippleStyle)); 3131 ripple.className = ripple.className.replace('waves-notransition', ''); 3132 3133 // Scale the ripple 3134 rippleStyle['-webkit-transform'] = scale; 3135 rippleStyle['-moz-transform'] = scale; 3136 rippleStyle['-ms-transform'] = scale; 3137 rippleStyle['-o-transform'] = scale; 3138 rippleStyle.transform = scale; 3139 rippleStyle.opacity = '1'; 3140 3141 rippleStyle['-webkit-transition-duration'] = Effect.duration + 'ms'; 3142 rippleStyle['-moz-transition-duration'] = Effect.duration + 'ms'; 3143 rippleStyle['-o-transition-duration'] = Effect.duration + 'ms'; 3144 rippleStyle['transition-duration'] = Effect.duration + 'ms'; 3145 3146 rippleStyle['-webkit-transition-timing-function'] = 'cubic-bezier(0.250, 0.460, 0.450, 0.940)'; 3147 rippleStyle['-moz-transition-timing-function'] = 'cubic-bezier(0.250, 0.460, 0.450, 0.940)'; 3148 rippleStyle['-o-transition-timing-function'] = 'cubic-bezier(0.250, 0.460, 0.450, 0.940)'; 3149 rippleStyle['transition-timing-function'] = 'cubic-bezier(0.250, 0.460, 0.450, 0.940)'; 3150 3151 ripple.setAttribute('style', convertStyle(rippleStyle)); 3152 }, 3153 3154 hide: function (e) { 3155 TouchHandler.touchup(e); 3156 3157 var el = this; 3158 var width = el.clientWidth * 1.4; 3159 3160 // Get first ripple 3161 var ripple = null; 3162 var ripples = el.getElementsByClassName('waves-ripple'); 3163 if (ripples.length > 0) { 3164 ripple = ripples[ripples.length - 1]; 3165 } else { 3166 return false; 3167 } 3168 3169 var relativeX = ripple.getAttribute('data-x'); 3170 var relativeY = ripple.getAttribute('data-y'); 3171 var scale = ripple.getAttribute('data-scale'); 3172 3173 // Get delay beetween mousedown and mouse leave 3174 var diff = Date.now() - Number(ripple.getAttribute('data-hold')); 3175 var delay = 350 - diff; 3176 3177 if (delay < 0) { 3178 delay = 0; 3179 } 3180 3181 // Fade out ripple after delay 3182 setTimeout(function () { 3183 var style = { 3184 'top': relativeY + 'px', 3185 'left': relativeX + 'px', 3186 'opacity': '0', 3187 3188 // Duration 3189 '-webkit-transition-duration': Effect.duration + 'ms', 3190 '-moz-transition-duration': Effect.duration + 'ms', 3191 '-o-transition-duration': Effect.duration + 'ms', 3192 'transition-duration': Effect.duration + 'ms', 3193 '-webkit-transform': scale, 3194 '-moz-transform': scale, 3195 '-ms-transform': scale, 3196 '-o-transform': scale, 3197 'transform': scale 3198 }; 3199 3200 ripple.setAttribute('style', convertStyle(style)); 3201 3202 setTimeout(function () { 3203 try { 3204 el.removeChild(ripple); 3205 } catch (e) { 3206 return false; 3207 } 3208 }, Effect.duration); 3209 }, delay); 3210 }, 3211 3212 // Little hack to make <input> can perform waves effect 3213 wrapInput: function (elements) { 3214 for (var a = 0; a < elements.length; a++) { 3215 var el = elements[a]; 3216 3217 if (el.tagName.toLowerCase() === 'input') { 3218 var parent = el.parentNode; 3219 3220 // If input already have parent just pass through 3221 if (parent.tagName.toLowerCase() === 'i' && parent.className.indexOf('waves-effect') !== -1) { 3222 continue; 3223 } 3224 3225 // Put element class and style to the specified parent 3226 var wrapper = document.createElement('i'); 3227 wrapper.className = el.className + ' waves-input-wrapper'; 3228 3229 var elementStyle = el.getAttribute('style'); 3230 3231 if (!elementStyle) { 3232 elementStyle = ''; 3233 } 3234 3235 wrapper.setAttribute('style', elementStyle); 3236 3237 el.className = 'waves-button-input'; 3238 el.removeAttribute('style'); 3239 3240 // Put element as child 3241 parent.replaceChild(wrapper, el); 3242 wrapper.appendChild(el); 3243 } 3244 } 3245 } 3246 }; 3247 3248 /** 3249 * Disable mousedown event for 500ms during and after touch 3250 */ 3251 var TouchHandler = { 3252 /* uses an integer rather than bool so there's no issues with 3253 * needing to clear timeouts if another touch event occurred 3254 * within the 500ms. Cannot mouseup between touchstart and 3255 * touchend, nor in the 500ms after touchend. */ 3256 touches: 0, 3257 allowEvent: function (e) { 3258 var allow = true; 3259 3260 if (e.type === 'touchstart') { 3261 TouchHandler.touches += 1; //push 3262 } else if (e.type === 'touchend' || e.type === 'touchcancel') { 3263 setTimeout(function () { 3264 if (TouchHandler.touches > 0) { 3265 TouchHandler.touches -= 1; //pop after 500ms 3266 } 3267 }, 500); 3268 } else if (e.type === 'mousedown' && TouchHandler.touches > 0) { 3269 allow = false; 3270 } 3271 3272 return allow; 3273 }, 3274 touchup: function (e) { 3275 TouchHandler.allowEvent(e); 3276 } 3277 }; 3278 3279 /** 3280 * Delegated click handler for .waves-effect element. 3281 * returns null when .waves-effect element not in "click tree" 3282 */ 3283 function getWavesEffectElement(e) { 3284 if (TouchHandler.allowEvent(e) === false) { 3285 return null; 3286 } 3287 3288 var element = null; 3289 var target = e.target || e.srcElement; 3290 3291 while (target.parentNode !== null) { 3292 if (!(target instanceof SVGElement) && target.className.indexOf('waves-effect') !== -1) { 3293 element = target; 3294 break; 3295 } 3296 target = target.parentNode; 3297 } 3298 return element; 3299 } 3300 3301 /** 3302 * Bubble the click and show effect if .waves-effect elem was found 3303 */ 3304 function showEffect(e) { 3305 var element = getWavesEffectElement(e); 3306 3307 if (element !== null) { 3308 Effect.show(e, element); 3309 3310 if ('ontouchstart' in window) { 3311 element.addEventListener('touchend', Effect.hide, false); 3312 element.addEventListener('touchcancel', Effect.hide, false); 3313 } 3314 3315 element.addEventListener('mouseup', Effect.hide, false); 3316 element.addEventListener('mouseleave', Effect.hide, false); 3317 element.addEventListener('dragend', Effect.hide, false); 3318 } 3319 } 3320 3321 Waves.displayEffect = function (options) { 3322 options = options || {}; 3323 3324 if ('duration' in options) { 3325 Effect.duration = options.duration; 3326 } 3327 3328 //Wrap input inside <i> tag 3329 Effect.wrapInput($$('.waves-effect')); 3330 3331 if ('ontouchstart' in window) { 3332 document.body.addEventListener('touchstart', showEffect, false); 3333 } 3334 3335 document.body.addEventListener('mousedown', showEffect, false); 3336 }; 3337 3338 /** 3339 * Attach Waves to an input element (or any element which doesn't 3340 * bubble mouseup/mousedown events). 3341 * Intended to be used with dynamically loaded forms/inputs, or 3342 * where the user doesn't want a delegated click handler. 3343 */ 3344 Waves.attach = function (element) { 3345 //FUTURE: automatically add waves classes and allow users 3346 // to specify them with an options param? Eg. light/classic/button 3347 if (element.tagName.toLowerCase() === 'input') { 3348 Effect.wrapInput([element]); 3349 element = element.parentNode; 3350 } 3351 3352 if ('ontouchstart' in window) { 3353 element.addEventListener('touchstart', showEffect, false); 3354 } 3355 3356 element.addEventListener('mousedown', showEffect, false); 3357 }; 3358 3359 window.Waves = Waves; 3360 3361 document.addEventListener('DOMContentLoaded', function () { 3362 Waves.displayEffect(); 3363 }, false); 3364})(window); 3365;(function ($,
3365Vel) { 3366 'use strict'; 3367 3368 var _defaults = { 3369 displayLength: Infinity, 3370 inDuration: 300, 3371 outDuration: 375, 3372 className: undefined, 3373 completeCallback: undefined, 3374 activationPercent: 0.8 3375 }; 3376 3377 var Toast = function () { 3378 function Toast(message, displayLength, className, completeCallback) { 3379 _classCallCheck(this, Toast); 3380 3381 if (!message) { 3382 return; 3383 } 3384 3385 /** 3386 * Options for the toast 3387 * @member Toast#options 3388 */ 3389 this.options = { 3390 displayLength: displayLength, 3391 className: className, 3392 completeCallback: completeCallback 3393 }; 3394 3395 this.options = $.extend({}, Toast.defaults, this.options); 3396 this.message = message; 3397 3398 /** 3399 * Describes current pan state toast 3400 * @type {Boolean} 3401 */ 3402 this.panning = false; 3403 3404 /** 3405 * Time remaining until toast is removed 3406 */ 3407 this.timeRemaining = this.options.displayLength; 3408 3409 if (Toast._toasts.length === 0) { 3410 Toast._createContainer(); 3411 } 3412 3413 // Create new toast 3414 Toast._toasts.push(this); 3415 var toastElement = this.createToast(); 3416 toastElement.M_Toast = this; 3417 this.el = toastElement; 3418 this._animateIn(); 3419 this.setTimer(); 3420 } 3421 3422 _createClass(Toast, [{ 3423 key: 'createToast', 3424 3425 3426 /** 3427 * Create toast and append it to toast container 3428 */ 3429 value: function createToast() { 3430 var toast = document.createElement('div'); 3431 toast.classList.add('toast'); 3432 3433 // Add custom classes onto toast 3434 if (this.options.className) { 3435 var classes = this.options.className.split(' '); 3436 var i = void 0, 3437 count = void 0; 3438 for (i = 0, count = classes.length; i < count; i++) { 3439 toast.classList.add(classes[i]); 3440 } 3441 } 3442 3443 // Set content 3444 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') { 3445 toast.appendChild(this.message); 3446 3447 // Check if it is jQuery object 3448 } else if (this.message instanceof jQuery) { 3449 $(toast).append(this.message); 3450 3451 // Insert as text; 3452 } else { 3453 toast.innerHTML = this.message; 3454 } 3455 3456 // Append toasft 3457 Toast._container.appendChild(toast); 3458 return toast; 3459 } 3460 3461 /** 3462 * Animate in toast 3463 */ 3464 3465 }, {
vendor: 4,804 bytes, lines 3466-3625
3466 key: '_animateIn', 3467 value: function _animateIn() { 3468 // Animate toast in 3469 Vel(this.el, { top: 0, opacity: 1 }, { 3470 duration: 300, 3471 easing: 'easeOutCubic', 3472 queue: false 3473 }); 3474 } 3475 3476 /** 3477 * Create setInterval which automatically removes toast when timeRemaining >= 0 3478 * has been reached 3479 */ 3480 3481 }, { 3482 key: 'setTimer', 3483 value: function setTimer() { 3484 var _this3 = this; 3485 3486 if (this.timeRemaining !== Infinity) { 3487 this.counterInterval = setInterval(function () { 3488 // If toast is not being dragged, decrease its time remaining 3489 if (!_this3.panning) { 3490 _this3.timeRemaining -= 20; 3491 } 3492 3493 // Animate toast out 3494 if (_this3.timeRemaining <= 0) { 3495 _this3.remove(); 3496 } 3497 }, 20); 3498 } 3499 } 3500 3501 /** 3502 * Dismiss toast with animation 3503 */ 3504 3505 }, { 3506 key: 'remove', 3507 value: function remove() { 3508 var _this4 = this; 3509 3510 window.clearInterval(this.counterInterval); 3511 var activationDistance = this.el.offsetWidth * this.options.activationPercent; 3512 3513 if (this.wasSwiped) { 3514 this.el.style.transition = 'transform .05s, opacity .05s'; 3515 this.el.style.transform = 'translateX(' + activationDistance + 'px)'; 3516 this.el.style.opacity = 0; 3517 } 3518 3519 Vel(this.el, { opacity: 0, marginTop: '-40px' }, { 3520 duration: this.options.outDuration, 3521 easing: 'easeOutExpo', 3522 queue: false, 3523 complete: function () { 3524 // Call the optional callback 3525 if (typeof _this4.options.completeCallback === 'function') { 3526 _this4.options.completeCallback(); 3527 } 3528 // Remove toast from DOM 3529 _this4.el.parentNode.removeChild(_this4.el); 3530 Toast._toasts.splice(Toast._toasts.indexOf(_this4), 1); 3531 if (Toast._toasts.length === 0) { 3532 Toast._removeContainer(); 3533 } 3534 } 3535 }); 3536 } 3537 }], [{ 3538 key: '_createContainer', 3539 3540 3541 /** 3542 * Append toast container and add event handlers 3543 */ 3544 value: function _createContainer() { 3545 var container = document.createElement('div'); 3546 container.setAttribute('id', 'toast-container'); 3547 3548 // Add event handler 3549 container.addEventListener('touchstart', Toast._onDragStart); 3550 container.addEventListener('touchmove', Toast._onDragMove); 3551 container.addEventListener('touchend', Toast._onDragEnd); 3552 3553 container.addEventListener('mousedown', Toast._onDragStart); 3554 document.addEventListener('mousemove', Toast._onDragMove); 3555 document.addEventListener('mouseup', Toast._onDragEnd); 3556 3557 document.body.appendChild(container); 3558 Toast._container = container; 3559 } 3560 3561 /** 3562 * Remove toast container and event handlers 3563 */ 3564 3565 }, { 3566 key: '_removeContainer', 3567 value: function _removeContainer() { 3568 // Add event handler 3569 document.removeEventListener('mousemove', Toast._onDragMove); 3570 document.removeEventListener('mouseup', Toast._onDragEnd); 3571 3572 Toast._container.parentNode.removeChild(Toast._container); 3573 Toast._container = null; 3574 } 3575 3576 /** 3577 * Begin drag handler 3578 * @param {Event} e 3579 */ 3580 3581 }, { 3582 key: '_onDragStart', 3583 value: function _onDragStart(e) { 3584 if (e.target && $(e.target).closest('.toast').length) { 3585 var $toast = $(e.target).closest('.toast'); 3586 var toast = $toast[0].M_Toast; 3587 toast.panning = true; 3588 Toast._draggedToast = toast; 3589 toast.el.classList.add('panning'); 3590 toast.el.style.transition = ''; 3591 toast.startingXPos = Toast._xPos(e); 3592 toast.time = Date.now(); 3593 toast.xPos = Toast._xPos(e); 3594 } 3595 } 3596 3597 /** 3598 * Drag move handler 3599 * @param {Event} e 3600 */ 3601 3602 }, { 3603 key: '_onDragMove', 3604 value: function _onDragMove(e) { 3605 if (!!Toast._draggedToast) { 3606 e.preventDefault(); 3607 var toast = Toast._draggedToast; 3608 toast.deltaX = Math.abs(toast.xPos - Toast._xPos(e)); 3609 toast.xPos = Toast._xPos(e); 3610 toast.velocityX = toast.deltaX / (Date.now() - toast.time); 3611 toast.time = Date.now(); 3612 3613 var totalDeltaX = toast.xPos - toast.startingXPos; 3614 var activationDistance = toast.el.offsetWidth * toast.options.activationPercent; 3615 toast.el.style.transform = 'translateX(' + totalDeltaX + 'px)'; 3616 toast.el.style.opacity = 1 - Math.abs(totalDeltaX / activationDistance); 3617 } 3618 } 3619 3620 /** 3621 * End drag handler 3622 * @param {Event} e 3623 */ 3624 3625 }, {
3626 key: '_onDragEnd', 3627 value: function _onDragEnd(e) { 3628 if (!!Toast._draggedToast) { 3629 var toast = Toast._draggedToast; 3630 toast.panning = false; 3631 toast.el.classList.remove('panning'); 3632 3633 var totalDeltaX = toast.xPos - toast.startingXPos; 3634 var activationDistance = toast.el.offsetWidth * toast.options.activationPercent; 3635 var shouldBeDismissed = Math.abs(totalDeltaX) > activationDistance || toast.velocityX > 1; 3636 3637 // Remove toast 3638 if (shouldBeDismissed) { 3639 toast.wasSwiped = true; 3640 toast.remove(); 3641 3642 // Animate toast back to original position 3643 } else { 3644 toast.el.style.transition = 'transform .2s, opacity .2s'; 3645 toast.el.style.transform = ''; 3646 toast.el.style.opacity = ''; 3647 } 3648 Toast._draggedToast = null; 3649 } 3650 } 3651 3652 /** 3653 * Get x position of mouse or touch event 3654 * @param {Event} e 3655 */ 3656 3657 }, { 3658 key: '_xPos', 3659 value: function _xPos(e) { 3660 if (e.targetTouches && e.targetTouches.length >= 1) { 3661 return e.targetTouches[0].clientX; 3662 } 3663 // mouse event 3664 return e.clientX; 3665 } 3666 3667 /** 3668 * Remove all toasts 3669 */ 3670 3671 }, { 3672 key: 'removeAll', 3673 value: function removeAll() { 3674 for (var toastIndex in Toast._toasts) { 3675 Toast._toasts[toastIndex].remove(); 3676 } 3677 } 3678 }, { 3679 key: 'defaults', 3680 get: function () { 3681 return _defaults; 3682 } 3683 }]); 3684 3685 return Toast; 3686 }(); 3687 3688 /** 3689 * @static 3690 * @memberof Toast 3691 * @type {Array.<Toast>} 3692 */ 3693 3694 3695 Toast._toasts = []; 3696 3697 /** 3698 * @static 3699 * @memberof Toast 3700 */ 3701 Toast._container = null; 3702 3703 /** 3704 * @static 3705 * @memberof Toast 3706 * @type {Toast} 3707 */ 3708 Toast._draggedToast = null; 3709 3710 Materialize.Toast = Toast; 3711 Materialize.toast = function (message, displayLength, className, completeCallback) { 3712 return new Toast(message, displayLength, className, completeCallback); 3713 }; 3714})(jQuery, Materialize.Vel); 3715;(function ($) { 3716 3717 var methods = { 3718 init: function (options) { 3719 var defaults = { 3720 menuWidth: 300, 3721 edge: 'left', 3722 closeOnClick: false, 3723 draggable: true, 3724 onOpen: null, 3725 onClose: null 3726 }; 3727 options = $.extend(defaults, options); 3728 3729 $(this).each(function () { 3730 var $this = $(this); 3731 var menuId = $this.attr('data-activates'); 3732 var menu = $("#" + menuId); 3733 3734 // Set to width 3735 if (options.menuWidth != 300) { 3736 menu.css('width', options.menuWidth); 3737 } 3738 3739 // Add Touch Area 3740 var $dragTarget = $('.drag-target[data-sidenav="' + menuId + '"]'); 3741 if (options.draggable) { 3742 // Regenerate dragTarget 3743 if ($dragTarget.length) { 3744 $dragTarget.remove(); 3745 } 3746 3747 $dragTarget = $('<div class="drag-target"></div>').attr('data-sidenav', menuId); 3748 $('body').append($dragTarget); 3749 } else { 3750 $dragTarget = $(); 3751 } 3752 3753 if (options.edge == 'left') { 3754 menu.css('transform', 'translateX(-100%)'); 3755 $dragTarget.css({ 'left': 0 }); // Add Touch Area 3756 } else { 3757 menu.addClass('right-aligned') // Change text-alignment to right 3758 .css('transform', 'translateX(100%)'); 3759 $dragTarget.css({ 'right': 0 }); // Add Touch Area 3760 } 3761 3762 // If fixed sidenav, bring menu out 3763 if (menu.hasClass('fixed')) { 3764 if (window.innerWidth > 992) { 3765 menu.css('transform', 'translateX(0)'); 3766 } 3767 } 3768 3769 // Window resize to reset on large screens fixed 3770 if (menu.hasClass('fixed')) { 3771 $(window).resize(function () { 3772 if (window.innerWidth > 992) { 3773 // Close menu if window is resized bigger than 992 and user has fixed sidenav 3774 if ($('#sidenav-overlay').length !== 0 && menuOut) { 3775 removeMenu(true); 3776 } else { 3777 // menu.removeAttr('style'); 3778 menu.css('transform', 'translateX(0%)'); 3779 // menu.css('width', options.menuWidth); 3780 } 3781 } else if (menuOut === false) { 3782 if (options.edge === 'left') { 3783 menu.css('transform', 'translateX(-100%)'); 3784 } else { 3785 menu.css('transform', 'translateX(100%)'); 3786 } 3787 } 3788 }); 3789 } 3790 3791 // if closeOnClick, then add close event for all a tags in side sideNav 3792 if (options.closeOnClick === true) { 3793 menu.on("click.itemclick", "a:not(.collapsible-header)", function () { 3794 if (!(window.innerWidth > 992 && menu.hasClass('fixed'))) { 3795 removeMenu(); 3796 } 3797 }); 3798 } 3799 3800 var removeMenu = function (restoreNav) { 3801 panning = false;
3802 menuOut = false; 3803 // Reenable scrolling 3804 $('body').css({ 3805 overflow: '', 3806 width: '' 3807 }); 3808 3809 $('#sidenav-overlay').velocity({ opacity: 0 }, { duration: 200, 3810 queue: false, easing: 'easeOutQuad', 3811 complete: function () { 3812 $(this).remove(); 3813 } }); 3814 if (options.edge === 'left') { 3815 // Reset phantom div 3816 $dragTarget.css({ width: '', right: '', left: '0' }); 3817 menu.velocity({ 'translateX': '-100%' }, { duration: 200, 3818 queue: false, 3819 easing: 'easeOutCubic', 3820 complete: function () { 3821 if (restoreNav === true) { 3822 // Restore Fixed sidenav 3823 menu.removeAttr('style'); 3824 menu.css('width', options.menuWidth); 3825 } 3826 } 3827 3828 }); 3829 } else { 3830 // Reset phantom div 3831 $dragTarget.css({ width: '', right: '0', left: '' }); 3832 menu.velocity({ 'translateX': '100%' }, { duration: 200, 3833 queue: false, 3834 easing: 'easeOutCubic', 3835 complete: function () { 3836 if (restoreNav === true) { 3837 // Restore Fixed sidenav 3838 menu.removeAttr('style'); 3839 menu.css('width', options.menuWidth); 3840 } 3841 } 3842 }); 3843 } 3844 3845 // Callback 3846 if (typeof options.onClose === 'function') { 3847 options.onClose.call(this, menu); 3848 } 3849 }; 3850 3851 // Touch Event 3852 var panning = false; 3853 var menuOut = false;
3854 3855 if (options.draggable) { 3856 $dragTarget.on('click', function () { 3857 if (menuOut) { 3858 removeMenu(); 3859 } 3860 }); 3861 3862 $dragTarget.hammer({ 3863 prevent_default: false 3864 }).on('pan', function (e) { 3865 3866 if (e.gesture.pointerType == "touch") { 3867 3868 var direction = e.gesture.direction; 3869 var x = e.gesture.center.x; 3870 var y = e.gesture.center.y; 3871 var velocityX = e.gesture.velocityX; 3872 3873 // Vertical scroll bugfix 3874 if (x === 0 && y === 0) { 3875 return; 3876 } 3877 3878 // Disable Scrolling 3879 var $body = $('body'); 3880 var $overlay = $('#sidenav-overlay'); 3881 var oldWidth = $body.innerWidth(); 3882 $body.css('overflow', 'hidden'); 3883 $body.width(oldWidth); 3884 3885 // If overlay does not exist, create one and if it is clicked, close menu 3886 if ($overlay.length === 0) { 3887 $overlay = $('<div id="sidenav-overlay"></div>'); 3888 $overlay.css('opacity', 0).click(function () { 3889 removeMenu(); 3890 }); 3891 3892 // Run 'onOpen' when sidenav is opened via touch/swipe if applicable 3893 if (typeof options.onOpen === 'function') { 3894 options.onOpen.call(this, menu); 3895 } 3896 3897 $('body').append($overlay); 3898 } 3899 3900 // Keep within boundaries 3901 if (options.edge === 'left') { 3902 if (x > options.menuWidth) { 3903 x = options.menuWidth; 3904 } else if (x < 0) { 3905 x = 0; 3906 } 3907 } 3908 3909 if (options.edge === 'left') { 3910 // Left Direction 3911 if (x < options.menuWidth / 2) { 3912 menuOut = false;
3913 } 3914 // Right Direction 3915 else if (x >= options.menuWidth / 2) { 3916 menuOut = true; 3917 } 3918 menu.css('transform', 'translateX(' + (x - options.menuWidth) + 'px)'); 3919 } else { 3920 // Left Direction 3921 if (x < window.innerWidth - options.menuWidth / 2) { 3922 menuOut = true; 3923 } 3924 // Right Direction 3925 else if (x >= window.innerWidth - options.menuWidth / 2) { 3926 menuOut = false; 3927 } 3928 var rightPos = x - options.menuWidth / 2; 3929 if (rightPos < 0) { 3930 rightPos = 0; 3931 } 3932 3933 menu.css('transform', 'translateX(' + rightPos + 'px)'); 3934 } 3935 3936 // Percentage overlay 3937 var overlayPerc; 3938 if (options.edge === 'left') { 3939 overlayPerc = x / options.menuWidth; 3940 $overlay.velocity({ opacity: overlayPerc }, { duration: 10, queue: false, easing: 'easeOutQuad' }); 3941 } else { 3942 overlayPerc = Math.abs((x - window.innerWidth) / options.menuWidth); 3943 $overlay.velocity({ opacity: overlayPerc }, { duration: 10, queue: false, easing: 'easeOutQuad' }); 3944 } 3945 } 3946 }).on('panend', function (e) { 3947 3948 if (e.gesture.pointerType == "touch") {
3949 var $overlay = $('#sidenav-overlay'); 3950 var velocityX = e.gesture.velocityX; 3951 var x = e.gesture.center.x; 3952 var leftPos = x - options.menuWidth; 3953 var rightPos = x - options.menuWidth / 2; 3954 if (leftPos > 0) { 3955 leftPos = 0; 3956 } 3957 if (rightPos < 0) { 3958 rightPos = 0; 3959 } 3960 panning = false; 3961 3962 if (options.edge === 'left') { 3963 // If velocityX <= 0.3 then the user is flinging the menu closed so ignore menuOut 3964 if (menuOut && velocityX <= 0.3 || velocityX < -0.5) { 3965 // Return menu to open 3966 if (leftPos !== 0) { 3967 menu.velocity({ 'translateX': [0, leftPos] }, { duration: 300, queue: false, easing: 'easeOutQuad' }); 3968 } 3969 3970 $overlay.velocity({ opacity: 1 }, { duration: 50, queue: false, easing: 'easeOutQuad' }); 3971 $dragTarget.css({ width: '50%', right: 0, left: '' }); 3972 menuOut = true; 3973 } else if (!menuOut || velocityX > 0.3) { 3974 // Enable Scrolling 3975 $('body').css({ 3976 overflow: '', 3977 width: '' 3978 }); 3979 // Slide menu closed 3980 menu.velocity({ 'translateX': [-1 * options.menuWidth - 10, leftPos] }, { duration: 200, queue: false, easing: 'easeOutQuad' }); 3981 $overlay.velocity({ opacity: 0 }, { duration: 200, queue: false, easing: 'easeOutQuad', 3982 complete: function () { 3983 // Run 'onClose' when sidenav is closed via touch/swipe if applicable 3984 if (typeof options.onClose === 'function') { 3985 options.onClose.call(this, menu); 3986 } 3987 3988 $(this).remove(); 3989 } }); 3990 $dragTarget.css({ width: '10px', right: '', left: 0 }); 3991 } 3992 } else { 3993 if (menuOut && velocityX >= -0.3 || velocityX > 0.5) { 3994 // Return menu to open 3995 if (rightPos !== 0) { 3996 menu.velocity({ 'translateX': [0, rightPos] }, { duration: 300, queue: false, easing: 'easeOutQuad' }); 3997 } 3998 3999 $overlay.velocity({ opacity: 1 }, { duration: 50, queue: false, easing: 'easeOutQuad' }); 4000 $dragTarget.css({ width: '50%', right: '', left: 0 }); 4001 menuOut = true; 4002 } else if (!menuOut || velocityX < -0.3) { 4003 // Enable Scrolling 4004 $('body').css({ 4005 overflow: '', 4006 width: '' 4007 }); 4008 4009 // Slide menu closed 4010 menu.velocity({ 'translateX': [options.menuWidth + 10, rightPos] }, { duration: 200, queue: false, easing: 'easeOutQuad' }); 4011 $overlay.velocity({ opacity: 0 }, { duration: 200, queue: false, easing: 'easeOutQuad', 4012 complete: function () { 4013 // Run 'onClose' when sidenav is closed via touch/swipe if applicable 4014 if (typeof options.onClose === 'function') { 4015 options.onClose.call(this, menu); 4016 } 4017 4018 $(this).remove(); 4019 } }); 4020 $dragTarget.css({ width: '10px', right: 0, left: '' }); 4021 } 4022 } 4023 } 4024 }); 4025 } 4026 4027 $this.off('click.sidenav').on('click.sidenav', function () { 4028 if (menuOut === true) { 4029 menuOut = false;
4030 panning = false; 4031 removeMenu(); 4032 } else { 4033 4034 // Disable Scrolling 4035 var $body = $('body'); 4036 var $overlay = $('<div id="sidenav-overlay"></div>'); 4037 var oldWidth = $body.innerWidth(); 4038 $body.css('overflow', 'hidden'); 4039 $body.width(oldWidth); 4040 4041 // Push current drag target on top of DOM tree 4042 $('body').append($dragTarget); 4043 4044 if (options.edge === 'left') { 4045 $dragTarget.css({ width: '50%', right: 0, left: '' }); 4046 menu.velocity({ 'translateX': [0, -1 * options.menuWidth] }, { duration: 300, queue: false, easing: 'easeOutQuad' }); 4047 } else { 4048 $dragTarget.css({ width: '50%', right: '', left: 0 }); 4049 menu.velocity({ 'translateX': [0, options.menuWidth] }, { duration: 300, queue: false, easing: 'easeOutQuad' }); 4050 } 4051 4052 // Overlay close on click 4053 $overlay.css('opacity', 0).click(function () { 4054 menuOut = false;
4055 panning = false; 4056 removeMenu(); 4057 $overlay.velocity({ opacity: 0 }, { duration: 300, queue: false, easing: 'easeOutQuad', 4058 complete: function () { 4059 $(this).remove(); 4060 } 4061 }); 4062 }); 4063 4064 // Append body 4065 $('body').append($overlay); 4066 $overlay.velocity({ opacity: 1 }, { duration: 300, queue: false, easing: 'easeOutQuad', 4067 complete: function () { 4068 menuOut = true; 4069 panning = false; 4070 } 4071 }); 4072 4073 // Callback 4074 if (typeof options.onOpen === 'function') { 4075 options.onOpen.call(this, menu); 4076 } 4077 } 4078 4079 return false; 4080 }); 4081 }); 4082 }, 4083 destroy: function () { 4084 var $overlay = $('#sidenav-overlay'); 4085 var $dragTarget = $('.drag-target[data-sidenav="' + $(this).attr('data-activates') + '"]'); 4086 $overlay.trigger('click'); 4087 $dragTarget.remove(); 4088 $(this).off('click'); 4089 $overlay.remove(); 4090 }, 4091 show: function () { 4092 this.trigger('click'); 4093 }, 4094 hide: function () { 4095 $('#sidenav-overlay').trigger('click'); 4096 } 4097 }; 4098 4099 $.fn.sideNav = function (methodOrOptions) { 4100 if (methods[methodOrOptions]) { 4101 return methods[methodOrOptions].apply(this, Array.prototype.slice.call(arguments, 1)); 4102 } else if (typeof methodOrOptions === 'object' || !methodOrOptions) { 4103 // Default to "init" 4104 return methods.init.apply(this, arguments); 4105 } else { 4106 $.error('Method ' + methodOrOptions + ' does not exist on jQuery.sideNav'); 4107 } 4108 }; // Plugin end 4109})(jQuery); 4110; /** 4111 * Extend jquery with a scrollspy plugin. 4112 * This watches the window scroll and fires events when elements are scrolled into viewport. 4113 * 4114 * throttle() and getTime() taken from Underscore.js 4115 * https://github.com/jashkenas/underscore 4116 * 4117 * @author Copyright 2013 John Smart 4118 * @license https://raw.github.com/thesmart/jquery-scrollspy/master/LICENSE 4119 * @see https://github.com/thesmart 4120 * @version 0.1.2 4121 */ 4122(function ($) { 4123 4124 var jWindow = $(window); 4125 var elements = []; 4126 var elementsInView = []; 4127 var isSpying = false; 4128 var ticks = 0; 4129 var unique_id = 1; 4130 var offset = { 4131 top: 0, 4132 right: 0, 4133 bottom: 0, 4134 left: 0 4135 4136 /** 4137 * Find elements that are within the boundary 4138 * @param {number} top 4139 * @param {number} right 4140 * @param {number} bottom 4141 * @param {number} left 4142 * @return {jQuery} A collection of elements 4143 */ 4144 };function findElements(top, right, bottom, left) { 4145 var hits = $(); 4146 $.each(elements, function (i, element) { 4147 if (element.height() > 0) { 4148 var elTop = element.offset().top, 4149 elLeft = element.offset().left, 4150 elRight = elLeft + element.width(), 4151 elBottom = elTop + element.height(); 4152 4153 var isIntersect = !(elLeft > right || elRight < left || elTop > bottom || elBottom < top); 4154 4155 if (isIntersect) { 4156 hits.push(element); 4157 } 4158 } 4159 }); 4160 4161 return hits; 4162 } 4163 4164 /** 4165 * Called when the user scrolls the window 4166 */ 4167 function onScroll(scrollOffset) { 4168 // unique tick id 4169 ++ticks; 4170 4171 // viewport rectangle 4172 var top = jWindow.scrollTop(), 4173 left = jWindow.scrollLeft(), 4174 right = left + jWindow.width(), 4175 bottom = top + jWindow.height(); 4176 4177 // determine which elements are in view 4178 var intersections = findElements(top + offset.top + scrollOffset || 200, right + offset.right, bottom + offset.bottom, left + offset.left); 4179 $.each(intersections, function (i, element) { 4180 4181 var lastTick = element.data('scrollSpy:ticks'); 4182 if (typeof lastTick != 'number') { 4183 // entered into view 4184 element.triggerHandler('scrollSpy:enter'); 4185 } 4186 4187 // update tick id 4188 element.data('scrollSpy:ticks', ticks); 4189 }); 4190 4191 // determine which elements are no longer in view 4192 $.each(elementsInView, function (i, element) { 4193 var lastTick = element.data('scrollSpy:ticks'); 4194 if (typeof lastTick == 'number' && lastTick !== ticks) { 4195 // exited from view 4196 element.triggerHandler('scrollSpy:exit'); 4197 element.data('scrollSpy:ticks', null); 4198 } 4199 }); 4200 4201 // remember elements in view for next tick 4202 elementsInView = intersections; 4203 } 4204 4205 /** 4206 * Called when window is resized 4207 */ 4208 function onWinSize() { 4209 jWindow.trigger('scrollSpy:winSize'); 4210 } 4211 4212 /** 4213 * Enables ScrollSpy using a selector 4214 * @param {jQuery|string} selector The elements collection, or a selector 4215 * @param {Object=} options Optional. 4216 throttle : number -> scrollspy throttling. Default: 100 ms 4217 offsetTop : number -> offset from top. Default: 0 4218 offsetRight : number -> offset from right. Default: 0 4219 offsetBottom : number -> offset from bottom. Default: 0 4220 offsetLeft : number -> offset from left. Default: 0 4221 activeClass : string -> Class name to be added to the active link. Default: active 4222 * @returns {jQuery} 4223 */ 4224 $.scrollSpy = function (selector, options) { 4225 var defaults = { 4226 throttle: 100, 4227 scrollOffset: 200, // offset - 200 allows elements near bottom of page to scroll 4228 activeClass: 'active', 4229 getActiveElement: function (id) { 4230 return 'a[href="#' + id + '"]'; 4231 } 4232 }; 4233 options = $.extend(defaults, options); 4234 4235 var visible = []; 4236 selector = $(selector); 4237 selector.each(function (i, element) { 4238 elements.push($(element)); 4239 $(element).data("scrollSpy:id", i); 4240 // Smooth scroll to section 4241 $('a[href="#' + $(element).attr('id') + '"]').click(function (e) { 4242 e.preventDefault(); 4243 var offset = $(Materialize.escapeHash(this.hash)).offset().top + 1; 4244 $('html, body').animate({ scrollTop: offset - options.scrollOffset }, { duration: 400, queue: false, easing: 'easeOutCubic' }); 4245 }); 4246 }); 4247 4248 offset.top = options.offsetTop || 0; 4249 offset.right = options.offsetRight || 0; 4250 offset.bottom = options.offsetBottom || 0; 4251 offset.left = options.offsetLeft || 0; 4252 4253 var throttledScroll = Materialize.throttle(function () { 4254 onScroll(options.scrollOffset); 4255 }, options.throttle || 100); 4256 var readyScroll = function () { 4257 $(document).ready(throttledScroll); 4258 }; 4259 4260 if (!isSpying) { 4261 jWindow.on('scroll', readyScroll); 4262 jWindow.on('resize', readyScroll); 4263 isSpying = true; 4264 } 4265 4266 // perform a scan once, after current execution context, and after dom is ready 4267 setTimeout(readyScroll, 0); 4268 4269 selector.on('scrollSpy:enter', function () { 4270 visible = $.grep(visible, function (value) { 4271 return value.height() != 0; 4272 }); 4273 4274 var $this = $(this); 4275 4276 if (visible[0]) { 4277 $(options.getActiveElement(visible[0].attr('id'))).removeClass(options.activeClass); 4278 if ($this.data('scrollSpy:id') < visible[0].data('scrollSpy:id')) { 4279 visible.unshift($(this)); 4280 } else { 4281 visible.push($(this)); 4282 } 4283 } else { 4284 visible.push($(this)); 4285 } 4286 4287 $(options.getActiveElement(visible[0].attr('id'))).addClass(options.activeClass); 4288 }); 4289 selector.on('scrollSpy:exit', function () { 4290 visible = $.grep(visible, function (value) { 4291 return value.height() != 0; 4292 }); 4293 4294 if (visible[0]) { 4295 $(options.getActiveElement(visible[0].attr('id'))).removeClass(options.activeClass); 4296 var $this = $(this); 4297 visible = $.grep(visible, function (value) { 4298 return value.attr('id') != $this.attr('id'); 4299 }); 4300 if (visible[0]) { 4301 // Check if empty 4302 $(options.getActiveElement(visible[0].attr('id'))).addClass(options.activeClass); 4303 } 4304 } 4305 }); 4306 4307 return selector; 4308 }; 4309 4310 /** 4311 * Listen for window resize events 4312 * @param {Object=} options Optional. Set { throttle: number } to change throttling. Default: 100 ms 4313 * @returns {jQuery} $(window) 4314 */ 4315 $.winSizeSpy = function (options) { 4316 $.winSizeSpy = function () { 4317 return jWindow; 4318 }; // lock from multiple calls 4319 options = options || { 4320 throttle: 100 4321 }; 4322 return jWindow.on('resize', Materialize.throttle(onWinSize, options.throttle || 100)); 4323 }; 4324 4325 /** 4326 * Enables ScrollSpy on a collection of elements 4327 * e.g. $('.scrollSpy').scrollSpy() 4328 * @param {Object=} options Optional. 4329 throttle : number -> scrollspy throttling. Default: 100 ms 4330 offsetTop : number -> offset from top. Default: 0 4331 offsetRight : number -> offset from right. Default: 0 4332 offsetBottom : number -> offset from bottom. Default: 0 4333 offsetLeft : number -> offset from left. Default: 0 4334 * @returns {jQuery} 4335 */ 4336 $.fn.scrollSpy = function (options) { 4337 return $.scrollSpy($(this), options); 4338 }; 4339})(jQuery); 4340;(function ($) { 4341 $(document).ready(function () { 4342 4343 // Function to update labels of text fields 4344 Materialize.updateTextFields = function () { 4345 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'; 4346 $(input_selector).each(function (index, element) { 4347 var $this = $(this); 4348 if ($(element).val().length > 0 || $(element).is(':focus') || element.autofocus || $this.attr('placeholder') !== undefined) { 4349 $this.siblings('label').addClass('active'); 4350 } else if ($(element)[0].validity) { 4351 $this.siblings('label').toggleClass('active', $(element)[0].validity.badInput === true); 4352 } else { 4353 $this.siblings('label').removeClass('active'); 4354 } 4355 }); 4356 }; 4357 4358 // Text based inputs 4359 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'; 4360 4361 // Add active if form auto complete 4362 $(document).on('change', input_selector, function () { 4363 if ($(this).val().length !== 0 || $(this).attr('placeholder') !== undefined) { 4364 $(this).siblings('label').addClass('active'); 4365 } 4366 validate_field($(this)); 4367 }); 4368 4369 // Add active if input element has been pre-populated on document ready 4370 $(document).ready(function () { 4371 Materialize.updateTextFields(); 4372 }); 4373 4374 // HTML DOM FORM RESET handling 4375 $(document).on('reset', function (e) { 4376 var formReset = $(e.target); 4377 if (formReset.is('form')) { 4378 formReset.find(input_selector).removeClass('valid').removeClass('invalid'); 4379 formReset.find(input_selector).each(function () { 4380 if ($(this).attr('value') === '') { 4381 $(this).siblings('label').removeClass('active'); 4382 } 4383 }); 4384 4385 // Reset select 4386 formReset.find('select.initialized').each(function () { 4387 var reset_text = formReset.find('option[selected]').text(); 4388 formReset.siblings('input.select-dropdown').val(reset_text); 4389 }); 4390 } 4391 }); 4392 4393 // Add active when element has focus 4394 $(document).on('focus', input_selector, function () { 4395 $(this).siblings('label, .prefix').addClass('active'); 4396 }); 4397 4398 $(document).on('blur', input_selector, function () { 4399 var $inputElement = $(this); 4400 var selector = ".prefix"; 4401 4402 if ($inputElement.val().length === 0 && $inputElement[0].validity.badInput !== true && $inputElement.attr('placeholder')
4402=== undefined) { 4403 selector += ", label"; 4404 } 4405 4406 $inputElement.siblings(selector).removeClass('active'); 4407 4408 validate_field($inputElement); 4409 }); 4410 4411 window.validate_field = function (object) { 4412 var hasLength = object.attr('data-length') !== undefined; 4413 var lenAttr = parseInt(object.attr('data-length')); 4414 var len = object.val().length; 4415 4416 if (object.val().length === 0 && object[0].validity.badInput === false && !object.is(':required')) { 4417 if (object.hasClass('validate')) { 4418 object.removeClass('valid'); 4419 object.removeClass('invalid'); 4420 } 4421 } else { 4422 if (object.hasClass('validate')) { 4423 // Check for character counter attributes 4424 if (object.is(':valid') && hasLength && len <= lenAttr || object.is(':valid') && !hasLength) { 4425 object.removeClass('invalid'); 4426 object.addClass('valid'); 4427 } else { 4428 object.removeClass('valid'); 4429 object.addClass('invalid'); 4430 } 4431 } 4432 } 4433 }; 4434 4435 // Radio and Checkbox focus class 4436 var radio_checkbox = 'input[type=radio], input[type=checkbox]'; 4437 $(document).on('keyup.radio', radio_checkbox, function (e) { 4438 // TAB, check if tabbing to radio or checkbox. 4439 if (e.which === 9) { 4440 $(this).addClass('tabbed'); 4441 var $this = $(this); 4442 $this.one('blur', function (e) { 4443 4444 $(this).removeClass('tabbed'); 4445 }); 4446 return; 4447 } 4448 }); 4449 4450 // Textarea Auto Resize 4451 var hiddenDiv = $('.hiddendiv').first(); 4452 if (!hiddenDiv.length) { 4453 hiddenDiv = $('<div class="hiddendiv common"></div>'); 4454 $('body').append(hiddenDiv); 4455 } 4456 var text_area_selector = '.materialize-textarea'; 4457 4458 function textareaAutoResize($textarea) { 4459 // Set font properties of hiddenDiv 4460 4461 var fontFamily = $textarea.css('font-family'); 4462 var fontSize = $textarea.css('font-size'); 4463 var lineHeight = $textarea.css('line-height'); 4464 var padding = $textarea.css('padding'); 4465 4466 if (fontSize) { 4467 hiddenDiv.css('font-size', fontSize); 4468 } 4469 if (fontFamily) { 4470 hiddenDiv.css('font-family', fontFamily); 4471 } 4472 if (lineHeight) { 4473 hiddenDiv.css('line-height', lineHeight); 4474 } 4475 if (padding) { 4476 hiddenDiv.css('padding', padding); 4477 } 4478 4479 // Set original-height, if none 4480 if (!$textarea.data('original-height')) { 4481 $textarea.data('original-height', $textarea.height()); 4482 } 4483 4484 if ($textarea.attr('wrap') === 'off') { 4485 hiddenDiv.css('overflow-wrap', 'normal').css('white-space', 'pre'); 4486 } 4487 4488 hiddenDiv.text($textarea.val() + '\n'); 4489 var content = hiddenDiv.html().replace(/\n/g, '<br>'); 4490 hiddenDiv.html(content); 4491 4492 // When textarea is hidden, width goes crazy. 4493 // Approximate with half of window size 4494 4495 if ($textarea.is(':visible')) { 4496 hiddenDiv.css('width', $textarea.width()); 4497 } else { 4498 hiddenDiv.css('width', $(window).width() / 2); 4499 } 4500 4501 /** 4502 * Resize if the new height is greater than the 4503 * original height of the textarea 4504 */ 4505 if ($textarea.data('original-height') <= hiddenDiv.height()) { 4506 $textarea.css('height', hiddenDiv.height()); 4507 } else if ($textarea.val().length < $textarea.data('previous-length')) { 4508 /** 4509 * In case the new height is less than original height, it 4510 * means the textarea has less text than before 4511 * So we set the height to the original one 4512 */ 4513 $textarea.css('height', $textarea.data('original-height')); 4514 } 4515 $textarea.data('previous-length', $textarea.val().length); 4516 } 4517 4518 $(text_area_selector).each(function () { 4519 var $textarea = $(this); 4520 /** 4521 * Instead of resizing textarea on document load, 4522 * store the original height and the original length 4523 */ 4524 $textarea.data('original-height', $textarea.height()); 4525 $textarea.data('previous-length', $textarea.val().length); 4526 }); 4527 4528 $('body').on('keyup keydown autoresize', text_area_selector, function () { 4529 textareaAutoResize($(this)); 4530 }); 4531 4532 // File Input Path 4533 $(document).on('change', '.file-field input[type="file"]', function () { 4534 var file_field = $(this).closest('.file-field'); 4535 var path_input = file_field.find('input.file-path'); 4536 var files = $(this)[0].files; 4537 var file_names = []; 4538 for (var i = 0; i < files.length; i++) { 4539 file_names.push(files[i].name); 4540 } 4541 path_input.val(file_names.join(", ")); 4542 path_input.trigger('change'); 4543 }); 4544 4545 /**************** 4546 * Range Input * 4547 ****************/ 4548 4549 var range_type = 'input[type=range]'; 4550 var range_mousedown = false;
4551 var left; 4552 4553 $(range_type).each(function () { 4554 var thumb = $('<span class="thumb"><span class="value"></span></span>'); 4555 $(this).after(thumb); 4556 }); 4557 4558 var showRangeBubble = function (thumb) { 4559 var paddingLeft = parseInt(thumb.parent().css('padding-left')); 4560 var marginLeft = -7 + paddingLeft + 'px'; 4561 thumb.velocity({ height: "30px", width: "30px", top: "-30px", marginLeft: marginLeft }, { duration: 300, easing: 'easeOutExpo' }); 4562 }; 4563 4564 var calcRangeOffset = function (range) { 4565 var width = range.width() - 15; 4566 var max = parseFloat(range.attr('max')); 4567 var min = parseFloat(range.attr('min')); 4568 var percent = (parseFloat(range.val()) - min) / (max - min); 4569 return percent * width; 4570 }; 4571 4572 var range_wrapper = '.range-field'; 4573 $(document).on('change', range_type, function (e) { 4574 var thumb = $(this).siblings('.thumb'); 4575 thumb.find('.value').html($(this).val()); 4576 4577 if (!thumb.hasClass('active')) { 4578 showRangeBubble(thumb); 4579 } 4580 4581 var offsetLeft = calcRangeOffset($(this)); 4582 thumb.addClass('active').css('left', offsetLeft); 4583 }); 4584 4585 $(document).on('mousedown touchstart', range_type, function (e) { 4586 var thumb = $(this).siblings('.thumb'); 4587 4588 // If thumb indicator does not exist yet, create it 4589 if (thumb.length <= 0) { 4590 thumb = $('<span class="thumb"><span class="value"></span></span>'); 4591 $(this).after(thumb); 4592 } 4593 4594 // Set indicator value 4595 thumb.find('.value').html($(this).val()); 4596 4597 range_mousedown = true; 4598 $(this).addClass('active'); 4599 4600 if (!thumb.hasClass('active')) { 4601 showRangeBubble(thumb); 4602 } 4603 4604 if (e.type !== 'input') { 4605 var offsetLeft = calcRangeOffset($(this)); 4606 thumb.addClass('active').css('left', offsetLeft); 4607 } 4608 }); 4609 4610 $(document).on('mouseup touchend', range_wrapper, function () { 4611 range_mousedown = false; 4612 $(this).removeClass('active'); 4613 }); 4614 4615 $(document).on('input mousemove touchmove', range_wrapper, function (e) { 4616 var thumb = $(this).children('.thumb'); 4617 var left; 4618 var input = $(this).find(range_type); 4619 4620 if (range_mousedown) { 4621 if (!thumb.hasClass('active')) { 4622 showRangeBubble(thumb); 4623 } 4624 4625 var offsetLeft = calcRangeOffset(input); 4626 thumb.addClass('active').css('left', offsetLeft); 4627 thumb.find('.value').html(thumb.siblings(range_type).val()); 4628 } 4629 }); 4630 4631 $(document).on('mouseout touchleave', range_wrapper, function () { 4632 if (!range_mousedown) { 4633 4634 var thumb = $(this).children('.thumb'); 4635 var paddingLeft = parseInt($(this).css('padding-left')); 4636 var marginLeft = 7 + paddingLeft + 'px'; 4637 4638 if (thumb.hasClass('active')) { 4639 thumb.velocity({ height: '0', width: '0', top: '10px', marginLeft: marginLeft }, { duration: 100 }); 4640 } 4641 thumb.removeClass('active'); 4642 } 4643 }); 4644 4645 /************************** 4646 * Auto complete plugin * 4647 *************************/ 4648 $.fn.autocomplete = function (options) { 4649 // Defaults 4650 var defaults = { 4651 data: {}, 4652 limit: Infinity, 4653 onAutocomplete: null, 4654 minLength: 1 4655 }; 4656 4657 options = $.extend(defaults, options); 4658 4659 return this.each(function () { 4660 var $input = $(this); 4661 var data = options.data, 4662 count = 0, 4663 activeIndex = -1, 4664 oldVal, 4665 $inputDiv = $input.closest('.input-field'); // Div to append on 4666 4667 // Check if data isn't empty 4668 if (!$.isEmptyObject(data)) { 4669 var $autocomplete = $('<ul class="autocomplete-content dropdown-content"></ul>'); 4670 var $oldAutocomplete; 4671 4672 // Append autocomplete element. 4673 // Prevent double structure init. 4674 if ($inputDiv.length) { 4675 $oldAutocomplete = $inputDiv.children('.autocomplete-content.dropdown-content').first(); 4676 if (!$oldAutocomplete.length) { 4677 $inputDiv.append($autocomplete); // Set ul in body 4678 } 4679 } else { 4680 $oldAutocomplete = $input.next('.autocomplete-content.dropdown-content'); 4681 if (!$oldAutocomplete.length) { 4682 $input.after($autocomplete); 4683 } 4684 } 4685 if ($oldAutocomplete.length) { 4686 $autocomplete = $oldAutocomplete; 4687 } 4688 4689 // Highlight partial match. 4690 var highlight = function (string, $el) { 4691 var img = $el.find('img'); 4692 var matchStart = $el.text().toLowerCase().indexOf("" + string.toLowerCase() + ""), 4693 matchEnd = matchStart + string.length - 1, 4694 beforeMatch = $el.text().slice(0, matchStart), 4695 matchText = $el.text().slice(matchStart, matchEnd + 1), 4696 afterMatch = $el.text().slice(matchEnd + 1); 4697 $el.html("<span>" + beforeMatch + "<span class='highlight'>" + matchText + "</span>" + afterMatch + "</span>"); 4698 if (img.length) { 4699 $el.prepend(img); 4700 } 4701 }; 4702 4703 // Reset current element position 4704 var resetCurrentElement = function () { 4705 activeIndex = -1; 4706 $autocomplete.find('.active').removeClass('active'); 4707 }; 4708 4709 // Remove autocomplete elements 4710 var removeAutocomplete = function () { 4711 $autocomplete.empty(); 4712 resetCurrentElement(); 4713 oldVal = undefined; 4714 }; 4715 4716 $input.off('blur.autocomplete').on('blur.autocomplete', function () { 4717 removeAutocomplete(); 4718 }); 4719 4720 // Perform search 4721 $input.off('keyup.autocomplete focus.autocomplete').on('keyup.autocomplete focus.autocomplete', function (e) { 4722 // Reset count. 4723 count = 0; 4724 var val = $input.val().toLowerCase(); 4725 4726 // Don't capture enter or arrow key usage. 4727 if (e.which === 13 || e.which === 38 || e.which === 40) { 4728 return; 4729 } 4730 4731 // Check if the input isn't empty 4732 if (oldVal !== val) { 4733 removeAutocomplete(); 4734 4735 if (val.length >= options.minLength) { 4736 for (var key in data) { 4737 if (data.hasOwnProperty(key) && key.toLowerCase().indexOf(val) !== -1) { 4738 // Break if past limit 4739 if (count >= options.limit) { 4740 break; 4741 } 4742 4743 var autocompleteOption = $('<li></li>'); 4744 if (!!data[key]) { 4745 autocompleteOption.append('<img src="' + data[key] + '" class="right circle"><span>' + key + '</span>'); 4746 } else { 4747 autocompleteOption.append('<span>' + key + '</span>'); 4748 } 4749 4750 $autocomplete.append(autocompleteOption); 4751 highlight(val, autocompleteOption); 4752 count++; 4753 } 4754 } 4755 } 4756 } 4757 4758 // Update oldVal 4759 oldVal = val; 4760 }); 4761 4762 $input.off('keydown.autocomplete').on('keydown.autocomplete', function (e) { 4763 // Arrow keys and enter key usage 4764 var keyCode = e.which, 4765 liElement, 4766 numItems = $autocomplete.children('li').length, 4767 $active = $autocomplete.children('.active').first(); 4768 4769 // select element on Enter 4770 if (keyCode === 13 && activeIndex >= 0) { 4771 liElement = $autocomplete.children('li').eq(activeIndex); 4772 if (liElement.length) { 4773 liElement.trigger('mousedown.autocomplete'); 4774 e.preventDefault(); 4775 } 4776 return; 4777 } 4778 4779 // Capture up and down key 4780 if (keyCode === 38 || keyCode === 40) { 4781 e.preventDefault(); 4782 4783 if (keyCode === 38 && activeIndex > 0) { 4784 activeIndex--; 4785 } 4786 4787 if (keyCode === 40 && activeIndex < numItems - 1) { 4788 activeIndex++; 4789 } 4790 4791 $active.removeClass('active'); 4792 if (activeIndex >= 0) { 4793 $autocomplete.children('li').eq(activeIndex).addClass('active'); 4794 } 4795 } 4796 }); 4797 4798 // Set input value 4799 $autocomplete.off('mousedown.autocomplete touchstart.autocomplete').on('mousedown.autocomplete touchstart.autocomplete', 'li', function () { 4800 var text = $(this).text().trim(); 4801 $input.val(text); 4802 $input.trigger('change'); 4803 removeAutocomplete(); 4804 4805 // Handle onAutocomplete callback. 4806 if (typeof options.onAutocomplete === "function") { 4807 options.onAutocomplete.call(this, text); 4808 } 4809 }); 4810 4811 // Empty data 4812 } else { 4813 $input.off('keyup.autocomplete focus.autocomplete'); 4814 } 4815 }); 4816 }; 4817 }); // End of $(document).ready 4818 4819 /******************* 4820 * Select Plugin * 4821 ******************/ 4822 $.fn.material_select = function (callback) { 4823 $(this).each(function () { 4824 var $select = $(this); 4825 4826 if ($select.hasClass('browser-default')) { 4827 return; // Continue to next (return false breaks out of entire loop) 4828 } 4829 4830 var multiple = $select.attr('multiple') ? true : false, 4831 lastID = $select.attr('data-select-id'); // Tear down structure if Select needs to be rebuilt 4832 4833 if (lastID) { 4834 $select.parent().find('span.caret').remove(); 4835 $select.parent().find('input').remove(); 4836 4837 $select.unwrap(); 4838 $('ul#select-options-' + lastID).remove(); 4839 } 4840 4841 // If destroying the select, remove the selelct-id and reset it to it's uninitialized state. 4842 if (callback === 'destroy') { 4843 $select.removeAttr('data-select-id').removeClass('initialized'); 4844 $(window).off('click.select'); 4845 return; 4846 } 4847 4848 var uniqueID = Materialize.guid(); 4849 $select.attr('data-select-id', uniqueID);
4850 var wrapper = $('<div class="select-wrapper"></div>'); 4851 wrapper.addClass($select.attr('class')); 4852 if ($select.is(':disabled')) wrapper.addClass('disabled'); 4853 var options = $('<ul id="select-options-' + uniqueID + '" class="dropdown-content select-dropdown ' + (multiple ? 'multiple-select-dropdown' : '') + '"></ul>'), 4854 selectChildren = $select.children('option, optgroup'), 4855 valuesSelected = [], 4856 optionsHover = false; 4857 4858 var label = $select.find('option:selected').html() || $select.find('option:first').html() || ""; 4859 4860 // Function that renders and appends the option taking into 4861 // account type and possible image icon. 4862 var appendOptionWithIcon = function (select, option, type) { 4863 // Add disabled attr if disabled 4864 var disabledClass = option.is(':disabled') ? 'disabled ' : ''; 4865 var optgroupClass = type === 'optgroup-option' ? 'optgroup-option ' : ''; 4866 var multipleCheckbox = multiple ? '<input type="checkbox"' + disabledClass + '/><label></label>' : ''; 4867 4868 // add icons 4869 var icon_url = option.data('icon'); 4870 var classes = option.attr('class'); 4871 if (!!icon_url) { 4872 var classString = ''; 4873 if (!!classes) classString = ' class="' + classes + '"'; 4874 4875 // Check for multiple type. 4876 options.append($('<li class="' + disabledClass + optgroupClass + '"><img alt="" src="' + icon_url + '"' + classString + '><span>' + multipleCheckbox + option.html() + '</span></li>')); 4877 return true; 4878 } 4879 4880 // Check for multiple type. 4881 options.append($('<li class="' + disabledClass + optgroupClass + '"><span>' + multipleCheckbox + option.html() + '</span></li>')); 4882 }; 4883 4884 /* Create dropdown structure. */ 4885 if (selectChildren.length) { 4886 selectChildren.each(function () { 4887 if ($(this).is('option')) { 4888 // Direct descendant option. 4889 if (multiple) { 4890 appendOptionWithIcon($select, $(this), 'multiple'); 4891 } else { 4892 appendOptionWithIcon($select, $(this)); 4893 } 4894 } else if ($(this).is('optgroup')) { 4895 // Optgroup. 4896 var selectOptions = $(this).children('option'); 4897 options.append($('<li class="optgroup"><span>' + $(this).attr('label') + '</span></li>')); 4898 4899 selectOptions.each(function () { 4900 appendOptionWithIcon($select, $(this), 'optgroup-option'); 4901 }); 4902 } 4903 }); 4904 } 4905 4906 options.find('li:not(.optgroup)').each(function (i) { 4907 $(this).click(function (e) { 4908 // Check if option element is disabled 4909 if (!$(this).hasClass('disabled') && !$(this).hasClass('optgroup')) { 4910 var selected = true; 4911 4912 if (multiple) { 4913 $('input[type="checkbox"]', this).prop('checked', function (i, v) { 4914 return !v; 4915 }); 4916 selected = toggleEntryFromArray(valuesSelected, i, $select); 4917 $newSelect.trigger('focus'); 4918 } else { 4919 options.find('li').removeClass('active'); 4920 $(this).toggleClass('active'); 4921 $newSelect.val($(this).text()); 4922 } 4923 4924 activateOption(options, $(this)); 4925 $select.find('option').eq(i).prop('selected', selected); 4926 // Trigger onchange() event 4927 $select.trigger('change'); 4928 if (typeof callback !== 'undefined') callback(); 4929 } 4930 4931 e.stopPropagation(); 4932 }); 4933 }); 4934 4935 // Wrap Elements 4936 $select.wrap(wrapper); 4937 // Add Select Display Element 4938 var dropdownIcon = $('<span class="caret">▼</span>'); 4939 4940 // escape double quotes 4941 var sanitizedLabelHtml = label.replace(/"/g, '"'); 4942 4943 var $newSelect = $('<input type="text" class="select-dropdown" readonly="true" ' + ($select.is(':disabled') ? 'disabled' : '') + ' data-activates="select-options-' + uniqueID + '" value="' + sanitizedLabelHtml + '"/>'); 4944 $select.before($newSelect); 4945 $newSelect.before(dropdownIcon); 4946 4947 $newSelect.after(options); 4948 // Check if section element is disabled 4949 if (!$select.is(':disabled')) { 4950 $newSelect.dropdown({ 'hover': false }); 4951 } 4952 4953 // Copy tabindex 4954 if ($select.attr('tabindex')) { 4955 $($newSelect[0]).attr('tabindex', $select.attr('tabindex')); 4956 } 4957 4958 $select.addClass('initialized'); 4959 4960 $newSelect.on({
4961 'focus': function () { 4962 if ($('ul.select-dropdown').not(options[0]).is(':visible')) { 4963 $('input.select-dropdown').trigger('close'); 4964 $(window).off('click.select'); 4965 } 4966 if (!options.is(':visible')) { 4967 $(this).trigger('open', ['focus']); 4968 var label = $(this).val(); 4969 if (multiple && label.indexOf(',') >= 0) { 4970 label = label.split(',')[0]; 4971 } 4972 4973 var selectedOption = options.find('li').filter(function () { 4974 return $(this).text().toLowerCase() === label.toLowerCase(); 4975 })[0]; 4976 activateOption(options, selectedOption, true); 4977 4978 $(window).off('click.select').on('click.select', function () { 4979 multiple && (optionsHover || $newSelect.trigger('close')); 4980 $(window).off('click.select'); 4981 }); 4982 } 4983 }, 4984 'click': function (e) { 4985 e.stopPropagation(); 4986 } 4987 }); 4988 4989 $newSelect.on('blur', function () { 4990 if (!multiple) { 4991 $(this).trigger('close'); 4992 $(window).off('click.select'); 4993 } 4994 options.find('li.selected').removeClass('selected'); 4995 }); 4996 4997 options.hover(function () { 4998 optionsHover = true; 4999 }, function () { 5000 optionsHover = false; 5001 }); 5002 5003 // Add initial multiple selections. 5004 if (multiple) { 5005 $select.find("option:selected:not(:disabled)").each(function () { 5006 var index = this.index; 5007 5008 toggleEntryFromArray(valuesSelected, index, $select); 5009 options.find("li:not(.optgroup)").eq(index).find(":checkbox").prop("checked", true); 5010 }); 5011 } 5012 5013 /** 5014 * Make option as selected and scroll to selected position 5015 * @param {jQuery} collection Select options jQuery element 5016 * @param {Element} newOption element of the new option 5017 * @param {Boolean} firstActivation If on first activation of select 5018 */ 5019 var activateOption = function (collection, newOption, firstActivation) { 5020 if (newOption) { 5021 collection.find('li.selected').removeClass('selected'); 5022 var option = $(newOption); 5023 option.addClass('selected'); 5024 if (!multiple || !!firstActivation) { 5025 options.scrollTo(option); 5026 } 5027 } 5028 }; 5029 5030 // Allow user to search by typing 5031 // this array is cleared after 1 second 5032 var filterQuery = [], 5033 onKeyDown = function (e) { 5034 // TAB - switch to another input 5035 if (e.which == 9) { 5036 $newSelect.trigger('close'); 5037 return; 5038 } 5039 5040 // ARROW DOWN WHEN SELECT IS CLOSED - open select options 5041 if (e.which == 40 && !options.is(':visible')) { 5042 $newSelect.trigger('open'); 5043 return; 5044 } 5045 5046 // ENTER WHEN SELECT IS CLOSED - submit form 5047 if (e.which == 13 && !options.is(':visible')) { 5048 return; 5049 } 5050 5051 e.preventDefault(); 5052 5053 // CASE WHEN USER TYPE LETTERS 5054 var letter = String.fromCharCode(e.which).toLowerCase(), 5055 nonLetters = [9, 13, 27, 38, 40]; 5056 if (letter && nonLetters.indexOf(e.which) === -1) { 5057 filterQuery.push(letter); 5058 5059 var string = filterQuery.join(''), 5060 newOption = options.find('li').filter(function () { 5061 return $(this).text().toLowerCase().indexOf(string) === 0; 5062 })[0]; 5063 5064 if (newOption) { 5065 activateOption(options, newOption); 5066 } 5067 } 5068 5069 // ENTER - select option and close when select options are opened 5070 if (e.which == 13) { 5071 var activeOption = options.find('li.selected:not(.disabled)')[0]; 5072 if (activeOption) { 5073 $(activeOption).trigger('click'); 5074 if (!multiple) { 5075 $newSelect.trigger('close'); 5076 } 5077 } 5078 } 5079 5080 // ARROW DOWN - move to next not disabled option 5081 if (e.which == 40) { 5082 if (options.find('li.selected').length) { 5083 newOption = options.find('li.selected').next('li:not(.disabled)')[0]; 5084 } else { 5085 newOption = options.find('li:not(.disabled)')[0]; 5086 } 5087 activateOption(options, newOption); 5088 } 5089 5090 // ESC - close options 5091 if (e.which == 27) { 5092 $newSelect.trigger('close'); 5093 } 5094 5095 // ARROW UP - move to previous not disabled option 5096 if (e.which == 38) { 5097 newOption = options.find('li.selected').prev('li:not(.disabled)')[0]; 5098 if (newOption) activateOption(options, newOption); 5099 } 5100 5101 // Automaticaly clean filter query so user can search again by starting letters 5102 setTimeout(function () { 5103 filterQuery = []; 5104 }, 1000); 5105 }; 5106
5107 $newSelect.on('keydown', onKeyDown); 5108 }); 5109 5110 function toggleEntryFromArray(entriesArray, entryIndex, select) { 5111 var index = entriesArray.indexOf(entryIndex), 5112 notAdded = index === -1; 5113 5114 if (notAdded) { 5115 entriesArray.push(entryIndex); 5116 } else { 5117 entriesArray.splice(index, 1); 5118 } 5119 5120 select.siblings('ul.dropdown-content').find('li:not(.optgroup)').eq(entryIndex).toggleClass('active'); 5121 5122 // use notAdded instead of true (to detect if the option is selected or not) 5123 select.find('option').eq(entryIndex).prop('selected', notAdded); 5124 setValueToInput(entriesArray, select); 5125 5126 return notAdded; 5127 } 5128 5129 function setValueToInput(entriesArray, select) { 5130 var value = ''; 5131 5132 for (var i = 0, count = entriesArray.length; i < count; i++) { 5133 var text = select.find('option').eq(entriesArray[i]).text(); 5134 5135 i === 0 ? value += text : value += ', ' + text; 5136 } 5137 5138 if (value === '') { 5139 value = select.find('option:disabled').eq(0).text(); 5140 } 5141 5142 select.siblings('input.select-dropdown').val(value); 5143 } 5144 }; 5145})(jQuery); 5146;(function ($) { 5147 5148 var methods = { 5149 5150 init: function (options) { 5151 var defaults = { 5152 indicators: true, 5153 height: 400, 5154 transition: 500, 5155 interval: 6000 5156 }; 5157 options = $.extend(defaults, options); 5158 5159 return this.each(function () { 5160 5161 // For each slider, we want to keep track of 5162 // which slide is active and its associated content 5163 var $this = $(this); 5164 var $slider = $this.find('ul.slides').first(); 5165 var $slides = $slider.find('> li'); 5166 var $active_index = $slider.find('.active').index(); 5167 var $active, $indicators, $interval; 5168 if ($active_index != -1) { 5169 $active = $slides.eq($active_index); 5170 } 5171 5172 // Transitions the caption depending on alignment 5173 function captionTransition(caption, duration) { 5174 if (caption.hasClass("center-align")) { 5175 caption.velocity({ opacity: 0, translateY: -100 }, { duration: duration, queue: false }); 5176 } else if (caption.hasClass("right-align")) { 5177 caption.velocity({ opacity: 0, translateX: 100 }, { duration: duration, queue: false }); 5178 } else if (caption.hasClass("left-align")) { 5179 caption.velocity({ opacity: 0, translateX: -100 }, { duration: duration, queue: false }); 5180 } 5181 } 5182 5183 // This function will transition the slide to any index of the next slide 5184 function moveToSlide(index) { 5185 // Wrap around indices. 5186 if (index >= $slides.length) index = 0;else if (index < 0) index = $slides.length - 1; 5187 5188 $active_index = $slider.find('.active').index(); 5189 5190 // Only do if index changes 5191 if ($active_index != index) { 5192 $active = $slides.eq($active_index); 5193 $caption = $active.find('.caption'); 5194 5195 $active.removeClass('active'); 5196 $active.velocity({ opacity: 0 }, { duration: options.transition, queue: false, easing: 'easeOutQuad', 5197 complete: function () { 5198 $slides.not('.active').velocity({ opacity: 0, translateX: 0, translateY: 0 }, { duration: 0, queue: false }); 5199 } }); 5200 captionTransition($caption, options.transition); 5201 5202 // Update indicators 5203 if (options.indicators) { 5204 $indicators.eq($active_index).removeClass('active'); 5205 } 5206 5207 $slides.eq(index).velocity({ opacity: 1 }, { duration: options.transition, queue: false, easing: 'easeOutQuad' }); 5208 $slides.eq(index).find('.caption').velocity({ opacity: 1, translateX: 0, translateY: 0 }, { duration: options.transition, delay: options.transition, queue: false, easing: 'easeOutQuad' }); 5209 $slides.eq(index).addClass('active'); 5210 5211 // Update indicators 5212 if (options.indicators) { 5213 $indicators.eq(index).addClass('active'); 5214 } 5215 } 5216 } 5217 5218 // Set height of slider 5219 // If fullscreen, do nothing 5220 if (!$this.hasClass('fullscreen')) { 5221 if (options.indicators) { 5222 // Add height if indicators are present 5223 $this.height(options.height + 40); 5224 } else { 5225 $this.height(options.height); 5226 } 5227 $slider.height(options.height); 5228 } 5229 5230 // Set initial positions of captions 5231 $slides.find('.caption').each(function () { 5232 captionTransition($(this), 0); 5233 }); 5234 5235 // Move img src into background-image 5236 $slides.find('img').each(function () { 5237 var placeholderBase64 = 'data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='; 5238 if ($(this).attr('src') !== placeholderBase64) { 5239 $(this).css('background-image', 'url("' + $(this).attr('src') + '")'); 5240 $(this).attr('src', placeholderBase64); 5241 } 5242 }); 5243 5244 // dynamically add indicators 5245 if (options.indicators) { 5246 $indicators = $('<ul class="indicators"></ul>'); 5247 $slides.each(function (index) { 5248 var $indicator = $('<li class="indicator-item"></li>'); 5249 5250 // Handle clicks on indicators 5251 $indicator.click(function () { 5252 var $parent = $slider.parent(); 5253 var curr_index = $parent.find($(this)).index(); 5254 moveToSlide(curr_index); 5255 5256 // reset interval 5257 clearInterval($interval); 5258 $interval = setInterval(function () { 5259 $active_index = $slider.find('.active').index(); 5260 if ($slides.length == $active_index + 1) $active_index = 0; // loop to start 5261 else $active_index += 1; 5262 5263 moveToSlide($active_index); 5264 }, options.transition + options.interval); 5265 }); 5266 $indicators.append($indicator); 5267 }); 5268 $this.append($indicators); 5269 $indicators = $this.find('ul.indicators').find('li.indicator-item'); 5270 } 5271 5272 if ($active) { 5273 $active.show(); 5274 } else { 5275 $slides.first().addClass('active').velocity({ opacity: 1 }, { duration: options.transition, queue: false, easing: 'easeOutQuad' }); 5276 5277 $active_index = 0; 5278 $active = $slides.eq($active_index); 5279 5280 // Update indicators 5281 if (options.indicators) { 5282 $indicators.eq($active_index).addClass('active'); 5283 } 5284 } 5285 5286 // Adjust height to current slide 5287 $active.find('img').each(function () { 5288 $active.find('.caption').velocity({ opacity: 1, translateX: 0, translateY: 0 }, { duration: options.transition, queue: false, easing: 'easeOutQuad' }); 5289 }); 5290 5291 // auto scroll 5292 $interval = setInterval(function () { 5293 $active_index = $slider.find('.active').index(); 5294 moveToSlide($active_index + 1); 5295 }, options.transition + options.interval); 5296 5297 // HammerJS, Swipe navigation 5298 5299 // Touch Event 5300 var panning = false;
5301 var swipeLeft = false; 5302 var swipeRight = false; 5303 5304 $this.hammer({ 5305 prevent_default: false 5306 }).on('pan', function (e) { 5307 if (e.gesture.pointerType === "touch") { 5308 5309 // reset interval 5310 clearInterval($interval); 5311 5312 var direction = e.gesture.direction; 5313 var x = e.gesture.deltaX; 5314 var velocityX = e.gesture.velocityX; 5315 var velocityY = e.gesture.velocityY; 5316 5317 $curr_slide = $slider.find('.active'); 5318 if (Math.abs(velocityX) > Math.abs(velocityY)) { 5319 $curr_slide.velocity({ translateX: x 5320 }, { duration: 50, queue: false, easing: 'easeOutQuad' }); 5321 } 5322 5323 // Swipe Left 5324 if (direction === 4 && (x > $this.innerWidth() / 2 || velocityX < -0.65)) { 5325 swipeRight = true; 5326 } 5327 // Swipe Right 5328 else if (direction === 2 && (x < -1 * $this.innerWidth() / 2 || velocityX > 0.65)) { 5329 swipeLeft = true; 5330 } 5331 5332 // Make Slide Behind active slide visible 5333 var next_slide; 5334 if (swipeLeft) { 5335 next_slide = $curr_slide.next(); 5336 if (next_slide.length === 0) { 5337 next_slide = $slides.first(); 5338 } 5339 next_slide.velocity({ opacity: 1 5340 }, { duration: 300, queue: false, easing: 'easeOutQuad' }); 5341 } 5342 if (swipeRight) { 5343 next_slide = $curr_slide.prev(); 5344 if (next_slide.length === 0) { 5345 next_slide = $slides.last(); 5346 } 5347 next_slide.velocity({ opacity: 1 5348 }, { duration: 300, queue: false, easing: 'easeOutQuad' }); 5349 } 5350 } 5351 }).on('panend', function (e) { 5352 if (e.gesture.pointerType === "touch") { 5353 5354 $curr_slide = $slider.find('.active'); 5355 panning = false; 5356 curr_index = $slider.find('.active').index(); 5357 5358 if (!swipeRight && !swipeLeft || $slides.length <= 1) { 5359 // Return to original spot 5360 $curr_slide.velocity({ translateX: 0 5361 }, { duration: 300, queue: false, easing: 'easeOutQuad' }); 5362 } else if (swipeLeft) { 5363 moveToSlide(curr_index + 1); 5364 $curr_slide.velocity({ translateX: -1 * $this.innerWidth() }, { duration: 300, queue: false, easing: 'easeOutQuad', 5365 complete: function () { 5366 $curr_slide.velocity({ opacity: 0, translateX: 0 }, { duration: 0, queue: false }); 5367 } }); 5368 } else if (swipeRight) { 5369 moveToSlide(curr_index - 1); 5370 $curr_slide.velocity({ translateX: $this.innerWidth() }, { duration: 300, queue: false, easing: 'easeOutQuad', 5371 complete: function () { 5372 $curr_slide.velocity({ opacity: 0, translateX: 0 }, { duration: 0, queue: false }); 5373 } }); 5374 } 5375 swipeLeft = false; 5376 swipeRight = false; 5377 5378 // Restart interval 5379 clearInterval($interval); 5380 $interval = setInterval(function () { 5381 $active_index = $slider.find('.active').index(); 5382 if ($slides.length == $active_index + 1) $active_index = 0; // loop to start 5383 else $active_index += 1; 5384 5385 moveToSlide($active_index); 5386 }, options.transition + options.interval); 5387 } 5388 }); 5389 5390 $this.on('sliderPause', function () { 5391 clearInterval($interval); 5392 }); 5393 5394 $this.on('sliderStart', function () { 5395 clearInterval($interval); 5396 $interval = setInterval(function () { 5397 $active_index = $slider.find('.active').index(); 5398 if ($slides.length == $active_index + 1) $active_index = 0; // loop to start 5399 else $active_index += 1; 5400 5401 moveToSlide($active_index); 5402 }, options.transition + options.interval); 5403 }); 5404 5405 $this.on('sliderNext', function () { 5406 $active_index = $slider.find('.active').index(); 5407 moveToSlide($active_index + 1); 5408 }); 5409 5410 $this.on('sliderPrev', function () { 5411 $active_index = $slider.find('.active').index(); 5412 moveToSlide($active_index - 1); 5413 }); 5414 }); 5415 }, 5416 pause: function () { 5417 $(this).trigger('sliderPause'); 5418 }, 5419 start: function () { 5420 $(this).trigger('sliderStart'); 5421 }, 5422 next: function () { 5423 $(this).trigger('sliderNext'); 5424 }, 5425 prev: function () { 5426 $(this).trigger('sliderPrev'); 5427 } 5428 }; 5429 5430 $.fn.slider = function (methodOrOptions) { 5431 if (methods[methodOrOptions]) { 5432 return methods[methodOrOptions].apply(this, Array.prototype.slice.call(arguments, 1)); 5433 } else if (typeof methodOrOptions === 'object' || !methodOrOptions) { 5434 // Default to "init" 5435 return methods.init.apply(this, arguments); 5436 } else { 5437 $.error('Method ' + methodOrOptions + ' does not exist on jQuery.tooltip'); 5438 } 5439 }; // Plugin end 5440})(jQuery); 5441;(function ($) { 5442 $(document).ready(function () { 5443 5444 $(document).on('click.card', '.card', function (e) { 5445 if ($(this).find('> .card-reveal').length) { 5446 var $card = $(e.target).closest('.card'); 5447 if ($card.data('initialOverflow') === undefined) { 5448 $card.data('initialOverflow', $card.css('overflow') === undefined ? '' : $card.css('overflow')); 5449 } 5450 if ($(e.target).is($('.card-reveal .card-title')) || $(e.target).is($('.card-reveal .card-title i'))) { 5451 // Make Reveal animate down and display none 5452 $(this).find('.card-reveal').velocity({ translateY: 0 }, { 5453 duration: 225, 5454 queue: false, 5455 easing: 'easeInOutQuad', 5456 complete: function () { 5457 $(this).css({ display: 'none' }); 5458 $card.css('overflow', $card.data('initialOverflow')); 5459 } 5460 }); 5461 } else if ($(e.target).is($('.card .activator')) || $(e.target).is($('.card .activator i'))) { 5462 $card.css('overflow', 'hidden'); 5463 $(this).find('.card-reveal').css({ display: 'block' }).velocity("stop", false).velocity({ translateY: '-100%' }, { duration: 300, queue: false, easing: 'easeInOutQuad' }); 5464 } 5465 } 5466 }); 5467 }); 5468})(jQuery); 5469;(function ($) { 5470 var materialChipsDefaults = { 5471 data: [], 5472 placeholder: '', 5473 secondaryPlaceholder: '', 5474 autocompleteOptions: {} 5475 }; 5476 5477 $(document).ready(function () { 5478 // Handle removal of static chips. 5479 $(document).on('click', '.chip .close', function (e) { 5480 var $chips = $(this).closest('.chips'); 5481 if ($chips.attr('data-initialized')) { 5482 return; 5483 } 5484 $(this).closest('.chip').remove(); 5485 }); 5486 }); 5487 5488 $.fn.material_chip = function (options) { 5489 var self = this; 5490 this.$el = $(this); 5491 this.$document = $(document); 5492 this.SELS = { 5493 CHIPS: '.chips', 5494 CHIP: '.chip', 5495 INPUT: 'input', 5496 DELETE: '.material-icons', 5497 SELECTED_CHIP: '.selected' 5498 }; 5499 5500 if ('data' === options) { 5501 return this.$el.data('chips'); 5502 } 5503 5504 var curr_options = $.extend({}, materialChipsDefaults, options); 5505 self.hasAutocomplete = !$.isEmptyObject(curr_options.autocompleteOptions.data); 5506 5507 // Initialize 5508 this.init = function () { 5509 var i = 0; 5510 var chips; 5511 self.$el.each(function () { 5512 var $chips = $(this); 5513 var chipId = Materialize.guid(); 5514 self.chipId = chipId; 5515 5516 if (!curr_options.data || !(curr_options.data instanceof Array)) { 5517 curr_options.data = []; 5518 } 5519 $chips.data('chips', curr_options.data); 5520 $chips.attr('data-index', i); 5521 $chips.attr('data-initialized', true); 5522 5523 if (!$chips.hasClass(self.SELS.CHIPS)) { 5524 $chips.addClass('chips'); 5525 } 5526 5527 self.chips($chips, chipId); 5528 i++; 5529 }); 5530 }; 5531 5532 this.handleEvents = function () { 5533 var SELS = self.SELS; 5534 5535 self.$document.off('click.chips-focus', SELS.CHIPS).on('click.chips-focus', SELS.CHIPS, function (e) { 5536 $(e.target).find(SELS.INPUT).focus(); 5537 }); 5538 5539 self.$document.off('click.chips-select', SELS.CHIP).on('click.chips-select', SELS.CHIP, function (e) { 5540 var $chip = $(e.target); 5541 if ($chip.length) { 5542 var wasSelected = $chip.hasClass('selected'); 5543 var $chips = $chip.closest(SELS.CHIPS); 5544 $(SELS.CHIP).removeClass('selected'); 5545 5546 if (!wasSelected) { 5547 self.selectChip($chip.index(), $chips); 5548 } 5549 } 5550 }); 5551 5552 self.$document.off('keydown.chips').on('keydown.chips', function (e) { 5553 if ($(e.target).is('input, textarea')) { 5554 return; 5555 } 5556 5557 // delete 5558 var $chip = self.$document.find(SELS.CHIP + SELS.SELECTED_CHIP); 5559 var $chips = $chip.closest(SELS.CHIPS); 5560 var length = $chip.siblings(SELS.CHIP).length; 5561 var index; 5562 5563 if (!$chip.length) { 5564 return; 5565 } 5566 5567 if (e.which === 8 || e.which === 46) { 5568 e.preventDefault(); 5569 5570 index = $chip.index(); 5571 self.deleteChip(index, $chips); 5572 5573 var selectIndex = null; 5574 if (index + 1 < length) { 5575 selectIndex = index; 5576 } else if (index === length || index + 1 === length) { 5577 selectIndex = length - 1; 5578 } 5579 5580 if (selectIndex < 0) selectIndex = null; 5581 5582 if (null !== selectIndex) { 5583 self.selectChip(selectIndex, $chips); 5584 } 5585 if (!length) $chips.find('input').focus(); 5586 5587 // left 5588 } else if (e.which === 37) { 5589 index = $chip.index() - 1; 5590 if (index < 0) { 5591 return; 5592 } 5593 $(SELS.CHIP).removeClass('selected'); 5594 self.selectChip(index, $chips); 5595 5596 // right 5597 } else if (e.which === 39) { 5598 index = $chip.index() + 1; 5599 $(SELS.CHIP).removeClass('selected'); 5600 if (index > length) { 5601 $chips.find('input').focus(); 5602 return; 5603 } 5604 self.selectChip(index, $chips); 5605 } 5606 }); 5607 5608 self.$document.off('focusin.chips', SELS.CHIPS + ' ' + SELS.INPUT).on('focusin.chips', SELS.CHIPS + ' ' + SELS.INPUT, function (e) { 5609 var $currChips = $(e.target).closest(SELS.CHIPS); 5610 $currChips.addClass('focus'); 5611 $currChips.siblings('label, .prefix').addClass('active'); 5612 $(SELS.CHIP).removeClass('selected'); 5613 }); 5614 5615 self.$document.off('focusout.chips', SELS.CHIPS + ' ' + SELS.INPUT).on('focusout.chips', SELS.CHIPS + ' ' + SELS.INPUT, function (e) { 5616 var $currChips = $(e.target).closest(SELS.CHIPS); 5617 $currChips.removeClass('focus'); 5618 5619 // Remove active if empty 5620 if ($currChips.data('chips') === undefined || !$currChips.data('chips').length) { 5621 $currChips.siblings('label').removeClass('active'); 5622 } 5623 $currChips.siblings('.prefix').removeClass('active'); 5624 }); 5625 5626 self.$document.off('keydown.chips-add', SELS.CHIPS + ' ' + SELS.INPUT).on('keydown.chips-add', SELS.CHIPS + ' ' + SELS.INPUT, function (e) { 5627 var $target = $(e.target); 5628 var $chips = $target.closest(SELS.CHIPS); 5629 var chipsLength = $chips.children(SELS.CHIP).length; 5630 5631 // enter 5632 if (13 === e.which) { 5633 // Override enter if autocompleting. 5634 if (self.hasAutocomplete && $chips.find('.autocomplete-content.dropdown-content').length && $chips.find('.autocomplete-content.dropdown-content').children().length) { 5635 return; 5636 } 5637 5638 e.preventDefault(); 5639 self.addChip({ tag: $target.val() }, $chips); 5640 $target.val(''); 5641 return; 5642 } 5643 5644 // delete or left 5645 if ((8 === e.keyCode || 37 === e.keyCode) && '' === $target.val() && chipsLength) { 5646 e.preventDefault(); 5647 self.selectChip(chipsLength - 1, $chips); 5648 $target.blur(); 5649 return; 5650 } 5651 }); 5652 5653 // Click on delete icon in chip. 5654 self.$document.off('click.chips-delete', SELS.CHIPS + ' ' + SELS.DELETE).on('click.chips-delete', SELS.CHIPS + ' ' + SELS.DELETE, function (e) { 5655 var $target = $(e.target); 5656 var $chips = $target.closest(SELS.CHIPS); 5657 var $chip = $target.closest(SELS.CHIP); 5658 e.stopPropagation(); 5659 self.deleteChip($chip.index(), $chips); 5660 $chips.find('input').focus(); 5661 }); 5662 }; 5663 5664 this.chips = function ($chips, chipId) { 5665 $chips.empty(); 5666 $chips.data('chips').forEach(function (elem) { 5667 $chips.append(self.renderChip(elem)); 5668 }); 5669 $chips.append($('<input id="' + chipId + '" class="input" placeholder="">')); 5670 self.setPlaceholder($chips); 5671 5672 // Set for attribute for label 5673 var label = $chips.next('label'); 5674 if (label.length) { 5675 label.attr('for', chipId); 5676 5677 if ($chips.data('chips') !== undefined && $chips.data('chips').length) { 5678 label.addClass('active'); 5679 } 5680 } 5681 5682 // Setup autocomplete if needed. 5683 var input = $('#' + chipId); 5684 if (self.hasAutocomplete) { 5685 curr_options.autocompleteOptions.onAutocomplete = function (val) { 5686 self.addChip({ tag: val }, $chips); 5687 input.val(''); 5688 input.focus(); 5689 }; 5690 input.autocomplete(curr_options.autocompleteOptions); 5691 } 5692 }; 5693 5694 /**
5695 * Render chip jQuery element. 5696 * @param {Object} elem 5697 * @return {jQuery} 5698 */ 5699 this.renderChip = function (elem) { 5700 if (!elem.tag) return; 5701 5702 var $renderedChip = $('<div class="chip"></div>'); 5703 $renderedChip.text(elem.tag); 5704 if (elem.image) { 5705 $renderedChip.prepend($('<img />').attr('src', elem.image)); 5706 } 5707 $renderedChip.append($('<i class="material-icons close">close</i>')); 5708 return $renderedChip; 5709 }; 5710 5711 this.setPlaceholder = function ($chips) { 5712 if ($chips.data('chips') !== undefined && !$chips.data('chips').length && curr_options.placeholder) { 5713 $chips.find('input').prop('placeholder', curr_options.placeholder); 5714 } else if (($chips.data('chips') === undefined || !!$chips.data('chips').length) && curr_options.secondaryPlaceholder) { 5715 $chips.find('input').prop('placeholder', curr_options.secondaryPlaceholder); 5716 } 5717 }; 5718 5719 this.isValid = function ($chips, elem) { 5720 var chips = $chips.data('chips'); 5721 var exists = false; 5722 for (var i = 0; i < chips.length; i++) { 5723 if (chips[i].tag === elem.tag) { 5724 exists = true; 5725 return; 5726 } 5727 } 5728 return '' !== elem.tag && !exists; 5729 }; 5730 5731 this.addChip = function (elem, $chips) { 5732 if (!self.isValid($chips, elem)) { 5733 return; 5734 } 5735 var $renderedChip = self.renderChip(elem); 5736 var newData = []; 5737 var oldData = $chips.data('chips'); 5738 for (var i = 0; i < oldData.length; i++) { 5739 newData.push(oldData[i]); 5740 } 5741 newData.push(elem); 5742 5743 $chips.data('chips', newData); 5744 $renderedChip.insertBefore($chips.find('input')); 5745 $chips.trigger('chip.add', elem); 5746 self.setPlaceholder($chips); 5747 }; 5748 5749 this.deleteChip = function (chipIndex, $chips) { 5750 var chip = $chips.data('chips')[chipIndex]; 5751 $chips.find('.chip').eq(chipIndex).remove(); 5752 5753 var newData = []; 5754 var oldData = $chips.data('chips'); 5755 for (var i = 0; i < oldData.length; i++) { 5756 if (i !== chipIndex) { 5757 newData.push(oldData[i]); 5758 } 5759 } 5760 5761 $chips.data('chips', newData); 5762 $chips.trigger('chip.delete', chip); 5763 self.setPlaceholder($chips); 5764 }; 5765 5766 this.selectChip = function (chipIndex, $chips) { 5767 var $chip = $chips.find('.chip').eq(chipIndex); 5768 if ($chip && false === $chip.hasClass('selected')) { 5769 $chip.addClass('selected'); 5770 $chips.trigger('chip.select', $chips.data('chips')[chipIndex]); 5771 } 5772 }; 5773 5774 this.getChipsElement = function (index, $chips) { 5775 return $chips.eq(index); 5776 }; 5777 5778 // init 5779 this.init(); 5780 5781 this.handleEvents(); 5782 }; 5783})(jQuery); 5784;(function ($) { 5785 $.fn.pushpin = function (options) { 5786 // Defaults 5787 var defaults = { 5788 top: 0, 5789 bottom: Infinity, 5790 offset: 0 5791 }; 5792 5793 // Remove pushpin event and classes 5794 if (options === "remove") { 5795 this.each(function () { 5796 if (id = $(this).data('pushpin-id')) { 5797 $(window).off('scroll.' + id); 5798 $(this).removeData('pushpin-id').removeClass('pin-top pinned pin-bottom').removeAttr('style'); 5799 } 5800 }); 5801 return false; 5802 } 5803 5804 options = $.extend(defaults, options); 5805 5806 $index = 0; 5807 return this.each(function () { 5808 var $uniqueId = Materialize.guid(), 5809 $this = $(this), 5810 $original_offset = $(this).offset().top; 5811 5812 function removePinClasses(object) { 5813 object.removeClass('pin-top'); 5814 object.removeClass('pinned'); 5815 object.removeClass('pin-bottom'); 5816 } 5817 5818 function updateElements(objects, scrolled) { 5819 objects.each(function () { 5820 // Add position fixed (because its between top and bottom) 5821 if (options.top <= scrolled && options.bottom >= scrolled && !$(this).hasClass('pinned')) { 5822 removePinClasses($(this)); 5823 $(this).css('top', options.offset); 5824 $(this).addClass('pinned'); 5825 } 5826 5827 // Add pin-top (when scrolled position is above top) 5828 if (scrolled < options.top && !$(this).hasClass('pin-top')) { 5829 removePinClasses($(this)); 5830 $(this).css('top', 0); 5831 $(this).addClass('pin-top'); 5832 } 5833 5834 // Add pin-bottom (when scrolled position is below bottom) 5835 if (scrolled > options.bottom && !$(this).hasClass('pin-bottom')) { 5836 removePinClasses($(this)); 5837 $(this).addClass('pin-bottom'); 5838 $(this).css('top', options.bottom - $original_offset); 5839 } 5840 }); 5841 } 5842 5843 $(this).data('pushpin-id', $uniqueId); 5844 updateElements($this, $(window).scrollTop()); 5845 $(window).on('scroll.' + $uniqueId, function () { 5846 var $scrolled = $(window).scrollTop() + options.offset; 5847 updateElements($this, $scrolled); 5848 }); 5849 }); 5850 }; 5851})(jQuery);;(function ($) { 5852 $(document).ready(function () { 5853 5854 // jQuery reverse 5855 $.fn.reverse = [].reverse; 5856 5857 // Hover behaviour: make sure this doesn't work on .click-to-toggle FABs! 5858 $(document).on('mouseenter.fixedActionBtn', '.fixed-action-btn:not(.click-to-toggle):not(.toolbar)', function (e) { 5859 var $this = $(this); 5860 openFABMenu($this); 5861 }); 5862 $(document).on('mouseleave.fixedActionBtn', '.fixed-action-btn:not(.click-to-toggle):not(.toolbar)', function (e) { 5863 var $this = $(this); 5864 closeFABMenu($this); 5865 }); 5866 5867 // Toggle-on-click behaviour. 5868 $(document).on('click.fabClickToggle', '.fixed-action-btn.click-to-toggle > a', function (e) { 5869 var $this = $(this); 5870 var $menu = $this.parent(); 5871 if ($menu.hasClass('active')) { 5872 closeFABMenu($menu); 5873 } else { 5874 openFABMenu($menu); 5875 } 5876 }); 5877 5878 // Toolbar transition behaviour. 5879 $(document).on('click.fabToolbar', '.fixed-action-btn.toolbar > a', function (e) { 5880 var $this = $(this); 5881 var $menu = $this.parent(); 5882 FABtoToolbar($menu); 5883 }); 5884 }); 5885 5886 $.fn.extend({ 5887 openFAB: function () { 5888 openFABMenu($(this)); 5889 }, 5890 closeFAB: function () { 5891 closeFABMenu($(this)); 5892 }, 5893 openToolbar: function () { 5894 FABtoToolbar($(this)); 5895 }, 5896 closeToolbar: function () { 5897 toolbarToFAB($(this)); 5898 } 5899 }); 5900 5901 var openFABMenu = function (btn) { 5902 var $this = btn; 5903 if ($this.hasClass('active') === false) { 5904 5905 // Get direction option 5906 var horizontal = $this.hasClass('horizontal'); 5907 var offsetY, offsetX; 5908 5909 if (horizontal === true) { 5910 offsetX = 40; 5911 } else { 5912 offsetY = 40; 5913 } 5914 5915 $this.addClass('active'); 5916 $this.find('ul .btn-floating').velocity({ scaleY: ".4", scaleX: ".4", translateY: offsetY + 'px', translateX: offsetX + 'px' }, { duration: 0 }); 5917 5918 var time = 0; 5919 $this.find('ul .btn-floating').reverse().each(function () { 5920 $(this).velocity({ opacity: "1", scaleX: "1", scaleY: "1", translateY: "0", translateX: '0' }
5920, { duration: 80, delay: time }); 5921 time += 40; 5922 }); 5923 } 5924 }; 5925 5926 var closeFABMenu = function (btn) { 5927 var $this = btn; 5928 // Get direction option 5929 var horizontal = $this.hasClass('horizontal'); 5930 var offsetY, offsetX; 5931 5932 if (horizontal === true) { 5933 offsetX = 40; 5934 } else { 5935 offsetY = 40; 5936 } 5937 5938 $this.removeClass('active'); 5939 var time = 0; 5940 $this.find('ul .btn-floating').velocity("stop", true); 5941 $this.find('ul .btn-floating').velocity({ opacity: "0", scaleX: ".4", scaleY: ".4", translateY: offsetY + 'px', translateX: offsetX + 'px' }, { duration: 80 }); 5942 }; 5943 5944 /** 5945 * Transform FAB into toolbar 5946 * @param {Object} object jQuery object 5947 */ 5948 var FABtoToolbar = function (btn) { 5949 if (btn.attr('data-open') === "true") { 5950 return; 5951 } 5952 5953 var offsetX, offsetY, scaleFactor; 5954 var windowWidth = window.innerWidth; 5955 var windowHeight = window.innerHeight; 5956 var btnRect = btn[0].getBoundingClientRect(); 5957 var anchor = btn.find('> a').first(); 5958 var menu = btn.find('> ul').first(); 5959 var backdrop = $('<div class="fab-backdrop"></div>'); 5960 var fabColor = anchor.css('background-color'); 5961 anchor.append(backdrop); 5962 5963 offsetX = btnRect.left - windowWidth / 2 + btnRect.width / 2; 5964 offsetY = windowHeight - btnRect.bottom; 5965 scaleFactor = windowWidth / backdrop.width(); 5966 btn.attr('data-origin-bottom', btnRect.bottom); 5967 btn.attr('data-origin-left', btnRect.left); 5968 btn.attr('data-origin-width', btnRect.width); 5969 5970 // Set initial state 5971 btn.addClass('active'); 5972 btn.attr('data-open', true); 5973 btn.css({ 5974 'text-align': 'center', 5975 width: '100%', 5976 bottom: 0, 5977 left: 0, 5978 transform: 'translateX(' + offsetX + 'px)', 5979 transition: 'none' 5980 }); 5981 anchor.css({ 5982 transform: 'translateY(' + -offsetY + 'px)', 5983 transition: 'none' 5984 }); 5985 backdrop.css({ 5986 'background-color': fabColor 5987 }); 5988 5989 setTimeout(function () { 5990 btn.css({ 5991 transform: '', 5992 transition: 'transform .2s cubic-bezier(0.550, 0.085, 0.680, 0.530), background-color 0s linear .2s' 5993 }); 5994 anchor.css({ 5995 overflow: 'visible', 5996 transform: '', 5997 transition: 'transform .2s' 5998 }); 5999 6000 setTimeout(function () { 6001 btn.css({ 6002 overflow: 'hidden', 6003 'background-color': fabColor 6004 }); 6005 backdrop.css({ 6006 transform: 'scale(' + scaleFactor + ')', 6007 transition: 'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)' 6008 }); 6009 menu.find('> li > a').css({ 6010 opacity: 1 6011 }); 6012 6013 // Scroll to close. 6014 $(window).on('scroll.fabToolbarClose', function () { 6015 toolbarToFAB(btn); 6016 $(window).off('scroll.fabToolbarClose'); 6017 $(document).off('click.fabToolbarClose'); 6018 }); 6019 6020 $(document).on('click.fabToolbarClose', function (e) { 6021 if (!$(e.target).closest(menu).length) { 6022 toolbarToFAB(btn); 6023 $(window).off('scroll.fabToolbarClose'); 6024 $(document).off('click.fabToolbarClose'); 6025 } 6026 }); 6027 }, 100); 6028 }, 0); 6029 }; 6030 6031 /** 6032 * Transform toolbar back into FAB 6033 * @param {Object} object jQuery object 6034 */ 6035 var toolbarToFAB = function (btn) { 6036 if (btn.attr('data-open') !== "true") { 6037 return; 6038 } 6039 6040 var offsetX, offsetY, scaleFactor; 6041 var windowWidth = window.innerWidth; 6042 var windowHeight = window.innerHeight; 6043 var btnWidth = btn.attr('data-origin-width'); 6044 var btnBottom = btn.attr('data-origin-bottom'); 6045 var btnLeft = btn.attr('data-origin-left'); 6046 var anchor = btn.find('> .btn-floating').first(); 6047 var menu = btn.find('> ul').first(); 6048 var backdrop = btn.find('.fab-backdrop'); 6049 var fabColor = anchor.css('background-color'); 6050 6051 offsetX = btnLeft - windowWidth / 2 + btnWidth / 2; 6052 offsetY = windowHeight - btnBottom; 6053 scaleFactor = windowWidth / backdrop.width(); 6054 6055 // Hide backdrop 6056 btn.removeClass('active'); 6057 btn.attr('data-open', false); 6058 btn.css({ 6059 'background-color': 'transparent', 6060 transition: 'none' 6061 }); 6062 anchor.css({ 6063 transition: 'none' 6064 }); 6065 backdrop.css({ 6066 transform: 'scale(0)', 6067 'background-color': fabColor 6068 }); 6069 menu.find('> li > a').css({ 6070 opacity: '' 6071 }); 6072 6073 setTimeout(function () { 6074 backdrop.remove(); 6075 6076 // Set initial state. 6077 btn.css({ 6078 'text-align': '', 6079 width: '', 6080 bottom: '', 6081 left: '', 6082 overflow: '', 6083 'background-color': '', 6084 transform: 'translate3d(' + -offsetX + 'px,0,0)' 6085 }); 6086 anchor.css({ 6087 overflow: '', 6088 transform: 'translate3d(0,' + offsetY + 'px,0)' 6089 }); 6090 6091 setTimeout(function () { 6092 btn.css({
6093 transform: 'translate3d(0,0,0)', 6094 transition: 'transform .2s' 6095 }); 6096 anchor.css({ 6097 transform: 'translate3d(0,0,0)', 6098 transition: 'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)' 6099 }); 6100 }, 20); 6101 }, 200); 6102 }; 6103})(jQuery); 6104;(function ($) { 6105 // Image transition function 6106 Materialize.fadeInImage = function (selectorOrEl) { 6107 var element; 6108 if (typeof selectorOrEl === 'string') { 6109 element = $(selectorOrEl); 6110 } else if (typeof selectorOrEl === 'object') { 6111 element = selectorOrEl; 6112 } else { 6113 return; 6114 } 6115 element.css({ opacity: 0 }); 6116 $(element).velocity({ opacity: 1 }, { 6117 duration: 650, 6118 queue: false, 6119 easing: 'easeOutSine' 6120 }); 6121 $(element).velocity({ opacity: 1 }, { 6122 duration: 1300, 6123 queue: false, 6124 easing: 'swing', 6125 step: function (now, fx) { 6126 fx.start = 100; 6127 var grayscale_setting = now / 100; 6128 var brightness_setting = 150 - (100 - now) / 1.75; 6129 6130 if (brightness_setting < 100) { 6131 brightness_setting = 100; 6132 } 6133 if (now >= 0) { 6134 $(this).css({ 6135 "-webkit-filter": "grayscale(" + grayscale_setting + ")" + "brightness(" + brightness_setting + "%)", 6136 "filter": "grayscale(" + grayscale_setting + ")" + "brightness(" + brightness_setting + "%)" 6137 }); 6138 } 6139 } 6140 }); 6141 }; 6142 6143 // Horizontal staggered list 6144 Materialize.showStaggeredList = function (selectorOrEl) { 6145 var element; 6146 if (typeof selectorOrEl === 'string') { 6147 element = $(selectorOrEl); 6148 } else if (typeof selectorOrEl === 'object') { 6149 element = selectorOrEl; 6150 } else { 6151 return; 6152 } 6153 var time = 0; 6154 element.find('li').velocity({ translateX: "-100px" }, { duration: 0 }); 6155 6156 element.find('li').each(function () { 6157 $(this).velocity({ opacity: "1", translateX: "0" }, { duration: 800, delay: time, easing: [60, 10] }); 6158 time += 120; 6159 }); 6160 }; 6161 6162 $(document).ready(function () { 6163 // Hardcoded .staggered-list scrollFire 6164 // var staggeredListOptions = []; 6165 // $('ul.staggered-list').each(function (i) { 6166 6167 // var label = 'scrollFire-' + i; 6168 // $(this).addClass(label); 6169 // staggeredListOptions.push( 6170 // {selector: 'ul.staggered-list.' + label, 6171 // offset: 200, 6172 // callback: 'showStaggeredList("ul.staggered-list.' + label + '")'}); 6173 // }); 6174 // scrollFire(staggeredListOptions); 6175 6176 // HammerJS, Swipe navigation 6177 6178 // Touch Event 6179 var swipeLeft = false; 6180 var swipeRight = false; 6181 6182 // Dismissible Collections 6183 $('.dismissable').each(function () { 6184 $(this).hammer({ 6185 prevent_default: false 6186 }).on('pan', function (e) { 6187 if (e.gesture.pointerType === "touch") { 6188 var $this = $(this); 6189 var direction = e.gesture.direction; 6190 var x = e.gesture.deltaX; 6191 var velocityX = e.gesture.velocityX; 6192 6193 $this.velocity({ translateX: x 6194 }, { duration: 50, queue: false, easing: 'easeOutQuad' }); 6195 6196 // Swipe Left 6197 if (direction === 4 && (x > $this.innerWidth() / 2 || velocityX < -0.75)) { 6198 swipeLeft = true; 6199 } 6200 6201 // Swipe Right 6202 if (direction === 2 && (x < -1 * $this.innerWidth() / 2 || velocityX > 0.75)) { 6203 swipeRight = true; 6204 } 6205 } 6206 }).on('panend', function (e) { 6207 // Reset if collection is moved back into original position 6208 if (Math.abs(e.gesture.deltaX) < $(this).innerWidth() / 2) { 6209 swipeRight = false; 6210 swipeLeft = false; 6211 } 6212 6213 if (e.gesture.pointerType === "touch") { 6214 var $this = $(this); 6215 if (swipeLeft || swipeRight) { 6216 var fullWidth; 6217 if (swipeLeft) { 6218 fullWidth = $this.innerWidth(); 6219 } else { 6220 fullWidth = -1 * $this.innerWidth(); 6221 } 6222 6223 $this.velocity({ translateX: fullWidth 6224 }, { duration: 100, queue: false, easing: 'easeOutQuad', complete: function () { 6225 $this.css('border', 'none'); 6226 $this.velocity({ height: 0, padding: 0 6227 }, { duration: 200, queue: false, easing: 'easeOutQuad', complete: function () { 6228 $this.remove(); 6229 } 6230 }); 6231 } 6232 }); 6233 } else { 6234 $this.velocity({ translateX: 0 6235 }, { duration: 100, queue: false, easing: 'easeOutQuad' }); 6236 } 6237 swipeLeft = false;
6238 swipeRight = false; 6239 } 6240 }); 6241 }); 6242 6243 // time = 0 6244 // // Vertical Staggered list 6245 // $('ul.staggered-list.vertical li').velocity( 6246 // { translateY: "100px"}, 6247 // { duration: 0 }); 6248 6249 // $('ul.staggered-list.vertical li').each(function() { 6250 // $(this).velocity( 6251 // { opacity: "1", translateY: "0"}, 6252 // { duration: 800, delay: time, easing: [60, 25] }); 6253 // time += 120; 6254 // }); 6255 6256 // // Fade in and Scale 6257 // $('.fade-in.scale').velocity( 6258 // { scaleX: .4, scaleY: .4, translateX: -600}, 6259 // { duration: 0}); 6260 // $('.fade-in').each(function() { 6261 // $(this).velocity( 6262 // { opacity: "1", scaleX: 1, scaleY: 1, translateX: 0}, 6263 // { duration: 800, easing: [60, 10] }); 6264 // }); 6265 }); 6266})(jQuery); 6267;(function ($) { 6268 6269 var scrollFireEventsHandled = false; 6270 6271 // Input: Array of JSON objects {selector, offset, callback} 6272 Materialize.scrollFire = function (options) { 6273 var onScroll = function () { 6274 var windowScroll = window.pageYOffset + window.innerHeight; 6275 6276 for (var i = 0; i < options.length; i++) { 6277 // Get options from each line 6278 var value = options[i]; 6279 var selector = value.selector, 6280 offset = value.offset, 6281 callback = value.callback; 6282 6283 var currentElement = document.querySelector(selector); 6284 if (currentElement !== null) { 6285 var elementOffset = currentElement.getBoundingClientRect().top + window.pageYOffset; 6286 6287 if (windowScroll > elementOffset + offset) { 6288 if (value.done !== true) { 6289 if (typeof callback === 'function') { 6290 callback.call(this, currentElement); 6291 } else if (typeof callback === 'string') { 6292 var callbackFunc = new Function(callback); 6293 callbackFunc(currentElement); 6294 } 6295 value.done = true; 6296 } 6297 } 6298 } 6299 } 6300 }; 6301 6302 var throttledScroll = Materialize.throttle(function () { 6303 onScroll(); 6304 }, options.throttle || 100); 6305 6306 if (!scrollFireEventsHandled) { 6307 window.addEventListener("scroll", throttledScroll); 6308 window.addEventListener("resize", throttledScroll); 6309 scrollFireEventsHandled = true; 6310 } 6311 6312 // perform a scan once, after current execution context, and after dom is ready 6313 setTimeout(throttledScroll, 0); 6314 }; 6315})(jQuery); 6316; /*! 6317 * pickadate.js v3.5.0, 2014/04/13 6318 * By Amsul, http://amsul.ca 6319 * Hosted on http://amsul.github.io/pickadate.js 6320 * Licensed under MIT 6321 */ 6322 6323(function (factory) { 6324 6325 Materialize.Picker = factory(jQuery); 6326})(function ($) { 6327 6328 var $window = $(window); 6329 var $document = $(document); 6330 var $html = $(document.documentElement); 6331 6332 /** 6333 * The picker constructor that creates a blank picker. 6334 */ 6335 function PickerConstructor(ELEMENT, NAME, COMPONENT, OPTIONS) { 6336 6337 // If thereâs no element, return the picker constructor. 6338 if (!ELEMENT) return PickerConstructor; 6339 6340 var IS_DEFAULT_THEME = false, 6341 6342 6343 // The state of the picker. 6344 STATE = { 6345 id: ELEMENT.id || 'P' + Math.abs(~~(Math.random() * new Date())) 6346 }, 6347 6348 6349 // Merge the defaults and options passed. 6350 SETTINGS = COMPONENT ? $.extend(true, {}, COMPONENT.defaults, OPTIONS) : OPTIONS || {}, 6351 6352 6353 // Merge the default classes with the settings classes. 6354 CLASSES = $.extend({}, PickerConstructor.klasses(), SETTINGS.klass), 6355 6356 6357 // The element node wrapper into a jQuery object. 6358 $ELEMENT = $(ELEMENT), 6359 6360 6361 // Pseudo picker constructor. 6362 PickerInstance = function () { 6363 return this.start(); 6364 }, 6365 6366 6367 // The picker prototype. 6368 P = PickerInstance.prototype = { 6369 6370 constructor: PickerInstance, 6371 6372 $node: $ELEMENT, 6373 6374 /** 6375 * Initialize everything 6376 */ 6377 start: function () { 6378 6379 // If itâs already started, do nothing. 6380 if (STATE && STATE.start) return P; 6381 6382 // Update the picker states. 6383 STATE.methods = {}; 6384 STATE.start = true; 6385 STATE.open = false; 6386 STATE.type = ELEMENT.type; 6387 6388 // Confirm focus state, convert into text input to remove UA stylings, 6389 // and set as readonly to prevent keyboard popup. 6390 ELEMENT.autofocus = ELEMENT == getActiveElement(); 6391 ELEMENT.readOnly = !SETTINGS.editable; 6392 ELEMENT.id = ELEMENT.id || STATE.id; 6393 if (ELEMENT.type != 'text') { 6394 ELEMENT.type = 'text'; 6395 } 6396 6397 // Create a new picker component with the settings. 6398 P.component = new COMPONENT(P, SETTINGS); 6399 6400 // Create the picker root with a holder and then prepare it. 6401 P.$root = $(PickerConstructor._.node('div', createWrappedComponent(), CLASSES.picker, 'id="' + ELEMENT.id + '_root" tabindex="0"')); 6402 prepareElementRoot(); 6403 6404 // If thereâs a format for the hidden input element, create the element. 6405 if (SETTINGS.formatSubmit) { 6406 prepareElementHidden(); 6407 } 6408 6409 // Prepare the input element. 6410 prepareElement(); 6411 6412 // Insert the root as specified in the settings. 6413 if (SETTINGS.container) $(SETTINGS.container).append(P.$root);else $ELEMENT.before(P.$root); 6414 6415 // Bind the default component and settings events. 6416 P.on({ 6417 start: P.component.onStart, 6418 render: P.component.onRender, 6419 stop: P.component.onStop, 6420 open: P.component.onOpen, 6421 close: P.component.onClose, 6422 set: P.component.onSet 6423 }).on({ 6424 start: SETTINGS.onStart, 6425 render: SETTINGS.onRender, 6426 stop: SETTINGS.onStop, 6427 open: SETTINGS.onOpen, 6428 close: SETTINGS.onClose, 6429 set: SETTINGS.onSet 6430 }); 6431 6432 // Once weâre all set, check the theme in use. 6433 IS_DEFAULT_THEME = isUsingDefaultTheme(P.$root.children()[0]); 6434 6435 // If the element has autofocus, open the picker. 6436 if (ELEMENT.autofocus) { 6437 P.open(); 6438 } 6439 6440 // Trigger queued the âstartâ and ârenderâ events. 6441 return P.trigger('start').trigger('render'); 6442 }, //start 6443 6444 6445 /**
6446 * Render a new picker 6447 */ 6448 render: function (entireComponent) { 6449 6450 // Insert a new component holder in the root or box. 6451 if (entireComponent) P.$root.html(createWrappedComponent());else P.$root.find('.' + CLASSES.box).html(P.component.nodes(STATE.open)); 6452 6453 // Trigger the queued ârenderâ events. 6454 return P.trigger('render'); 6455 }, //render 6456 6457 6458 /** 6459 * Destroy everything 6460 */ 6461 stop: function () { 6462 6463 // If itâs already stopped, do nothing. 6464 if (!STATE.start) return P; 6465 6466 // Then close the picker. 6467 P.close(); 6468 6469 // Remove the hidden field. 6470 if (P._hidden) { 6471 P._hidden.parentNode.removeChild(P._hidden); 6472 } 6473 6474 // Remove the root. 6475 P.$root.remove(); 6476 6477 // Remove the input class, remove the stored data, and unbind 6478 // the events (after a tick for IE - see `P.close`). 6479 $ELEMENT.removeClass(CLASSES.input).removeData(NAME); 6480 setTimeout(function () { 6481 $ELEMENT.off('.' + STATE.id); 6482 }, 0); 6483 6484 // Restore the element state 6485 ELEMENT.type = STATE.type; 6486 ELEMENT.readOnly = false; 6487 6488 // Trigger the queued âstopâ events. 6489 P.trigger('stop'); 6490 6491 // Reset the picker states. 6492 STATE.methods = {}; 6493 STATE.start = false;
6494 6495 return P; 6496 }, //stop 6497 6498 6499 /** 6500 * Open up the picker 6501 */ 6502 open: function (dontGiveFocus) { 6503 6504 // If itâs already open, do nothing. 6505 if (STATE.open) return P; 6506 6507 // Add the âactiveâ class. 6508 $ELEMENT.addClass(CLASSES.active); 6509 aria(ELEMENT, 'expanded', true); 6510 6511 // * A Firefox bug, when `html` has `overflow:hidden`, results in 6512 // killing transitions :(. So add the âopenedâ state on the next tick. 6513 // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=625289 6514 setTimeout(function () { 6515 6516 // Add the âopenedâ class to the picker root. 6517 P.$root.addClass(CLASSES.opened); 6518 aria(P.$root[0], 'hidden', false); 6519 }, 0); 6520 6521 // If we have to give focus, bind the element and doc events. 6522 if (dontGiveFocus !== false) { 6523 6524 // Set it as open. 6525 STATE.open = true; 6526 6527 // Prevent the page from scrolling. 6528 if (IS_DEFAULT_THEME) { 6529 $html.css('overflow', 'hidden').css('padding-right', '+=' + getScrollbarWidth()); 6530 } 6531 6532 // Pass focus to the root elementâs jQuery object. 6533 // * Workaround for iOS8 to bring the pickerâs root into view. 6534 P.$root.eq(0).focus(); 6535 6536 // Bind the document events. 6537 $document.on('click.' + STATE.id + ' focusin.' + STATE.id, function (event) { 6538 6539 var target = event.target; 6540 6541 // If the target of the event is not the element, close the picker picker. 6542 // * Donât worry about clicks or focusins on the root because those donât bubble up. 6543 // Also, for Firefox, a click on an `option` element bubbles up directly 6544 // to the doc. So make sure the target wasn't the doc. 6545 // * In Firefox stopPropagation() doesnât prevent right-click events from bubbling, 6546 // which causes the picker to unexpectedly close when right-clicking it. So make 6547 // sure the event wasnât a right-click. 6548 if (target != ELEMENT && target != document && event.which != 3) { 6549 6550 // If the target was the holder that covers the screen, 6551 // keep the element focused to maintain tabindex. 6552 P.close(target === P.$root.children()[0]); 6553 } 6554 }).on('keydown.' + STATE.id, function (event) { 6555 6556 var 6557 // Get the keycode. 6558 keycode = event.keyCode, 6559 6560 6561 // Translate that to a selection change. 6562 keycodeToMove = P.component.key[keycode], 6563 6564 6565 // Grab the target. 6566 target = event.target; 6567 6568 // On escape, close the picker and give focus. 6569 if (keycode == 27) { 6570 P.close(true); 6571 } 6572 6573 // Check if there is a key movement or âenterâ keypress on the element. 6574 else if (target == P.$root[0] && (keycodeToMove || keycode == 13)) { 6575 6576 // Prevent the default action to stop page movement. 6577 event.preventDefault(); 6578 6579 // Trigger the key movement action. 6580 if (keycodeToMove) { 6581 PickerConstructor._.trigger(P.component.key.go, P, [PickerConstructor._.trigger(keycodeToMove)]); 6582 } 6583 6584 // On âenterâ, if the highlighted item isnât disabled, set the value and close. 6585 else if (!P.$root.find('.' + CLASSES.highlighted).hasClass(CLASSES.disabled)) { 6586 P.set('select', P.component.item.highlight); 6587 if (SETTINGS.closeOnSelect) { 6588 P.close(true); 6589 } 6590 } 6591 } 6592 6593 // If the target is within the root and âenterâ is pressed, 6594 // prevent the default action and trigger a click on the target instead. 6595 else if ($.contains(P.$root[0], target) && keycode == 13) { 6596 event.preventDefault(); 6597 target.click(); 6598 } 6599 }); 6600 } 6601 6602 // Trigger the queued âopenâ events. 6603 return P.trigger('open'); 6604 }, //open 6605 6606 6607 /** 6608 * Close the picker 6609 */ 6610 close: function (giveFocus) { 6611 6612 // If we need to give focus, do it before changing states. 6613 if (giveFocus) { 6614 // ....ah yes! It wouldâve been incomplete without a crazy workaround for IE :| 6615 // The focus is triggered *after* the close has completed - causing it 6616 // to open again. So unbind and rebind the event at the next tick. 6617 P.$root.off('focus.toOpen').eq(0).focus(); 6618 setTimeout(function () { 6619 P.$root.on('focus.toOpen', handleFocusToOpenEvent); 6620 }, 0); 6621 } 6622 6623 // Remove the âactiveâ class. 6624 $ELEMENT.removeClass(CLASSES.active); 6625 aria(ELEMENT, 'expanded', false); 6626 6627 // * A Firefox bug, when `html` has `overflow:hidden`, results in 6628 // killing transitions :(. So remove the âopenedâ state on the next tick. 6629 // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=625289 6630 setTimeout(function () { 6631 6632 // Remove the âopenedâ and âfocusedâ class from the picker root. 6633 P.$root.removeClass(CLASSES.opened + ' ' + CLASSES.focused); 6634 aria(P.$root[0], 'hidden', true); 6635 }, 0); 6636 6637 // If itâs already closed, do nothing more. 6638 if (!STATE.open) return P; 6639 6640 // Set it as closed. 6641 STATE.open = false;
6642 6643 // Allow the page to scroll. 6644 if (IS_DEFAULT_THEME) { 6645 $html.css('overflow', '').css('padding-right', '-=' + getScrollbarWidth()); 6646 } 6647 6648 // Unbind the document events. 6649 $document.off('.' + STATE.id); 6650 6651 // Trigger the queued âcloseâ events. 6652 return P.trigger('close'); 6653 }, //close 6654 6655 6656 /** 6657 * Clear the values 6658 */ 6659 clear: function (options) { 6660 return P.set('clear', null, options); 6661 }, //clear 6662 6663 6664 /** 6665 * Set something 6666 */ 6667 set: function (thing, value, options) { 6668 6669 var thingItem, 6670 thingValue, 6671 thingIsObject = $.isPlainObject(thing), 6672 thingObject = thingIsObject ? thing : {}; 6673 6674 // Make sure we have usable options. 6675 options = thingIsObject && $.isPlainObject(value) ? value : options || {}; 6676 6677 if (thing) { 6678 6679 // If the thing isnât an object, make it one. 6680 if (!thingIsObject) { 6681 thingObject[thing] = value; 6682 } 6683 6684 // Go through the things of items to set. 6685 for (thingItem in thingObject) { 6686 6687 // Grab the value of the thing. 6688 thingValue = thingObject[thingItem]; 6689 6690 // First, if the item exists and thereâs a value, set it. 6691 if (thingItem in P.component.item) { 6692 if (thingValue === undefined) thingValue = null; 6693 P.component.set(thingItem, thingValue, options); 6694 } 6695 6696 // Then, check to update the element value and broadcast a change. 6697 if (thingItem == 'select' || thingItem == 'clear') { 6698 $ELEMENT.val(thingItem == 'clear' ? '' : P.get(thingItem, SETTINGS.format)).trigger('change'); 6699 } 6700 } 6701 6702 // Render a new picker. 6703 P.render(); 6704 } 6705 6706 // When the method isnât muted, trigger queued âsetâ events and pass the `thingObject`. 6707 return options.muted ? P : P.trigger('set', thingObject); 6708 }, //set 6709 6710 6711 /** 6712 * Get something 6713 */ 6714 get: function (thing, format) { 6715 6716 // Make sure thereâs something to get. 6717 thing = thing || 'value'; 6718 6719 // If a picker state exists, return that. 6720 if (STATE[thing] != null) { 6721 return STATE[thing]; 6722 } 6723 6724 // Return the submission value, if that. 6725 if (thing == 'valueSubmit') { 6726 if (P._hidden) { 6727 return P._hidden.value; 6728 } 6729 thing = 'value'; 6730 } 6731 6732 // Return the value, if that. 6733 if (thing == 'value') { 6734 return ELEMENT.value; 6735 } 6736 6737 // Check if a component item exists, return that. 6738 if (thing in P.component.item) { 6739 if (typeof format == 'string') { 6740 var thingValue = P.component.get(thing); 6741 return thingValue ? PickerConstructor._.trigger(P.component.formats.toString, P.component, [format, thingValue]) : ''; 6742 } 6743 return P.component.get(thing); 6744 } 6745 }, //get 6746 6747 6748 /** 6749 * Bind events on the things. 6750 */ 6751 on: function (thing, method, internal) { 6752 6753 var thingName, 6754 thingMethod, 6755 thingIsObject = $.isPlainObject(thing), 6756 thingObject = thingIsObject ? thing : {}; 6757 6758 if (thing) { 6759 6760 // If the thing isnât an object, make it one. 6761 if (!thingIsObject) { 6762 thingObject[thing] = method; 6763 } 6764 6765 // Go through the things to bind to. 6766 for (thingName in thingObject) { 6767 6768 // Grab the method of the thing. 6769 thingMethod = thingObject[thingName]; 6770 6771 // If it was an internal binding, prefix it. 6772 if (internal) { 6773 thingName = '_' + thingName; 6774 } 6775 6776 // Make sure the thing methods collection exists. 6777 STATE.methods[thingName] = STATE.methods[thingName] || []; 6778 6779 // Add the method to the relative method collection. 6780 STATE.methods[thingName].push(thingMethod); 6781 } 6782 } 6783 6784 return P; 6785 }, //on 6786 6787 6788 /** 6789 * Unbind events on the things. 6790 */ 6791 off: function () { 6792 var i, 6793 thingName, 6794 names = arguments; 6795 for (i = 0, namesCount = names.length; i < namesCount; i += 1) { 6796 thingName = names[i]; 6797 if (thingName in STATE.methods) { 6798 delete STATE.methods[thingName]; 6799 } 6800 } 6801 return P; 6802 }, 6803 6804 /** 6805 * Fire off method events. 6806 */ 6807 trigger: function (name, data) { 6808 var _trigger = function (name) { 6809 var methodList = STATE.methods[name]; 6810 if (methodList) { 6811 methodList.map(function (method) { 6812 PickerConstructor._.trigger(method, P, [data]); 6813 }); 6814 } 6815 }; 6816 _trigger('_' + name); 6817 _trigger(name); 6818 return P; 6819 }
6819 //trigger 6820 //PickerInstance.prototype 6821 6822 6823 /** 6824 * Wrap the picker holder components together. 6825 */ 6826 };function createWrappedComponent() { 6827 6828 // Create a picker wrapper holder 6829 return PickerConstructor._.node('div', 6830 6831 // Create a picker wrapper node 6832 PickerConstructor._.node('div', 6833 6834 // Create a picker frame 6835 PickerConstructor._.node('div', 6836 6837 // Create a picker box node 6838 PickerConstructor._.node('div', 6839 6840 // Create the components nodes. 6841 P.component.nodes(STATE.open), 6842 6843 // The picker box class 6844 CLASSES.box), 6845 6846 // Picker wrap class 6847 CLASSES.wrap), 6848 6849 // Picker frame class 6850 CLASSES.frame), 6851 6852 // Picker holder class 6853 CLASSES.holder); //endreturn 6854 } //createWrappedComponent 6855 6856 6857 /** 6858 * Prepare the input element with all bindings. 6859 */ 6860 function prepareElement() { 6861 6862 $ELEMENT. 6863 6864 // Store the picker data by component name. 6865 data(NAME, P). 6866 6867 // Add the âinputâ class name. 6868 addClass(CLASSES.input). 6869 6870 // Remove the tabindex. 6871 attr('tabindex', -1). 6872 6873 // If thereâs a `data-value`, update the value of the element. 6874 val($ELEMENT.data('value') ? P.get('select', SETTINGS.format) : ELEMENT.value); 6875 6876 // Only bind keydown events if the element isnât editable. 6877 if (!SETTINGS.editable) { 6878 6879 $ELEMENT. 6880 6881 // On focus/click, focus onto the root to open it up. 6882 on('focus.' + STATE.id + ' click.' + STATE.id, function (event) { 6883 event.preventDefault(); 6884 P.$root.eq(0).focus(); 6885 }). 6886 6887 // Handle keyboard event based on the picker being opened or not. 6888 on('keydown.' + STATE.id, handleKeydownEvent); 6889 } 6890 6891 // Update the aria attributes. 6892 aria(ELEMENT, { 6893 haspopup: true, 6894 expanded: false, 6895 readonly: false, 6896 owns: ELEMENT.id + '_root' 6897 }); 6898 } 6899 6900 /** 6901 * Prepare the root picker element with all bindings. 6902 */ 6903 function prepareElementRoot() { 6904 6905 P.$root.on({ 6906 6907 // For iOS8. 6908 keydown: handleKeydownEvent, 6909 6910 // When something within the root is focused, stop from bubbling 6911 // to the doc and remove the âfocusedâ state from the root. 6912 focusin: function (event) { 6913 P.$root.removeClass(CLASSES.focused); 6914 event.stopPropagation(); 6915 }, 6916 6917 // When something within the root holder is clicked, stop it 6918 // from bubbling to the doc. 6919 'mousedown click': function (event) { 6920 6921 var target = event.target; 6922 6923 // Make sure the target isnât the root holder so it can bubble up. 6924 if (target != P.$root.children()[0]) { 6925 6926 event.stopPropagation(); 6927 6928 // * For mousedown events, cancel the default action in order to 6929 // prevent cases where focus is shifted onto external elements 6930 // when using things like jQuery mobile or MagnificPopup (ref: #249 & #120). 6931 // Also, for Firefox, donât prevent action on the `option` element. 6932 if (event.type == 'mousedown' && !$(target).is('input, select, textarea, button, option')) { 6933 6934 event.preventDefault(); 6935 6936 // Re-focus onto the root so that users can click away 6937 // from elements focused within the picker. 6938 P.$root.eq(0).focus(); 6939 } 6940 } 6941 } 6942 }). 6943 6944 // Add/remove the âtargetâ class on focus and blur. 6945 on({ 6946 focus: function () { 6947 $ELEMENT.addClass(CLASSES.target); 6948 }, 6949 blur: function () { 6950 $ELEMENT.removeClass(CLASSES.target); 6951 } 6952 }). 6953 6954 // Open the picker and adjust the root âfocusedâ state 6955 on('focus.toOpen', handleFocusToOpenEvent). 6956 6957 // If thereâs a click on an actionable element, carry out the actions. 6958 on('click', '[data-pick], [data-nav], [data-clear], [data-close]', function () { 6959 6960 var $target = $(this), 6961 targetData = $target.data(), 6962 targetDisabled = $target.hasClass(CLASSES.navDisabled) || $target.hasClass(CLASSES.disabled), 6963 6964 6965 // * For IE, non-focusable elements can be active elements as well 6966 // (http://stackoverflow.com/a/2684561). 6967 activeElement = getActiveElement(); 6968 activeElement = activeElement && (activeElement.type || activeElement.href) && activeElement; 6969 6970 // If itâs disabled or nothing inside is actively focused, re-focus the element. 6971 if (targetDisabled || activeElement && !$.contains(P.$root[0], activeElement)) { 6972 P.$root.eq(0).focus(); 6973 } 6974 6975 // If something is superficially changed, update the `highlight` based on the `nav`. 6976 if (!targetDisabled && targetData.nav) { 6977 P.set('highlight', P.component.item.highlight, { nav: targetData.nav }); 6978 } 6979 6980 // If something is picked, set `select` then close with focus. 6981 else if (!targetDisabled && 'pick' in targetData) { 6982 P.set('select', targetData.pick); 6983 if (SETTINGS.closeOnSelect) { 6984 P.close(true); 6985 } 6986 } 6987 6988 // If a âclearâ button is pressed, empty the values and close with focus. 6989 else if (targetData.clear) { 6990 P.clear(); 6991 if (SETTINGS.closeOnSelect) { 6992 P.close(true); 6993 } 6994 } else if (targetData.close) { 6995 P.close(true); 6996 } 6997 }); //P.$root 6998 6999 aria(P.$root[0], 'hidden', true); 7000 } 7001 7002 /** 7003 * Prepare the hidden input element along with all bindings. 7004 */ 7005 function prepareElementHidden() { 7006 7007 var name; 7008 7009 if (SETTINGS.hiddenName === true) { 7010 name = ELEMENT.name; 7011 ELEMENT.name = ''; 7012 } else { 7013 name = [typeof SETTINGS.hiddenPrefix == 'string' ? SETTINGS.hiddenPrefix : '', typeof SETTINGS.hiddenSuffix == 'string' ? SETTINGS.hiddenSuffix : '_submit']; 7014 name = name[0] + ELEMENT.name + name[1]; 7015 } 7016 7017 P._hidden = $('<input ' + 'type=hidden ' + 7018 7019 // Create the name using the original inputâs with a prefix and suffix. 7020 'name="' + name + '"' + ( 7021 7022 // If the element has a value, set the hidden value as well. 7023 $ELEMENT.data('value') || ELEMENT.value ? ' value="' + P.get('select', SETTINGS.formatSubmit) + '"' : '') + '>')[0]; 7024 7025 $ELEMENT. 7026 7027 // If the value changes, update the hidden input with the correct format. 7028 on('change.' + STATE.id, function () { 7029 P._hidden.value = ELEMENT.value ? P.get('select', SETTINGS.formatSubmit) : ''; 7030 }); 7031 7032 // Insert the hidden input as specified in the settings. 7033 if (SETTINGS.container) $(SETTINGS.container).append(P._hidden);else $ELEMENT.before(P._hidden); 7034 } 7035 7036 // For iOS8. 7037 function handleKeydownEvent(event) { 7038 7039 var keycode = event.keyCode, 7040 7041 7042 // Check if one of the delete keys was pressed. 7043 isKeycodeDelete = /^(8|46)$/.test(keycode); 7044 7045 // For some reason IE clears the input value on âescapeâ. 7046 if (keycode == 27) { 7047 P.close(); 7048 return false;
7049 } 7050 7051 // Check if `space` or `delete` was pressed or the picker is closed with a key movement. 7052 if (keycode == 32 || isKeycodeDelete || !STATE.open && P.component.key[keycode]) { 7053 7054 // Prevent it from moving the page and bubbling to doc. 7055 event.preventDefault(); 7056 event.stopPropagation(); 7057 7058 // If `delete` was pressed, clear the values and close the picker. 7059 // Otherwise open the picker. 7060 if (isKeycodeDelete) { 7061 P.clear().close(); 7062 } else { 7063 P.open(); 7064 } 7065 } 7066 } 7067 7068 // Separated for IE 7069 function handleFocusToOpenEvent(event) { 7070 7071 // Stop the event from propagating to the doc. 7072 event.stopPropagation(); 7073 7074 // If itâs a focus event, add the âfocusedâ class to the root. 7075 if (event.type == 'focus') { 7076 P.$root.addClass(CLASSES.focused); 7077 } 7078 7079 // And then finally open the picker. 7080 P.open(); 7081 } 7082 7083 // Return a new picker instance. 7084 return new PickerInstance(); 7085 } //PickerConstructor 7086 7087 7088 /** 7089 * The default classes and prefix to use for the HTML classes. 7090 */ 7091 PickerConstructor.klasses = function (prefix) { 7092 prefix = prefix || 'picker'; 7093 return { 7094 7095 picker: prefix, 7096 opened: prefix + '--opened', 7097 focused: prefix + '--focused', 7098 7099 input: prefix + '__input', 7100 active: prefix + '__input--active', 7101 target: prefix + '__input--target', 7102 7103 holder: prefix + '__holder', 7104 7105 frame: prefix + '__frame', 7106 wrap: prefix + '__wrap', 7107 7108 box: prefix + '__box' 7109 }; 7110 }; //PickerConstructor.klasses 7111 7112 7113 /** 7114 * Check if the default theme is being used. 7115 */ 7116 function isUsingDefaultTheme(element) { 7117 7118 var theme, 7119 prop = 'position'; 7120 7121 // For IE. 7122 if (element.currentStyle) { 7123 theme = element.currentStyle[prop]; 7124 } 7125 7126 // For normal browsers. 7127 else if (window.getComputedStyle) { 7128 theme = getComputedStyle(element)[prop]; 7129 } 7130 7131 return theme == 'fixed'; 7132 } 7133 7134 /** 7135 * Get the width of the browserâs scrollbar. 7136 * Taken from: https://github.com/VodkaBears/Remodal/blob/master/src/jquery.remodal.js 7137 */ 7138 function getScrollbarWidth() { 7139 7140 if ($html.height() <= $window.height()) { 7141 return 0; 7142 } 7143 7144 var $outer = $('<div style="visibility:hidden;width:100px" />').appendTo('body'); 7145 7146 // Get the width without scrollbars. 7147 var widthWithoutScroll = $outer[0].offsetWidth; 7148 7149 // Force adding scrollbars. 7150 $outer.css('overflow', 'scroll'); 7151 7152 // Add the inner div. 7153 var $inner = $('<div style="width:100%" />').appendTo($outer); 7154 7155 // Get the width with scrollbars. 7156 var widthWithScroll = $inner[0].offsetWidth; 7157 7158 // Remove the divs. 7159 $outer.remove(); 7160 7161 // Return the difference between the widths. 7162 return widthWithoutScroll - widthWithScroll; 7163 } 7164 7165 /** 7166 * PickerConstructor helper methods. 7167 */ 7168 PickerConstructor._ = { 7169 7170 /** 7171 * Create a group of nodes. Expects: 7172 * ` 7173 { 7174 min: {Integer}, 7175 max: {Integer}, 7176 i: {Integer}, 7177 node: {String}, 7178 item: {Function} 7179 } 7180 * ` 7181 */ 7182 group: function (groupObject) { 7183 7184 var 7185 // Scope for the looped object 7186 loopObjectScope, 7187 7188 7189 // Create the nodes list 7190 nodesList = '', 7191 7192 7193 // The counter starts from the `min` 7194 counter = PickerConstructor._.trigger(groupObject.min, groupObject); 7195 7196 // Loop from the `min` to `max`, incrementing by `i` 7197 for (; counter <= PickerConstructor._.trigger(groupObject.max, groupObject, [counter]); counter += groupObject.i) { 7198 7199 // Trigger the `item` function within scope of the object 7200 loopObjectScope = PickerConstructor._.trigger(groupObject.item, groupObject, [counter]); 7201 7202 // Splice the subgroup and create nodes out of the sub nodes 7203 nodesList += PickerConstructor._.node(groupObject.node, loopObjectScope[0], // the node 7204 loopObjectScope[1], // the classes 7205 loopObjectScope[2] // the attributes 7206 ); 7207 } 7208 7209 // Return the list of nodes 7210 return nodesList; 7211 }, //group 7212 7213 7214 /** 7215 * Create a dom node string 7216 */ 7217 node: function (wrapper, item, klass, attribute) { 7218 7219 // If the item is false-y, just return an empty string 7220 if (!item) return ''; 7221 7222 // If the item is an array, do a join 7223 item = $.isArray(item) ? item.join('') : item; 7224 7225 // Check for the class 7226 klass = klass ? ' class="' + klass + '"' : ''; 7227 7228 // Check for any attributes 7229 attribute = attribute ? ' ' + attribute : ''; 7230 7231 // Return the wrapped item 7232 return '<' + wrapper + klass + attribute + '>' + item + '</' + wrapper + '>'; 7233 }, //node 7234 7235 7236 /** 7237 * Lead numbers below 10 with a zero. 7238 */ 7239 lead: function (number) { 7240 return (number < 10 ? '0' : '') + number; 7241 }, 7242 7243 /** 7244 * Trigger a function otherwise return the value. 7245 */ 7246 trigger: function (callback, scope, args) { 7247 return typeof callback == 'function' ? callback.apply(scope, args || []) : callback; 7248 }, 7249 7250 /** 7251 * If the second character is a digit, length is 2 otherwise 1. 7252 */ 7253 digits: function (string) { 7254 return (/\d/.test(string[1]) ? 2 : 1 7255 ); 7256 }, 7257 7258 /** 7259 * Tell if something is a date object. 7260 */ 7261 isDate: function (value) { 7262 return {}.toString.call(value).indexOf('Date') > -1 && this.isInteger(value.getDate()); 7263 }, 7264 7265 /** 7266 * Tell if something is an integer. 7267 */ 7268 isInteger: function (value) { 7269 return {}.toString.call(value).indexOf('Number') > -1 && value % 1 === 0; 7270 }, 7271 7272 /** 7273 * Create ARIA attribute strings. 7274 */ 7275 ariaAttr: ariaAttr //PickerConstructor._ 7276 7277 7278 /** 7279 * Extend the picker with a component and defaults. 7280 */ 7281 };PickerConstructor.extend = function (name, Component) { 7282 7283 // Extend jQuery. 7284 $.fn[name] = function (options, action) { 7285 7286 // Grab the component data. 7287 var componentData = this.data(name); 7288 7289 // If the picker is requested, return the data object. 7290 if (options == 'picker') { 7291 return componentData; 7292 } 7293 7294 7295 // If the component data exists and `options` is a string, carry out the action. 7296 if (componentData && typeof options == 'string') { 7297 return PickerConstructor._.trigger(componentData[options], componentData, [action]); 7298 } 7299 7300 // Otherwise go through each matched element and if the component 7301 // doesnât exist, create a new picker using `this` element 7302 // and merging the defaults and options with a deep copy. 7303 return this.each(function () { 7304 var $this = $(this); 7305 if (!$this.data(name)) { 7306 new PickerConstructor(this, name, Component, options); 7307 } 7308 }); 7309 }; 7310 7311 // Set the defaults. 7312 $.fn[name].defaults = Component.defaults; 7313 }; //PickerConstructor.extend 7314 7315 7316 function aria(element, attribute, value) { 7317 if ($.isPlainObject(attribute)) { 7318 for (var key in attribute) { 7319 ariaSet(element, key, attribute[key]); 7320 } 7321 } else { 7322 ariaSet(element, attribute, value); 7323 } 7324 } 7325 function ariaSet(element, attribute, value) { 7326 element.setAttribute((attribute == 'role' ? '' : 'aria-') + attribute, value); 7327 } 7328 function ariaAttr(attribute, data) { 7329 if (!$.isPlainObject(attribute)) { 7330 attribute = { attribute: data }; 7331 } 7332 data = ''; 7333 for (var key in attribute) { 7334 var attr = (key == 'role' ? '' : 'aria-') + key, 7335 attrVal = attribute[key]; 7336 data += attrVal == null ? '' : attr + '="' + attribute[key] + '"'; 7337 } 7338 return data; 7339 } 7340 7341 // IE8 bug throws an error for activeElements within iframes. 7342 function getActiveElement() { 7343 try { 7344 return document.activeElement; 7345 } catch (err) {} 7346 } 7347 7348 // Expose the picker constructor. 7349 return PickerConstructor; 7350}); 7351; /*! 7352 * Date picker for pickadate.js v3.5.0 7353 * http://amsul.github.io/pickadate.js/date.htm 7354 */ 7355 7356(function (factory) { 7357 factory(Materialize.Picker, jQuery); 7358})(function (Picker, $) { 7359 7360 /** 7361 * Globals and constants 7362 */ 7363 var DAYS_IN_WEEK = 7, 7364 WEEKS_IN_CALENDAR = 6, 7365 _ = Picker._; 7366 7367 /** 7368 * The date picker constructor 7369 */ 7370 function DatePicker(picker, settings) { 7371 7372 var calendar = this, 7373 element = picker.$node[0], 7374 elementValue = element.value, 7375 elementDataValue = picker.$node.data('value'), 7376 valueString = elementDataValue || elementValue, 7377 formatString = elementDataValue ? settings.formatSubmit : settings.format, 7378 isRTL = function () { 7379 7380 return element.currentStyle ? 7381 7382 // For IE. 7383 element.currentStyle.direction == 'rtl' : 7384 7385 // For normal browsers. 7386 getComputedStyle(picker.$root[0]).direction == 'rtl'; 7387 }; 7388 7389 calendar.settings = settings; 7390 calendar.$node = picker.$node; 7391 7392 // The queue of methods that will be used to build item objects. 7393 calendar.queue = { 7394 min: 'measure create', 7395 max: 'measure create', 7396 now: 'now create', 7397 select: 'parse create validate', 7398 highlight: 'parse navigate create validate', 7399 view: 'parse create validate viewset', 7400 disable: 'deactivate', 7401 enable: 'activate' 7402 7403 // The component's item object. 7404 };calendar.item = {}; 7405 7406 calendar.item.clear = null; 7407 calendar.item.disable = (settings.disable || []).slice(0); 7408 calendar.item.enable = -function (collectionDisabled) { 7409 return collectionDisabled[0] === true ? collectionDisabled.shift() : -1; 7410 }(calendar.item.disable); 7411 7412 calendar.set('min', settings.min).set('max', settings.max).set('now'); 7413 7414 // When thereâs a value, set the `select`, which in turn 7415 // also sets the `highlight` and `view`. 7416 if (valueString) { 7417 calendar.set('select', valueString, { format: formatString }); 7418 } 7419 7420 // If thereâs no value, default to highlighting âtodayâ. 7421 else { 7422 calendar.set('select', null).set('highlight', calendar.item.now); 7423 } 7424 7425 // The keycode to movement mapping. 7426 calendar.key = { 7427 40: 7, // Down 7428 38: -7, // Up 7429 39: function () { 7430 return isRTL() ? -1 : 1; 7431 }, // Right 7432 37: function () { 7433 return isRTL() ? 1 : -1; 7434 }, // Left 7435 go: function (timeChange) { 7436 var highlightedObject = calendar.item.highlight, 7437 targetDate = new Date(highlightedObject.year, highlightedObject.month, highlightedObject.date + timeChange); 7438 calendar.set('highlight', targetDate, { interval: timeChange }); 7439 this.render(); 7440 } 7441 7442 // Bind some picker events. 7443 };picker.on('render', function () { 7444 picker.$root.find('.' + settings.klass.selectMonth).on('change', function () { 7445 var value = this.value; 7446 if (value) { 7447 picker.set('highlight', [picker.get('view').year, value, picker.get('highlight').date]); 7448 picker.$root.find('.' + settings.klass.selectMonth).trigger('focus'); 7449 } 7450 }); 7451 picker.$root.find('.' + settings.klass.selectYear).on('change', function () { 7452 var value = this.value; 7453 if (value) { 7454 picker.set('highlight', [value, picker.get('view').month, picker.get('highlight').date]); 7455 picker.$root.find('.' + settings.klass.selectYear).trigger('focus'); 7456 } 7457 }); 7458 }, 1).on('open', function () { 7459 var includeToday = ''; 7460 if (calendar.disabled(calendar.get('now'))) { 7461 includeToday = ':not(.' + settings.klass.buttonToday + ')'; 7462 } 7463 picker.$root.find('button' + includeToday + ', select').attr('disabled', false); 7464 }, 1).on('close', function () { 7465 picker.$root.find('button, select').attr('disabled', true); 7466 }, 1); 7467 } //DatePicker 7468 7469 7470 /** 7471 * Set a datepicker item object. 7472 */ 7473 DatePicker.prototype.set = function (type, value, options) { 7474 7475 var calendar = this, 7476 calendarItem = calendar.item; 7477 7478 // If the value is `null` just set it immediately. 7479 if (value === null) { 7480 if (type == 'clear') type = 'select'; 7481 calendarItem[type] = value; 7482 return calendar; 7483 } 7484 7485 // Otherwise go through the queue of methods, and invoke the functions. 7486 // Update this as the time unit, and set the final value as this item. 7487 // * In the case of `enable`, keep the queue but set `disable` instead. 7488 // And in the case of `flip`, keep the queue but set `enable` instead. 7489 calendarItem[type == 'enable' ? 'disable' : type == 'flip' ? 'enable' : type] = calendar.queue[type].split(' ').map(function (method) { 7490 value = calendar[method](type, value, options); 7491 return value; 7492 }).pop(); 7493 7494 // Check if we need to cascade through more updates. 7495 if (type == 'select') { 7496 calendar.set('highlight', calendarItem.select, options); 7497 } else if (type == 'highlight') { 7498 calendar.set('view', calendarItem.highlight, options); 7499 } else if (type.match(/^(flip|min|max|disable|enable)$/)) { 7500 if (calendarItem.select && calendar.disabled(calendarItem.select)) { 7501 calendar.set('select', calendarItem.select, options); 7502 } 7503 if (calendarItem.highlight && calendar.disabled(calendarItem.highlight)) { 7504 calendar.set('highlight', calendarItem.highlight, options); 7505 } 7506 } 7507 7508 return calendar; 7509 }; //DatePicker.prototype.set 7510 7511 7512 /** 7513 * Get a datepicker item object. 7514 */ 7515 DatePicker.prototype.get = function (type) { 7516 return this.item[type]; 7517 }; //DatePicker.prototype.get 7518 7519 7520 /** 7521 * Create a picker date object. 7522 */ 7523 DatePicker.prototype.create = function (type, value, options) { 7524 7525 var isInfiniteValue, 7526 calendar = this; 7527 7528 // If thereâs no value, use the type as the value. 7529 value = value === undefined ? type : value; 7530 7531 // If itâs infinity, update the value. 7532 if (value == -Infinity || value == Infinity) { 7533 isInfiniteValue = value; 7534 } 7535 7536 // If itâs an object, use the native date object. 7537 else if ($.isPlainObject(value) && _.isInteger(value.pick)) { 7538 value = value.obj; 7539 } 7540 7541 // If itâs an array, convert it into a date and make sure 7542 // that itâs a valid date â otherwise default to today. 7543 else if ($.isArray(value)) { 7544 value = new Date(value[0], value[1], value[2]); 7545 value = _.isDate(value) ? value : calendar.create().obj; 7546 } 7547 7548 // If itâs a number or date object, make a normalized date. 7549 else if (_.isInteger(value) || _.isDate(value)) { 7550 value = calendar.normalize(new Date(value), options); 7551 } 7552 7553 // If itâs a literal true or any other case, set it to now. 7554 else /*if ( value === true )*/{ 7555 value = calendar.now(type, value, options); 7556 } 7557 7558 // Return the compiled object. 7559 return { 7560 year: isInfiniteValue || value.getFullYear(), 7561 month: isInfiniteValue || value.getMonth(), 7562 date: isInfiniteValue || value.getDate(), 7563 day: isInfiniteValue || value.getDay(), 7564 obj: isInfiniteValue || value, 7565 pick: isInfiniteValue || value.getTime() 7566 }; 7567 }; //DatePicker.prototype.create 7568 7569 7570 /** 7571 * Create a range limit object using an array, date object, 7572 * literal âtrueâ, or integer relative to another time. 7573 */ 7574 DatePicker.prototype.createRange = function (from, to) { 7575 7576 var calendar = this, 7577 createDate = function (date) { 7578 if (date === true || $.isArray(date) || _.isDate(date)) { 7579 return calendar.create(date); 7580 } 7581 return date; 7582 }; 7583 7584 // Create objects if possible. 7585 if (!_.isInteger(from)) { 7586 from = createDate(from); 7587 } 7588 if (!_.isInteger(to)) { 7589 to = createDate(to); 7590 } 7591 7592 // Create relative dates. 7593 if (_.isInteger(from) && $.isPlainObject(to)) { 7594 from = [to.year, to.month, to.date + from]; 7595 } else if (_.isInteger(to) && $.isPlainObject(from)) { 7596 to = [from.year, from.month, from.date + to]; 7597 } 7598 7599 return { 7600 from: createDate(from), 7601 to: createDate(to) 7602 }; 7603 }; //DatePicker.prototype.createRange 7604 7605 7606 /** 7607 * Check if a date unit falls within a date range object. 7608 */ 7609 DatePicker.prototype.withinRange = function (range, dateUnit) { 7610 range = this.createRange(range.from, range.to); 7611 return dateUnit.pick >= range.from.pick && dateUnit.pick <= range.to.pick; 7612 }; 7613 7614 /** 7615 * Check if two date range objects overlap. 7616 */ 7617 DatePicker.prototype.overlapRanges = fun
7617ction (one, two) { 7618 7619 var calendar = this; 7620 7621 // Convert the ranges into comparable dates. 7622 one = calendar.createRange(one.from, one.to); 7623 two = calendar.createRange(two.from, two.to); 7624 7625 return calendar.withinRange(one, two.from) || calendar.withinRange(one, two.to) || calendar.withinRange(two, one.from) || calendar.withinRange(two, one.to); 7626 }; 7627 7628 /** 7629 * Get the date today. 7630 */ 7631 DatePicker.prototype.now = function (type, value, options) { 7632 value = new Date(); 7633 if (options && options.rel) { 7634 value.setDate(value.getDate() + options.rel); 7635 } 7636 return this.normalize(value, options); 7637 }; 7638 7639 /** 7640 * Navigate to next/prev month. 7641 */ 7642 DatePicker.prototype.navigate = function (type, value, options) { 7643 7644 var targetDateObject, 7645 targetYear, 7646 targetMonth, 7647 targetDate, 7648 isTargetArray = $.isArray(value), 7649 isTargetObject = $.isPlainObject(value), 7650 viewsetObject = this.item.view; /*, 7651 safety = 100*/ 7652 7653 if (isTargetArray || isTargetObject) { 7654 7655 if (isTargetObject) { 7656 targetYear = value.year; 7657 targetMonth = value.month; 7658 targetDate = value.date; 7659 } else { 7660 targetYear = +value[0]; 7661 targetMonth = +value[1]; 7662 targetDate = +value[2]; 7663 } 7664 7665 // If weâre navigating months but the view is in a different 7666 // month, navigate to the viewâs year and month. 7667 if (options && options.nav && viewsetObject && viewsetObject.month !== targetMonth) { 7668 targetYear = viewsetObject.year; 7669 targetMonth = viewsetObject.month; 7670 } 7671 7672 // Figure out the expected target year and month. 7673 targetDateObject = new Date(targetYear, targetMonth + (options && options.nav ? options.nav : 0), 1); 7674 targetYear = targetDateObject.getFullYear(); 7675 targetMonth = targetDateObject.getMonth(); 7676 7677 // If the month weâre going to doesnât have enough days, 7678 // keep decreasing the date until we reach the monthâs last date. 7679 while ( /*safety &&*/new Date(targetYear, targetMonth, targetDate).getMonth() !== targetMonth) { 7680 targetDate -= 1; 7681 /*safety -= 1 7682 if ( !safety ) { 7683 throw 'Fell into an infinite loop while navigating to ' + new Date( targetYear, targetMonth, targetDate ) + '.' 7684 }*/ 7685 } 7686 7687 value = [targetYear, targetMonth, targetDate]; 7688 } 7689 7690 return value; 7691 }; //DatePicker.prototype.navigate 7692 7693 7694 /** 7695 * Normalize a date by setting the hours to midnight. 7696 */ 7697 DatePicker.prototype.normalize = function (value /*, options*/) { 7698 value.setHours(0, 0, 0, 0); 7699 return value; 7700 }; 7701 7702 /** 7703 * Measure the range of dates. 7704 */ 7705 DatePicker.prototype.measure = function (type, value /*, options*/) { 7706 7707 var calendar = this; 7708 7709 // If itâs anything false-y, remove the limits. 7710 if (!value) { 7711 value = type == 'min' ? -Infinity : Infinity; 7712 } 7713 7714 // If itâs a string, parse it. 7715 else if (typeof value == 'string') { 7716 value = calendar.parse(type, value); 7717 } 7718 7719 // If it's an integer, get a date relative to today. 7720 else if (_.isInteger(value)) { 7721 value = calendar.now(type, value, { rel: value }); 7722 } 7723 7724 return value; 7725 }; ///DatePicker.prototype.measure 7726 7727 7728 /** 7729 * Create a viewset object based on navigation. 7730 */ 7731 DatePicker.prototype.viewset = function (type, dateObject /*, options*/) { 7732 return this.create([dateObject.year, dateObject.month, 1]); 7733 }; 7734 7735 /** 7736 * Validate a date as enabled and shift if needed. 7737 */ 7738 DatePicker.prototype.validate = function (type, dateObject, options) { 7739 7740 var calendar = this, 7741 7742 7743 // Keep a reference to the original date. 7744 originalDateObject = dateObject, 7745 7746 7747 // Make sure we have an interval. 7748 interval = options && options.interval ? options.interval : 1, 7749 7750 7751 // Check if the calendar enabled dates are inverted. 7752 isFlippedBase = calendar.item.enable === -1, 7753 7754 7755 // Check if we have any enabled dates after/before now. 7756 hasEnabledBeforeTarget, 7757 hasEnabledAfterTarget, 7758 7759 7760 // The min & max limits. 7761 minLimitObject = calendar.item.min, 7762 maxLimitObject = calendar.item.max, 7763 7764 7765 // Check if weâve reached the limit during shifting. 7766 reachedMin, 7767 reachedMax, 7768 7769 7770 // Check if the calendar is inverted and at least one weekday is enabled. 7771 hasEnabledWeekdays = isFlippedBase && calendar.item.disable.filter(function (value) { 7772 7773 // If thereâs a date, check where it is relative to the target. 7774 if ($.isArray(value)) { 7775 var dateTime = calendar.create(value).pick; 7776 if (dateTime < dateObject.pick) hasEnabledBeforeTarget = true;else if (dateTime > dateObject.pick) hasEnabledAfterTarget = true; 7777 } 7778 7779 // Return only integers for enabled weekdays. 7780 return _.isInteger(value); 7781 }).length; /*, 7782 safety = 100*/ 7783 7784 // Cases to validate for: 7785 // [1] Not inverted and date disabled. 7786 // [2] Inverted and some dates enabled. 7787 // [3] Not inverted and out of range. 7788 // 7789 // Cases to **not** validate for: 7790 // ⢠Navigating months. 7791 // ⢠Not inverted and date enabled. 7792 // ⢠Inverted and all dates disabled. 7793 // ⢠..and anything else. 7794 if (!options || !options.nav) if ( 7795 /* 1 */!isFlippedBase && calendar.disabled(dateObject) || 7796 /* 2 */isFlippedBase && calendar.disabled(dateObject) && (hasEnabledWeekdays || hasEnabledBeforeTarget || hasEnabledAfterTarget) || 7797 /* 3 */!isFlippedBase && (dateObject.pick <= minLimitObject.pick || dateObject.pick >= maxLimitObject.pick)) { 7798 7799 // When inverted, flip the direction if there arenât any enabled weekdays 7800 // and there are no enabled dates in the direction of the interval. 7801 if (isFlippedBase && !hasEnabledWeekdays && (!hasEnabledAfterTarget && interval > 0 || !hasEnabledBeforeTarget && interval < 0)) { 7802 interval *= -1; 7803 } 7804 7805 // Keep looping until we reach an enabled date. 7806 while ( /*safety &&*/calendar.disabled(dateObject)) { 7807 7808 /*safety -= 1 7809 if ( !safety ) { 7810 throw 'Fell into an infinite loop while validating ' + dateObject.obj + '.' 7811 }*/ 7812 7813 // If weâve looped into the next/prev month with a large interval, return to the original date and flatten the interval. 7814 if (Math.abs(interval) > 1 && (dateObject.month < originalDateObject.month || dateObject.month > originalDateObject.month)) { 7815 dateObject = originalDateObject; 7816 interval = interval > 0 ? 1 : -1; 7817 } 7818 7819 // If weâve reached the min/max limit, reverse the direction, flatten the interval and set it to the limit. 7820 if (dateObject.pick <= minLimitObject.pick) { 7821 reachedMin = true; 7822 interval = 1; 7823 dateObject = calendar.create([minLimitObject.year, minLimitObject.month, minLimitObject.date + (dateObject.pick === minLimitObject.pick ? 0 : -1)]); 7824 } else if (dateObject.pick >= maxLimitObject.pick) { 7825 reachedMax = true; 7826 interval = -1; 7827 dateObject = calendar.create([maxLimitObject.year, maxLimitObject.month, maxLimitObject.date + (dateObject.pick === maxLimitObject.pick ? 0 : 1)]); 7828 } 7829 7830 // If weâve reached both limits, just break out of the loop. 7831 if (reachedMin && reachedMax) { 7832 break; 7833 } 7834 7835 // Finally, create the shifted date using the interval and keep looping. 7836 dateObject = calendar.create([dateObject.year, dateObject.month, dateObject.date + interval]); 7837 } 7838 } //endif 7839 7840 7841 // Return the date object settled on. 7842 return dateObject; 7843 }; //DatePicker.prototype.validate 7844 7845 7846 /** 7847 * Check if a date is disabled. 7848 */ 7849 DatePicker.prototype.disabled = function (dateToVerify) { 7850 7851 var calendar = this, 7852 7853 7854 // Filter through the disabled dates to check if this is one. 7855 isDisabledMatch = calendar.item.disable.filter(function (dateToDisable) { 7856 7857 // If the date is a number, match the weekday with 0index and `firstDay` check. 7858 if (_.isInteger(dateToDisable)) { 7859 return dateToVerify.day === (calendar.settings.firstDay ? dateToDisable : dateToDisable - 1) % 7; 7860 } 7861 7862 // If itâs an array or a native JS date, create and match the exact date. 7863 if ($.isArray(dateToDisable) || _.isDate(dateToDisable)) { 7864 return dateToVerify.pick === calendar.create(dateToDisable).pick; 7865 } 7866 7867 // If itâs an object, match a date within the âfromâ and âtoâ range. 7868 if ($.isPlainObject(dateToDisable)) { 7869 return calendar.withinRange(dateToDisable, dateToVerify); 7870 } 7871 }); 7872 7873 // If this date matches a disabled date, confirm itâs not inverted. 7874 isDisabledMatch = isDisabledMatch.length && !isDisabledMatch.filter(function (dateToDisable) { 7875 return $.isArray(dateToDisable) && dateToDisable[3] == 'inverted' || $.isPlainObject(dateToDisable) && dateToDisable.inverted; 7876 }).length; 7877 7878 // Check the calendar âenabledâ flag and respectively flip the 7879 // disabled state. Then also check if itâs beyond the min/max limits. 7880 return calendar.item.enable === -1 ? !isDisabledMatch : isDisabledMatch || dateToVerify.pick < calendar.item.min.pick || dateToVerify.pick > calendar.item.max.pick; 7881 }; //DatePicker.prototype.disabled 7882 7883 7884 /** 7885 * Parse a string into a usable type. 7886 */ 7887 DatePicker.prototype.parse = function (type, value, options) { 7888 7889 var calendar = this, 7890 parsingObject = {}; 7891 7892 // If itâs already parsed, weâre good. 7893 if (!value || typeof value != 'string') { 7894 return value; 7895 } 7896 7897 // We need a `.format` to parse the value with. 7898 if (!(options && options.format)) { 7899 options = options || {}; 7900 options.format = calendar.settings.format; 7901 } 7902 7903 // Convert the format into an array and then map through it. 7904 calendar.formats.toArray(options.format).map(function (label) { 7905 7906 var 7907 // Grab the formatting label. 7908 formattingLabel = calendar.formats[label], 7909 7910 7911 // The format length is from the formatting label function or the 7912 // label length without the escaping exclamation (!) mark. 7913 formatLength = formattingLabel ? _.trigger(formattingLabel, calendar, [value, parsingObject]) : label.replace(/^!/, '').length; 7914 7915 // If there's a format label, split the value up to the format length. 7916 // Then add it to the parsing object with appropriate label. 7917 if (formattingLabel) { 7918 parsingObject[label] = value.substr(0, formatLength); 7919 } 7920 7921 // Update the value as the substring from format length to end. 7922 value = value.substr(formatLength); 7923 }); 7924 7925 // Compensate for month 0index. 7926 return [parsingObject.yyyy || parsingObject.yy, +(parsingObject.mm || parsingObject.m) - 1, parsingObject.dd || parsingObject.d]; 7927 }; //DatePicker.prototype.parse 7928 7929 7930 /** 7931 * Various formats to display the object in. 7932 */ 7933 DatePicker.prototype.formats = function () { 7934 7935 // Return the length of the first word in a collection. 7936 function getWordLengthFromCollection(string, collection, dateObject) { 7937 7938 // Grab the first word from the string. 7939 var word = string.match(/\w+/)[0]; 7940 7941 // If there's no month index, add it to the date object 7942 if (!dateObject.mm && !dateObject.m) { 7943 dateObject.m = collection.indexOf(word) + 1; 7944 } 7945 7946 // Return the length of the word. 7947 return word.length; 7948 } 7949 7950 // Get the length of the first word in a string. 7951 function getFirstWordLength(string) { 7952 return string.match(/\w+/)[0].length; 7953 } 7954 7955 return { 7956 7957 d: function (string, dateObject) { 7958 7959 // If there's string, then get the digits length. 7960 // Otherwise return the selected date. 7961 return string ? _.digits(string) : dateObject.date; 7962 }, 7963 dd: function (string, dateObject) { 7964 7965 // If there's a string, then the length is always 2. 7966 // Otherwise return the selected date with a leading zero. 7967 return string ? 2 : _.lead(dateObject.date); 7968 }, 7969 ddd: function (string, dateObject) { 7970 7971 // If there's a string, then get the length of the first word. 7972 // Otherwise return the short selected weekday. 7973 return string ? getFirstWordLength(string) : this.settings.weekdaysShort[dateObject.day]; 7974 }, 7975 dddd: function (string, dateObject) { 7976 7977 // If there's a string, then get the length of the first word. 7978 // Otherwise return the full selected weekday. 7979 return string ? getFirstWordLength(string) : this.settings.weekdaysFull[dateObject.day]; 7980 }, 7981 m: function (string, dateObject) { 7982 7983 // If there's a string, then get the length of the digits 7984 // Otherwise return the selected month with 0index compensation. 7985 return string ? _.digits(string) : dateObject.month + 1; 7986 }, 7987 mm: function (string, dateObject) { 7988 7989 // If there's a string, then the length is always 2. 7990 // Otherwise return the selected month with 0index and leading zero. 7991 return string ? 2 : _.lead(dateObject.month + 1); 7992 }, 7993 mmm: function (string, dateObject) { 7994 7995 var collection = this.settings.monthsShort; 7996 7997 // If there's a string, get length of the relevant month from the short 7998 // months collection. Otherwise return the selected month from that c
7998ollection. 7999 return string ? getWordLengthFromCollection(string, collection, dateObject) : collection[dateObject.month]; 8000 }, 8001 mmmm: function (string, dateObject) { 8002 8003 var collection = this.settings.monthsFull; 8004 8005 // If there's a string, get length of the relevant month from the full 8006 // months collection. Otherwise return the selected month from that collection. 8007 return string ? getWordLengthFromCollection(string, collection, dateObject) : collection[dateObject.month]; 8008 }, 8009 yy: function (string, dateObject) { 8010 8011 // If there's a string, then the length is always 2. 8012 // Otherwise return the selected year by slicing out the first 2 digits. 8013 return string ? 2 : ('' + dateObject.year).slice(2); 8014 }, 8015 yyyy: function (string, dateObject) { 8016 8017 // If there's a string, then the length is always 4. 8018 // Otherwise return the selected year. 8019 return string ? 4 : dateObject.year; 8020 }, 8021 8022 // Create an array by splitting the formatting string passed. 8023 toArray: function (formatString) { 8024 return formatString.split(/(d{1,4}|m{1,4}|y{4}|yy|!.)/g); 8025 }, 8026 8027 // Format an object into a string using the formatting options. 8028 toString: function (formatString, itemObject) { 8029 var calendar = this; 8030 return calendar.formats.toArray(formatString).map(function (label) { 8031 return _.trigger(calendar.formats[label], calendar, [0, itemObject]) || label.replace(/^!/, ''); 8032 }).join(''); 8033 } 8034 }; 8035 }(); //DatePicker.prototype.formats 8036 8037 8038 /** 8039 * Check if two date units are the exact. 8040 */ 8041 DatePicker.prototype.isDateExact = function (one, two) { 8042 8043 var calendar = this; 8044 8045 // When weâre working with weekdays, do a direct comparison. 8046 if (_.isInteger(one) && _.isInteger(two) || typeof one == 'boolean' && typeof two == 'boolean') { 8047 return one === two; 8048 } 8049 8050 // When weâre working with date representations, compare the âpickâ value. 8051 if ((_.isDate(one) || $.isArray(one)) && (_.isDate(two) || $.isArray(two))) { 8052 return calendar.create(one).pick === calendar.create(two).pick; 8053 } 8054 8055 // When weâre working with range objects, compare the âfromâ and âtoâ. 8056 if ($.isPlainObject(one) && $.isPlainObject(two)) { 8057 return calendar.isDateExact(one.from, two.from) && calendar.isDateExact(one.to, two.to); 8058 } 8059 8060 return false; 8061 }; 8062 8063 /** 8064 * Check if two date units overlap. 8065 */ 8066 DatePicker.prototype.isDateOverlap = function (one, two) { 8067 8068 var calendar = this, 8069 firstDay = calendar.settings.firstDay ? 1 : 0; 8070 8071 // When weâre working with a weekday index, compare the days. 8072 if (_.isInteger(one) && (_.isDate(two) || $.isArray(two))) { 8073 one = one % 7 + firstDay; 8074 return one === calendar.create(two).day + 1; 8075 } 8076 if (_.isInteger(two) && (_.isDate(one) || $.isArray(one))) { 8077 two = two % 7 + firstDay; 8078 return two === calendar.create(one).day + 1; 8079 } 8080 8081 // When weâre working with range objects, check if the ranges overlap. 8082 if ($.isPlainObject(one) && $.isPlainObject(two)) { 8083 return calendar.overlapRanges(one, two); 8084 } 8085 8086 return false; 8087 }; 8088 8089 /** 8090 * Flip the âenabledâ state. 8091 */ 8092 DatePicker.prototype.flipEnable = function (val) { 8093 var itemObject = this.item; 8094 itemObject.enable = val || (itemObject.enable == -1 ? 1 : -1); 8095 }; 8096 8097 /** 8098 * Mark a collection of dates as âdisabledâ. 8099 */ 8100 DatePicker.prototype.deactivate = function (type, datesToDisable) { 8101 8102 var calendar = this, 8103 disabledItems = calendar.item.disable.slice(0); 8104 8105 // If weâre flipping, thatâs all we need to do. 8106 if (datesToDisable == 'flip') { 8107 calendar.flipEnable(); 8108 } else if (datesToDisable === false) { 8109 calendar.flipEnable(1); 8110 disabledItems = []; 8111 } else if (datesToDisable === true) { 8112 calendar.flipEnable(-1); 8113 disabledItems = []; 8114 } 8115 8116 // Otherwise go through the dates to disable. 8117 else { 8118 8119 datesToDisable.map(function (unitToDisable) { 8120 8121 var matchFound; 8122 8123 // When we have disabled items, check for matches. 8124 // If something is matched, immediately break out. 8125 for (var index = 0; index < disabledItems.length; index += 1) { 8126 if (calendar.isDateExact(unitToDisable, disabledItems[index])) { 8127 matchFound = true; 8128 break; 8129 } 8130 } 8131 8132 // If nothing was found, add the validated unit to the collection. 8133 if (!matchFound) { 8134 if (_.isInteger(unitToDisable) || _.isDate(unitToDisable) || $.isArray(unitToDisable) || $.isPlainObject(unitToDisable) && unitToDisable.from && unitToDisable.to) { 8135 disabledItems.push(unitToDisable); 8136 } 8137 } 8138 }); 8139 } 8140 8141 // Return the updated collection. 8142 return disabledItems; 8143 }; //DatePicker.prototype.deactivate 8144 8145 8146 /** 8147 * Mark a collection of dates as âenabledâ. 8148 */ 8149 DatePicker.prototype.activate = function (type, datesToEnable) { 8150 8151 var calendar = this, 8152 disabledItems = calendar.item.disable, 8153 disabledItemsCount = disabledItems.length; 8154 8155 // If weâre flipping, thatâs all we need to do. 8156 if (datesToEnable == 'flip') { 8157 calendar.flipEnable(); 8158 } else if (datesToEnable === true) { 8159 calendar.flipEnable(1); 8160 disabledItems = []; 8161 } else if (datesToEnable === false) { 8162 calendar.flipEnable(-1); 8163 disabledItems = []; 8164 } 8165 8166 // Otherwise go through the disabled dates. 8167 else { 8168 8169 datesToEnable.map(function (unitToEnable) { 8170 8171 var matchFound, disabledUnit, index, isExactRange; 8172 8173 // Go through the disabled items and try to find a match. 8174 for (index = 0; index < disabledItemsCount; index += 1) { 8175 8176 disabledUnit = disabledItems[index]; 8177 8178 // When an exact match is found, remove it from the collection. 8179 if (calendar.isDateExact(disabledUnit, unitToEnable)) { 8180 matchFound = disabledItems[index] = null; 8181 isExactRange = true; 8182 break; 8183 } 8184 8185 // When an overlapped match is found, add the âinvertedâ state to it. 8186 else if (calendar.isDateOverlap(disabledUnit, unitToEnable)) { 8187 if ($.isPlainObject(unitToEnable)) { 8188 unitToEnable.inverted = true; 8189 matchFound = unitToEnable; 8190 } else if ($.isArray(unitToEnable)) { 8191 matchFound = unitToEnable; 8192 if (!matchFound[3]) matchFound.push('inverted'); 8193 } else if (_.isDate(unitToEnable)) { 8194 matchFound = [unitToEnable.getFullYear(), unitToEnable.getMonth(), unitToEnable.getDate(), 'inverted']; 8195 } 8196 break; 8197 } 8198 } 8199 8200 // If a match was found, remove a previous duplicate entry. 8201 if (matchFound) for (index = 0; index < disabledItemsCount; index += 1) { 8202 if (calendar.isDateExact(disabledItems[index], unitToEnable)) { 8203 disabledItems[index] = null; 8204 break; 8205 } 8206 } 8207 8208 // In the event that weâre dealing with an exact range of dates, 8209 // make sure there are no âinvertedâ dates because of it. 8210 if (isExactRange) for (index = 0; index < disabledItemsCount; index += 1) { 8211 if (calendar.isDateOverlap(disabledItems[index], unitToEnable)) { 8212 disabledItems[index] = null; 8213 break; 8214 } 8215 } 8216 8217 // If something is still matched, add it into the collection. 8218 if (matchFound) { 8219 disabledItems.push(matchFound); 8220 } 8221 }); 8222 } 8223 8224 // Return the updated collection. 8225 return disabledItems.filter(function (val) { 8226 return val != null; 8227 }); 8228 }; //DatePicker.prototype.activate 8229 8230 8231 /** 8232 * Create a string for the nodes in the picker. 8233 */ 8234 DatePicker.prototype.nodes = function (isOpen) { 8235 8236 var calendar = this, 8237 settings = calendar.settings, 8238 calendarItem = calendar.item, 8239 nowObject = calendarItem.now, 8240 selectedObject = calendarItem.select, 8241 highlightedObject = calendarItem.highlight, 8242 viewsetObject = calendarItem.view, 8243 disabledCollection = calendarItem.disable, 8244 minLimitObject = calendarItem.min, 8245 maxLimitObject = calendarItem.max, 8246 8247 8248 // Create the calendar table head using a copy of weekday labels collection. 8249 // * We do a copy so we don't mutate the original array. 8250 tableHead = function (collection, fullCollection) { 8251 8252 // If the first day should be Monday, move Sunday to the end. 8253 if (settings.firstDay) { 8254 collection.push(collection.shift()); 8255 fullCollection.push(fullCollection.shift()); 8256 } 8257 8258 // Create and return the table head group.
8259 return _.node('thead', _.node('tr', _.group({ 8260 min: 0, 8261 max: DAYS_IN_WEEK - 1, 8262 i: 1, 8263 node: 'th', 8264 item: function (counter) { 8265 return [collection[counter], settings.klass.weekdays, 'scope=col title="' + fullCollection[counter] + '"']; 8266 } 8267 }))); //endreturn 8268 8269 // Materialize modified 8270 }((settings.showWeekdaysFull ? settings.weekdaysFull : settings.weekdaysLetter).slice(0), settings.weekdaysFull.slice(0)), 8271 //tableHead 8272 8273 8274 // Create the nav for next/prev month. 8275 createMonthNav = function (next) { 8276 8277 // Otherwise, return the created month tag. 8278 return _.node('div', ' ', settings.klass['nav' + (next ? 'Next' : 'Prev')] + ( 8279 8280 // If the focused month is outside the range, disabled the button. 8281 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({ 8282 role: 'button', 8283 controls: calendar.$node[0].id + '_table' 8284 }) + ' ' + 'title="' + (next ? settings.labelMonthNext : settings.labelMonthPrev) + '"'); //endreturn 8285 }, 8286 //createMonthNav 8287 8288 8289 // Create the month label. 8290 //Materialize modified 8291 createMonthLabel = function (override) { 8292 8293 var monthsCollection = settings.showMonthsShort ? settings.monthsShort : settings.monthsFull; 8294 8295 // Materialize modified 8296 if (override == "short_months") { 8297 monthsCollection = settings.monthsShort; 8298 } 8299 8300 // If there are months to select, add a dropdown menu. 8301 if (settings.selectMonths && override == undefined) { 8302 8303 return _.node('select', _.group({ 8304 min: 0, 8305 max: 11, 8306 i: 1, 8307 node: 'option', 8308 item: function (loopedMonth) { 8309 8310 return [ 8311 8312 // The looped month and no classes. 8313 monthsCollection[loopedMonth], 0, 8314 8315 // Set the value and selected index. 8316 'value=' + loopedMonth + (viewsetObject.month == loopedMonth ? ' selected' : '') + (viewsetObject.year == minLimitObject.year && loopedMonth < minLimitObject.month || viewsetObject.year == maxLimitObject.year && loopedMonth > maxLimitObject.month ? ' disabled' : '')]; 8317 } 8318 }), settings.klass.selectMonth + ' browser-default', (isOpen ? '' : 'disabled') + ' ' + _.ariaAttr({ controls: calendar.$node[0].id + '_table' }) + ' ' + 'title="' + settings.labelMonthSelect + '"'); 8319 } 8320 8321 // Materialize modified 8322 if (override == "short_months") if (selectedObject != null) return monthsCollection[selectedObject.month];else return monthsCollection[viewsetObject.month]; 8323 8324 // If there's a need for a month selector 8325 return _.node('div', monthsCollection[viewsetObject.month], settings.klass.month); 8326 }, 8327 //createMonthLabel 8328 8329 8330 // Create the year label. 8331 // Materialize modified 8332 createYearLabel = function (override) { 8333 8334 var focusedYear = viewsetObject.year, 8335 8336 8337 // If years selector is set to a literal "true", set it to 5. Otherwise 8338 // divide in half to get half before and half after focused year. 8339 numberYears = settings.selectYears === true ? 5 : ~~(settings.selectYears / 2); 8340 8341 // If there are years to select, add a dropdown menu. 8342 if (numberYears) { 8343 8344 var minYear = minLimitObject.year, 8345 maxYear = maxLimitObject.year, 8346 lowestYear = focusedYear - numberYears, 8347 highestYear = focusedYear + numberYears; 8348 8349 // If the min year is greater than the lowest year, increase the highest year 8350 // by the difference and set the lowest year to the min year. 8351 if (minYear > lowestYear) { 8352 highestYear += minYear - lowestYear; 8353 lowestYear = minYear; 8354 } 8355 8356 // If the max year is less than the highest year, decrease the lowest year 8357 // by the lower of the two: available and needed years. Then set the 8358 // highest year to the max year. 8359 if (maxYear < highestYear) { 8360 8361 var availableYears = lowestYear - minYear, 8362 neededYears = highestYear - maxYear; 8363 8364 lowestYear -= availableYears > neededYears ? neededYears : availableYears;
8365 highestYear = maxYear; 8366 } 8367 8368 if (settings.selectYears && override == undefined) { 8369 return _.node('select', _.group({ 8370 min: lowestYear, 8371 max: highestYear, 8372 i: 1, 8373 node: 'option', 8374 item: function (loopedYear) { 8375 return [ 8376 8377 // The looped year and no classes. 8378 loopedYear, 0, 8379 8380 // Set the value and selected index. 8381 'value=' + loopedYear + (focusedYear == loopedYear ? ' selected' : '')]; 8382 } 8383 }), settings.klass.selectYear + ' browser-default', (isOpen ? '' : 'disabled') + ' ' + _.ariaAttr({ controls: calendar.$node[0].id + '_table' }) + ' ' + 'title="' + settings.labelYearSelect + '"'); 8384 } 8385 } 8386 8387 // Materialize modified 8388 if (override === 'raw' && selectedObject != null) { 8389 return _.node('div', selectedObject.year); 8390 } 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: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], 8514 monthsShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], 8515 weekdaysFull: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], 8516 weekdaysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], 8517 8518 // Materialize modified 8519 8520 weekdaysLetter: ['S', 'M', 'T', 'W', 'T', 'F', 'S'], 8521 8522 // Today and clear 8523 today: 'Today', 8524 clear: 'Clear', 8525 close: 'Ok', 8526 8527 // Picker close behavior (Prevent a change in behaviour for backwards compatibility) 8528 closeOnSelect: false, 8529 8530 // The format to show on the `input` element 8531 format: 'd mmmm, yyyy', 8532 8533 // Classes 8534 klass: { 8535 8536 table: prefix + 'table', 8537 8538 header: prefix + 'header', 8539 8540 // Materialize Added klasses 8541 date_display: prefix + 'date-display', 8542 day_display: prefix + 'day-display', 8543 month_display: prefix + 'month-display', 8544 year_display: prefix + 'year-display', 8545 calendar_container: prefix + 'calendar-container', 8546 // end 8547 8548 8549 navPrev: prefix + 'nav--prev', 8550 navNext: prefix + 'nav--next', 8551 navDisabled: prefix + 'nav--disabled', 8552 8553 month: prefix + 'month', 8554 year: prefix + 'year', 8555 8556 selectMonth: prefix + 'select--month', 8557 selectYear: prefix + 'select--year', 8558 8559 weekdays: prefix + 'weekday', 8560 8561 day: prefix + 'day', 8562 disabled: prefix + 'day--disabled', 8563 selected: prefix + 'day--selected', 8564 highlighted: prefix + 'day--highlighted', 8565 now: prefix + 'day--today', 8566 infocus: prefix + 'day--infocus', 8567 outfocus: prefix + 'day--outfocus', 8568 8569 footer: prefix + 'footer', 8570 8571 buttonClear: prefix + 'button--clear', 8572 buttonToday: prefix + 'button--today', 8573 buttonClose: prefix + 'button--close' 8574 } 8575 }; 8576 }(Picker.klasses().picker + '__'); 8577 8578 /** 8579 * Extend the picker to add the date picker. 8580 */ 8581 Picker.extend('pickadate', DatePicker); 8582}); 8583; /*! 8584 * ClockPicker v0.0.7 (http://weareoutman.github.io/clockpicker/) 8585 * Copyright 2014 Wang Shenwei. 8586 * Licensed under MIT (https://github.com/weareoutman/clockpicker/blob/gh-pages/LICENSE) 8587 * 8588 * Further modified 8589 * Copyright 2015 Ching Yaw Hao. 8590 */ 8591 8592(function ($) { 8593 var $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 = 70, 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 8953 // Append popover to input by default 8954 var containerEl = document.querySelector(this.options.container); 8955 if (this.options.container && containerEl) { 8956 containerEl.appendChild(this.popover[0]); 8957 } else { 8958 this.popover.insertAfter(this.input); 8959 } 8960 8961 if (this.options.twelvehour) { 8962 if (this.amOrPm === 'PM') { 8963 this.spanAmPm.children('#click-pm').addClass("text-primary"); 8964 this.spanAmPm.children('#click-am').removeClass("text-primary"); 8965 } else { 8966 this.spanAmPm.children('#click-am').addClass("text-primary"); 8967 this.spanAmPm.children('#click-pm').removeClass("text-primary"); 8968 } 8969 } 8970 // Reset position when resize 8971 $win.on('resize.clockpicker' + this.id, function () { 8972 if (self.isShown) { 8973 self.locate(); 8974 } 8975 }); 8976 this.isAppended = true; 8977 } 8978 // Toggle to hours view 8979 this.toggleView('hours'); 8980 // Set position 8981 this.locate(); 8982 this.isShown = true; 8983 // Hide when clicking or tabbing on any element except the clock and input 8984 $doc.on('click.clockpicker.' + this.id + ' focusin.clockpicker.' + this.id, function (e) { 8985 var target = $(e.target); 8986 if (target.closest(self.popover.find('.picker__wrap')).length === 0 && target.closest(self.input).length === 0) { 8987 self.hide(); 8988 } 8989 }); 8990 // Hide when ESC is pressed 8991 $doc.on('keyup.clockpicker.' + this.id, function (e) { 8992 if (e.keyCode === 27) { 8993 self.hide(); 8994 } 8995 }); 8996 raiseCallback(this.options.afterShow); 8997 }; 8998 // Hide popover 8999 ClockPicker.prototype.hide = function () { 9000 raiseCallback(this.options.beforeHide); 9001 this.input.removeClass('picker__input picker__input--active'); 9002 this.popover.removeClass('picker--opened'); 9003 $(document.body).css('overflow', 'visible'); 9004 this.isShown = false;
vendor: 4,323 bytes, lines 9005-9142
9005 $(':input').each(function (index) { 9006 $(this).attr('tabindex', index + 1); 9007 }); 9008 // Unbinding events on document 9009 $doc.off('click.clockpicker.' + this.id + ' focusin.clockpicker.' + this.id); 9010 $doc.off('keyup.clockpicker.' + this.id); 9011 this.popover.hide(); 9012 raiseCallback(this.options.afterHide); 9013 }; 9014 // Toggle to hours or minutes view 9015 ClockPicker.prototype.toggleView = function (view, delay) { 9016 var raiseAfterHourSelect = false; 9017 if (view === 'minutes' && $(this.hoursView).css("visibility") === "visible") { 9018 raiseCallback(this.options.beforeHourSelect); 9019 raiseAfterHourSelect = true; 9020 } 9021 var isHours = view === 'hours', 9022 nextView = isHours ? this.hoursView : this.minutesView, 9023 hideView = isHours ? this.minutesView : this.hoursView; 9024 this.currentView = view; 9025 9026 this.spanHours.toggleClass('text-primary', isHours); 9027 this.spanMinutes.toggleClass('text-primary', !isHours); 9028 9029 // Let's make transitions 9030 hideView.addClass('clockpicker-dial-out'); 9031 nextView.css('visibility', 'visible').removeClass('clockpicker-dial-out'); 9032 9033 // Reset clock hand 9034 this.resetClock(delay); 9035 9036 // After transitions ended 9037 clearTimeout(this.toggleViewTimer); 9038 this.toggleViewTimer = setTimeout(function () { 9039 hideView.css('visibility', 'hidden'); 9040 }, duration); 9041 9042 if (raiseAfterHourSelect) { 9043 raiseCallback(this.options.afterHourSelect); 9044 } 9045 }; 9046 9047 // Reset clock hand 9048 ClockPicker.prototype.resetClock = function (delay) { 9049 var view = this.currentView, 9050 value = this[view], 9051 isHours = view === 'hours', 9052 unit = Math.PI / (isHours ? 6 : 30), 9053 radian = value * unit, 9054 radius = isHours && value > 0 && value < 13 ? innerRadius : outerRadius, 9055 x = Math.sin(radian) * radius, 9056 y = -Math.cos(radian) * radius, 9057 self = this; 9058 9059 if (svgSupported && delay) { 9060 self.canvas.addClass('clockpicker-canvas-out'); 9061 setTimeout(function () { 9062 self.canvas.removeClass('clockpicker-canvas-out'); 9063 self.setHand(x, y); 9064 }, delay); 9065 } else this.setHand(x, y); 9066 }; 9067 9068 // Set clock hand to (x, y) 9069 ClockPicker.prototype.setHand = function (x, y, roundBy5, dragging) { 9070 var radian = Math.atan2(x, -y), 9071 isHours = this.currentView === 'hours', 9072 unit = Math.PI / (isHours || roundBy5 ? 6 : 30), 9073 z = Math.sqrt(x * x + y * y), 9074 options = this.options, 9075 inner = isHours && z < (outerRadius + innerRadius) / 2, 9076 radius = inner ? innerRadius : outerRadius, 9077 value; 9078 9079 if (options.twelvehour) { 9080 radius = outerRadius; 9081 } 9082 9083 // Radian should in range [0, 2PI] 9084 if (radian < 0) { 9085 radian = Math.PI * 2 + radian; 9086 } 9087 9088 // Get the round value 9089 value = Math.round(radian / unit); 9090 9091 // Get the round radian 9092 radian = value * unit; 9093 9094 // Correct the hours or minutes 9095 if (options.twelvehour) { 9096 if (isHours) { 9097 if (value === 0) value = 12; 9098 } else { 9099 if (roundBy5) value *= 5; 9100 if (value === 60) value = 0; 9101 } 9102 } else { 9103 if (isHours) { 9104 if (value === 12) value = 0; 9105 value = inner ? value === 0 ? 12 : value : value === 0 ? 0 : value + 12; 9106 } else { 9107 if (roundBy5) value *= 5; 9108 if (value === 60) value = 0; 9109 } 9110 } 9111 9112 // Once hours or minutes changed, vibrate the device 9113 if (this[this.currentView] !== value) { 9114 if (vibrate && this.options.vibrate) { 9115 // Do not vibrate too frequently 9116 if (!this.vibrateTimer) { 9117 navigator[vibrate](10); 9118 this.vibrateTimer = setTimeout($.proxy(function () { 9119 this.vibrateTimer = null; 9120 }, this), 100); 9121 } 9122 } 9123 } 9124 9125 this[this.currentView] = value; 9126 if (isHours) { 9127 this['spanHours'].html(value); 9128 } else { 9129 this['spanMinutes'].html(leadingZero(value)); 9130 } 9131 9132 // If svg is not supported, just add an active class to the tick 9133 if (!svgSupported) { 9134 this[isHours ? 'hoursView' : 'minutesView'].find('.clockpicker-tick').each(function () { 9135 var tick = $(this); 9136 tick.toggleClass('active', value === +tick.html()); 9137 }); 9138 return; 9139 } 9140 9141 // Set clock hand and others' position 9142 var cx1 = Math.sin(radian) * (radius - tickRadius),
9143 cy1 = -Math.cos(radian) * (radius - tickRadius), 9144 cx2 = Math.sin(radian) * radius, 9145 cy2 = -Math.cos(radian) * radius; 9146 this.hand.setAttribute('x2', cx1); 9147 this.hand.setAttribute('y2', cy1); 9148 this.bg.setAttribute('cx', cx2); 9149 this.bg.setAttribute('cy', cy2); 9150 }; 9151 9152 // Hours and minutes are selected 9153 ClockPicker.prototype.done = function () { 9154 raiseCallback(this.options.beforeDone); 9155 this.hide(); 9156 this.label.addClass('active'); 9157 9158 var last = this.input.prop('value'), 9159 value = leadingZero(this.hours) + ':' + leadingZero(this.minutes); 9160 if (this.options.twelvehour) { 9161 value = value + this.amOrPm; 9162 } 9163 9164 this.input.prop('value', value); 9165 if (value !== last) { 9166 this.input.triggerHandler('change'); 9167 if (!this.isInput) { 9168 this.element.trigger('change'); 9169 } 9170 } 9171 9172 if (this.options.autoclose) this.input.trigger('blur'); 9173 9174 raiseCallback(this.options.afterDone); 9175 }; 9176 9177 // Clear input field 9178 ClockPicker.prototype.clear = function () { 9179 this.hide(); 9180 this.label.removeClass('active'); 9181 9182 var last = this.input.prop('value'), 9183 value = ''; 9184 9185 this.input.prop('value', value); 9186 if (value !== last) { 9187 this.input.triggerHandler('change'); 9188 if (!this.isInput) { 9189 this.element.trigger('change'); 9190 } 9191 } 9192 9193 if (this.options.autoclose) { 9194 this.input.trigger('blur'); 9195 } 9196 }; 9197 9198 // Remove clockpicker from input 9199 ClockPicker.prototype.remove = function () { 9200 this.element.removeData('clockpicker'); 9201 this.input.off('focus.clockpicker click.clockpicker'); 9202 if (this.isShown) { 9203 this.hide(); 9204 } 9205 if (this.isAppended) { 9206 $win.off('resize.clockpicker' + this.id); 9207 this.popover.remove(); 9208 } 9209 }; 9210 9211 // Extends $.fn.clockpicker 9212 $.fn.pickatime = function (option) { 9213 var args = Array.prototype.slice.call(arguments, 1); 9214 return this.each(function () { 9215 var $this = $(this), 9216 data = $this.data('clockpicker'); 9217 if (!data) { 9218 var options = $.extend({}, ClockPicker.DEFAULTS, $this.data(), typeof option == 'object' && option); 9219 $this.data('clockpicker', new ClockPicker($this, options)); 9220 } else { 9221 // Manual operatsions. show, hide, remove, e.g. 9222 if (typeof data[option] === 'function') { 9223 data[option].apply(data, args); 9224 } 9225 } 9226 }); 9227 }; 9228})(jQuery); 9229;(function ($) { 9230 9231 $.fn.characterCounter = function () { 9232 return this.each(function () { 9233 var $input = $(this); 9234 var $counterElement = $input.parent().find('span[class="character-counter"]'); 9235 9236 // character counter has already been added appended to the parent container 9237 if ($counterElement.length) { 9238 return; 9239 } 9240 9241 var itHasLengthAttribute = $input.attr('data-length') !== undefined; 9242 9243 if (itHasLengthAttribute) { 9244 $input.on('input', updateCounter); 9245 $input.on('focus', updateCounter); 9246 $input.on('blur', removeCounterElement); 9247 9248 addCounterElement($input); 9249 } 9250 }); 9251 }; 9252 9253 function updateCounter() { 9254 var maxLength = +$(this).attr('data-length'), 9255 actualLength = +$(this).val().length, 9256 isValidLength = actualLength <= maxLength; 9257 9258 $(this).parent().find('span[class="character-counter"]').html(actualLength + '/' + maxLength); 9259 9260 addInputStyle(isValidLength, $(this)); 9261 } 9262 9263 function addCounterElement($input) { 9264 var $counterElement = $input.parent().find('span[class="character-counter"]'); 9265 9266 if ($counterElement.length) { 9267 return; 9268 } 9269 9270 $counterElement = $('<span/>').addClass('character-counter').css('float', 'right').css('font-size', '12px').css('height', 1); 9271 9272 $input.parent().append($counterElement); 9273 } 9274 9275 function removeCounterElement() { 9276 $(this).parent().find('span[class="character-counter"]').html(''); 9277 } 9278 9279 function addInputStyle(isValidLength, $input) { 9280 var inputHasInvalidClass = $input.hasClass('invalid'); 9281 if (isValidLength && inputHasInvalidClass) { 9282 $input.removeClass('invalid'); 9283 } else if (!isValidLength && !inputHasInvalidClass) { 9284 $input.removeClass('valid'); 9285 $input.addClass('invalid'); 9286 } 9287 } 9288 9289 $(document).ready(function () { 9290 $('input, textarea').characterCounter(); 9291 }); 9292})(jQuery); 9293;(function ($) { 9294 9295 var methods = { 9296 9297 init: function (options) { 9298 var defaults = { 9299 duration: 200, // ms 9300 dist: -100, // zoom scale TODO: make this more intuitive as an option 9301 shift: 0, // spacing for center image 9302 padding: 0, // Padding between non center items 9303 fullWidth: false, // Change to full width styles 9304 indicators: false, // Toggle indicators 9305 noWrap: false, // Don't wrap around and cycle through items. 9306 onCycleTo: null // Callback for when a new slide is cycled to. 9307 }; 9308 options = $.extend(defaults, options);
9309 var namespace = Materialize.objectSelectorString($(this)); 9310 9311 return this.each(function (i) { 9312 9313 var images, item_width, item_height, offset, center, pressed, dim, count, reference, referenceY, amplitude, target, velocity, scrolling, xform, frame, timestamp, ticker, dragged, vertical_dragged; 9314 var $indicators = $('<ul class="indicators"></ul>'); 9315 var scrollingTimeout = null; 9316 var oneTimeCallback = null; 9317 9318 // Initialize 9319 var view = $(this); 9320 var hasMultipleSlides = view.find('.carousel-item').length > 1; 9321 var showIndicators = (view.attr('data-indicators') || options.indicators) && hasMultipleSlides; 9322 var noWrap = view.attr('data-no-wrap') || options.noWrap || !hasMultipleSlides; 9323 var uniqueNamespace = view.attr('data-namespace') || namespace + i; 9324 view.attr('data-namespace', uniqueNamespace); 9325 9326 // Options 9327 var setCarouselHeight = function (imageOnly) { 9328 var firstSlide = view.find('.carousel-item.active').length ? view.find('.carousel-item.active').first() : view.find('.carousel-item').first(); 9329 var firstImage = firstSlide.find('img').first(); 9330 if (firstImage.length) { 9331 if (firstImage[0].complete) { 9332 // If image won't trigger the load event 9333 var imageHeight = firstImage.height(); 9334 if (imageHeight > 0) { 9335 view.css('height', firstImage.height()); 9336 } else { 9337 // If image still has no height, use the natural dimensions to calculate 9338 var naturalWidth = firstImage[0].naturalWidth; 9339 var naturalHeight = firstImage[0].naturalHeight; 9340 var adjustedHeight = view.width() / naturalWidth * naturalHeight; 9341 view.css('height', adjustedHeight); 9342 } 9343 } else { 9344 // Get height when image is loaded normally 9345 firstImage.on('load', function () { 9346 view.css('height', $(this).height()); 9347 }); 9348 } 9349 } else if (!imageOnly) { 9350 var slideHeight = firstSlide.height(); 9351 view.css('height', slideHeight); 9352 } 9353 }; 9354 9355 if (options.fullWidth) { 9356 options.dist = 0; 9357 setCarouselHeight(); 9358 9359 // Offset fixed items when indicators. 9360 if (showIndicators) { 9361 view.find('.carousel-fixed-item').addClass('with-indicators'); 9362 } 9363 } 9364 9365 // Don't double initialize. 9366 if (view.hasClass('initialized')) { 9367 // Recalculate variables 9368 $(window).trigger('resize'); 9369 9370 // Redraw carousel. 9371 view.trigger('carouselNext', [0.000001]); 9372 return true; 9373 } 9374 9375 view.addClass('initialized'); 9376 pressed = false; 9377 offset = target = 0; 9378 images = []; 9379 item_width = view.find('.carousel-item').first().innerWidth(); 9380 item_height = view.find('.carousel-item').first().innerHeight(); 9381 dim = item_width * 2 + options.padding; 9382 9383 view.find('.carousel-item').each(function (i) { 9384 images.push($(this)[0]); 9385 if (showIndicators) { 9386 var $indicator = $('<li class="indicator-item"></li>'); 9387 9388 // Add active to first by default. 9389 if (i === 0) { 9390 $indicator.addClass('active'); 9391 } 9392 9393 // Handle clicks on indicators. 9394 $indicator.click(function (e) { 9395 e.stopPropagation(); 9396 9397 var index = $(this).index(); 9398 cycleTo(index); 9399 }); 9400 $indicators.append($indicator); 9401 } 9402 }); 9403 9404 if (showIndicators) { 9405 view.append($indicators); 9406 } 9407 count = images.length; 9408 9409 function setupEvents() { 9410 if (typeof window.ontouchstart !== 'undefined') { 9411 view.on('touchstart.carousel', tap); 9412 view.on('touchmove.carousel', drag); 9413 view.on('touchend.carousel', release); 9414 } 9415 view.on('mousedown.carousel', tap); 9416 view.on('mousemove.carousel', drag); 9417 view.on('mouseup.carousel', release); 9418 view.on('mouseleave.carousel', release); 9419 view.on('click.carousel', click); 9420 } 9421 9422 function xpos(e) { 9423 // touch event 9424 if (e.targetTouches && e.targetTouches.length >= 1) { 9425 return e.targetTouches[0].clientX; 9426 } 9427 9428 // mouse event 9429 return e.clientX; 9430 } 9431 9432 function ypos(e) { 9433 // touch event 9434 if (e.targetTouches && e.targetTouches.length >= 1) { 9435 return e.targetTouches[0].clientY; 9436 } 9437 9438 // mouse event 9439 return e.clientY; 9440 } 9441 9442 function wrap(x) { 9443 return x >= count ? x % count : x < 0 ? wrap(count + x % count) : x; 9444 } 9445 9446 function scroll(x) { 9447 // Track scrolling state 9448 scrolling = true; 9449 if (!view.hasClass('scrolling')) { 9450 view.addClass('scrolling'); 9451 } 9452 if (scrollingTimeout != null) { 9453 window.clearTimeout(scrollingTimeout); 9454 } 9455 scrollingTimeout = window.setTimeout(function () { 9456 scrolling = false;
9457 view.removeClass('scrolling'); 9458 }, options.duration); 9459 9460 // Start actual scroll 9461 var i, half, delta, dir, tween, el, alignment, xTranslation; 9462 var lastCenter = center; 9463 9464 offset = typeof x === 'number' ? x : offset; 9465 center = Math.floor((offset + dim / 2) / dim); 9466 delta = offset - center * dim; 9467 dir = delta < 0 ? 1 : -1; 9468 tween = -dir * delta * 2 / dim; 9469 half = count >> 1; 9470 9471 if (!options.fullWidth) { 9472 alignment = 'translateX(' + (view[0].clientWidth - item_width) / 2 + 'px) '; 9473 alignment += 'translateY(' + (view[0].clientHeight - item_height) / 2 + 'px)'; 9474 } else { 9475 alignment = 'translateX(0)'; 9476 } 9477 9478 // Set indicator active 9479 if (showIndicators) { 9480 var diff = center % count; 9481 var activeIndicator = $indicators.find('.indicator-item.active'); 9482 if (activeIndicator.index() !== diff) { 9483 activeIndicator.removeClass('active'); 9484 $indicators.find('.indicator-item').eq(diff).addClass('active'); 9485 } 9486 } 9487 9488 // center 9489 // Don't show wrapped items. 9490 if (!noWrap || center >= 0 && center < count) { 9491 el = images[wrap(center)]; 9492 9493 // Add active class to center item. 9494 if (!$(el).hasClass('active')) { 9495 view.find('.carousel-item').removeClass('active'); 9496 $(el).addClass('active'); 9497 } 9498 el.style[xform] = alignment + ' translateX(' + -delta / 2 + 'px)' + ' translateX(' + dir * options.shift * tween * i + 'px)' + ' translateZ(' + options.dist * tween + 'px)'; 9499 el.style.zIndex = 0; 9500 if (options.fullWidth) { 9501 tweenedOpacity = 1; 9502 } else { 9503 tweenedOpacity = 1 - 0.2 * tween; 9504 } 9505 el.style.opacity = tweenedOpacity; 9506 el.style.display = 'block'; 9507 } 9508 9509 for (i = 1; i <= half; ++i) { 9510 // right side 9511 if (options.fullWidth) { 9512 zTranslation = options.dist; 9513 tweenedOpacity = i === half && delta < 0 ? 1 - tween : 1; 9514 } else { 9515 zTranslation = options.dist * (i * 2 + tween * dir); 9516 tweenedOpacity = 1 - 0.2 * (i * 2 + tween * dir); 9517 } 9518 // Don't show wrapped items. 9519 if (!noWrap || center + i < count) { 9520 el = images[wrap(center + i)]; 9521 el.style[xform] = alignment + ' translateX(' + (options.shift + (dim * i - delta) / 2) + 'px)' + ' translateZ(' + zTranslation + 'px)'; 9522 el.style.zIndex = -i; 9523 el.style.opacity = tweenedOpacity; 9524 el.style.display = 'block'; 9525 } 9526 9527 // left side 9528 if (options.fullWidth) { 9529 zTranslation = options.dist; 9530 tweenedOpacity = i === half && delta > 0 ? 1 - tween : 1; 9531 } else { 9532 zTranslation = options.dist * (i * 2 - tween * dir); 9533 tweenedOpacity = 1 - 0.2 * (i * 2 - tween * dir); 9534 } 9535 // Don't show wrapped items. 9536 if (!noWrap || center - i >= 0) { 9537 el = images[wrap(center - i)]; 9538 el.style[xform] = alignment + ' translateX(' + (-options.shift + (-dim * i - delta) / 2) + 'px)' + ' translateZ(' + zTranslation + 'px)'; 9539 el.style.zIndex = -i; 9540 el.style.opacity = tweenedOpacity; 9541 el.style.display = 'block'; 9542 } 9543 } 9544 9545 // center 9546 // Don't show wrapped items. 9547 if (!noWrap || center >= 0 && center < count) { 9548 el = images[wrap(center)]; 9549 el.style[xform] = alignment + ' translateX(' + -delta / 2 + 'px)' + ' translateX(' + dir * options.shift * tween + 'px)' + ' translateZ(' + options.dist * tween + 'px)'; 9550 el.style.zIndex = 0; 9551 if (options.fullWidth) { 9552 tweenedOpacity = 1; 9553 } else { 9554 tweenedOpacity = 1 - 0.2 * tween; 9555 } 9556 el.style.opacity = tweenedOpacity; 9557 el.style.display = 'block'; 9558 } 9559 9560 // onCycleTo callback 9561 if (lastCenter !== center && typeof options.onCycleTo === "function") { 9562 var $curr_item = view.find('.carousel-item').eq(wrap(center)); 9563 options.onCycleTo.call(this, $curr_item, dragged); 9564 } 9565 9566 // One time callback 9567 if (typeof oneTimeCallback === "function") { 9568 oneTimeCallback.call(this, $curr_item, dragged); 9569 oneTimeCallback = null; 9570 } 9571 } 9572 9573 function track() { 9574 var now, elapsed, delta, v; 9575 9576 now = Date.now();
9577 elapsed = now - timestamp; 9578 timestamp = now; 9579 delta = offset - frame; 9580 frame = offset; 9581 9582 v = 1000 * delta / (1 + elapsed); 9583 velocity = 0.8 * v + 0.2 * velocity; 9584 } 9585 9586 function autoScroll() { 9587 var elapsed, delta; 9588 9589 if (amplitude) { 9590 elapsed = Date.now() - timestamp; 9591 delta = amplitude * Math.exp(-elapsed / options.duration); 9592 if (delta > 2 || delta < -2) { 9593 scroll(target - delta); 9594 requestAnimationFrame(autoScroll); 9595 } else { 9596 scroll(target); 9597 } 9598 } 9599 } 9600 9601 function click(e) { 9602 // Disable clicks if carousel was dragged. 9603 if (dragged) { 9604 e.preventDefault(); 9605 e.stopPropagation(); 9606 return false; 9607 } else if (!options.fullWidth) { 9608 var clickedIndex = $(e.target).closest('.carousel-item').index(); 9609 var diff = wrap(center) - clickedIndex; 9610 9611 // Disable clicks if carousel was shifted by click 9612 if (diff !== 0) { 9613 e.preventDefault(); 9614 e.stopPropagation(); 9615 } 9616 cycleTo(clickedIndex); 9617 } 9618 } 9619 9620 function cycleTo(n) { 9621 var diff = center % count - n; 9622 9623 // Account for wraparound. 9624 if (!noWrap) { 9625 if (diff < 0) { 9626 if (Math.abs(diff + count) < Math.abs(diff)) { 9627 diff += count; 9628 } 9629 } else if (diff > 0) { 9630 if (Math.abs(diff - count) < diff) { 9631 diff -= count; 9632 } 9633 } 9634 } 9635 9636 // Call prev or next accordingly. 9637 if (diff < 0) { 9638 view.trigger('carouselNext', [Math.abs(diff)]); 9639 } else if (diff > 0) { 9640 view.trigger('carouselPrev', [diff]); 9641 } 9642 } 9643 9644 function tap(e) { 9645 // Fixes firefox draggable image bug 9646 if (e.type === 'mousedown' && $(e.target).is('img')) { 9647 e.preventDefault(); 9648 } 9649 pressed = true; 9650 dragged = false; 9651 vertical_dragged = false; 9652 reference = xpos(e); 9653 referenceY = ypos(e); 9654 9655 velocity = amplitude = 0; 9656 frame = offset; 9657 timestamp = Date.now(); 9658 clearInterval(ticker); 9659 ticker = setInterval(track, 100); 9660 } 9661 9662 function drag(e) { 9663 var x, delta, deltaY; 9664 if (pressed) { 9665 x = xpos(e); 9666 y = ypos(e); 9667 delta = reference - x; 9668 deltaY = Math.abs(referenceY - y); 9669 if (deltaY < 30 && !vertical_dragged) { 9670 // If vertical scrolling don't allow dragging. 9671 if (delta > 2 || delta < -2) { 9672 dragged = true; 9673 reference = x; 9674 scroll(offset + delta); 9675 } 9676 } else if (dragged) { 9677 // If dragging don't allow vertical scroll. 9678 e.preventDefault(); 9679 e.stopPropagation(); 9680 return false; 9681 } else { 9682 // Vertical scrolling. 9683 vertical_dragged = true; 9684 } 9685 } 9686 9687 if (dragged) { 9688 // If dragging don't allow vertical scroll. 9689 e.preventDefault(); 9690 e.stopPropagation(); 9691 return false; 9692 } 9693 } 9694 9695 function release(e) { 9696 if (pressed) { 9697 pressed = false; 9698 } else { 9699 return; 9700 } 9701 9702 clearInterval(ticker); 9703 target = offset; 9704 if (velocity > 10 || velocity < -10) { 9705 amplitude = 0.9 * velocity; 9706 target = offset + amplitude; 9707 } 9708 target = Math.round(target / dim) * dim; 9709 9710 // No wrap of items. 9711 if (noWrap) { 9712 if (target >= dim * (count - 1)) { 9713 target = dim * (count - 1); 9714 } else if (target < 0) { 9715 target = 0; 9716 } 9717 } 9718 amplitude = target - offset; 9719 timestamp = Date.now(); 9720 requestAnimationFrame(autoScroll); 9721 9722 if (dragged) { 9723 e.preventDefault(); 9724 e.stopPropagation(); 9725 } 9726 return false;
9727 } 9728 9729 xform = 'transform'; 9730 ['webkit', 'Moz', 'O', 'ms'].every(function (prefix) { 9731 var e = prefix + 'Transform'; 9732 if (typeof document.body.style[e] !== 'undefined') { 9733 xform = e; 9734 return false; 9735 } 9736 return true; 9737 }); 9738 9739 var throttledResize = Materialize.throttle(function () { 9740 if (options.fullWidth) { 9741 item_width = view.find('.carousel-item').first().innerWidth(); 9742 var imageHeight = view.find('.carousel-item.active').height(); 9743 dim = item_width * 2 + options.padding; 9744 offset = center * 2 * item_width; 9745 target = offset; 9746 setCarouselHeight(true); 9747 } else { 9748 scroll(); 9749 } 9750 }, 200); 9751 $(window).off('resize.carousel-' + uniqueNamespace).on('resize.carousel-' + uniqueNamespace, throttledResize); 9752 9753 setupEvents(); 9754 scroll(offset); 9755 9756 $(this).on('carouselNext', function (e, n, callback) { 9757 if (n === undefined) { 9758 n = 1; 9759 } 9760 if (typeof callback === "function") { 9761 oneTimeCallback = callback; 9762 } 9763 9764 target = dim * Math.round(offset / dim) + dim * n; 9765 if (offset !== target) { 9766 amplitude = target - offset; 9767 timestamp = Date.now(); 9768 requestAnimationFrame(autoScroll); 9769 } 9770 }); 9771 9772 $(this).on('carouselPrev', function (e, n, callback) { 9773 if (n === undefined) { 9774 n = 1; 9775 } 9776 if (typeof callback === "function") { 9777 oneTimeCallback = callback; 9778 } 9779 9780 target = dim * Math.round(offset / dim) - dim * n; 9781 if (offset !== target) { 9782 amplitude = target - offset; 9783 timestamp = Date.now(); 9784 requestAnimationFrame(autoScroll); 9785 } 9786 }); 9787 9788 $(this).on('carouselSet', function (e, n, callback) { 9789 if (n === undefined) { 9790 n = 0; 9791 } 9792 if (typeof callback === "function") { 9793 oneTimeCallback = callback; 9794 } 9795 9796 cycleTo(n); 9797 }); 9798 }); 9799 }, 9800 next: function (n, callback) { 9801 $(this).trigger('carouselNext', [n, callback]); 9802 }, 9803 prev: function (n, callback) { 9804 $(this).trigger('carouselPrev', [n, callback]); 9805 }, 9806 set: function (n, callback) { 9807 $(this).trigger('carouselSet', [n, callback]); 9808 }, 9809 destroy: function () { 9810 var uniqueNamespace = $(this).attr('data-namespace'); 9811 $(this).removeAttr('data-namespace'); 9812 $(this).removeClass('initialized'); 9813 $(this).find('.indicators').remove(); 9814 9815 // Remove event handlers 9816 $(this).off('carouselNext carouselPrev carouselSet'); 9817 $(window).off('resize.carousel-' + uniqueNamespace); 9818 if (typeof window.ontouchstart !== 'undefined') { 9819 $(this).off('touchstart.carousel touchmove.carousel touchend.carousel'); 9820 } 9821 $(this).off('mousedown.carousel mousemove.carousel mouseup.carousel mouseleave.carousel click.carousel'); 9822 } 9823 }; 9824 9825 $.fn.carousel = function (methodOrOptions) { 9826 if (methods[methodOrOptions]) { 9827 return methods[methodOrOptions].apply(this, Array.prototype.slice.call(arguments, 1)); 9828 } else if (typeof methodOrOptions === 'object' || !methodOrOptions) { 9829 // Default to "init" 9830 return methods.init.apply(this, arguments); 9831 } else { 9832 $.error('Method ' + methodOrOptions + ' does not exist on jQuery.carousel'); 9833 } 9834 }; // Plugin end 9835})(jQuery); 9836;(function ($) { 9837 9838 var methods = { 9839 init: function (options) { 9840 return this.each(function () { 9841 var origin = $('#' + $(this).attr('data-activates')); 9842 var screen = $('body'); 9843 9844 // Creating tap target 9845 var tapTargetEl = $(this); 9846 var tapTargetWrapper = tapTargetEl.parent('.tap-target-wrapper'); 9847 var tapTargetWave = tapTargetWrapper.find('.tap-target-wave'); 9848 var tapTargetOriginEl = tapTargetWrapper.find('.tap-target-origin'); 9849 var tapTargetContentEl = tapTargetEl.find('.tap-target-content'); 9850 9851 // Creating wrapper 9852 if (!tapTargetWrapper.length) { 9853 tapTargetWrapper = tapTargetEl.wrap($('<div class="tap-target-wrapper"></div>')).parent(); 9854 } 9855 9856 // Creating content 9857 if (!tapTargetContentEl.length) {
9858 tapTargetContentEl = $('<div class="tap-target-content"></div>'); 9859 tapTargetEl.append(tapTargetContentEl); 9860 } 9861 9862 // Creating foreground wave 9863 if (!tapTargetWave.length) { 9864 tapTargetWave = $('<div class="tap-target-wave"></div>'); 9865 9866 // Creating origin 9867 if (!tapTargetOriginEl.length) { 9868 tapTargetOriginEl = origin.clone(true, true); 9869 tapTargetOriginEl.addClass('tap-target-origin'); 9870 tapTargetOriginEl.removeAttr('id'); 9871 tapTargetOriginEl.removeAttr('style'); 9872 tapTargetWave.append(tapTargetOriginEl); 9873 } 9874 9875 tapTargetWrapper.append(tapTargetWave); 9876 } 9877 9878 // Open 9879 var openTapTarget = function () { 9880 if (tapTargetWrapper.is('.open')) { 9881 return; 9882 } 9883 9884 // Adding open class 9885 tapTargetWrapper.addClass('open'); 9886 9887 setTimeout(function () { 9888 tapTargetOriginEl.off('click.tapTarget').on('click.tapTarget', function (e) { 9889 closeTapTarget(); 9890 tapTargetOriginEl.off('click.tapTarget'); 9891 }); 9892 9893 $(document).off('click.tapTarget').on('click.tapTarget', function (e) { 9894 closeTapTarget(); 9895 $(document).off('click.tapTarget'); 9896 }); 9897 9898 var throttledCalc = Materialize.throttle(function () { 9899 calculateTapTarget(); 9900 }, 200); 9901 $(window).off('resize.tapTarget').on('resize.tapTarget', throttledCalc); 9902 }, 0); 9903 }; 9904 9905 // Close 9906 var closeTapTarget = function () { 9907 if (!tapTargetWrapper.is('.open')) { 9908 return; 9909 } 9910 9911 tapTargetWrapper.removeClass('open'); 9912 tapTargetOriginEl.off('click.tapTarget'); 9913 $(document).off('click.tapTarget'); 9914 $(window).off('resize.tapTarget'); 9915 }; 9916 9917 // Pre calculate 9918 var calculateTapTarget = function () { 9919 // Element or parent is fixed position? 9920 var isFixed = origin.css('position') === 'fixed'; 9921 if (!isFixed) { 9922 var parents = origin.parents(); 9923 for (var i = 0; i < parents.length; i++) { 9924 isFixed = $(parents[i]).css('position') == 'fixed'; 9925 if (isFixed) { 9926 break; 9927 } 9928 } 9929 } 9930 9931 // Calculating origin 9932 var originWidth = origin.outerWidth(); 9933 var originHeight = origin.outerHeight(); 9934 var originTop = isFixed ? origin.offset().top - $(document).scrollTop() : origin.offset().top; 9935 var originLeft = isFixed ? origin.offset().left - $(document).scrollLeft() : origin.offset().left; 9936 9937 // Calculating screen 9938 var windowWidth = $(window).width(); 9939 var windowHeight = $(window).height(); 9940 var centerX = windowWidth / 2; 9941 var centerY = windowHeight / 2; 9942 var isLeft = originLeft <= centerX; 9943 var isRight = originLeft > centerX; 9944 var isTop = originTop <= centerY; 9945 var isBottom = originTop > centerY; 9946 var isCenterX = originLeft >= windowWidth * 0.25 && originLeft <= windowWidth * 0.75; 9947 var isCenterY = originTop >= windowHeight * 0.25 && originTop <= windowHeight * 0.75; 9948 9949 // Calculating tap target 9950 var tapTargetWidth = tapTargetEl.outerWidth(); 9951 var tapTargetHeight = tapTargetEl.outerHeight(); 9952 var tapTargetTop = originTop + originHeight / 2 - tapTargetHeight / 2; 9953 var tapTargetLeft = originLeft + originWidth / 2 - tapTargetWidth / 2; 9954 var tapTargetPosition = isFixed ? 'fixed' : 'absolute'; 9955 9956 // Calculating content 9957 var tapTargetTextWidth = isCenterX ? tapTargetWidth : tapTargetWidth / 2 + originWidth; 9958 var tapTargetTextHeight = tapTargetHeight / 2; 9959 var tapTargetTextTop = isTop ? tapTargetHeight / 2 : 0; 9960 var tapTargetTextBottom = 0; 9961 var tapTargetTextLeft = isLeft && !isCenterX ? tapTargetWidth / 2 - originWidth : 0; 9962 var tapTargetTextRight = 0; 9963 var tapTargetTextPadding = originWidth; 9964 var tapTargetTextAlign = isBottom ? 'bottom' : 'top'; 9965 9966 // Calculating wave 9967 var tapTargetWaveWidth = originWidth > originHeight ? originWidth * 2 : originWidth * 2; 9968 var tapTargetWaveHeight = tapTargetWaveWidth; 9969 var tapTargetWaveTop = tapTargetHeight / 2 - tapTargetWaveHeight / 2; 9970 var tapTargetWaveLeft = tapTargetWidth / 2 - tapTargetWaveWidth / 2; 9971 9972 // Setting tap target 9973 var tapTargetWrapperCssObj = {}; 9974 tapTargetWrapperCssObj.top = isTop ? tapTargetTop : ''; 9975 tapTargetWrapperCssObj.right = isRight ? windowWidth - tapTargetLeft - tapTargetWidth : ''; 9976 tapTargetWrapperCssObj.bottom = isBottom ? windowHeight - tapTargetTop - tapTargetHeight : ''; 9977 tapTargetWrapperCssObj.left = isLeft ? tapTargetLeft : ''; 9978 tapTargetWrapperCssObj.position = tapTargetPosition; 9979 tapTargetWrapper.css(tapTargetWrapperCssObj); 9980 9981 // Setting content 9982 tapTargetContentEl.css({
9983 width: tapTargetTextWidth, 9984 height: tapTargetTextHeight, 9985 top: tapTargetTextTop, 9986 right: tapTargetTextRight, 9987 bottom: tapTargetTextBottom, 9988 left: tapTargetTextLeft, 9989 padding: tapTargetTextPadding, 9990 verticalAlign: tapTargetTextAlign 9991 }); 9992 9993 // Setting wave 9994 tapTargetWave.css({ 9995 top: tapTargetWaveTop, 9996 left: tapTargetWaveLeft, 9997 width: tapTargetWaveWidth, 9998 height: tapTargetWaveHeight 9999 }); 10000 }; 10001 10002 if (options == 'open') { 10003 calculateTapTarget(); 10004 openTapTarget(); 10005 } 10006 10007 if (options == 'close') closeTapTarget(); 10008 }); 10009 }, 10010 open: function () {}, 10011 close: function () {} 10012 }; 10013 10014 $.fn.tapTarget = function (methodOrOptions) { 10015 if (methods[methodOrOptions] || typeof methodOrOptions === 'object') return methods.init.apply(this, arguments); 10016 10017 $.error('Method ' + methodOrOptions + ' does not exist on jQuery.tap-target'); 10018 }; 10019})(jQuery); 10020 10021//# sourceMappingURL=materialize_concat.js.map 10022//# sourceMappingURL=materialize.js.map
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.