all.js 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029
  1. /**
  2. * Often used vanilla js functions, so that we don't need
  3. * to use all of underscore/jQuery
  4. */
  5. (function( undefined ) {
  6. "use strict";
  7. var v = ( window.VAMTAM = window.VAMTAM || {} ); // Namespace
  8. // Returns a function, that, as long as it continues to be invoked, will not
  9. // be triggered. The function will be called after it stops being called for
  10. // N milliseconds. If `immediate` is passed, trigger the function on the
  11. // leading edge, instead of the trailing.
  12. v.debounce = function( func, wait, immediate ) {
  13. var timeout;
  14. return function() {
  15. var context = this, args = arguments;
  16. var later = function() {
  17. timeout = null;
  18. if ( ! immediate ) func.apply( context, args );
  19. };
  20. var callNow = immediate && ! timeout;
  21. clearTimeout( timeout );
  22. timeout = setTimeout( later, wait );
  23. if ( callNow ) func.apply( context, args );
  24. };
  25. };
  26. // vanilla jQuery.fn.offset() replacement
  27. // @see https://plainjs.com/javascript/styles/get-the-position-of-an-element-relative-to-the-document-24/
  28. v.offset = function( el ) {
  29. var rect = el.getBoundingClientRect(),
  30. scrollLeft = window.pageXOffset || document.documentElement.scrollLeft,
  31. scrollTop = window.pageYOffset || document.documentElement.scrollTop;
  32. return { top: rect.top + scrollTop, left: rect.left + scrollLeft };
  33. };
  34. // Faster scroll-based animations
  35. v.scroll_handlers = [];
  36. v.latestKnownScrollY = 0;
  37. var ticking = false;
  38. v.addScrollHandler = function( handler ) {
  39. requestAnimationFrame( function() {
  40. handler.init();
  41. v.scroll_handlers.push( handler );
  42. handler.measure( v.latestKnownScrollY );
  43. handler.mutate( v.latestKnownScrollY );
  44. } );
  45. };
  46. v.onScroll = function() {
  47. v.latestKnownScrollY = window.pageYOffset;
  48. if ( ! ticking ) {
  49. ticking = true;
  50. requestAnimationFrame( function() {
  51. var i;
  52. for ( i = 0; i < v.scroll_handlers.length; i++ ) {
  53. v.scroll_handlers[i].measure( v.latestKnownScrollY );
  54. }
  55. for ( i = 0; i < v.scroll_handlers.length; i++ ) {
  56. v.scroll_handlers[i].mutate( v.latestKnownScrollY );
  57. }
  58. ticking = false;
  59. } );
  60. }
  61. };
  62. window.addEventListener( 'scroll', v.onScroll, { passive: true } );
  63. // Load an async script
  64. v.load_script = function( src, callback ) {
  65. var s = document.createElement('script');
  66. s.type = 'text/javascript';
  67. s.async = true;
  68. s.src = src;
  69. if ( callback ) {
  70. s.onload = callback;
  71. }
  72. document.getElementsByTagName('script')[0].before( s );
  73. };
  74. })();
  75. (function($, undefined) {
  76. "use strict";
  77. window.vamtam_yepnope=function(a,b){function c(){}function d(a){return Object(a)===a}function e(a){return"string"==typeof a}function f(){return"yn_"+q++}function g(){o&&o.parentNode||(o=b.getElementsByTagName("script")[0])}function h(a){return!a||"loaded"==a||"complete"==a||"uninitialized"==a}function i(b,c){c.call(a)}function j(a,j){var k,l,m;e(a)?k=a:d(a)&&(k=a._url||a.src,l=a.attrs,m=a.timeout),j=j||c,l=l||{};var q,r,t=b.createElement("script");m=m||n.errorTimeout,t.src=k,s&&(t.event="onclick",t.id=t.htmlFor=l.id||f());for(r in l)t.setAttribute(r,l[r]);t.onreadystatechange=t.onload=function(){if(!q&&h(t.readyState)){if(q=1,s)try{t.onclick()}catch(a){}i(k,j)}t.onload=t.onreadystatechange=t.onerror=null},t.onerror=function(){q=1,j(new Error("Script Error: "+k))},p(function(){q||(q=1,j(new Error("Timeout: "+k)),t.parentNode.removeChild(t))},m),g(),o.parentNode.insertBefore(t,o)}function k(f,h){var i,j,k={};d(f)?(i=f._url||f.href,k=f.attrs||{}):e(f)&&(i=f);var l=b.createElement("link");h=h||c,l.href=i,l.rel="stylesheet",l.media="only x",l.type="text/css",p(function(){l.media=k.media||"all"});for(j in k)l.setAttribute(j,k[j]);g(),o.parentNode.appendChild(l),p(function(){h.call(a)})}function l(a){var b=a.split("?")[0];return b.substr(b.lastIndexOf(".")+1)}function m(a,b){var c=a,d=[],e=[];for(var f in b)b.hasOwnProperty(f)&&(b[f]?d.push(encodeURIComponent(f)):e.push(encodeURIComponent(f)));return(d.length||e.length)&&(c+="?"),d.length&&(c+="yep="+d.join(",")),e.length&&(c+=(d.length?"&":"")+"nope="+e.join(",")),c}function n(a,b,c){var e;d(a)&&(e=a,a=e.src||e.href),a=n.urlFormatter(a,b),e?e._url=a:e={_url:a};var f=l(a);if("js"===f)j(e,c);else{if("css"!==f)throw new Error("Unable to determine filetype.");k(e,c)}}var o,p=a.setTimeout,q=0,r={}.toString,s=!(!b.attachEvent||a.opera&&"[object Opera]"==r.call(a.opera));return n.errorTimeout=1e4,n.injectJs=j,n.injectCss=k,n.urlFormatter=m,n}(window,document); // jshint ignore:line
  78. var queue = [];
  79. function process_queue() {
  80. for ( var i = 0; i < queue.length; i++ ) {
  81. queue[i].call( window );
  82. }
  83. }
  84. document.addEventListener( 'DOMContentLoaded', function() {
  85. var scripts = [];
  86. if ( 'punchgs' in window ) {
  87. window.vamtamgs = window.GreenSockGlobals = window.punchgs;
  88. window._gsQueue = window._gsDefine = null;
  89. } else {
  90. window.vamtamgs = window.GreenSockGlobals = {};
  91. window._gsQueue = window._gsDefine = null;
  92. scripts.push(
  93. window.VAMTAM_FRONT.jspath + 'plugins/thirdparty/gsap/TweenLite.min.js',
  94. window.VAMTAM_FRONT.jspath + 'plugins/thirdparty/gsap/TimelineLite.min.js',
  95. window.VAMTAM_FRONT.jspath + 'plugins/thirdparty/gsap/plugins/CSSPlugin.min.js'
  96. );
  97. }
  98. window.vamtam_greensock_loaded = false;
  99. if ( ! ( 'scroll-behavior' in document.documentElement.style ) ) {
  100. scripts.push( window.VAMTAM_FRONT.jspath + 'plugins/thirdparty/smoothscroll.js' );
  101. }
  102. var total_ready = 0;
  103. var maybe_ready = function() {
  104. if ( ++ total_ready >= scripts.length ) {
  105. window.GreenSockGlobals = window._gsQueue = window._gsDefine = null;
  106. window.vamtam_greensock_loaded = true;
  107. process_queue();
  108. }
  109. };
  110. if ( scripts.length > 0 ) {
  111. for ( var i = 0; i < scripts.length; i++ ) {
  112. vamtam_yepnope.injectJs( scripts[i], maybe_ready );
  113. }
  114. } else {
  115. maybe_ready();
  116. }
  117. });
  118. window.vamtam_greensock_wait = function( callback ) {
  119. var callback_wrapper = function() {
  120. requestAnimationFrame( callback );
  121. };
  122. if ( window.vamtam_greensock_loaded ) {
  123. callback_wrapper();
  124. } else {
  125. queue.push( callback_wrapper );
  126. }
  127. };
  128. })(jQuery);
  129. (function() {
  130. 'use strict';
  131. // ChildNode (MDN)
  132. var buildDOM = function() {
  133. var nodes = Array.prototype.slice.call(arguments),
  134. frag = document.createDocumentFragment(),
  135. div, node;
  136. while (node = nodes.shift()) {
  137. if (typeof node == "string") {
  138. div = document.createElement("div");
  139. div.innerHTML = node;
  140. while (div.firstChild) {
  141. frag.appendChild(div.firstChild);
  142. }
  143. } else {
  144. frag.appendChild(node);
  145. }
  146. }
  147. return frag;
  148. };
  149. var proto = {
  150. before: function() {
  151. var frag = buildDOM.apply(this, arguments);
  152. this.parentNode.insertBefore(frag, this);
  153. },
  154. after: function() {
  155. var frag = buildDOM.apply(this, arguments);
  156. this.parentNode.insertBefore(frag, this.nextSibling);
  157. },
  158. replaceWith: function() {
  159. if (this.parentNode) {
  160. var frag = buildDOM.apply(this, arguments);
  161. this.parentNode.replaceChild(frag, this);
  162. }
  163. },
  164. remove: function() {
  165. if (this.parentNode) {
  166. this.parentNode.removeChild(this);
  167. }
  168. }
  169. };
  170. var a = ["Element", "DocumentType", "CharacterData"]; // interface
  171. var b = ["before", "after", "replaceWith", "remove"]; // methods
  172. a.forEach(function(v) {
  173. b.forEach(function(func) {
  174. if (window[v]) {
  175. if (window[v].prototype[func]) { return; }
  176. window[v].prototype[func] = proto[func];
  177. }
  178. });
  179. });
  180. // ParentNode.prepend()
  181. // Source: https://github.com/jserz/js_piece/blob/master/DOM/ParentNode/prepend()/prepend().md
  182. (function(arr) {
  183. arr.forEach(function(item) {
  184. if (item.hasOwnProperty('prepend')) {
  185. return;
  186. }
  187. Object.defineProperty(item, 'prepend', {
  188. configurable: true,
  189. enumerable: true,
  190. writable: true,
  191. value: function prepend() {
  192. var argArr = Array.prototype.slice.call(arguments),
  193. docFrag = document.createDocumentFragment();
  194. argArr.forEach(function(argItem) {
  195. var isNode = argItem instanceof Node;
  196. docFrag.appendChild(isNode ? argItem : document.createTextNode(String(argItem)));
  197. });
  198. this.insertBefore(docFrag, this.firstChild);
  199. }
  200. });
  201. });
  202. })([Element.prototype, Document.prototype, DocumentFragment.prototype]);
  203. // Object.assign() (MDN)
  204. if (typeof Object.assign != 'function') {
  205. (function () {
  206. Object.assign = function (target) {
  207. // We must check against these specific cases.
  208. if (target === undefined || target === null) {
  209. throw new TypeError('Cannot convert undefined or null to object');
  210. }
  211. var output = Object(target);
  212. for (var index = 1; index < arguments.length; index++) {
  213. var source = arguments[index];
  214. if (source !== undefined && source !== null) {
  215. for (var nextKey in source) {
  216. if (source.hasOwnProperty(nextKey)) {
  217. output[nextKey] = source[nextKey];
  218. }
  219. }
  220. }
  221. }
  222. return output;
  223. };
  224. })();
  225. }
  226. // Element.prototype.matches (https://plainjs.com/javascript/traversing/get-closest-element-by-selector-39/)
  227. window.Element && function(ElementPrototype) {
  228. ElementPrototype.matches = ElementPrototype.matches ||
  229. ElementPrototype.matchesSelector ||
  230. ElementPrototype.webkitMatchesSelector ||
  231. ElementPrototype.msMatchesSelector ||
  232. function(selector) {
  233. var node = this, nodes = (node.parentNode || node.document).querySelectorAll(selector), i = -1;
  234. while (nodes[++i] && nodes[i] != node);
  235. return !!nodes[i];
  236. };
  237. }(Element.prototype);
  238. // Element.prototype.closest (https://plainjs.com/javascript/traversing/get-closest-element-by-selector-39/)
  239. window.Element && function(ElementPrototype) {
  240. ElementPrototype.closest = ElementPrototype.closest ||
  241. function(selector) {
  242. var el = this;
  243. while (el.matches && !el.matches(selector)) el = el.parentNode;
  244. return el.matches ? el : null;
  245. };
  246. }(Element.prototype);
  247. }());
  248. /*
  249. * classList.js: Cross-browser full element.classList implementation.
  250. * 1.1.20150312
  251. *
  252. * By Eli Grey, http://eligrey.com
  253. * License: Dedicated to the public domain.
  254. * See https://github.com/eligrey/classList.js/blob/master/LICENSE.md
  255. */
  256. /*global self, document, DOMException */
  257. /*! @source http://purl.eligrey.com/github/classList.js/blob/master/classList.js */
  258. if ("document" in self) {
  259. // Full polyfill for browsers with no classList support
  260. // Including IE < Edge missing SVGElement.classList
  261. if (!("classList" in document.createElement("_"))
  262. || document.createElementNS && !("classList" in document.createElementNS("http://www.w3.org/2000/svg","g"))) {
  263. (function (view) {
  264. "use strict";
  265. if (!('Element' in view)) return;
  266. var
  267. classListProp = "classList"
  268. , protoProp = "prototype"
  269. , elemCtrProto = view.Element[protoProp]
  270. , objCtr = Object
  271. , strTrim = String[protoProp].trim || function () {
  272. return this.replace(/^\s+|\s+$/g, "");
  273. }
  274. , arrIndexOf = Array[protoProp].indexOf || function (item) {
  275. var
  276. i = 0
  277. , len = this.length
  278. ;
  279. for (; i < len; i++) {
  280. if (i in this && this[i] === item) {
  281. return i;
  282. }
  283. }
  284. return -1;
  285. }
  286. // Vendors: please allow content code to instantiate DOMExceptions
  287. , DOMEx = function (type, message) {
  288. this.name = type;
  289. this.code = DOMException[type];
  290. this.message = message;
  291. }
  292. , checkTokenAndGetIndex = function (classList, token) {
  293. if (token === "") {
  294. throw new DOMEx(
  295. "SYNTAX_ERR"
  296. , "An invalid or illegal string was specified"
  297. );
  298. }
  299. if (/\s/.test(token)) {
  300. throw new DOMEx(
  301. "INVALID_CHARACTER_ERR"
  302. , "String contains an invalid character"
  303. );
  304. }
  305. return arrIndexOf.call(classList, token);
  306. }
  307. , ClassList = function (elem) {
  308. var
  309. trimmedClasses = strTrim.call(elem.getAttribute("class") || "")
  310. , classes = trimmedClasses ? trimmedClasses.split(/\s+/) : []
  311. , i = 0
  312. , len = classes.length
  313. ;
  314. for (; i < len; i++) {
  315. this.push(classes[i]);
  316. }
  317. this._updateClassName = function () {
  318. elem.setAttribute("class", this.toString());
  319. };
  320. }
  321. , classListProto = ClassList[protoProp] = []
  322. , classListGetter = function () {
  323. return new ClassList(this);
  324. }
  325. ;
  326. // Most DOMException implementations don't allow calling DOMException's toString()
  327. // on non-DOMExceptions. Error's toString() is sufficient here.
  328. DOMEx[protoProp] = Error[protoProp];
  329. classListProto.item = function (i) {
  330. return this[i] || null;
  331. };
  332. classListProto.contains = function (token) {
  333. token += "";
  334. return checkTokenAndGetIndex(this, token) !== -1;
  335. };
  336. classListProto.add = function () {
  337. var
  338. tokens = arguments
  339. , i = 0
  340. , l = tokens.length
  341. , token
  342. , updated = false
  343. ;
  344. do {
  345. token = tokens[i] + "";
  346. if (checkTokenAndGetIndex(this, token) === -1) {
  347. this.push(token);
  348. updated = true;
  349. }
  350. }
  351. while (++i < l);
  352. if (updated) {
  353. this._updateClassName();
  354. }
  355. };
  356. classListProto.remove = function () {
  357. var
  358. tokens = arguments
  359. , i = 0
  360. , l = tokens.length
  361. , token
  362. , updated = false
  363. , index
  364. ;
  365. do {
  366. token = tokens[i] + "";
  367. index = checkTokenAndGetIndex(this, token);
  368. while (index !== -1) {
  369. this.splice(index, 1);
  370. updated = true;
  371. index = checkTokenAndGetIndex(this, token);
  372. }
  373. }
  374. while (++i < l);
  375. if (updated) {
  376. this._updateClassName();
  377. }
  378. };
  379. classListProto.toggle = function (token, force) {
  380. token += "";
  381. var
  382. result = this.contains(token)
  383. , method = result ?
  384. force !== true && "remove"
  385. :
  386. force !== false && "add"
  387. ;
  388. if (method) {
  389. this[method](token);
  390. }
  391. if (force === true || force === false) {
  392. return force;
  393. } else {
  394. return !result;
  395. }
  396. };
  397. classListProto.toString = function () {
  398. return this.join(" ");
  399. };
  400. if (objCtr.defineProperty) {
  401. var classListPropDesc = {
  402. get: classListGetter
  403. , enumerable: true
  404. , configurable: true
  405. };
  406. try {
  407. objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc);
  408. } catch (ex) { // IE 8 doesn't support enumerable:true
  409. if (ex.number === -0x7FF5EC54) {
  410. classListPropDesc.enumerable = false;
  411. objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc);
  412. }
  413. }
  414. } else if (objCtr[protoProp].__defineGetter__) {
  415. elemCtrProto.__defineGetter__(classListProp, classListGetter);
  416. }
  417. }(self));
  418. } else {
  419. // There is full or partial native classList support, so just check if we need
  420. // to normalize the add/remove and toggle APIs.
  421. (function () {
  422. "use strict";
  423. var testElement = document.createElement("_");
  424. testElement.classList.add("c1", "c2");
  425. // Polyfill for IE 10/11 and Firefox <26, where classList.add and
  426. // classList.remove exist but support only one argument at a time.
  427. if (!testElement.classList.contains("c2")) {
  428. var createMethod = function(method) {
  429. var original = DOMTokenList.prototype[method];
  430. DOMTokenList.prototype[method] = function(token) {
  431. var i, len = arguments.length;
  432. for (i = 0; i < len; i++) {
  433. token = arguments[i];
  434. original.call(this, token);
  435. }
  436. };
  437. };
  438. createMethod('add');
  439. createMethod('remove');
  440. }
  441. testElement.classList.toggle("c3", false);
  442. // Polyfill for IE 10 and Firefox <24, where classList.toggle does not
  443. // support the second argument.
  444. if (testElement.classList.contains("c3")) {
  445. var _toggle = DOMTokenList.prototype.toggle;
  446. DOMTokenList.prototype.toggle = function(token, force) {
  447. if (1 in arguments && !this.contains(token) === !force) {
  448. return force;
  449. } else {
  450. return _toggle.call(this, token);
  451. }
  452. };
  453. }
  454. testElement = null;
  455. }());
  456. }
  457. }
  458. (function(undefined) {
  459. 'use strict';
  460. // Namespace
  461. window.VAMTAM = window.VAMTAM || {};
  462. window.VAMTAM.MEDIA = window.VAMTAM.MEDIA || {
  463. layout: {}
  464. };
  465. var LAYOUT_SIZES = [{
  466. min: 0,
  467. max: window.VAMTAM_FRONT.beaver_small,
  468. className: 'layout-small'
  469. }, {
  470. min: window.VAMTAM_FRONT.beaver_responsive + 1,
  471. max: Infinity,
  472. className: 'layout-max'
  473. }, {
  474. min: window.VAMTAM_FRONT.beaver_responsive + 1,
  475. max: window.VAMTAM_FRONT.content_width,
  476. className: 'layout-max-low'
  477. }, {
  478. min: 0,
  479. max: window.VAMTAM_FRONT.beaver_responsive,
  480. className: 'layout-below-max'
  481. } ];
  482. document.addEventListener('DOMContentLoaded', function () {
  483. if ( document.body.classList.contains( 'responsive-layout' ) && 'matchMedia' in window ) {
  484. var sizesLength = LAYOUT_SIZES.length;
  485. var remap = window.VAMTAM.debounce( function() {
  486. var map = {};
  487. for ( var i = 0; i < sizesLength; i++ ) {
  488. var mq = '(min-width: '+LAYOUT_SIZES[i].min+'px)';
  489. if ( LAYOUT_SIZES[i].max !== Infinity )
  490. mq += ' and (max-width: '+LAYOUT_SIZES[i].max+'px)';
  491. if ( window.matchMedia(mq).matches ) {
  492. map[LAYOUT_SIZES[i].className] = true;
  493. }
  494. else {
  495. map[LAYOUT_SIZES[i].className] = false;
  496. }
  497. }
  498. window.VAMTAM.MEDIA.layout = map;
  499. }, 100 );
  500. window.addEventListener( 'resize', remap, false );
  501. window.addEventListener( 'load', remap, false );
  502. remap();
  503. } else {
  504. window.VAMTAM.MEDIA.layout = { 'layout-max': true, 'layout-below-max': false };
  505. }
  506. } );
  507. })();
  508. (function($, v, undefined) {
  509. "use strict";
  510. vamtam_greensock_wait( function() {
  511. var mainHeader = $('header.main-header');
  512. var main = $( '#main' );
  513. var body = $( 'body' );
  514. var header_contents = mainHeader.find( '.header-contents' );
  515. var menu_toggle = document.getElementById( 'vamtam-megamenu-main-menu-toggle' );
  516. var original_toggle = document.querySelector( '#main-menu > .mega-menu-wrap > .mega-menu-toggle' );
  517. // main menu custom toggle
  518. if ( menu_toggle ) {
  519. menu_toggle.addEventListener( 'click', function( e ) {
  520. e.preventDefault();
  521. requestAnimationFrame( function() {
  522. var is_open = original_toggle.classList.contains( 'mega-menu-open' );
  523. menu_toggle.classList.toggle( 'mega-menu-open', ! is_open );
  524. original_toggle.classList.toggle( 'mega-menu-open', ! is_open );
  525. } );
  526. } );
  527. }
  528. // overlay menu
  529. var overlay_menu = document.getElementById( 'vamtam-overlay-menu' );
  530. var overlay_menu_toggle = document.querySelector( '.vamtam-overlay-menu-toggle' );
  531. var overlay_open = false;
  532. var toggle_clone;
  533. var toggle_overlay_menu = function( e ) {
  534. e.preventDefault();
  535. requestAnimationFrame( function() {
  536. overlay_open = ! overlay_open;
  537. if ( overlay_open ) {
  538. toggle_clone = overlay_menu_toggle.cloneNode( true );
  539. // measure
  540. var offset = overlay_menu_toggle.getBoundingClientRect();
  541. // mutate
  542. document.body.appendChild( toggle_clone );
  543. Object.assign( toggle_clone.style, {
  544. position: 'fixed',
  545. top: offset.top + 'px',
  546. left: offset.left + 'px',
  547. } );
  548. requestAnimationFrame( function() {
  549. overlay_menu.classList.add( 'open' );
  550. toggle_clone.classList.add( 'is-active' );
  551. } );
  552. } else {
  553. toggle_clone.classList.remove( 'is-active' );
  554. overlay_menu.classList.remove( 'open' );
  555. setTimeout( function() {
  556. requestAnimationFrame( function() {
  557. toggle_clone.remove();
  558. } );
  559. }, 650 );
  560. }
  561. } );
  562. };
  563. document.body.addEventListener( 'click', function( e ) {
  564. var button = e.target.closest( 'button' );
  565. if ( button && button.classList.contains( 'vamtam-overlay-menu-toggle' ) ) {
  566. toggle_overlay_menu( e );
  567. }
  568. } );
  569. // add left/right classes to submenus depending on resolution
  570. var allSubMenus = $( '#main-menu .sub-menu, #top-nav-wrapper .sub-menu' );
  571. window.addEventListener( 'resize', window.VAMTAM.debounce( function() {
  572. var winWidth = window.innerWidth;
  573. allSubMenus.show().removeClass( 'invert-position' ).each( function() {
  574. if ( $( this ).offset().left + $( this ).width() > winWidth ) {
  575. $( this ).addClass( 'invert-position' );
  576. }
  577. } );
  578. allSubMenus.css( 'display', '' );
  579. }, 100 ), false );
  580. // scrolling below
  581. var smoothScrollTimer, smoothScrollCallback;
  582. var smoothScrollListener = function() {
  583. clearTimeout( smoothScrollTimer );
  584. smoothScrollTimer = setTimeout( scrollToElComplete, 200 );
  585. };
  586. var scrollToElComplete = function() {
  587. window.removeEventListener( 'scroll', smoothScrollListener, { passive: true } );
  588. v.blockStickyHeaderAnimation = false;
  589. setTimeout( function() {
  590. requestAnimationFrame( function() {
  591. document.body.classList.remove( 'no-sticky-header-animation-tmp' );
  592. } );
  593. }, 50 );
  594. if ( smoothScrollCallback ) {
  595. smoothScrollCallback();
  596. }
  597. };
  598. var scrollToEl = function( el, duration, callback ) {
  599. requestAnimationFrame( function() {
  600. var el_offset = el.offset().top;
  601. v.blockStickyHeaderAnimation = true;
  602. // measure header height
  603. var header_height = 0;
  604. if ( mainHeader.hasClass( 'layout-standard' ) || mainHeader.hasClass( 'logo-text-menu' ) ) {
  605. if ( el_offset >= main.offset().top ) {
  606. header_height = mainHeader.find( '.second-row-columns' ).height();
  607. } else {
  608. header_height = mainHeader.height();
  609. }
  610. } else {
  611. if ( body.hasClass( 'no-sticky-header-animation' ) ) {
  612. // single line header with a special page template
  613. header_height = mainHeader.height();
  614. } else {
  615. header_height = header_contents.height();
  616. if ( 'stickyHeader' in v ) {
  617. v.stickyHeader.singleRowStick();
  618. }
  619. // in this case stick the header,
  620. // we'd like the menu to be visible after scrolling
  621. document.body.classList.add( 'no-sticky-header-animation-tmp' );
  622. }
  623. }
  624. var scroll_position = el_offset - v.admin_bar_fix - header_height;
  625. smoothScrollCallback = callback;
  626. window.addEventListener( 'scroll', smoothScrollListener, { passive: true } );
  627. window.scroll( { left: 0, top: scroll_position, behavior: 'smooth' } );
  628. if ( el.attr( 'id' ) ) {
  629. if ( history.pushState ) {
  630. history.pushState( null, null, '#' + el.attr( 'id' ) );
  631. } else {
  632. window.location.hash = el.attr( 'id' );
  633. }
  634. }
  635. menu_toggle && menu_toggle.classList.remove( 'mega-menu-open' );
  636. original_toggle && original_toggle.classList.remove( 'mega-menu-open' );
  637. } );
  638. };
  639. window.FLBuilderLayout && Object.assign( window.FLBuilderLayout, {
  640. /**
  641. * Monkey patches the built-in animated scroll with a better implementation
  642. * which does not use jQuery
  643. */
  644. _scrollToElement: function( el, callback ) {
  645. var config = window.FLBuilderLayoutConfig.anchorLinkAnimations;
  646. if ( el.length ) {
  647. menu_toggle.classList.toggle( 'mega-menu-open', false );
  648. original_toggle.classList.toggle( 'mega-menu-open', false );
  649. scrollToEl( el, config.duration / 1000, callback );
  650. }
  651. },
  652. } );
  653. $( document.body ).on('click', '.vamtam-animated-page-scroll[href], .vamtam-animated-page-scroll [href], .vamtam-animated-page-scroll [data-href], .mega-vamtam-animated-page-scroll[href], .mega-vamtam-animated-page-scroll [href], .mega-vamtam-animated-page-scroll [data-href]', function(e) {
  654. var href = $( this ).prop( 'href' ) || $( this ).data( 'href' );
  655. var el = $( '#' + ( href ).split( "#" )[1] );
  656. var l = document.createElement('a');
  657. l.href = href;
  658. if(el.length && l.pathname === window.location.pathname) {
  659. menu_toggle.classList.toggle( 'mega-menu-open', false );
  660. original_toggle.classList.toggle( 'mega-menu-open', false );
  661. scrollToEl( el );
  662. e.preventDefault();
  663. }
  664. });
  665. if ( window.location.hash !== "" &&
  666. (
  667. $( '.vamtam-animated-page-scroll[href*="' + window.location.hash + '"]' ).length ||
  668. $( '.vamtam-animated-page-scroll [href*="' + window.location.hash + '"]').length ||
  669. $( '.vamtam-animated-page-scroll [data-href*="'+window.location.hash+'"]' ).length ||
  670. $( '.mega-vamtam-animated-page-scroll[href*="' + window.location.hash + '"]' ).length ||
  671. $( '.mega-vamtam-animated-page-scroll [href*="' + window.location.hash + '"]').length ||
  672. $( '.mega-vamtam-animated-page-scroll [data-href*="'+window.location.hash+'"]' ).length
  673. )
  674. ) {
  675. var el = $( window.location.hash );
  676. if ( el.length > 0 ) {
  677. $( window ).add( 'html, body, #page' ).scrollTop( 0 );
  678. }
  679. setTimeout( function() {
  680. scrollToEl( el );
  681. }, 400 );
  682. }
  683. // adds .current-menu-item classes
  684. var hashes = [
  685. // ['top', $('<div></div>'), $('#top')]
  686. ];
  687. $('#main-menu').find('.mega-menu, .menu').find('.maybe-current-menu-item, .mega-current-menu-item, .current-menu-item').each(function() {
  688. var link = $('> a', this);
  689. if(link.prop('href').indexOf('#') > -1) {
  690. var link_hash = link.prop('href').split('#')[1];
  691. if('#'+link_hash !== window.location.hash) {
  692. $(this).removeClass('mega-current-menu-item current-menu-item');
  693. }
  694. hashes.push([link_hash, $(this), $('#'+link_hash)]);
  695. }
  696. });
  697. if ( hashes.length ) {
  698. var winHeight = 0;
  699. var documentHeight = 0;
  700. var prev_upmost_data = null;
  701. v.addScrollHandler( {
  702. init: function() {},
  703. add_current_menu_item: function( hash ) {
  704. // there may be more than one links with the same hash,
  705. // so we need to loop over all of the hashes
  706. for ( var i = 0; i < hashes.length; i++ ) {
  707. if ( hashes[i][0] === hash ) {
  708. hashes[i][1][0].classList.add( 'mega-current-menu-item', 'current-menu-item' );
  709. }
  710. }
  711. },
  712. measure: function( cpos ) {
  713. winHeight = window.innerHeight;
  714. documentHeight = document.body.offsetHeight;
  715. this.upmost = Infinity;
  716. this.upmost_data = null;
  717. for ( var i = 0; i < hashes.length; i++ ) {
  718. var el = hashes[i][2];
  719. if ( el.length ) {
  720. var top = el.offset().top + 10;
  721. if (
  722. top > cpos &&
  723. top < this.upmost &&
  724. (
  725. top < cpos + winHeight / 2 ||
  726. ( top < cpos + winHeight && cpos + winHeight === documentHeight )
  727. )
  728. ) {
  729. this.upmost_data = hashes[i];
  730. this.upmost = top;
  731. }
  732. }
  733. }
  734. },
  735. mutate: function( cpos ) {
  736. for ( var i = 0; i < hashes.length; i++ ) {
  737. if ( hashes[i][2].length ) {
  738. hashes[i][1][0].classList.remove( 'mega-current-menu-item', 'current-menu-item' );
  739. hashes[i][1][0].childNodes[0].blur();
  740. }
  741. }
  742. if ( this.upmost_data ) {
  743. this.add_current_menu_item( this.upmost_data[0] );
  744. // attempt to push a state to the history if the current hash is different from the previous one
  745. if ( 'history' in window && ( prev_upmost_data !== null ? prev_upmost_data[0] : '' ) !== this.upmost_data[0] ) {
  746. window.history.pushState(
  747. this.upmost_data[0],
  748. $( '> a', this.upmost_data[1] ).text(),
  749. ( cpos !== 0 ? '#' + this.upmost_data[0] : location.href.replace( location.hash, '' ) )
  750. );
  751. prev_upmost_data = $.extend({}, this.upmost_data);
  752. }
  753. } else if ( this.upmost_data === null && prev_upmost_data !== null ) {
  754. this.add_current_menu_item( prev_upmost_data[0] );
  755. }
  756. }
  757. } );
  758. }
  759. });
  760. })( jQuery, window.VAMTAM );
  761. ( function( v, undefined ) {
  762. 'use strict';
  763. // this one can be initialized late (on load) instead of on DOMContentLoaded
  764. window.addEventListener( 'load', function() {
  765. var columns = document.querySelectorAll( '[data-progressive-animation]' );
  766. if ( columns.length && ! document.body.classList.contains( 'fl-builder-active' ) ) {
  767. vamtam_greensock_wait( function() {
  768. v.addScrollHandler( {
  769. defaultOptions: {
  770. origin: 'center center',
  771. type: 'progressive',
  772. exit: true,
  773. delay: 0,
  774. mobile: false,
  775. pin: false,
  776. pinTrigger: 'center',
  777. },
  778. blockAnimations: false,
  779. canActivate: function( mobile ) {
  780. return mobile || ! v.MEDIA.layout[ 'layout-below-max' ];
  781. },
  782. buildTimeline: function( target, withExit ) {
  783. var timeline = new vamtamgs.TimelineLite( { paused: true } );
  784. var type = target.getAttribute( 'data-progressive-animation' );
  785. if ( type === 'dummy' ) {
  786. timeline.fromTo( target, 1, { opacity: 1 }, {opacity: 1 }, '0' );
  787. withExit && timeline.to( target, 1, { opacity: 1 }, '1' );
  788. } else if ( type === 'rotate' ) {
  789. timeline.fromTo( target, 1, { rotation: -180 }, { rotation: 0 }, '0' );
  790. withExit && timeline.to( target, 1, { rotation: 180 }, '1' );
  791. } else if ( type === 'fade' ) {
  792. timeline.fromTo( target, 1, {
  793. opacity: 0,
  794. }, {
  795. opacity: 1,
  796. }, '0' );
  797. withExit && timeline.to( target, 0.4, { opacity: 0 }, '1.6' );
  798. withExit && timeline.to( target, 1, { y: -100 }, '1.6' );
  799. // Move + Fade //
  800. } else if ( type === 'move-from-top' ) {
  801. timeline.fromTo( target, 1, {
  802. y: -160,
  803. opacity: 0,
  804. }, {
  805. y: 0,
  806. opacity: 1,
  807. }, '0' );
  808. withExit && timeline.to( target, 0.4, { opacity: 0 }, '1.6' );
  809. withExit && timeline.to( target, 1, { y: -100 }, '1.6' );
  810. } else if ( type === 'move-from-bottom' ) {
  811. timeline.fromTo( target, 1, {
  812. y: 100,
  813. opacity: 0,
  814. }, {
  815. y: 0,
  816. opacity: 1,
  817. }, '0' );
  818. withExit && timeline.to( target, 0.4, { opacity: 0 }, '1.6' );
  819. withExit && timeline.to( target, 1, { y: -50 }, '1.6' );
  820. } else if ( type === 'move-from-left' ) {
  821. timeline.fromTo( target, 1, {
  822. x: -160,
  823. opacity: 0,
  824. }, {
  825. x: 0,
  826. opacity: 1,
  827. }, '0' );
  828. withExit && timeline.to( target, 0.4, { opacity: 0 }, '1.6' );
  829. withExit && timeline.to( target, 1, { x: -100 }, '1.6' );
  830. } else if ( type === 'move-from-right' ) {
  831. timeline.fromTo( target, 1, {
  832. x: 160,
  833. opacity: 0,
  834. }, {
  835. x: 0,
  836. opacity: 1,
  837. }, '0' );
  838. withExit && timeline.to( target, 0.4, { opacity: 0 }, '1.6' );
  839. withExit && timeline.to( target, 1, { x: 100 }, '1.6' );
  840. // Scale //
  841. } else if ( type === 'scale-in' ) {
  842. timeline.fromTo( target, 1, {
  843. opacity: 0,
  844. scaleX: 0.0,
  845. scaleY: 0.0,
  846. }, {
  847. opacity: 1,
  848. scaleX: 1,
  849. scaleY: 1,
  850. }, '0' );
  851. withExit && timeline.to( target, 0.4, { opacity: 0 }, '1.6' );
  852. } else if ( type === 'scale-out' ) {
  853. timeline.fromTo( target, 1, {
  854. opacity: 0,
  855. scaleX: 2,
  856. scaleY: 2,
  857. }, {
  858. opacity: 1,
  859. scaleX: 1,
  860. scaleY: 1,
  861. }, '0' );
  862. withExit && timeline.to( target, 0.4, { opacity: 0 }, '1.6' );
  863. // Move + Scale //
  864. // Zoom In //
  865. } else if ( type === 'move-scale-in-from-top' ) {
  866. timeline.fromTo( target, 1, {
  867. y: -160,
  868. opacity: 0,
  869. scaleX: 0.6,
  870. scaleY: 0.6,
  871. }, {
  872. y: 0,
  873. opacity: 1,
  874. scaleX: 1,
  875. scaleY: 1,
  876. }, '0' );
  877. withExit && timeline.to( target, 0.4, { opacity: 0 }, '1.6' );
  878. withExit && timeline.to( target, 1, { y: -100 }, '1.6' );
  879. } else if ( type === 'move-scale-in-from-bottom' ) {
  880. timeline.fromTo( target, 1, {
  881. y: 160,
  882. opacity: 0,
  883. scaleX: 0.6,
  884. scaleY: 0.6,
  885. }, {
  886. y: 0,
  887. opacity: 1,
  888. scaleX: 1,
  889. scaleY: 1,
  890. }, '0' );
  891. withExit && timeline.to( target, 0.4, { opacity: 0 }, '1.6' );
  892. withExit && timeline.to( target, 1, { y: -100 }, '1.6' );
  893. } else if ( type === 'move-scale-in-from-left' ) {
  894. timeline.fromTo( target, 1, {
  895. x: -160,
  896. opacity: 0,
  897. scaleX: 0.6,
  898. scaleY: 0.6,
  899. }, {
  900. x: 0,
  901. opacity: 1,
  902. scaleX: 1,
  903. scaleY: 1,
  904. }, '0' );
  905. withExit && timeline.to( target, 0.4, { opacity: 0 }, '1.6' );
  906. withExit && timeline.to( target, 1, { x: -100 }, '1.6' );
  907. } else if ( type === 'move-scale-in-from-right' ) {
  908. timeline.fromTo( target, 1, {
  909. x: 160,
  910. opacity: 0,
  911. scaleX: 0.6,
  912. scaleY: 0.6,
  913. }, {
  914. x: 0,
  915. opacity: 1,
  916. scaleX: 1,
  917. scaleY: 1,
  918. }, '0' );
  919. withExit && timeline.to( target, 0.4, { opacity: 0 }, '1.6' );
  920. withExit && timeline.to( target, 1, { x: 100 }, '1.6' );
  921. // Zoom Out //
  922. } else if ( type === 'move-scale-out-from-top' ) {
  923. timeline.fromTo( target, 1, {
  924. y: -160,
  925. opacity: 0,
  926. scaleX: 1.6,
  927. scaleY: 1.6,
  928. }, {
  929. y: 0,
  930. opacity: 1,
  931. scaleX: 1,
  932. scaleY: 1,
  933. }, '0' );
  934. withExit && timeline.to( target, 0.4, { opacity: 0 }, '1.6' );
  935. withExit && timeline.to( target, 1, { y: -100 }, '1.6' );
  936. } else if ( type === 'move-scale-out-from-bottom' ) {
  937. timeline.fromTo( target, 1, {
  938. y: 160,
  939. opacity: 0,
  940. scaleX: 1.6,
  941. scaleY: 1.6,
  942. }, {
  943. y: 0,
  944. opacity: 1,
  945. scaleX: 1,
  946. scaleY: 1,
  947. }, '0' );
  948. withExit && timeline.to( target, 0.4, { opacity: 0 }, '1.6' );
  949. withExit && timeline.to( target, 1, { y: -100 }, '1.6' );
  950. } else if ( type === 'move-scale-out-from-left' ) {
  951. timeline.fromTo( target, 1, {
  952. x: -160,
  953. opacity: 0,
  954. scaleX: 1.6,
  955. scaleY: 1.6,
  956. }, {
  957. x: 0,
  958. opacity: 1,
  959. scaleX: 1,
  960. scaleY: 1,
  961. }, '0' );
  962. withExit && timeline.to( target, 0.4, { opacity: 0 }, '1.6' );
  963. withExit && timeline.to( target, 1, { x: -100 }, '1.6' );
  964. } else if ( type === 'move-scale-out-from-right' ) {
  965. timeline.fromTo( target, 1, {
  966. x: 160,
  967. opacity: 0,
  968. scaleX: 1.6,
  969. scaleY: 1.6,
  970. }, {
  971. x: 0,
  972. opacity: 1,
  973. scaleX: 1,
  974. scaleY: 1,
  975. }, '0' );
  976. withExit && timeline.to( target, 0.4, { opacity: 0 }, '1.6' );
  977. withExit && timeline.to( target, 1, { x: 100 }, '1.6' );
  978. // Rotate //
  979. } else if ( type === 'rotate-from-top-right' ) {
  980. timeline.fromTo( target, 1, {
  981. y: -200,
  982. x: 120,
  983. rotation: -10,
  984. opacity: 0,
  985. }, {
  986. y: 0,
  987. x: 0,
  988. rotation: 0,
  989. opacity: 1,
  990. }, '0' );
  991. withExit && timeline.fromTo( target, 1, { immediateRender: false, y: 0 }, { y: -70 }, '1.6' );
  992. } else if ( type === 'page-title' ) {
  993. var line = target.querySelector( '.page-header-line' );
  994. var desc = target.querySelector( '.desc' );
  995. var shadow = document.getElementById( 'sub-header' ).querySelector( '.text-shadow' );
  996. timeline.fromTo( target.querySelector( 'h1' ), 0.9, { y: 0, opacity: 1 }, { y: -10, opacity: 0, ease: vamtamgs.Quad.easeIn }, '0.1' );
  997. desc && timeline.fromTo( desc, 1, { y: 0, opacity: 1 }, { y: 30, opacity: 0, ease: vamtamgs.Quad.easeIn }, '0' );
  998. shadow && timeline.fromTo( shadow, 1, { opacity: 0.3 }, { opacity: 0.7, ease: vamtamgs.Quad.easeIn }, '0' );
  999. line && timeline.to( line, 1, { scaleX: 0, y: 30, opacity: 0, ease: vamtamgs.Quad.easeIn }, '0' );
  1000. } else if ( type === 'custom' ) {
  1001. timeline.to( target, 1, { className: target.getAttribute( 'data-progressive-animation-custom' ) }, '1' );
  1002. }
  1003. return timeline;
  1004. },
  1005. getPinTrigger: function( column ) {
  1006. if ( column.options.pinTrigger === 'center' ) {
  1007. return this.winHeight / 2 - column.height / 2;
  1008. }
  1009. if ( column.options.pinTrigger === 'bottom' ) {
  1010. return this.winHeight - column.height;
  1011. }
  1012. if ( column.options.pinTrigger === 'top' ) {
  1013. return 0;
  1014. }
  1015. },
  1016. calculatePinDuration: function( column ) {
  1017. if ( v.MEDIA.layout[ 'layout-below-max' ] ) {
  1018. column.vamtamProgressiveTimeline.pinDuration = 0;
  1019. } else if ( column.vamtamProgressiveTimeline.options.pin === 'parent' ) {
  1020. var closestRow = column.closest( '.fl-row-content' );
  1021. column.vamtamProgressiveTimeline.pinDuration = closestRow.offsetHeight - ( column.vamtamProgressiveTimeline.top - v.offset( closestRow ).top );
  1022. } else {
  1023. column.vamtamProgressiveTimeline.pinDuration = + column.vamtamProgressiveTimeline.options.pin;
  1024. }
  1025. },
  1026. onresize: function() {
  1027. var self = this;
  1028. this.winHeight = window.innerHeight;
  1029. this.blockAnimations = true;
  1030. requestAnimationFrame( function() {
  1031. // if the timeline was previously initialized - reset the progress to 0
  1032. for ( var i = 0; i < columns.length; i++ ) {
  1033. if ( columns[i].vamtamProgressiveTimeline.timeline ) {
  1034. columns[i].vamtamProgressiveTimeline.timeline.progress( 0 );
  1035. }
  1036. if ( columns[i].vamtamProgressiveTimeline.wrapper ) {
  1037. Object.assign( columns[i].vamtamProgressiveTimeline.pusher.style, {
  1038. top: '',
  1039. width: '',
  1040. height: '',
  1041. } );
  1042. Object.assign( columns[i].vamtamProgressiveTimeline.wrapper.style, {
  1043. top: '',
  1044. width: '',
  1045. height: '',
  1046. position: '',
  1047. } );
  1048. }
  1049. }
  1050. requestAnimationFrame( function() {
  1051. var cpos = window.pageYOffset;
  1052. var i;
  1053. var chromeWrapperFix = [];
  1054. // measure
  1055. for ( i = 0; i < columns.length; i++ ) {
  1056. var columnTop = v.offset( columns[i] ).top;
  1057. Object.assign( columns[i].vamtamProgressiveTimeline, {
  1058. top: columnTop,
  1059. height: columns[i].offsetHeight,
  1060. width: columns[i].offsetWidth,
  1061. } );
  1062. self.calculatePinDuration( columns[i] );
  1063. }
  1064. // mutate
  1065. for ( i = 0; i < columns.length; i++ ) {
  1066. var data = columns[i].vamtamProgressiveTimeline;
  1067. if ( self.canActivate( data.options.mobile ) ) {
  1068. data.timeline = self.buildTimeline(
  1069. columns[i],
  1070. data.options.type === 'progressive' && data.options.exit
  1071. );
  1072. if ( data.pusher ) {
  1073. data.pusher.parentElement.minHeight = data.options.pin + 'px';
  1074. data.pusher.style.height = data.pinDuration + 'px';
  1075. if ( ! data.pusher.classList.contains( 'fl-col' ) ) {
  1076. data.pusher.style.width = data.width + 'px';
  1077. }
  1078. data.wrapper.style.height = data.height + 'px';
  1079. data.wrapper.style.top = self.getPinTrigger( data ) + 'px';
  1080. data.wrapper.classList.add( 'vamtam-pin-active' );
  1081. }
  1082. } else if ( data.timeline ) {
  1083. data.timeline.seek( 1 );
  1084. data.timeline = null;
  1085. if ( data.pusher ) {
  1086. data.pusher.parentElement.minHeight = '';
  1087. data.wrapper.classList.remove( 'vamtam-pin-active' );
  1088. /*
  1089. Fix a weird Chrome bug where the wrapper
  1090. behaves as if it has visibility: hidden
  1091. after disabling the pin for narrow screens
  1092. */
  1093. data.wrapper.style.display = 'block';
  1094. chromeWrapperFix.push( data.wrapper );
  1095. /* End Chrome fix */
  1096. }
  1097. }
  1098. }
  1099. (function( wrappers ) {
  1100. requestAnimationFrame( function() {
  1101. wrappers.forEach( function( wrapper ) {
  1102. wrapper.style.display = '';
  1103. } );
  1104. } );
  1105. })( chromeWrapperFix );
  1106. self.blockAnimations = false;
  1107. self.measure( cpos );
  1108. self.mutate( cpos );
  1109. } );
  1110. } );
  1111. },
  1112. init: function() {
  1113. this.winHeight = window.innerHeight;
  1114. var i, closestRow;
  1115. // measure
  1116. for ( i = 0; i < columns.length; i++ ) {
  1117. var options = Object.assign( {}, this.defaultOptions, JSON.parse( columns[i].getAttribute( 'data-vamtam-animation-options' ) ) || {} );
  1118. var columnTop = v.offset( columns[i] ).top;
  1119. columns[i].vamtamProgressiveTimeline = {
  1120. top: columnTop,
  1121. height: columns[i].offsetHeight,
  1122. width: columns[i].offsetWidth,
  1123. options: options
  1124. };
  1125. this.calculatePinDuration( columns[i] );
  1126. columns[i].style.transformOrigin = columns[i].vamtamProgressiveTimeline.options.origin;
  1127. if ( this.canActivate( options.mobile ) ) {
  1128. columns[i].vamtamProgressiveTimeline.timeline = this.buildTimeline(
  1129. columns[i],
  1130. options.type === 'progressive' && options.exit
  1131. );
  1132. } else {
  1133. columns[i].vamtamProgressiveTimeline.timeline = null;
  1134. }
  1135. }
  1136. // mutate
  1137. for ( i = 0; i < columns.length; i++ ) {
  1138. var data = columns[i].vamtamProgressiveTimeline;
  1139. closestRow = columns[i].closest( '.fl-row' );
  1140. closestRow && closestRow.classList.add( 'vamtam-animation-inside' );
  1141. if ( data.options.pin !== false ) {
  1142. closestRow.classList.add( 'vamtam-pin-inside' );
  1143. data.pusher = document.createElement( 'div' );
  1144. data.pusher.classList.add( 'vamtam-pin-pusher' );
  1145. // by default Beaver Builder sets the width of the .fl-col element
  1146. // we need to move the .fl-col class to the wrapper
  1147. // and set the width of the original column to 100%
  1148. if ( columns[i].classList.contains( 'fl-col' ) ) {
  1149. data.pusher.classList.add( 'fl-col' );
  1150. data.pusher.classList.add( 'fl-node-' + columns[i].attributes['data-node'].value );
  1151. data.pusher.style.width = '';
  1152. }
  1153. data.wrapper = document.createElement( 'div' );
  1154. data.wrapper.classList.add( 'vamtam-pin-wrapper' );
  1155. data.wrapper.style.willChange = 'transform, position';
  1156. data.wrapper.style.height = data.height + 'px';
  1157. data.wrapper.style.top = this.getPinTrigger( data ) + 'px';
  1158. columns[i].before( data.pusher );
  1159. data.wrapper.appendChild( columns[i] );
  1160. data.pusher.appendChild( data.wrapper );
  1161. columns[i].style.width = '100%';
  1162. data.pusher.parentElement.style.position = 'relative';
  1163. if ( data.timeline && data.options.pin !== 'parent' ) {
  1164. data.pusher.parentElement.style.minHeight = data.options.pin + 'px';
  1165. }
  1166. if ( this.canActivate( data.options.mobile ) ) {
  1167. Object.assign( data.pusher.style, {
  1168. width: data.width + 'px',
  1169. height: data.pinDuration + 'px',
  1170. });
  1171. data.wrapper.classList.add( 'vamtam-pin-active' );
  1172. }
  1173. }
  1174. }
  1175. window.addEventListener( 'resize', window.VAMTAM.debounce( this.onresize, 100 ).bind( this ), false );
  1176. },
  1177. measure: function() {
  1178. },
  1179. mutate: function( cpos ) {
  1180. if ( this.blockAnimations ) {
  1181. return;
  1182. }
  1183. for ( var i = 0; i < columns.length; i++ ) {
  1184. var data = columns[i].vamtamProgressiveTimeline;
  1185. if ( data.timeline && cpos + this.winHeight > data.top ) {
  1186. // natural column vertical middle
  1187. var from = data.top + data.height / 2;
  1188. var progress;
  1189. if ( data.options.pin !== false ) {
  1190. var pinTrigger;
  1191. if ( data.options.pinTrigger === 'center' ) {
  1192. pinTrigger = cpos + this.winHeight / 2;
  1193. } else if ( data.options.pinTrigger === 'bottom' ) {
  1194. pinTrigger = cpos + this.winHeight - data.height / 2;
  1195. } else if ( data.options.pinTrigger === 'top' ) {
  1196. pinTrigger = cpos + data.height / 2;
  1197. }
  1198. // pin length starts when the "natural column vertical middle"
  1199. // aligns with the trigger (middle of the viewport, top/bottom of viewport - half column height)
  1200. //
  1201. // it ends after data.pinDuration - data.height px
  1202. var pinTo = from + data.pinDuration - data.height;
  1203. progress = 2 * ( pinTrigger - from ) / ( pinTo - from ) - 1;
  1204. } else {
  1205. progress = 1 - ( ( from - cpos ) / Math.min( this.winHeight / 2, from ) );
  1206. }
  1207. progress -= data.options.delay;
  1208. if ( data.options.type === 'progressive' ) {
  1209. if ( data.timeline.totalDuration() > 1 || ! columns[i].vamtamProgressiveTimeline.options.exit ) {
  1210. // two part (entry/exit) animation
  1211. // note that the exit is optional
  1212. progress = Math.min( 1, Math.max( -1, progress ) ); // clip
  1213. // progress + 1 is used so that we can avoid negative position params
  1214. //
  1215. // [0; 1] -> entrance animation
  1216. // [1; 2] -> exit animation
  1217. //
  1218. // it's then divided by two, since the progress() method takes a [0; 1] fraction as its argument
  1219. progress = progress + 1;
  1220. } else {
  1221. // only exit animation
  1222. progress = Math.min( 1, Math.max( 0, progress ) ); // clip
  1223. }
  1224. data.timeline.seek( progress );
  1225. } else {
  1226. if ( ! data.used && progress >= 0 ) {
  1227. data.used = true;
  1228. data.timeline.timeScale( 2 ).play();
  1229. } else if ( data.used ) {
  1230. // if the animation was played once - make sure that the timeline is at its end
  1231. data.timeline.seek( 1 );
  1232. }
  1233. }
  1234. }
  1235. }
  1236. }
  1237. } );
  1238. } );
  1239. }
  1240. }, { passive: true });
  1241. } )( window.VAMTAM );
  1242. ( function( v, undefined ) {
  1243. 'use strict';
  1244. var initialized = false;
  1245. v.parallaxBackground = {
  1246. /**
  1247. * Loop through all rows with a parallax background,
  1248. * load the image asynchronously,
  1249. * and create the necessary elements
  1250. *
  1251. * Also bind resize/load events here
  1252. */
  1253. init: function() {
  1254. this.rows = document.querySelectorAll( '.fl-row-bg-parallax' );
  1255. for ( var i = 0; i < this.rows.length; i++ ) {
  1256. var row = this.rows[ i ];
  1257. var src = row.getAttribute( 'data-parallax-image' );
  1258. if ( ! row.vamtamParallaxLoaded && src ) {
  1259. var img = new Image();
  1260. img.addEventListener( 'load', this.loadImageCallback );
  1261. img.row = row;
  1262. img.src = src;
  1263. }
  1264. }
  1265. window.addEventListener( 'resize', window.VAMTAM.debounce( this.onresize, 100 ).bind( this ), false );
  1266. window.addEventListener( 'load', window.VAMTAM.debounce( this.onresize, 100 ).bind( this ), false );
  1267. this.onresize();
  1268. },
  1269. /**
  1270. * Fired when the background image is loaded,
  1271. * this creates the element holding the background
  1272. */
  1273. loadImageCallback: function( e ) {
  1274. var row = e.target.row;
  1275. var contentWrap = row.firstElementChild;
  1276. var imageHolder = document.createElement( 'div' );
  1277. imageHolder.classList.add( 'vamtam-parallax-bg' );
  1278. Object.assign( imageHolder.style, {
  1279. backgroundImage: 'url(' + e.target.src + ')',
  1280. backgroundSize: 'cover',
  1281. backgroundRepeat: 'repeat',
  1282. position: 'absolute',
  1283. top: '-300px',
  1284. right: 0,
  1285. bottom: '-300px',
  1286. left: 0,
  1287. 'will-change': 'transform',
  1288. } );
  1289. requestAnimationFrame( function() {
  1290. row.vamtamParallaxLoaded = true;
  1291. var content = contentWrap.querySelector( '.fl-node-content' );
  1292. content.before( imageHolder );
  1293. contentWrap.style.overflow = 'hidden';
  1294. content.style.zIndex = 1;
  1295. content.style.position = 'relative';
  1296. } );
  1297. },
  1298. /**
  1299. * Measure and store the offset for each row
  1300. * This only needs to happen on resize/page load
  1301. */
  1302. onresize: function() {
  1303. requestAnimationFrame( function() {
  1304. var cpos = window.pageYOffset;
  1305. for ( var i = 0; i < this.rows.length; i++ ) {
  1306. this.rows[ i ].vamtamParallaxOffset = v.offset( this.rows[ i ].firstElementChild );
  1307. }
  1308. this.measure( cpos );
  1309. this.mutate( cpos );
  1310. }.bind( this ) );
  1311. },
  1312. measure: function() {
  1313. },
  1314. /**
  1315. * Reposition the background elements.
  1316. */
  1317. mutate: function( cpos ) {
  1318. for ( var i = 0; i < this.rows.length; i++ ) {
  1319. if ( this.rows[ i ].vamtamParallaxLoaded ) {
  1320. var speed = this.rows[ i ].getAttribute( 'data-parallax-speed' );
  1321. var pos = - ( ( cpos - this.rows[ i ].vamtamParallaxOffset.top ) / speed );
  1322. this.rows[ i ].firstElementChild.firstElementChild.style.transform = 'translateY(' + pos + 'px)';
  1323. }
  1324. }
  1325. },
  1326. };
  1327. window.FLBuilderLayout && Object.assign( window.FLBuilderLayout, {
  1328. /**
  1329. * Monkey patches the built-in parallax with a better implementation
  1330. */
  1331. _initParallaxBackgrounds: function() {
  1332. if ( ! initialized ) {
  1333. initialized = true;
  1334. // parallax should only be enabled if Beaver Builder is not active,
  1335. // that is, only on pages which are not currently being edited
  1336. if ( ! document.body.classList.contains( 'fl-builder-active' ) ) {
  1337. v.addScrollHandler( v.parallaxBackground );
  1338. } else {
  1339. var rows = document.querySelectorAll( '.fl-row-bg-parallax' );
  1340. for ( var i = 0; i < rows.length; i++ ) {
  1341. var row = rows[ i ];
  1342. var src = row.getAttribute( 'data-parallax-image' );
  1343. Object.assign( row.style, {
  1344. backgroundImage: 'url(' + src + ')',
  1345. backgroundSize: 'cover',
  1346. backgroundRepeat: 'repeat',
  1347. } );
  1348. }
  1349. }
  1350. }
  1351. },
  1352. _scrollParallaxBackgrounds: function() {
  1353. // should only be called once after we remove the event listener
  1354. jQuery( window ).off( 'scroll.fl-bg-parallax' );
  1355. },
  1356. } );
  1357. } )( window.VAMTAM );
  1358. /* jshint multistr:true */
  1359. (function( $, undefined ) {
  1360. "use strict";
  1361. window.VAMTAM = window.VAMTAM || {}; // Namespace
  1362. $(function () {
  1363. window.VAMTAM.admin_bar_fix = document.body.classList.contains( 'admin-bar' ) ? 32 : 0;
  1364. if ( /iPad|iPhone|iPod/.test( navigator.userAgent ) && ! window.MSStream) {
  1365. requestAnimationFrame( function() {
  1366. document.documentElement.classList.add( 'ios-safari' );
  1367. } );
  1368. }
  1369. // trigger resize after publishing a layout in order to deal with the disappearance of Beaver's UI
  1370. if ( 'FLBuilder' in window ) {
  1371. FLBuilder.addHook( 'didPublishLayout', function() {
  1372. window.dispatchEvent( new Event( 'resize' ) );
  1373. } );
  1374. }
  1375. // prevent hover when scrolling
  1376. (function() {
  1377. var box = document.querySelector( '.boxed-layout' ),
  1378. timer;
  1379. window.addEventListener( 'scroll', function() {
  1380. clearTimeout(timer);
  1381. requestAnimationFrame( function() {
  1382. box.style.pointerEvents = 'none';
  1383. timer = setTimeout( function() {
  1384. box.style.pointerEvents = '';
  1385. }, 300 );
  1386. } );
  1387. }, { passive: true } );
  1388. })();
  1389. // Code which depends on the window width
  1390. // =====================================================================
  1391. window.VAMTAM.resizeElements = function() {
  1392. // video size
  1393. $('.portfolio-image-wrapper,\
  1394. .boxed-layout .media-inner,\
  1395. .boxed-layout .loop-wrapper.news .thumbnail,\
  1396. .boxed-layout .portfolio-image .thumbnail,\
  1397. .vamtam-video-frame').find('iframe, object, embed, video').each(function() {
  1398. setTimeout( function() {
  1399. requestAnimationFrame( function() {
  1400. var v_width = this.offsetWidth;
  1401. this.style.width = '100%';
  1402. if ( this.width === '0' && this.height === '0' ) {
  1403. this.style.height = ( v_width * 9/16 ) + 'px';
  1404. } else {
  1405. this.style.height = ( this.height * v_width / this.width ) + 'px';
  1406. }
  1407. $( this ).trigger('vamtam-video-resized');
  1408. }.bind( this ) );
  1409. }.bind( this ), 50 );
  1410. });
  1411. setTimeout( function() {
  1412. requestAnimationFrame( function() {
  1413. $('.mejs-time-rail').css('width', '-=1px');
  1414. } );
  1415. }, 100 );
  1416. };
  1417. window.addEventListener( 'resize', window.VAMTAM.debounce( window.VAMTAM.resizeElements, 100 ), false );
  1418. window.VAMTAM.resizeElements();
  1419. } );
  1420. // Low priority scripts are loaded later
  1421. document.addEventListener('DOMContentLoaded', function () {
  1422. window.VAMTAM.load_script( VAMTAM_FRONT.jspath + 'build/low-priority.min.js' );
  1423. if ( ! ( window.CSS && window.CSS.supports && window.CSS.supports( '(--foo: red)' ) ) ) {
  1424. window.VAMTAM.load_script( VAMTAM_FRONT.jspath + 'plugins/thirdparty/css-variables-polyfill.js' );
  1425. var ie11styles = document.createElement('link');
  1426. ie11styles.type = 'text/css';
  1427. ie11styles.rel = 'stylesheet';
  1428. ie11styles.href = VAMTAM_FRONT.jspath + '../css/dist/ie11.css';
  1429. document.body.appendChild( ie11styles );
  1430. }
  1431. }, { passive: true } );
  1432. })(jQuery);
  1433. (function(v, undefined) {
  1434. 'use strict';
  1435. // lazy loading
  1436. var observer;
  1437. if ( 'IntersectionObserver' in window ) {
  1438. observer = new IntersectionObserver( function( changes ) {
  1439. changes.forEach( function( change ) {
  1440. if ( change.intersectionRatio > 0 || change.isIntersecting ) {
  1441. showImage( change.target );
  1442. observer.unobserve(change.target);
  1443. }
  1444. });
  1445. }, {
  1446. rootMargin: '200px',
  1447. });
  1448. }
  1449. function onImageLoad() {
  1450. /* jshint validthis: true */
  1451. this.removeEventListener( 'load', onImageLoad );
  1452. // this.dispatchEvent( new Event( 'vamtamlazyloaded', { bubbles: true } ) );
  1453. requestAnimationFrame( function() {
  1454. if ( ! ( this.classList.contains( 'vamtam-lazyload-noparent' ) ) && this.parentElement ) {
  1455. this.parentElement.classList.add( 'image-loaded' );
  1456. } else {
  1457. this.classList.add( 'image-loaded' );
  1458. }
  1459. }.bind( this ) );
  1460. }
  1461. function showImage( image ) {
  1462. var srcset = image.dataset.srcset;
  1463. if ( srcset ) {
  1464. requestAnimationFrame( function() {
  1465. image.addEventListener( 'load', onImageLoad );
  1466. image.srcset = srcset;
  1467. } );
  1468. delete image.dataset.srcset;
  1469. } else {
  1470. onImageLoad.call( image );
  1471. }
  1472. }
  1473. // Either observe the images, or load immediately if IntersectionObserver doesn't exist
  1474. function addElements() {
  1475. var images = document.querySelectorAll('img[data-srcset]');
  1476. var i;
  1477. if ( observer ) {
  1478. for ( i = 0; i < images.length; i++ ) {
  1479. if ( ! ( 'vamtamLazyLoaded' in images[i] ) ) {
  1480. images[i].vamtamLazyLoaded = true;
  1481. observer.observe( images[i] );
  1482. }
  1483. }
  1484. } else {
  1485. for ( i = 0; i < images.length; i++ ) {
  1486. if ( ! ( 'vamtamLazyLoaded' in images[i] ) ) {
  1487. images[i].vamtamLazyLoaded = true;
  1488. showImage( images[i] );
  1489. }
  1490. }
  1491. }
  1492. var otherImages = document.querySelectorAll('.vamtam-responsive-wrapper:not(.image-loaded) img:not([srcset])');
  1493. for ( i = 0; i< otherImages.length; i++ ) {
  1494. if ( ! ( 'vamtamLazyLoaded' in otherImages[i] ) ) {
  1495. otherImages[i].vamtamLazyLoaded = true;
  1496. showImage( otherImages[i] );
  1497. }
  1498. }
  1499. }
  1500. document.addEventListener('DOMContentLoaded', function() {
  1501. var mutationObserver = new MutationObserver( addElements );
  1502. mutationObserver.observe( document.body, {
  1503. childList: true,
  1504. subtree: true
  1505. } );
  1506. addElements();
  1507. });
  1508. })( window.VAMTAM );
  1509. ( function( $, undefined ) {
  1510. 'use strict';
  1511. $(function() {
  1512. var cube_found = 'cubeportfolio' in $.fn;
  1513. var cube_loading = false;
  1514. var win = $(window);
  1515. var cube_narrow = function( el ) {
  1516. requestAnimationFrame( function() {
  1517. var inner = el.find( '.cbp-wrapper' );
  1518. var outer = el.find( '.cbp-wrapper-outer' );
  1519. if ( inner.width() <= outer.width() ) {
  1520. el.addClass( 'vamtam-cube-narrow' );
  1521. } else {
  1522. el.removeClass( 'vamtam-cube-narrow' );
  1523. }
  1524. } );
  1525. };
  1526. var attempt_cube_load_callback = function() {
  1527. $( '.vamtam-cubeportfolio[data-options]:not(.vamtam-cube-loaded)' ).filter( ':visible' ).each( function() {
  1528. var self = $( this );
  1529. var options = self.data( 'options' );
  1530. if ( 'singlePageCallback' in options ) {
  1531. options.singlePageCallback = cube_single_page[ options.singlePageCallback ];
  1532. }
  1533. self.on( 'initComplete.cbp', function() {
  1534. if ( 'slider' === options.layoutMode ) {
  1535. cube_narrow( self );
  1536. win.on( 'resize.vamtamcube', function() {
  1537. cube_narrow( self );
  1538. } );
  1539. }
  1540. } );
  1541. self.addClass( 'vamtam-cube-loaded' ).cubeportfolio( options );
  1542. self.on( 'vamtam-video-resized', 'iframe, object, embed, video', function() {
  1543. self.data('cubeportfolio').layoutAndAdjustment();
  1544. } );
  1545. this.addEventListener( 'vamtamlazyloaded', function() {
  1546. self.data('cubeportfolio').layoutAndAdjustment();
  1547. } );
  1548. } );
  1549. };
  1550. // if there are cube instances, check that the script is loaded
  1551. // otherwise - load it and prevent further calls to attempt_cube_load
  1552. // until cube is available
  1553. var attempt_cube_load = function() {
  1554. if ( document.getElementsByClassName( 'vamtam-cubeportfolio' ).length ) {
  1555. if ( cube_found ) {
  1556. attempt_cube_load_callback();
  1557. } else if ( ! cube_loading ) {
  1558. cube_loading = true;
  1559. var s = document.createElement('script');
  1560. s.type = 'text/javascript';
  1561. s.async = true;
  1562. s.src = VAMTAM_FRONT.cube_path;
  1563. s.onload = function() {
  1564. cube_found = 'cubeportfolio' in $.fn;
  1565. attempt_cube_load_callback();
  1566. };
  1567. document.getElementsByTagName('script')[0].before( s );
  1568. }
  1569. }
  1570. };
  1571. var cube_single_page = {
  1572. portfolio: function( url ) {
  1573. var t = this;
  1574. $.ajax({
  1575. url: url,
  1576. type: 'GET',
  1577. dataType: 'html'
  1578. })
  1579. .done(function(result) {
  1580. t.updateSinglePage(result);
  1581. attempt_cube_load();
  1582. $( document ).trigger( 'vamtam-single-page-project-loaded' );
  1583. })
  1584. .fail(function() {
  1585. t.updateSinglePage('AJAX Error! Please refresh the page!');
  1586. });
  1587. }
  1588. };
  1589. $( document ).bind( 'vamtam-attempt-cube-load', attempt_cube_load );
  1590. attempt_cube_load();
  1591. window.addEventListener( 'resize', window.VAMTAM.debounce( attempt_cube_load, 100 ), false );
  1592. });
  1593. } )( jQuery );
  1594. ( function( $, undefined ) {
  1595. 'use strict';
  1596. $( function() {
  1597. var dropdown = $( '.fixed-header-box .cart-dropdown' ),
  1598. link = $( '.vamtam-cart-dropdown-link' ),
  1599. count = $( '.products', link ),
  1600. widget = $( '.widget', dropdown ),
  1601. isVisible = false;
  1602. $( document.body ).on( 'added_to_cart removed_from_cart wc_fragments_refreshed wc_fragments_loaded', function() {
  1603. var count_val = parseInt( Cookies.get( 'woocommerce_items_in_cart' ) || 0, 10 );
  1604. if ( count_val > 0 ) {
  1605. var count_real = 0;
  1606. var spans = document.querySelector( '.widget_shopping_cart' ).querySelectorAll( 'li .quantity' );
  1607. for ( var i = 0; i < spans.length; i++ ) {
  1608. count_real += parseInt( spans[i].innerHTML.split( '<span' )[0].replace( /[^\d]/g, '' ), 10 );
  1609. }
  1610. // sanitize count_real - if it's not a number, then don't show the counter at all
  1611. count_real = count_real >= 0 ? count_real : '';
  1612. count.text( count_real );
  1613. count.removeClass( 'cart-empty' );
  1614. dropdown.removeClass( 'hidden' );
  1615. } else {
  1616. var show_if_empty = dropdown.hasClass( 'show-if-empty' );
  1617. count.addClass( 'cart-empty' );
  1618. count.text( '0' );
  1619. dropdown.toggleClass( 'hidden', ! show_if_empty );
  1620. }
  1621. } );
  1622. var open = 0;
  1623. var showCart = function() {
  1624. open = +new Date();
  1625. dropdown.addClass( 'state-hover' );
  1626. widget.stop( true, true ).fadeIn( 300, function() {
  1627. isVisible = true;
  1628. } );
  1629. };
  1630. var hideCart = function() {
  1631. var elapsed = new Date() - open;
  1632. if( elapsed > 1000 ) {
  1633. dropdown.removeClass( 'state-hover' );
  1634. widget.stop( true, true ).fadeOut( 300, function() {
  1635. isVisible = false;
  1636. } );
  1637. } else {
  1638. setTimeout( function() {
  1639. if( !dropdown.is( ':hover' ) ) {
  1640. hideCart();
  1641. }
  1642. }, 1000 - elapsed );
  1643. }
  1644. };
  1645. dropdown.on( 'mouseenter', function() {
  1646. showCart();
  1647. } ).on( 'mouseleave', function() {
  1648. hideCart();
  1649. } );
  1650. link.not( '.no-dropdown' ).bind( 'click', function( e ) {
  1651. if( isVisible ) {
  1652. hideCart();
  1653. } else {
  1654. showCart();
  1655. }
  1656. e.preventDefault();
  1657. } );
  1658. } );
  1659. } )( jQuery );