ryfan

materialize.js

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