You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

7467 lines
292 KiB

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