openworktime/webapp/js/materialize.js
webapp/js/materialize.jsRaw
1/*!
2 * Materialize v0.97.7 (http://materializecss.com)
3 * Copyright 2014-2015 Materialize
4 * MIT License (https://raw.githubusercontent.com/Dogfalo/materialize/master/LICENSE)
5 */
6// Check for jQuery.
7if (typeof(jQuery) === 'undefined') {
8 var jQuery;
9 // Check if require is a defined function.
10 if (typeof(require) === 'function') {
11 jQuery = $ = require('jquery');
12 // Else use the dollar sign alias.
13 } else {
14 jQuery = $;
15 }
16}
17;/*
18 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
19 *
20 * Uses the built in easing capabilities added In jQuery 1.1
21 * to offer multiple easing options
22 *
23 * TERMS OF USE - jQuery Easing
24 *
25 * Open source under the BSD License.
26 *
27 * Copyright © 2008 George McGinley Smith
28 * All rights reserved.
29 *
30 * Redistribution and use in source and binary forms, with or without modification,
31 * are permitted provided that the following conditions are met:
32 *
33 * Redistributions of source code must retain the above copyright notice, this list of
34 * conditions and the following disclaimer.
35 * Redistributions in binary form must reproduce the above copyright notice, this list
36 * of conditions and the following disclaimer in the documentation and/or other materials
37 * provided with the distribution.
38 *
39 * Neither the name of the author nor the names of contributors may be used to endorse
40 * or promote products derived from this software without specific prior written permission.
41 *
42 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
43 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
44 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
45 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
46 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
47 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
48 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
49 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 *
52*/
53
54// t: current time, b: begInnIng value, c: change In value, d: duration
55jQuery.easing['jswing'] = jQuery.easing['swing'];
56
57jQuery.extend( jQuery.easing,
58{
59 def: 'easeOutQuad',
60 swing: function (x, t, b, c, d) {
61 //alert(jQuery.easing.default);
62 return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
63 },
64 easeInQuad: function (x, t, b, c, d) {
65 return c*(t/=d)*t + b;
66 },
67 easeOutQuad: function (x, t, b, c, d) {
68 return -c *(t/=d)*(t-2) + b;
69 },
70 easeInOutQuad: function (x, t, b, c, d) {
71 if ((t/=d/2) < 1) return c/2*t*t + b;
72 return -c/2 * ((--t)*(t-2) - 1) + b;
73 },
74 easeInCubic: function (x, t, b, c, d) {
75 return c*(t/=d)*t*t + b;
76 },
77 easeOutCubic: function (x, t, b, c, d) {
78 return c*((t=t/d-1)*t*t + 1) + b;
79 },
80 easeInOutCubic: function (x, t, b, c, d) {
81 if ((t/=d/2) < 1) return c/2*t*t*t + b;
82 return c/2*((t-=2)*t*t + 2) + b;
83 },
84 easeInQuart: function (x, t, b, c, d) {
85 return c*(t/=d)*t*t*t + b;
86 },
87 easeOutQuart: function (x, t, b, c, d) {
88 return -c * ((t=t/d-1)*t*t*t - 1) + b;
89 },
90 easeInOutQuart: function (x, t, b, c, d) {
91 if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
92 return -c/2 * ((t-=2)*t*t*t - 2) + b;
93 },
94 easeInQuint: function (x, t, b, c, d) {
95 return c*(t/=d)*t*t*t*t + b;
96 },
97 easeOutQuint: function (x, t, b, c, d) {
98 return c*((t=t/d-1)*t*t*t*t + 1) + b;
99 },
100 easeInOutQuint: function (x, t, b, c, d) {
101 if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
102 return c/2*((t-=2)*t*t*t*t + 2) + b;
103 },
104 easeInSine: function (x, t, b, c, d) {
105 return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
106 },
107 easeOutSine: function (x, t, b, c, d) {
108 return c * Math.sin(t/d * (Math.PI/2)) + b;
109 },
110 easeInOutSine: function (x, t, b, c, d) {
111 return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
112 },
113 easeInExpo: function (x, t, b, c, d) {
114 return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
115 },
116 easeOutExpo: function (x, t, b, c, d) {
117 return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
118 },
119 easeInOutExpo: function (x, t, b, c, d) {
120 if (t==0) return b;
121 if (t==d) return b+c;
122 if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
123 return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
124 },
125 easeInCirc: function (x, t, b, c, d) {
126 return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
127 },
128 easeOutCirc: function (x, t, b, c, d) {
129 return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
130 },
131 easeInOutCirc: function (x, t, b, c, d) {
132 if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
133 return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
134 },
135 easeInElastic: function (x, t, b, c, d) {
136 var s=1.70158;var p=0;var a=c;
137 if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
138 if (a < Math.abs(c)) { a=c; var s=p/4; }
139 else var s = p/(2*Math.PI) * Math.asin (c/a);
140 return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
141 },
142 easeOutElastic: function (x, t, b, c, d) {
143 var s=1.70158;var p=0;var a=c;
144 if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
145 if (a < Math.abs(c)) { a=c; var s=p/4; }
146 else var s = p/(2*Math.PI) * Math.asin (c/a);
147 return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
148 },
149 easeInOutElastic: function (x, t, b, c, d) {
150 var s=1.70158;var p=0;var a=c;
151 if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
152 if (a < Math.abs(c)) { a=c; var s=p/4; }
153 else var s = p/(2*Math.PI) * Math.asin (c/a);
154 if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
155 return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
156 },
157 easeInBack: function (x, t, b, c, d, s) {
158 if (s == undefined) s = 1.70158;
159 return c*(t/=d)*t*((s+1)*t - s) + b;
160 },
161 easeOutBack: function (x, t, b, c, d, s) {
162 if (s == undefined) s = 1.70158;
163 return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
164 },
165 easeInOutBack: function (x, t, b, c, d, s) {
166 if (s == undefined) s = 1.70158;
167 if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
168 return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
169 },
170 easeInBounce: function (x, t, b, c, d) {
171 return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
172 },
173 easeOutBounce: function (x, t, b, c, d) {
174 if ((t/=d) < (1/2.75)) {
175 return c*(7.5625*t*t) + b;
176 } else if (t < (2/2.75)) {
177 return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
178 } else if (t < (2.5/2.75)) {
179 return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
180 } else {
181 return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
182 }
183 },
184 easeInOutBounce: function (x, t, b, c, d) {
185 if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
186 return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
187 }
188});
189
190/*
191 *
192 * TERMS OF USE - EASING EQUATIONS
193 *
194 * Open source under the BSD License.
195 *
196 * Copyright © 2001 Robert Penner
197 * All rights reserved.
198 *
199 * Redistribution and use in source and binary forms, with or without modification,
200 * are permitted provided that the following conditions are met:
201 *
202 * Redistributions of source code must retain the above copyright notice, this list of
203 * conditions and the following disclaimer.
204 * Redistributions in binary form must reproduce the above copyright notice, this list
205 * of conditions and the following disclaimer in the documentation and/or other materials
206 * provided with the distribution.
207 *
208 * Neither the name of the author nor the names of contributors may be used to endorse
209 * or promote products derived from this software without specific prior written permission.
210 *
211 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
212 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
213 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
214 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
215 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
216 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
217 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
218 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
219 * OF THE POSSIBILITY OF SUCH DAMAGE.
220 *
221 */; // Custom Easing
222 jQuery.extend( jQuery.easing,
223 {
224 easeInOutMaterial: function (x, t, b, c, d) {
225 if ((t/=d/2) < 1) return c/2*t*t + b;
226 return c/4*((t-=2)*t*t + 2) + b;
227 }
228 });
229
230;/*! VelocityJS.org (1.2.3). (C) 2014 Julian Shapiro. MIT @license: en.wikipedia.org/wiki/MIT_License */
231/*! VelocityJS.org jQuery Shim (1.0.1). (C) 2014 The jQuery Foundation. MIT @license: en.wikipedia.org/wiki/MIT_License. */
232/*! Note that this has been modified by Materialize to confirm that Velocity is not already being imported. */
233jQuery.Velocity?console.log("Velocity is already loaded. You may be needlessly importing Velocity again; note that Materialize includes Velocity."):(!function(e){function t(e){var t=e.length,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}if(!e.jQuery){var r=function(e,t){return new r.fn.init(e,t)};r.isWindow=function(e){return null!=e&&e==e.window},r.type=function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[i.call(e)]||"object":typeof e},r.isArray=Array.isArray||function(e){return"array"===r.type(e)},r.isPlainObject=function(e){var t;if(!e||"object"!==r.type(e)||e.nodeType||r.isWindow(e))return!1;try{if(e.constructor&&!o.call(e,"constructor")&&!o.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(a){return!1}for(t in e);return void 0===t||o.call(e,t)},r.each=function(e,r,a){var n,o=0,i=e.length,s=t(e);if(a){if(s)for(;i>o&&(n=r.apply(e[o],a),n!==!1);o++);else for(o in e)if(n=r.apply(e[o],a),n===!1)break}else if(s)for(;i>o&&(n=r.call(e[o],o,e[o]),n!==!1);o++);else for(o in e)if(n=r.call(e[o],o,e[o]),n===!1)break;return e},r.data=function(e,t,n){if(void 0===n){var o=e[r.expando],i=o&&a[o];if(void 0===t)return i;if(i&&t in i)return i[t]}else if(void 0!==t){var o=e[r.expando]||(e[r.expando]=++r.uuid);return a[o]=a[o]||{},a[o][t]=n,n}},r.removeData=function(e,t){var n=e[r.expando],o=n&&a[n];o&&r.each(t,function(e,t){delete o[t]})},r.extend=function(){var e,t,a,n,o,i,s=arguments[0]||{},l=1,u=arguments.length,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++)if(null!=(o=arguments[l]))for(n in o)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));return s},r.queue=function(e,a,n){function o(e,r){var a=r||[];return null!=e&&(t(Object(e))?!function(e,t){for(var r=+t.length,a=0,n=e.length;r>a;)e[n++]=t[a++];if(r!==r)for(;void 0!==t[a];)e[n++]=t[a++];return e.length=n,e}(a,"string"==typeof e?[e]:e):[].push.call(a,e)),a}if(e){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||[]}},r.dequeue=function(e,t){r.each(e.nodeType?[e]:e,function(e,a){t=t||"fx";var n=r.queue(a,t),o=n.shift();"inprogress"===o&&(o=n.shift()),o&&("fx"===t&&n.unshift("inprogress"),o.call(a,function(){r.dequeue(a,t)}))})},r.fn=r.prototype={init:function(e){if(e.nodeType)return this[0]=e,this;throw new Error("Not a DOM node.")},offset:function(){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)}},position:function(){function e(){for(var e=this.offsetParent||document;e&&"html"===!e.nodeType.toLowerCase&&"static"===e.style.position;)e=e.offsetParent;return e||document}var t=this[0],e=e.apply(t),a=this.offset(),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}}};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++)n["[object "+s[l]+"]"]=s[l].toLowerCase();r.fn.init.prototype=r.fn,e.Velocity={Utilities:r}}}(window),function(e){"object"==typeof module&&"object"==typeof module.exports?module.exports=e():"function"==typeof define&&define.amd?define(e):e()}(function(){return function(e,t,r,a){function n(e){for(var t=-1,r=e?e.length:0,a=[];++t<r;){var n=e[t];n&&a.push(n)}return a}function o(e){return m.isWrapped(e)?e=[].slice.call(e):m.isNode(e)&&(e=[e]),e}function i(e){var t=f.data(e,"velocity");return null===t?a:t}function s(e){return function(t){return Math.round(t*e)*(1/e)}}function l(e,r,a,n){function o(e,t){return 1-3*t+3*e}function i(e,t){return 3*t-6*e}function s(e){return 3*e}function l(e,t,r){return((o(t,r)*e+i(t,r))*e+s(t))*e}function u(e,t,r){return 3*o(t,r)*e*e+2*i(t,r)*e+s(t)}function c(t,r){for(var n=0;m>n;++n){var o=u(r,e,a);if(0===o)return r;var i=l(r,e,a)-t;r-=i/o}return r}function p(){for(var t=0;b>t;++t)w[t]=l(t*x,e,a)}function f(t,r,n){var o,i,s=0;do i=r+(n-r)/2,o=l(i,e,a)-t,o>0?n=i:r=i;while(Math.abs(o)>h&&++s<v);return i}function d(t){for(var r=0,n=1,o=b-1;n!=o&&w[n]<=t;++n)r+=x;--n;var i=(t-w[n])/(w[n+1]-w[n]),s=r+i*x,l=u(s,e,a);return l>=y?c(t,s):0==l?s:f(t,r,r+x)}function g(){V=!0,(e!=r||a!=n)&&p()}var m=4,y=.001,h=1e-7,v=10,b=11,x=1/(b-1),S="Float32Array"in t;if(4!==arguments.length)return!1;for(var P=0;4>P;++P)if("number"!=typeof arguments[P]||isNaN(arguments[P])||!isFinite(arguments[P]))return!1;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),V=!1,C=function(t){return V||g(),e===r&&a===n?t:0===t?0:1===t?1:l(d(t),r,n)};C.getControlPoints=function(){return[{x:e,y:r},{x:a,y:n}]};var T="generateBezier("+[e,r,a,n]+")";return C.toString=function(){return T},C}function u(e,t){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}function c(e){if(e){var t=(new Date).getTime(),r=b.State.calls.length;r>1e4&&(b.State.calls=n(b.State.calls));for(var o=0;r>o;o++)if(b.State.calls[o]){var s=b.State.calls[o],l=s[0],u=s[2],d=s[3],g=!!d,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++){var P=l[v],V=P.element;if(i(V)){var C=!1;if(u.display!==a&&null!==u.display&&"none"!==u.display){if("flex"===u.display){var T=["-webkit-box","-moz-box","-ms-flexbox","-webkit-flex"];f.each(T,function(e,t){S.setPropertyValue(V,"display",t)})}S.setPropertyValue(V,"display",u.display)}u.visibility!==a&&"hidden"!==u.visibility&&S.setPropertyValue(V,"visibility",u.visibility);for(var k in P)if("element"!==k){var A,F=P[k],j=m.isString(F.easing)?b.Easings[F.easing]:F.easing;if(1===h)A=F.endValue;else{var E=F.endValue-F.startValue;if(A=F.startValue+E*j(h,u,E),!g&&A===F.currentValue)continue}if(F.currentValue=A,"tween"===k)y=A;else{if(S.Hooks.registered[k]){var H=S.Hooks.getRoot(k),N=i(V).rootPropertyValueCache[H];N&&(F.rootPropertyValue=N)}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)}}u.mobileHA&&i(V).transformCache.translate3d===a&&(i(V).transformCache.translate3d="(0px, 0px, 0px)",C=!0),C&&S.flushTransformCache(V)}}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)}}b.State.isTicking&&w(c)}function p(e,t){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++){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)){i(p).isAnimating=!1,i(p).rootPropertyValueCache={};var d=!1;f.each(S.Lists.transforms3D,function(e,t){var r=/^scale/.test(t)?1:0,n=i(p).transformCache[t];i(p).transformCache[t]!==a&&new RegExp("^\\("+r+"[^.]").test(n)&&(d=!0,delete i(p).transformCache[t])}),o.mobileHA&&(d=!0,delete i(p).transformCache.translate3d),d&&S.flushTransformCache(p),S.Values.removeClass(p,"velocity-animating")}if(!t&&o.complete&&!o.loop&&u===c-1)try{o.complete.call(n,n)}catch(g){setTimeout(function(){throw g},1)}s&&o.loop!==!0&&s(n),i(p)&&o.loop===!0&&!t&&(f.each(i(p).tweensContainer,function(e,t){/^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)}),b(p,"reverse",{loop:!0,delay:o.delay})),o.queue!==!1&&f.dequeue(p,o.queue)}b.State.calls[e]=!1;for(var m=0,y=b.State.calls.length;y>m;m++)if(b.State.calls[m]!==!1){l=!0;break}l===!1&&(b.State.isTicking=!1,delete b.State.calls,b.State.calls=[])}var f,d=function(){if(r.documentMode)return r.documentMode;for(var e=7;e>4;e--){var t=r.createElement("div");if(t.innerHTML="<!--[if IE "+e+"]><span></span><![endif]-->",t.getElementsByTagName("span").length)return t=null,e}return a}(),g=function(){var e=0;return t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||function(t){var r,a=(new Date).getTime();return r=Math.max(0,16-(a-e)),e=a+r,setTimeout(function(){t(a+r)},r)}}(),m={isString:function(e){return"string"==typeof e},isArray:Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},isFunction:function(e){return"[object Function]"===Object.prototype.toString.call(e)},isNode:function(e){return e&&e.nodeType},isNodeList:function(e){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)},isWrapped:function(e){return e&&(e.jquery||t.Zepto&&t.Zepto.zepto.isZ(e))},isSVG:function(e){return t.SVGElement&&e instanceof t.SVGElement},isEmptyObject:function(e){for(var t in e)return!1;return!0}},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,v="swing",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){f.data(e,"velocity",{isSVG:m.isSVG(e),isAnimating:!1,computedStyle:null,tweensContainer:null,rootPropertyValueCache:{},transformCache:{}})},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(){function e(e){return-e.tension*e.x-e.friction*e.v}function t(t,r,a){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)}}function r(r,a){var n={dx:r.v,dv:e(r)},o=t(r,.5*a,n),i=t(r,.5*a,o),s=t(r,a,i),l=1/6*(n.dx+2*(o.dx+i.dx)+s.dx),u=1/6*(n.dv+2*(o.dv+i.dv)+s.dv);return r.x=r.x+l*a,r.v=r.v+u*a,r}return function a(e,t,n){var o,i,s,l={x:-1,v:0,tension:null,friction:null},u=[0],c=0,p=1e-4,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){return u[e*(u.length-1)|0]}:c}}();b.Easings={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},spring:function(e){return 1-Math.cos(4.5*e*Math.PI)*Math.exp(6*-e)}},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){b.Easings[t[0]]=l.apply(null,t[1])});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(){for(var e=0;e<S.Lists.colors.length;e++){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]}var r,a,n;if(d)for(r in S.Hooks.templates){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(" ")])}for(r in S.Hooks.templates){a=S.Hooks.templates[r],n=a[0].split(" ");for(var e in n){var i=r+n[e],s=e;S.Hooks.registered[i]=[r,s]}}},getRoot:function(e){var t=S.Hooks.registered[e];return t?t[0]:e},cleanRootPropertyValue:function(e,t){return S.RegEx.valueUnwrap.test(t)&&(t=t.match(S.RegEx.valueUnwrap)[1]),S.Values.isCSSNullValue(t)&&(t=S.Hooks.templates[e][1]),t},extractValue:function(e,t){var r=S.Hooks.registered[e];if(r){var a=r[0],n=r[1];return t=S.Hooks.cleanRootPropertyValue(a,t),t.toString().match(S.RegEx.valueSplit)[n]}return t},injectValue:function(e,t,r){var a=S.Hooks.registered[e];if(a){var n,o,i=a[0],s=a[1];return r=S.Hooks.cleanRootPropertyValue(i,r),n=r.toString().match(S.RegEx.valueSplit),n[s]=t,o=n.join(" ")}return r}},Normalizations:{registered:{clip:function(e,t,r){switch(e){case"name":return"clip";case"extract":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":return"rect("+r+")"}},blur:function(e,t,r){switch(e){case"name":return b.State.isFirefox?"filter":"-webkit-filter";case"extract":var a=parseFloat(r);if(!a&&0!==a){var n=r.toString().match(/blur\(([0-9]+[A-z]+)\)/i);a=n?n[1]:0}return a;case"inject":return parseFloat(r)?"blur("+r+")":"none"}},opacity:function(e,t,r){if(8>=d)switch(e){case"name":return"filter";case"extract":var a=r.toString().match(/alpha\(opacity=(.*)\)/i);return r=a?a[1]/100:1;case"inject":return t.style.zoom=1,parseFloat(r)>=1?"":"alpha(opacity="+parseInt(100*parseFloat(r),10)+")"}else switch(e){case"name":return"opacity";case"extract":return r;case"inject":return r}}},register:function(){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++)!function(){var t=S.Lists.transformsBase[e];S.Normalizations.registered[t]=function(e,r,n){switch(e){case"name":return"transform";case"extract":return i(r)===a||i(r).transformCache[t]===a?/^scale/i.test(t)?1:0:i(r).transformCache[t].replace(/[()]/g,"");case"inject":var o=!1;switch(t.substr(0,t.length-1)){case"translate":o=!/(%|px|em|rem|vw|vh|\d)$/i.test(n);break;case"scal":case"scale":b.State.isAndroid&&i(r).transformCache[t]===a&&1>n&&(n=1),o=!/(\d)$/i.test(n);break;case"skew":o=!/(deg|\d)$/i.test(n);break;case"rotate":o=!/(deg|\d)$/i.test(n)}return o||(i(r).transformCache[t]="("+n+")"),i(r).transformCache[t]}}}();for(var e=0;e<S.Lists.colors.length;e++)!function(){var t=S.Lists.colors[e];S.Normalizations.registered[t]=function(e,r,n){switch(e){case"name":return t;case"extract":var o;if(S.RegEx.wrappedValueAlreadyExtracted.test(n))o=n;else{var i,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," ")}return 8>=d||3!==o.split(" ").length||(o+=" 1"),o;case"inject":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,"")+")"}}}()}},Names:{camelCase:function(e){return e.replace(/-(\w)/g,function(e,t){return t.toUpperCase()})},SVGAttribute:function(e){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)},prefixCheck:function(e){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++){var n;if(n=0===r?e:t[r]+e.replace(/^\w/,function(e){return e.toUpperCase()}),m.isString(b.State.prefixElement.style[n]))return b.State.prefixMatches[e]=n,[n,!0]}return[e,!1]}},Values:{hexToRgb:function(e){var t,r=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,a=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i;return e=e.replace(r,function(e,t,r,a){return t+t+r+r+a+a}),t=a.exec(e),t?[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]:[0,0,0]},isCSSNullValue:function(e){return 0==e||/^(none|auto|transparent|(rgba\(0, ?0, ?0, ?0\)))$/i.test(e)},getUnitType:function(e){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"},getDisplayType:function(e){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"},addClass:function(e,t){e.classList?e.classList.add(t):e.className+=(e.className.length?" ":"")+t},removeClass:function(e,t){e.classList?e.classList.remove(t):e.className=e.className.toString().replace(new RegExp("(^|\\s)"+t.split(" ").join("|")+"(\\s|$)","gi")," ")}},getPropertyValue:function(e,r,n,o){function s(e,r){function n(){u&&S.setPropertyValue(e,"display","none")}var l=0;if(8>=d)l=f.css(e,r);else{var u=!1;if(/^(width|height)$/.test(r)&&0===S.getPropertyValue(e,"display")&&(u=!0,S.setPropertyValue(e,"display",S.Values.getDisplayType(e))),!o){if("height"===r&&"border-box"!==S.getPropertyValue(e,"boxSizing").toString().toLowerCase()){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}if("width"===r&&"border-box"!==S.getPropertyValue(e,"boxSizing").toString().toLowerCase()){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}}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()}if("auto"===l&&/^(top|right|bottom|left)$/i.test(r)){var m=s(e,"position");("fixed"===m||"absolute"===m&&/top|left/i.test(r))&&(l=f(e).position()[r]+"px")}return l}var l;if(S.Hooks.registered[r]){var u=r,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)}else if(S.Normalizations.registered[r]){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)}if(!/^[\d-]/.test(l))if(i(e)&&i(e).isSVG&&S.Names.SVGAttribute(r))if(/^(height|width)$/i.test(r))try{l=e.getBBox()[r]}catch(m){l=0}else l=e.getAttribute(r);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},setPropertyValue:function(e,r,a,n,o){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{if(S.Hooks.registered[r]){var l=r,u=S.Hooks.getRoot(r);n=n||S.getPropertyValue(e,u),a=S.Hooks.injectValue(l,a,n),r=u}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{e.style[s]=a}catch(c){b.debug&&console.log("Browser does not support ["+a+"] for ["+s+"]")}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)}return[s,a]},flushTransformCache:function(e){function t(t){return parseFloat(S.getPropertyValue(e,t))}var r="";if((d||b.State.isAndroid&&!b.State.isChrome)&&i(e).isSVG){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){/^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])})}else{var n,o;f.each(i(e).transformCache,function(t){return n=i(e).transformCache[t],"transformPerspective"===t?(o=n,!0):(9===d&&"rotateZ"===t&&(t="rotate"),void(r+=t+n+" "))}),o&&(r="perspective"+o+" "+r)}S.setPropertyValue(e,"transform",r)}};S.Hooks.register(),S.Normalizations.register(),b.hook=function(e,t,r){var n=a;return e=o(e),f.each(e,function(e,o){if(i(o)===a&&b.init(o),r===a)n===a&&(n=b.CSS.getPropertyValue(o,t));else{var s=b.CSS.setPropertyValue(o,t,r);"transform"===s[0]&&b.CSS.flushTransformCache(o),n=s}}),n};var P=function(){function e(){return s?k.promise||null:l}function n(){function e(e){function p(e,t){var r=a,n=a,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]}function d(e,t){var r,a;return a=(t||"0").toString().toLowerCase().replace(/[%A-z]+$/,function(e){return r=e,""}),r||(r=S.Values.getUnitType(e)),[a,r]}function h(){var e={myParent:o.parentNode||r.body,position:S.getPropertyValue(o,"position"),fontSize:S.getPropertyValue(o,"fontSize")},a=e.position===L.lastPosition&&e.myParent===L.lastParent,n=e.fontSize===L.lastFontSize;L.lastParent=e.myParent,L.lastPosition=e.position,L.lastFontSize=e.fontSize;var s=100,l={};if(n&&a)l.emToPx=L.lastEmToPx,l.percentToPxWidth=L.lastPercentToPxWidth,l.percentToPxHeight=L.lastPercentToPxHeight;else{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){b.CSS.setPropertyValue(u,t,"hidden")}),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){b.CSS.setPropertyValue(u,t,s+"%")}),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)}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}if(s.begin&&0===V)try{s.begin.call(g,g)}catch(x){setTimeout(function(){throw x},1)}if("scroll"===A){var P,C,T,F=/^x$/i.test(s.axis)?"Left":"Top",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)}else if("reverse"===A){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)if("element"!==H){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)}l=E}else if("start"===A){var E;i(o).tweensContainer&&i(o).isAnimating===!0&&(E=i(o).tweensContainer),f.each(y,function(e,t){if(RegExp("^"+S.Lists.colors.join("$|^")+"$").test(e)){var r=p(t,!0),n=r[0],o=r[1],i=r[2];if(S.RegEx.isHex.test(n)){for(var s=["Red","Green","Blue"],l=S.Values.hexToRgb(n),u=i?S.Values.hexToRgb(i):a,c=0;c<s.length;c++){var f=[l[c]];o&&f.push(o),u!==a&&f.push(u[c]),y[e+s[c]]=f}delete y[e]}}});for(var z in y){var O=p(y[z]),q=O[0],$=O[1],M=O[2];z=S.Names.camelCase(z);var I=S.Hooks.getRoot(z),B=!1;if(i(o).isSVG||"tween"===I||S.Names.prefixCheck(I)[1]!==!1||S.Normalizations.registered[I]!==a){(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,G,Y,D=!1;if(W=d(z,M),M=W[0],Y=W[1],W=d(z,q),q=W[0].replace(/^([+-\/*])=/,function(e,t){return D=t,""}),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{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"%":M*="x"===Q?n.percentToPxWidth:n.percentToPxHeight;break;case"px":break;default:M*=n[Y+"ToPx"]}switch(G){case"%":M*=1/("x"===Q?n.percentToPxWidth:n.percentToPxHeight);break;case"px":break;default:M*=1/n[G+"ToPx"]}}switch(D){case"+":q=M+q;break;case"-":q=M-q;break;case"*":q=M*q;break;case"/":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)}else b.debug&&console.log("Skipping ["+I+"] due to a lack of browser support.")}l.element=o}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++)}var n,o=this,s=f.extend({},b.defaults,v),l={};switch(i(o)===a&&b.init(o),parseFloat(s.delay)&&s.queue!==!1&&f.queue(o,s.queue,function(e){b.velocityQueueEntryFlag=!0,i(o).delayTimer={setTimeout:setTimeout(e,parseFloat(s.delay)),next:e}}),s.duration.toString().toLowerCase()){case"fast":s.duration=200;break;case"normal":s.duration=h;break;case"slow":s.duration=600;break;default: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){return r===!0?(k.promise&&k.resolver(g),!0):(b.velocityQueueEntryFlag=!0,void e(t))}),""!==s.queue&&"fx"!==s.queue||"inprogress"===f.queue(o)[0]||f.dequeue(o)}var s,l,d,g,y,v,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)){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,V=0;if(!/^(stop|finish)$/i.test(y)&&!f.isPlainObject(v)){var C=d+1;v={};for(var T=C;T<arguments.length;T++)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]}var k={promise:null,resolver:null,rejecter:null};s&&b.Promise&&(k.promise=new b.Promise(function(e,t){k.resolver=e,k.rejecter=t}));var A;switch(y){case"scroll":A="scroll";break;case"reverse":A="reverse";break;case"finish":case"stop":f.each(g,function(e,t){i(t)&&i(t).delayTimer&&(clearTimeout(i(t).delayTimer.setTimeout),i(t).delayTimer.next&&i(t).delayTimer.next(),delete i(t).delayTimer)});var F=[];return f.each(b.State.calls,function(e,t){t&&f.each(t[1],function(r,n){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){a===n&&((v===!0||m.isString(v))&&(f.each(f.queue(a,m.isString(v)?v:""),function(e,t){
234m.isFunction(t)&&t(null,!0)}),f.queue(a,m.isString(v)?v:"",[])),"stop"===y?(i(a)&&i(a).tweensContainer&&o!==!1&&f.each(i(a).tweensContainer,function(e,t){t.endValue=t.currentValue}),F.push(e)):"finish"===y&&(t[2].duration=1))}):!0})}),"stop"===y&&(f.each(F,function(e,t){p(t,!0)}),k.promise&&k.resolver(g)),e();default:if(!f.isPlainObject(y)||m.isEmptyObject(y)){if(m.isString(y)&&b.Redirects[y]){var j=f.extend({},v),E=j.duration,H=j.delay||0;return j.backwards===!0&&(g=f.extend(!0,[],g).reverse()),f.each(g,function(e,t){parseFloat(j.stagger)?j.delay=H+parseFloat(j.stagger)*e:m.isFunction(j.stagger)&&(j.delay=H+j.stagger.call(t,e,w)),j.drag&&(j.duration=parseFloat(E)||(/^(callout|transition)/.test(y)?1e3:h),j.duration=Math.max(j.duration*(j.backwards?1-e/w:(e+1)/w),.75*j.duration,200)),b.Redirects[y].call(t,t,j||{},e,w,g,k.promise?k:a)}),e()}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()}A="start"}var L={lastParent:null,lastPosition:null,lastFontSize:null,lastPercentToPxWidth:null,lastPercentToPxHeight:null,lastEmToPx:null,remToPx:null,vwToPx:null,vhToPx:null},R=[];f.each(g,function(e,t){m.isNode(t)&&n.call(t)});var z,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++){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)}return e()}};b=f.extend(P,b),b.animate=P;var w=t.requestAnimationFrame||g;return b.State.isMobile||r.hidden===a||r.addEventListener("visibilitychange",function(){r.hidden?(w=function(e){return setTimeout(function(){e(!0)},16)},c()):w=t.requestAnimationFrame||g}),e.Velocity=b,e!==t&&(e.fn.velocity=P,e.fn.velocity.defaults=b.defaults),f.each(["Down","Up"],function(e,t){b.Redirects["slide"+t]=function(e,r,n,o,i,s){var l=f.extend({},r),u=l.begin,c=l.complete,p={height:"",marginTop:"",marginBottom:"",paddingTop:"",paddingBottom:""},d={};l.display===a&&(l.display="Down"===t?"inline"===b.CSS.Values.getDisplayType(e)?"inline-block":"block":"none"),l.begin=function(){u&&u.call(i,i);for(var r in p){d[r]=e.style[r];var a=b.CSS.getPropertyValue(e,r);p[r]="Down"===t?[a,0]:[0,a]}d.overflow=e.style.overflow,e.style.overflow="hidden"},l.complete=function(){for(var t in d)e.style[t]=d[t];c&&c.call(i,i),s&&s.resolver(i)},b(e,p,l)}}),f.each(["In","Out"],function(e,t){b.Redirects["fade"+t]=function(e,r,n,o,i,s){var l=f.extend({},r),u={opacity:"In"===t?1:0},c=l.complete;l.complete=n!==o-1?l.begin=null:function(){c&&c.call(i,i),s&&s.resolver(i)},l.display===a&&(l.display="In"===t?"auto":"none"),b(this,u,l)}}),b}(window.jQuery||window.Zepto||window,window,document)}));
235;!function(a,b,c,d){"use strict";function k(a,b,c){return setTimeout(q(a,c),b)}function l(a,b,c){return Array.isArray(a)?(m(a,c[b],c),!0):!1}function m(a,b,c){var e;if(a)if(a.forEach)a.forEach(b,c);else if(a.length!==d)for(e=0;e<a.length;)b.call(c,a[e],e,a),e++;else for(e in a)a.hasOwnProperty(e)&&b.call(c,a[e],e,a)}function n(a,b,c){for(var e=Object.keys(b),f=0;f<e.length;)(!c||c&&a[e[f]]===d)&&(a[e[f]]=b[e[f]]),f++;return a}function o(a,b){return n(a,b,!0)}function p(a,b,c){var e,d=b.prototype;e=a.prototype=Object.create(d),e.constructor=a,e._super=d,c&&n(e,c)}function q(a,b){return function(){return a.apply(b,arguments)}}function r(a,b){return typeof a==g?a.apply(b?b[0]||d:d,b):a}function s(a,b){return a===d?b:a}function t(a,b,c){m(x(b),function(b){a.addEventListener(b,c,!1)})}function u(a,b,c){m(x(b),function(b){a.removeEventListener(b,c,!1)})}function v(a,b){for(;a;){if(a==b)return!0;a=a.parentNode}return!1}function w(a,b){return a.indexOf(b)>-1}function x(a){return a.trim().split(/\s+/g)}function y(a,b,c){if(a.indexOf&&!c)return a.indexOf(b);for(var d=0;d<a.length;){if(c&&a[d][c]==b||!c&&a[d]===b)return d;d++}return-1}function z(a){return Array.prototype.slice.call(a,0)}function A(a,b,c){for(var d=[],e=[],f=0;f<a.length;){var g=b?a[f][b]:a[f];y(e,g)<0&&d.push(a[f]),e[f]=g,f++}return c&&(d=b?d.sort(function(a,c){return a[b]>c[b]}):d.sort()),d}function B(a,b){for(var c,f,g=b[0].toUpperCase()+b.slice(1),h=0;h<e.length;){if(c=e[h],f=c?c+g:b,f in a)return f;h++}return d}function D(){return C++}function E(a){var b=a.ownerDocument;return b.defaultView||b.parentWindow}function ab(a,b){var c=this;this.manager=a,this.callback=b,this.element=a.element,this.target=a.options.inputTarget,this.domHandler=function(b){r(a.options.enable,[a])&&c.handler(b)},this.init()}function bb(a){var b,c=a.options.inputClass;return b=c?c:H?wb:I?Eb:G?Gb:rb,new b(a,cb)}function cb(a,b,c){var d=c.pointers.length,e=c.changedPointers.length,f=b&O&&0===d-e,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}function db(a,b){var c=a.session,d=b.pointers,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,g=c.firstMultiple,h=g?g.center:f.center,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}function eb(a,b){var c=b.center,d=a.offsetDelta||{},e=a.prevDelta||{},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)}function fb(a,b){var f,g,h,j,c=a.lastInterval||b,e=b.timeStamp-c.timeStamp;if(b.eventType!=R&&(e>N||c.velocity===d)){var k=c.deltaX-b.deltaX,l=c.deltaY-b.deltaY,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}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}function gb(a){for(var b=[],c=0;c<a.pointers.length;)b[c]={clientX:h(a.pointers[c].clientX),clientY:h(a.pointers[c].clientY)},c++;return{timeStamp:j(),pointers:b,center:hb(b),deltaX:a.deltaX,deltaY:a.deltaY}}function hb(a){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;)c+=a[e].clientX,d+=a[e].clientY,e++;return{x:h(c/b),y:h(d/b)}}function ib(a,b,c){return{x:b/a||0,y:c/a||0}}function jb(a,b){return a===b?S:i(a)>=i(b)?a>0?T:U:b>0?V:W}function kb(a,b,c){c||(c=$);var d=b[c[0]]-a[c[0]],e=b[c[1]]-a[c[1]];return Math.sqrt(d*d+e*e)}function lb(a,b,c){c||(c=$);var d=b[c[0]]-a[c[0]],e=b[c[1]]-a[c[1]];return 180*Math.atan2(e,d)/Math.PI}function mb(a,b){return lb(b[1],b[0],_)-lb(a[1],a[0],_)}function nb(a,b){return kb(b[0],b[1],_)/kb(a[0],a[1],_)}function rb(){this.evEl=pb,this.evWin=qb,this.allow=!0,this.pressed=!1,ab.apply(this,arguments)}function wb(){this.evEl=ub,this.evWin=vb,ab.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}function Ab(){this.evTarget=yb,this.evWin=zb,this.started=!1,ab.apply(this,arguments)}function Bb(a,b){var c=z(a.touches),d=z(a.changedTouches);return b&(Q|R)&&(c=A(c.concat(d),"identifier",!0)),[c,d]}function Eb(){this.evTarget=Db,this.targetIds={},ab.apply(this,arguments)}function Fb(a,b){var c=z(a.touches),d=this.targetIds;if(b&(O|P)&&1===c.length)return d[c[0].identifier]=!0,[c,c];var e,f,g=z(a.changedTouches),h=[],i=this.target;if(f=c.filter(function(a){return v(a.target,i)}),b===O)for(e=0;e<f.length;)d[f[e].identifier]=!0,e++;for(e=0;e<g.length;)d[g[e].identifier]&&h.push(g[e]),b&(Q|R)&&delete d[g[e].identifier],e++;return h.length?[A(f.concat(h),"identifier",!0),h]:void 0}function Gb(){ab.apply(this,arguments);var a=q(this.handler,this);this.touch=new Eb(this.manager,a),this.mouse=new rb(this.manager,a)}function Pb(a,b){this.manager=a,this.set(b)}function Qb(a){if(w(a,Mb))return Mb;var b=w(a,Nb),c=w(a,Ob);return b&&c?Nb+" "+Ob:b||c?b?Nb:Ob:w(a,Lb)?Lb:Kb}function Yb(a){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=[]}function Zb(a){return a&Wb?"cancel":a&Ub?"end":a&Tb?"move":a&Sb?"start":""}function $b(a){return a==W?"down":a==V?"up":a==T?"left":a==U?"right":""}function _b(a,b){var c=b.manager;return c?c.get(a):a}function ac(){Yb.apply(this,arguments)}function bc(){ac.apply(this,arguments),this.pX=null,this.pY=null}function cc(){ac.apply(this,arguments)}function dc(){Yb.apply(this,arguments),this._timer=null,this._input=null}function ec(){ac.apply(this,arguments)}function fc(){ac.apply(this,arguments)}function gc(){Yb.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}function hc(a,b){return b=b||{},b.recognizers=s(b.recognizers,hc.defaults.preset),new kc(a,b)}function kc(a,b){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){var b=this.add(new a[0](a[1]));a[2]&&b.recognizeWith(a[2]),a[3]&&b.requireFailure(a[3])},this)}function lc(a,b){var c=a.element;m(a.options.cssProps,function(a,d){c.style[B(c.style,d)]=b?a:""})}function mc(a,c){var d=b.createEvent("Event");d.initEvent(a,!0,!0),d.gesture=c,c.target.dispatchEvent(d)}var e=["","webkit","moz","MS","ms","o"],f=b.createElement("div"),g="function",h=Math.round,i=Math.abs,j=Date.now,C=1,F=/mobile|tablet|ip(ad|hone|od)|android/i,G="ontouchstart"in a,H=B(a,"PointerEvent")!==d,I=G&&F.test(navigator.userAgent),J="touch",K="pen",L="mouse",M="kinect",N=25,O=1,P=2,Q=4,R=8,S=1,T=2,U=4,V=8,W=16,X=T|U,Y=V|W,Z=X|Y,$=["x","y"],_=["clientX","clientY"];ab.prototype={handler:function(){},init:function(){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)},destroy:function(){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)}};var ob={mousedown:O,mousemove:P,mouseup:Q},pb="mousedown",qb="mousemove mouseup";p(rb,ab,{handler:function(a){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}))}});var sb={pointerdown:O,pointermove:P,pointerup:Q,pointercancel:R,pointerout:R},tb={2:J,3:K,4:L,5:M},ub="pointerdown",vb="pointermove pointerup pointercancel";a.MSPointerEvent&&(ub="MSPointerDown",vb="MSPointerMove MSPointerUp MSPointerCancel"),p(wb,ab,{handler:function(a){var b=this.store,c=!1,d=a.type.toLowerCase().replace("ms",""),e=sb[d],f=tb[a.pointerType]||a.pointerType,g=f==J,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))}});var xb={touchstart:O,touchmove:P,touchend:Q,touchcancel:R},yb="touchstart",zb="touchstart touchmove touchend touchcancel";p(Ab,ab,{handler:function(a){var b=xb[a.type];if(b===O&&(this.started=!0),this.started){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})}}});var Cb={touchstart:O,touchmove:P,touchend:Q,touchcancel:R},Db="touchstart touchmove touchend touchcancel";p(Eb,ab,{handler:function(a){var b=Cb[a.type],c=Fb.call(this,a,b);c&&this.callback(this.manager,b,{pointers:c[0],changedPointers:c[1],pointerType:J,srcEvent:a})}}),p(Gb,ab,{handler:function(a,b,c){var d=c.pointerType==J,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)},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});var Hb=B(f.style,"touchAction"),Ib=Hb!==d,Jb="compute",Kb="auto",Lb="manipulation",Mb="none",Nb="pan-x",Ob="pan-y";Pb.prototype={set:function(a){a==Jb&&(a=this.compute()),Ib&&(this.manager.element.style[Hb]=a),this.actions=a.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var a=[];return m(this.manager.recognizers,function(b){r(b.options.enable,[b])&&(a=a.concat(b.getTouchAction()))}),Qb(a.join(" "))},preventDefaults:function(a){if(!Ib){var b=a.srcEvent,c=a.offsetDirection;if(this.manager.session.prevented)return b.preventDefault(),void 0;var d=this.actions,e=w(d,Mb),f=w(d,Ob),g=w(d,Nb);return e||f&&c&X||g&&c&Y?this.preventSrc(b):void 0}},preventSrc:function(a){this.manager.session.prevented=!0,a.preventDefault()}};var Rb=1,Sb=2,Tb=4,Ub=8,Vb=Ub,Wb=16,Xb=32;Yb.prototype={defaults:{},set:function(a){return n(this.options,a),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(a){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},dropRecognizeWith:function(a){return l(a,"dropRecognizeWith",this)?this:(a=_b(a,this),delete this.simultaneous[a.id],this)},requireFailure:function(a){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},dropRequireFailure:function(a){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},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(a){return!!this.simultaneous[a.id]},emit:function(a){function d(d){b.manager.emit(b.options.event+(d?Zb(c):""),a)}var b=this,c=this.state;Ub>c&&d(!0),d(),c>=Ub&&d(!0)},tryEmit:function(a){return this.canEmit()?this.emit(a):(this.state=Xb,void 0)},canEmit:function(){for(var a=0;a<this.requireFail.length;){if(!(this.requireFail[a].state&(Xb|Rb)))return!1;a++}return!0},recognize:function(a){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)},process:function(){},getTouchAction:function(){},reset:function(){}},p(ac,Yb,{defaults:{pointers:1},attrTest:function(a){var b=this.options.pointers;return 0===b||a.pointers.length===b},process:function(a){var b=this.state,c=a.eventType,d=b&(Sb|Tb),e=this.attrTest(a);return d&&(c&R||!e)?b|Wb:d||e?c&Q?b|Ub:b&Sb?b|Tb:Sb:Xb}}),p(bc,ac,{defaults:{event:"pan",threshold:10,pointers:1,direction:Z},getTouchAction:function(){var a=this.options.direction,b=[];return a&X&&b.push(Ob),a&Y&&b.push(Nb),b},directionTest:function(a){var b=this.options,c=!0,d=a.distance,e=a.direction,f=a.deltaX,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},attrTest:function(a){return ac.prototype.attrTest.call(this,a)&&(this.state&Sb||!(this.state&Sb)&&this.directionTest(a))},emit:function(a){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)}}),p(cc,ac,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[Mb]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.scale-1)>this.options.threshold||this.state&Sb)},emit:function(a){if(this._super.emit.call(this,a),1!==a.scale){var b=a.scale<1?"in":"out";this.manager.emit(this.options.event+b,a)}}}),p(dc,Yb,{defaults:{event:"press",pointers:1,time:500,threshold:5},getTouchAction:function(){return[Kb]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distance<b.threshold,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(){this.state=Vb,this.tryEmit()},b.time,this);else if(a.eventType&Q)return Vb;return Xb},reset:function(){clearTimeout(this._timer)},emit:function(a){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)))}}),p(ec,ac,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[Mb]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.rotation)>this.options.threshold||this.state&Sb)}}),p(fc,ac,{defaults:{event:"swipe",threshold:10,velocity:.65,direction:X|Y,pointers:1},getTouchAction:function(){return bc.prototype.getTouchAction.call(this)},attrTest:function(a){var c,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},emit:function(a){var b=$b(a.direction);b&&this.manager.emit(this.options.event+b,a),this.manager.emit(this.options.event,a)}}),p(gc,Yb,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:2,posThreshold:10},getTouchAction:function(){return[Lb]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distance<b.threshold,e=a.deltaTime<b.time;if(this.reset(),a.eventType&O&&0===this.count)return this.failTimeout();if(d&&e&&c){if(a.eventType!=Q)return this.failTimeout();var f=this.pTime?a.timeStamp-this.pTime<b.interval:!0,g=!this.pCenter||kb(this.pCenter,a.center)<b.posThreshold;this.pTime=a.timeStamp,this.pCenter=a.center,g&&f?this.count+=1:this.count=1,this._input=a;var h=this.count%b.taps;if(0===h)return this.hasRequireFailures()?(this._timer=k(function(){this.state=Vb,this.tryEmit()},b.interval,this),Sb):Vb}return Xb},failTimeout:function(){return this._timer=k(function(){this.state=Xb},this.options.interval,this),Xb},reset:function(){clearTimeout(this._timer)},emit:function(){this.state==Vb&&(this._input.tapCount=this.count,this.manager.emit(this.options.event,this._input))}}),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,jc=2;kc.prototype={set:function(a){return n(this.options,a),a.touchAction&&this.touchAction.update(),a.inputTarget&&(this.input.destroy(),this.input.target=a.inputTarget,this.input.init()),this},stop:function(a){this.session.stopped=a?jc:ic},recognize:function(a){var b=this.session;if(!b.stopped){this.touchAction.preventDefaults(a);var c,d=this.recognizers,e=b.curRecognizer;(!e||e&&e.state&Vb)&&(e=b.curRecognizer=null);for(var f=0;f<d.length;)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++}},get:function(a){if(a instanceof Yb)return a;for(var b=this.recognizers,c=0;c<b.length;c++)if(b[c].options.event==a)return b[c];return null},add:function(a){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},remove:function(a){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},on:function(a,b){var c=this.handlers;return m(x(a),function(a){c[a]=c[a]||[],c[a].push(b)}),this},off:function(a,b){var c=this.handlers;return m(x(a),function(a){b?c[a].splice(y(c[a],b),1):delete c[a]}),this},emit:function(a,b){this.options.domEvents&&mc(a,b);var c=this.handlers[a]&&this.handlers[a].slice();if(c&&c.length){b.type=a,b.preventDefault=function(){b.srcEvent.preventDefault()};for(var d=0;d<c.length;)c[d](b),d++}},destroy:function(){this.element&&lc(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}},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(){return hc}):"undefined"!=typeof module&&module.exports?module.exports=hc:a[c]=hc}(window,document,"Hammer");;(function(factory) {
236 if (typeof define === 'function' && define.amd) {
237 define(['jquery', 'hammerjs'], factory);
238 } else if (typeof exports === 'object') {
239 factory(require('jquery'), require('hammerjs'));
240 } else {
241 factory(jQuery, Hammer);
242 }
243}(function($, Hammer) {
244 function hammerify(el, options) {
245 var $el = $(el);
246 if(!$el.data("hammer")) {
247 $el.data("hammer", new Hammer($el[0], options));
248 }
249 }
250
251 $.fn.hammer = function(options) {
252 return this.each(function() {
253 hammerify(this, options);
254 });
255 };
256
257 // extend the emit method to also trigger jQuery events
258 Hammer.Manager.prototype.emit = (function(originalEmit) {
259 return function(type, data) {
260 originalEmit.call(this, type, data);
261 $(this.element).trigger({
262 type: type,
263 gesture: data
264 });
265 };
266 })(Hammer.Manager.prototype.emit);
267}));
268;// Required for Meteor package, the use of window prevents export by Meteor
269(function(window){
270 if(window.Package){
271 Materialize = {};
272 } else {
273 window.Materialize = {};
274 }
275})(window);
276
277
278// Unique ID
279Materialize.guid = (function() {
280 function s4() {
281 return Math.floor((1 + Math.random()) * 0x10000)
282 .toString(16)
283 .substring(1);
284 }
285 return function() {
286 return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
287 s4() + '-' + s4() + s4() + s4();
288 };
289})();
290
291Materialize.elementOrParentIsFixed = function(element) {
292 var $element = $(element);
293 var $checkElements = $element.add($element.parents());
294 var isFixed = false;
295 $checkElements.each(function(){
296 if ($(this).css("position") === "fixed") {
297 isFixed = true;
298 return false;
299 }
300 });
301 return isFixed;
302};
303
304// Velocity has conflicts when loaded with jQuery, this will check for it
305var Vel;
306if ($) {
307 Vel = $.Velocity;
308} else if (jQuery) {
309 Vel = jQuery.Velocity;
310} else {
311 Vel = Velocity;
312}
313;(function ($) {
314 $.fn.collapsible = function(options) {
315 var defaults = {
316 accordion: undefined
317 };
318
319 options = $.extend(defaults, options);
320
321
322 return this.each(function() {
323
324 var $this = $(this);
325
326 var $panel_headers = $(this).find('> li > .collapsible-header');
327
328 var collapsible_type = $this.data("collapsible");
329
330 // Turn off any existing event handlers
331 $this.off('click.collapse', '> li > .collapsible-header');
332 $panel_headers.off('click.collapse');
333
334
335 /****************
336 Helper Functions
337 ****************/
338
339 // Accordion Open
340 function accordionOpen(object) {
341 $panel_headers = $this.find('> li > .collapsible-header');
342 if (object.hasClass('active')) {
343 object.parent().addClass('active');
344 }
345 else {
346 object.parent().removeClass('active');
347 }
348 if (object.parent().hasClass('active')){
349 object.siblings('.collapsible-body').stop(true,false).slideDown({ duration: 350, easing: "easeOutQuart", queue: false, complete: function() {$(this).css('height', '');}});
350 }
351 else{
352 object.siblings('.collapsible-body').stop(true,false).slideUp({ duration: 350, easing: "easeOutQuart", queue: false, complete: function() {$(this).css('height', '');}});
353 }
354
355 $panel_headers.not(object).removeClass('active').parent().removeClass('active');
356 $panel_headers.not(object).parent().children('.collapsible-body').stop(true,false).slideUp(
357 {
358 duration: 350,
359 easing: "easeOutQuart",
360 queue: false,
361 complete:
362 function() {
363 $(this).css('height', '');
364 }
365 });
366 }
367
368 // Expandable Open
369 function expandableOpen(object) {
370 if (object.hasClass('active')) {
371 object.parent().addClass('active');
372 }
373 else {
374 object.parent().removeClass('active');
375 }
376 if (object.parent().hasClass('active')){
377 object.siblings('.collapsible-body').stop(true,false).slideDown({ duration: 350, easing: "easeOutQuart", queue: false, complete: function() {$(this).css('height', '');}});
378 }
379 else{
380 object.siblings('.collapsible-body').stop(true,false).slideUp({ duration: 350, easing: "easeOutQuart", queue: false, complete: function() {$(this).css('height', '');}});
381 }
382 }
383
384 /**
385 * Check if object is children of panel header
386 * @param {Object} object Jquery object
387 * @return {Boolean} true if it is children
388 */
389 function isChildrenOfPanelHeader(object) {
390
391 var panelHeader = getPanelHeader(object);
392
393 return panelHeader.length > 0;
394 }
395
396 /**
397 * Get panel header from a children element
398 * @param {Object} object Jquery object
399 * @return {Object} panel header object
400 */
401 function getPanelHeader(object) {
402
403 return object.closest('li > .collapsible-header');
404 }
405
406 /***** End Helper Functions *****/
407
408
409
410 // Add click handler to only direct collapsible header children
411 $this.on('click.collapse', '> li > .collapsible-header', function(e) {
412 var $header = $(this),
413 element = $(e.target);
414
415 if (isChildrenOfPanelHeader(element)) {
416 element = getPanelHeader(element);
417 }
418
419 element.toggleClass('active');
420
421 if (options.accordion || collapsible_type === "accordion" || collapsible_type === undefined) { // Handle Accordion
422 accordionOpen(element);
423 } else { // Handle Expandables
424 expandableOpen(element);
425
426 if ($header.hasClass('active')) {
427 expandableOpen($header);
428 }
429 }
430 });
431
432 // Open first active
433 var $panel_headers = $this.find('> li > .collapsible-header');
434 if (options.accordion || collapsible_type === "accordion" || collapsible_type === undefined) { // Handle Accordion
435 accordionOpen($panel_headers.filter('.active').first());
436 }
437 else { // Handle Expandables
438 $panel_headers.filter('.active').each(function() {
439 expandableOpen($(this));
440 });
441 }
442
443 });
444 };
445
446 $(document).ready(function(){
447 $('.collapsible').collapsible();
448 });
449}( jQuery ));;(function ($) {
450
451 // Add posibility to scroll to selected option
452 // usefull for select for example
453 $.fn.scrollTo = function(elem) {
454 $(this).scrollTop($(this).scrollTop() - $(this).offset().top + $(elem).offset().top);
455 return this;
456 };
457
458 $.fn.dropdown = function (options) {
459 var defaults = {
460 inDuration: 300,
461 outDuration: 225,
462 constrain_width: true, // Constrains width of dropdown to the activator
463 hover: false,
464 gutter: 0, // Spacing from edge
465 belowOrigin: false,
466 alignment: 'left',
467 stopPropagation: false
468 };
469
470 // Open dropdown.
471 if (options === "open") {
472 this.each(function() {
473 $(this).trigger('open');
474 });
475 return false;
476 }
477
478 // Close dropdown.
479 if (options === "close") {
480 this.each(function() {
481 $(this).trigger('close');
482 });
483 return false;
484 }
485
486 this.each(function(){
487 var origin = $(this);
488 var options = $.extend({}, defaults, options);
489 var isFocused = false;
490
491 // Dropdown menu
492 var activates = $("#"+ origin.attr('data-activates'));
493
494 function updateOptions() {
495 if (origin.data('induration') !== undefined)
496 options.inDuration = origin.data('induration');
497 if (origin.data('outduration') !== undefined)
498 options.outDuration = origin.data('outduration');
499 if (origin.data('constrainwidth') !== undefined)
500 options.constrain_width = origin.data('constrainwidth');
501 if (origin.data('hover') !== undefined)
502 options.hover = origin.data('hover');
503 if (origin.data('gutter') !== undefined)
504 options.gutter = origin.data('gutter');
505 if (origin.data('beloworigin') !== undefined)
506 options.belowOrigin = origin.data('beloworigin');
507 if (origin.data('alignment') !== undefined)
508 options.alignment = origin.data('alignment');
509 if (origin.data('stoppropagation') !== undefined)
510 options.stopPropagation = origin.data('stoppropagation');
511 }
512
513 updateOptions();
514
515 // Attach dropdown to its activator
516 origin.after(activates);
517
518 /*
519 Helper function to position and resize dropdown.
520 Used in hover and click handler.
521 */
522 function placeDropdown(eventType) {
523 // Check for simultaneous focus and click events.
524 if (eventType === 'focus') {
525 isFocused = true;
526 }
527
528 // Check html data attributes
529 updateOptions();
530
531 // Set Dropdown state
532 activates.addClass('active');
533 origin.addClass('active');
534
535 // Constrain width
536 if (options.constrain_width === true) {
537 activates.css('width', origin.outerWidth());
538
539 } else {
540 activates.css('white-space', 'nowrap');
541 }
542
543 // Offscreen detection
544 var windowHeight = window.innerHeight;
545 var originHeight = origin.innerHeight();
546 var offsetLeft = origin.offset().left;
547 var offsetTop = origin.offset().top - $(window).scrollTop();
548 var currAlignment = options.alignment;
549 var gutterSpacing = 0;
550 var leftPosition = 0;
551
552 // Below Origin
553 var verticalOffset = 0;
554 if (options.belowOrigin === true) {
555 verticalOffset = originHeight;
556 }
557
558 // Check for scrolling positioned container.
559 var scrollYOffset = 0;
560 var scrollXOffset = 0;
561 var wrapper = origin.parent();
562 if (!wrapper.is('body')) {
563 if (wrapper[0].scrollHeight > wrapper[0].clientHeight) {
564 scrollYOffset = wrapper[0].scrollTop;
565 }
566 if (wrapper[0].scrollWidth > wrapper[0].clientWidth) {
567 scrollXOffset = wrapper[0].scrollLeft;
568 }
569 }
570
571
572 if (offsetLeft + activates.innerWidth() > $(window).width()) {
573 // Dropdown goes past screen on right, force right alignment
574 currAlignment = 'right';
575
576 } else if (offsetLeft - activates.innerWidth() + origin.innerWidth() < 0) {
577 // Dropdown goes past screen on left, force left alignment
578 currAlignment = 'left';
579 }
580 // Vertical bottom offscreen detection
581 if (offsetTop + activates.innerHeight() > windowHeight) {
582 // If going upwards still goes offscreen, just crop height of dropdown.
583 if (offsetTop + originHeight - activates.innerHeight() < 0) {
584 var adjustedHeight = windowHeight - offsetTop - verticalOffset;
585 activates.css('max-height', adjustedHeight);
586 } else {
587 // Flow upwards.
588 if (!verticalOffset) {
589 verticalOffset += originHeight;
590 }
591 verticalOffset -= activates.innerHeight();
592 }
593 }
594
595 // Handle edge alignment
596 if (currAlignment === 'left') {
597 gutterSpacing = options.gutter;
598 leftPosition = origin.position().left + gutterSpacing;
599 }
600 else if (currAlignment === 'right') {
601 var offsetRight = origin.position().left + origin.outerWidth() - activates.outerWidth();
602 gutterSpacing = -options.gutter;
603 leftPosition = offsetRight + gutterSpacing;
604 }
605
606 // Position dropdown
607 activates.css({
608 position: 'absolute',
609 top: origin.position().top + verticalOffset + scrollYOffset,
610 left: leftPosition + scrollXOffset
611 });
612
613
614 // Show dropdown
615 activates.stop(true, true).css('opacity', 0)
616 .slideDown({
617 queue: false,
618 duration: options.inDuration,
619 easing: 'easeOutCubic',
620 complete: function() {
621 $(this).css('height', '');
622 }
623 })
624 .animate( {opacity: 1}, {queue: false, duration: options.inDuration, easing: 'easeOutSine'});
625 }
626
627 function hideDropdown() {
628 // Check for simultaneous focus and click events.
629 isFocused = false;
630 activates.fadeOut(options.outDuration);
631 activates.removeClass('active');
632 origin.removeClass('active');
633 setTimeout(function() { activates.css('max-height', ''); }, options.outDuration);
634 }
635
636 // Hover
637 if (options.hover) {
638 var open = false;
639 origin.unbind('click.' + origin.attr('id'));
640 // Hover handler to show dropdown
641 origin.on('mouseenter', function(e){ // Mouse over
642 if (open === false) {
643 placeDropdown();
644 open = true;
645 }
646 });
647 origin.on('mouseleave', function(e){
648 // If hover on origin then to something other than dropdown content, then close
649 var toEl = e.toElement || e.relatedTarget; // added browser compatibility for target element
650 if(!$(toEl).closest('.dropdown-content').is(activates)) {
651 activates.stop(true, true);
652 hideDropdown();
653 open = false;
654 }
655 });
656
657 activates.on('mouseleave', function(e){ // Mouse out
658 var toEl = e.toElement || e.relatedTarget;
659 if(!$(toEl).closest('.dropdown-button').is(origin)) {
660 activates.stop(true, true);
661 hideDropdown();
662 open = false;
663 }
664 });
665
666 // Click
667 } else {
668 // Click handler to show dropdown
669 origin.unbind('click.' + origin.attr('id'));
670 origin.bind('click.'+origin.attr('id'), function(e){
671 if (!isFocused) {
672 if ( origin[0] == e.currentTarget &&
673 !origin.hasClass('active') &&
674 ($(e.target).closest('.dropdown-content').length === 0)) {
675 e.preventDefault(); // Prevents button click from moving window
676 if (options.stopPropagation) {
677 e.stopPropagation();
678 }
679 placeDropdown('click');
680 }
681 // If origin is clicked and menu is open, close menu
682 else if (origin.hasClass('active')) {
683 hideDropdown();
684 $(document).unbind('click.'+ activates.attr('id') + ' touchstart.' + activates.attr('id'));
685 }
686 // If menu open, add click close handler to document
687 if (activates.hasClass('active')) {
688 $(document).bind('click.'+ activates.attr('id') + ' touchstart.' + activates.attr('id'), function (e) {
689 if (!activates.is(e.target) && !origin.is(e.target) && (!origin.find(e.target).length) ) {
690 hideDropdown();
691 $(document).unbind('click.'+ activates.attr('id') + ' touchstart.' + activates.attr('id'));
692 }
693 });
694 }
695 }
696 });
697
698 } // End else
699
700 // Listen to open and close event - useful for select component
701 origin.on('open', function(e, eventType) {
702 placeDropdown(eventType);
703 });
704 origin.on('close', hideDropdown);
705
706
707 });
708 }; // End dropdown plugin
709
710 $(document).ready(function(){
711 $('.dropdown-button').dropdown();
712 });
713}( jQuery ));
714;(function($) {
715 var _stack = 0,
716 _lastID = 0,
717 _generateID = function() {
718 _lastID++;
719 return 'materialize-lean-overlay-' + _lastID;
720 };
721
722 $.fn.extend({
723 openModal: function(options) {
724
725 var $body = $('body');
726 var oldWidth = $body.innerWidth();
727 $body.css('overflow', 'hidden');
728 $body.width(oldWidth);
729
730 var defaults = {
731 opacity: 0.5,
732 in_duration: 350,
733 out_duration: 250,
734 ready: undefined,
735 complete: undefined,
736 dismissible: true,
737 starting_top: '4%',
738 ending_top: '10%'
739 };
740 var $modal = $(this);
741
742 if ($modal.hasClass('open')) {
743 return;
744 }
745
746 var overlayID = _generateID();
747 var $overlay = $('<div class="lean-overlay"></div>');
748 lStack = (++_stack);
749
750 // Store a reference of the overlay
751 $overlay.attr('id', overlayID).css('z-index', 1000 + lStack * 2);
752 $modal.data('overlay-id', overlayID).css('z-index', 1000 + lStack * 2 + 1);
753 $modal.addClass('open');
754
755 $("body").append($overlay);
756
757 // Override defaults
758 options = $.extend(defaults, options);
759
760 if (options.dismissible) {
761 $overlay.click(function() {
762 $modal.closeModal(options);
763 });
764 // Return on ESC
765 $(document).on('keyup.leanModal' + overlayID, function(e) {
766 if (e.keyCode === 27) { // ESC key
767 $modal.closeModal(options);
768 }
769 });
770 }
771
772 $modal.find(".modal-close").on('click.close', function(e) {
773 $modal.closeModal(options);
774 });
775
776 $overlay.css({ display : "block", opacity : 0 });
777
778 $modal.css({
779 display : "block",
780 opacity: 0
781 });
782
783 $overlay.velocity({opacity: options.opacity}, {duration: options.in_duration, queue: false, ease: "easeOutCubic"});
784 $modal.data('associated-overlay', $overlay[0]);
785
786 // Define Bottom Sheet animation
787 if ($modal.hasClass('bottom-sheet')) {
788 $modal.velocity({bottom: "0", opacity: 1}, {
789 duration: options.in_duration,
790 queue: false,
791 ease: "easeOutCubic",
792 // Handle modal ready callback
793 complete: function() {
794 if (typeof(options.ready) === "function") {
795 options.ready();
796 }
797 }
798 });
799 }
800 else {
801 $.Velocity.hook($modal, "scaleX", 0.7);
802 $modal.css({ top: options.starting_top });
803 $modal.velocity({top: options.ending_top, opacity: 1, scaleX: '1'}, {
804 duration: options.in_duration,
805 queue: false,
806 ease: "easeOutCubic",
807 // Handle modal ready callback
808 complete: function() {
809 if (typeof(options.ready) === "function") {
810 options.ready();
811 }
812 }
813 });
814 }
815
816
817 }
818 });
819
820 $.fn.extend({
821 closeModal: function(options) {
822 var defaults = {
823 out_duration: 250,
824 complete: undefined
825 };
826 var $modal = $(this);
827 var overlayID = $modal.data('overlay-id');
828 var $overlay = $('#' + overlayID);
829 $modal.removeClass('open');
830
831 options = $.extend(defaults, options);
832
833 // Enable scrolling
834 $('body').css({
835 overflow: '',
836 width: ''
837 });
838
839 $modal.find('.modal-close').off('click.close');
840 $(document).off('keyup.leanModal' + overlayID);
841
842 $overlay.velocity( { opacity: 0}, {duration: options.out_duration, queue: false, ease: "easeOutQuart"});
843
844
845 // Define Bottom Sheet animation
846 if ($modal.hasClass('bottom-sheet')) {
847 $modal.velocity({bottom: "-100%", opacity: 0}, {
848 duration: options.out_duration,
849 queue: false,
850 ease: "easeOutCubic",
851 // Handle modal ready callback
852 complete: function() {
853 $overlay.css({display:"none"});
854
855 // Call complete callback
856 if (typeof(options.complete) === "function") {
857 options.complete();
858 }
859 $overlay.remove();
860 _stack--;
861 }
862 });
863 }
864 else {
865 $modal.velocity(
866 { top: options.starting_top, opacity: 0, scaleX: 0.7}, {
867 duration: options.out_duration,
868 complete:
869 function() {
870
871 $(this).css('display', 'none');
872 // Call complete callback
873 if (typeof(options.complete) === "function") {
874 options.complete();
875 }
876 $overlay.remove();
877 _stack--;
878 }
879 }
880 );
881 }
882 }
883 });
884
885 $.fn.extend({
886 leanModal: function(option) {
887 return this.each(function() {
888
889 var defaults = {
890 starting_top: '4%'
891 },
892 // Override defaults
893 options = $.extend(defaults, option);
894
895 // Close Handlers
896 $(this).click(function(e) {
897 options.starting_top = ($(this).offset().top - $(window).scrollTop()) /1.15;
898 var modal_id = $(this).attr("href") || '#' + $(this).data('target');
899 $(modal_id).openModal(options);
900 e.preventDefault();
901 }); // done set on click
902 }); // done return
903 }
904 });
905})(jQuery);
906;(function ($) {
907
908 $.fn.materialbox = function () {
909
910 return this.each(function() {
911
912 if ($(this).hasClass('initialized')) {
913 return;
914 }
915
916 $(this).addClass('initialized');
917
918 var overlayActive = false;
919 var doneAnimating = true;
920 var inDuration = 275;
921 var outDuration = 200;
922 var origin = $(this);
923 var placeholder = $('<div></div>').addClass('material-placeholder');
924 var originalWidth = 0;
925 var originalHeight = 0;
926 var ancestorsChanged;
927 var ancestor;
928 origin.wrap(placeholder);
929
930
931 origin.on('click', function(){
932 var placeholder = origin.parent('.material-placeholder');
933 var windowWidth = window.innerWidth;
934 var windowHeight = window.innerHeight;
935 var originalWidth = origin.width();
936 var originalHeight = origin.height();
937
938
939 // If already modal, return to original
940 if (doneAnimating === false) {
941 returnToOriginal();
942 return false;
943 }
944 else if (overlayActive && doneAnimating===true) {
945 returnToOriginal();
946 return false;
947 }
948
949
950 // Set states
951 doneAnimating = false;
952 origin.addClass('active');
953 overlayActive = true;
954
955 // Set positioning for placeholder
956 placeholder.css({
957 width: placeholder[0].getBoundingClientRect().width,
958 height: placeholder[0].getBoundingClientRect().height,
959 position: 'relative',
960 top: 0,
961 left: 0
962 });
963
964 // Find ancestor with overflow: hidden; and remove it
965 ancestorsChanged = undefined;
966 ancestor = placeholder[0].parentNode;
967 var count = 0;
968 while (ancestor !== null && !$(ancestor).is(document)) {
969 var curr = $(ancestor);
970 if (curr.css('overflow') !== 'visible') {
971 curr.css('overflow', 'visible');
972 if (ancestorsChanged === undefined) {
973 ancestorsChanged = curr;
974 }
975 else {
976 ancestorsChanged = ancestorsChanged.add(curr);
977 }
978 }
979 ancestor = ancestor.parentNode;
980 }
981
982 // Set css on origin
983 origin.css({position: 'absolute', 'z-index': 1000})
984 .data('width', originalWidth)
985 .data('height', originalHeight);
986
987 // Add overlay
988 var overlay = $('<div id="materialbox-overlay"></div>')
989 .css({
990 opacity: 0
991 })
992 .click(function(){
993 if (doneAnimating === true)
994 returnToOriginal();
995 });
996 // Animate Overlay
997 // Put before in origin image to preserve z-index layering.
998 origin.before(overlay);
999 overlay.velocity({opacity: 1},
1000 {duration: inDuration, queue: false, easing: 'easeOutQuad'} );
1001
1002 // Add and animate caption if it exists
1003 if (origin.data('caption') !== "") {
1004 var $photo_caption = $('<div class="materialbox-caption"></div>');
1005 $photo_caption.text(origin.data('caption'));
1006 $('body').append($photo_caption);
1007 $photo_caption.css({ "display": "inline" });
1008 $photo_caption.velocity({opacity: 1}, {duration: inDuration, queue: false, easing: 'easeOutQuad'});
1009 }
1010
1011 // Resize Image
1012 var ratio = 0;
1013 var widthPercent = originalWidth / windowWidth;
1014 var heightPercent = originalHeight / windowHeight;
1015 var newWidth = 0;
1016 var newHeight = 0;
1017
1018 if (widthPercent > heightPercent) {
1019 ratio = originalHeight / originalWidth;
1020 newWidth = windowWidth * 0.9;
1021 newHeight = windowWidth * 0.9 * ratio;
1022 }
1023 else {
1024 ratio = originalWidth / originalHeight;
1025 newWidth = (windowHeight * 0.9) * ratio;
1026 newHeight = windowHeight * 0.9;
1027 }
1028
1029 // Animate image + set z-index
1030 if(origin.hasClass('responsive-img')) {
1031 origin.velocity({'max-width': newWidth, 'width': originalWidth}, {duration: 0, queue: false,
1032 complete: function(){
1033 origin.css({left: 0, top: 0})
1034 .velocity(
1035 {
1036 height: newHeight,
1037 width: newWidth,
1038 left: $(document).scrollLeft() + windowWidth/2 - origin.parent('.material-placeholder').offset().left - newWidth/2,
1039 top: $(document).scrollTop() + windowHeight/2 - origin.parent('.material-placeholder').offset().top - newHeight/ 2
1040 },
1041 {
1042 duration: inDuration,
1043 queue: false,
1044 easing: 'easeOutQuad',
1045 complete: function(){doneAnimating = true;}
1046 }
1047 );
1048 } // End Complete
1049 }); // End Velocity
1050 }
1051 else {
1052 origin.css('left', 0)
1053 .css('top', 0)
1054 .velocity(
1055 {
1056 height: newHeight,
1057 width: newWidth,
1058 left: $(document).scrollLeft() + windowWidth/2 - origin.parent('.material-placeholder').offset().left - newWidth/2,
1059 top: $(document).scrollTop() + windowHeight/2 - origin.parent('.material-placeholder').offset().top - newHeight/ 2
1060 },
1061 {
1062 duration: inDuration,
1063 queue: false,
1064 easing: 'easeOutQuad',
1065 complete: function(){doneAnimating = true;}
1066 }
1067 ); // End Velocity
1068 }
1069
1070 }); // End origin on click
1071
1072
1073 // Return on scroll
1074 $(window).scroll(function() {
1075 if (overlayActive) {
1076 returnToOriginal();
1077 }
1078 });
1079
1080 // Return on ESC
1081 $(document).keyup(function(e) {
1082
1083 if (e.keyCode === 27 && doneAnimating === true) { // ESC key
1084 if (overlayActive) {
1085 returnToOriginal();
1086 }
1087 }
1088 });
1089
1090
1091 // This function returns the modaled image to the original spot
1092 function returnToOriginal() {
1093
1094 doneAnimating = false;
1095
1096 var placeholder = origin.parent('.material-placeholder');
1097 var windowWidth = window.innerWidth;
1098 var windowHeight = window.innerHeight;
1099 var originalWidth = origin.data('width');
1100 var originalHeight = origin.data('height');
1101
1102 origin.velocity("stop", true);
1103 $('#materialbox-overlay').velocity("stop", true);
1104 $('.materialbox-caption').velocity("stop", true);
1105
1106
1107 $('#materialbox-overlay').velocity({opacity: 0}, {
1108 duration: outDuration, // Delay prevents animation overlapping
1109 queue: false, easing: 'easeOutQuad',
1110 complete: function(){
1111 // Remove Overlay
1112 overlayActive = false;
1113 $(this).remove();
1114 }
1115 });
1116
1117 // Resize Image
1118 origin.velocity(
1119 {
1120 width: originalWidth,
1121 height: originalHeight,
1122 left: 0,
1123 top: 0
1124 },
1125 {
1126 duration: outDuration,
1127 queue: false, easing: 'easeOutQuad'
1128 }
1129 );
1130
1131 // Remove Caption + reset css settings on image
1132 $('.materialbox-caption').velocity({opacity: 0}, {
1133 duration: outDuration, // Delay prevents animation overlapping
1134 queue: false, easing: 'easeOutQuad',
1135 complete: function(){
1136 placeholder.css({
1137 height: '',
1138 width: '',
1139 position: '',
1140 top: '',
1141 left: ''
1142 });
1143
1144 origin.css({
1145 height: '',
1146 top: '',
1147 left: '',
1148 width: '',
1149 'max-width': '',
1150 position: '',
1151 'z-index': ''
1152 });
1153
1154 // Remove class
1155 origin.removeClass('active');
1156 doneAnimating = true;
1157 $(this).remove();
1158
1159 // Remove overflow overrides on ancestors
1160 if (ancestorsChanged) {
1161 ancestorsChanged.css('overflow', '');
1162 }
1163 }
1164 });
1165
1166 }
1167 });
1168};
1169
1170$(document).ready(function(){
1171 $('.materialboxed').materialbox();
1172});
1173
1174}( jQuery ));
1175;(function ($) {
1176
1177 $.fn.parallax = function () {
1178 var window_width = $(window).width();
1179 // Parallax Scripts
1180 return this.each(function(i) {
1181 var $this = $(this);
1182 $this.addClass('parallax');
1183
1184 function updateParallax(initial) {
1185 var container_height;
1186 if (window_width < 601) {
1187 container_height = ($this.height() > 0) ? $this.height() : $this.children("img").height();
1188 }
1189 else {
1190 container_height = ($this.height() > 0) ? $this.height() : 500;
1191 }
1192 var $img = $this.children("img").first();
1193 var img_height = $img.height();
1194 var parallax_dist = img_height - container_height;
1195 var bottom = $this.offset().top + container_height;
1196 var top = $this.offset().top;
1197 var scrollTop = $(window).scrollTop();
1198 var windowHeight = window.innerHeight;
1199 var windowBottom = scrollTop + windowHeight;
1200 var percentScrolled = (windowBottom - top) / (container_height + windowHeight);
1201 var parallax = Math.round((parallax_dist * percentScrolled));
1202
1203 if (initial) {
1204 $img.css('display', 'block');
1205 }
1206 if ((bottom > scrollTop) && (top < (scrollTop + windowHeight))) {
1207 $img.css('transform', "translate3D(-50%," + parallax + "px, 0)");
1208 }
1209
1210 }
1211
1212 // Wait for image load
1213 $this.children("img").one("load", function() {
1214 updateParallax(true);
1215 }).each(function() {
1216 if(this.complete) $(this).load();
1217 });
1218
1219 $(window).scroll(function() {
1220 window_width = $(window).width();
1221 updateParallax(false);
1222 });
1223
1224 $(window).resize(function() {
1225 window_width = $(window).width();
1226 updateParallax(false);
1227 });
1228
1229 });
1230
1231 };
1232}( jQuery ));;(function ($) {
1233
1234 var methods = {
1235 init : function(options) {
1236 var defaults = {
1237 onShow: null
1238 };
1239 options = $.extend(defaults, options);
1240
1241 return this.each(function() {
1242
1243 // For each set of tabs, we want to keep track of
1244 // which tab is active and its associated content
1245 var $this = $(this),
1246 window_width = $(window).width();
1247
1248 $this.width('100%');
1249 var $active, $content, $links = $this.find('li.tab a'),
1250 $tabs_width = $this.width(),
1251 $tab_width = Math.max($tabs_width, $this[0].scrollWidth) / $links.length,
1252 $index = 0;
1253
1254 // If the location.hash matches one of the links, use that as the active tab.
1255 $active = $($links.filter('[href="'+location.hash+'"]'));
1256
1257 // If no match is found, use the first link or any with class 'active' as the initial active tab.
1258 if ($active.length === 0) {
1259 $active = $(this).find('li.tab a.active').first();
1260 }
1261 if ($active.length === 0) {
1262 $active = $(this).find('li.tab a').first();
1263 }
1264
1265 $active.addClass('active');
1266 $index = $links.index($active);
1267 if ($index < 0) {
1268 $index = 0;
1269 }
1270
1271 if ($active[0] !== undefined) {
1272 $content = $($active[0].hash);
1273 }
1274
1275 // append indicator then set indicator width to tab width
1276 $this.append('<div class="indicator"></div>');
1277 var $indicator = $this.find('.indicator');
1278 if ($this.is(":visible")) {
1279 $indicator.css({"right": $tabs_width - (($index + 1) * $tab_width)});
1280 $indicator.css({"left": $index * $tab_width});
1281 }
1282 $(window).resize(function () {
1283 $tabs_width = $this.width();
1284 $tab_width = Math.max($tabs_width, $this[0].scrollWidth) / $links.length;
1285 if ($index < 0) {
1286 $index = 0;
1287 }
1288 if ($tab_width !== 0 && $tabs_width !== 0) {
1289 $indicator.css({"right": $tabs_width - (($index + 1) * $tab_width)});
1290 $indicator.css({"left": $index * $tab_width});
1291 }
1292 });
1293
1294 // Hide the remaining content
1295 $links.not($active).each(function () {
1296 $(this.hash).hide();
1297 });
1298
1299
1300 // Bind the click event handler
1301 $this.on('click', 'a', function(e) {
1302 if ($(this).parent().hasClass('disabled')) {
1303 e.preventDefault();
1304 return;
1305 }
1306
1307 // Act as regular link if target attribute is specified.
1308 if (!!$(this).attr("target")) {
1309 return;
1310 }
1311
1312 $tabs_width = $this.width();
1313 $tab_width = Math.max($tabs_width, $this[0].scrollWidth) / $links.length;
1314
1315 // Make the old tab inactive.
1316 $active.removeClass('active');
1317 if ($content !== undefined) {
1318 $content.hide();
1319 }
1320
1321 // Update the variables with the new link and content
1322 $active = $(this);
1323 $content = $(this.hash);
1324 $links = $this.find('li.tab a');
1325
1326 // Make the tab active.
1327 $active.addClass('active');
1328 var $prev_index = $index;
1329 $index = $links.index($(this));
1330 if ($index < 0) {
1331 $index = 0;
1332 }
1333 // Change url to current tab
1334 // window.location.hash = $active.attr('href');
1335
1336 if ($content !== undefined) {
1337 $content.show();
1338 if (typeof(options.onShow) === "function") {
1339 options.onShow.call(this, $content);
1340 }
1341 }
1342
1343 // Update indicator
1344 if (($index - $prev_index) >= 0) {
1345 $indicator.velocity({"right": $tabs_width - (($index + 1) * $tab_width)}, { duration: 300, queue: false, easing: 'easeOutQuad'});
1346 $indicator.velocity({"left": $index * $tab_width}, {duration: 300, queue: false, easing: 'easeOutQuad', delay: 90});
1347
1348 }
1349 else {
1350 $indicator.velocity({"left": $index * $tab_width}, { duration: 300, queue: false, easing: 'easeOutQuad'});
1351 $indicator.velocity({"right": $tabs_width - (($index + 1) * $tab_width)}, {duration: 300, queue: false, easing: 'easeOutQuad', delay: 90});
1352 }
1353
1354 // Prevent the anchor's default click action
1355 e.preventDefault();
1356 });
1357 });
1358
1359 },
1360 select_tab : function( id ) {
1361 this.find('a[href="#' + id + '"]').trigger('click');
1362 }
1363 };
1364
1365 $.fn.tabs = function(methodOrOptions) {
1366 if ( methods[methodOrOptions] ) {
1367 return methods[ methodOrOptions ].apply( this, Array.prototype.slice.call( arguments, 1 ));
1368 } else if ( typeof methodOrOptions === 'object' || ! methodOrOptions ) {
1369 // Default to "init"
1370 return methods.init.apply( this, arguments );
1371 } else {
1372 $.error( 'Method ' + methodOrOptions + ' does not exist on jQuery.tooltip' );
1373 }
1374 };
1375
1376 $(document).ready(function(){
1377 $('ul.tabs').tabs();
1378 });
1379}( jQuery ));
1380;(function ($) {
1381 $.fn.tooltip = function (options) {
1382 var timeout = null,
1383 margin = 5;
1384
1385 // Defaults
1386 var defaults = {
1387 delay: 350,
1388 tooltip: '',
1389 position: 'bottom',
1390 html: false
1391 };
1392
1393 // Remove tooltip from the activator
1394 if (options === "remove") {
1395 this.each(function() {
1396 $('#' + $(this).attr('data-tooltip-id')).remove();
1397 $(this).off('mouseenter.tooltip mouseleave.tooltip');
1398 });
1399 return false;
1400 }
1401
1402 options = $.extend(defaults, options);
1403
1404 return this.each(function() {
1405 var tooltipId = Materialize.guid();
1406 var origin = $(this);
1407 origin.attr('data-tooltip-id', tooltipId);
1408
1409 // Get attributes.
1410 var allowHtml,
1411 tooltipDelay,
1412 tooltipPosition,
1413 tooltipText,
1414 tooltipEl,
1415 backdrop;
1416 var setAttributes = function() {
1417 allowHtml = origin.attr('data-html') ? origin.attr('data-html') === 'true' : options.html;
1418 tooltipDelay = origin.attr('data-delay');
1419 tooltipDelay = (tooltipDelay === undefined || tooltipDelay === '') ?
1420 options.delay : tooltipDelay;
1421 tooltipPosition = origin.attr('data-position');
1422 tooltipPosition = (tooltipPosition === undefined || tooltipPosition === '') ?
1423 options.position : tooltipPosition;
1424 tooltipText = origin.attr('data-tooltip');
1425 tooltipText = (tooltipText === undefined || tooltipText === '') ?
1426 options.tooltip : tooltipText;
1427 };
1428 setAttributes();
1429
1430 var renderTooltipEl = function() {
1431 var tooltip = $('<div class="material-tooltip"></div>');
1432
1433 // Create Text span
1434 if (allowHtml) {
1435 tooltipText = $('<span></span>').html(tooltipText);
1436 } else{
1437 tooltipText = $('<span></span>').text(tooltipText);
1438 }
1439
1440 // Create tooltip
1441 tooltip.append(tooltipText)
1442 .appendTo($('body'))
1443 .attr('id', tooltipId);
1444
1445 // Create backdrop
1446 backdrop = $('<div class="backdrop"></div>');
1447 backdrop.appendTo(tooltip);
1448 return tooltip;
1449 };
1450 tooltipEl = renderTooltipEl();
1451
1452 // Destroy previously binded events
1453 origin.off('mouseenter.tooltip mouseleave.tooltip');
1454 // Mouse In
1455 var started = false, timeoutRef;
1456 origin.on({'mouseenter.tooltip': function(e) {
1457 var showTooltip = function() {
1458 setAttributes();
1459 started = true;
1460 tooltipEl.velocity('stop');
1461 backdrop.velocity('stop');
1462 tooltipEl.css({ display: 'block', left: '0px', top: '0px' });
1463
1464 // Tooltip positioning
1465 var originWidth = origin.outerWidth();
1466 var originHeight = origin.outerHeight();
1467
1468 var tooltipHeight = tooltipEl.outerHeight();
1469 var tooltipWidth = tooltipEl.outerWidth();
1470 var tooltipVerticalMovement = '0px';
1471 var tooltipHorizontalMovement = '0px';
1472 var scaleXFactor = 8;
1473 var scaleYFactor = 8;
1474 var targetTop, targetLeft, newCoordinates;
1475
1476 if (tooltipPosition === "top") {
1477 // Top Position
1478 targetTop = origin.offset().top - tooltipHeight - margin;
1479 targetLeft = origin.offset().left + originWidth/2 - tooltipWidth/2;
1480 newCoordinates = repositionWithinScreen(targetLeft, targetTop, tooltipWidth, tooltipHeight);
1481
1482 tooltipVerticalMovement = '-10px';
1483 backdrop.css({
1484 bottom: 0,
1485 left: 0,
1486 borderRadius: '14px 14px 0 0',
1487 transformOrigin: '50% 100%',
1488 marginTop: tooltipHeight,
1489 marginLeft: (tooltipWidth/2) - (backdrop.width()/2)
1490 });
1491 }
1492 // Left Position
1493 else if (tooltipPosition === "left") {
1494 targetTop = origin.offset().top + originHeight/2 - tooltipHeight/2;
1495 targetLeft = origin.offset().left - tooltipWidth - margin;
1496 newCoordinates = repositionWithinScreen(targetLeft, targetTop, tooltipWidth, tooltipHeight);
1497
1498 tooltipHorizontalMovement = '-10px';
1499 backdrop.css({
1500 top: '-7px',
1501 right: 0,
1502 width: '14px',
1503 height: '14px',
1504 borderRadius: '14px 0 0 14px',
1505 transformOrigin: '95% 50%',
1506 marginTop: tooltipHeight/2,
1507 marginLeft: tooltipWidth
1508 });
1509 }
1510 // Right Position
1511 else if (tooltipPosition === "right") {
1512 targetTop = origin.offset().top + originHeight/2 - tooltipHeight/2;
1513 targetLeft = origin.offset().left + originWidth + margin;
1514 newCoordinates = repositionWithinScreen(targetLeft, targetTop, tooltipWidth, tooltipHeight);
1515
1516 tooltipHorizontalMovement = '+10px';
1517 backdrop.css({
1518 top: '-7px',
1519 left: 0,
1520 width: '14px',
1521 height: '14px',
1522 borderRadius: '0 14px 14px 0',
1523 transformOrigin: '5% 50%',
1524 marginTop: tooltipHeight/2,
1525 marginLeft: '0px'
1526 });
1527 }
1528 else {
1529 // Bottom Position
1530 targetTop = origin.offset().top + origin.outerHeight() + margin;
1531 targetLeft = origin.offset().left + originWidth/2 - tooltipWidth/2;
1532 newCoordinates = repositionWithinScreen(targetLeft, targetTop, tooltipWidth, tooltipHeight);
1533 tooltipVerticalMovement = '+10px';
1534 backdrop.css({
1535 top: 0,
1536 left: 0,
1537 marginLeft: (tooltipWidth/2) - (backdrop.width()/2)
1538 });
1539 }
1540
1541 // Set tooptip css placement
1542 tooltipEl.css({
1543 top: newCoordinates.y,
1544 left: newCoordinates.x
1545 });
1546
1547 // Calculate Scale to fill
1548 scaleXFactor = Math.SQRT2 * tooltipWidth / parseInt(backdrop.css('width'));
1549 scaleYFactor = Math.SQRT2 * tooltipHeight / parseInt(backdrop.css('height'));
1550
1551 tooltipEl.velocity({ marginTop: tooltipVerticalMovement, marginLeft: tooltipHorizontalMovement}, { duration: 350, queue: false })
1552 .velocity({opacity: 1}, {duration: 300, delay: 50, queue: false});
1553 backdrop.css({ display: 'block' })
1554 .velocity({opacity:1},{duration: 55, delay: 0, queue: false})
1555 .velocity({scaleX: scaleXFactor, scaleY: scaleYFactor}, {duration: 300, delay: 0, queue: false, easing: 'easeInOutQuad'});
1556 };
1557
1558 timeoutRef = setTimeout(showTooltip, tooltipDelay); // End Interval
1559
1560 // Mouse Out
1561 },
1562 'mouseleave.tooltip': function(){
1563 // Reset State
1564 started = false;
1565 clearTimeout(timeoutRef);
1566
1567 // Animate back
1568 setTimeout(function() {
1569 if (started !== true) {
1570 tooltipEl.velocity({
1571 opacity: 0, marginTop: 0, marginLeft: 0}, { duration: 225, queue: false});
1572 backdrop.velocity({opacity: 0, scaleX: 1, scaleY: 1}, {
1573 duration:225,
1574 queue: false,
1575 complete: function(){
1576 backdrop.css('display', 'none');
1577 tooltipEl.css('display', 'none');
1578 started = false;}
1579 });
1580 }
1581 },225);
1582 }
1583 });
1584 });
1585 };
1586
1587 var repositionWithinScreen = function(x, y, width, height) {
1588 var newX = x;
1589 var newY = y;
1590
1591 if (newX < 0) {
1592 newX = 4;
1593 } else if (newX + width > window.innerWidth) {
1594 newX -= newX + width - window.innerWidth;
1595 }
1596
1597 if (newY < 0) {
1598 newY = 4;
1599 } else if (newY + height > window.innerHeight + $(window).scrollTop) {
1600 newY -= newY + height - window.innerHeight;
1601 }
1602
1603 return {x: newX, y: newY};
1604 };
1605
1606 $(document).ready(function(){
1607 $('.tooltipped').tooltip();
1608 });
1609}( jQuery ));
1610;/*!
1611 * Waves v0.6.4
1612 * http://fian.my.id/Waves
1613 *
1614 * Copyright 2014 Alfiana E. Sibuea and other contributors
1615 * Released under the MIT license
1616 * https://github.com/fians/Waves/blob/master/LICENSE
1617 */
1618
1619;(function(window) {
1620 'use strict';
1621
1622 var Waves = Waves || {};
1623 var $$ = document.querySelectorAll.bind(document);
1624
1625 // Find exact position of element
1626 function isWindow(obj) {
1627 return obj !== null && obj === obj.window;
1628 }
1629
1630 function getWindow(elem) {
1631 return isWindow(elem) ? elem : elem.nodeType === 9 && elem.defaultView;
1632 }
1633
1634 function offset(elem) {
1635 var docElem, win,
1636 box = {top: 0, left: 0},
1637 doc = elem && elem.ownerDocument;
1638
1639 docElem = doc.documentElement;
1640
1641 if (typeof elem.getBoundingClientRect !== typeof undefined) {
1642 box = elem.getBoundingClientRect();
1643 }
1644 win = getWindow(doc);
1645 return {
1646 top: box.top + win.pageYOffset - docElem.clientTop,
1647 left: box.left + win.pageXOffset - docElem.clientLeft
1648 };
1649 }
1650
1651 function convertStyle(obj) {
1652 var style = '';
1653
1654 for (var a in obj) {
1655 if (obj.hasOwnProperty(a)) {
1656 style += (a + ':' + obj[a] + ';');
1657 }
1658 }
1659
1660 return style;
1661 }
1662
1663 var Effect = {
1664
1665 // Effect delay
1666 duration: 750,
1667
1668 show: function(e, element) {
1669
1670 // Disable right click
1671 if (e.button === 2) {
1672 return false;
1673 }
1674
1675 var el = element || this;
1676
1677 // Create ripple
1678 var ripple = document.createElement('div');
1679 ripple.className = 'waves-ripple';
1680 el.appendChild(ripple);
1681
1682 // Get click coordinate and element witdh
1683 var pos = offset(el);
1684 var relativeY = (e.pageY - pos.top);
1685 var relativeX = (e.pageX - pos.left);
1686 var scale = 'scale('+((el.clientWidth / 100) * 10)+')';
1687
1688 // Support for touch devices
1689 if ('touches' in e) {
1690 relativeY = (e.touches[0].pageY - pos.top);
1691 relativeX = (e.touches[0].pageX - pos.left);
1692 }
1693
1694 // Attach data to element
1695 ripple.setAttribute('data-hold', Date.now());
1696 ripple.setAttribute('data-scale', scale);
1697 ripple.setAttribute('data-x', relativeX);
1698 ripple.setAttribute('data-y', relativeY);
1699
1700 // Set ripple position
1701 var rippleStyle = {
1702 'top': relativeY+'px',
1703 'left': relativeX+'px'
1704 };
1705
1706 ripple.className = ripple.className + ' waves-notransition';
1707 ripple.setAttribute('style', convertStyle(rippleStyle));
1708 ripple.className = ripple.className.replace('waves-notransition', '');
1709
1710 // Scale the ripple
1711 rippleStyle['-webkit-transform'] = scale;
1712 rippleStyle['-moz-transform'] = scale;
1713 rippleStyle['-ms-transform'] = scale;
1714 rippleStyle['-o-transform'] = scale;
1715 rippleStyle.transform = scale;
1716 rippleStyle.opacity = '1';
1717
1718 rippleStyle['-webkit-transition-duration'] = Effect.duration + 'ms';
1719 rippleStyle['-moz-transition-duration'] = Effect.duration + 'ms';
1720 rippleStyle['-o-transition-duration'] = Effect.duration + 'ms';
1721 rippleStyle['transition-duration'] = Effect.duration + 'ms';
1722
1723 rippleStyle['-webkit-transition-timing-function'] = 'cubic-bezier(0.250, 0.460, 0.450, 0.940)';
1724 rippleStyle['-moz-transition-timing-function'] = 'cubic-bezier(0.250, 0.460, 0.450, 0.940)';
1725 rippleStyle['-o-transition-timing-function'] = 'cubic-bezier(0.250, 0.460, 0.450, 0.940)';
1726 rippleStyle['transition-timing-function'] = 'cubic-bezier(0.250, 0.460, 0.450, 0.940)';
1727
1728 ripple.setAttribute('style', convertStyle(rippleStyle));
1729 },
1730
1731 hide: function(e) {
1732 TouchHandler.touchup(e);
1733
1734 var el = this;
1735 var width = el.clientWidth * 1.4;
1736
1737 // Get first ripple
1738 var ripple = null;
1739 var ripples = el.getElementsByClassName('waves-ripple');
1740 if (ripples.length > 0) {
1741 ripple = ripples[ripples.length - 1];
1742 } else {
1743 return false;
1744 }
1745
1746 var relativeX = ripple.getAttribute('data-x');
1747 var relativeY = ripple.getAttribute('data-y');
1748 var scale = ripple.getAttribute('data-scale');
1749
1750 // Get delay beetween mousedown and mouse leave
1751 var diff = Date.now() - Number(ripple.getAttribute('data-hold'));
1752 var delay = 350 - diff;
1753
1754 if (delay < 0) {
1755 delay = 0;
1756 }
1757
1758 // Fade out ripple after delay
1759 setTimeout(function() {
1760 var style = {
1761 'top': relativeY+'px',
1762 'left': relativeX+'px',
1763 'opacity': '0',
1764
1765 // Duration
1766 '-webkit-transition-duration': Effect.duration + 'ms',
1767 '-moz-transition-duration': Effect.duration + 'ms',
1768 '-o-transition-duration': Effect.duration + 'ms',
1769 'transition-duration': Effect.duration + 'ms',
1770 '-webkit-transform': scale,
1771 '-moz-transform': scale,
1772 '-ms-transform': scale,
1773 '-o-transform': scale,
1774 'transform': scale,
1775 };
1776
1777 ripple.setAttribute('style', convertStyle(style));
1778
1779 setTimeout(function() {
1780 try {
1781 el.removeChild(ripple);
1782 } catch(e) {
1783 return false;
1784 }
1785 }, Effect.duration);
1786 }, delay);
1787 },
1788
1789 // Little hack to make <input> can perform waves effect
1790 wrapInput: function(elements) {
1791 for (var a = 0; a < elements.length; a++) {
1792 var el = elements[a];
1793
1794 if (el.tagName.toLowerCase() === 'input') {
1795 var parent = el.parentNode;
1796
1797 // If input already have parent just pass through
1798 if (parent.tagName.toLowerCase() === 'i' && parent.className.indexOf('waves-effect') !== -1) {
1799 continue;
1800 }
1801
1802 // Put element class and style to the specified parent
1803 var wrapper = document.createElement('i');
1804 wrapper.className = el.className + ' waves-input-wrapper';
1805
1806 var elementStyle = el.getAttribute('style');
1807
1808 if (!elementStyle) {
1809 elementStyle = '';
1810 }
1811
1812 wrapper.setAttribute('style', elementStyle);
1813
1814 el.className = 'waves-button-input';
1815 el.removeAttribute('style');
1816
1817 // Put element as child
1818 parent.replaceChild(wrapper, el);
1819 wrapper.appendChild(el);
1820 }
1821 }
1822 }
1823 };
1824
1825
1826 /**
1827 * Disable mousedown event for 500ms during and after touch
1828 */
1829 var TouchHandler = {
1830 /* uses an integer rather than bool so there's no issues with
1831 * needing to clear timeouts if another touch event occurred
1832 * within the 500ms. Cannot mouseup between touchstart and
1833 * touchend, nor in the 500ms after touchend. */
1834 touches: 0,
1835 allowEvent: function(e) {
1836 var allow = true;
1837
1838 if (e.type === 'touchstart') {
1839 TouchHandler.touches += 1; //push
1840 } else if (e.type === 'touchend' || e.type === 'touchcancel') {
1841 setTimeout(function() {
1842 if (TouchHandler.touches > 0) {
1843 TouchHandler.touches -= 1; //pop after 500ms
1844 }
1845 }, 500);
1846 } else if (e.type === 'mousedown' && TouchHandler.touches > 0) {
1847 allow = false;
1848 }
1849
1850 return allow;
1851 },
1852 touchup: function(e) {
1853 TouchHandler.allowEvent(e);
1854 }
1855 };
1856
1857
1858 /**
1859 * Delegated click handler for .waves-effect element.
1860 * returns null when .waves-effect element not in "click tree"
1861 */
1862 function getWavesEffectElement(e) {
1863 if (TouchHandler.allowEvent(e) === false) {
1864 return null;
1865 }
1866
1867 var element = null;
1868 var target = e.target || e.srcElement;
1869
1870 while (target.parentElement !== null) {
1871 if (!(target instanceof SVGElement) && target.className.indexOf('waves-effect') !== -1) {
1872 element = target;
1873 break;
1874 } else if (target.classList.contains('waves-effect')) {
1875 element = target;
1876 break;
1877 }
1878 target = target.parentElement;
1879 }
1880
1881 return element;
1882 }
1883
1884 /**
1885 * Bubble the click and show effect if .waves-effect elem was found
1886 */
1887 function showEffect(e) {
1888 var element = getWavesEffectElement(e);
1889
1890 if (element !== null) {
1891 Effect.show(e, element);
1892
1893 if ('ontouchstart' in window) {
1894 element.addEventListener('touchend', Effect.hide, false);
1895 element.addEventListener('touchcancel', Effect.hide, false);
1896 }
1897
1898 element.addEventListener('mouseup', Effect.hide, false);
1899 element.addEventListener('mouseleave', Effect.hide, false);
1900 }
1901 }
1902
1903 Waves.displayEffect = function(options) {
1904 options = options || {};
1905
1906 if ('duration' in options) {
1907 Effect.duration = options.duration;
1908 }
1909
1910 //Wrap input inside <i> tag
1911 Effect.wrapInput($$('.waves-effect'));
1912
1913 if ('ontouchstart' in window) {
1914 document.body.addEventListener('touchstart', showEffect, false);
1915 }
1916
1917 document.body.addEventListener('mousedown', showEffect, false);
1918 };
1919
1920 /**
1921 * Attach Waves to an input element (or any element which doesn't
1922 * bubble mouseup/mousedown events).
1923 * Intended to be used with dynamically loaded forms/inputs, or
1924 * where the user doesn't want a delegated click handler.
1925 */
1926 Waves.attach = function(element) {
1927 //FUTURE: automatically add waves classes and allow users
1928 // to specify them with an options param? Eg. light/classic/button
1929 if (element.tagName.toLowerCase() === 'input') {
1930 Effect.wrapInput([element]);
1931 element = element.parentElement;
1932 }
1933
1934 if ('ontouchstart' in window) {
1935 element.addEventListener('touchstart', showEffect, false);
1936 }
1937
1938 element.addEventListener('mousedown', showEffect, false);
1939 };
1940
1941 window.Waves = Waves;
1942
1943 document.addEventListener('DOMContentLoaded', function() {
1944 Waves.displayEffect();
1945 }, false);
1946
1947})(window);
1948;Materialize.toast = function (message, displayLength, className, completeCallback) {
1949 className = className || "";
1950
1951 var container = document.getElementById('toast-container');
1952
1953 // Create toast container if it does not exist
1954 if (container === null) {
1955 // create notification container
1956 container = document.createElement('div');
1957 container.id = 'toast-container';
1958 document.body.appendChild(container);
1959 }
1960
1961 // Select and append toast
1962 var newToast = createToast(message);
1963
1964 // only append toast if message is not undefined
1965 if(message){
1966 container.appendChild(newToast);
1967 }
1968
1969 newToast.style.top = '35px';
1970 newToast.style.opacity = 0;
1971
1972 // Animate toast in
1973 Vel(newToast, { "top" : "0px", opacity: 1 }, {duration: 300,
1974 easing: 'easeOutCubic',
1975 queue: false});
1976
1977 // Allows timer to be pause while being panned
1978 var timeLeft = displayLength;
1979 var counterInterval = setInterval (function(){
1980
1981
1982 if (newToast.parentNode === null)
1983 window.clearInterval(counterInterval);
1984
1985 // If toast is not being dragged, decrease its time remaining
1986 if (!newToast.classList.contains('panning')) {
1987 timeLeft -= 20;
1988 }
1989
1990 if (timeLeft <= 0) {
1991 // Animate toast out
1992 Vel(newToast, {"opacity": 0, marginTop: '-40px'}, { duration: 375,
1993 easing: 'easeOutExpo',
1994 queue: false,
1995 complete: function(){
1996 // Call the optional callback
1997 if(typeof(completeCallback) === "function")
1998 completeCallback();
1999 // Remove toast after it times out
2000 this[0].parentNode.removeChild(this[0]);
2001 }
2002 });
2003 window.clearInterval(counterInterval);
2004 }
2005 }, 20);
2006
2007
2008
2009 function createToast(html) {
2010
2011 // Create toast
2012 var toast = document.createElement('div');
2013 toast.classList.add('toast');
2014 if (className) {
2015 var classes = className.split(' ');
2016
2017 for (var i = 0, count = classes.length; i < count; i++) {
2018 toast.classList.add(classes[i]);
2019 }
2020 }
2021 // If type of parameter is HTML Element
2022 if ( typeof HTMLElement === "object" ? html instanceof HTMLElement : html && typeof html === "object" && html !== null && html.nodeType === 1 && typeof html.nodeName==="string"
2023) {
2024 toast.appendChild(html);
2025 }
2026 else if (html instanceof jQuery) {
2027 // Check if it is jQuery object
2028 toast.appendChild(html[0]);
2029 }
2030 else {
2031 // Insert as text;
2032 toast.innerHTML = html;
2033 }
2034 // Bind hammer
2035 var hammerHandler = new Hammer(toast, {prevent_default: false});
2036 hammerHandler.on('pan', function(e) {
2037 var deltaX = e.deltaX;
2038 var activationDistance = 80;
2039
2040 // Change toast state
2041 if (!toast.classList.contains('panning')){
2042 toast.classList.add('panning');
2043 }
2044
2045 var opacityPercent = 1-Math.abs(deltaX / activationDistance);
2046 if (opacityPercent < 0)
2047 opacityPercent = 0;
2048
2049 Vel(toast, {left: deltaX, opacity: opacityPercent }, {duration: 50, queue: false, easing: 'easeOutQuad'});
2050
2051 });
2052
2053 hammerHandler.on('panend', function(e) {
2054 var deltaX = e.deltaX;
2055 var activationDistance = 80;
2056
2057 // If toast dragged past activation point
2058 if (Math.abs(deltaX) > activationDistance) {
2059 Vel(toast, {marginTop: '-40px'}, { duration: 375,
2060 easing: 'easeOutExpo',
2061 queue: false,
2062 complete: function(){
2063 if(typeof(completeCallback) === "function") {
2064 completeCallback();
2065 }
2066 toast.parentNode.removeChild(toast);
2067 }
2068 });
2069
2070 } else {
2071 toast.classList.remove('panning');
2072 // Put toast back into original position
2073 Vel(toast, { left: 0, opacity: 1 }, { duration: 300,
2074 easing: 'easeOutExpo',
2075 queue: false
2076 });
2077
2078 }
2079 });
2080
2081 return toast;
2082 }
2083};
2084;(function ($) {
2085
2086 var methods = {
2087 init : function(options) {
2088 var defaults = {
2089 menuWidth: 300,
2090 edge: 'left',
2091 closeOnClick: false
2092 };
2093 options = $.extend(defaults, options);
2094
2095 $(this).each(function(){
2096 var $this = $(this);
2097 var menu_id = $("#"+ $this.attr('data-activates'));
2098
2099 // Set to width
2100 if (options.menuWidth != 300) {
2101 menu_id.css('width', options.menuWidth);
2102 }
2103
2104 // Add Touch Area
2105 var dragTarget = $('<div class="drag-target"></div>');
2106 $('body').append(dragTarget);
2107
2108 if (options.edge == 'left') {
2109 menu_id.css('transform', 'translateX(-100%)');
2110 dragTarget.css({'left': 0}); // Add Touch Area
2111 }
2112 else {
2113 menu_id.addClass('right-aligned') // Change text-alignment to right
2114 .css('transform', 'translateX(100%)');
2115 dragTarget.css({'right': 0}); // Add Touch Area
2116 }
2117
2118 // If fixed sidenav, bring menu out
2119 if (menu_id.hasClass('fixed')) {
2120 if (window.innerWidth > 992) {
2121 menu_id.css('transform', 'translateX(0)');
2122 }
2123 }
2124
2125 // Window resize to reset on large screens fixed
2126 if (menu_id.hasClass('fixed')) {
2127 $(window).resize( function() {
2128 if (window.innerWidth > 992) {
2129 // Close menu if window is resized bigger than 992 and user has fixed sidenav
2130 if ($('#sidenav-overlay').length !== 0 && menuOut) {
2131 removeMenu(true);
2132 }
2133 else {
2134 // menu_id.removeAttr('style');
2135 menu_id.css('transform', 'translateX(0%)');
2136 // menu_id.css('width', options.menuWidth);
2137 }
2138 }
2139 else if (menuOut === false){
2140 if (options.edge === 'left') {
2141 menu_id.css('transform', 'translateX(-100%)');
2142 } else {
2143 menu_id.css('transform', 'translateX(100%)');
2144 }
2145
2146 }
2147
2148 });
2149 }
2150
2151 // if closeOnClick, then add close event for all a tags in side sideNav
2152 if (options.closeOnClick === true) {
2153 menu_id.on("click.itemclick", "a:not(.collapsible-header)", function(){
2154 removeMenu();
2155 });
2156 }
2157
2158 function removeMenu(restoreNav) {
2159 panning = false;
2160 menuOut = false;
2161 // Reenable scrolling
2162 $('body').css({
2163 overflow: '',
2164 width: ''
2165 });
2166
2167 $('#sidenav-overlay').velocity({opacity: 0}, {duration: 200,
2168 queue: false, easing: 'easeOutQuad',
2169 complete: function() {
2170 $(this).remove();
2171 } });
2172 if (options.edge === 'left') {
2173 // Reset phantom div
2174 dragTarget.css({width: '', right: '', left: '0'});
2175 menu_id.velocity(
2176 {'translateX': '-100%'},
2177 { duration: 200,
2178 queue: false,
2179 easing: 'easeOutCubic',
2180 complete: function() {
2181 if (restoreNav === true) {
2182 // Restore Fixed sidenav
2183 menu_id.removeAttr('style');
2184 menu_id.css('width', options.menuWidth);
2185 }
2186 }
2187
2188 });
2189 }
2190 else {
2191 // Reset phantom div
2192 dragTarget.css({width: '', right: '0', left: ''});
2193 menu_id.velocity(
2194 {'translateX': '100%'},
2195 { duration: 200,
2196 queue: false,
2197 easing: 'easeOutCubic',
2198 complete: function() {
2199 if (restoreNav === true) {
2200 // Restore Fixed sidenav
2201 menu_id.removeAttr('style');
2202 menu_id.css('width', options.menuWidth);
2203 }
2204 }
2205 });
2206 }
2207 }
2208
2209
2210
2211 // Touch Event
2212 var panning = false;
2213 var menuOut = false;
2214
2215 dragTarget.on('click', function(){
2216 if (menuOut) {
2217 removeMenu();
2218 }
2219 });
2220
2221 dragTarget.hammer({
2222 prevent_default: false
2223 }).bind('pan', function(e) {
2224
2225 if (e.gesture.pointerType == "touch") {
2226
2227 var direction = e.gesture.direction;
2228 var x = e.gesture.center.x;
2229 var y = e.gesture.center.y;
2230 var velocityX = e.gesture.velocityX;
2231
2232 // Disable Scrolling
2233 var $body = $('body');
2234 var oldWidth = $body.innerWidth();
2235 $body.css('overflow', 'hidden');
2236 $body.width(oldWidth);
2237
2238 // If overlay does not exist, create one and if it is clicked, close menu
2239 if ($('#sidenav-overlay').length === 0) {
2240 var overlay = $('<div id="sidenav-overlay"></div>');
2241 overlay.css('opacity', 0).click( function(){
2242 removeMenu();
2243 });
2244 $('body').append(overlay);
2245 }
2246
2247 // Keep within boundaries
2248 if (options.edge === 'left') {
2249 if (x > options.menuWidth) { x = options.menuWidth; }
2250 else if (x < 0) { x = 0; }
2251 }
2252
2253 if (options.edge === 'left') {
2254 // Left Direction
2255 if (x < (options.menuWidth / 2)) { menuOut = false; }
2256 // Right Direction
2257 else if (x >= (options.menuWidth / 2)) { menuOut = true; }
2258 menu_id.css('transform', 'translateX(' + (x - options.menuWidth) + 'px)');
2259 }
2260 else {
2261 // Left Direction
2262 if (x < (window.innerWidth - options.menuWidth / 2)) {
2263 menuOut = true;
2264 }
2265 // Right Direction
2266 else if (x >= (window.innerWidth - options.menuWidth / 2)) {
2267 menuOut = false;
2268 }
2269 var rightPos = (x - options.menuWidth / 2);
2270 if (rightPos < 0) {
2271 rightPos = 0;
2272 }
2273
2274 menu_id.css('transform', 'translateX(' + rightPos + 'px)');
2275 }
2276
2277
2278 // Percentage overlay
2279 var overlayPerc;
2280 if (options.edge === 'left') {
2281 overlayPerc = x / options.menuWidth;
2282 $('#sidenav-overlay').velocity({opacity: overlayPerc }, {duration: 10, queue: false, easing: 'easeOutQuad'});
2283 }
2284 else {
2285 overlayPerc = Math.abs((x - window.innerWidth) / options.menuWidth);
2286 $('#sidenav-overlay').velocity({opacity: overlayPerc }, {duration: 10, queue: false, easing: 'easeOutQuad'});
2287 }
2288 }
2289
2290 }).bind('panend', function(e) {
2291
2292 if (e.gesture.pointerType == "touch") {
2293 var velocityX = e.gesture.velocityX;
2294 var x = e.gesture.center.x;
2295 var leftPos = x - options.menuWidth;
2296 var rightPos = x - options.menuWidth / 2;
2297 if (leftPos > 0 ) {
2298 leftPos = 0;
2299 }
2300 if (rightPos < 0) {
2301 rightPos = 0;
2302 }
2303 panning = false;
2304
2305 if (options.edge === 'left') {
2306 // If velocityX <= 0.3 then the user is flinging the menu closed so ignore menuOut
2307 if ((menuOut && velocityX <= 0.3) || velocityX < -0.5) {
2308 // Return menu to open
2309 if (leftPos !== 0) {
2310 menu_id.velocity({'translateX': [0, leftPos]}, {duration: 300, queue: false, easing: 'easeOutQuad'});
2311 }
2312
2313 $('#sidenav-overlay').velocity({opacity: 1 }, {duration: 50, queue: false, easing: 'easeOutQuad'});
2314 dragTarget.css({width: '50%', right: 0, left: ''});
2315 menuOut = true;
2316 }
2317 else if (!menuOut || velocityX > 0.3) {
2318 // Enable Scrolling
2319 $('body').css({
2320 overflow: '',
2321 width: ''
2322 });
2323 // Slide menu closed
2324 menu_id.velocity({'translateX': [-1 * options.menuWidth - 10, leftPos]}, {duration: 200, queue: false, easing: 'easeOutQuad'});
2325 $('#sidenav-overlay').velocity({opacity: 0 }, {duration: 200, queue: false, easing: 'easeOutQuad',
2326 complete: function () {
2327 $(this).remove();
2328 }});
2329 dragTarget.css({width: '10px', right: '', left: 0});
2330 }
2331 }
2332 else {
2333 if ((menuOut && velocityX >= -0.3) || velocityX > 0.5) {
2334 // Return menu to open
2335 if (rightPos !== 0) {
2336 menu_id.velocity({'translateX': [0, rightPos]}, {duration: 300, queue: false, easing: 'easeOutQuad'});
2337 }
2338
2339 $('#sidenav-overlay').velocity({opacity: 1 }, {duration: 50, queue: false, easing: 'easeOutQuad'});
2340 dragTarget.css({width: '50%', right: '', left: 0});
2341 menuOut = true;
2342 }
2343 else if (!menuOut || velocityX < -0.3) {
2344 // Enable Scrolling
2345 $('body').css({
2346 overflow: '',
2347 width: ''
2348 });
2349
2350 // Slide menu closed
2351 menu_id.velocity({'translateX': [options.menuWidth + 10, rightPos]}, {duration: 200, queue: false, easing: 'easeOutQuad'});
2352 $('#sidenav-overlay').velocity({opacity: 0 }, {duration: 200, queue: false, easing: 'easeOutQuad',
2353 complete: function () {
2354 $(this).remove();
2355 }});
2356 dragTarget.css({width: '10px', right: 0, left: ''});
2357 }
2358 }
2359
2360 }
2361 });
2362
2363 $this.click(function() {
2364 if (menuOut === true) {
2365 menuOut = false;
2366 panning = false;
2367 removeMenu();
2368 }
2369 else {
2370
2371 // Disable Scrolling
2372 var $body = $('body');
2373 var oldWidth = $body.innerWidth();
2374 $body.css('overflow', 'hidden');
2375 $body.width(oldWidth);
2376
2377 // Push current drag target on top of DOM tree
2378 $('body').append(dragTarget);
2379
2380 if (options.edge === 'left') {
2381 dragTarget.css({width: '50%', right: 0, left: ''});
2382 menu_id.velocity({'translateX': [0, -1 * options.menuWidth]}, {duration: 300, queue: false, easing: 'easeOutQuad'});
2383 }
2384 else {
2385 dragTarget.css({width: '50%', right: '', left: 0});
2386 menu_id.velocity({'translateX': [0, options.menuWidth]}, {duration: 300, queue: false, easing: 'easeOutQuad'});
2387 }
2388
2389 var overlay = $('<div id="sidenav-overlay"></div>');
2390 overlay.css('opacity', 0)
2391 .click(function(){
2392 menuOut = false;
2393 panning = false;
2394 removeMenu();
2395 overlay.velocity({opacity: 0}, {duration: 300, queue: false, easing: 'easeOutQuad',
2396 complete: function() {
2397 $(this).remove();
2398 } });
2399
2400 });
2401 $('body').append(overlay);
2402 overlay.velocity({opacity: 1}, {duration: 300, queue: false, easing: 'easeOutQuad',
2403 complete: function () {
2404 menuOut = true;
2405 panning = false;
2406 }
2407 });
2408 }
2409
2410 return false;
2411 });
2412 });
2413
2414
2415 },
2416 show : function() {
2417 this.trigger('click');
2418 },
2419 hide : function() {
2420 $('#sidenav-overlay').trigger('click');
2421 }
2422 };
2423
2424
2425 $.fn.sideNav = function(methodOrOptions) {
2426 if ( methods[methodOrOptions] ) {
2427 return methods[ methodOrOptions ].apply( this, Array.prototype.slice.call( arguments, 1 ));
2428 } else if ( typeof methodOrOptions === 'object' || ! methodOrOptions ) {
2429 // Default to "init"
2430 return methods.init.apply( this, arguments );
2431 } else {
2432 $.error( 'Method ' + methodOrOptions + ' does not exist on jQuery.sideNav' );
2433 }
2434 }; // Plugin end
2435}( jQuery ));
2436;/**
2437 * Extend jquery with a scrollspy plugin.
2438 * This watches the window scroll and fires events when elements are scrolled into viewport.
2439 *
2440 * throttle() and getTime() taken from Underscore.js
2441 * https://github.com/jashkenas/underscore
2442 *
2443 * @author Copyright 2013 John Smart
2444 * @license https://raw.github.com/thesmart/jquery-scrollspy/master/LICENSE
2445 * @see https://github.com/thesmart
2446 * @version 0.1.2
2447 */
2448(function($) {
2449
2450 var jWindow = $(window);
2451 var elements = [];
2452 var elementsInView = [];
2453 var isSpying = false;
2454 var ticks = 0;
2455 var unique_id = 1;
2456 var offset = {
2457 top : 0,
2458 right : 0,
2459 bottom : 0,
2460 left : 0,
2461 }
2462
2463 /**
2464 * Find elements that are within the boundary
2465 * @param {number} top
2466 * @param {number} right
2467 * @param {number} bottom
2468 * @param {number} left
2469 * @return {jQuery} A collection of elements
2470 */
2471 function findElements(top, right, bottom, left) {
2472 var hits = $();
2473 $.each(elements, function(i, element) {
2474 if (element.height() > 0) {
2475 var elTop = element.offset().top,
2476 elLeft = element.offset().left,
2477 elRight = elLeft + element.width(),
2478 elBottom = elTop + element.height();
2479
2480 var isIntersect = !(elLeft > right ||
2481 elRight < left ||
2482 elTop > bottom ||
2483 elBottom < top);
2484
2485 if (isIntersect) {
2486 hits.push(element);
2487 }
2488 }
2489 });
2490
2491 return hits;
2492 }
2493
2494
2495 /**
2496 * Called when the user scrolls the window
2497 */
2498 function onScroll() {
2499 // unique tick id
2500 ++ticks;
2501
2502 // viewport rectangle
2503 var top = jWindow.scrollTop(),
2504 left = jWindow.scrollLeft(),
2505 right = left + jWindow.width(),
2506 bottom = top + jWindow.height();
2507
2508 // determine which elements are in view
2509// + 60 accounts for fixed nav
2510 var intersections = findElements(top+offset.top + 200, right+offset.right, bottom+offset.bottom, left+offset.left);
2511 $.each(intersections, function(i, element) {
2512
2513 var lastTick = element.data('scrollSpy:ticks');
2514 if (typeof lastTick != 'number') {
2515 // entered into view
2516 element.triggerHandler('scrollSpy:enter');
2517 }
2518
2519 // update tick id
2520 element.data('scrollSpy:ticks', ticks);
2521 });
2522
2523 // determine which elements are no longer in view
2524 $.each(elementsInView, function(i, element) {
2525 var lastTick = element.data('scrollSpy:ticks');
2526 if (typeof lastTick == 'number' && lastTick !== ticks) {
2527 // exited from view
2528 element.triggerHandler('scrollSpy:exit');
2529 element.data('scrollSpy:ticks', null);
2530 }
2531 });
2532
2533 // remember elements in view for next tick
2534 elementsInView = intersections;
2535 }
2536
2537 /**
2538 * Called when window is resized
2539 */
2540 function onWinSize() {
2541 jWindow.trigger('scrollSpy:winSize');
2542 }
2543
2544 /**
2545 * Get time in ms
2546 * @license https://raw.github.com/jashkenas/underscore/master/LICENSE
2547 * @type {function}
2548 * @return {number}
2549 */
2550 var getTime = (Date.now || function () {
2551 return new Date().getTime();
2552 });
2553
2554 /**
2555 * Returns a function, that, when invoked, will only be triggered at most once
2556 * during a given window of time. Normally, the throttled function will run
2557 * as much as it can, without ever going more than once per `wait` duration;
2558 * but if you'd like to disable the execution on the leading edge, pass
2559 * `{leading: false}`. To disable execution on the trailing edge, ditto.
2560 * @license https://raw.github.com/jashkenas/underscore/master/LICENSE
2561 * @param {function} func
2562 * @param {number} wait
2563 * @param {Object=} options
2564 * @returns {Function}
2565 */
2566 function throttle(func, wait, options) {
2567 var context, args, result;
2568 var timeout = null;
2569 var previous = 0;
2570 options || (options = {});
2571 var later = function () {
2572 previous = options.leading === false ? 0 : getTime();
2573 timeout = null;
2574 result = func.apply(context, args);
2575 context = args = null;
2576 };
2577 return function () {
2578 var now = getTime();
2579 if (!previous && options.leading === false) previous = now;
2580 var remaining = wait - (now - previous);
2581 context = this;
2582 args = arguments;
2583 if (remaining <= 0) {
2584 clearTimeout(timeout);
2585 timeout = null;
2586 previous = now;
2587 result = func.apply(context, args);
2588 context = args = null;
2589 } else if (!timeout && options.trailing !== false) {
2590 timeout = setTimeout(later, remaining);
2591 }
2592 return result;
2593 };
2594 };
2595
2596 /**
2597 * Enables ScrollSpy using a selector
2598 * @param {jQuery|string} selector The elements collection, or a selector
2599 * @param {Object=} options Optional.
2600 throttle : number -> scrollspy throttling. Default: 100 ms
2601 offsetTop : number -> offset from top. Default: 0
2602 offsetRight : number -> offset from right. Default: 0
2603 offsetBottom : number -> offset from bottom. Default: 0
2604 offsetLeft : number -> offset from left. Default: 0
2605 * @returns {jQuery}
2606 */
2607 $.scrollSpy = function(selector, options) {
2608 var defaults = {
2609 throttle: 100,
2610 scrollOffset: 200 // offset - 200 allows elements near bottom of page to scroll
2611 };
2612 options = $.extend(defaults, options);
2613
2614 var visible = [];
2615 selector = $(selector);
2616 selector.each(function(i, element) {
2617 elements.push($(element));
2618 $(element).data("scrollSpy:id", i);
2619 // Smooth scroll to section
2620 $('a[href="#' + $(element).attr('id') + '"]').click(function(e) {
2621 e.preventDefault();
2622 var offset = $(this.hash).offset().top + 1;
2623 $('html, body').animate({ scrollTop: offset - options.scrollOffset }, {duration: 400, queue: false, easing: 'easeOutCubic'});
2624 });
2625 });
2626
2627 offset.top = options.offsetTop || 0;
2628 offset.right = options.offsetRight || 0;
2629 offset.bottom = options.offsetBottom || 0;
2630 offset.left = options.offsetLeft || 0;
2631
2632 var throttledScroll = throttle(onScroll, options.throttle || 100);
2633 var readyScroll = function(){
2634 $(document).ready(throttledScroll);
2635 };
2636
2637 if (!isSpying) {
2638 jWindow.on('scroll', readyScroll);
2639 jWindow.on('resize', readyScroll);
2640 isSpying = true;
2641 }
2642
2643 // perform a scan once, after current execution context, and after dom is ready
2644 setTimeout(readyScroll, 0);
2645
2646
2647 selector.on('scrollSpy:enter', function() {
2648 visible = $.grep(visible, function(value) {
2649 return value.height() != 0;
2650 });
2651
2652 var $this = $(this);
2653
2654 if (visible[0]) {
2655 $('a[href="#' + visible[0].attr('id') + '"]').removeClass('active');
2656 if ($this.data('scrollSpy:id') < visible[0].data('scrollSpy:id')) {
2657 visible.unshift($(this));
2658 }
2659 else {
2660 visible.push($(this));
2661 }
2662 }
2663 else {
2664 visible.push($(this));
2665 }
2666
2667
2668 $('a[href="#' + visible[0].attr('id') + '"]').addClass('active');
2669 });
2670 selector.on('scrollSpy:exit', function() {
2671 visible = $.grep(visible, function(value) {
2672 return value.height() != 0;
2673 });
2674
2675 if (visible[0]) {
2676 $('a[href="#' + visible[0].attr('id') + '"]').removeClass('active');
2677 var $this = $(this);
2678 visible = $.grep(visible, function(value) {
2679 return value.attr('id') != $this.attr('id');
2680 });
2681 if (visible[0]) { // Check if empty
2682 $('a[href="#' + visible[0].attr('id') + '"]').addClass('active');
2683 }
2684 }
2685 });
2686
2687 return selector;
2688 };
2689
2690 /**
2691 * Listen for window resize events
2692 * @param {Object=} options Optional. Set { throttle: number } to change throttling. Default: 100 ms
2693 * @returns {jQuery} $(window)
2694 */
2695 $.winSizeSpy = function(options) {
2696 $.winSizeSpy = function() { return jWindow; }; // lock from multiple calls
2697 options = options || {
2698 throttle: 100
2699 };
2700 return jWindow.on('resize', throttle(onWinSize, options.throttle || 100));
2701 };
2702
2703 /**
2704 * Enables ScrollSpy on a collection of elements
2705 * e.g. $('.scrollSpy').scrollSpy()
2706 * @param {Object=} options Optional.
2707 throttle : number -> scrollspy throttling. Default: 100 ms
2708 offsetTop : number -> offset from top. Default: 0
2709 offsetRight : number -> offset from right. Default: 0
2710 offsetBottom : number -> offset from bottom. Default: 0
2711 offsetLeft : number -> offset from left. Default: 0
2712 * @returns {jQuery}
2713 */
2714 $.fn.scrollSpy = function(options) {
2715 return $.scrollSpy($(this), options);
2716 };
2717
2718})(jQuery);
2719;(function ($) {
2720 $(document).ready(function() {
2721
2722 // Function to update labels of text fields
2723 Materialize.updateTextFields = function() {
2724 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';
2725 $(input_selector).each(function(index, element) {
2726 if ($(element).val().length > 0 || element.autofocus ||$(this).attr('placeholder') !== undefined || $(element)[0].validity.badInput === true) {
2727 $(this).siblings('label').addClass('active');
2728 }
2729 else {
2730 $(this).siblings('label').removeClass('active');
2731 }
2732 });
2733 };
2734
2735 // Text based inputs
2736 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';
2737
2738 // Add active if form auto complete
2739 $(document).on('change', input_selector, function () {
2740 if($(this).val().length !== 0 || $(this).attr('placeholder') !== undefined) {
2741 $(this).siblings('label').addClass('active');
2742 }
2743 validate_field($(this));
2744 });
2745
2746 // Add active if input element has been pre-populated on document ready
2747 $(document).ready(function() {
2748 Materialize.updateTextFields();
2749 });
2750
2751 // HTML DOM FORM RESET handling
2752 $(document).on('reset', function(e) {
2753 var formReset = $(e.target);
2754 if (formReset.is('form')) {
2755 formReset.find(input_selector).removeClass('valid').removeClass('invalid');
2756 formReset.find(input_selector).each(function () {
2757 if ($(this).attr('value') === '') {
2758 $(this).siblings('label').removeClass('active');
2759 }
2760 });
2761
2762 // Reset select
2763 formReset.find('select.initialized').each(function () {
2764 var reset_text = formReset.find('option[selected]').text();
2765 formReset.siblings('input.select-dropdown').val(reset_text);
2766 });
2767 }
2768 });
2769
2770 // Add active when element has focus
2771 $(document).on('focus', input_selector, function () {
2772 $(this).siblings('label, .prefix').addClass('active');
2773 });
2774
2775 $(document).on('blur', input_selector, function () {
2776 var $inputElement = $(this);
2777 var selector = ".prefix";
2778
2779 if ($inputElement.val().length === 0 && $inputElement[0].validity.badInput !== true && $inputElement.attr('placeholder') === undefined) {
2780 selector += ", label";
2781 }
2782
2783 $inputElement.siblings(selector).removeClass('active');
2784
2785 validate_field($inputElement);
2786 });
2787
2788 window.validate_field = function(object) {
2789 var hasLength = object.attr('length') !== undefined;
2790 var lenAttr = parseInt(object.attr('length'));
2791 var len = object.val().length;
2792
2793 if (object.val().length === 0 && object[0].validity.badInput === false) {
2794 if (object.hasClass('validate')) {
2795 object.removeClass('valid');
2796 object.removeClass('invalid');
2797 }
2798 }
2799 else {
2800 if (object.hasClass('validate')) {
2801 // Check for character counter attributes
2802 if ((object.is(':valid') && hasLength && (len <= lenAttr)) || (object.is(':valid') && !hasLength)) {
2803 object.removeClass('invalid');
2804 object.addClass('valid');
2805 }
2806 else {
2807 object.removeClass('valid');
2808 object.addClass('invalid');
2809 }
2810 }
2811 }
2812 };
2813
2814 // Radio and Checkbox focus class
2815 var radio_checkbox = 'input[type=radio], input[type=checkbox]';
2816 $(document).on('keyup.radio', radio_checkbox, function(e) {
2817 // TAB, check if tabbing to radio or checkbox.
2818 if (e.which === 9) {
2819 $(this).addClass('tabbed');
2820 var $this = $(this);
2821 $this.one('blur', function(e) {
2822
2823 $(this).removeClass('tabbed');
2824 });
2825 return;
2826 }
2827 });
2828
2829 // Textarea Auto Resize
2830 var hiddenDiv = $('.hiddendiv').first();
2831 if (!hiddenDiv.length) {
2832 hiddenDiv = $('<div class="hiddendiv common"></div>');
2833 $('body').append(hiddenDiv);
2834 }
2835 var text_area_selector = '.materialize-textarea';
2836
2837 function textareaAutoResize($textarea) {
2838 // Set font properties of hiddenDiv
2839
2840 var fontFamily = $textarea.css('font-family');
2841 var fontSize = $textarea.css('font-size');
2842 var lineHeight = $textarea.css('line-height');
2843
2844 if (fontSize) { hiddenDiv.css('font-size', fontSize); }
2845 if (fontFamily) { hiddenDiv.css('font-family', fontFamily); }
2846 if (lineHeight) { hiddenDiv.css('line-height', lineHeight); }
2847
2848 if ($textarea.attr('wrap') === "off") {
2849 hiddenDiv.css('overflow-wrap', "normal")
2850 .css('white-space', "pre");
2851 }
2852
2853 hiddenDiv.text($textarea.val() + '\n');
2854 var content = hiddenDiv.html().replace(/\n/g, '<br>');
2855 hiddenDiv.html(content);
2856
2857
2858 // When textarea is hidden, width goes crazy.
2859 // Approximate with half of window size
2860
2861 if ($textarea.is(':visible')) {
2862 hiddenDiv.css('width', $textarea.width());
2863 }
2864 else {
2865 hiddenDiv.css('width', $(window).width()/2);
2866 }
2867
2868 $textarea.css('height', hiddenDiv.height());
2869 }
2870
2871 $(text_area_selector).each(function () {
2872 var $textarea = $(this);
2873 if ($textarea.val().length) {
2874 textareaAutoResize($textarea);
2875 }
2876 });
2877
2878 $('body').on('keyup keydown autoresize', text_area_selector, function () {
2879 textareaAutoResize($(this));
2880 });
2881
2882 // File Input Path
2883 $(document).on('change', '.file-field input[type="file"]', function () {
2884 var file_field = $(this).closest('.file-field');
2885 var path_input = file_field.find('input.file-path');
2886 var files = $(this)[0].files;
2887 var file_names = [];
2888 for (var i = 0; i < files.length; i++) {
2889 file_names.push(files[i].name);
2890 }
2891 path_input.val(file_names.join(", "));
2892 path_input.trigger('change');
2893 });
2894
2895 /****************
2896 * Range Input *
2897 ****************/
2898
2899 var range_type = 'input[type=range]';
2900 var range_mousedown = false;
2901 var left;
2902
2903 $(range_type).each(function () {
2904 var thumb = $('<span class="thumb"><span class="value"></span></span>');
2905 $(this).after(thumb);
2906 });
2907
2908 var range_wrapper = '.range-field';
2909 $(document).on('change', range_type, function(e) {
2910 var thumb = $(this).siblings('.thumb');
2911 thumb.find('.value').html($(this).val());
2912 });
2913
2914 $(document).on('input mousedown touchstart', range_type, function(e) {
2915 var thumb = $(this).siblings('.thumb');
2916 var width = $(this).outerWidth();
2917
2918 // If thumb indicator does not exist yet, create it
2919 if (thumb.length <= 0) {
2920 thumb = $('<span class="thumb"><span class="value"></span></span>');
2921 $(this).after(thumb);
2922 }
2923
2924 // Set indicator value
2925 thumb.find('.value').html($(this).val());
2926
2927 range_mousedown = true;
2928 $(this).addClass('active');
2929
2930 if (!thumb.hasClass('active')) {
2931 thumb.velocity({ height: "30px", width: "30px", top: "-20px", marginLeft: "-15px"}, { duration: 300, easing: 'easeOutExpo' });
2932 }
2933
2934 if (e.type !== 'input') {
2935 if(e.pageX === undefined || e.pageX === null){//mobile
2936 left = e.originalEvent.touches[0].pageX - $(this).offset().left;
2937 }
2938 else{ // desktop
2939 left = e.pageX - $(this).offset().left;
2940 }
2941 if (left < 0) {
2942 left = 0;
2943 }
2944 else if (left > width) {
2945 left = width;
2946 }
2947 thumb.addClass('active').css('left', left);
2948 }
2949
2950 thumb.find('.value').html($(this).val());
2951 });
2952
2953 $(document).on('mouseup touchend', range_wrapper, function() {
2954 range_mousedown = false;
2955 $(this).removeClass('active');
2956 });
2957
2958 $(document).on('mousemove touchmove', range_wrapper, function(e) {
2959 var thumb = $(this).children('.thumb');
2960 var left;
2961 if (range_mousedown) {
2962 if (!thumb.hasClass('active')) {
2963 thumb.velocity({ height: '30px', width: '30px', top: '-20px', marginLeft: '-15px'}, { duration: 300, easing: 'easeOutExpo' });
2964 }
2965 if (e.pageX === undefined || e.pageX === null) { //mobile
2966 left = e.originalEvent.touches[0].pageX - $(this).offset().left;
2967 }
2968 else{ // desktop
2969 left = e.pageX - $(this).offset().left;
2970 }
2971 var width = $(this).outerWidth();
2972
2973 if (left < 0) {
2974 left = 0;
2975 }
2976 else if (left > width) {
2977 left = width;
2978 }
2979 thumb.addClass('active').css('left', left);
2980 thumb.find('.value').html(thumb.siblings(range_type).val());
2981 }
2982 });
2983
2984 $(document).on('mouseout touchleave', range_wrapper, function() {
2985 if (!range_mousedown) {
2986
2987 var thumb = $(this).children('.thumb');
2988
2989 if (thumb.hasClass('active')) {
2990 thumb.velocity({ height: '0', width: '0', top: '10px', marginLeft: '-6px'}, { duration: 100 });
2991 }
2992 thumb.removeClass('active');
2993 }
2994 });
2995
2996 /**************************
2997 * Auto complete plugin *
2998 *************************/
2999 $.fn.autocomplete = function (options) {
3000 // Defaults
3001 var defaults = {
3002 data: {}
3003 };
3004
3005 options = $.extend(defaults, options);
3006
3007 return this.each(function() {
3008 var $input = $(this);
3009 var data = options.data,
3010 $inputDiv = $input.closest('.input-field'); // Div to append on
3011
3012 // Check if data isn't empty
3013 if (!$.isEmptyObject(data)) {
3014 // Create autocomplete element
3015 var $autocomplete = $('<ul class="autocomplete-content dropdown-content"></ul>');
3016
3017 // Append autocomplete element
3018 if ($inputDiv.length) {
3019 $inputDiv.append($autocomplete); // Set ul in body
3020 } else {
3021 $input.after($autocomplete);
3022 }
3023
3024 var highlight = function(string, $el) {
3025 var img = $el.find('img');
3026 var matchStart = $el.text().toLowerCase().indexOf("" + string.toLowerCase() + ""),
3027 matchEnd = matchStart + string.length - 1,
3028 beforeMatch = $el.text().slice(0, matchStart),
3029 matchText = $el.text().slice(matchStart, matchEnd + 1),
3030 afterMatch = $el.text().slice(matchEnd + 1);
3031 $el.html("<span>" + beforeMatch + "<span class='highlight'>" + matchText + "</span>" + afterMatch + "</span>");
3032 if (img.length) {
3033 $el.prepend(img);
3034 }
3035 };
3036
3037 // Perform search
3038 $input.on('keyup', function (e) {
3039 // Capture Enter
3040 if (e.which === 13) {
3041 $autocomplete.find('li').first().click();
3042 return;
3043 }
3044
3045 var val = $input.val().toLowerCase();
3046 $autocomplete.empty();
3047
3048 // Check if the input isn't empty
3049 if (val !== '') {
3050 for(var key in data) {
3051 if (data.hasOwnProperty(key) &&
3052 key.toLowerCase().indexOf(val) !== -1 &&
3053 key.toLowerCase() !== val) {
3054 var autocompleteOption = $('<li></li>');
3055 if(!!data[key]) {
3056 autocompleteOption.append('<img src="'+ data[key] +'" class="right circle"><span>'+ key +'</span>');
3057 } else {
3058 autocompleteOption.append('<span>'+ key +'</span>');
3059 }
3060 $autocomplete.append(autocompleteOption);
3061
3062 highlight(val, autocompleteOption);
3063 }
3064 }
3065 }
3066 });
3067
3068 // Set input value
3069 $autocomplete.on('click', 'li', function () {
3070 $input.val($(this).text().trim());
3071 $autocomplete.empty();
3072 });
3073 }
3074 });
3075 };
3076
3077 }); // End of $(document).ready
3078
3079 /*******************
3080 * Select Plugin *
3081 ******************/
3082 $.fn.material_select = function (callback) {
3083 $(this).each(function(){
3084 var $select = $(this);
3085
3086 if ($select.hasClass('browser-default')) {
3087 return; // Continue to next (return false breaks out of entire loop)
3088 }
3089
3090 var multiple = $select.attr('multiple') ? true : false,
3091 lastID = $select.data('select-id'); // Tear down structure if Select needs to be rebuilt
3092
3093 if (lastID) {
3094 $select.parent().find('span.caret').remove();
3095 $select.parent().find('input').remove();
3096
3097 $select.unwrap();
3098 $('ul#select-options-'+lastID).remove();
3099 }
3100
3101 // If destroying the select, remove the selelct-id and reset it to it's uninitialized state.
3102 if(callback === 'destroy') {
3103 $select.data('select-id', null).removeClass('initialized');
3104 return;
3105 }
3106
3107 var uniqueID = Materialize.guid();
3108 $select.data('select-id', uniqueID);
3109 var wrapper = $('<div class="select-wrapper"></div>');
3110 wrapper.addClass($select.attr('class'));
3111 var options = $('<ul id="select-options-' + uniqueID +'" class="dropdown-content select-dropdown ' + (multiple ? 'multiple-select-dropdown' : '') + '"></ul>'),
3112 selectChildren = $select.children('option, optgroup'),
3113 valuesSelected = [],
3114 optionsHover = false;
3115
3116 var label = $select.find('option:selected').html() || $select.find('option:first').html() || "";
3117
3118 // Function that renders and appends the option taking into
3119 // account type and possible image icon.
3120 var appendOptionWithIcon = function(select, option, type) {
3121 // Add disabled attr if disabled
3122 var disabledClass = (option.is(':disabled')) ? 'disabled ' : '';
3123 var optgroupClass = (type === 'optgroup-option') ? 'optgroup-option ' : '';
3124
3125 // add icons
3126 var icon_url = option.data('icon');
3127 var classes = option.attr('class');
3128 if (!!icon_url) {
3129 var classString = '';
3130 if (!!classes) classString = ' class="' + classes + '"';
3131
3132 // Check for multiple type.
3133 if (type === 'multiple') {
3134 options.append($('<li class="' + disabledClass + '"><img src="' + icon_url + '"' + classString + '><span><input type="checkbox"' + disabledClass + '/><label></label>' + option.html() + '</span></li>'));
3135 } else {
3136 options.append($('<li class="' + disabledClass + optgroupClass + '"><img src="' + icon_url + '"' + classString + '><span>' + option.html() + '</span></li>'));
3137 }
3138 return true;
3139 }
3140
3141 // Check for multiple type.
3142 if (type === 'multiple') {
3143 options.append($('<li class="' + disabledClass + '"><span><input type="checkbox"' + disabledClass + '/><label></label>' + option.html() + '</span></li>'));
3144 } else {
3145 options.append($('<li class="' + disabledClass + optgroupClass + '"><span>' + option.html() + '</span></li>'));
3146 }
3147 };
3148
3149 /* Create dropdown structure. */
3150 if (selectChildren.length) {
3151 selectChildren.each(function() {
3152 if ($(this).is('option')) {
3153 // Direct descendant option.
3154 if (multiple) {
3155 appendOptionWithIcon($select, $(this), 'multiple');
3156
3157 } else {
3158 appendOptionWithIcon($select, $(this));
3159 }
3160 } else if ($(this).is('optgroup')) {
3161 // Optgroup.
3162 var selectOptions = $(this).children('option');
3163 options.append($('<li class="optgroup"><span>' + $(this).attr('label') + '</span></li>'));
3164
3165 selectOptions.each(function() {
3166 appendOptionWithIcon($select, $(this), 'optgroup-option');
3167 });
3168 }
3169 });
3170 }
3171
3172 options.find('li:not(.optgroup)').each(function (i) {
3173 $(this).click(function (e) {
3174 // Check if option element is disabled
3175 if (!$(this).hasClass('disabled') && !$(this).hasClass('optgroup')) {
3176 var selected = true;
3177
3178 if (multiple) {
3179 $('input[type="checkbox"]', this).prop('checked', function(i, v) { return !v; });
3180 selected = toggleEntryFromArray(valuesSelected, $(this).index(), $select);
3181 $newSelect.trigger('focus');
3182 } else {
3183 options.find('li').removeClass('active');
3184 $(this).toggleClass('active');
3185 $newSelect.val($(this).text());
3186 }
3187
3188 activateOption(options, $(this));
3189 $select.find('option').eq(i).prop('selected', selected);
3190 // Trigger onchange() event
3191 $select.trigger('change');
3192 if (typeof callback !== 'undefined') callback();
3193 }
3194
3195 e.stopPropagation();
3196 });
3197 });
3198
3199 // Wrap Elements
3200 $select.wrap(wrapper);
3201 // Add Select Display Element
3202 var dropdownIcon = $('<span class="caret">▼</span>');
3203 if ($select.is(':disabled'))
3204 dropdownIcon.addClass('disabled');
3205
3206 // escape double quotes
3207 var sanitizedLabelHtml = label.replace(/"/g, '"');
3208
3209 var $newSelect = $('<input type="text" class="select-dropdown" readonly="true" ' + (($select.is(':disabled')) ? 'disabled' : '') + ' data-activates="select-options-' + uniqueID +'" value="'+ sanitizedLabelHtml +'"/>');
3210 $select.before($newSelect);
3211 $newSelect.before(dropdownIcon);
3212
3213 $newSelect.after(options);
3214 // Check if section element is disabled
3215 if (!$select.is(':disabled')) {
3216 $newSelect.dropdown({'hover': false, 'closeOnClick': false});
3217 }
3218
3219 // Copy tabindex
3220 if ($select.attr('tabindex')) {
3221 $($newSelect[0]).attr('tabindex', $select.attr('tabindex'));
3222 }
3223
3224 $select.addClass('initialized');
3225
3226 $newSelect.on({
3227 'focus': function (){
3228 if ($('ul.select-dropdown').not(options[0]).is(':visible')) {
3229 $('input.select-dropdown').trigger('close');
3230 }
3231 if (!options.is(':visible')) {
3232 $(this).trigger('open', ['focus']);
3233 var label = $(this).val();
3234 var selectedOption = options.find('li').filter(function() {
3235 return $(this).text().toLowerCase() === label.toLowerCase();
3236 })[0];
3237 activateOption(options, selectedOption);
3238 }
3239 },
3240 'click': function (e){
3241 e.stopPropagation();
3242 }
3243 });
3244
3245 $newSelect.on('blur', function() {
3246 if (!multiple) {
3247 $(this).trigger('close');
3248 }
3249 options.find('li.selected').removeClass('selected');
3250 });
3251
3252 options.hover(function() {
3253 optionsHover = true;
3254 }, function () {
3255 optionsHover = false;
3256 });
3257
3258 $(window).on({
3259 'click': function () {
3260 multiple && (optionsHover || $newSelect.trigger('close'));
3261 }
3262 });
3263
3264 // Add initial multiple selections.
3265 if (multiple) {
3266 $select.find("option:selected:not(:disabled)").each(function () {
3267 var index = $(this).index();
3268
3269 toggleEntryFromArray(valuesSelected, index, $select);
3270 options.find("li").eq(index).find(":checkbox").prop("checked", true);
3271 });
3272 }
3273
3274 // Make option as selected and scroll to selected position
3275 var activateOption = function(collection, newOption) {
3276 if (newOption) {
3277 collection.find('li.selected').removeClass('selected');
3278 var option = $(newOption);
3279 option.addClass('selected');
3280 options.scrollTo(option);
3281 }
3282 };
3283
3284 // Allow user to search by typing
3285 // this array is cleared after 1 second
3286 var filterQuery = [],
3287 onKeyDown = function(e){
3288 // TAB - switch to another input
3289 if(e.which == 9){
3290 $newSelect.trigger('close');
3291 return;
3292 }
3293
3294 // ARROW DOWN WHEN SELECT IS CLOSED - open select options
3295 if(e.which == 40 && !options.is(':visible')){
3296 $newSelect.trigger('open');
3297 return;
3298 }
3299
3300 // ENTER WHEN SELECT IS CLOSED - submit form
3301 if(e.which == 13 && !options.is(':visible')){
3302 return;
3303 }
3304
3305 e.preventDefault();
3306
3307 // CASE WHEN USER TYPE LETTERS
3308 var letter = String.fromCharCode(e.which).toLowerCase(),
3309 nonLetters = [9,13,27,38,40];
3310 if (letter && (nonLetters.indexOf(e.which) === -1)) {
3311 filterQuery.push(letter);
3312
3313 var string = filterQuery.join(''),
3314 newOption = options.find('li').filter(function() {
3315 return $(this).text().toLowerCase().indexOf(string) === 0;
3316 })[0];
3317
3318 if (newOption) {
3319 activateOption(options, newOption);
3320 }
3321 }
3322
3323 // ENTER - select option and close when select options are opened
3324 if (e.which == 13) {
3325 var activeOption = options.find('li.selected:not(.disabled)')[0];
3326 if(activeOption){
3327 $(activeOption).trigger('click');
3328 if (!multiple) {
3329 $newSelect.trigger('close');
3330 }
3331 }
3332 }
3333
3334 // ARROW DOWN - move to next not disabled option
3335 if (e.which == 40) {
3336 if (options.find('li.selected').length) {
3337 newOption = options.find('li.selected').next('li:not(.disabled)')[0];
3338 } else {
3339 newOption = options.find('li:not(.disabled)')[0];
3340 }
3341 activateOption(options, newOption);
3342 }
3343
3344 // ESC - close options
3345 if (e.which == 27) {
3346 $newSelect.trigger('close');
3347 }
3348
3349 // ARROW UP - move to previous not disabled option
3350 if (e.which == 38) {
3351 newOption = options.find('li.selected').prev('li:not(.disabled)')[0];
3352 if(newOption)
3353 activateOption(options, newOption);
3354 }
3355
3356 // Automaticaly clean filter query so user can search again by starting letters
3357 setTimeout(function(){ filterQuery = []; }, 1000);
3358 };
3359
3360 $newSelect.on('keydown', onKeyDown);
3361 });
3362
3363 function toggleEntryFromArray(entriesArray, entryIndex, select) {
3364 var index = entriesArray.indexOf(entryIndex),
3365 notAdded = index === -1;
3366
3367 if (notAdded) {
3368 entriesArray.push(entryIndex);
3369 } else {
3370 entriesArray.splice(index, 1);
3371 }
3372
3373 select.siblings('ul.dropdown-content').find('li').eq(entryIndex).toggleClass('active');
3374
3375 // use notAdded instead of true (to detect if the option is selected or not)
3376 select.find('option').eq(entryIndex).prop('selected', notAdded);
3377 setValueToInput(entriesArray, select);
3378
3379 return notAdded;
3380 }
3381
3382 function setValueToInput(entriesArray, select) {
3383 var value = '';
3384
3385 for (var i = 0, count = entriesArray.length; i < count; i++) {
3386 var text = select.find('option').eq(entriesArray[i]).text();
3387
3388 i === 0 ? value += text : value += ', ' + text;
3389 }
3390
3391 if (value === '') {
3392 value = select.find('option:disabled').eq(0).text();
3393 }
3394
3395 select.siblings('input.select-dropdown').val(value);
3396 }
3397 };
3398
3399}( jQuery ));
3400;(function ($) {
3401
3402 var methods = {
3403
3404 init : function(options) {
3405 var defaults = {
3406 indicators: true,
3407 height: 400,
3408 transition: 500,
3409 interval: 6000
3410 };
3411 options = $.extend(defaults, options);
3412
3413 return this.each(function() {
3414
3415 // For each slider, we want to keep track of
3416 // which slide is active and its associated content
3417 var $this = $(this);
3418 var $slider = $this.find('ul.slides').first();
3419 var $slides = $slider.find('> li');
3420 var $active_index = $slider.find('.active').index();
3421 var $active, $indicators, $interval;
3422 if ($active_index != -1) { $active = $slides.eq($active_index); }
3423
3424 // Transitions the caption depending on alignment
3425 function captionTransition(caption, duration) {
3426 if (caption.hasClass("center-align")) {
3427 caption.velocity({opacity: 0, translateY: -100}, {duration: duration, queue: false});
3428 }
3429 else if (caption.hasClass("right-align")) {
3430 caption.velocity({opacity: 0, translateX: 100}, {duration: duration, queue: false});
3431 }
3432 else if (caption.hasClass("left-align")) {
3433 caption.velocity({opacity: 0, translateX: -100}, {duration: duration, queue: false});
3434 }
3435 }
3436
3437 // This function will transition the slide to any index of the next slide
3438 function moveToSlide(index) {
3439 // Wrap around indices.
3440 if (index >= $slides.length) index = 0;
3441 else if (index < 0) index = $slides.length -1;
3442
3443 $active_index = $slider.find('.active').index();
3444
3445 // Only do if index changes
3446 if ($active_index != index) {
3447 $active = $slides.eq($active_index);
3448 $caption = $active.find('.caption');
3449
3450 $active.removeClass('active');
3451 $active.velocity({opacity: 0}, {duration: options.transition, queue: false, easing: 'easeOutQuad',
3452 complete: function() {
3453 $slides.not('.active').velocity({opacity: 0, translateX: 0, translateY: 0}, {duration: 0, queue: false});
3454 } });
3455 captionTransition($caption, options.transition);
3456
3457
3458 // Update indicators
3459 if (options.indicators) {
3460 $indicators.eq($active_index).removeClass('active');
3461 }
3462
3463 $slides.eq(index).velocity({opacity: 1}, {duration: options.transition, queue: false, easing: 'easeOutQuad'});
3464 $slides.eq(index).find('.caption').velocity({opacity: 1, translateX: 0, translateY: 0}, {duration: options.transition, delay: options.transition, queue: false, easing: 'easeOutQuad'});
3465 $slides.eq(index).addClass('active');
3466
3467
3468 // Update indicators
3469 if (options.indicators) {
3470 $indicators.eq(index).addClass('active');
3471 }
3472 }
3473 }
3474
3475 // Set height of slider
3476 // If fullscreen, do nothing
3477 if (!$this.hasClass('fullscreen')) {
3478 if (options.indicators) {
3479 // Add height if indicators are present
3480 $this.height(options.height + 40);
3481 }
3482 else {
3483 $this.height(options.height);
3484 }
3485 $slider.height(options.height);
3486 }
3487
3488
3489 // Set initial positions of captions
3490 $slides.find('.caption').each(function () {
3491 captionTransition($(this), 0);
3492 });
3493
3494 // Move img src into background-image
3495 $slides.find('img').each(function () {
3496 var placeholderBase64 = 'data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
3497 if ($(this).attr('src') !== placeholderBase64) {
3498 $(this).css('background-image', 'url(' + $(this).attr('src') + ')' );
3499 $(this).attr('src', placeholderBase64);
3500 }
3501 });
3502
3503 // dynamically add indicators
3504 if (options.indicators) {
3505 $indicators = $('<ul class="indicators"></ul>');
3506 $slides.each(function( index ) {
3507 var $indicator = $('<li class="indicator-item"></li>');
3508
3509 // Handle clicks on indicators
3510 $indicator.click(function () {
3511 var $parent = $slider.parent();
3512 var curr_index = $parent.find($(this)).index();
3513 moveToSlide(curr_index);
3514
3515 // reset interval
3516 clearInterval($interval);
3517 $interval = setInterval(
3518 function(){
3519 $active_index = $slider.find('.active').index();
3520 if ($slides.length == $active_index + 1) $active_index = 0; // loop to start
3521 else $active_index += 1;
3522
3523 moveToSlide($active_index);
3524
3525 }, options.transition + options.interval
3526 );
3527 });
3528 $indicators.append($indicator);
3529 });
3530 $this.append($indicators);
3531 $indicators = $this.find('ul.indicators').find('li.indicator-item');
3532 }
3533
3534 if ($active) {
3535 $active.show();
3536 }
3537 else {
3538 $slides.first().addClass('active').velocity({opacity: 1}, {duration: options.transition, queue: false, easing: 'easeOutQuad'});
3539
3540 $active_index = 0;
3541 $active = $slides.eq($active_index);
3542
3543 // Update indicators
3544 if (options.indicators) {
3545 $indicators.eq($active_index).addClass('active');
3546 }
3547 }
3548
3549 // Adjust height to current slide
3550 $active.find('img').each(function() {
3551 $active.find('.caption').velocity({opacity: 1, translateX: 0, translateY: 0}, {duration: options.transition, queue: false, easing: 'easeOutQuad'});
3552 });
3553
3554 // auto scroll
3555 $interval = setInterval(
3556 function(){
3557 $active_index = $slider.find('.active').index();
3558 moveToSlide($active_index + 1);
3559
3560 }, options.transition + options.interval
3561 );
3562
3563
3564 // HammerJS, Swipe navigation
3565
3566 // Touch Event
3567 var panning = false;
3568 var swipeLeft = false;
3569 var swipeRight = false;
3570
3571 $this.hammer({
3572 prevent_default: false
3573 }).bind('pan', function(e) {
3574 if (e.gesture.pointerType === "touch") {
3575
3576 // reset interval
3577 clearInterval($interval);
3578
3579 var direction = e.gesture.direction;
3580 var x = e.gesture.deltaX;
3581 var velocityX = e.gesture.velocityX;
3582
3583 $curr_slide = $slider.find('.active');
3584 $curr_slide.velocity({ translateX: x
3585 }, {duration: 50, queue: false, easing: 'easeOutQuad'});
3586
3587 // Swipe Left
3588 if (direction === 4 && (x > ($this.innerWidth() / 2) || velocityX < -0.65)) {
3589 swipeRight = true;
3590 }
3591 // Swipe Right
3592 else if (direction === 2 && (x < (-1 * $this.innerWidth() / 2) || velocityX > 0.65)) {
3593 swipeLeft = true;
3594 }
3595
3596 // Make Slide Behind active slide visible
3597 var next_slide;
3598 if (swipeLeft) {
3599 next_slide = $curr_slide.next();
3600 if (next_slide.length === 0) {
3601 next_slide = $slides.first();
3602 }
3603 next_slide.velocity({ opacity: 1
3604 }, {duration: 300, queue: false, easing: 'easeOutQuad'});
3605 }
3606 if (swipeRight) {
3607 next_slide = $curr_slide.prev();
3608 if (next_slide.length === 0) {
3609 next_slide = $slides.last();
3610 }
3611 next_slide.velocity({ opacity: 1
3612 }, {duration: 300, queue: false, easing: 'easeOutQuad'});
3613 }
3614
3615
3616 }
3617
3618 }).bind('panend', function(e) {
3619 if (e.gesture.pointerType === "touch") {
3620
3621 $curr_slide = $slider.find('.active');
3622 panning = false;
3623 curr_index = $slider.find('.active').index();
3624
3625 if (!swipeRight && !swipeLeft || $slides.length <=1) {
3626 // Return to original spot
3627 $curr_slide.velocity({ translateX: 0
3628 }, {duration: 300, queue: false, easing: 'easeOutQuad'});
3629 }
3630 else if (swipeLeft) {
3631 moveToSlide(curr_index + 1);
3632 $curr_slide.velocity({translateX: -1 * $this.innerWidth() }, {duration: 300, queue: false, easing: 'easeOutQuad',
3633 complete: function() {
3634 $curr_slide.velocity({opacity: 0, translateX: 0}, {duration: 0, queue: false});
3635 } });
3636 }
3637 else if (swipeRight) {
3638 moveToSlide(curr_index - 1);
3639 $curr_slide.velocity({translateX: $this.innerWidth() }, {duration: 300, queue: false, easing: 'easeOutQuad',
3640 complete: function() {
3641 $curr_slide.velocity({opacity: 0, translateX: 0}, {duration: 0, queue: false});
3642 } });
3643 }
3644 swipeLeft = false;
3645 swipeRight = false;
3646
3647 // Restart interval
3648 clearInterval($interval);
3649 $interval = setInterval(
3650 function(){
3651 $active_index = $slider.find('.active').index();
3652 if ($slides.length == $active_index + 1) $active_index = 0; // loop to start
3653 else $active_index += 1;
3654
3655 moveToSlide($active_index);
3656
3657 }, options.transition + options.interval
3658 );
3659 }
3660 });
3661
3662 $this.on('sliderPause', function() {
3663 clearInterval($interval);
3664 });
3665
3666 $this.on('sliderStart', function() {
3667 clearInterval($interval);
3668 $interval = setInterval(
3669 function(){
3670 $active_index = $slider.find('.active').index();
3671 if ($slides.length == $active_index + 1) $active_index = 0; // loop to start
3672 else $active_index += 1;
3673
3674 moveToSlide($active_index);
3675
3676 }, options.transition + options.interval
3677 );
3678 });
3679
3680 $this.on('sliderNext', function() {
3681 $active_index = $slider.find('.active').index();
3682 moveToSlide($active_index + 1);
3683 });
3684
3685 $this.on('sliderPrev', function() {
3686 $active_index = $slider.find('.active').index();
3687 moveToSlide($active_index - 1);
3688 });
3689
3690 });
3691
3692
3693
3694 },
3695 pause : function() {
3696 $(this).trigger('sliderPause');
3697 },
3698 start : function() {
3699 $(this).trigger('sliderStart');
3700 },
3701 next : function() {
3702 $(this).trigger('sliderNext');
3703 },
3704 prev : function() {
3705 $(this).trigger('sliderPrev');
3706 }
3707 };
3708
3709
3710 $.fn.slider = function(methodOrOptions) {
3711 if ( methods[methodOrOptions] ) {
3712 return methods[ methodOrOptions ].apply( this, Array.prototype.slice.call( arguments, 1 ));
3713 } else if ( typeof methodOrOptions === 'object' || ! methodOrOptions ) {
3714 // Default to "init"
3715 return methods.init.apply( this, arguments );
3716 } else {
3717 $.error( 'Method ' + methodOrOptions + ' does not exist on jQuery.tooltip' );
3718 }
3719 }; // Plugin end
3720}( jQuery ));
3721;(function ($) {
3722 $(document).ready(function() {
3723
3724 $(document).on('click.card', '.card', function (e) {
3725 if ($(this).find('> .card-reveal').length) {
3726 if ($(e.target).is($('.card-reveal .card-title')) || $(e.target).is($('.card-reveal .card-title i'))) {
3727 // Make Reveal animate down and display none
3728 $(this).find('.card-reveal').velocity(
3729 {translateY: 0}, {
3730 duration: 225,
3731 queue: false,
3732 easing: 'easeInOutQuad',
3733 complete: function() { $(this).css({ display: 'none'}); }
3734 }
3735 );
3736 }
3737 else if ($(e.target).is($('.card .activator')) ||
3738 $(e.target).is($('.card .activator i')) ) {
3739 $(e.target).closest('.card').css('overflow', 'hidden');
3740 $(this).find('.card-reveal').css({ display: 'block'}).velocity("stop", false).velocity({translateY: '-100%'}, {duration: 300, queue: false, easing: 'easeInOutQuad'});
3741 }
3742 }
3743 });
3744
3745 });
3746}( jQuery ));;(function ($) {
3747 var chipsHandleEvents = false;
3748 var materialChipsDefaults = {
3749 data: [],
3750 placeholder: '',
3751 secondaryPlaceholder: '',
3752 };
3753
3754 $(document).ready(function(){
3755 // Handle removal of static chips.
3756 $(document).on('click', '.chip .close', function(e){
3757 var $chips = $(this).closest('.chips');
3758 if ($chips.data('initialized')) {
3759 return;
3760 }
3761 $(this).closest('.chip').remove();
3762 });
3763 });
3764
3765 $.fn.material_chip = function (options) {
3766 var self = this;
3767 this.$el = $(this);
3768 this.$document = $(document);
3769 this.SELS = {
3770 CHIPS: '.chips',
3771 CHIP: '.chip',
3772 INPUT: 'input',
3773 DELETE: '.material-icons',
3774 SELECTED_CHIP: '.selected',
3775 };
3776
3777 if ('data' === options) {
3778 return this.$el.data('chips');
3779 }
3780
3781 if ('options' === options) {
3782 return this.$el.data('options');
3783 }
3784
3785 this.$el.data('options', $.extend({}, materialChipsDefaults, options));
3786
3787 // Initialize
3788 this.init = function() {
3789 var i = 0;
3790 var chips;
3791 self.$el.each(function(){
3792 var $chips = $(this);
3793 if ($chips.data('initialized')) {
3794 // Prevent double initialization.
3795 return;
3796 }
3797 var options = $chips.data('options');
3798 if (!options.data || !options.data instanceof Array) {
3799 options.data = [];
3800 }
3801 $chips.data('chips', options.data);
3802 $chips.data('index', i);
3803 $chips.data('initialized', true);
3804
3805 if (!$chips.hasClass(self.SELS.CHIPS)) {
3806 $chips.addClass('chips');
3807 }
3808
3809 self.chips($chips);
3810 i++;
3811 });
3812 };
3813
3814 this.handleEvents = function(){
3815 var SELS = self.SELS;
3816
3817 self.$document.on('click', SELS.CHIPS, function(e){
3818 $(e.target).find(SELS.INPUT).focus();
3819 });
3820
3821 self.$document.on('click', SELS.CHIP, function(e){
3822 $(SELS.CHIP).removeClass('selected');
3823 $(this).toggleClass('selected');
3824 });
3825
3826 self.$document.on('keydown', function(e){
3827 if ($(e.target).is('input, textarea')) {
3828 return;
3829 }
3830
3831 // delete
3832 var $chip = self.$document.find(SELS.CHIP + SELS.SELECTED_CHIP);
3833 var $chips = $chip.closest(SELS.CHIPS);
3834 var length = $chip.siblings(SELS.CHIP).length;
3835 var index;
3836
3837 if (!$chip.length) {
3838 return;
3839 }
3840
3841 if (e.which === 8 || e.which === 46) {
3842 e.preventDefault();
3843 var chipsIndex = $chips.data('index');
3844
3845 index = $chip.index();
3846 self.deleteChip(chipsIndex, index, $chips);
3847
3848 var selectIndex = null;
3849 if ((index + 1) < length) {
3850 selectIndex = index;
3851 } else if (index === length || (index + 1) === length) {
3852 selectIndex = length - 1;
3853 }
3854
3855 if (selectIndex < 0) selectIndex = null;
3856
3857 if (null !== selectIndex) {
3858 self.selectChip(chipsIndex, selectIndex, $chips);
3859 }
3860 if (!length) $chips.find('input').focus();
3861
3862 // left
3863 } else if (e.which === 37) {
3864 index = $chip.index() - 1;
3865 if (index < 0) {
3866 return;
3867 }
3868 $(SELS.CHIP).removeClass('selected');
3869 self.selectChip($chips.data('index'), index, $chips);
3870
3871 // right
3872 } else if (e.which === 39) {
3873 index = $chip.index() + 1;
3874 $(SELS.CHIP).removeClass('selected');
3875 if (index > length) {
3876 $chips.find('input').focus();
3877 return;
3878 }
3879 self.selectChip($chips.data('index'), index, $chips);
3880 }
3881 });
3882
3883 self.$document.on('focusin', SELS.CHIPS + ' ' + SELS.INPUT, function(e){
3884 $(e.target).closest(SELS.CHIPS).addClass('focus');
3885 $(SELS.CHIP).removeClass('selected');
3886 });
3887
3888 self.$document.on('focusout', SELS.CHIPS + ' ' + SELS.INPUT, function(e){
3889 $(e.target).closest(SELS.CHIPS).removeClass('focus');
3890 });
3891
3892 self.$document.on('keydown', SELS.CHIPS + ' ' + SELS.INPUT, function(e){
3893 var $target = $(e.target);
3894 var $chips = $target.closest(SELS.CHIPS);
3895 var chipsIndex = $chips.data('index');
3896 var chipsLength = $chips.children(SELS.CHIP).length;
3897
3898 // enter
3899 if (13 === e.which) {
3900 e.preventDefault();
3901 self.addChip(chipsIndex, {tag: $target.val()}, $chips);
3902 $target.val('');
3903 return;
3904 }
3905
3906 // delete or left
3907 if ((8 === e.keyCode || 37 === e.keyCode) && '' === $target.val() && chipsLength) {
3908 self.selectChip(chipsIndex, chipsLength - 1, $chips);
3909 $target.blur();
3910 return;
3911 }
3912 });
3913
3914 self.$document.on('click', SELS.CHIPS + ' ' + SELS.DELETE, function(e) {
3915 var $target = $(e.target);
3916 var $chips = $target.closest(SELS.CHIPS);
3917 var $chip = $target.closest(SELS.CHIP);
3918 e.stopPropagation();
3919 self.deleteChip(
3920 $chips.data('index'),
3921 $chip.index(),
3922 $chips
3923 );
3924 $chips.find('input').focus();
3925 });
3926 };
3927
3928 this.chips = function($chips) {
3929 var html = '';
3930 var options = $chips.data('options');
3931 $chips.data('chips').forEach(function(elem){
3932 html += self.renderChip(elem);
3933 });
3934 html += '<input class="input" placeholder="">';
3935 $chips.html(html);
3936 self.setPlaceholder($chips);
3937 };
3938
3939 this.renderChip = function(elem) {
3940 if (!elem.tag) return;
3941
3942 var html = '<div class="chip">' + elem.tag;
3943 if (elem.image) {
3944 html += ' <img src="' + elem.image + '"> ';
3945 }
3946 html += '<i class="material-icons close">close</i>';
3947 html += '</div>';
3948 return html;
3949 };
3950
3951 this.setPlaceholder = function($chips) {
3952 var options = $chips.data('options');
3953 if ($chips.data('chips').length && options.placeholder) {
3954 $chips.find('input').prop('placeholder', options.placeholder);
3955 } else if (!$chips.data('chips').length && options.secondaryPlaceholder) {
3956 $chips.find('input').prop('placeholder', options.secondaryPlaceholder);
3957 }
3958 };
3959
3960 this.isValid = function($chips, elem) {
3961 var chips = $chips.data('chips');
3962 var exists = false;
3963 for (var i=0; i < chips.length; i++) {
3964 if (chips[i].tag === elem.tag) {
3965 exists = true;
3966 return;
3967 }
3968 }
3969 return '' !== elem.tag && !exists;
3970 };
3971
3972 this.addChip = function(chipsIndex, elem, $chips) {
3973 if (!self.isValid($chips, elem)) {
3974 return;
3975 }
3976 var options = $chips.data('options');
3977 var chipHtml = self.renderChip(elem);
3978 $chips.data('chips').push(elem);
3979 $(chipHtml).insertBefore($chips.find('input'));
3980 $chips.trigger('chip.add', elem);
3981 self.setPlaceholder($chips);
3982 };
3983
3984 this.deleteChip = function(chipsIndex, chipIndex, $chips) {
3985 var chip = $chips.data('chips')[chipIndex];
3986 $chips.find('.chip').eq(chipIndex).remove();
3987 $chips.data('chips').splice(chipIndex, 1);
3988 $chips.trigger('chip.delete', chip);
3989 self.setPlaceholder($chips);
3990 };
3991
3992 this.selectChip = function(chipsIndex, chipIndex, $chips) {
3993 var $chip = $chips.find('.chip').eq(chipIndex);
3994 if ($chip && false === $chip.hasClass('selected')) {
3995 $chip.addClass('selected');
3996 $chips.trigger('chip.select', $chips.data('chips')[chipIndex]);
3997 }
3998 };
3999
4000 this.getChipsElement = function(index, $chips) {
4001 return $chips.eq(index);
4002 };
4003
4004 // init
4005 this.init();
4006
4007 if (!chipsHandleEvents) {
4008 this.handleEvents();
4009 chipsHandleEvents = true;
4010 }
4011 };
4012}( jQuery ));;(function ($) {
4013 $.fn.pushpin = function (options) {
4014 // Defaults
4015 var defaults = {
4016 top: 0,
4017 bottom: Infinity,
4018 offset: 0
4019 };
4020
4021 // Remove pushpin event and classes
4022 if (options === "remove") {
4023 this.each(function () {
4024 if (id = $(this).data('pushpin-id')) {
4025 $(window).off('scroll.' + id);
4026 $(this).removeData('pushpin-id').removeClass('pin-top pinned pin-bottom').removeAttr('style');
4027 }
4028 });
4029 return false;
4030 }
4031
4032 options = $.extend(defaults, options);
4033
4034
4035 $index = 0;
4036 return this.each(function() {
4037 var $uniqueId = Materialize.guid(),
4038 $this = $(this),
4039 $original_offset = $(this).offset().top;
4040
4041 function removePinClasses(object) {
4042 object.removeClass('pin-top');
4043 object.removeClass('pinned');
4044 object.removeClass('pin-bottom');
4045 }
4046
4047 function updateElements(objects, scrolled) {
4048 objects.each(function () {
4049 // Add position fixed (because its between top and bottom)
4050 if (options.top <= scrolled && options.bottom >= scrolled && !$(this).hasClass('pinned')) {
4051 removePinClasses($(this));
4052 $(this).css('top', options.offset);
4053 $(this).addClass('pinned');
4054 }
4055
4056 // Add pin-top (when scrolled position is above top)
4057 if (scrolled < options.top && !$(this).hasClass('pin-top')) {
4058 removePinClasses($(this));
4059 $(this).css('top', 0);
4060 $(this).addClass('pin-top');
4061 }
4062
4063 // Add pin-bottom (when scrolled position is below bottom)
4064 if (scrolled > options.bottom && !$(this).hasClass('pin-bottom')) {
4065 removePinClasses($(this));
4066 $(this).addClass('pin-bottom');
4067 $(this).css('top', options.bottom - $original_offset);
4068 }
4069 });
4070 }
4071
4072 $(this).data('pushpin-id', $uniqueId);
4073 updateElements($this, $(window).scrollTop());
4074 $(window).on('scroll.' + $uniqueId, function () {
4075 var $scrolled = $(window).scrollTop() + options.offset;
4076 updateElements($this, $scrolled);
4077 });
4078
4079 });
4080
4081 };
4082}( jQuery ));;(function ($) {
4083 $(document).ready(function() {
4084
4085 // jQuery reverse
4086 $.fn.reverse = [].reverse;
4087
4088 // Hover behaviour: make sure this doesn't work on .click-to-toggle FABs!
4089 $(document).on('mouseenter.fixedActionBtn', '.fixed-action-btn:not(.click-to-toggle)', function(e) {
4090 var $this = $(this);
4091 openFABMenu($this);
4092 });
4093 $(document).on('mouseleave.fixedActionBtn', '.fixed-action-btn:not(.click-to-toggle)', function(e) {
4094 var $this = $(this);
4095 closeFABMenu($this);
4096 });
4097
4098 // Toggle-on-click behaviour.
4099 $(document).on('click.fixedActionBtn', '.fixed-action-btn.click-to-toggle > a', function(e) {
4100 var $this = $(this);
4101 var $menu = $this.parent();
4102 if ($menu.hasClass('active')) {
4103 closeFABMenu($menu);
4104 } else {
4105 openFABMenu($menu);
4106 }
4107 });
4108
4109 });
4110
4111 $.fn.extend({
4112 openFAB: function() {
4113 openFABMenu($(this));
4114 },
4115 closeFAB: function() {
4116 closeFABMenu($(this));
4117 }
4118 });
4119
4120
4121 var openFABMenu = function (btn) {
4122 $this = btn;
4123 if ($this.hasClass('active') === false) {
4124
4125 // Get direction option
4126 var horizontal = $this.hasClass('horizontal');
4127 var offsetY, offsetX;
4128
4129 if (horizontal === true) {
4130 offsetX = 40;
4131 } else {
4132 offsetY = 40;
4133 }
4134
4135 $this.addClass('active');
4136 $this.find('ul .btn-floating').velocity(
4137 { scaleY: ".4", scaleX: ".4", translateY: offsetY + 'px', translateX: offsetX + 'px'},
4138 { duration: 0 });
4139
4140 var time = 0;
4141 $this.find('ul .btn-floating').reverse().each( function () {
4142 $(this).velocity(
4143 { opacity: "1", scaleX: "1", scaleY: "1", translateY: "0", translateX: '0'},
4144 { duration: 80, delay: time });
4145 time += 40;
4146 });
4147 }
4148 };
4149
4150 var closeFABMenu = function (btn) {
4151 $this = btn;
4152 // Get direction option
4153 var horizontal = $this.hasClass('horizontal');
4154 var offsetY, offsetX;
4155
4156 if (horizontal === true) {
4157 offsetX = 40;
4158 } else {
4159 offsetY = 40;
4160 }
4161
4162 $this.removeClass('active');
4163 var time = 0;
4164 $this.find('ul .btn-floating').velocity("stop", true);
4165 $this.find('ul .btn-floating').velocity(
4166 { opacity: "0", scaleX: ".4", scaleY: ".4", translateY: offsetY + 'px', translateX: offsetX + 'px'},
4167 { duration: 80 }
4168 );
4169 };
4170
4171
4172}( jQuery ));
4173;(function ($) {
4174 // Image transition function
4175 Materialize.fadeInImage = function(selectorOrEl) {
4176 var element;
4177 if (typeof(selectorOrEl) === 'string') {
4178 element = $(selectorOrEl);
4179 } else if (typeof(selectorOrEl) === 'object') {
4180 element = selectorOrEl;
4181 } else {
4182 return;
4183 }
4184 element.css({opacity: 0});
4185 $(element).velocity({opacity: 1}, {
4186 duration: 650,
4187 queue: false,
4188 easing: 'easeOutSine'
4189 });
4190 $(element).velocity({opacity: 1}, {
4191 duration: 1300,
4192 queue: false,
4193 easing: 'swing',
4194 step: function(now, fx) {
4195 fx.start = 100;
4196 var grayscale_setting = now/100;
4197 var brightness_setting = 150 - (100 - now)/1.75;
4198
4199 if (brightness_setting < 100) {
4200 brightness_setting = 100;
4201 }
4202 if (now >= 0) {
4203 $(this).css({
4204 "-webkit-filter": "grayscale("+grayscale_setting+")" + "brightness("+brightness_setting+"%)",
4205 "filter": "grayscale("+grayscale_setting+")" + "brightness("+brightness_setting+"%)"
4206 });
4207 }
4208 }
4209 });
4210 };
4211
4212 // Horizontal staggered list
4213 Materialize.showStaggeredList = function(selectorOrEl) {
4214 var element;
4215 if (typeof(selectorOrEl) === 'string') {
4216 element = $(selectorOrEl);
4217 } else if (typeof(selectorOrEl) === 'object') {
4218 element = selectorOrEl;
4219 } else {
4220 return;
4221 }
4222 var time = 0;
4223 element.find('li').velocity(
4224 { translateX: "-100px"},
4225 { duration: 0 });
4226
4227 element.find('li').each(function() {
4228 $(this).velocity(
4229 { opacity: "1", translateX: "0"},
4230 { duration: 800, delay: time, easing: [60, 10] });
4231 time += 120;
4232 });
4233 };
4234
4235
4236 $(document).ready(function() {
4237 // Hardcoded .staggered-list scrollFire
4238 // var staggeredListOptions = [];
4239 // $('ul.staggered-list').each(function (i) {
4240
4241 // var label = 'scrollFire-' + i;
4242 // $(this).addClass(label);
4243 // staggeredListOptions.push(
4244 // {selector: 'ul.staggered-list.' + label,
4245 // offset: 200,
4246 // callback: 'showStaggeredList("ul.staggered-list.' + label + '")'});
4247 // });
4248 // scrollFire(staggeredListOptions);
4249
4250 // HammerJS, Swipe navigation
4251
4252 // Touch Event
4253 var swipeLeft = false;
4254 var swipeRight = false;
4255
4256
4257 // Dismissible Collections
4258 $('.dismissable').each(function() {
4259 $(this).hammer({
4260 prevent_default: false
4261 }).bind('pan', function(e) {
4262 if (e.gesture.pointerType === "touch") {
4263 var $this = $(this);
4264 var direction = e.gesture.direction;
4265 var x = e.gesture.deltaX;
4266 var velocityX = e.gesture.velocityX;
4267
4268 $this.velocity({ translateX: x
4269 }, {duration: 50, queue: false, easing: 'easeOutQuad'});
4270
4271 // Swipe Left
4272 if (direction === 4 && (x > ($this.innerWidth() / 2) || velocityX < -0.75)) {
4273 swipeLeft = true;
4274 }
4275
4276 // Swipe Right
4277 if (direction === 2 && (x < (-1 * $this.innerWidth() / 2) || velocityX > 0.75)) {
4278 swipeRight = true;
4279 }
4280 }
4281 }).bind('panend', function(e) {
4282 // Reset if collection is moved back into original position
4283 if (Math.abs(e.gesture.deltaX) < ($(this).innerWidth() / 2)) {
4284 swipeRight = false;
4285 swipeLeft = false;
4286 }
4287
4288 if (e.gesture.pointerType === "touch") {
4289 var $this = $(this);
4290 if (swipeLeft || swipeRight) {
4291 var fullWidth;
4292 if (swipeLeft) { fullWidth = $this.innerWidth(); }
4293 else { fullWidth = -1 * $this.innerWidth(); }
4294
4295 $this.velocity({ translateX: fullWidth,
4296 }, {duration: 100, queue: false, easing: 'easeOutQuad', complete:
4297 function() {
4298 $this.css('border', 'none');
4299 $this.velocity({ height: 0, padding: 0,
4300 }, {duration: 200, queue: false, easing: 'easeOutQuad', complete:
4301 function() { $this.remove(); }
4302 });
4303 }
4304 });
4305 }
4306 else {
4307 $this.velocity({ translateX: 0,
4308 }, {duration: 100, queue: false, easing: 'easeOutQuad'});
4309 }
4310 swipeLeft = false;
4311 swipeRight = false;
4312 }
4313 });
4314
4315 });
4316
4317
4318 // time = 0
4319 // // Vertical Staggered list
4320 // $('ul.staggered-list.vertical li').velocity(
4321 // { translateY: "100px"},
4322 // { duration: 0 });
4323
4324 // $('ul.staggered-list.vertical li').each(function() {
4325 // $(this).velocity(
4326 // { opacity: "1", translateY: "0"},
4327 // { duration: 800, delay: time, easing: [60, 25] });
4328 // time += 120;
4329 // });
4330
4331 // // Fade in and Scale
4332 // $('.fade-in.scale').velocity(
4333 // { scaleX: .4, scaleY: .4, translateX: -600},
4334 // { duration: 0});
4335 // $('.fade-in').each(function() {
4336 // $(this).velocity(
4337 // { opacity: "1", scaleX: 1, scaleY: 1, translateX: 0},
4338 // { duration: 800, easing: [60, 10] });
4339 // });
4340 });
4341}( jQuery ));
4342;(function($) {
4343
4344 // Input: Array of JSON objects {selector, offset, callback}
4345
4346 Materialize.scrollFire = function(options) {
4347
4348 var didScroll = false;
4349
4350 window.addEventListener("scroll", function() {
4351 didScroll = true;
4352 });
4353
4354 // Rate limit to 100ms
4355 setInterval(function() {
4356 if(didScroll) {
4357 didScroll = false;
4358
4359 var windowScroll = window.pageYOffset + window.innerHeight;
4360
4361 for (var i = 0 ; i < options.length; i++) {
4362 // Get options from each line
4363 var value = options[i];
4364 var selector = value.selector,
4365 offset = value.offset,
4366 callback = value.callback;
4367
4368 var currentElement = document.querySelector(selector);
4369 if ( currentElement !== null) {
4370 var elementOffset = currentElement.getBoundingClientRect().top + window.pageYOffset;
4371
4372 if (windowScroll > (elementOffset + offset)) {
4373 if (value.done !== true) {
4374 if (typeof(callback) === 'function') {
4375 callback.call(this, currentElement);
4376 } else if (typeof(callback) === 'string') {
4377 var callbackFunc = new Function(callback);
4378 callbackFunc(currentElement);
4379 }
4380 value.done = true;
4381 }
4382 }
4383 }
4384 }
4385 }
4386 }, 100);
4387 };
4388
4389})(jQuery);
4390;/*!
4391 * pickadate.js v3.5.0, 2014/04/13
4392 * By Amsul, http://amsul.ca
4393 * Hosted on http://amsul.github.io/pickadate.js
4394 * Licensed under MIT
4395 */
4396
4397(function ( factory ) {
4398
4399 // AMD.
4400 if ( typeof define == 'function' && define.amd )
4401 define( 'picker', ['jquery'], factory )
4402
4403 // Node.js/browserify.
4404 else if ( typeof exports == 'object' )
4405 module.exports = factory( require('jquery') )
4406
4407 // Browser globals.
4408 else this.Picker = factory( jQuery )
4409
4410}(function( $ ) {
4411
4412var $window = $( window )
4413var $document = $( document )
4414var $html = $( document.documentElement )
4415
4416
4417/**
4418 * The picker constructor that creates a blank picker.
4419 */
4420function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) {
4421
4422 // If there’s no element, return the picker constructor.
4423 if ( !ELEMENT ) return PickerConstructor
4424
4425
4426 var
4427 IS_DEFAULT_THEME = false,
4428
4429
4430 // The state of the picker.
4431 STATE = {
4432 id: ELEMENT.id || 'P' + Math.abs( ~~(Math.random() * new Date()) )
4433 },
4434
4435
4436 // Merge the defaults and options passed.
4437 SETTINGS = COMPONENT ? $.extend( true, {}, COMPONENT.defaults, OPTIONS ) : OPTIONS || {},
4438
4439
4440 // Merge the default classes with the settings classes.
4441 CLASSES = $.extend( {}, PickerConstructor.klasses(), SETTINGS.klass ),
4442
4443
4444 // The element node wrapper into a jQuery object.
4445 $ELEMENT = $( ELEMENT ),
4446
4447
4448 // Pseudo picker constructor.
4449 PickerInstance = function() {
4450 return this.start()
4451 },
4452
4453
4454 // The picker prototype.
4455 P = PickerInstance.prototype = {
4456
4457 constructor: PickerInstance,
4458
4459 $node: $ELEMENT,
4460
4461
4462 /**
4463 * Initialize everything
4464 */
4465 start: function() {
4466
4467 // If it’s already started, do nothing.
4468 if ( STATE && STATE.start ) return P
4469
4470
4471 // Update the picker states.
4472 STATE.methods = {}
4473 STATE.start = true
4474 STATE.open = false
4475 STATE.type = ELEMENT.type
4476
4477
4478 // Confirm focus state, convert into text input to remove UA stylings,
4479 // and set as readonly to prevent keyboard popup.
4480 ELEMENT.autofocus = ELEMENT == getActiveElement()
4481 ELEMENT.readOnly = !SETTINGS.editable
4482 ELEMENT.id = ELEMENT.id || STATE.id
4483 if ( ELEMENT.type != 'text' ) {
4484 ELEMENT.type = 'text'
4485 }
4486
4487
4488 // Create a new picker component with the settings.
4489 P.component = new COMPONENT(P, SETTINGS)
4490
4491
4492 // Create the picker root with a holder and then prepare it.
4493 P.$root = $( PickerConstructor._.node('div', createWrappedComponent(), CLASSES.picker, 'id="' + ELEMENT.id + '_root" tabindex="0"') )
4494 prepareElementRoot()
4495
4496
4497 // If there’s a format for the hidden input element, create the element.
4498 if ( SETTINGS.formatSubmit ) {
4499 prepareElementHidden()
4500 }
4501
4502
4503 // Prepare the input element.
4504 prepareElement()
4505
4506
4507 // Insert the root as specified in the settings.
4508 if ( SETTINGS.container ) $( SETTINGS.container ).append( P.$root )
4509 else $ELEMENT.after( P.$root )
4510
4511
4512 // Bind the default component and settings events.
4513 P.on({
4514 start: P.component.onStart,
4515 render: P.component.onRender,
4516 stop: P.component.onStop,
4517 open: P.component.onOpen,
4518 close: P.component.onClose,
4519 set: P.component.onSet
4520 }).on({
4521 start: SETTINGS.onStart,
4522 render: SETTINGS.onRender,
4523 stop: SETTINGS.onStop,
4524 open: SETTINGS.onOpen,
4525 close: SETTINGS.onClose,
4526 set: SETTINGS.onSet
4527 })
4528
4529
4530 // Once we’re all set, check the theme in use.
4531 IS_DEFAULT_THEME = isUsingDefaultTheme( P.$root.children()[ 0 ] )
4532
4533
4534 // If the element has autofocus, open the picker.
4535 if ( ELEMENT.autofocus ) {
4536 P.open()
4537 }
4538
4539
4540 // Trigger queued the “start” and “render” events.
4541 return P.trigger( 'start' ).trigger( 'render' )
4542 }, //start
4543
4544
4545 /**
4546 * Render a new picker
4547 */
4548 render: function( entireComponent ) {
4549
4550 // Insert a new component holder in the root or box.
4551 if ( entireComponent ) P.$root.html( createWrappedComponent() )
4552 else P.$root.find( '.' + CLASSES.box ).html( P.component.nodes( STATE.open ) )
4553
4554 // Trigger the queued “render” events.
4555 return P.trigger( 'render' )
4556 }, //render
4557
4558
4559 /**
4560 * Destroy everything
4561 */
4562 stop: function() {
4563
4564 // If it’s already stopped, do nothing.
4565 if ( !STATE.start ) return P
4566
4567 // Then close the picker.
4568 P.close()
4569
4570 // Remove the hidden field.
4571 if ( P._hidden ) {
4572 P._hidden.parentNode.removeChild( P._hidden )
4573 }
4574
4575 // Remove the root.
4576 P.$root.remove()
4577
4578 // Remove the input class, remove the stored data, and unbind
4579 // the events (after a tick for IE - see `P.close`).
4580 $ELEMENT.removeClass( CLASSES.input ).removeData( NAME )
4581 setTimeout( function() {
4582 $ELEMENT.off( '.' + STATE.id )
4583 }, 0)
4584
4585 // Restore the element state
4586 ELEMENT.type = STATE.type
4587 ELEMENT.readOnly = false
4588
4589 // Trigger the queued “stop” events.
4590 P.trigger( 'stop' )
4591
4592 // Reset the picker states.
4593 STATE.methods = {}
4594 STATE.start = false
4595
4596 return P
4597 }, //stop
4598
4599
4600 /**
4601 * Open up the picker
4602 */
4603 open: function( dontGiveFocus ) {
4604
4605 // If it’s already open, do nothing.
4606 if ( STATE.open ) return P
4607
4608 // Add the “active” class.
4609 $ELEMENT.addClass( CLASSES.active )
4610 aria( ELEMENT, 'expanded', true )
4611
4612 // * A Firefox bug, when `html` has `overflow:hidden`, results in
4613 // killing transitions :(. So add the “opened” state on the next tick.
4614 // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=625289
4615 setTimeout( function() {
4616
4617 // Add the “opened” class to the picker root.
4618 P.$root.addClass( CLASSES.opened )
4619 aria( P.$root[0], 'hidden', false )
4620
4621 }, 0 )
4622
4623 // If we have to give focus, bind the element and doc events.
4624 if ( dontGiveFocus !== false ) {
4625
4626 // Set it as open.
4627 STATE.open = true
4628
4629 // Prevent the page from scrolling.
4630 if ( IS_DEFAULT_THEME ) {
4631 $html.
4632 css( 'overflow', 'hidden' ).
4633 css( 'padding-right', '+=' + getScrollbarWidth() )
4634 }
4635
4636 // Pass focus to the root element’s jQuery object.
4637 // * Workaround for iOS8 to bring the picker’s root into view.
4638 P.$root.eq(0).focus()
4639
4640 // Bind the document events.
4641 $document.on( 'click.' + STATE.id + ' focusin.' + STATE.id, function( event ) {
4642
4643 var target = event.target
4644
4645 // If the target of the event is not the element, close the picker picker.
4646 // * Don’t worry about clicks or focusins on the root because those don’t bubble up.
4647 // Also, for Firefox, a click on an `option` element bubbles up directly
4648 // to the doc. So make sure the target wasn't the doc.
4649 // * In Firefox stopPropagation() doesn’t prevent right-click events from bubbling,
4650 // which causes the picker to unexpectedly close when right-clicking it. So make
4651 // sure the event wasn’t a right-click.
4652 if ( target != ELEMENT && target != document && event.which != 3 ) {
4653
4654 // If the target was the holder that covers the screen,
4655 // keep the element focused to maintain tabindex.
4656 P.close( target === P.$root.children()[0] )
4657 }
4658
4659 }).on( 'keydown.' + STATE.id, function( event ) {
4660
4661 var
4662 // Get the keycode.
4663 keycode = event.keyCode,
4664
4665 // Translate that to a selection change.
4666 keycodeToMove = P.component.key[ keycode ],
4667
4668 // Grab the target.
4669 target = event.target
4670
4671
4672 // On escape, close the picker and give focus.
4673 if ( keycode == 27 ) {
4674 P.close( true )
4675 }
4676
4677
4678 // Check if there is a key movement or “enter” keypress on the element.
4679 else if ( target == P.$root[0] && ( keycodeToMove || keycode == 13 ) ) {
4680
4681 // Prevent the default action to stop page movement.
4682 event.preventDefault()
4683
4684 // Trigger the key movement action.
4685 if ( keycodeToMove ) {
4686 PickerConstructor._.trigger( P.component.key.go, P, [ PickerConstructor._.trigger( keycodeToMove ) ] )
4687 }
4688
4689 // On “enter”, if the highlighted item isn’t disabled, set the value and close.
4690 else if ( !P.$root.find( '.' + CLASSES.highlighted ).hasClass( CLASSES.disabled ) ) {
4691 P.set( 'select', P.component.item.highlight ).close()
4692 }
4693 }
4694
4695
4696 // If the target is within the root and “enter” is pressed,
4697 // prevent the default action and trigger a click on the target instead.
4698 else if ( $.contains( P.$root[0], target ) && keycode == 13 ) {
4699 event.preventDefault()
4700 target.click()
4701 }
4702 })
4703 }
4704
4705 // Trigger the queued “open” events.
4706 return P.trigger( 'open' )
4707 }, //open
4708
4709
4710 /**
4711 * Close the picker
4712 */
4713 close: function( giveFocus ) {
4714
4715 // If we need to give focus, do it before changing states.
4716 if ( giveFocus ) {
4717 // ....ah yes! It would’ve been incomplete without a crazy workaround for IE :|
4718 // The focus is triggered *after* the close has completed - causing it
4719 // to open again. So unbind and rebind the event at the next tick.
4720 P.$root.off( 'focus.toOpen' ).eq(0).focus()
4721 setTimeout( function() {
4722 P.$root.on( 'focus.toOpen', handleFocusToOpenEvent )
4723 }, 0 )
4724 }
4725
4726 // Remove the “active” class.
4727 $ELEMENT.removeClass( CLASSES.active )
4728 aria( ELEMENT, 'expanded', false )
4729
4730 // * A Firefox bug, when `html` has `overflow:hidden`, results in
4731 // killing transitions :(. So remove the “opened” state on the next tick.
4732 // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=625289
4733 setTimeout( function() {
4734
4735 // Remove the “opened” and “focused” class from the picker root.
4736 P.$root.removeClass( CLASSES.opened + ' ' + CLASSES.focused )
4737 aria( P.$root[0], 'hidden', true )
4738
4739 }, 0 )
4740
4741 // If it’s already closed, do nothing more.
4742 if ( !STATE.open ) return P
4743
4744 // Set it as closed.
4745 STATE.open = false
4746
4747 // Allow the page to scroll.
4748 if ( IS_DEFAULT_THEME ) {
4749 $html.
4750 css( 'overflow', '' ).
4751 css( 'padding-right', '-=' + getScrollbarWidth() )
4752 }
4753
4754 // Unbind the document events.
4755 $document.off( '.' + STATE.id )
4756
4757 // Trigger the queued “close” events.
4758 return P.trigger( 'close' )
4759 }, //close
4760
4761
4762 /**
4763 * Clear the values
4764 */
4765 clear: function( options ) {
4766 return P.set( 'clear', null, options )
4767 }, //clear
4768
4769
4770 /**
4771 * Set something
4772 */
4773 set: function( thing, value, options ) {
4774
4775 var thingItem, thingValue,
4776 thingIsObject = $.isPlainObject( thing ),
4777 thingObject = thingIsObject ? thing : {}
4778
4779 // Make sure we have usable options.
4780 options = thingIsObject && $.isPlainObject( value ) ? value : options || {}
4781
4782 if ( thing ) {
4783
4784 // If the thing isn’t an object, make it one.
4785 if ( !thingIsObject ) {
4786 thingObject[ thing ] = value
4787 }
4788
4789 // Go through the things of items to set.
4790 for ( thingItem in thingObject ) {
4791
4792 // Grab the value of the thing.
4793 thingValue = thingObject[ thingItem ]
4794
4795 // First, if the item exists and there’s a value, set it.
4796 if ( thingItem in P.component.item ) {
4797 if ( thingValue === undefined ) thingValue = null
4798 P.component.set( thingItem, thingValue, options )
4799 }
4800
4801 // Then, check to update the element value and broadcast a change.
4802 if ( thingItem == 'select' || thingItem == 'clear' ) {
4803 $ELEMENT.
4804 val( thingItem == 'clear' ? '' : P.get( thingItem, SETTINGS.format ) ).
4805 trigger( 'change' )
4806 }
4807 }
4808
4809 // Render a new picker.
4810 P.render()
4811 }
4812
4813 // When the method isn’t muted, trigger queued “set” events and pass the `thingObject`.
4814 return options.muted ? P : P.trigger( 'set', thingObject )
4815 }, //set
4816
4817
4818 /**
4819 * Get something
4820 */
4821 get: function( thing, format ) {
4822
4823 // Make sure there’s something to get.
4824 thing = thing || 'value'
4825
4826 // If a picker state exists, return that.
4827 if ( STATE[ thing ] != null ) {
4828 return STATE[ thing ]
4829 }
4830
4831 // Return the submission value, if that.
4832 if ( thing == 'valueSubmit' ) {
4833 if ( P._hidden ) {
4834 return P._hidden.value
4835 }
4836 thing = 'value'
4837 }
4838
4839 // Return the value, if that.
4840 if ( thing == 'value' ) {
4841 return ELEMENT.value
4842 }
4843
4844 // Check if a component item exists, return that.
4845 if ( thing in P.component.item ) {
4846 if ( typeof format == 'string' ) {
4847 var thingValue = P.component.get( thing )
4848 return thingValue ?
4849 PickerConstructor._.trigger(
4850 P.component.formats.toString,
4851 P.component,
4852 [ format, thingValue ]
4853 ) : ''
4854 }
4855 return P.component.get( thing )
4856 }
4857 }, //get
4858
4859
4860
4861 /**
4862 * Bind events on the things.
4863 */
4864 on: function( thing, method, internal ) {
4865
4866 var thingName, thingMethod,
4867 thingIsObject = $.isPlainObject( thing ),
4868 thingObject = thingIsObject ? thing : {}
4869
4870 if ( thing ) {
4871
4872 // If the thing isn’t an object, make it one.
4873 if ( !thingIsObject ) {
4874 thingObject[ thing ] = method
4875 }
4876
4877 // Go through the things to bind to.
4878 for ( thingName in thingObject ) {
4879
4880 // Grab the method of the thing.
4881 thingMethod = thingObject[ thingName ]
4882
4883 // If it was an internal binding, prefix it.
4884 if ( internal ) {
4885 thingName = '_' + thingName
4886 }
4887
4888 // Make sure the thing methods collection exists.
4889 STATE.methods[ thingName ] = STATE.methods[ thingName ] || []
4890
4891 // Add the method to the relative method collection.
4892 STATE.methods[ thingName ].push( thingMethod )
4893 }
4894 }
4895
4896 return P
4897 }, //on
4898
4899
4900
4901 /**
4902 * Unbind events on the things.
4903 */
4904 off: function() {
4905 var i, thingName,
4906 names = arguments;
4907 for ( i = 0, namesCount = names.length; i < namesCount; i += 1 ) {
4908 thingName = names[i]
4909 if ( thingName in STATE.methods ) {
4910 delete STATE.methods[thingName]
4911 }
4912 }
4913 return P
4914 },
4915
4916
4917 /**
4918 * Fire off method events.
4919 */
4920 trigger: function( name, data ) {
4921 var _trigger = function( name ) {
4922 var methodList = STATE.methods[ name ]
4923 if ( methodList ) {
4924 methodList.map( function( method ) {
4925 PickerConstructor._.trigger( method, P, [ data ] )
4926 })
4927 }
4928 }
4929 _trigger( '_' + name )
4930 _trigger( name )
4931 return P
4932 } //trigger
4933 } //PickerInstance.prototype
4934
4935
4936 /**
4937 * Wrap the picker holder components together.
4938 */
4939 function createWrappedComponent() {
4940
4941 // Create a picker wrapper holder
4942 return PickerConstructor._.node( 'div',
4943
4944 // Create a picker wrapper node
4945 PickerConstructor._.node( 'div',
4946
4947 // Create a picker frame
4948 PickerConstructor._.node( 'div',
4949
4950 // Create a picker box node
4951 PickerConstructor._.node( 'div',
4952
4953 // Create the components nodes.
4954 P.component.nodes( STATE.open ),
4955
4956 // The picker box class
4957 CLASSES.box
4958 ),
4959
4960 // Picker wrap class
4961 CLASSES.wrap
4962 ),
4963
4964 // Picker frame class
4965 CLASSES.frame
4966 ),
4967
4968 // Picker holder class
4969 CLASSES.holder
4970 ) //endreturn
4971 } //createWrappedComponent
4972
4973
4974
4975 /**
4976 * Prepare the input element with all bindings.
4977 */
4978 function prepareElement() {
4979
4980 $ELEMENT.
4981
4982 // Store the picker data by component name.
4983 data(NAME, P).
4984
4985 // Add the “input” class name.
4986 addClass(CLASSES.input).
4987
4988 // Remove the tabindex.
4989 attr('tabindex', -1).
4990
4991 // If there’s a `data-value`, update the value of the element.
4992 val( $ELEMENT.data('value') ?
4993 P.get('select', SETTINGS.format) :
4994 ELEMENT.value
4995 )
4996
4997
4998 // Only bind keydown events if the element isn’t editable.
4999 if ( !SETTINGS.editable ) {
5000
5001 $ELEMENT.
5002
5003 // On focus/click, focus onto the root to open it up.
5004 on( 'focus.' + STATE.id + ' click.' + STATE.id, function( event ) {
5005 event.preventDefault()
5006 P.$root.eq(0).focus()
5007 }).
5008
5009 // Handle keyboard event based on the picker being opened or not.
5010 on( 'keydown.' + STATE.id, handleKeydownEvent )
5011 }
5012
5013
5014 // Update the aria attributes.
5015 aria(ELEMENT, {
5016 haspopup: true,
5017 expanded: false,
5018 readonly: false,
5019 owns: ELEMENT.id + '_root'
5020 })
5021 }
5022
5023
5024 /**
5025 * Prepare the root picker element with all bindings.
5026 */
5027 function prepareElementRoot() {
5028
5029 P.$root.
5030
5031 on({
5032
5033 // For iOS8.
5034 keydown: handleKeydownEvent,
5035
5036 // When something within the root is focused, stop from bubbling
5037 // to the doc and remove the “focused” state from the root.
5038 focusin: function( event ) {
5039 P.$root.removeClass( CLASSES.focused )
5040 event.stopPropagation()
5041 },
5042
5043 // When something within the root holder is clicked, stop it
5044 // from bubbling to the doc.
5045 'mousedown click': function( event ) {
5046
5047 var target = event.target
5048
5049 // Make sure the target isn’t the root holder so it can bubble up.
5050 if ( target != P.$root.children()[ 0 ] ) {
5051
5052 event.stopPropagation()
5053
5054 // * For mousedown events, cancel the default action in order to
5055 // prevent cases where focus is shifted onto external elements
5056 // when using things like jQuery mobile or MagnificPopup (ref: #249 & #120).
5057 // Also, for Firefox, don’t prevent action on the `option` element.
5058 if ( event.type == 'mousedown' && !$( target ).is( 'input, select, textarea, button, option' )) {
5059
5060 event.preventDefault()
5061
5062 // Re-focus onto the root so that users can click away
5063 // from elements focused within the picker.
5064 P.$root.eq(0).focus()
5065 }
5066 }
5067 }
5068 }).
5069
5070 // Add/remove the “target” class on focus and blur.
5071 on({
5072 focus: function() {
5073 $ELEMENT.addClass( CLASSES.target )
5074 },
5075 blur: function() {
5076 $ELEMENT.removeClass( CLASSES.target )
5077 }
5078 }).
5079
5080 // Open the picker and adjust the root “focused” state
5081 on( 'focus.toOpen', handleFocusToOpenEvent ).
5082
5083 // If there’s a click on an actionable element, carry out the actions.
5084 on( 'click', '[data-pick], [data-nav], [data-clear], [data-close]', function() {
5085
5086 var $target = $( this ),
5087 targetData = $target.data(),
5088 targetDisabled = $target.hasClass( CLASSES.navDisabled ) || $target.hasClass( CLASSES.disabled ),
5089
5090 // * For IE, non-focusable elements can be active elements as well
5091 // (http://stackoverflow.com/a/2684561).
5092 activeElement = getActiveElement()
5093 activeElement = activeElement && ( activeElement.type || activeElement.href )
5094
5095 // If it’s disabled or nothing inside is actively focused, re-focus the element.
5096 if ( targetDisabled || activeElement && !$.contains( P.$root[0], activeElement ) ) {
5097 P.$root.eq(0).focus()
5098 }
5099
5100 // If something is superficially changed, update the `highlight` based on the `nav`.
5101 if ( !targetDisabled && targetData.nav ) {
5102 P.set( 'highlight', P.component.item.highlight, { nav: targetData.nav } )
5103 }
5104
5105 // If something is picked, set `select` then close with focus.
5106 else if ( !targetDisabled && 'pick' in targetData ) {
5107 P.set( 'select', targetData.pick )
5108 }
5109
5110 // If a “clear” button is pressed, empty the values and close with focus.
5111 else if ( targetData.clear ) {
5112 P.clear().close( true )
5113 }
5114
5115 else if ( targetData.close ) {
5116 P.close( true )
5117 }
5118
5119 }) //P.$root
5120
5121 aria( P.$root[0], 'hidden', true )
5122 }
5123
5124
5125 /**
5126 * Prepare the hidden input element along with all bindings.
5127 */
5128 function prepareElementHidden() {
5129
5130 var name
5131
5132 if ( SETTINGS.hiddenName === true ) {
5133 name = ELEMENT.name
5134 ELEMENT.name = ''
5135 }
5136 else {
5137 name = [
5138 typeof SETTINGS.hiddenPrefix == 'string' ? SETTINGS.hiddenPrefix : '',
5139 typeof SETTINGS.hiddenSuffix == 'string' ? SETTINGS.hiddenSuffix : '_submit'
5140 ]
5141 name = name[0] + ELEMENT.name + name[1]
5142 }
5143
5144 P._hidden = $(
5145 '<input ' +
5146 'type=hidden ' +
5147
5148 // Create the name using the original input’s with a prefix and suffix.
5149 'name="' + name + '"' +
5150
5151 // If the element has a value, set the hidden value as well.
5152 (
5153 $ELEMENT.data('value') || ELEMENT.value ?
5154 ' value="' + P.get('select', SETTINGS.formatSubmit) + '"' :
5155 ''
5156 ) +
5157 '>'
5158 )[0]
5159
5160 $ELEMENT.
5161
5162 // If the value changes, update the hidden input with the correct format.
5163 on('change.' + STATE.id, function() {
5164 P._hidden.value = ELEMENT.value ?
5165 P.get('select', SETTINGS.formatSubmit) :
5166 ''
5167 })
5168
5169
5170 // Insert the hidden input as specified in the settings.
5171 if ( SETTINGS.container ) $( SETTINGS.container ).append( P._hidden )
5172 else $ELEMENT.after( P._hidden )
5173 }
5174
5175
5176 // For iOS8.
5177 function handleKeydownEvent( event ) {
5178
5179 var keycode = event.keyCode,
5180
5181 // Check if one of the delete keys was pressed.
5182 isKeycodeDelete = /^(8|46)$/.test(keycode)
5183
5184 // For some reason IE clears the input value on “escape”.
5185 if ( keycode == 27 ) {
5186 P.close()
5187 return false
5188 }
5189
5190 // Check if `space` or `delete` was pressed or the picker is closed with a key movement.
5191 if ( keycode == 32 || isKeycodeDelete || !STATE.open && P.component.key[keycode] ) {
5192
5193 // Prevent it from moving the page and bubbling to doc.
5194 event.preventDefault()
5195 event.stopPropagation()
5196
5197 // If `delete` was pressed, clear the values and close the picker.
5198 // Otherwise open the picker.
5199 if ( isKeycodeDelete ) { P.clear().close() }
5200 else { P.open() }
5201 }
5202 }
5203
5204
5205 // Separated for IE
5206 function handleFocusToOpenEvent( event ) {
5207
5208 // Stop the event from propagating to the doc.
5209 event.stopPropagation()
5210
5211 // If it’s a focus event, add the “focused” class to the root.
5212 if ( event.type == 'focus' ) {
5213 P.$root.addClass( CLASSES.focused )
5214 }
5215
5216 // And then finally open the picker.
5217 P.open()
5218 }
5219
5220
5221 // Return a new picker instance.
5222 return new PickerInstance()
5223} //PickerConstructor
5224
5225
5226
5227/**
5228 * The default classes and prefix to use for the HTML classes.
5229 */
5230PickerConstructor.klasses = function( prefix ) {
5231 prefix = prefix || 'picker'
5232 return {
5233
5234 picker: prefix,
5235 opened: prefix + '--opened',
5236 focused: prefix + '--focused',
5237
5238 input: prefix + '__input',
5239 active: prefix + '__input--active',
5240 target: prefix + '__input--target',
5241
5242 holder: prefix + '__holder',
5243
5244 frame: prefix + '__frame',
5245 wrap: prefix + '__wrap',
5246
5247 box: prefix + '__box'
5248 }
5249} //PickerConstructor.klasses
5250
5251
5252
5253/**
5254 * Check if the default theme is being used.
5255 */
5256function isUsingDefaultTheme( element ) {
5257
5258 var theme,
5259 prop = 'position'
5260
5261 // For IE.
5262 if ( element.currentStyle ) {
5263 theme = element.currentStyle[prop]
5264 }
5265
5266 // For normal browsers.
5267 else if ( window.getComputedStyle ) {
5268 theme = getComputedStyle( element )[prop]
5269 }
5270
5271 return theme == 'fixed'
5272}
5273
5274
5275
5276/**
5277 * Get the width of the browser’s scrollbar.
5278 * Taken from: https://github.com/VodkaBears/Remodal/blob/master/src/jquery.remodal.js
5279 */
5280function getScrollbarWidth() {
5281
5282 if ( $html.height() <= $window.height() ) {
5283 return 0
5284 }
5285
5286 var $outer = $( '<div style="visibility:hidden;width:100px" />' ).
5287 appendTo( 'body' )
5288
5289 // Get the width without scrollbars.
5290 var widthWithoutScroll = $outer[0].offsetWidth
5291
5292 // Force adding scrollbars.
5293 $outer.css( 'overflow', 'scroll' )
5294
5295 // Add the inner div.
5296 var $inner = $( '<div style="width:100%" />' ).appendTo( $outer )
5297
5298 // Get the width with scrollbars.
5299 var widthWithScroll = $inner[0].offsetWidth
5300
5301 // Remove the divs.
5302 $outer.remove()
5303
5304 // Return the difference between the widths.
5305 return widthWithoutScroll - widthWithScroll
5306}
5307
5308
5309
5310/**
5311 * PickerConstructor helper methods.
5312 */
5313PickerConstructor._ = {
5314
5315 /**
5316 * Create a group of nodes. Expects:
5317 * `
5318 {
5319 min: {Integer},
5320 max: {Integer},
5321 i: {Integer},
5322 node: {String},
5323 item: {Function}
5324 }
5325 * `
5326 */
5327 group: function( groupObject ) {
5328
5329 var
5330 // Scope for the looped object
5331 loopObjectScope,
5332
5333 // Create the nodes list
5334 nodesList = '',
5335
5336 // The counter starts from the `min`
5337 counter = PickerConstructor._.trigger( groupObject.min, groupObject )
5338
5339
5340 // Loop from the `min` to `max`, incrementing by `i`
5341 for ( ; counter <= PickerConstructor._.trigger( groupObject.max, groupObject, [ counter ] ); counter += groupObject.i ) {
5342
5343 // Trigger the `item` function within scope of the object
5344 loopObjectScope = PickerConstructor._.trigger( groupObject.item, groupObject, [ counter ] )
5345
5346 // Splice the subgroup and create nodes out of the sub nodes
5347 nodesList += PickerConstructor._.node(
5348 groupObject.node,
5349 loopObjectScope[ 0 ], // the node
5350 loopObjectScope[ 1 ], // the classes
5351 loopObjectScope[ 2 ] // the attributes
5352 )
5353 }
5354
5355 // Return the list of nodes
5356 return nodesList
5357 }, //group
5358
5359
5360 /**
5361 * Create a dom node string
5362 */
5363 node: function( wrapper, item, klass, attribute ) {
5364
5365 // If the item is false-y, just return an empty string
5366 if ( !item ) return ''
5367
5368 // If the item is an array, do a join
5369 item = $.isArray( item ) ? item.join( '' ) : item
5370
5371 // Check for the class
5372 klass = klass ? ' class="' + klass + '"' : ''
5373
5374 // Check for any attributes
5375 attribute = attribute ? ' ' + attribute : ''
5376
5377 // Return the wrapped item
5378 return '<' + wrapper + klass + attribute + '>' + item + '</' + wrapper + '>'
5379 }, //node
5380
5381
5382 /**
5383 * Lead numbers below 10 with a zero.
5384 */
5385 lead: function( number ) {
5386 return ( number < 10 ? '0': '' ) + number
5387 },
5388
5389
5390 /**
5391 * Trigger a function otherwise return the value.
5392 */
5393 trigger: function( callback, scope, args ) {
5394 return typeof callback == 'function' ? callback.apply( scope, args || [] ) : callback
5395 },
5396
5397
5398 /**
5399 * If the second character is a digit, length is 2 otherwise 1.
5400 */
5401 digits: function( string ) {
5402 return ( /\d/ ).test( string[ 1 ] ) ? 2 : 1
5403 },
5404
5405
5406 /**
5407 * Tell if something is a date object.
5408 */
5409 isDate: function( value ) {
5410 return {}.toString.call( value ).indexOf( 'Date' ) > -1 && this.isInteger( value.getDate() )
5411 },
5412
5413
5414 /**
5415 * Tell if something is an integer.
5416 */
5417 isInteger: function( value ) {
5418 return {}.toString.call( value ).indexOf( 'Number' ) > -1 && value % 1 === 0
5419 },
5420
5421
5422 /**
5423 * Create ARIA attribute strings.
5424 */
5425 ariaAttr: ariaAttr
5426} //PickerConstructor._
5427
5428
5429
5430/**
5431 * Extend the picker with a component and defaults.
5432 */
5433PickerConstructor.extend = function( name, Component ) {
5434
5435 // Extend jQuery.
5436 $.fn[ name ] = function( options, action ) {
5437
5438 // Grab the component data.
5439 var componentData = this.data( name )
5440
5441 // If the picker is requested, return the data object.
5442 if ( options == 'picker' ) {
5443 return componentData
5444 }
5445
5446 // If the component data exists and `options` is a string, carry out the action.
5447 if ( componentData && typeof options == 'string' ) {
5448 return PickerConstructor._.trigger( componentData[ options ], componentData, [ action ] )
5449 }
5450
5451 // Otherwise go through each matched element and if the component
5452 // doesn’t exist, create a new picker using `this` element
5453 // and merging the defaults and options with a deep copy.
5454 return this.each( function() {
5455 var $this = $( this )
5456 if ( !$this.data( name ) ) {
5457 new PickerConstructor( this, name, Component, options )
5458 }
5459 })
5460 }
5461
5462 // Set the defaults.
5463 $.fn[ name ].defaults = Component.defaults
5464} //PickerConstructor.extend
5465
5466
5467
5468function aria(element, attribute, value) {
5469 if ( $.isPlainObject(attribute) ) {
5470 for ( var key in attribute ) {
5471 ariaSet(element, key, attribute[key])
5472 }
5473 }
5474 else {
5475 ariaSet(element, attribute, value)
5476 }
5477}
5478function ariaSet(element, attribute, value) {
5479 element.setAttribute(
5480 (attribute == 'role' ? '' : 'aria-') + attribute,
5481 value
5482 )
5483}
5484function ariaAttr(attribute, data) {
5485 if ( !$.isPlainObject(attribute) ) {
5486 attribute = { attribute: data }
5487 }
5488 data = ''
5489 for ( var key in attribute ) {
5490 var attr = (key == 'role' ? '' : 'aria-') + key,
5491 attrVal = attribute[key]
5492 data += attrVal == null ? '' : attr + '="' + attribute[key] + '"'
5493 }
5494 return data
5495}
5496
5497// IE8 bug throws an error for activeElements within iframes.
5498function getActiveElement() {
5499 try {
5500 return document.activeElement
5501 } catch ( err ) { }
5502}
5503
5504
5505
5506// Expose the picker constructor.
5507return PickerConstructor
5508
5509
5510}));
5511
5512
5513;/*!
5514 * Date picker for pickadate.js v3.5.0
5515 * http://amsul.github.io/pickadate.js/date.htm
5516 */
5517
5518(function ( factory ) {
5519
5520 // AMD.
5521 if ( typeof define == 'function' && define.amd )
5522 define( ['picker', 'jquery'], factory )
5523
5524 // Node.js/browserify.
5525 else if ( typeof exports == 'object' )
5526 module.exports = factory( require('./picker.js'), require('jquery') )
5527
5528 // Browser globals.
5529 else factory( Picker, jQuery )
5530
5531}(function( Picker, $ ) {
5532
5533
5534/**
5535 * Globals and constants
5536 */
5537var DAYS_IN_WEEK = 7,
5538 WEEKS_IN_CALENDAR = 6,
5539 _ = Picker._
5540
5541
5542
5543/**
5544 * The date picker constructor
5545 */
5546function DatePicker( picker, settings ) {
5547
5548 var calendar = this,
5549 element = picker.$node[ 0 ],
5550 elementValue = element.value,
5551 elementDataValue = picker.$node.data( 'value' ),
5552 valueString = elementDataValue || elementValue,
5553 formatString = elementDataValue ? settings.formatSubmit : settings.format,
5554 isRTL = function() {
5555
5556 return element.currentStyle ?
5557
5558 // For IE.
5559 element.currentStyle.direction == 'rtl' :
5560
5561 // For normal browsers.
5562 getComputedStyle( picker.$root[0] ).direction == 'rtl'
5563 }
5564
5565 calendar.settings = settings
5566 calendar.$node = picker.$node
5567
5568 // The queue of methods that will be used to build item objects.
5569 calendar.queue = {
5570 min: 'measure create',
5571 max: 'measure create',
5572 now: 'now create',
5573 select: 'parse create validate',
5574 highlight: 'parse navigate create validate',
5575 view: 'parse create validate viewset',
5576 disable: 'deactivate',
5577 enable: 'activate'
5578 }
5579
5580 // The component's item object.
5581 calendar.item = {}
5582
5583 calendar.item.clear = null
5584 calendar.item.disable = ( settings.disable || [] ).slice( 0 )
5585 calendar.item.enable = -(function( collectionDisabled ) {
5586 return collectionDisabled[ 0 ] === true ? collectionDisabled.shift() : -1
5587 })( calendar.item.disable )
5588
5589 calendar.
5590 set( 'min', settings.min ).
5591 set( 'max', settings.max ).
5592 set( 'now' )
5593
5594 // When there’s a value, set the `select`, which in turn
5595 // also sets the `highlight` and `view`.
5596 if ( valueString ) {
5597 calendar.set( 'select', valueString, { format: formatString })
5598 }
5599
5600 // If there’s no value, default to highlighting “today”.
5601 else {
5602 calendar.
5603 set( 'select', null ).
5604 set( 'highlight', calendar.item.now )
5605 }
5606
5607
5608 // The keycode to movement mapping.
5609 calendar.key = {
5610 40: 7, // Down
5611 38: -7, // Up
5612 39: function() { return isRTL() ? -1 : 1 }, // Right
5613 37: function() { return isRTL() ? 1 : -1 }, // Left
5614 go: function( timeChange ) {
5615 var highlightedObject = calendar.item.highlight,
5616 targetDate = new Date( highlightedObject.year, highlightedObject.month, highlightedObject.date + timeChange )
5617 calendar.set(
5618 'highlight',
5619 targetDate,
5620 { interval: timeChange }
5621 )
5622 this.render()
5623 }
5624 }
5625
5626
5627 // Bind some picker events.
5628 picker.
5629 on( 'render', function() {
5630 picker.$root.find( '.' + settings.klass.selectMonth ).on( 'change', function() {
5631 var value = this.value
5632 if ( value ) {
5633 picker.set( 'highlight', [ picker.get( 'view' ).year, value, picker.get( 'highlight' ).date ] )
5634 picker.$root.find( '.' + settings.klass.selectMonth ).trigger( 'focus' )
5635 }
5636 })
5637 picker.$root.find( '.' + settings.klass.selectYear ).on( 'change', function() {
5638 var value = this.value
5639 if ( value ) {
5640 picker.set( 'highlight', [ value, picker.get( 'view' ).month, picker.get( 'highlight' ).date ] )
5641 picker.$root.find( '.' + settings.klass.selectYear ).trigger( 'focus' )
5642 }
5643 })
5644 }, 1 ).
5645 on( 'open', function() {
5646 var includeToday = ''
5647 if ( calendar.disabled( calendar.get('now') ) ) {
5648 includeToday = ':not(.' + settings.klass.buttonToday + ')'
5649 }
5650 picker.$root.find( 'button' + includeToday + ', select' ).attr( 'disabled', false )
5651 }, 1 ).
5652 on( 'close', function() {
5653 picker.$root.find( 'button, select' ).attr( 'disabled', true )
5654 }, 1 )
5655
5656} //DatePicker
5657
5658
5659/**
5660 * Set a datepicker item object.
5661 */
5662DatePicker.prototype.set = function( type, value, options ) {
5663
5664 var calendar = this,
5665 calendarItem = calendar.item
5666
5667 // If the value is `null` just set it immediately.
5668 if ( value === null ) {
5669 if ( type == 'clear' ) type = 'select'
5670 calendarItem[ type ] = value
5671 return calendar
5672 }
5673
5674 // Otherwise go through the queue of methods, and invoke the functions.
5675 // Update this as the time unit, and set the final value as this item.
5676 // * In the case of `enable`, keep the queue but set `disable` instead.
5677 // And in the case of `flip`, keep the queue but set `enable` instead.
5678 calendarItem[ ( type == 'enable' ? 'disable' : type == 'flip' ? 'enable' : type ) ] = calendar.queue[ type ].split( ' ' ).map( function( method ) {
5679 value = calendar[ method ]( type, value, options )
5680 return value
5681 }).pop()
5682
5683 // Check if we need to cascade through more updates.
5684 if ( type == 'select' ) {
5685 calendar.set( 'highlight', calendarItem.select, options )
5686 }
5687 else if ( type == 'highlight' ) {
5688 calendar.set( 'view', calendarItem.highlight, options )
5689 }
5690 else if ( type.match( /^(flip|min|max|disable|enable)$/ ) ) {
5691 if ( calendarItem.select && calendar.disabled( calendarItem.select ) ) {
5692 calendar.set( 'select', calendarItem.select, options )
5693 }
5694 if ( calendarItem.highlight && calendar.disabled( calendarItem.highlight ) ) {
5695 calendar.set( 'highlight', calendarItem.highlight, options )
5696 }
5697 }
5698
5699 return calendar
5700} //DatePicker.prototype.set
5701
5702
5703/**
5704 * Get a datepicker item object.
5705 */
5706DatePicker.prototype.get = function( type ) {
5707 return this.item[ type ]
5708} //DatePicker.prototype.get
5709
5710
5711/**
5712 * Create a picker date object.
5713 */
5714DatePicker.prototype.create = function( type, value, options ) {
5715
5716 var isInfiniteValue,
5717 calendar = this
5718
5719 // If there’s no value, use the type as the value.
5720 value = value === undefined ? type : value
5721
5722
5723 // If it’s infinity, update the value.
5724 if ( value == -Infinity || value == Infinity ) {
5725 isInfiniteValue = value
5726 }
5727
5728 // If it’s an object, use the native date object.
5729 else if ( $.isPlainObject( value ) && _.isInteger( value.pick ) ) {
5730 value = value.obj
5731 }
5732
5733 // If it’s an array, convert it into a date and make sure
5734 // that it’s a valid date – otherwise default to today.
5735 else if ( $.isArray( value ) ) {
5736 value = new Date( value[ 0 ], value[ 1 ], value[ 2 ] )
5737 value = _.isDate( value ) ? value : calendar.create().obj
5738 }
5739
5740 // If it’s a number or date object, make a normalized date.
5741 else if ( _.isInteger( value ) || _.isDate( value ) ) {
5742 value = calendar.normalize( new Date( value ), options )
5743 }
5744
5745 // If it’s a literal true or any other case, set it to now.
5746 else /*if ( value === true )*/ {
5747 value = calendar.now( type, value, options )
5748 }
5749
5750 // Return the compiled object.
5751 return {
5752 year: isInfiniteValue || value.getFullYear(),
5753 month: isInfiniteValue || value.getMonth(),
5754 date: isInfiniteValue || value.getDate(),
5755 day: isInfiniteValue || value.getDay(),
5756 obj: isInfiniteValue || value,
5757 pick: isInfiniteValue || value.getTime()
5758 }
5759} //DatePicker.prototype.create
5760
5761
5762/**
5763 * Create a range limit object using an array, date object,
5764 * literal “true”, or integer relative to another time.
5765 */
5766DatePicker.prototype.createRange = function( from, to ) {
5767
5768 var calendar = this,
5769 createDate = function( date ) {
5770 if ( date === true || $.isArray( date ) || _.isDate( date ) ) {
5771 return calendar.create( date )
5772 }
5773 return date
5774 }
5775
5776 // Create objects if possible.
5777 if ( !_.isInteger( from ) ) {
5778 from = createDate( from )
5779 }
5780 if ( !_.isInteger( to ) ) {
5781 to = createDate( to )
5782 }
5783
5784 // Create relative dates.
5785 if ( _.isInteger( from ) && $.isPlainObject( to ) ) {
5786 from = [ to.year, to.month, to.date + from ];
5787 }
5788 else if ( _.isInteger( to ) && $.isPlainObject( from ) ) {
5789 to = [ from.year, from.month, from.date + to ];
5790 }
5791
5792 return {
5793 from: createDate( from ),
5794 to: createDate( to )
5795 }
5796} //DatePicker.prototype.createRange
5797
5798
5799/**
5800 * Check if a date unit falls within a date range object.
5801 */
5802DatePicker.prototype.withinRange = function( range, dateUnit ) {
5803 range = this.createRange(range.from, range.to)
5804 return dateUnit.pick >= range.from.pick && dateUnit.pick <= range.to.pick
5805}
5806
5807
5808/**
5809 * Check if two date range objects overlap.
5810 */
5811DatePicker.prototype.overlapRanges = function( one, two ) {
5812
5813 var calendar = this
5814
5815 // Convert the ranges into comparable dates.
5816 one = calendar.createRange( one.from, one.to )
5817 two = calendar.createRange( two.from, two.to )
5818
5819 return calendar.withinRange( one, two.from ) || calendar.withinRange( one, two.to ) ||
5820 calendar.withinRange( two, one.from ) || calendar.withinRange( two, one.to )
5821}
5822
5823
5824/**
5825 * Get the date today.
5826 */
5827DatePicker.prototype.now = function( type, value, options ) {
5828 value = new Date()
5829 if ( options && options.rel ) {
5830 value.setDate( value.getDate() + options.rel )
5831 }
5832 return this.normalize( value, options )
5833}
5834
5835
5836/**
5837 * Navigate to next/prev month.
5838 */
5839DatePicker.prototype.navigate = function( type, value, options ) {
5840
5841 var targetDateObject,
5842 targetYear,
5843 targetMonth,
5844 targetDate,
5845 isTargetArray = $.isArray( value ),
5846 isTargetObject = $.isPlainObject( value ),
5847 viewsetObject = this.item.view/*,
5848 safety = 100*/
5849
5850
5851 if ( isTargetArray || isTargetObject ) {
5852
5853 if ( isTargetObject ) {
5854 targetYear = value.year
5855 targetMonth = value.month
5856 targetDate = value.date
5857 }
5858 else {
5859 targetYear = +value[0]
5860 targetMonth = +value[1]
5861 targetDate = +value[2]
5862 }
5863
5864 // If we’re navigating months but the view is in a different
5865 // month, navigate to the view’s year and month.
5866 if ( options && options.nav && viewsetObject && viewsetObject.month !== targetMonth ) {
5867 targetYear = viewsetObject.year
5868 targetMonth = viewsetObject.month
5869 }
5870
5871 // Figure out the expected target year and month.
5872 targetDateObject = new Date( targetYear, targetMonth + ( options && options.nav ? options.nav : 0 ), 1 )
5873 targetYear = targetDateObject.getFullYear()
5874 targetMonth = targetDateObject.getMonth()
5875
5876 // If the month we’re going to doesn’t have enough days,
5877 // keep decreasing the date until we reach the month’s last date.
5878 while ( /*safety &&*/ new Date( targetYear, targetMonth, targetDate ).getMonth() !== targetMonth ) {
5879 targetDate -= 1
5880 /*safety -= 1
5881 if ( !safety ) {
5882 throw 'Fell into an infinite loop while navigating to ' + new Date( targetYear, targetMonth, targetDate ) + '.'
5883 }*/
5884 }
5885
5886 value = [ targetYear, targetMonth, targetDate ]
5887 }
5888
5889 return value
5890} //DatePicker.prototype.navigate
5891
5892
5893/**
5894 * Normalize a date by setting the hours to midnight.
5895 */
5896DatePicker.prototype.normalize = function( value/*, options*/ ) {
5897 value.setHours( 0, 0, 0, 0 )
5898 return value
5899}
5900
5901
5902/**
5903 * Measure the range of dates.
5904 */
5905DatePicker.prototype.measure = function( type, value/*, options*/ ) {
5906
5907 var calendar = this
5908
5909 // If it’s anything false-y, remove the limits.
5910 if ( !value ) {
5911 value = type == 'min' ? -Infinity : Infinity
5912 }
5913
5914 // If it’s a string, parse it.
5915 else if ( typeof value == 'string' ) {
5916 value = calendar.parse( type, value )
5917 }
5918
5919 // If it's an integer, get a date relative to today.
5920 else if ( _.isInteger( value ) ) {
5921 value = calendar.now( type, value, { rel: value } )
5922 }
5923
5924 return value
5925} ///DatePicker.prototype.measure
5926
5927
5928/**
5929 * Create a viewset object based on navigation.
5930 */
5931DatePicker.prototype.viewset = function( type, dateObject/*, options*/ ) {
5932 return this.create([ dateObject.year, dateObject.month, 1 ])
5933}
5934
5935
5936/**
5937 * Validate a date as enabled and shift if needed.
5938 */
5939DatePicker.prototype.validate = function( type, dateObject, options ) {
5940
5941 var calendar = this,
5942
5943 // Keep a reference to the original date.
5944 originalDateObject = dateObject,
5945
5946 // Make sure we have an interval.
5947 interval = options && options.interval ? options.interval : 1,
5948
5949 // Check if the calendar enabled dates are inverted.
5950 isFlippedBase = calendar.item.enable === -1,
5951
5952 // Check if we have any enabled dates after/before now.
5953 hasEnabledBeforeTarget, hasEnabledAfterTarget,
5954
5955 // The min & max limits.
5956 minLimitObject = calendar.item.min,
5957 maxLimitObject = calendar.item.max,
5958
5959 // Check if we’ve reached the limit during shifting.
5960 reachedMin, reachedMax,
5961
5962 // Check if the calendar is inverted and at least one weekday is enabled.
5963 hasEnabledWeekdays = isFlippedBase && calendar.item.disable.filter( function( value ) {
5964
5965 // If there’s a date, check where it is relative to the target.
5966 if ( $.isArray( value ) ) {
5967 var dateTime = calendar.create( value ).pick
5968 if ( dateTime < dateObject.pick ) hasEnabledBeforeTarget = true
5969 else if ( dateTime > dateObject.pick ) hasEnabledAfterTarget = true
5970 }
5971
5972 // Return only integers for enabled weekdays.
5973 return _.isInteger( value )
5974 }).length/*,
5975
5976 safety = 100*/
5977
5978
5979
5980 // Cases to validate for:
5981 // [1] Not inverted and date disabled.
5982 // [2] Inverted and some dates enabled.
5983 // [3] Not inverted and out of range.
5984 //
5985 // Cases to **not** validate for:
5986 // • Navigating months.
5987 // • Not inverted and date enabled.
5988 // • Inverted and all dates disabled.
5989 // • ..and anything else.
5990 if ( !options || !options.nav ) if (
5991 /* 1 */ ( !isFlippedBase && calendar.disabled( dateObject ) ) ||
5992 /* 2 */ ( isFlippedBase && calendar.disabled( dateObject ) && ( hasEnabledWeekdays || hasEnabledBeforeTarget || hasEnabledAfterTarget ) ) ||
5993 /* 3 */ ( !isFlippedBase && (dateObject.pick <= minLimitObject.pick || dateObject.pick >= maxLimitObject.pick) )
5994 ) {
5995
5996
5997 // When inverted, flip the direction if there aren’t any enabled weekdays
5998 // and there are no enabled dates in the direction of the interval.
5999 if ( isFlippedBase && !hasEnabledWeekdays && ( ( !hasEnabledAfterTarget && interval > 0 ) || ( !hasEnabledBeforeTarget && interval < 0 ) ) ) {
6000 interval *= -1
6001 }
6002
6003
6004 // Keep looping until we reach an enabled date.
6005 while ( /*safety &&*/ calendar.disabled( dateObject ) ) {
6006
6007 /*safety -= 1
6008 if ( !safety ) {
6009 throw 'Fell into an infinite loop while validating ' + dateObject.obj + '.'
6010 }*/
6011
6012
6013 // If we’ve looped into the next/prev month with a large interval, return to the original date and flatten the interval.
6014 if ( Math.abs( interval ) > 1 && ( dateObject.month < originalDateObject.month || dateObject.month > originalDateObject.month ) ) {
6015 dateObject = originalDateObject
6016 interval = interval > 0 ? 1 : -1
6017 }
6018
6019
6020 // If we’ve reached the min/max limit, reverse the direction, flatten the interval and set it to the limit.
6021 if ( dateObject.pick <= minLimitObject.pick ) {
6022 reachedMin = true
6023 interval = 1
6024 dateObject = calendar.create([
6025 minLimitObject.year,
6026 minLimitObject.month,
6027 minLimitObject.date + (dateObject.pick === minLimitObject.pick ? 0 : -1)
6028 ])
6029 }
6030 else if ( dateObject.pick >= maxLimitObject.pick ) {
6031 reachedMax = true
6032 interval = -1
6033 dateObject = calendar.create([
6034 maxLimitObject.year,
6035 maxLimitObject.month,
6036 maxLimitObject.date + (dateObject.pick === maxLimitObject.pick ? 0 : 1)
6037 ])
6038 }
6039
6040
6041 // If we’ve reached both limits, just break out of the loop.
6042 if ( reachedMin && reachedMax ) {
6043 break
6044 }
6045
6046
6047 // Finally, create the shifted date using the interval and keep looping.
6048 dateObject = calendar.create([ dateObject.year, dateObject.month, dateObject.date + interval ])
6049 }
6050
6051 } //endif
6052
6053
6054 // Return the date object settled on.
6055 return dateObject
6056} //DatePicker.prototype.validate
6057
6058
6059/**
6060 * Check if a date is disabled.
6061 */
6062DatePicker.prototype.disabled = function( dateToVerify ) {
6063
6064 var
6065 calendar = this,
6066
6067 // Filter through the disabled dates to check if this is one.
6068 isDisabledMatch = calendar.item.disable.filter( function( dateToDisable ) {
6069
6070 // If the date is a number, match the weekday with 0index and `firstDay` check.
6071 if ( _.isInteger( dateToDisable ) ) {
6072 return dateToVerify.day === ( calendar.settings.firstDay ? dateToDisable : dateToDisable - 1 ) % 7
6073 }
6074
6075 // If it’s an array or a native JS date, create and match the exact date.
6076 if ( $.isArray( dateToDisable ) || _.isDate( dateToDisable ) ) {
6077 return dateToVerify.pick === calendar.create( dateToDisable ).pick
6078 }
6079
6080 // If it’s an object, match a date within the “from” and “to” range.
6081 if ( $.isPlainObject( dateToDisable ) ) {
6082 return calendar.withinRange( dateToDisable, dateToVerify )
6083 }
6084 })
6085
6086 // If this date matches a disabled date, confirm it’s not inverted.
6087 isDisabledMatch = isDisabledMatch.length && !isDisabledMatch.filter(function( dateToDisable ) {
6088 return $.isArray( dateToDisable ) && dateToDisable[3] == 'inverted' ||
6089 $.isPlainObject( dateToDisable ) && dateToDisable.inverted
6090 }).length
6091
6092 // Check the calendar “enabled” flag and respectively flip the
6093 // disabled state. Then also check if it’s beyond the min/max limits.
6094 return calendar.item.enable === -1 ? !isDisabledMatch : isDisabledMatch ||
6095 dateToVerify.pick < calendar.item.min.pick ||
6096 dateToVerify.pick > calendar.item.max.pick
6097
6098} //DatePicker.prototype.disabled
6099
6100
6101/**
6102 * Parse a string into a usable type.
6103 */
6104DatePicker.prototype.parse = function( type, value, options ) {
6105
6106 var calendar = this,
6107 parsingObject = {}
6108
6109 // If it’s already parsed, we’re good.
6110 if ( !value || typeof value != 'string' ) {
6111 return value
6112 }
6113
6114 // We need a `.format` to parse the value with.
6115 if ( !( options && options.format ) ) {
6116 options = options || {}
6117 options.format = calendar.settings.format
6118 }
6119
6120 // Convert the format into an array and then map through it.
6121 calendar.formats.toArray( options.format ).map( function( label ) {
6122
6123 var
6124 // Grab the formatting label.
6125 formattingLabel = calendar.formats[ label ],
6126
6127 // The format length is from the formatting label function or the
6128 // label length without the escaping exclamation (!) mark.
6129 formatLength = formattingLabel ? _.trigger( formattingLabel, calendar, [ value, parsingObject ] ) : label.replace( /^!/, '' ).length
6130
6131 // If there's a format label, split the value up to the format length.
6132 // Then add it to the parsing object with appropriate label.
6133 if ( formattingLabel ) {
6134 parsingObject[ label ] = value.substr( 0, formatLength )
6135 }
6136
6137 // Update the value as the substring from format length to end.
6138 value = value.substr( formatLength )
6139 })
6140
6141 // Compensate for month 0index.
6142 return [
6143 parsingObject.yyyy || parsingObject.yy,
6144 +( parsingObject.mm || parsingObject.m ) - 1,
6145 parsingObject.dd || parsingObject.d
6146 ]
6147} //DatePicker.prototype.parse
6148
6149
6150/**
6151 * Various formats to display the object in.
6152 */
6153DatePicker.prototype.formats = (function() {
6154
6155 // Return the length of the first word in a collection.
6156 function getWordLengthFromCollection( string, collection, dateObject ) {
6157
6158 // Grab the first word from the string.
6159 var word = string.match( /\w+/ )[ 0 ]
6160
6161 // If there's no month index, add it to the date object
6162 if ( !dateObject.mm && !dateObject.m ) {
6163 dateObject.m = collection.indexOf( word ) + 1
6164 }
6165
6166 // Return the length of the word.
6167 return word.length
6168 }
6169
6170 // Get the length of the first word in a string.
6171 function getFirstWordLength( string ) {
6172 return string.match( /\w+/ )[ 0 ].length
6173 }
6174
6175 return {
6176
6177 d: function( string, dateObject ) {
6178
6179 // If there's string, then get the digits length.
6180 // Otherwise return the selected date.
6181 return string ? _.digits( string ) : dateObject.date
6182 },
6183 dd: function( string, dateObject ) {
6184
6185 // If there's a string, then the length is always 2.
6186 // Otherwise return the selected date with a leading zero.
6187 return string ? 2 : _.lead( dateObject.date )
6188 },
6189 ddd: function( string, dateObject ) {
6190
6191 // If there's a string, then get the length of the first word.
6192 // Otherwise return the short selected weekday.
6193 return string ? getFirstWordLength( string ) : this.settings.weekdaysShort[ dateObject.day ]
6194 },
6195 dddd: function( string, dateObject ) {
6196
6197 // If there's a string, then get the length of the first word.
6198 // Otherwise return the full selected weekday.
6199 return string ? getFirstWordLength( string ) : this.settings.weekdaysFull[ dateObject.day ]
6200 },
6201 m: function( string, dateObject ) {
6202
6203 // If there's a string, then get the length of the digits
6204 // Otherwise return the selected month with 0index compensation.
6205 return string ? _.digits( string ) : dateObject.month + 1
6206 },
6207 mm: function( string, dateObject ) {
6208
6209 // If there's a string, then the length is always 2.
6210 // Otherwise return the selected month with 0index and leading zero.
6211 return string ? 2 : _.lead( dateObject.month + 1 )
6212 },
6213 mmm: function( string, dateObject ) {
6214
6215 var collection = this.settings.monthsShort
6216
6217 // If there's a string, get length of the relevant month from the short
6218 // months collection. Otherwise return the selected month from that collection.
6219 return string ? getWordLengthFromCollection( string, collection, dateObject ) : collection[ dateObject.month ]
6220 },
6221 mmmm: function( string, dateObject ) {
6222
6223 var collection = this.settings.monthsFull
6224
6225 // If there's a string, get length of the relevant month from the full
6226 // months collection. Otherwise return the selected month from that collection.
6227 return string ? getWordLengthFromCollection( string, collection, dateObject ) : collection[ dateObject.month ]
6228 },
6229 yy: function( string, dateObject ) {
6230
6231 // If there's a string, then the length is always 2.
6232 // Otherwise return the selected year by slicing out the first 2 digits.
6233 return string ? 2 : ( '' + dateObject.year ).slice( 2 )
6234 },
6235 yyyy: function( string, dateObject ) {
6236
6237 // If there's a string, then the length is always 4.
6238 // Otherwise return the selected year.
6239 return string ? 4 : dateObject.year
6240 },
6241
6242 // Create an array by splitting the formatting string passed.
6243 toArray: function( formatString ) { return formatString.split( /(d{1,4}|m{1,4}|y{4}|yy|!.)/g ) },
6244
6245 // Format an object into a string using the formatting options.
6246 toString: function ( formatString, itemObject ) {
6247 var calendar = this
6248 return calendar.formats.toArray( formatString ).map( function( label ) {
6249 return _.trigger( calendar.formats[ label ], calendar, [ 0, itemObject ] ) || label.replace( /^!/, '' )
6250 }).join( '' )
6251 }
6252 }
6253})() //DatePicker.prototype.formats
6254
6255
6256
6257
6258/**
6259 * Check if two date units are the exact.
6260 */
6261DatePicker.prototype.isDateExact = function( one, two ) {
6262
6263 var calendar = this
6264
6265 // When we’re working with weekdays, do a direct comparison.
6266 if (
6267 ( _.isInteger( one ) && _.isInteger( two ) ) ||
6268 ( typeof one == 'boolean' && typeof two == 'boolean' )
6269 ) {
6270 return one === two
6271 }
6272
6273 // When we’re working with date representations, compare the “pick” value.
6274 if (
6275 ( _.isDate( one ) || $.isArray( one ) ) &&
6276 ( _.isDate( two ) || $.isArray( two ) )
6277 ) {
6278 return calendar.create( one ).pick === calendar.create( two ).pick
6279 }
6280
6281 // When we’re working with range objects, compare the “from” and “to”.
6282 if ( $.isPlainObject( one ) && $.isPlainObject( two ) ) {
6283 return calendar.isDateExact( one.from, two.from ) && calendar.isDateExact( one.to, two.to )
6284 }
6285
6286 return false
6287}
6288
6289
6290/**
6291 * Check if two date units overlap.
6292 */
6293DatePicker.prototype.isDateOverlap = function( one, two ) {
6294
6295 var calendar = this,
6296 firstDay = calendar.settings.firstDay ? 1 : 0
6297
6298 // When we’re working with a weekday index, compare the days.
6299 if ( _.isInteger( one ) && ( _.isDate( two ) || $.isArray( two ) ) ) {
6300 one = one % 7 + firstDay
6301 return one === calendar.create( two ).day + 1
6302 }
6303 if ( _.isInteger( two ) && ( _.isDate( one ) || $.isArray( one ) ) ) {
6304 two = two % 7 + firstDay
6305 return two === calendar.create( one ).day + 1
6306 }
6307
6308 // When we’re working with range objects, check if the ranges overlap.
6309 if ( $.isPlainObject( one ) && $.isPlainObject( two ) ) {
6310 return calendar.overlapRanges( one, two )
6311 }
6312
6313 return false
6314}
6315
6316
6317/**
6318 * Flip the “enabled” state.
6319 */
6320DatePicker.prototype.flipEnable = function(val) {
6321 var itemObject = this.item
6322 itemObject.enable = val || (itemObject.enable == -1 ? 1 : -1)
6323}
6324
6325
6326/**
6327 * Mark a collection of dates as “disabled”.
6328 */
6329DatePicker.prototype.deactivate = function( type, datesToDisable ) {
6330
6331 var calendar = this,
6332 disabledItems = calendar.item.disable.slice(0)
6333
6334
6335 // If we’re flipping, that’s all we need to do.
6336 if ( datesToDisable == 'flip' ) {
6337 calendar.flipEnable()
6338 }
6339
6340 else if ( datesToDisable === false ) {
6341 calendar.flipEnable(1)
6342 disabledItems = []
6343 }
6344
6345 else if ( datesToDisable === true ) {
6346 calendar.flipEnable(-1)
6347 disabledItems = []
6348 }
6349
6350 // Otherwise go through the dates to disable.
6351 else {
6352
6353 datesToDisable.map(function( unitToDisable ) {
6354
6355 var matchFound
6356
6357 // When we have disabled items, check for matches.
6358 // If something is matched, immediately break out.
6359 for ( var index = 0; index < disabledItems.length; index += 1 ) {
6360 if ( calendar.isDateExact( unitToDisable, disabledItems[index] ) ) {
6361 matchFound = true
6362 break
6363 }
6364 }
6365
6366 // If nothing was found, add the validated unit to the collection.
6367 if ( !matchFound ) {
6368 if (
6369 _.isInteger( unitToDisable ) ||
6370 _.isDate( unitToDisable ) ||
6371 $.isArray( unitToDisable ) ||
6372 ( $.isPlainObject( unitToDisable ) && unitToDisable.from && unitToDisable.to )
6373 ) {
6374 disabledItems.push( unitToDisable )
6375 }
6376 }
6377 })
6378 }
6379
6380 // Return the updated collection.
6381 return disabledItems
6382} //DatePicker.prototype.deactivate
6383
6384
6385/**
6386 * Mark a collection of dates as “enabled”.
6387 */
6388DatePicker.prototype.activate = function( type, datesToEnable ) {
6389
6390 var calendar = this,
6391 disabledItems = calendar.item.disable,
6392 disabledItemsCount = disabledItems.length
6393
6394 // If we’re flipping, that’s all we need to do.
6395 if ( datesToEnable == 'flip' ) {
6396 calendar.flipEnable()
6397 }
6398
6399 else if ( datesToEnable === true ) {
6400 calendar.flipEnable(1)
6401 disabledItems = []
6402 }
6403
6404 else if ( datesToEnable === false ) {
6405 calendar.flipEnable(-1)
6406 disabledItems = []
6407 }
6408
6409 // Otherwise go through the disabled dates.
6410 else {
6411
6412 datesToEnable.map(function( unitToEnable ) {
6413
6414 var matchFound,
6415 disabledUnit,
6416 index,
6417 isExactRange
6418
6419 // Go through the disabled items and try to find a match.
6420 for ( index = 0; index < disabledItemsCount; index += 1 ) {
6421
6422 disabledUnit = disabledItems[index]
6423
6424 // When an exact match is found, remove it from the collection.
6425 if ( calendar.isDateExact( disabledUnit, unitToEnable ) ) {
6426 matchFound = disabledItems[index] = null
6427 isExactRange = true
6428 break
6429 }
6430
6431 // When an overlapped match is found, add the “inverted” state to it.
6432 else if ( calendar.isDateOverlap( disabledUnit, unitToEnable ) ) {
6433 if ( $.isPlainObject( unitToEnable ) ) {
6434 unitToEnable.inverted = true
6435 matchFound = unitToEnable
6436 }
6437 else if ( $.isArray( unitToEnable ) ) {
6438 matchFound = unitToEnable
6439 if ( !matchFound[3] ) matchFound.push( 'inverted' )
6440 }
6441 else if ( _.isDate( unitToEnable ) ) {
6442 matchFound = [ unitToEnable.getFullYear(), unitToEnable.getMonth(), unitToEnable.getDate(), 'inverted' ]
6443 }
6444 break
6445 }
6446 }
6447
6448 // If a match was found, remove a previous duplicate entry.
6449 if ( matchFound ) for ( index = 0; index < disabledItemsCount; index += 1 ) {
6450 if ( calendar.isDateExact( disabledItems[index], unitToEnable ) ) {
6451 disabledItems[index] = null
6452 break
6453 }
6454 }
6455
6456 // In the event that we’re dealing with an exact range of dates,
6457 // make sure there are no “inverted” dates because of it.
6458 if ( isExactRange ) for ( index = 0; index < disabledItemsCount; index += 1 ) {
6459 if ( calendar.isDateOverlap( disabledItems[index], unitToEnable ) ) {
6460 disabledItems[index] = null
6461 break
6462 }
6463 }
6464
6465 // If something is still matched, add it into the collection.
6466 if ( matchFound ) {
6467 disabledItems.push( matchFound )
6468 }
6469 })
6470 }
6471
6472 // Return the updated collection.
6473 return disabledItems.filter(function( val ) { return val != null })
6474} //DatePicker.prototype.activate
6475
6476
6477/**
6478 * Create a string for the nodes in the picker.
6479 */
6480DatePicker.prototype.nodes = function( isOpen ) {
6481
6482 var
6483 calendar = this,
6484 settings = calendar.settings,
6485 calendarItem = calendar.item,
6486 nowObject = calendarItem.now,
6487 selectedObject = calendarItem.select,
6488 highlightedObject = calendarItem.highlight,
6489 viewsetObject = calendarItem.view,
6490 disabledCollection = calendarItem.disable,
6491 minLimitObject = calendarItem.min,
6492 maxLimitObject = calendarItem.max,
6493
6494
6495 // Create the calendar table head using a copy of weekday labels collection.
6496 // * We do a copy so we don't mutate the original array.
6497 tableHead = (function( collection, fullCollection ) {
6498
6499 // If the first day should be Monday, move Sunday to the end.
6500 if ( settings.firstDay ) {
6501 collection.push( collection.shift() )
6502 fullCollection.push( fullCollection.shift() )
6503 }
6504
6505 // Create and return the table head group.
6506 return _.node(
6507 'thead',
6508 _.node(
6509 'tr',
6510 _.group({
6511 min: 0,
6512 max: DAYS_IN_WEEK - 1,
6513 i: 1,
6514 node: 'th',
6515 item: function( counter ) {
6516 return [
6517 collection[ counter ],
6518 settings.klass.weekdays,
6519 'scope=col title="' + fullCollection[ counter ] + '"'
6520 ]
6521 }
6522 })
6523 )
6524 ) //endreturn
6525
6526 // Materialize modified
6527 })( ( settings.showWeekdaysFull ? settings.weekdaysFull : settings.weekdaysLetter ).slice( 0 ), settings.weekdaysFull.slice( 0 ) ), //tableHead
6528
6529
6530 // Create the nav for next/prev month.
6531 createMonthNav = function( next ) {
6532
6533 // Otherwise, return the created month tag.
6534 return _.node(
6535 'div',
6536 ' ',
6537 settings.klass[ 'nav' + ( next ? 'Next' : 'Prev' ) ] + (
6538
6539 // If the focused month is outside the range, disabled the button.
6540 ( next && viewsetObject.year >= maxLimitObject.year && viewsetObject.month >= maxLimitObject.month ) ||
6541 ( !next && viewsetObject.year <= minLimitObject.year && viewsetObject.month <= minLimitObject.month ) ?
6542 ' ' + settings.klass.navDisabled : ''
6543 ),
6544 'data-nav=' + ( next || -1 ) + ' ' +
6545 _.ariaAttr({
6546 role: 'button',
6547 controls: calendar.$node[0].id + '_table'
6548 }) + ' ' +
6549 'title="' + (next ? settings.labelMonthNext : settings.labelMonthPrev ) + '"'
6550 ) //endreturn
6551 }, //createMonthNav
6552
6553
6554 // Create the month label.
6555 //Materialize modified
6556 createMonthLabel = function(override) {
6557
6558 var monthsCollection = settings.showMonthsShort ? settings.monthsShort : settings.monthsFull
6559
6560 // Materialize modified
6561 if (override == "short_months") {
6562 monthsCollection = settings.monthsShort;
6563 }
6564
6565 // If there are months to select, add a dropdown menu.
6566 if ( settings.selectMonths && override == undefined) {
6567
6568 return _.node( 'select',
6569 _.group({
6570 min: 0,
6571 max: 11,
6572 i: 1,
6573 node: 'option',
6574 item: function( loopedMonth ) {
6575
6576 return [
6577
6578 // The looped month and no classes.
6579 monthsCollection[ loopedMonth ], 0,
6580
6581 // Set the value and selected index.
6582 'value=' + loopedMonth +
6583 ( viewsetObject.month == loopedMonth ? ' selected' : '' ) +
6584 (
6585 (
6586 ( viewsetObject.year == minLimitObject.year && loopedMonth < minLimitObject.month ) ||
6587 ( viewsetObject.year == maxLimitObject.year && loopedMonth > maxLimitObject.month )
6588 ) ?
6589 ' disabled' : ''
6590 )
6591 ]
6592 }
6593 }),
6594 settings.klass.selectMonth + ' browser-default',
6595 ( isOpen ? '' : 'disabled' ) + ' ' +
6596 _.ariaAttr({ controls: calendar.$node[0].id + '_table' }) + ' ' +
6597 'title="' + settings.labelMonthSelect + '"'
6598 )
6599 }
6600
6601 // Materialize modified
6602 if (override == "short_months")
6603 if (selectedObject != null)
6604 return _.node( 'div', monthsCollection[ selectedObject.month ] );
6605 else return _.node( 'div', monthsCollection[ viewsetObject.month ] );
6606
6607 // If there's a need for a month selector
6608 return _.node( 'div', monthsCollection[ viewsetObject.month ], settings.klass.month )
6609 }, //createMonthLabel
6610
6611
6612 // Create the year label.
6613 // Materialize modified
6614 createYearLabel = function(override) {
6615
6616 var focusedYear = viewsetObject.year,
6617
6618 // If years selector is set to a literal "true", set it to 5. Otherwise
6619 // divide in half to get half before and half after focused year.
6620 numberYears = settings.selectYears === true ? 5 : ~~( settings.selectYears / 2 )
6621
6622 // If there are years to select, add a dropdown menu.
6623 if ( numberYears ) {
6624
6625 var
6626 minYear = minLimitObject.year,
6627 maxYear = maxLimitObject.year,
6628 lowestYear = focusedYear - numberYears,
6629 highestYear = focusedYear + numberYears
6630
6631 // If the min year is greater than the lowest year, increase the highest year
6632 // by the difference and set the lowest year to the min year.
6633 if ( minYear > lowestYear ) {
6634 highestYear += minYear - lowestYear
6635 lowestYear = minYear
6636 }
6637
6638 // If the max year is less than the highest year, decrease the lowest year
6639 // by the lower of the two: available and needed years. Then set the
6640 // highest year to the max year.
6641 if ( maxYear < highestYear ) {
6642
6643 var availableYears = lowestYear - minYear,
6644 neededYears = highestYear - maxYear
6645
6646 lowestYear -= availableYears > neededYears ? neededYears : availableYears
6647 highestYear = maxYear
6648 }
6649
6650 if ( settings.selectYears && override == undefined ) {
6651 return _.node( 'select',
6652 _.group({
6653 min: lowestYear,
6654 max: highestYear,
6655 i: 1,
6656 node: 'option',
6657 item: function( loopedYear ) {
6658 return [
6659
6660 // The looped year and no classes.
6661 loopedYear, 0,
6662
6663 // Set the value and selected index.
6664 'value=' + loopedYear + ( focusedYear == loopedYear ? ' selected' : '' )
6665 ]
6666 }
6667 }),
6668 settings.klass.selectYear + ' browser-default',
6669 ( isOpen ? '' : 'disabled' ) + ' ' + _.ariaAttr({ controls: calendar.$node[0].id + '_table' }) + ' ' +
6670 'title="' + settings.labelYearSelect + '"'
6671 )
6672 }
6673 }
6674
6675 // Materialize modified
6676 if (override == "raw")
6677 return _.node( 'div', focusedYear )
6678
6679 // Otherwise just return the year focused
6680 return _.node( 'div', focusedYear, settings.klass.year )
6681 } //createYearLabel
6682
6683
6684 // Materialize modified
6685 createDayLabel = function() {
6686 if (selectedObject != null)
6687 return _.node( 'div', selectedObject.date)
6688 else return _.node( 'div', nowObject.date)
6689 }
6690 createWeekdayLabel = function() {
6691 var display_day;
6692
6693 if (selectedObject != null)
6694 display_day = selectedObject.day;
6695 else
6696 display_day = nowObject.day;
6697 var weekday = settings.weekdaysFull[ display_day ]
6698 return weekday
6699 }
6700
6701
6702 // Create and return the entire calendar.
6703return _.node(
6704 // Date presentation View
6705 'div',
6706 _.node(
6707 'div',
6708 createWeekdayLabel(),
6709 "picker__weekday-display"
6710 )+
6711 _.node(
6712 // Div for short Month
6713 'div',
6714 createMonthLabel("short_months"),
6715 settings.klass.month_display
6716 )+
6717 _.node(
6718 // Div for Day
6719 'div',
6720 createDayLabel() ,
6721 settings.klass.day_display
6722 )+
6723 _.node(
6724 // Div for Year
6725 'div',
6726 createYearLabel("raw") ,
6727 settings.klass.year_display
6728 ),
6729 settings.klass.date_display
6730 )+
6731 // Calendar container
6732 _.node('div',
6733 _.node('div',
6734 ( settings.selectYears ? createMonthLabel() + createYearLabel() : createMonthLabel() + createYearLabel() ) +
6735 createMonthNav() + createMonthNav( 1 ),
6736 settings.klass.header
6737 ) + _.node(
6738 'table',
6739 tableHead +
6740 _.node(
6741 'tbody',
6742 _.group({
6743 min: 0,
6744 max: WEEKS_IN_CALENDAR - 1,
6745 i: 1,
6746 node: 'tr',
6747 item: function( rowCounter ) {
6748
6749 // If Monday is the first day and the month starts on Sunday, shift the date back a week.
6750 var shiftDateBy = settings.firstDay && calendar.create([ viewsetObject.year, viewsetObject.month, 1 ]).day === 0 ? -7 : 0
6751
6752 return [
6753 _.group({
6754 min: DAYS_IN_WEEK * rowCounter - viewsetObject.day + shiftDateBy + 1, // Add 1 for weekday 0index
6755 max: function() {
6756 return this.min + DAYS_IN_WEEK - 1
6757 },
6758 i: 1,
6759 node: 'td',
6760 item: function( targetDate ) {
6761
6762 // Convert the time date from a relative date to a target date.
6763 targetDate = calendar.create([ viewsetObject.year, viewsetObject.month, targetDate + ( settings.firstDay ? 1 : 0 ) ])
6764
6765 var isSelected = selectedObject && selectedObject.pick == targetDate.pick,
6766 isHighlighted = highlightedObject && highlightedObject.pick == targetDate.pick,
6767 isDisabled = disabledCollection && calendar.disabled( targetDate ) || targetDate.pick < minLimitObject.pick || targetDate.pick > maxLimitObject.pick,
6768 formattedDate = _.trigger( calendar.formats.toString, calendar, [ settings.format, targetDate ] )
6769
6770 return [
6771 _.node(
6772 'div',
6773 targetDate.date,
6774 (function( klasses ) {
6775
6776 // Add the `infocus` or `outfocus` classes based on month in view.
6777 klasses.push( viewsetObject.month == targetDate.month ? settings.klass.infocus : settings.klass.outfocus )
6778
6779 // Add the `today` class if needed.
6780 if ( nowObject.pick == targetDate.pick ) {
6781 klasses.push( settings.klass.now )
6782 }
6783
6784 // Add the `selected` class if something's selected and the time matches.
6785 if ( isSelected ) {
6786 klasses.push( settings.klass.selected )
6787 }
6788
6789 // Add the `highlighted` class if something's highlighted and the time matches.
6790 if ( isHighlighted ) {
6791 klasses.push( settings.klass.highlighted )
6792 }
6793
6794 // Add the `disabled` class if something's disabled and the object matches.
6795 if ( isDisabled ) {
6796 klasses.push( settings.klass.disabled )
6797 }
6798
6799 return klasses.join( ' ' )
6800 })([ settings.klass.day ]),
6801 'data-pick=' + targetDate.pick + ' ' + _.ariaAttr({
6802 role: 'gridcell',
6803 label: formattedDate,
6804 selected: isSelected && calendar.$node.val() === formattedDate ? true : null,
6805 activedescendant: isHighlighted ? true : null,
6806 disabled: isDisabled ? true : null
6807 })
6808 ),
6809 '',
6810 _.ariaAttr({ role: 'presentation' })
6811 ] //endreturn
6812 }
6813 })
6814 ] //endreturn
6815 }
6816 })
6817 ),
6818 settings.klass.table,
6819 'id="' + calendar.$node[0].id + '_table' + '" ' + _.ariaAttr({
6820 role: 'grid',
6821 controls: calendar.$node[0].id,
6822 readonly: true
6823 })
6824 )
6825 , settings.klass.calendar_container) // end calendar
6826
6827 +
6828
6829 // * For Firefox forms to submit, make sure to set the buttons’ `type` attributes as “button”.
6830 _.node(
6831 'div',
6832 _.node( 'button', settings.today, "btn-flat picker__today",
6833 'type=button data-pick=' + nowObject.pick +
6834 ( isOpen && !calendar.disabled(nowObject) ? '' : ' disabled' ) + ' ' +
6835 _.ariaAttr({ controls: calendar.$node[0].id }) ) +
6836 _.node( 'button', settings.clear, "btn-flat picker__clear",
6837 'type=button data-clear=1' +
6838 ( isOpen ? '' : ' disabled' ) + ' ' +
6839 _.ariaAttr({ controls: calendar.$node[0].id }) ) +
6840 _.node('button', settings.close, "btn-flat picker__close",
6841 'type=button data-close=true ' +
6842 ( isOpen ? '' : ' disabled' ) + ' ' +
6843 _.ariaAttr({ controls: calendar.$node[0].id }) ),
6844 settings.klass.footer
6845 ) //endreturn
6846} //DatePicker.prototype.nodes
6847
6848
6849
6850
6851/**
6852 * The date picker defaults.
6853 */
6854DatePicker.defaults = (function( prefix ) {
6855
6856 return {
6857
6858 // The title label to use for the month nav buttons
6859 labelMonthNext: 'Next month',
6860 labelMonthPrev: 'Previous month',
6861
6862 // The title label to use for the dropdown selectors
6863 labelMonthSelect: 'Select a month',
6864 labelYearSelect: 'Select a year',
6865
6866 // Months and weekdays
6867 monthsFull: [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ],
6868 monthsShort: [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ],
6869 weekdaysFull: [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ],
6870 weekdaysShort: [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ],
6871
6872 // Materialize modified
6873 weekdaysLetter: [ 'S', 'M', 'T', 'W', 'T', 'F', 'S' ],
6874
6875 // Today and clear
6876 today: 'Today',
6877 clear: 'Clear',
6878 close: 'Close',
6879
6880 // The format to show on the `input` element
6881 format: 'd mmmm, yyyy',
6882
6883 // Classes
6884 klass: {
6885
6886 table: prefix + 'table',
6887
6888 header: prefix + 'header',
6889
6890
6891 // Materialize Added klasses
6892 date_display: prefix + 'date-display',
6893 day_display: prefix + 'day-display',
6894 month_display: prefix + 'month-display',
6895 year_display: prefix + 'year-display',
6896 calendar_container: prefix + 'calendar-container',
6897 // end
6898
6899
6900
6901 navPrev: prefix + 'nav--prev',
6902 navNext: prefix + 'nav--next',
6903 navDisabled: prefix + 'nav--disabled',
6904
6905 month: prefix + 'month',
6906 year: prefix + 'year',
6907
6908 selectMonth: prefix + 'select--month',
6909 selectYear: prefix + 'select--year',
6910
6911 weekdays: prefix + 'weekday',
6912
6913 day: prefix + 'day',
6914 disabled: prefix + 'day--disabled',
6915 selected: prefix + 'day--selected',
6916 highlighted: prefix + 'day--highlighted',
6917 now: prefix + 'day--today',
6918 infocus: prefix + 'day--infocus',
6919 outfocus: prefix + 'day--outfocus',
6920
6921 footer: prefix + 'footer',
6922
6923 buttonClear: prefix + 'button--clear',
6924 buttonToday: prefix + 'button--today',
6925 buttonClose: prefix + 'button--close'
6926 }
6927 }
6928})( Picker.klasses().picker + '__' )
6929
6930
6931
6932
6933
6934/**
6935 * Extend the picker to add the date picker.
6936 */
6937Picker.extend( 'pickadate', DatePicker )
6938
6939
6940}));
6941
6942
6943;(function ($) {
6944
6945 $.fn.characterCounter = function(){
6946 return this.each(function(){
6947 var $input = $(this);
6948 var $counterElement = $input.parent().find('span[class="character-counter"]');
6949
6950 // character counter has already been added appended to the parent container
6951 if ($counterElement.length) {
6952 return;
6953 }
6954
6955 var itHasLengthAttribute = $input.attr('length') !== undefined;
6956
6957 if(itHasLengthAttribute){
6958 $input.on('input', updateCounter);
6959 $input.on('focus', updateCounter);
6960 $input.on('blur', removeCounterElement);
6961
6962 addCounterElement($input);
6963 }
6964
6965 });
6966 };
6967
6968 function updateCounter(){
6969 var maxLength = +$(this).attr('length'),
6970 actualLength = +$(this).val().length,
6971 isValidLength = actualLength <= maxLength;
6972
6973 $(this).parent().find('span[class="character-counter"]')
6974 .html( actualLength + '/' + maxLength);
6975
6976 addInputStyle(isValidLength, $(this));
6977 }
6978
6979 function addCounterElement($input) {
6980 var $counterElement = $input.parent().find('span[class="character-counter"]');
6981
6982 if ($counterElement.length) {
6983 return;
6984 }
6985
6986 $counterElement = $('<span/>')
6987 .addClass('character-counter')
6988 .css('float','right')
6989 .css('font-size','12px')
6990 .css('height', 1);
6991
6992 $input.parent().append($counterElement);
6993 }
6994
6995 function removeCounterElement(){
6996 $(this).parent().find('span[class="character-counter"]').html('');
6997 }
6998
6999 function addInputStyle(isValidLength, $input){
7000 var inputHasInvalidClass = $input.hasClass('invalid');
7001 if (isValidLength && inputHasInvalidClass) {
7002 $input.removeClass('invalid');
7003 }
7004 else if(!isValidLength && !inputHasInvalidClass){
7005 $input.removeClass('valid');
7006 $input.addClass('invalid');
7007 }
7008 }
7009
7010 $(document).ready(function(){
7011 $('input, textarea').characterCounter();
7012 });
7013
7014}( jQuery ));
7015;(function ($) {
7016
7017 var methods = {
7018
7019 init : function(options) {
7020 var defaults = {
7021 time_constant: 200, // ms
7022 dist: -100, // zoom scale TODO: make this more intuitive as an option
7023 shift: 0, // spacing for center image
7024 padding: 0, // Padding between non center items
7025 full_width: false, // Change to full width styles
7026 indicators: false, // Toggle indicators
7027 no_wrap: false // Don't wrap around and cycle through items.
7028 };
7029 options = $.extend(defaults, options);
7030
7031 return this.each(function() {
7032
7033 var images, offset, center, pressed, dim, count,
7034 reference, referenceY, amplitude, target, velocity,
7035 xform, frame, timestamp, ticker, dragged, vertical_dragged;
7036 var $indicators = $('<ul class="indicators"></ul>');
7037
7038
7039 // Initialize
7040 var view = $(this);
7041 var showIndicators = view.attr('data-indicators') || options.indicators;
7042
7043 // Don't double initialize.
7044 if (view.hasClass('initialized')) {
7045 // Redraw carousel.
7046 $(this).trigger('carouselNext', [0.000001]);
7047 return true;
7048 }
7049
7050
7051 // Options
7052 if (options.full_width) {
7053 options.dist = 0;
7054 var firstImage = view.find('.carousel-item img').first();
7055 if (firstImage.length) {
7056 imageHeight = firstImage.load(function(){
7057 view.css('height', $(this).height());
7058 });
7059 } else {
7060 imageHeight = view.find('.carousel-item').first().height();
7061 view.css('height', imageHeight);
7062 }
7063
7064 // Offset fixed items when indicators.
7065 if (showIndicators) {
7066 view.find('.carousel-fixed-item').addClass('with-indicators');
7067 }
7068 }
7069
7070
7071 view.addClass('initialized');
7072 pressed = false;
7073 offset = target = 0;
7074 images = [];
7075 item_width = view.find('.carousel-item').first().innerWidth();
7076 dim = item_width * 2 + options.padding;
7077
7078 view.find('.carousel-item').each(function (i) {
7079 images.push($(this)[0]);
7080 if (showIndicators) {
7081 var $indicator = $('<li class="indicator-item"></li>');
7082
7083 // Add active to first by default.
7084 if (i === 0) {
7085 $indicator.addClass('active');
7086 }
7087
7088 // Handle clicks on indicators.
7089 $indicator.click(function () {
7090 var index = $(this).index();
7091 cycleTo(index);
7092 });
7093 $indicators.append($indicator);
7094 }
7095 });
7096
7097 if (showIndicators) {
7098 view.append($indicators);
7099 }
7100 count = images.length;
7101
7102
7103 function setupEvents() {
7104 if (typeof window.ontouchstart !== 'undefined') {
7105 view[0].addEventListener('touchstart', tap);
7106 view[0].addEventListener('touchmove', drag);
7107 view[0].addEventListener('touchend', release);
7108 }
7109 view[0].addEventListener('mousedown', tap);
7110 view[0].addEventListener('mousemove', drag);
7111 view[0].addEventListener('mouseup', release);
7112 view[0].addEventListener('mouseleave', release);
7113 view[0].addEventListener('click', click);
7114 }
7115
7116 function xpos(e) {
7117 // touch event
7118 if (e.targetTouches && (e.targetTouches.length >= 1)) {
7119 return e.targetTouches[0].clientX;
7120 }
7121
7122 // mouse event
7123 return e.clientX;
7124 }
7125
7126 function ypos(e) {
7127 // touch event
7128 if (e.targetTouches && (e.targetTouches.length >= 1)) {
7129 return e.targetTouches[0].clientY;
7130 }
7131
7132 // mouse event
7133 return e.clientY;
7134 }
7135
7136 function wrap(x) {
7137 return (x >= count) ? (x % count) : (x < 0) ? wrap(count + (x % count)) : x;
7138 }
7139
7140 function scroll(x) {
7141 var i, half, delta, dir, tween, el, alignment, xTranslation;
7142
7143 offset = (typeof x === 'number') ? x : offset;
7144 center = Math.floor((offset + dim / 2) / dim);
7145 delta = offset - center * dim;
7146 dir = (delta < 0) ? 1 : -1;
7147 tween = -dir * delta * 2 / dim;
7148 half = count >> 1;
7149
7150 if (!options.full_width) {
7151 alignment = 'translateX(' + (view[0].clientWidth - item_width) / 2 + 'px) ';
7152 alignment += 'translateY(' + (view[0].clientHeight - item_width) / 2 + 'px)';
7153 } else {
7154 alignment = 'translateX(0)';
7155 }
7156
7157 // Set indicator active
7158 if (showIndicators) {
7159 var diff = (center % count);
7160 var activeIndicator = $indicators.find('.indicator-item.active');
7161 if (activeIndicator.index() !== diff) {
7162 activeIndicator.removeClass('active');
7163 $indicators.find('.indicator-item').eq(diff).addClass('active');
7164 }
7165 }
7166
7167 // center
7168 // Don't show wrapped items.
7169 if (!options.no_wrap || (center >= 0 && center < count)) {
7170 el = images[wrap(center)];
7171 el.style[xform] = alignment +
7172 ' translateX(' + (-delta / 2) + 'px)' +
7173 ' translateX(' + (dir * options.shift * tween * i) + 'px)' +
7174 ' translateZ(' + (options.dist * tween) + 'px)';
7175 el.style.zIndex = 0;
7176 if (options.full_width) { tweenedOpacity = 1; }
7177 else { tweenedOpacity = 1 - 0.2 * tween; }
7178 el.style.opacity = tweenedOpacity;
7179 el.style.display = 'block';
7180 }
7181
7182 for (i = 1; i <= half; ++i) {
7183 // right side
7184 if (options.full_width) {
7185 zTranslation = options.dist;
7186 tweenedOpacity = (i === half && delta < 0) ? 1 - tween : 1;
7187 } else {
7188 zTranslation = options.dist * (i * 2 + tween * dir);
7189 tweenedOpacity = 1 - 0.2 * (i * 2 + tween * dir);
7190 }
7191 // Don't show wrapped items.
7192 if (!options.no_wrap || center + i < count) {
7193 el = images[wrap(center + i)];
7194 el.style[xform] = alignment +
7195 ' translateX(' + (options.shift + (dim * i - delta) / 2) + 'px)' +
7196 ' translateZ(' + zTranslation + 'px)';
7197 el.style.zIndex = -i;
7198 el.style.opacity = tweenedOpacity;
7199 el.style.display = 'block';
7200 }
7201
7202
7203 // left side
7204 if (options.full_width) {
7205 zTranslation = options.dist;
7206 tweenedOpacity = (i === half && delta > 0) ? 1 - tween : 1;
7207 } else {
7208 zTranslation = options.dist * (i * 2 - tween * dir);
7209 tweenedOpacity = 1 - 0.2 * (i * 2 - tween * dir);
7210 }
7211 // Don't show wrapped items.
7212 if (!options.no_wrap || center - i >= 0) {
7213 el = images[wrap(center - i)];
7214 el.style[xform] = alignment +
7215 ' translateX(' + (-options.shift + (-dim * i - delta) / 2) + 'px)' +
7216 ' translateZ(' + zTranslation + 'px)';
7217 el.style.zIndex = -i;
7218 el.style.opacity = tweenedOpacity;
7219 el.style.display = 'block';
7220 }
7221 }
7222
7223 // center
7224 // Don't show wrapped items.
7225 if (!options.no_wrap || (center >= 0 && center < count)) {
7226 el = images[wrap(center)];
7227 el.style[xform] = alignment +
7228 ' translateX(' + (-delta / 2) + 'px)' +
7229 ' translateX(' + (dir * options.shift * tween) + 'px)' +
7230 ' translateZ(' + (options.dist * tween) + 'px)';
7231 el.style.zIndex = 0;
7232 if (options.full_width) { tweenedOpacity = 1; }
7233 else { tweenedOpacity = 1 - 0.2 * tween; }
7234 el.style.opacity = tweenedOpacity;
7235 el.style.display = 'block';
7236 }
7237 }
7238
7239 function track() {
7240 var now, elapsed, delta, v;
7241
7242 now = Date.now();
7243 elapsed = now - timestamp;
7244 timestamp = now;
7245 delta = offset - frame;
7246 frame = offset;
7247
7248 v = 1000 * delta / (1 + elapsed);
7249 velocity = 0.8 * v + 0.2 * velocity;
7250 }
7251
7252 function autoScroll() {
7253 var elapsed, delta;
7254
7255 if (amplitude) {
7256 elapsed = Date.now() - timestamp;
7257 delta = amplitude * Math.exp(-elapsed / options.time_constant);
7258 if (delta > 2 || delta < -2) {
7259 scroll(target - delta);
7260 requestAnimationFrame(autoScroll);
7261 } else {
7262 scroll(target);
7263 }
7264 }
7265 }
7266
7267 function click(e) {
7268 // Disable clicks if carousel was dragged.
7269 if (dragged) {
7270 e.preventDefault();
7271 e.stopPropagation();
7272 return false;
7273
7274 } else if (!options.full_width) {
7275 var clickedIndex = $(e.target).closest('.carousel-item').index();
7276 var diff = (center % count) - clickedIndex;
7277
7278 // Disable clicks if carousel was shifted by click
7279 if (diff !== 0) {
7280 e.preventDefault();
7281 e.stopPropagation();
7282 }
7283 cycleTo(clickedIndex);
7284 }
7285 }
7286
7287 function cycleTo(n) {
7288 var diff = (center % count) - n;
7289
7290 // Account for wraparound.
7291 if (!options.no_wrap) {
7292 if (diff < 0) {
7293 if (Math.abs(diff + count) < Math.abs(diff)) { diff += count; }
7294
7295 } else if (diff > 0) {
7296 if (Math.abs(diff - count) < diff) { diff -= count; }
7297 }
7298 }
7299
7300 // Call prev or next accordingly.
7301 if (diff < 0) {
7302 view.trigger('carouselNext', [Math.abs(diff)]);
7303
7304 } else if (diff > 0) {
7305 view.trigger('carouselPrev', [diff]);
7306 }
7307 }
7308
7309 function tap(e) {
7310 pressed = true;
7311 dragged = false;
7312 vertical_dragged = false;
7313 reference = xpos(e);
7314 referenceY = ypos(e);
7315
7316 velocity = amplitude = 0;
7317 frame = offset;
7318 timestamp = Date.now();
7319 clearInterval(ticker);
7320 ticker = setInterval(track, 100);
7321
7322 }
7323
7324 function drag(e) {
7325 var x, delta, deltaY;
7326 if (pressed) {
7327 x = xpos(e);
7328 y = ypos(e);
7329 delta = reference - x;
7330 deltaY = Math.abs(referenceY - y);
7331 if (deltaY < 30 && !vertical_dragged) {
7332 // If vertical scrolling don't allow dragging.
7333 if (delta > 2 || delta < -2) {
7334 dragged = true;
7335 reference = x;
7336 scroll(offset + delta);
7337 }
7338
7339 } else if (dragged) {
7340 // If dragging don't allow vertical scroll.
7341 e.preventDefault();
7342 e.stopPropagation();
7343 return false;
7344
7345 } else {
7346 // Vertical scrolling.
7347 vertical_dragged = true;
7348 }
7349 }
7350
7351 if (dragged) {
7352 // If dragging don't allow vertical scroll.
7353 e.preventDefault();
7354 e.stopPropagation();
7355 return false;
7356 }
7357 }
7358
7359 function release(e) {
7360 if (pressed) {
7361 pressed = false;
7362 } else {
7363 return;
7364 }
7365
7366 clearInterval(ticker);
7367 target = offset;
7368 if (velocity > 10 || velocity < -10) {
7369 amplitude = 0.9 * velocity;
7370 target = offset + amplitude;
7371 }
7372 target = Math.round(target / dim) * dim;
7373
7374 // No wrap of items.
7375 if (options.no_wrap) {
7376 if (target >= dim * (count - 1)) {
7377 target = dim * (count - 1);
7378 } else if (target < 0) {
7379 target = 0;
7380 }
7381 }
7382 amplitude = target - offset;
7383 timestamp = Date.now();
7384 requestAnimationFrame(autoScroll);
7385
7386 if (dragged) {
7387 e.preventDefault();
7388 e.stopPropagation();
7389 }
7390 return false;
7391 }
7392
7393 xform = 'transform';
7394 ['webkit', 'Moz', 'O', 'ms'].every(function (prefix) {
7395 var e = prefix + 'Transform';
7396 if (typeof document.body.style[e] !== 'undefined') {
7397 xform = e;
7398 return false;
7399 }
7400 return true;
7401 });
7402
7403
7404
7405 window.onresize = scroll;
7406
7407 setupEvents();
7408 scroll(offset);
7409
7410 $(this).on('carouselNext', function(e, n) {
7411 if (n === undefined) {
7412 n = 1;
7413 }
7414 target = offset + dim * n;
7415 if (offset !== target) {
7416 amplitude = target - offset;
7417 timestamp = Date.now();
7418 requestAnimationFrame(autoScroll);
7419 }
7420 });
7421
7422 $(this).on('carouselPrev', function(e, n) {
7423 if (n === undefined) {
7424 n = 1;
7425 }
7426 target = offset - dim * n;
7427 if (offset !== target) {
7428 amplitude = target - offset;
7429 timestamp = Date.now();
7430 requestAnimationFrame(autoScroll);
7431 }
7432 });
7433
7434 $(this).on('carouselSet', function(e, n) {
7435 if (n === undefined) {
7436 n = 0;
7437 }
7438 cycleTo(n);
7439 });
7440
7441 });
7442
7443
7444
7445 },
7446 next : function(n) {
7447 $(this).trigger('carouselNext', [n]);
7448 },
7449 prev : function(n) {
7450 $(this).trigger('carouselPrev', [n]);
7451 },
7452 set : function(n) {
7453 $(this).trigger('carouselSet', [n]);
7454 }
7455 };
7456
7457
7458 $.fn.carousel = function(methodOrOptions) {
7459 if ( methods[methodOrOptions] ) {
7460 return methods[ methodOrOptions ].apply( this, Array.prototype.slice.call( arguments, 1 ));
7461 } else if ( typeof methodOrOptions === 'object' || ! methodOrOptions ) {
7462 // Default to "init"
7463 return methods.init.apply( this, arguments );
7464 } else {
7465 $.error( 'Method ' + methodOrOptions + ' does not exist on jQuery.carousel' );
7466 }
7467 }; // Plugin end
7468}( jQuery ));