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