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