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