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

6830 line
272KB

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