PageSourceSearch

https://laasunciondonostia.org/templates/asuncion/js/materialize.js?cf12049f5ddc714ed44a26ee8215de46

js laasunciondonostia.org collected 2026-09-27 08:09:21 UTC 309,031 bytes, 7,778 lines download raw bytes

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

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.