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