· 6 years ago · Feb 19, 2020, 07:44 AM
1/**
2 * Load utils - BEGIN
3 */
4/*
5 CSS Browser Selector 1.0
6 Originally written by Rafael Lima (http://rafael.adm.br)
7 http://rafael.adm.br/css_browser_selector
8 License: http://creativecommons.org/licenses/by/2.5/
9
10 Co-maintained by:
11 https://github.com/ridjohansen/css_browser_selector
12 https://github.com/wbruno/css_browser_selector
13 */
14
15"use strict";
16
17window.requestAnimFrame = (function() {
18 return window.requestAnimationFrame ||
19 window.webkitRequestAnimationFrame ||
20 window.mozRequestAnimationFrame ||
21 window.oRequestAnimationFrame ||
22 window.msRequestAnimationFrame ||
23 function(/* function */ callback, /* DOMElement */ element){
24 window.setTimeout(callback, 1000 / 60);
25 };
26})();
27
28window.requestTimeout = function(fn, delay) {
29 if( !window.requestAnimationFrame &&
30 !window.webkitRequestAnimationFrame &&
31 !(window.mozRequestAnimationFrame && window.mozCancelRequestAnimationFrame) && // Firefox 5 ships without cancel support
32 !window.oRequestAnimationFrame &&
33 !window.msRequestAnimationFrame)
34 return window.setTimeout(fn, delay);
35
36 var start = new Date().getTime(),
37 handle = new Object();
38
39 function loop(){
40 var current = new Date().getTime(),
41 delta = current - start;
42
43 delta >= delay ? fn.call() : handle.value = requestAnimFrame(loop);
44 };
45
46 handle.value = requestAnimFrame(loop);
47 return handle;
48};
49
50window.clearRequestTimeout = function(handle) {
51 if ( typeof handle !== 'undefined' ) {
52 window.cancelAnimationFrame ? window.cancelAnimationFrame(handle.value) :
53 window.webkitCancelAnimationFrame ? window.webkitCancelAnimationFrame(handle.value) :
54 window.webkitCancelRequestAnimationFrame ? window.webkitCancelRequestAnimationFrame(handle.value) : /* Support for legacy API */
55 window.mozCancelRequestAnimationFrame ? window.mozCancelRequestAnimationFrame(handle.value) :
56 window.oCancelRequestAnimationFrame ? window.oCancelRequestAnimationFrame(handle.value) :
57 window.msCancelRequestAnimationFrame ? window.msCancelRequestAnimationFrame(handle.value) :
58 clearTimeout(handle);
59 }
60};
61
62var uaInfo = {
63 ua: '',
64 is: function(t) {
65 return RegExp(t, "i").test(uaInfo.ua);
66 },
67 version: function(p, n) {
68 n = n.replace(".", "_");
69 var i = n.indexOf('_'),
70 ver = "";
71 while (i > 0) {
72 ver += " " + p + n.substring(0, i);
73 i = n.indexOf('_', i + 1);
74 }
75 ver += " " + p + n;
76 return ver;
77 },
78 getBrowser: function() {
79 var g = 'gecko',
80 w = 'webkit',
81 c = 'chrome',
82 f = 'firefox',
83 s = 'safari',
84 o = 'opera',
85 a = 'android',
86 bb = 'blackberry',
87 dv = 'device_',
88 ua = uaInfo.ua,
89 is = uaInfo.is;
90 return [
91 (!(/opera|webtv/i.test(ua)) && /msie\s(\d+)/.test(ua)) ? ('ie ie' + (/trident\/4\.0/.test(ua) ? '8' : RegExp.$1))
92 : is('edge\/') ? 'edge ie' + (/edge\/(\d+)\.(\d+)/.test(ua) ? RegExp.$1 + ' ie' + RegExp.$1 + '_' + RegExp.$2 : '') // IE Edge
93 : is('trident\/') ? 'ie ie'+ (/trident\/.+rv:(\d+)/i.test(ua) ? RegExp.$1 : '') //ie11+
94 : is('firefox/') ? g + " " + f + (/firefox\/((\d+)(\.(\d+))(\.\d+)*)/.test(ua) ? ' ' + f + RegExp.$2 + ' ' + f + RegExp.$2 + "_" + RegExp.$4 : '')
95 : is('gecko/') ? g
96 : is('opera') ? o + (/version\/((\d+)(\.(\d+))(\.\d+)*)/.test(ua) ? ' ' + o + RegExp.$2 + ' ' + o + RegExp.$2 + "_" + RegExp.$4 : (/opera(\s|\/)(\d+)\.(\d+)/.test(ua) ? ' ' + o + RegExp.$2 + " " + o + RegExp.$2 + "_" + RegExp.$3 : ''))
97 : is('konqueror') ? 'konqueror'
98 : is('blackberry') ? (bb + (/Version\/(\d+)(\.(\d+)+)/i.test(ua) ? " " + bb + RegExp.$1 + " " + bb + RegExp.$1 + RegExp.$2.replace('.', '_') : (/Blackberry ?(([0-9]+)([a-z]?))[\/|;]/gi.test(ua) ? ' ' + bb + RegExp.$2 + (RegExp.$3 ? ' ' + bb + RegExp.$2 + RegExp.$3 : '') : ''))) // blackberry
99 : is('android') ? (a + (/Version\/(\d+)(\.(\d+))+/i.test(ua) ? " " + a + RegExp.$1 + " " + a + RegExp.$1 + RegExp.$2.replace('.', '_') : '') + (/Android (.+); (.+) Build/i.test(ua) ? ' ' + dv + ((RegExp.$2).replace(/ /g, "_")).replace(/-/g, "_") : '')) //android
100 : is('chrome') ? w + ' ' + c + (/chrome\/((\d+)(\.(\d+))(\.\d+)*)/.test(ua) ? ' ' + c + RegExp.$2 + ((RegExp.$4 > 0) ? ' ' + c + RegExp.$2 + "_" + RegExp.$4 : '') : '')
101 : is('iron') ? w + ' iron'
102 : is('applewebkit/') ? (w + ' ' + s + (/version\/((\d+)(\.(\d+))(\.\d+)*)/.test(ua) ? ' ' + s + RegExp.$2 + " " + s + RegExp.$2 + RegExp.$3.replace('.', '_') : (/ Safari\/(\d+)/i.test(ua) ? ((RegExp.$1 == "419" || RegExp.$1 == "417" || RegExp.$1 == "416" || RegExp.$1 == "412") ? ' ' + s + '2_0' : RegExp.$1 == "312" ? ' ' + s + '1_3' : RegExp.$1 == "125" ? ' ' + s + '1_2' : RegExp.$1 == "85" ? ' ' + s + '1_0' : '') : ''))) //applewebkit
103 : is('mozilla/') ? g : ''
104 ];
105 },
106 getPlatform : function() {
107 var wp = 'winphone',
108 a = 'android',
109 bb = 'blackberry',
110 dv = 'device_',
111
112 ua = uaInfo.ua,
113 version = uaInfo.version,
114 is = uaInfo.is;
115
116 return [
117 is('j2me') ? 'j2me'
118 :is('windows phone') ? (wp + (/Windows Phone (\d+)(\.(\d+))+/i.test(ua) ? " " + wp + RegExp.$1 + " " + wp + RegExp.$1 + RegExp.$2.replace('.', '_') : (/Windows Phone OS (\d+)(\.(\d+))+/i.test(ua) ? " " + wp + RegExp.$1 + " " + wp + RegExp.$1 + RegExp.$2.replace('.', '_') : ''))) // Windows Phone
119 :is('blackberry') ? (bb + (/Version\/(\d+)(\.(\d+)+)/i.test(ua) ? " " + bb + RegExp.$1 + " " + bb + RegExp.$1 + RegExp.$2.replace('.', '_') : (/Blackberry ?(([0-9]+)([a-z]?))[\/|;]/gi.test(ua) ? ' ' + bb + RegExp.$2 + (RegExp.$3 ? ' ' + bb + RegExp.$2 + RegExp.$3 : '') : ''))) // blackberry
120 :is('android') ? (a + (/Version\/(\d+)(\.(\d+))+/i.test(ua) ? " " + a + RegExp.$1 + " " + a + RegExp.$1 + RegExp.$2.replace('.', '_') : '') + (/Android (.+); (.+) Build/i.test(ua) ? ' ' + dv + ((RegExp.$2).replace(/ /g, "_")).replace(/-/g, "_") : '')) //android
121 :is('ipad|ipod|iphone') ? (
122 (/CPU( iPhone)? OS (\d+[_|\.]\d+([_|\.]\d+)*)/i.test(ua) ? 'ios' + version('ios', RegExp.$2) : '') + ' ' + (/(ip(ad|od|hone))/gi.test(ua) ? RegExp.$1 : "")) //'iphone'
123 //:is('ipod')?'ipod'
124 //:is('ipad')?'ipad'
125 :is('playbook') ? 'playbook'
126 :is('kindle|silk') ? 'kindle'
127 :is('playbook') ? 'playbook'
128 :is('mac') ? 'mac' + (/mac os x ((\d+)[.|_](\d+))/.test(ua) ? (' mac' + (RegExp.$2) + ' mac' + (RegExp.$1).replace('.', "_")) : '')
129 :is('win') ? 'win' + (is('windows nt 10.0') ? ' win10'
130 :is('windows nt 6.3') ? ' win8_1'
131 :is('windows nt 6.2') ? ' win8'
132 :is('windows nt 6.1') ? ' win7'
133 :is('windows nt 6.0') ? ' vista'
134 :is('windows nt 5.2') || is('windows nt 5.1') ? ' win_xp'
135 :is('windows nt 5.0') ? ' win_2k'
136 :is('windows nt 4.0') || is('WinNT4.0') ? ' win_nt' : '')
137 :is('freebsd') ? 'freebsd'
138 :is('x11|linux') ? 'linux' : ''
139 ];
140 },
141 getMobile: function() {
142 var is = uaInfo.is;
143 return [
144 is("android|mobi|mobile|j2me|iphone|ipod|ipad|blackberry|playbook|kindle|silk") ? 'mobile' : ''
145 ];
146 },
147 getIpadApp: function() {
148 var is = uaInfo.is;
149 return [
150 (is('ipad|iphone|ipod') && !is('safari')) ? 'ipad_app' : ''
151 ];
152 },
153 getLang: function() {
154 var ua = uaInfo.ua;
155 return [/[; |\[](([a-z]{2})(\-[a-z]{2})?)[)|;|\]]/i.test(ua) ? ('lang_' + RegExp.$2).replace("-", "_") + (RegExp.$3 != '' ? (' ' + 'lang_' + RegExp.$1).replace("-", "_") : '') : ''];
156 }
157}
158var screenInfo = {
159 width: (window.outerWidth || document.documentElement.clientWidth) - 15,
160 height: window.outerHeight || document.documentElement.clientHeight,
161 screens: [0, 768, 980, 1200],
162 screenSize: function() {
163 screenInfo.width = (window.outerWidth || document.documentElement.clientWidth) - 15;
164 screenInfo.height = window.outerHeight || document.documentElement.clientHeight;
165 var screens = screenInfo.screens,
166 i = screens.length,
167 arr = [],
168 maxw,
169 minw;
170 while (i--) {
171 if (screenInfo.width >= screens[i]) {
172 if (i) {
173 arr.push("minw_" + screens[(i)]);
174 }
175 if (i <= 2) {
176 arr.push("maxw_" + (screens[(i) + 1] - 1));
177 }
178 break;
179 }
180 }
181 return arr;
182 },
183 getOrientation: function() {
184 return screenInfo.width < screenInfo.height ? ["orientation_portrait"] : ["orientation_landscape"];
185 },
186 getInfo: function() {
187 var arr = [];
188 arr = arr.concat(screenInfo.screenSize());
189 arr = arr.concat(screenInfo.getOrientation());
190 return arr;
191 },
192 getPixelRatio: function() {
193 var arr = [],
194 pixelRatio = window.devicePixelRatio ? window.devicePixelRatio : 1;
195 if (pixelRatio > 1) {
196 arr.push('retina_' + parseInt(pixelRatio) + 'x');
197 arr.push('hidpi');
198 } else {
199 arr.push('no-hidpi');
200 }
201 return arr;
202 }
203}
204var dataUriInfo = {
205 data: new Image(),
206 div: document.createElement("div"),
207 isIeLessThan9: false,
208 getImg: function() {
209 dataUriInfo.data.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
210 dataUriInfo.div.innerHTML = "<!--[if lt IE 9]><i></i><![endif]-->";
211 dataUriInfo.isIeLessThan9 = dataUriInfo.div.getElementsByTagName("i").length == 1;
212 return dataUriInfo.data;
213 },
214 checkSupport: function() {
215 if (dataUriInfo.data.width != 1 || dataUriInfo.data.height != 1 || dataUriInfo.isIeLessThan9) {
216 return ["no-datauri"];
217 } else {
218 return ["datauri"];
219 }
220 }
221}
222
223function css_browser_selector(u, ns) {
224 var html = document.documentElement,
225 b = []
226 ns = ns ? ns : "";
227 /* ua */
228 uaInfo.ua = u.toLowerCase();
229 var browser = uaInfo.getBrowser();
230 if (browser == 'gecko') browser = (!(window.ActiveXObject) && "ActiveXObject" in window) ? 'ie ie11' : browser;
231 var pattTouch = /no-touch/g;
232 if (pattTouch.test(html.className)) b = b.concat('no-touch');
233 else b = b.concat('touch');
234 var pattAdmin = /admin-mode/g;
235 if (pattAdmin.test(html.className)) b = b.concat('admin-mode');
236 b = b.concat(browser);
237 b = b.concat(uaInfo.getPlatform());
238 b = b.concat(uaInfo.getMobile());
239 b = b.concat(uaInfo.getIpadApp());
240 b = b.concat(uaInfo.getLang());
241 /* js */
242 b = b.concat(['js']);
243 /* pixel ratio */
244 b = b.concat(screenInfo.getPixelRatio());
245 /* screen */
246 b = b.concat(screenInfo.getInfo());
247 var updateScreen = function() {
248 html.className = html.className.replace(/ ?orientation_\w+/g, "").replace(/ [min|max|cl]+[w|h]_\d+/g, "");
249 html.className = html.className + ' ' + screenInfo.getInfo().join(' ');
250 }
251 window.addEventListener('resize', updateScreen);
252 window.addEventListener('orientationchange', updateScreen);
253 /* dataURI */
254 var data = dataUriInfo.getImg();
255 data.onload = data.onerror = function() {
256 html.className += ' ' + dataUriInfo.checkSupport().join(' ');
257 }
258 /* removendo itens invalidos do array */
259 b = b.filter(function(e) {
260 return e;
261 });
262 /* prefixo do namespace */
263 b[0] = ns ? ns + b[0] : b[0];
264 html.className = b.join(' ' + ns);
265 return html.className;
266 }
267 // define css_browser_selector_ns before loading this script to assign a namespace
268var css_browser_selector_ns = css_browser_selector_ns || "";
269// init
270css_browser_selector(navigator.userAgent, css_browser_selector_ns);
271/**
272 * skip-link-focus-fix.js
273 *
274 * Helps with accessibility for keyboard only users.
275 *
276 * Learn more: https://github.com/Automattic/_s/pull/136
277 */
278(function() {
279 var is_webkit = navigator.userAgent.toLowerCase().indexOf('webkit') > -1,
280 is_opera = navigator.userAgent.toLowerCase().indexOf('opera') > -1,
281 is_ie = navigator.userAgent.toLowerCase().indexOf('msie') > -1;
282 if ((is_webkit || is_opera || is_ie) && document.getElementById && window.addEventListener) {
283 window.addEventListener('hashchange', function() {
284 var id = location.hash.substring(1),
285 element;
286 if (!(/^[A-z0-9_-]+$/.test(id))) {
287 return;
288 }
289 element = document.getElementById(id);
290 if (element) {
291 if (!(/^(?:a|select|input|button|textarea)$/i.test(element.tagName))) {
292 element.tabIndex = -1;
293 }
294 element.focus();
295 }
296 }, false);
297 }
298})();
299// Polyfill for creating CustomEvents on IE9/10/11
300// code pulled from:
301// https://github.com/d4tocchini/customevent-polyfill
302// https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent#Polyfill
303try {
304 new CustomEvent("test");
305} catch (e) {
306 var CustomEvent = function(event, params) {
307 var evt;
308 params = params || {
309 bubbles: false,
310 cancelable: false,
311 detail: undefined
312 };
313 evt = document.createEvent("CustomEvent");
314 evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
315 return evt;
316 };
317 CustomEvent.prototype = window.Event.prototype;
318 window.CustomEvent = CustomEvent; // expose definition to window
319}
320// Evento - v1.0.0
321// by Erik Royall <erikroyalL@hotmail.com> (http://erikroyall.github.io)
322// Dual licensed under MIT and GPL
323// Array.prototype.indexOf shim
324// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf
325Array.prototype.indexOf || (Array.prototype.indexOf = function(n) {
326 "use strict";
327 if (null == this) throw new TypeError;
328 var t, e, o = Object(this),
329 r = o.length >>> 0;
330 if (0 === r) return -1;
331 if (t = 0, arguments.length > 1 && (t = Number(arguments[1]), t != t ? t = 0 : 0 != t && 1 / 0 != t && t != -1 / 0 && (t = (t > 0 || -1) * Math.floor(Math.abs(t)))), t >= r) return -1;
332 for (e = t >= 0 ? t : Math.max(r - Math.abs(t), 0); r > e; e++)
333 if (e in o && o[e] === n) return e;
334 return -1
335});
336var evento = function(n) {
337 var t, e, o, r = n,
338 i = r.document,
339 f = {};
340 return t = function() {
341 return "function" == typeof i.addEventListener ? function(n, t, e) {
342 n.addEventListener(t, e, !1), f[n] = f[n] || {}, f[n][t] = f[n][t] || [], f[n][t].push(e)
343 } : "function" == typeof i.attachEvent ? function(n, t, e) {
344 n.attachEvent(t, e), f[n] = f[n] || {}, f[n][t] = f[n][t] || [], f[n][t].push(e)
345 } : function(n, t, e) {
346 n["on" + t] = e, f[n] = f[n] || {}, f[n][t] = f[n][t] || [], f[n][t].push(e)
347 }
348 }(), e = function() {
349 return "function" == typeof i.removeEventListener ? function(n, t, e) {
350 n.removeEventListener(t, e, !1), Helio.each(f[n][t], function(o) {
351 o === e && (f[n] = f[n] || {}, f[n][t] = f[n][t] || [], f[n][t][f[n][t].indexOf(o)] = void 0)
352 })
353 } : "function" == typeof i.detachEvent ? function(n, t, e) {
354 n.detachEvent(t, e), Helio.each(f[n][t], function(o) {
355 o === e && (f[n] = f[n] || {}, f[n][t] = f[n][t] || [], f[n][t][f[n][t].indexOf(o)] = void 0)
356 })
357 } : function(n, t, e) {
358 n["on" + t] = void 0, Helio.each(f[n][t], function(o) {
359 o === e && (f[n] = f[n] || {}, f[n][t] = f[n][t] || [], f[n][t][f[n][t].indexOf(o)] = void 0)
360 })
361 }
362 }(), o = function(n, t) {
363 f[n] = f[n] || {}, f[n][t] = f[n][t] || [];
364 for (var e = 0, o = f[n][t].length; o > e; e += 1) f[n][t][e]()
365 }, {
366 add: t,
367 remove: e,
368 trigger: o,
369 _handlers: f
370 }
371}(this);
372/*
373 * OKVideo by OKFocus v2.3.2
374 * http://okfoc.us
375 *
376 * Copyright 2014, OKFocus
377 * Licensed under the MIT license.
378 *
379 */
380var player, OKEvents, options, videoWidth, videoHeight, YTplayers, youtubePlayers = new Array();
381// youtube player ready
382function onYouTubeIframeAPIReady() {
383 YTplayers = new Array();
384 jQuery('.no-touch .uncode-video-container.video').each(function() {
385 var playerY;
386 if (jQuery(this).attr('data-provider') == 'youtube') {
387 var id = jQuery(this).attr('data-id');
388 options = jQuery(window).data('okoptions-' + id);
389 options.time = jQuery(this).attr('data-t');
390 playerY = new YT.Player('okplayer-' + id, {
391 videoId: options.video ? options.video.id : null,
392 playerVars: {
393 'autohide': 1,
394 'autoplay': 0, //options.autoplay,
395 'disablekb': options.keyControls,
396 'cc_load_policy': options.captions,
397 'controls': options.controls,
398 'enablejsapi': 1,
399 'fs': 0,
400 'modestbranding': 1,
401 'origin': window.location.origin || (window.location.protocol + '//' + window.location.hostname),
402 'iv_load_policy': options.annotations,
403 'loop': options.loop,
404 'showinfo': 0,
405 'rel': 0,
406 'wmode': 'opaque',
407 'hd': options.hd,
408 'mute': 1
409 },
410 events: {
411 'onReady': OKEvents.yt.ready,
412 'onStateChange': OKEvents.yt.onStateChange,
413 'onError': OKEvents.yt.error
414 }
415 });
416 YTplayers[id] = playerY;
417 playerY.videoId = id;
418 }
419 });
420}
421// vimeo player ready
422function vimeoPlayerReady(id) {
423 options = jQuery(window).data('okoptions-' + id);
424 var jIframe = options.jobject,
425 iframe = jIframe[0];
426 jIframe.attr('src', jIframe.data('src'));
427 var playerV = $f(iframe);
428 // hide player until Vimeo hides controls...
429 playerV.addEvent('ready', function(e) {
430 OKEvents.v.onReady(iframe);
431 var carouselContainer = jQuery(iframe).closest('.owl-carousel');
432 if (carouselContainer.length) {
433 UNCODE.owlPlayVideo(carouselContainer);
434 }
435 // "Do not try to add listeners or call functions before receiving this event."
436 if (OKEvents.utils.isMobile()) {
437 // mobile devices cannot listen for play event
438 OKEvents.v.onPlay(playerV);
439 } else {
440 playerV.addEvent('play', OKEvents.v.onPlay(playerV));
441 playerV.addEvent('pause', OKEvents.v.onPause);
442 playerV.addEvent('finish', OKEvents.v.onFinish);
443 }
444 if (options.time != null) {
445 playerV.api('seekTo', (options.time).replace('t=', ''));
446 }
447
448 playerV.api('play');
449 jQuery(iframe).css({
450 visibility: 'visible',
451 opacity: 1
452 });
453 jQuery(iframe).closest('.uncode-video-container').css('opacity', '1');
454 jQuery(iframe).closest('#page-header').addClass('video-started');
455 jQuery(iframe).closest('.background-wrapper').find('.block-bg-blend-mode.not-ie').css('opacity', '1');
456
457 });
458}
459OKEvents = {
460 yt: {
461 ready: function(event) {
462 var id = event.target.videoId;
463 youtubePlayers[id] = event.target;
464 event.target.setVolume(options.volume);
465 if (options.autoplay === 1) {
466 if (options.playlist.list) {
467 player.loadPlaylist(options.playlist.list, options.playlist.index, options.playlist.startSeconds, options.playlist.suggestedQuality);
468 } else {
469 var inCarousel = jQuery('#okplayer-' + id).closest('.owl-item');
470 if (!inCarousel.length || (inCarousel.length && inCarousel.hasClass('active'))) {
471 if (options.time != null) {
472 event.target.seekTo(parseInt(options.time));
473 }
474 event.target.playVideo();
475 } else {
476 event.target.pauseVideo();
477 }
478 }
479 }
480 OKEvents.utils.isFunction(options.onReady) && options.onReady(event.target);
481 },
482 onStateChange: function(event) {
483 var id = event.target.videoId;
484 switch (event.data) {
485 case -1:
486 OKEvents.utils.isFunction(options.unstarted) && options.unstarted();
487 break;
488 case 0:
489 OKEvents.utils.isFunction(options.onFinished) && options.onFinished();
490 options.loop && event.target.playVideo();
491 break;
492 case 1:
493 OKEvents.utils.isFunction(options.onPlay) && options.onPlay();
494 setTimeout(function() {
495 UNCODE.initVideoComponent(document.body, '.uncode-video-container.video, .uncode-video-container.self-video');
496 jQuery('#okplayer-' + id).closest('.uncode-video-container').css('opacity', '1');
497 jQuery('#okplayer-' + id).closest('#page-header').addClass('video-started');
498 jQuery('#okplayer-' + id).closest('.background-wrapper').find('.block-bg-blend-mode.not-ie').css('opacity', '1');
499 }, 300);
500 break;
501 case 2:
502 OKEvents.utils.isFunction(options.onPause) && options.onPause();
503 break;
504 case 3:
505 OKEvents.utils.isFunction(options.buffering) && options.buffering();
506 break;
507 case 5:
508 OKEvents.utils.isFunction(options.cued) && options.cued();
509 break;
510 default:
511 throw "OKVideo: received invalid data from YT player.";
512 }
513 },
514 error: function(event) {
515 throw event;
516 }
517 },
518 v: {
519 onReady: function(target) {
520 OKEvents.utils.isFunction(options.onReady) && options.onReady(target);
521 },
522 onPlay: function(player) {
523 if (!OKEvents.utils.isMobile()) player.api('setVolume', options.volume);
524 OKEvents.utils.isFunction(options.onPlay) && options.onPlay();
525 jQuery(player.element).closest('.uncode-video-container').css('opacity', '1');
526 jQuery(player.element).closest('#page-header').addClass('video-started');
527 jQuery(player.element).closest('.background-wrapper').find('.block-bg-blend-mode.not-ie').css('opacity', '1');
528 },
529 onPause: function() {
530 OKEvents.utils.isFunction(options.onPause) && options.onPause();
531 },
532 onFinish: function() {
533 OKEvents.utils.isFunction(options.onFinish) && options.onFinish();
534 }
535 },
536 utils: {
537 isFunction: function(func) {
538 if (typeof func === 'function') {
539 return true;
540 } else {
541 return false;
542 }
543 },
544 isMobile: function() {
545 if (navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry)/)) {
546 return true;
547 } else {
548 return false;
549 }
550 }
551 }
552};
553// DOM class helper
554(function(window) {
555 'use strict';
556 // class helper functions from bonzo https://github.com/ded/bonzo
557 function classReg(className) {
558 return new RegExp("(^|\\s+)" + className + "(\\s+|$)");
559 }
560 // classList support for class management
561 // altho to be fair, the api sucks because it won't accept multiple classes at once
562 var hasClass, addClass, removeClass;
563 if ('classList' in document.documentElement) {
564 hasClass = function(elem, c) {
565 if ( elem !== null && typeof elem.classList !== 'undefined' ) return elem.classList.contains(c);
566 };
567 addClass = function(elem, c) {
568 if ( elem !== null && typeof elem.classList !== 'undefined' ) elem.classList.add(c);
569 };
570 removeClass = function(elem, c) {
571 if ( elem !== null && typeof elem.classList !== 'undefined' ) elem.classList.remove(c);
572 };
573 } else {
574 hasClass = function(elem, c) {
575 if (elem !== null) return classReg(c).test(elem.className);
576 };
577 addClass = function(elem, c) {
578 if (!hasClass(elem, c)) {
579 if (elem !== null) elem.className = elem.className + ' ' + c;
580 }
581 };
582 removeClass = function(elem, c) {
583 if (elem !== null) elem.className = elem.className.replace(classReg(c), ' ');
584 };
585 }
586
587 function toggleClass(elem, c) {
588 var fn = hasClass(elem, c) ? removeClass : addClass;
589 fn(elem, c);
590 }
591 var classie = {
592 // full names
593 hasClass: hasClass,
594 addClass: addClass,
595 removeClass: removeClass,
596 toggleClass: toggleClass,
597 // short names
598 has: hasClass,
599 add: addClass,
600 remove: removeClass,
601 toggle: toggleClass
602 };
603 // transport
604 if (typeof define === 'function' && define.amd) {
605 // AMD
606 define(classie);
607 } else {
608 // browser global
609 window.classie = classie;
610 }
611
612 window.wrap = function(wrapper, elms) {
613 if (!elms.length) {
614 elms = [elms];
615 }
616
617 for (var i = elms.length - 1; i >= 0; i--) {
618 var child = (i > 0) ? wrapper.cloneNode(true) : wrapper;
619 var el = elms[i];
620
621 var parent = el.parentNode;
622 var sibling = el.nextSibling;
623
624 child.appendChild(el);
625
626 if (sibling) {
627 parent.insertBefore(child, sibling);
628 } else {
629 parent.appendChild(child);
630 }
631 }
632 };
633
634 window.wrapAll = function(wrapper, nodes) {
635 var parent = nodes[0].parentNode;
636 var previousSibling = nodes[0].previousSibling;
637
638 for (var i = 0; nodes.length - i; wrapper.firstChild === nodes[0] && i++) {
639 wrapper.appendChild(nodes[i]);
640 }
641
642 var nextSibling = previousSibling ? previousSibling.nextSibling : parent.firstChild;
643 parent.insertBefore(wrapper, nextSibling);
644
645 return wrapper;
646 };
647})(window);
648/* From Modernizr */
649function whichTransitionEvent() {
650 var t;
651 var el = document.createElement('fakeelement');
652 var transitions = {
653 'transition': 'transitionend',
654 'OTransition': 'oTransitionEnd',
655 'MozTransition': 'transitionend',
656 'WebkitTransition': 'webkitTransitionEnd'
657 }
658 for (t in transitions) {
659 if (el.style[t] !== undefined) {
660 return transitions[t];
661 }
662 }
663 }
664function whichAnimationEvent() {
665 var t;
666 var el = document.createElement('fakeelement');
667 var animations = {
668 'animation': 'animationend',
669 'OAnimation': 'oAnimationEnd',
670 'MozAnimation': 'animationend',
671 'WebkitAnimation': 'webkitAnimationEnd'
672 }
673 for (t in animations) {
674 if (el.style[t] !== undefined) {
675 return animations[t];
676 }
677 }
678 }
679/**
680 * Load utils - END
681 */
682
683/**
684 * Start main js
685 */
686(function(window, undefined) {
687 'use strict';
688
689 // Init variables
690 var bodyTop,
691 scrollbarWidth = false,
692 noScroll = false,
693 boxEvent = new CustomEvent('boxResized'),
694 menuClose = new CustomEvent('menuClose'),
695 menuOpen = new CustomEvent('menuOpen'),
696 bodyBorder = 0,
697 adminBarHeight = 0,
698 boxWidth = 0,
699 boxLeft = 0,
700 parallaxRows,
701 parallaxCols,
702 parallaxHeaders,
703 kenburnsHeaders,
704 kenburnsRows,
705 kenburnsCols,
706 backwashHeaders,
707 backwashRows,
708 backwashCols,
709 visibleRows,
710 headerWithOpacity,
711 speedDivider = SiteParameters.parallax_factor,
712 adminBar,
713 pageHeader,
714 headerVideo,
715 masthead,
716 mastheadMobile,
717 mastheadMobilePaddingTop = 0,
718 maincontainer,
719 menuwrapper,
720 menuhide,
721 menusticky,
722 menuHeight = 0,
723 menuMobileHeight = 0,
724 mainmenu = new Array(),
725 secmenu = new Array(),
726 secmenuHeight = 0,
727 transmenuHeight = 0,
728 header,
729 transmenuel,
730 logo,
731 logoel,
732 logolink,
733 logoMinScale,
734 lastScrollValue = 0,
735 wwidth = window.innerWidth || document.documentElement.clientWidth,
736 wheight = window.innerHeight || document.documentElement.clientHeight,
737 isScrolling = false,
738 boxWrapper,
739 docheight = 0,
740 isMobile = classie.hasClass(document.documentElement, 'touch') ? true : false,
741 isIE = classie.hasClass(document.documentElement, 'ie') || classie.hasClass(document.documentElement, 'opera12') ? true : false,
742 isFF = classie.hasClass(document.documentElement, 'firefox') ? true : false,
743 isFullPage,
744 isFullPageSnap,
745 isFrontEndEditor,
746 transitionEvent = whichTransitionEvent(),
747 animationEvent = whichAnimationEvent(),
748 footerScroller = false,
749 mediaQuery = 959,
750 mediaQueryMobile = 569,
751 menuOpened = false,
752 overlayOpened = false,
753 menuMobileTriggerEvent = new CustomEvent('menuMobileTrigged'),
754 resizeTimer_,
755 resizeTimer,
756 hidingTimer,
757 isSplitMenu = false,
758 mainNavMenu,
759 mainNavWrapper,
760 isMobileTransparent = false,
761 isMobileParallaxAllowed = SiteParameters.mobile_parallax_allowed,
762 loadedFonts = new Array(),
763 already_font = false,
764 scrollRowHeight_fix = window.pageYOffset,
765
766 checkVisible = function( elm ) {
767 var rect = elm.getBoundingClientRect();
768 var viewHeight = Math.max(document.documentElement.clientHeight, window.innerHeight);
769 return !(rect.bottom < 0 || rect.top - viewHeight >= 0);
770 },
771 initBox = function() {
772 var bodyBorderDiv = document.querySelectorAll('.body-borders .top-border');
773 if (bodyBorderDiv.length) {
774 bodyBorder = outerHeight(bodyBorderDiv[0]);
775 } else bodyBorder = 0;
776 UNCODE.isRTL = classie.hasClass(document.body, 'rtl') ? true : false,
777 UNCODE.bodyBorder = bodyBorder;
778 UNCODE.isFrontEndEditor = classie.hasClass(document.body, 'compose-mode') && classie.hasClass(document.body, 'vc_editor');
779 UNCODE.isFullPage = !UNCODE.isFrontEndEditor && classie.hasClass(document.body, 'uncode-fullpage-slide') && !( UNCODE.isMobile && classie.hasClass(document.body, 'uncode-fp-mobile-disable') && window.innerWidth < 570 );
780 UNCODE.isFullPageSnap = !UNCODE.isFrontEndEditor && classie.hasClass(document.body, 'uncode-scroll-snap');
781 if (bodyBorder != 0) {
782 if ( !UNCODE.isFullPage ) {
783 document.documentElement.style.paddingTop = bodyBorder + 'px';
784 }
785 wheight = (window.innerHeight || document.documentElement.clientHeight) - (bodyBorder * 2);
786 }
787 if (!isMobile && !scrollbarWidth) {
788 // Create the measurement node
789 var scrollDiv = document.createElement("div");
790 scrollDiv.className = "scrollbar-measure";
791 var dombody = document.body;
792 if (dombody != null) {
793 dombody.appendChild(scrollDiv);
794 // Get the scrollbar width
795 scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
796 // Delete the DIV
797 dombody.removeChild(scrollDiv);
798 }
799 }
800 if (!isMobile) {
801 forEachElement('.box-container', function(el, i) {
802 if (!classie.hasClass(el, 'limit-width')) {
803 var elWidth = outerWidth(el),
804 newWidth = 12 * Math.ceil((wwidth - scrollbarWidth) / 12);
805 boxWidth = newWidth - (bodyBorder * 2);
806 boxLeft = (wwidth - boxWidth - scrollbarWidth) / 2;
807 el.style.width = boxWidth + 'px';
808 if ( UNCODE.isRTL )
809 el.style.marginRight = boxLeft + 'px';
810 else
811 el.style.marginLeft = boxLeft + 'px';
812 if (mainmenu != undefined && mainmenu[0] != undefined) {
813 mainmenu[0].style.width = boxWidth + 'px';
814 }
815 }
816 });
817 }
818
819 if (classie.hasClass(document.body, 'menu-mobile-transparent')) isMobileTransparent = true;
820
821 if (!isMobileTransparent) {
822 if (wwidth > mediaQuery && classie.hasClass(document.body, 'menu-force-opacity')) classie.removeClass(document.body, 'menu-force-opacity');
823 if (wwidth < mediaQuery && !classie.hasClass(document.body, 'menu-force-opacity')) classie.addClass(document.body, 'menu-force-opacity');
824 }
825
826 },
827 fixMenuHeight = function() {
828 if (!classie.hasClass(document.body, 'vmenu')) noScroll = true;
829
830 menuwrapper = document.querySelectorAll(".menu-wrapper");
831 masthead = document.getElementById("masthead");
832 if (classie.hasClass(document.body, 'hmenu-center-split')) {
833 mastheadMobile = new Array(document.getElementById("logo-container-mobile"), document.getElementById("main-logo").parentNode);
834 } else mastheadMobile = document.getElementById("logo-container-mobile");
835 menuhide = document.querySelector('#masthead .menu-hide, .main-header .menu-hide, #masthead .menu-hide-vertical');
836 menusticky = document.querySelectorAll('.menu-sticky, .menu-sticky-vertical');
837 transmenuel = document.querySelectorAll('.menu-transparent:not(.vmenu-container)');
838 var menuItemsButton = document.querySelectorAll('.menu-item-button .menu-btn-table');
839 logo = document.querySelector('#main-logo');
840 if (logo != undefined) logolink = (logo.firstElementChild || logo.firstChild);
841 if (logolink != undefined) logoMinScale = logolink.getAttribute("data-minheight");
842 logoel = document.querySelectorAll('.menu-shrink .logo-container');
843 mainmenu = document.querySelectorAll('.vmenu .vmenu-container, .menu-primary .menu-container');
844 if (classie.hasClass(document.body, 'hmenu-center')) {
845 var mainmenucenter = document.querySelectorAll('.hmenu-center .menu-container-mobile');
846 var first_array = Array.prototype.slice.call(mainmenu);
847 var second_array = Array.prototype.slice.call(mainmenucenter);
848 mainmenu = first_array.concat(second_array);
849 }
850 secmenu = document.querySelectorAll('.menu-secondary');
851 calculateMenuHeight(true);
852 for (var k = 0; k < menuItemsButton.length; k++) {
853 var a_item = menuItemsButton[k].parentNode,
854 buttonHeight = outerHeight(menuItemsButton[k]);
855 a_item.style.height = buttonHeight + 'px';
856 }
857 if (classie.hasClass(document.body, 'hmenu-center-split')) {
858 mainNavMenu = document.querySelector('#masthead .navbar-main .menu-primary-inner');
859 mainNavWrapper = document.querySelector('#masthead > .menu-container');
860 isSplitMenu = true;
861 }
862 fixMenu();
863 },
864 calculateMenuHeight = function(first) {
865 menuHeight = transmenuHeight = secmenuHeight = 0;
866
867 if (mastheadMobile != null) {
868 if (mastheadMobile.length === 2) {
869 if (wwidth > mediaQuery) {
870 UNCODE.menuMobileHeight = outerHeight(mastheadMobile[1]);
871 mastheadMobilePaddingTop = parseFloat(getComputedStyle(mastheadMobile[1]).paddingTop);
872 } else {
873 UNCODE.menuMobileHeight = outerHeight(mastheadMobile[0]);
874 mastheadMobilePaddingTop = parseFloat(getComputedStyle(mastheadMobile[0]).paddingTop);
875 }
876 } else {
877 UNCODE.menuMobileHeight = outerHeight(mastheadMobile);
878 mastheadMobilePaddingTop = parseFloat(getComputedStyle(mastheadMobile).paddingTop);
879 }
880 }
881
882 if (wwidth > mediaQuery) {
883 for (var i = 0; i < mainmenu.length; i++) {
884 if (classie.hasClass(document.body, 'hmenu-center') && i === 1) continue;
885 if (!classie.hasClass(masthead, 'masthead-vertical')) {
886 menuHeight = menuHeight + outerHeight(mainmenu[i]);
887 } else menuHeight = 0;
888
889 if (isIE && first) {
890 getDivChildren(mainmenu[i], '.menu-horizontal-inner', function(innerMenu, i) {
891 innerMenu.style.height = menuHeight + 'px';
892 });
893 }
894
895 if (classie.hasClass(mainmenu[i].parentNode, 'menu-transparent')) {
896 transmenuHeight += menuHeight;
897 }
898 }
899
900 for (var j = 0; j < secmenu.length; j++) {
901 secmenuHeight += outerHeight(secmenu[j]);
902 }
903 menuHeight += secmenuHeight;
904 } else {
905 menuHeight = UNCODE.menuMobileHeight;
906 if (isMobileTransparent) {
907 for (var i = 0; i < mainmenu.length; i++) {
908 if (classie.hasClass(mainmenu[i].parentNode, 'menu-transparent')) {
909 transmenuHeight += menuHeight;
910 }
911 }
912 }
913 var search_box = document.querySelectorAll('.search-icon .drop-menu');
914 for (var i = 0; i < search_box.length; i++) {
915 search_box[i].removeAttribute('style');
916 }
917 }
918
919
920 if (classie.hasClass(document.documentElement, 'admin-mode')) {
921 adminBar = document.getElementById("wpadminbar");
922 if (wwidth > 600) {
923 if (adminBar != null) adminBarHeight = outerHeight(adminBar);
924 else {
925 if (wwidth > 782) adminBarHeight = 32;
926 else adminBarHeight = 46;
927 }
928 } else adminBarHeight = 0;
929 }
930 UNCODE.adminBarHeight = adminBarHeight;
931 UNCODE.menuHeight = menuHeight;
932
933 if ( UNCODE.isFullPage && ! UNCODE.isFrontEndEditor ) {
934 if ( UNCODE.adminBarHeight > 0 )
935 document.body.style.marginTop = ( ( UNCODE.adminBarHeight + UNCODE.bodyBorder ) * -1 ) + 'px';
936
937 document.body.style.paddingTop = ( UNCODE.adminBarHeight + UNCODE.bodyBorder ) + 'px';
938 } else {
939 document.body.style.marginTop = 0;
940 document.body.style.paddingTop = 0;
941 }
942
943 if (masthead != undefined) {
944 //masthead.parentNode.style.height = menuHeight + 'px';
945 if (classie.hasClass(masthead, 'menu-transparent')) {
946 if (wwidth > mediaQuery) masthead.parentNode.style.height = '0px';
947 }
948 }
949
950 if (typeof menuhide == 'object' && menuhide != null && mainmenu[0] != undefined) {
951 var sticky_element = (typeof mainmenu.item === 'undefined' ? ((wwidth > mediaQuery) ? mainmenu[0] : mainmenu[1]) : mainmenu[0]);
952 if (sticky_element.style.top != '') {
953 sticky_element.style.top = UNCODE.bodyBorder + 'px'
954 }
955 }
956
957 },
958 centerSplitMenu = function() {
959 if (wwidth > mediaQuery && mainNavMenu) {
960 if (mainNavMenu.style.left == '') {
961 mainNavMenu.style.left = '0px';
962 var logoPos = logo.parentNode.getBoundingClientRect();
963 mainNavMenu.style.left = (wwidth / 2) - (logoPos.left + (logoPos.width / 2) ) + 'px';
964 mainNavWrapper.style.opacity = '1';
965 }
966 mainNavWrapper.style.opacity = '1';
967 }
968 },
969 initHeader = function() {
970 UNCODE.adaptive();
971 headerHeight('.header-wrapper');
972
973 parallaxHeaders = document.querySelectorAll('.header-parallax > .header-bg-wrapper');
974 header = document.querySelectorAll('.header-wrapper.header-uncode-block, .header-wrapper.header-revslider, .header-wrapper.header-layerslider, .header-basic .header-wrapper, .header-uncode-block > .row-container:first-child > .row > .row-inner > .col-lg-12 > .uncol, .header-uncode-block .uncode-slider .owl-carousel > .row-container:first-child .column_child .uncoltable');
975 headerWithOpacity = document.querySelectorAll('.header-scroll-opacity');
976 pageHeader = document.getElementById("page-header");
977 if ( typeof pageHeader === 'object' && pageHeader !== null ) {
978 headerVideo = pageHeader.querySelectorAll('.uncode-video-container');
979 kenburnsHeaders = pageHeader.querySelectorAll('.with-kburns > .header-bg-wrapper');
980 backwashHeaders = pageHeader.querySelectorAll('.with-zoomout > .header-bg-wrapper');
981 if ( headerVideo.length ) {
982 classie.addClass(pageHeader, 'has-video');
983 }
984 }
985 if (pageHeader != undefined) {
986 var backs = pageHeader.querySelectorAll('.header-bg'),
987 backsCarousel = pageHeader.querySelectorAll('.header-uncode-block .background-inner'),
988 uri_pattern = /\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/ig;
989 if (backs.length == 0 && backsCarousel.length == 0) {
990 pageHeader.setAttribute('data-imgready', 'true');
991 } else {
992 if (backsCarousel.length) {
993 for (var j = 0; j < backsCarousel.length; j++) {
994 if (j == 0) {
995 if (!!backsCarousel[j].style.backgroundImage && backsCarousel[j].style.backgroundImage !== void 0) {
996 var url = (backsCarousel[j].style.backgroundImage).match(uri_pattern),
997 image = new Image();
998 image.onload = function() {
999 pageHeader.setAttribute('data-imgready', 'true');
1000 };
1001 image.src = url[0];
1002 } else {
1003 pageHeader.setAttribute('data-imgready', 'true');
1004 }
1005 }
1006 }
1007 } else {
1008 for (var i = 0; i < backs.length; i++) {
1009 if (i == 0) {
1010 if (!!backs[i].style.backgroundImage && backs[i].style.backgroundImage !== void 0) {
1011 var url = (backs[i].style.backgroundImage).match(uri_pattern),
1012 image = new Image();
1013 image.onload = function() {
1014 pageHeader.setAttribute('data-imgready', 'true');
1015 };
1016 image.src = url[0];
1017 } else {
1018 pageHeader.setAttribute('data-imgready', 'true');
1019 }
1020 }
1021 }
1022 }
1023 }
1024 }
1025
1026 if (masthead != undefined && !classie.hasClass(masthead, 'masthead-vertical')) {
1027 if (header.length) {
1028 masthead.parentNode.style.height = menuHeight + 'px';
1029 if (menuwrapper[0] != undefined) classie.addClass(menuwrapper[0], 'with-header');
1030 for (var j = 0; j < header.length; j++) {
1031 var headerel = header[j],
1032 closestStyle = getClosest(headerel, 'style-light'),
1033 wcClosestStyle = getClosest(headerel, 'wc-parent-style-light');
1034 if (closestStyle != null && classie.hasClass(closestStyle, 'style-light')) {
1035 switchColorsMenu(0, 'light');
1036 } else if (wcClosestStyle != null && classie.hasClass(wcClosestStyle, 'wc-parent-style-light')) {
1037 switchColorsMenu(0, 'light');
1038 } else if (getClosest(headerel, 'style-dark') != null) {
1039 switchColorsMenu(0, 'dark');
1040 } else if (getClosest(headerel, 'wc-parent-style-dark') != null) {
1041 switchColorsMenu(0, 'dark');
1042 } else {
1043 if (masthead.style.opacity !== 1) masthead.style.opacity = 1;
1044 }
1045 if (classie.hasClass(masthead, 'menu-transparent')) {
1046 if (isMobileTransparent || wwidth > mediaQuery) {
1047 masthead.parentNode.style.height = '0px';
1048 if (classie.hasClass(masthead, 'menu-add-padding')) {
1049 var headerBlock = getClosest(headerel, 'header-uncode-block');
1050 if (headerBlock != null) {
1051 var innerRows = headerel.querySelectorAll('.column_parent > .uncol > .uncoltable > .uncell > .uncont, .uncode-slider .column_child > .uncol > .uncoltable > .uncell > .uncont');
1052 for (var k = 0; k < innerRows.length; k++) {
1053 if (innerRows[k] != undefined) {
1054 if (wwidth > mediaQuery) innerRows[k].style.paddingTop = transmenuHeight + 'px';
1055 else innerRows[k].style.paddingTop = (transmenuHeight - mastheadMobilePaddingTop) + 'px';
1056 }
1057 }
1058 } else {
1059 getDivChildren(headerel, '.header-content', function(headerContent, i) {
1060 if (wwidth > mediaQuery) headerContent.style.paddingTop = transmenuHeight + 'px';
1061 else headerContent.style.paddingTop = (transmenuHeight - mastheadMobilePaddingTop) + 'px';
1062 });
1063 }
1064 }
1065 }
1066 }
1067 if (classie.hasClass(headerel, 'uncoltable')) {
1068 break;
1069 }
1070 }
1071 } else {
1072 if (menuwrapper[0] != undefined) classie.addClass(menuwrapper[0], 'no-header');
1073 classie.removeClass(masthead, 'menu-transparent');
1074 transmenuHeight = 0;
1075 isMobileTransparent = false;
1076 }
1077 } else {
1078 isMobileTransparent = false;
1079 }
1080 if (typeof transmenuel === 'undefined' || !transmenuel.length) isMobileTransparent = false;
1081 bodyTop = document.documentElement['scrollTop'] || document.body['scrollTop'];
1082 UNCODE.bodyTop = bodyTop;
1083 if (!classie.hasClass(document.body, 'vmenu'))
1084 initBox();
1085 scrollFunction();
1086 showHideScrollup(bodyTop);
1087
1088 if ( UNCODE.isMobile ) {
1089
1090 var eventName = 'loadedmetadata';
1091 eventName = eventName.replace(/^on/, '');
1092 var elt = document.createElement('video'[eventName]);
1093 var eventIsSupported = ('on'+eventName in elt);
1094 elt = null;
1095 if ( ! eventIsSupported) {
1096 classie.addClass(document.body, 'video-not-supported');
1097 }
1098 }
1099 },
1100 initRow = function(currentRow) {
1101 UNCODE.adaptive();
1102 var el = typeof currentRow.parentNode !== 'undefined' && currentRow.parentNode.parentNode.getAttribute("data-parent") == 'true' ? currentRow.parentNode : ( currentRow.getAttribute("data-parent") == 'true' ? currentRow.querySelector('.row-parent') : currentRow.parentNode.parentNode ),
1103 rowParent = el.parentNode,
1104 rowInner = currentRow.parentNode,
1105 percentHeight = el.getAttribute("data-height-ratio"),
1106 minHeight = el.getAttribute("data-minheight"),
1107 calculateHeight,
1108 calculatePadding = 0,
1109 isHeader = false,
1110 isFirst = false,
1111 uri_pattern = /\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/ig;
1112
1113 /** Add class to the row when contains responsive column size */
1114 getDivChildren(el.parentNode, '.column_parent, .column_child', function(obj, i, total) {
1115 if ((obj.className).indexOf("col-md-") > - 1) {
1116 classie.addClass(obj.parentNode, 'cols-md-responsive');
1117 }
1118 obj.className = obj.className.replace(/vc_col-sm-(\d{1,2})/g, "");
1119 if ((obj.className).indexOf("col-sm-") > - 1 && (obj.className).indexOf("col-sm-clear") == - 1) {
1120 classie.addClass(obj.parentNode, 'cols-sm-responsive');
1121 }
1122 });
1123
1124 setRowHeight(el);
1125
1126 var elements = 0;
1127 getDivChildren(el, '.row-internal .background-inner', function(obj, i, total) {
1128 elements++;
1129 if (i == 0) {
1130 if (!!obj.style.backgroundImage && obj.style.backgroundImage !== void 0) {
1131 var url = (obj.style.backgroundImage).match(uri_pattern),
1132 image = new Image();
1133 image.onload = function() {
1134 el.setAttribute('data-imgready', 'true');
1135 el.dispatchEvent(new CustomEvent('imgLoaded'));
1136 };
1137 image.src = url[0];
1138 } else {
1139 el.setAttribute('data-imgready', 'true');
1140 el.dispatchEvent(new CustomEvent('imgLoaded'));
1141 }
1142 }
1143 });
1144 if (elements == 0) {
1145 el.setAttribute('data-imgready', 'true');
1146 }
1147
1148 /** init parallax is not mobile */
1149 if ( ! UNCODE.isFullPage ) {
1150 bodyTop = document.documentElement['scrollTop'] || document.body['scrollTop'];
1151 kenburnsRows = el.parentNode.parentNode.querySelectorAll('.with-kburns > .row-background > .background-wrapper, .with-kburns > .fp-tableCell > .row-background > .background-wrapper, .with-kburns > .fp-tableCell > .fp-scrollable > .fp-scroller > .row-background > .background-wrapper');
1152 kenburnsCols = el.querySelectorAll('.with-kburns > .column-background > .background-wrapper');
1153 backwashRows = el.parentNode.parentNode.querySelectorAll('.with-zoomout > .row-background > .background-wrapper, .with-zoomout > .fp-tableCell > .row-background > .background-wrapper, .with-zoomout > .fp-tableCell > .fp-scrollable > .fp-scroller > .row-background > .background-wrapper');
1154 backwashCols = el.querySelectorAll('.with-zoomout > .column-background > .background-wrapper');
1155 if (isMobileParallaxAllowed || !UNCODE.isMobile) {
1156 parallaxRows = el.parentNode.parentNode.querySelectorAll('.with-parallax > .row-background > .background-wrapper, .with-parallax > .fp-tableCell > .row-background > .background-wrapper, .with-parallax > .fp-tableCell > .fp-scrollable > .fp-scroller > .row-background > .background-wrapper');
1157 parallaxCols = el.querySelectorAll('.with-parallax > .column-background > .background-wrapper');
1158 visibleRows = el.parentNode.parentNode;
1159 parallaxRowCol(bodyTop);
1160 visibleRowCol(bodyTop);
1161 } else {
1162 if (UNCODE.isMobile) {
1163 kenburnsHeader(bodyTop);
1164 kenburnsRowCol(bodyTop);
1165 backwashHeader(bodyTop);
1166 backwashRowCol(bodyTop);
1167 }
1168 }
1169 }
1170
1171 shapeDivider();
1172
1173 var wrapLinesWw = wwidth;
1174
1175 //Text animation, automatic lines and highlights
1176 var setWrap;
1177
1178 function word_for_lines(event, $parent_el){
1179
1180 if ( typeof $parent_el === 'undefined' || $parent_el === null ) {
1181 $parent_el = document.body;
1182 }
1183
1184 var $headings = $parent_el.querySelectorAll('.heading-text');
1185
1186 for (var head_k = 0; head_k < $headings.length; head_k++) {
1187 var $heading = $headings[head_k],
1188 heading_cont = $heading.innerHTML,
1189 $row = $heading.closest('.row-parent'),
1190 $owl_carousel = $heading.closest('.owl-carousel-wrapper'),
1191 $owl_item = $heading.closest('.owl-item'),
1192 $words = $heading.querySelectorAll('.split-word'),
1193 setWrap;
1194
1195 if ( ! $words.length ) {
1196 if ( $owl_item !== null )
1197 continue;
1198 }
1199
1200 if ( $owl_carousel === null && typeof event !== 'undefined' && event !== 'resize' && event !== false ) {
1201 continue;
1202 }
1203
1204 if ( $owl_carousel !== null ) {
1205 if (
1206 ( $owl_item === null )
1207 ||
1208 ( $owl_item !== null && classie.hasClass($owl_item, 'active') && $owl_item.getAttribute('data-index') !== '1' )
1209 ||
1210 ( $owl_item !== null && classie.hasClass($owl_item, 'active') && $owl_item.getAttribute('data-index') === '1' && $owl_item.getAttribute('data-already-reached') === 'true' )
1211 ) {
1212 continue;
1213 }
1214 }
1215
1216 $heading.innerHTML = heading_cont;
1217 $words = $heading.querySelectorAll('.split-word');
1218 var lineArray = [],
1219 lineIndex = 0,
1220 lineStart = true,
1221 lineEnd = false,
1222 $text_highlight = $heading.querySelectorAll('.heading-text-highlight'),
1223 $line_wraps = $heading.querySelectorAll('.heading-line-wrap');
1224
1225 if ( $line_wraps.length && typeof event === 'undefined' ) {
1226 continue;
1227 }
1228
1229 var lettering = function(){
1230 var $wraps = $parent_el.querySelectorAll('.animate_inner_when_almost_visible.curtain, .animate_inner_when_almost_visible.curtain-words, .animate_inner_when_almost_visible.typewriter, .animate_inner_when_almost_visible.single-curtain, .animate_inner_when_almost_visible.single-slide, .animate_inner_when_almost_visible.single-slide-opposite');
1231
1232 for (var i = 0; i < $wraps.length; i++) {
1233 var $wrap = $wraps[i],
1234 $lines = $wrap.querySelectorAll('.heading-line-wrap'),
1235 $words = $wrap.querySelectorAll('.split-word'),
1236 containerDelay = $wrap.getAttribute('data-delay'),
1237 containerSpeed = $wrap.getAttribute('data-speed'),
1238 containerSpeed_val = typeof containerSpeed !== 'undefined' && containerSpeed !== null ? parseFloat(containerSpeed) : 400,
1239 containerInterval = typeof $wrap.getAttribute('data-interval') !== 'undefined' && $wrap.getAttribute('data-interval') !== null ? $wrap.getAttribute('data-interval') : 0,
1240 delayAttr = (containerDelay != undefined) ? containerDelay : 0;
1241
1242 if ( classie.hasClass($wrap, 'already-animated') ) {
1243 continue;
1244 }
1245
1246 if ( classie.hasClass($wrap, 'curtain') ) {
1247
1248 for (var il = 0; il < $lines.length; il++) {
1249 var $line = $lines[il],
1250 $spans = $line.querySelectorAll('.split-word-inner');
1251
1252 for (var is = 0; is < $spans.length; is++) {
1253
1254 var $span = $spans[is];
1255
1256 $span.setAttribute('data-delay', ( parseFloat(delayAttr) + ( ( parseFloat(containerInterval) + 100 ) * il ) ) );
1257
1258 if (typeof containerSpeed_val !== 'undefined' ) {
1259 $span.setAttribute('data-speed', containerSpeed_val);
1260 }
1261
1262 classie.addClass($span, 'animate_when_parent_almost_visible');
1263 classie.addClass($span, 'text-bottom-t-top');
1264
1265 if ( is+1 === $spans.length && il+1 === $lines.length ) {
1266 classie.addClass($span, 'anim-tot-checker');
1267 }
1268 }
1269
1270 }
1271
1272 } else if ( classie.hasClass($wrap, 'single-curtain') ) {
1273
1274 var $spans = $wrap.querySelectorAll('.split-char');
1275
1276 for (var is = 0; is < $spans.length; is++) {
1277 var $span = $spans[is];
1278
1279 $span.setAttribute('data-delay', ( parseFloat(delayAttr) + ( ( parseFloat(containerInterval) + 20 ) * is ) ) );
1280
1281 if (typeof containerSpeed_val !== 'undefined' ) {
1282 $span.setAttribute('data-speed', containerSpeed_val);
1283 }
1284
1285 classie.addClass($span, 'animate_when_parent_almost_visible');
1286 classie.addClass($span, 'text-bottom-t-top');
1287
1288 if ( is+1 == $spans.length ) {
1289 classie.addClass($span, 'anim-tot-checker');
1290 }
1291 };
1292
1293 } else if ( classie.hasClass($wrap, 'typewriter') ) {
1294
1295 var $spans = $wrap.querySelectorAll('.split-char');
1296
1297 for (var is = 0; is < $spans.length; is++) {
1298 var $span = $spans[is];
1299
1300 $span.setAttribute('data-delay', ( parseFloat(delayAttr) + ( ( parseFloat(containerInterval) + 20 ) * is ) ) );
1301
1302 if (typeof containerSpeed_val !== 'undefined' ) {
1303 $span.setAttribute('data-speed', containerSpeed_val);
1304 }
1305
1306 classie.addClass($span, 'animate_when_parent_almost_visible');
1307 classie.addClass($span, 'typewriter');
1308
1309 if ( is+1 == $spans.length ) {
1310 classie.addClass($span, 'anim-tot-checker');
1311 }
1312
1313 }
1314
1315 } else if ( classie.hasClass($wrap, 'single-slide') ) {
1316
1317 var $spans = $wrap.querySelectorAll('.split-word-inner');
1318
1319 for (var is = 0; is < $spans.length; is++) {
1320 var $span = $spans[is];
1321
1322 $span.setAttribute('data-delay', ( parseFloat(delayAttr) + ( ( parseFloat(containerInterval) + 50 ) * is ) ) );
1323
1324 if (typeof containerSpeed_val !== 'undefined' ) {
1325 $span.setAttribute('data-speed', containerSpeed_val);
1326 }
1327
1328 classie.addClass($span, 'animate_when_parent_almost_visible');
1329 if ( classie.hasClass(document.body, 'rtl') ) {
1330 classie.addClass($span, 'text-left-t-right');
1331 } else {
1332 classie.addClass($span, 'text-right-t-left');
1333 }
1334
1335 if ( is+1 == $spans.length ) {
1336 classie.addClass($span, 'anim-tot-checker');
1337 }
1338 }
1339
1340 } else if ( classie.hasClass($wrap, 'single-slide-opposite') ) {
1341
1342 var $spans = $wrap.querySelectorAll('.split-word-inner');
1343
1344 for (var is = 0; is < $spans.length; is++) {
1345 var $span = $spans[is];
1346
1347 $span.setAttribute('data-delay', ( parseFloat(delayAttr) + ( ( parseFloat(containerInterval) + 50 ) * is ) ) );
1348
1349 if (typeof containerSpeed_val !== 'undefined' ) {
1350 $span.setAttribute('data-speed', containerSpeed_val);
1351 }
1352
1353 classie.addClass($span, 'animate_when_parent_almost_visible');
1354 if ( classie.hasClass(document.body, 'rtl') ) {
1355 classie.addClass($span, 'text-left-t-right');
1356 } else {
1357 classie.addClass($span, 'text-right-t-left');
1358 }
1359
1360 if ( is+1 == $spans.length ) {
1361 classie.addClass($span, 'anim-tot-checker');
1362 }
1363 }
1364
1365 } else if ( classie.hasClass($wrap, 'curtain-words') ) {
1366
1367 var $spans = $wrap.querySelectorAll('.split-word-inner');
1368
1369 for (var is = 0; is < $spans.length; is++) {
1370 var $span = $spans[is];
1371
1372 $span.setAttribute('data-delay', ( parseFloat(delayAttr) + ( ( parseFloat(containerInterval) + 50 ) * is ) ) );
1373
1374 if (typeof containerSpeed_val !== 'undefined' ) {
1375 $span.setAttribute('data-speed', containerSpeed_val);
1376 }
1377
1378 classie.addClass($span, 'animate_when_parent_almost_visible');
1379 classie.addClass($span, 'text-bottom-t-top');
1380
1381 if ( is+1 == $spans.length ) {
1382 classie.addClass($span, 'anim-tot-checker');
1383 }
1384 }
1385 }
1386
1387 }
1388 }
1389
1390 var removeOldLines = function(){
1391
1392 for (var wrap_k = 0; wrap_k < $line_wraps.length; wrap_k++) {
1393 var $line_wrap = $line_wraps[wrap_k];
1394 var $parent_wrap = $line_wrap.parentNode;
1395 if ( $parent_wrap !== null ) {
1396 while ( $line_wrap.firstChild ) {
1397 $parent_wrap.insertBefore($line_wrap.firstChild, $line_wrap);
1398 }
1399 $parent_wrap.removeChild($line_wrap);
1400 }
1401 }
1402
1403 }
1404
1405 var createHighlightSpans = function(){
1406 for (var high_k = 0; high_k < $text_highlight.length; high_k++) {
1407 var $highlight = $text_highlight[high_k],
1408 atts = $highlight.getAttribute('data-atts'),
1409 objAtts,
1410 styleEl = '',
1411 classEl = '',
1412 animation = false,
1413 hexRe = /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i,
1414 $h_words = $highlight.querySelectorAll('.split-word');
1415
1416 if ( typeof atts !== 'undefined' && atts != '' ) {
1417 objAtts = JSON.parse(atts);
1418 if ( typeof objAtts.bg != 'undefined' ) {
1419 if ( hexRe.test(objAtts.bg)) {
1420 styleEl += 'background-color:' + objAtts.bg + ';';
1421 } else {
1422 classEl += ' ' + objAtts.bg;
1423 }
1424 }
1425 if ( typeof objAtts.color != 'undefined' ) {
1426 if ( hexRe.test(objAtts.color)) {
1427 styleEl += 'color:' + objAtts.color + ';';
1428 } else {
1429 var classChild = objAtts.color;
1430 }
1431 }
1432 if ( typeof objAtts.height != 'undefined' ) {
1433 styleEl += 'height:' + objAtts.height + ';';
1434 }
1435 if ( typeof objAtts.offset != 'undefined' ) {
1436 styleEl += 'bottom:' + objAtts.offset + ';';
1437 }
1438 if ( typeof objAtts.opacity != 'undefined' ) {
1439 styleEl += 'opacity:' + objAtts.opacity + ';';
1440 }
1441 if ( objAtts.animated == 'yes' ) {
1442 animation = true;
1443 }
1444
1445 }
1446
1447 for (var h_words_k = 0; h_words_k < $h_words.length; h_words_k++) {
1448 var $word = $h_words[h_words_k],
1449 $new_el = document.createElement('span');
1450
1451 if ( typeof classChild !== 'undefined' ) {
1452 classie.addClass($word, objAtts.color);
1453 }
1454
1455 if ( h_words_k === 0 ) {
1456 classie.addClass($word, 'first-highlight');
1457 } else if ( (h_words_k+1) === $h_words.length ) {
1458 classie.addClass($word, 'last-highlight');
1459 }
1460
1461 $new_el.className = 'heading-text-highlight-inner' + classEl;
1462 if ( styleEl !== '' ) {
1463 $new_el.setAttribute('style', styleEl);
1464 }
1465
1466 if ( animation ) {
1467 $new_el.setAttribute('data-animated', 'yes');
1468 }
1469
1470 $word.appendChild($new_el);
1471
1472 };
1473
1474 var $parent_highlight = $highlight.parentNode;
1475 while ( $highlight.firstChild ) {
1476 $parent_highlight.insertBefore($highlight.firstChild, $highlight);
1477 }
1478 $parent_highlight.removeChild($highlight);
1479
1480 }
1481
1482 }
1483
1484 var createNewLines = function(){
1485 for (var word_k = 0; word_k < $words.length; word_k++) {
1486 var $word = $words[word_k],
1487 top = $word.offsetTop,
1488 elH = $word.offsetHeight,
1489 $next = typeof $words[(word_k+1)] !== 'undefined' ? $words[(word_k+1)] : null,
1490 nextTop = $next !== null ? $next.offsetTop : null;
1491
1492 if (lineStart) {
1493 lineArray[lineIndex] = [word_k];
1494
1495 if (nextTop !== null && nextTop > (top + elH/2)) {
1496 lineArray[lineIndex].push(word_k);
1497 lineIndex++;
1498 lineStart = true;
1499 } else {
1500 lineStart = false;
1501 }
1502 } else {
1503 if (nextTop !== null && nextTop > (top + elH/2)) {//tollerance
1504 lineArray[lineIndex].push(word_k);
1505 lineIndex++;
1506 lineStart = true;
1507 } else if ( nextTop === null ) {
1508 lineArray[lineIndex].push(word_k);
1509 }
1510 }
1511 }
1512
1513 for (var i = 0; i < lineArray.length; i++) {
1514 var start = lineArray[i][0],
1515 end = lineArray[i][1] + 1;
1516
1517 var spanWrap = document.createElement('span');
1518 spanWrap.className = 'heading-line-wrap';
1519
1520 if (!end) {
1521 window.wrap(spanWrap, $words[start]);
1522 } else {
1523 for (var _i = start; _i < end; _i++) {
1524 if ( typeof $words[_i] !== 'undefined' && $words[_i] !== null ) {
1525 classie.addClass($words[_i], 'heading-temp');
1526 $words[_i].style.zIndex = end - _i;
1527 }
1528 }
1529 var $towrap = $heading.querySelectorAll('.heading-temp');
1530 if ( typeof $towrap[0] !== 'undefined' && $towrap[0] !== null ) {
1531 window.wrapAll(spanWrap, $towrap);
1532 for (var _i = 0; _i < $towrap.length; _i++) {
1533 classie.removeClass($towrap[_i], 'heading-temp');
1534 }
1535 }
1536 }
1537
1538 if ( (i+1) == lineArray.length ) {
1539 classie.addClass($row, 'loaded-split-word');
1540 }
1541
1542 classie.addClass($heading, 'heading-lined');
1543 }
1544 lettering();
1545
1546 }
1547
1548 removeOldLines();
1549 createHighlightSpans();
1550 createNewLines();
1551
1552 $parent_el.addEventListener("owl-carousel-changed", function() {
1553 removeOldLines();
1554 createHighlightSpans();
1555 createNewLines();
1556 });
1557
1558 if ( event !== 'resize' ) {
1559 document.body.dispatchEvent(new CustomEvent('uncode_waypoints'));
1560 }
1561
1562 }
1563 }
1564
1565 var $h_markup = document.body.querySelectorAll('.font-obs'),
1566 fontArr = new Array();
1567
1568 for (var i = 0; i < $h_markup.length; i++) {
1569 var font_to_check = $h_markup[i].getAttribute("data-font");
1570
1571 if ( font_to_check === null ) {
1572 word_for_lines(false, el);
1573 } else {
1574 var font_weight = $h_markup[i].getAttribute("data-weight");
1575 var font_style = $h_markup[i].getAttribute("data-style");
1576
1577 if ( font_weight === null ) {
1578 font_weight = 'normal';
1579 }
1580
1581 if ( font_style === null ) {
1582 font_style = 'normal';
1583 }
1584
1585 font_to_check = font_to_check.split(',');
1586
1587 var font_val = font_to_check[0].replace(/['"]+/g, ''),
1588 font_key = '\''+font_val+'_'+font_weight+'_'+font_style+'\'';
1589
1590 if ( fontArr.indexOf( font_val+'_'+font_weight ) === -1 ) {
1591 fontArr[font_key] = {'family':font_val,'weight':font_weight,'style':font_style };
1592 }
1593 }
1594 }
1595
1596 var counter = 0;
1597
1598 for (var key in fontArr) {
1599 if (fontArr.hasOwnProperty(key)) {
1600 var font = new FontFaceObserver(fontArr[key].family, { weight: fontArr[key].weight, style: fontArr[key].style } );
1601
1602 font.load(null, 10000).then(function (font) {
1603 counter++;
1604 if ( counter == Object.keys(fontArr).length ) {
1605 already_font = true;
1606 requestTimeout(function(){
1607 word_for_lines(false, el);
1608 }, 10);
1609 }
1610 }, function (error) {
1611 word_for_lines(false, el);
1612 });
1613 }
1614 }
1615
1616 el.addEventListener("owl-carousel-initialized", function() {
1617 word_for_lines("owl-carousel-initialized", el);
1618 });
1619
1620 el.addEventListener("vc-shortcodeView-updated", function() {
1621 word_for_lines(false, el);
1622 });
1623
1624 window.addEventListener("resize", function() {
1625 if ( wwidth != wrapLinesWw ) {
1626 clearRequestTimeout(setWrap);
1627 setWrap = requestTimeout( function(){
1628 wrapLinesWw = wwidth;
1629 word_for_lines('resize');
1630 }, 100 );
1631 }
1632 });
1633
1634 scrollFunction();
1635
1636 var videos = document.querySelectorAll('.wp-video-shortcode');
1637 for (var i = 0; i < videos.length; i++) {
1638 var video = videos[i];
1639 if ( typeof video.getAttribute('autoplay') !== 'undefined' && video.getAttribute('autoplay') !== null && ( typeof video.getAttribute('muted') === 'undefined' || video.getAttribute('muted') === null ) ) {
1640 video.oncanplay = function(e) {
1641 video.muted = true;
1642 video.play();
1643 };
1644 break;
1645 }
1646 }
1647
1648 },
1649 setRowHeight = function(container, forced, resized) {
1650 var currentTallest = 0,
1651 percentHeight = 0,
1652 minHeight = 0,
1653 el,
1654 child,
1655 hasSubCols = false;
1656 if (container.length == undefined) {
1657 container = [container];
1658 }
1659 // Loop for each container element to match their heights
1660 for (var i = 0; i < container.length; i++) {
1661 var el = container[i],
1662 $row = el,
1663 totalHeight = 0,
1664 colsArray = new Array(),
1665 calculatePadding = 0,
1666 $rowParent = $row.parentNode,
1667 isHeader = false,
1668 isFirst = false;
1669 $row.oversized = false;
1670 percentHeight = el.getAttribute("data-height-ratio");
1671 minHeight = el.getAttribute("data-minheight");
1672 child = (el.firstElementChild || el.firstChild);
1673 var childHeight = outerHeight(child);
1674 /** window height without header **/
1675 if (!!percentHeight || !!minHeight || forced || (isIE && classie.hasClass(el, 'unequal')) ) {
1676 child.style.height = '';
1677 if (!!percentHeight) {
1678 if (percentHeight == 'full') {
1679 currentTallest = parseInt(wheight);
1680 } else {
1681 currentTallest = parseInt((wheight * percentHeight) / 100);
1682 }
1683 } else {
1684 currentTallest = el.clientHeight;
1685 }
1686
1687 if (!!minHeight) {
1688 if (currentTallest < minHeight || currentTallest == undefined) currentTallest = parseInt(minHeight);
1689 }
1690
1691 if (getClosest(el, 'header-uncode-block') != null) {
1692 el.setAttribute('data-row-header', 'true');
1693 isHeader = true;
1694 } else {
1695 if (pageHeader == null) {
1696 var prevRow = $rowParent.previousSibling;
1697 if (prevRow != null && prevRow.innerText == 'UNCODE.initHeader();') {
1698 isFirst = true;
1699 }
1700 }
1701 }
1702
1703 if (classie.hasClass(el, 'row-slider')) {
1704 percentHeight = el.getAttribute("data-height-ratio");
1705 minHeight = el.getAttribute("data-minheight");
1706 if (percentHeight == 'full') {
1707 currentTallest = parseInt(wheight);
1708 } else {
1709 currentTallest = parseInt((wheight * percentHeight) / 100);
1710 }
1711
1712 var computedStyleRow = getComputedStyle(el),
1713 computedStyleRowParent = getComputedStyle($rowParent);
1714 calculatePadding -= (parseFloat(computedStyleRow.paddingTop) + parseFloat(computedStyleRowParent.paddingTop));
1715 calculatePadding -= (parseFloat(computedStyleRow.paddingBottom) + parseFloat(computedStyleRowParent.paddingBottom));
1716
1717 if (isHeader || isFirst) {
1718 if (isMobileTransparent || wwidth > mediaQuery) currentTallest -= menuHeight - transmenuHeight;
1719 else currentTallest -= menuHeight - secmenuHeight;
1720 currentTallest += calculatePadding;
1721 } else {
1722 if (isMobileTransparent || wwidth > mediaQuery) currentTallest += calculatePadding;
1723 else currentTallest = 'auto';
1724 }
1725
1726 getDivChildren(el, '.owl-carousel', function(owl, i) {
1727 owl.style.height = (currentTallest == 'auto' ? 'auto' : currentTallest + 'px');
1728 if (isIE) {
1729 getDivChildren(owl, '.owl-stage', function(owlIn, i) {
1730 owlIn.style.height = (currentTallest == 'auto' ? '100%' : currentTallest + 'px');
1731 });
1732 }
1733 });
1734 if ( UNCODE.isFullPageSnap || classie.hasClass(masthead, 'menu-transparent') )
1735 continue;
1736 else {
1737 if ( classie.hasClass(document.body, 'uncode-fp-menu-hide') ) {
1738 $rowParent.parentNode.style.paddingTop = menuHeight + 'px';
1739 }
1740 }
1741 } else {
1742 if (isHeader || isFirst || UNCODE.isFullPage ) {
1743 if ( !( UNCODE.isFullPage && !classie.hasClass(masthead, 'menu-transparent') && classie.hasClass(document.body, 'uncode-fp-menu-hide') && !isHeader && !isFirst ) ) {
1744 if (isMobileTransparent || wwidth > mediaQuery) currentTallest -= menuHeight - transmenuHeight;
1745 else currentTallest -= menuHeight - secmenuHeight;
1746 }
1747 if ( UNCODE.isFullPage && classie.hasClass(document.body, 'uncode-scroll-safe-padding') && classie.hasClass(masthead, 'menu-transparent') && !classie.hasClass(document.body, 'uncode-fp-menu-hide') ) {
1748 var safeMenuHeight = parseFloat(document.body.getAttribute("data-additional-padding")) + parseFloat(menuHeight);
1749 if ( (" " + child.parentNode.className + " ").replace(/[\n\t]/g, " ").indexOf("-top-padding ") < 0 || classie.hasClass(child.parentNode, 'single-top-padding') ) {
1750 classie.addClass(child.parentNode, 'fp-safe-padding-top');
1751 child.parentNode.style.paddingTop = safeMenuHeight + 'px';
1752 }
1753 if ( (" " + child.parentNode.className + " ").replace(/[\n\t]/g, " ").indexOf("-bottom-padding ") < 0 || classie.hasClass(child.parentNode, 'single-bottom-padding') ) {
1754 classie.addClass(child.parentNode, 'fp-safe-padding-bottom');
1755 child.parentNode.style.paddingBottom = safeMenuHeight + 'px';
1756 }
1757 }
1758 if ( !classie.hasClass(masthead, 'menu-transparent') && classie.hasClass(document.body, 'uncode-fp-menu-hide') && ( isFirst || isHeader ) )
1759 $rowParent.parentNode.style.paddingTop = menuHeight + 'px';
1760
1761 var computedStyleRow = getComputedStyle(el),
1762 computedStyleRowParent = getComputedStyle($rowParent);
1763 calculatePadding -= (parseFloat(computedStyleRow.paddingTop) + parseFloat(computedStyleRowParent.paddingTop));
1764 calculatePadding -= (parseFloat(computedStyleRow.paddingBottom) + parseFloat(computedStyleRowParent.paddingBottom));
1765
1766 currentTallest += calculatePadding;
1767
1768 } else {
1769
1770 var computedStyleRow = getComputedStyle(el),
1771 computedStyleRowParent = getComputedStyle($rowParent);
1772 calculatePadding -= (parseFloat(computedStyleRow.paddingTop) + parseFloat(computedStyleRowParent.paddingTop));
1773 calculatePadding -= (parseFloat(computedStyleRow.paddingBottom) + parseFloat(computedStyleRowParent.paddingBottom));
1774
1775 if (wwidth > mediaQuery) currentTallest += calculatePadding;
1776 else currentTallest = 'auto';
1777
1778 }
1779 }
1780 if ( UNCODE.isFullPage ) {
1781 currentTallest -= UNCODE.adminBarHeight;
1782 }
1783 if (!!minHeight) {
1784 if (currentTallest < minHeight || currentTallest == 'auto') currentTallest = parseInt(minHeight);
1785 }
1786
1787 if ( UNCODE.isFrontEndEditor && child !== null ) {
1788 var innerWrapper = child.querySelectorAll('.owl-carousel-wrapper');
1789 if ( innerWrapper.length ) {
1790 getDivChildren(child, '.owl-carousel-wrapper', function(wrapper, i) {
1791 if ( wrapper !== null ) {
1792 wrapper.style.height = (currentTallest == 'auto' ? 'auto' : currentTallest + 'px');
1793 } else {
1794 child.style.height = (currentTallest == 'auto' ? 'auto' : currentTallest + 'px');
1795 }
1796 });
1797 } else {
1798 child.style.height = (currentTallest == 'auto' ? 'auto' : currentTallest + 'px');
1799 }
1800 } else {
1801 child.style.height = (currentTallest == 'auto' ? 'auto' : currentTallest + 'px');
1802 }
1803 } else {
1804 currentTallest = 0;
1805 if ( UNCODE.isFrontEndEditor && child !== null ) {
1806
1807 child.style.height = '';
1808
1809 getDivChildren(el, '.owl-carousel', function(owl, i) {
1810 owl.style.height = '';
1811 if (isIE) {
1812 getDivChildren(owl, '.owl-stage', function(owlIn, i) {
1813 owlIn.style.height = '';
1814 });
1815 }
1816 });
1817 }
1818 }
1819
1820 if (wwidth > mediaQuery) {
1821
1822 getDivChildren(el, '.column_parent', function(col, i, total) {
1823 var $col = col,
1824 $colHeight = 0,
1825 $colDiff = 0,
1826 $colPercDiff = 100;
1827 $col.oversized = false;
1828 $col.forceHeight = currentTallest;
1829 currentTallest = child.clientHeight;
1830 if ((isHeader || isFirst) && currentTallest != 'auto') currentTallest -= transmenuHeight;
1831 var getFirstCol = null,
1832 getMargin = 0,
1833 getSubMargin = 0;
1834 getDivChildren(col, '.row-child', function(obj, i, total) {
1835 var $colChild = obj,
1836 $colParent = $colChild.parentNode,
1837 computedStyleCol = getComputedStyle($colParent);
1838 parseFloat(computedStyleCol.marginTop);
1839 getSubMargin += parseFloat(computedStyleCol.marginTop);
1840 });
1841 currentTallest += getSubMargin;
1842 getDivChildren(col, '.row-child', function(obj, i, total) {
1843 var $colChild = obj,
1844 $colInner,
1845 $colParent = $colChild.parentNode,
1846 $uncont = $colParent.parentNode;
1847 for (var it = 0; it < $colChild.childNodes.length; it++) {
1848 if ( ! classie.hasClass($colChild.childNodes[it], 'uncode-divider-wrap') ) {
1849 $colInner = $colChild.childNodes[it];
1850 break;
1851 }
1852 }
1853 if (i == 0 && total > 1) getFirstCol = $colInner;
1854 $colChild.oversized = false;
1855 percentHeight = $colChild.getAttribute("data-height");
1856 minHeight = $colChild.getAttribute("data-minheight");
1857 if (percentHeight != null || minHeight != null) {
1858 if ( ! classie.hasClass($colInner, 'uncode-divider-wrap') )
1859 $colInner.style.height = '';
1860 $colParent.style.height = 'auto';
1861 $uncont.style.height = '100%';
1862 $colChild.removeAttribute("style");
1863 var newHeight = (percentHeight != null) ? Math.ceil((currentTallest) * (percentHeight / 100)) : parseInt(minHeight);
1864 var computedStyleCol = getComputedStyle($colParent);
1865 getMargin = parseFloat(computedStyleCol.marginTop);
1866 newHeight -= (getMargin);
1867 $colPercDiff -= (percentHeight != null) ? percentHeight : 0;
1868 if (currentTallest > newHeight) {
1869 var getColHeight = outerHeight($colChild);
1870 if (getColHeight > newHeight) {
1871 $colHeight += getColHeight;
1872 $colDiff += getColHeight;
1873 $colChild.oversized = true;
1874 $col.oversized = true;
1875 $row.oversized = true;
1876 } else {
1877 $colHeight += newHeight;
1878 if ( ! classie.hasClass($colInner, 'uncode-divider-wrap') )
1879 $colInner.style.height = newHeight + 'px';
1880 }
1881 }
1882 } else {
1883 $colHeight += outerHeight($colChild);
1884 }
1885 });
1886 if (getFirstCol != null) {
1887 getFirstCol.style.height = (parseFloat(getFirstCol.style.height) - getMargin) + 'px';
1888 }
1889 colsArray.push({
1890 colHeight: $colHeight,
1891 colDiv: $col
1892 });
1893 $col.colDiff = $colDiff;
1894 $col.colPercDiff = $colPercDiff;
1895
1896 });
1897
1898 if ($row.oversized) {
1899 child.style.height = '';
1900 colsArray.sort(function(a, b) {
1901 if (a.colHeight < b.colHeight) return 1;
1902 if (a.colHeight > b.colHeight) return -1;
1903 return 0;
1904 });
1905 var $totalHeight = 0;
1906 colsArray.forEach(function(col) {
1907 var $col = col.colDiv,
1908 $colHeight = col.colHeight;
1909 getDivChildren($col, '.row-child', function(obj, i, total) {
1910 var $colChild = obj,
1911 $colInner = $colChild.children[0],
1912 percentHeight = $colChild.getAttribute("data-height"),
1913 $colParent = $colChild.parentNode,
1914 $uncont = $colParent.parentNode,
1915 newHeight;
1916
1917 $colHeight = $col.forceHeight - $col.colDiff;
1918 if (percentHeight != null) {
1919 if ($colHeight > 0) {
1920 if ($col.oversized) {
1921 if (!$colChild.oversized) {
1922 newHeight = Math.ceil(($colHeight) * (percentHeight / $col.colPercDiff));
1923 if (i == total - 1 && total > 1) {
1924 $uncont.style.height = 'auto';
1925 $colChild.style.display = 'none';
1926 newHeight = outerHeight($col.parentNode) - outerHeight($uncont);
1927 $uncont.style.height = '100%';
1928 $colChild.style.display = 'table';
1929 }
1930 if (newHeight == 0) newHeight = Math.ceil(($col.forceHeight) * (percentHeight / 100));
1931 $colInner.style.height = newHeight + 'px';
1932 }
1933 } else {
1934 if ($totalHeight == 0) newHeight = Math.ceil(($colHeight) * (percentHeight / $col.colPercDiff));
1935 else {
1936 newHeight = Math.ceil(($totalHeight) * (percentHeight / $col.colPercDiff));
1937 }
1938 if (i == total - 1 && total > 1) {
1939 $uncont.style.height = 'auto';
1940 $colChild.style.display = 'none';
1941 newHeight = outerHeight($col.parentNode) - outerHeight($uncont);
1942 $uncont.style.height = '100%';
1943 $colChild.style.display = 'table';
1944 }
1945 $colInner.style.height = newHeight + 'px';
1946 }
1947 } else {
1948 if ($colChild.oversized) {
1949 if ($totalHeight == 0) newHeight = Math.ceil(($colHeight) * (percentHeight / $col.colPercDiff));
1950 else {
1951 if ($col.colPercDiff == 0) $col.colPercDiff = 100;
1952 newHeight = Math.ceil(($totalHeight) * (percentHeight / $col.colPercDiff));
1953 }
1954 if (i == total - 1 && total > 1) {
1955 $uncont.style.height = 'auto';
1956 $colChild.style.display = 'none';
1957 newHeight = outerHeight($col.parentNode) - outerHeight($uncont);
1958 $uncont.style.height = '100%';
1959 $colChild.style.display = 'table';
1960 }
1961 $colInner.style.height = newHeight + 'px';
1962 }
1963 }
1964 }
1965 });
1966 var uncell = $col.getElementsByClassName('uncell');
1967 if (uncell[0] != undefined && $totalHeight == 0) $totalHeight = outerHeight(uncell[0]);
1968 });
1969 }
1970 if (isFF) {
1971 getDivChildren(el, '.uncoltable', function(col, i, total) {
1972 if (col.style.minHeight != '') {
1973 col.style.height = '';
1974 }
1975 });
1976 }
1977 if (resized) {
1978 getDivChildren(el, '.row-child > .row-inner', function(obj, k, total) {
1979 if (obj.style.height == '') {
1980 if (wwidth > mediaQueryMobile) {
1981 var getStyle = (window.getComputedStyle((obj.parentNode), null)),
1982 getInnerHeight = (parseInt(obj.parentNode.clientHeight) - parseInt(getStyle.paddingTop) - parseInt(getStyle.paddingBottom));
1983 obj.style.height = getInnerHeight + 'px';
1984 //obj.style.marginBottom = '-1px';
1985 }
1986 }
1987 });
1988 getDivChildren(el, '.row-parent > .row-inner', function(obj, k, total) {
1989 if (obj.style.height != '') {
1990 var getStyle = (window.getComputedStyle((obj.parentNode), null)),
1991 getInnerHeight = (parseInt(obj.parentNode.clientHeight) - parseInt(getStyle.paddingTop) - parseInt(getStyle.paddingBottom)),
1992 getTempHeight = parseInt(obj.style.height);
1993 if (getInnerHeight > getTempHeight) {
1994 obj.style.height = getInnerHeight + 'px';
1995 //obj.style.marginBottom = '-1px';
1996 }
1997 }
1998 });
1999 }
2000 } else {
2001 if (isFF) {
2002 getDivChildren(el, '.uncoltable', function(col, i, total) {
2003 if (col.style.minHeight != '') {
2004 col.style.height = '';
2005 col.style.height = outerHeight(col.parentNode) + 'px';
2006 }
2007 });
2008 }
2009 if (isIE && (wwidth > mediaQueryMobile)) {
2010 if (child.style.height == 'auto') {
2011 child.style.height = outerHeight(child) + 'px';
2012 }
2013 }
2014 }
2015 if (isFF) {
2016 var sliderColumnFix = document.querySelector('.uncode-slider .row-inner > .column_child:only-child');
2017 if (sliderColumnFix != null) {
2018 if (wwidth > mediaQuery) {
2019 sliderColumnFix.style.setProperty("height", "");
2020 } else {
2021 sliderColumnFix.style.setProperty("height", "");
2022 sliderColumnFix.style.setProperty("height", outerHeight(sliderColumnFix.parentNode) + "px", "important");
2023 }
2024 }
2025 }
2026 };
2027 if ( resized || UNCODE.isFrontEndEditor ) {
2028 window.scroll(0, scrollRowHeight_fix);
2029 }
2030 },
2031 headerHeight = function(container) {
2032 forEachElement(container, function(el, i) {
2033 var getHeight = el.getAttribute("data-height"),
2034 newHeight = ((wheight * getHeight) / 100);
2035 if (getHeight != 'fixed' && newHeight != 0) {
2036 if (isMobileTransparent || wwidth > mediaQuery) newHeight -= menuHeight - transmenuHeight;
2037 else newHeight -= menuHeight - secmenuHeight;
2038 el.style.height = newHeight + 'px';
2039 }
2040 });
2041 if (masthead != undefined) {
2042 masthead.parentNode.style.height = menuHeight + 'px';
2043 if (header != undefined && header.length) {
2044 if (classie.hasClass(masthead, 'menu-transparent')) {
2045 if (isMobileTransparent || wwidth > mediaQuery) {
2046 masthead.parentNode.style.height = '0px';
2047 if (classie.hasClass(masthead, 'menu-add-padding')) {
2048 for (var j = 0; j < header.length; j++) {
2049 var headerel = header[j];
2050 var headerBlock = getClosest(headerel, 'header-uncode-block');
2051 if (headerBlock != null) {
2052 var innerRows = headerel.querySelectorAll('.column_parent > .uncol > .uncoltable > .uncell > .uncont, .uncode-slider .column_child > .uncol > .uncoltable > .uncell > .uncont');
2053 for (var k = 0; k < innerRows.length; k++) {
2054 if (innerRows[k] != undefined) {
2055 if (wwidth > mediaQuery) innerRows[k].style.paddingTop = transmenuHeight + 'px';
2056 else innerRows[k].style.paddingTop = (transmenuHeight - mastheadMobilePaddingTop) + 'px';
2057 }
2058 }
2059 } else {
2060 getDivChildren(headerel, '.header-content', function(headerContent, i) {
2061 if (wwidth > mediaQuery) headerContent.style.paddingTop = transmenuHeight + 'px';
2062 else headerContent.style.paddingTop = (transmenuHeight - mastheadMobilePaddingTop) + 'px';
2063 });
2064 }
2065 }
2066 }
2067 }
2068 }
2069 }
2070 }
2071 },
2072 initVideoComponent = function(container, classTarget) {
2073 if ( UNCODE.isFrontEndEditor )
2074 return;
2075 getDivChildren(container, classTarget, function(el, i) {
2076 var width = outerWidth(el),
2077 pWidth, // player width, to be defined
2078 height = outerHeight(el),
2079 pHeight, // player height, tbd
2080 $tubularPlayer = (el.getElementsByTagName('iframe').length == 1) ? el.getElementsByTagName('iframe') : el.getElementsByTagName('video'),
2081 ratio = (el.getAttribute("data-ratio") != null) ? Number(el.getAttribute("data-ratio")) : typeof $tubularPlayer[0] !== 'undefined' ? $tubularPlayer[0].getAttribute("data-ratio") : '1.8',
2082 heightOffset = 80,
2083 widthOffset = heightOffset * ratio;
2084 // when screen aspect ratio differs from video, video must center and underlay one dimension
2085 if ($tubularPlayer[0] != undefined) {
2086 if (width / ratio < height) { // if new video height < window height (gap underneath)
2087 pWidth = Math.ceil((height + heightOffset) * ratio); // get new player width
2088 $tubularPlayer[0].style.width = pWidth + widthOffset + 'px';
2089 $tubularPlayer[0].style.height = height + heightOffset + 'px';
2090 $tubularPlayer[0].style.left = ((width - pWidth) / 2) - (widthOffset / 2) + 'px';
2091 $tubularPlayer[0].style.top = '-' + (heightOffset / 2) + 'px';
2092 $tubularPlayer[0].style.position = 'absolute';
2093 } else { // new video width < window width (gap to right)
2094 pHeight = Math.ceil(width / ratio); // get new player height
2095 $tubularPlayer[0].style.width = width + widthOffset + 'px';
2096 $tubularPlayer[0].style.height = pHeight + heightOffset + 'px';
2097 $tubularPlayer[0].style.left = '-' + (widthOffset / 2) + 'px';
2098 $tubularPlayer[0].style.top = ((height - pHeight) / 2) - (heightOffset / 2) + 'px';
2099 $tubularPlayer[0].style.position = 'absolute';
2100 }
2101 }
2102 });
2103 },
2104 init_overlay = function() {
2105 if ( UNCODE.isFrontEndEditor )
2106 return;
2107 var triggerButton,
2108 closeButtons = new Array();
2109 function toggleOverlay(btn) {
2110 Array.prototype.forEach.call(document.querySelectorAll('div.overlay'), function(overlay) {
2111 if (btn.getAttribute('data-area') == overlay.getAttribute('data-area')) {
2112 var container = document.querySelector('div.' + btn.getAttribute('data-container')),
2113 inputField = overlay.querySelector('.search-field');
2114 if (classie.has(overlay, 'open')) {
2115 window.dispatchEvent(menuClose);
2116 overlayOpened = false;
2117 classie.remove(overlay, 'open');
2118 classie.remove(container, 'overlay-open');
2119 classie.add(overlay, 'close');
2120 classie.remove(overlay, 'open-items');
2121 var onEndTransitionFn = function(ev) {
2122 if (transitionEvent) {
2123 if (ev.propertyName !== 'visibility') return;
2124 this.removeEventListener(transitionEvent, onEndTransitionFn);
2125 }
2126 classie.remove(overlay, 'close');
2127 };
2128 if (transitionEvent) {
2129 overlay.addEventListener(transitionEvent, onEndTransitionFn);
2130 } else {
2131 onEndTransitionFn();
2132 }
2133 } else if (!classie.has(overlay, 'close')) {
2134 window.dispatchEvent(menuOpen);
2135 overlayOpened = true;
2136 classie.add(overlay, 'open');
2137 classie.add(container, 'overlay-open');
2138 if (jQuery('body.menu-overlay').length == 0) {
2139 setTimeout(function() {
2140 inputField.focus();
2141 }, 1000);
2142 }
2143 setTimeout(function() {
2144 if (classie.has(overlay, 'overlay-sequential')) classie.add(overlay, 'open-items');
2145 }, 800);
2146 }
2147 }
2148 });
2149
2150 if (classie.hasClass(btn, 'search-icon') || classie.hasClass(btn, 'menu-close-search')) return;
2151
2152 if (classie.hasClass(triggerButton, 'close')) {
2153 UNCODE.menuOpened = false;
2154 classie.removeClass(triggerButton, 'close');
2155 classie.addClass(triggerButton, 'closing');
2156 Array.prototype.forEach.call(closeButtons, function(closeButton) {
2157 if (!classie.hasClass(closeButton, 'menu-close-search')) {
2158 classie.removeClass(closeButton, 'close');
2159 classie.addClass(closeButton, 'closing');
2160 }
2161 });
2162 setTimeout(function() {
2163 classie.removeClass(triggerButton, 'closing');
2164 triggerButton.style.opacity = 1;
2165 Array.prototype.forEach.call(closeButtons, function(closeButton) {
2166 if (!classie.hasClass(closeButton, 'menu-close-search')) {
2167 classie.removeClass(closeButton, 'closing');
2168 closeButton.style.opacity = 0;
2169 }
2170 });
2171 }, 800);
2172 } else {
2173 UNCODE.menuOpened = true;
2174 triggerButton.style.opacity = 0;
2175 var getBtnRect = !classie.hasClass(triggerButton, 'search-icon') ? triggerButton.getBoundingClientRect() : null;
2176 Array.prototype.forEach.call(closeButtons, function(closeButton) {
2177 if (!classie.hasClass(closeButton, 'menu-close-search')) {
2178 classie.addClass(triggerButton, 'close');
2179 if (getBtnRect != null) closeButton.setAttribute('style', 'top:' + getBtnRect.top + 'px; left:'+ getBtnRect.left + 'px !important');
2180 classie.addClass(closeButton, 'close');
2181 closeButton.style.opacity = 1;
2182 }
2183 });
2184 window.addEventListener("resize", function() {
2185 positionCloseBtn(triggerButton, closeButtons);
2186 });
2187 }
2188 }
2189 function positionCloseBtn(triggerButton, closeButtons){
2190 var getBtnRect = !classie.hasClass(triggerButton, 'search-icon') ? triggerButton.getBoundingClientRect() : null;
2191 Array.prototype.forEach.call(closeButtons, function(closeButton) {
2192 if (!classie.hasClass(closeButton, 'menu-close-search')) {
2193 if (getBtnRect != null) closeButton.setAttribute('style', 'top:' + getBtnRect.top + 'px; left:'+ getBtnRect.left + 'px !important');
2194 closeButton.style.opacity = 1;
2195 }
2196 });
2197 }
2198 (function bindEscape() {
2199 document.onkeydown = function(evt) {
2200 evt = evt || window.event;
2201 var isEscape = false;
2202 if ("key" in evt) {
2203 isEscape = (evt.key == "Escape" || evt.key == "Esc");
2204 } else {
2205 isEscape = (evt.keyCode == 27);
2206 }
2207 if (isEscape && overlayOpened) {
2208 Array.prototype.forEach.call(closeButtons, function(closeButton) {
2209 if (classie.hasClass(closeButton, 'overlay-close') && classie.hasClass(closeButton, 'menu-button-overlay')) {
2210 closeButton.click();
2211 }
2212 });
2213 }
2214 };
2215 })();
2216 Array.prototype.forEach.call(document.querySelectorAll('.trigger-overlay'), function(triggerBttn) {
2217 if (UNCODE.menuOpened) return;
2218 triggerBttn.addEventListener('click', function(e) {
2219 triggerButton = e.currentTarget;
2220 if (wwidth < mediaQuery && classie.hasClass(triggerButton, 'search-icon')) {
2221 return true;
2222 } else {
2223 e.stopPropagation();
2224 if (wwidth > mediaQuery) toggleOverlay(triggerButton);
2225 else {
2226 if (classie.addClass(triggerButton, 'search-icon')) return true;
2227 }
2228 e.preventDefault();
2229 return false;
2230 }
2231 }, false);
2232 });
2233 Array.prototype.forEach.call(document.querySelectorAll('.overlay-close'), function(closeBttn) {
2234 closeButtons.push(closeBttn);
2235 closeBttn.addEventListener('click', function(e) {
2236 if (wwidth > mediaQuery) toggleOverlay(closeBttn);
2237 e.preventDefault();
2238 return false;
2239 }, false);
2240 });
2241 },
2242 /** All scrolling functions - Begin */
2243 /** Shrink menu **/
2244 shrinkMenu = function(bodyTop) {
2245 if ( UNCODE.isFrontEndEditor )
2246 return;
2247 var logoShrink,
2248 offset = 100;
2249 for (var i = 0; i < logoel.length; i++) {
2250 if (((secmenuHeight == 0) ? bodyTop > menuHeight : bodyTop > secmenuHeight + offset) && !classie.hasClass(logoel[i], 'shrinked') && (wwidth > mediaQuery)) {
2251 classie.addClass(logoel[i], 'shrinked');
2252 if (logoMinScale != undefined) {
2253 logoShrink = logolink.children;
2254 Array.prototype.forEach.call(logoShrink, function(singleLogo) {
2255 singleLogo.style.height = logoMinScale + 'px';
2256 singleLogo.style.lineHeight = logoMinScale + 'px';
2257 if (classie.hasClass(singleLogo, 'text-logo')) singleLogo.style.fontSize = logoMinScale + 'px';
2258 });
2259 }
2260 setTimeout(function() {
2261 calculateMenuHeight(false);
2262 //window.dispatchEvent(new Event('resize'));
2263 }, 300);
2264 } else if ((((secmenuHeight == 0) ? bodyTop == 0 : bodyTop <= secmenuHeight + offset) || (wwidth < mediaQuery)) && classie.hasClass(logoel[i], 'shrinked')) {
2265 classie.removeClass(logoel[i], 'shrinked');
2266 if (logoMinScale != undefined) {
2267 logoShrink = logolink.children;
2268 Array.prototype.forEach.call(logoShrink, function(singleLogo) {
2269 singleLogo.style.height = singleLogo.getAttribute('data-maxheight') + 'px';
2270 singleLogo.style.lineHeight = singleLogo.getAttribute('data-maxheight') + 'px';
2271 if (classie.hasClass(singleLogo, 'text-logo')) singleLogo.style.fontSize = singleLogo.getAttribute('data-maxheight') + 'px';
2272 });
2273 }
2274 setTimeout(function() {
2275 calculateMenuHeight(false);
2276 //window.dispatchEvent(new Event('resize'));
2277 }, 300);
2278 }
2279 }
2280 },
2281 /** Switch colors menu **/
2282 switchColorsMenu = function(bodyTop, style) {
2283 for (var i = 0; i < transmenuel.length; i++) {
2284 if (masthead.style.opacity !== 1) masthead.style.opacity = 1;
2285 if ((secmenuHeight == 0) ? bodyTop > menuHeight / 2 : bodyTop > secmenuHeight) {
2286 if (classie.hasClass(masthead, 'style-dark-original')) {
2287 logo.className = logo.className.replace("style-light", "style-dark");
2288 }
2289 if (classie.hasClass(masthead, 'style-light-original')) {
2290 logo.className = logo.className.replace("style-dark", "style-light");
2291 }
2292 if (style != undefined) {
2293 if (style == 'dark') {
2294 classie.removeClass(transmenuel[i], 'style-light-override');
2295 }
2296 if (style == 'light') {
2297 classie.removeClass(transmenuel[i], 'style-dark-override');
2298 }
2299 classie.addClass(transmenuel[i], 'style-' + style + '-override');
2300 }
2301 } else {
2302 if (style != undefined) {
2303 if (style == 'dark') {
2304 classie.removeClass(transmenuel[i], 'style-light-override');
2305 }
2306 if (style == 'light') {
2307 classie.removeClass(transmenuel[i], 'style-dark-override');
2308 }
2309 classie.addClass(transmenuel[i], 'style-' + style + '-override');
2310 }
2311 }
2312 }
2313 if (pageHeader != undefined) {
2314 if (style != undefined) {
2315 if (classie.hasClass(pageHeader, 'header-style-dark')) {
2316 classie.removeClass(pageHeader, 'header-style-dark');
2317 }
2318 if (classie.hasClass(pageHeader, 'header-style-light')) {
2319 classie.removeClass(pageHeader, 'header-style-light');
2320 }
2321 classie.addClass(pageHeader, 'header-style-' + style);
2322 }
2323 }
2324 },
2325 /** VisibleRows **/
2326 visibleRowCol = function(bodyTop) {
2327 if ( typeof visibleRows == 'object') {
2328 for (var i = 0; i < visibleRows.length; i++) {
2329 var section = visibleRows[i],
2330 sectionHeight = outerHeight(section),
2331 offSetTop = bodyTop + ( section != null ? section.getBoundingClientRect().top : 0 ),
2332 offSetPosition = wheight + bodyTop - offSetTop;
2333 if (offSetPosition > 0 && offSetPosition < (sectionHeight + wheight)) {
2334 classie.addClass($kenburnsInner[0], 'uncode-scroll-visible');
2335 visibleRows[i].dispatchEvent(new CustomEvent('enter-row'));
2336 } else {
2337 classie.removeClass($kenburnsInner[0], 'uncode-scroll-visible');
2338 visibleRows[i].dispatchEvent(new CustomEvent('exit-row'));
2339 }
2340 }
2341 }
2342 },
2343 /** KenBurns **/
2344 kenburnsHeader = function(bodyTop) {
2345 var value;
2346 if ( typeof kenburnsHeaders == 'object' && kenburnsHeaders.length ) {
2347 for (var i = 0; i < kenburnsHeaders.length; i++) {
2348 var section = kenburnsHeaders[i].parentNode,
2349 sectionHeight = outerHeight(section),
2350 offSetTop = bodyTop + (section != null ? (classie.hasClass(section.parentNode.parentNode, 'owl-carousel') ? section.parentNode.parentNode.getBoundingClientRect().top : section.getBoundingClientRect().top) : 0),
2351 offSetPosition = wheight + bodyTop - offSetTop,
2352 $kenburnsInner = kenburnsHeaders[i].querySelectorAll('.header-bg');
2353 if (classie.hasClass(kenburnsHeaders[i], 'header-carousel-wrapper')) {
2354 $kenburnsInner = kenburnsHeaders[i].querySelectorAll('.t-background-cover');
2355 }
2356 if (offSetPosition > 0 && offSetPosition < (sectionHeight + wheight)) {
2357 for (var i = 0; i < $kenburnsInner.length; i++) {
2358 classie.addClass($kenburnsInner[i], 'uncode-kburns');
2359 $kenburnsInner[i].dispatchEvent(new CustomEvent('enter-kburns'));
2360 }
2361 } else {
2362 for (var i = 0; i < $kenburnsInner.length; i++) {
2363 classie.removeClass($kenburnsInner[i], 'uncode-kburns');
2364 $kenburnsInner[i].dispatchEvent(new CustomEvent('exit-kburns'));
2365 }
2366 }
2367 }
2368 }
2369 },
2370 kenburnsRowCol = function(bodyTop) {
2371 var value;
2372 if ( UNCODE.isFrontEndEditor ) {
2373 kenburnsRows = document.querySelectorAll('.with-kburns > .row-background > .background-wrapper, .with-kburns > .fp-tableCell > .row-background > .background-wrapper, .with-kburns > .fp-tableCell > .fp-scrollable > .fp-scroller > .row-background > .background-wrapper');
2374 }
2375 if ( typeof kenburnsRows == 'object' && kenburnsRows.length ) {
2376 for (var i = 0; i < kenburnsRows.length; i++) {
2377 var section = kenburnsRows[i].parentNode,
2378 sectionHeight = outerHeight(section),
2379 offSetTop = bodyTop + (section != null ? (classie.hasClass(section.parentNode.parentNode, 'owl-carousel') ? section.parentNode.parentNode.getBoundingClientRect().top : section.getBoundingClientRect().top) : 0),
2380 offSetPosition = wheight + bodyTop - offSetTop,
2381 $kenburnsInner = kenburnsRows[i].querySelectorAll('.background-inner, .header-bg');
2382 if (offSetPosition > 0 && offSetPosition < (sectionHeight + wheight)) {
2383 classie.addClass($kenburnsInner[0], 'uncode-kburns');
2384 $kenburnsInner[0].dispatchEvent(new CustomEvent('enter-kburns'));
2385 } else {
2386 classie.removeClass($kenburnsInner[0], 'uncode-kburns');
2387 $kenburnsInner[0].dispatchEvent(new CustomEvent('exit-kburns'));
2388 }
2389 }
2390 }
2391 if ( UNCODE.isFrontEndEditor ) {
2392 kenburnsCols = document.querySelectorAll('.with-kburns > .column-background > .background-wrapper');
2393 }
2394 if ( typeof kenburnsCols == 'object' && kenburnsCols.length ) {
2395 for (var j = 0; j < kenburnsCols.length; j++) {
2396 var elm = kenburnsCols[j],
2397 $kenburnsInner = elm.querySelectorAll('.background-inner');
2398 if (checkVisible(elm)) {
2399 classie.addClass($kenburnsInner[0], 'uncode-kburns');
2400 $kenburnsInner[0].dispatchEvent(new CustomEvent('enter-kburns'));
2401 } else {
2402 classie.removeClass($kenburnsInner[0], 'uncode-kburns');
2403 $kenburnsInner[0].dispatchEvent(new CustomEvent('exit-kburns'));
2404 }
2405 }
2406 }
2407 },
2408 /** Zoom Out BackWash **/
2409 backwashHeader = function(bodyTop) {
2410 var value;
2411 var onEndAnimationFn = function(ev){
2412 if (animationEvent) {
2413 if (ev.animationName !== 'backwash') {
2414 return;
2415 }
2416 this.removeEventListener(animationEvent, onEndAnimationFn);
2417 }
2418 classie.addClass(ev.target, 'uncode-zoomout-already');
2419 }
2420 if ( typeof backwashHeaders == 'object' && backwashHeaders.length ) {
2421 for (var i = 0; i < backwashHeaders.length; i++) {
2422 var section = backwashHeaders[i].parentNode,
2423 sectionHeight = outerHeight(section),
2424 offSetTop = bodyTop + (section != null ? (classie.hasClass(section.parentNode.parentNode, 'owl-carousel') ? section.parentNode.parentNode.getBoundingClientRect().top : section.getBoundingClientRect().top) : 0),
2425 offSetPosition = wheight + bodyTop - offSetTop,
2426 $backwashInner = backwashHeaders[i].querySelectorAll('.header-bg');
2427
2428 if ( classie.hasClass($backwashInner[0], 'uncode-video-container') ) {
2429 continue;
2430 }
2431
2432 if (classie.hasClass(backwashHeaders[i], 'header-carousel-wrapper')) {
2433 $backwashInner = backwashHeaders[i].querySelectorAll('.t-background-cover');
2434 }
2435
2436 if (offSetPosition > 0 && offSetPosition < (sectionHeight + wheight)) {
2437 for (var i = 0; i < $backwashInner.length; i++) {
2438 classie.addClass($backwashInner[i], 'uncode-zoomout');
2439 $backwashInner[i].dispatchEvent(new CustomEvent('enter-zoomout'));
2440 }
2441 } else {
2442 for (var i = 0; i < $backwashInner.length; i++) {
2443 classie.removeClass($backwashInner[i], 'uncode-zoomout');
2444 $backwashInner[i].dispatchEvent(new CustomEvent('exit-zoomout'));
2445 }
2446 }
2447 for (var i = 0; i < $backwashInner.length; i++) {
2448 $backwashInner[i].addEventListener(animationEvent, onEndAnimationFn);
2449 }
2450 }
2451 }
2452 },
2453 backwashRowCol = function(bodyTop) {
2454 var value;
2455 var onEndAnimationFn = function(ev){
2456 if (animationEvent) {
2457 if (ev.animationName !== 'backwash') {
2458 return;
2459 }
2460 this.removeEventListener(animationEvent, onEndAnimationFn);
2461 }
2462 classie.addClass(ev.target, 'uncode-zoomout-already');
2463 }
2464 if ( UNCODE.isFrontEndEditor ) {
2465 backwashRows = document.querySelectorAll('.with-zoomout > .row-background > .background-wrapper, .with-zoomout > .fp-tableCell > .row-background > .background-wrapper, .with-zoomout > .fp-tableCell > .fp-scrollable > .fp-scroller > .row-background > .background-wrapper');
2466 }
2467 if ( typeof backwashRows == 'object' && backwashRows.length ) {
2468 for (var i = 0; i < backwashRows.length; i++) {
2469 var section = backwashRows[i].parentNode,
2470 sectionHeight = outerHeight(section),
2471 offSetTop = bodyTop + (section != null ? (classie.hasClass(section.parentNode.parentNode, 'owl-carousel') ? section.parentNode.parentNode.getBoundingClientRect().top : section.getBoundingClientRect().top) : 0),
2472 offSetPosition = wheight + bodyTop - offSetTop,
2473 $backwashInner = backwashRows[i].querySelectorAll('.background-inner');
2474
2475 if ( classie.hasClass($backwashInner[0], 'uncode-video-container') ) {
2476 continue;
2477 }
2478
2479 if (offSetPosition > 0 && offSetPosition < (sectionHeight + wheight) ) {
2480 classie.addClass($backwashInner[0], 'uncode-zoomout');
2481 $backwashInner[0].dispatchEvent(new CustomEvent('enter-zoomout'));
2482 } else {
2483 classie.removeClass($backwashInner[0], 'uncode-zoomout');
2484 $backwashInner[0].dispatchEvent(new CustomEvent('exit-zoomout'));
2485 }
2486 $backwashInner[0].addEventListener(animationEvent, onEndAnimationFn);
2487 }
2488
2489 }
2490 if ( UNCODE.isFrontEndEditor ) {
2491 backwashCols = document.querySelectorAll('.with-zoomout > .column-background > .background-wrapper');
2492 }
2493 if ( typeof backwashCols == 'object' && backwashCols.length ) {
2494 for (var j = 0; j < backwashCols.length; j++) {
2495 var elm = backwashCols[j],
2496 $backwashInner = elm.querySelectorAll('.background-inner');
2497 if (checkVisible(elm)) {
2498 classie.addClass($backwashInner[0], 'uncode-zoomout');
2499 $backwashInner[0].dispatchEvent(new CustomEvent('enter-zoomout'));
2500 } else {
2501 classie.removeClass($backwashInner[0], 'uncode-zoomout');
2502 $backwashInner[0].dispatchEvent(new CustomEvent('exit-zoomout'));
2503 }
2504 $backwashInner[0].addEventListener(animationEvent, onEndAnimationFn);
2505 }
2506 }
2507 },
2508 /** Parallax Rows **/
2509 parallaxRowCol = function(bodyTop) {
2510 var value;
2511 if ( UNCODE.isFrontEndEditor ) {
2512 parallaxRows = document.querySelectorAll('.with-parallax > .row-background > .background-wrapper, .with-parallax > .fp-tableCell > .row-background > .background-wrapper, .with-parallax > .fp-tableCell > .fp-scrollable > .fp-scroller > .row-background > .background-wrapper');
2513 }
2514 if (typeof parallaxRows == 'object') {
2515 for (var i = 0; i < parallaxRows.length; i++) {
2516 var section = parallaxRows[i].parentNode,
2517 thisHeight = outerHeight(parallaxRows[i]),
2518 sectionHeight = outerHeight(section),
2519 offSetTop = bodyTop + (section != null ? (classie.hasClass(section.parentNode.parentNode, 'owl-carousel') ? section.parentNode.parentNode.getBoundingClientRect().top : section.getBoundingClientRect().top) : 0),
2520 offSetPosition = wheight + bodyTop - offSetTop;
2521 if (offSetPosition > 0 && offSetPosition < (sectionHeight + wheight)) {
2522 value = ((offSetPosition - wheight) * speedDivider);
2523 if (Math.abs(value) < (thisHeight - sectionHeight)) {
2524 translateElement(parallaxRows[i], Math.floor(value));
2525 } else {
2526 translateElement(parallaxRows[i], Math.floor(thisHeight - sectionHeight));
2527 }
2528 }
2529 }
2530 }
2531 if ( UNCODE.isFrontEndEditor ) {
2532 parallaxCols = document.querySelectorAll('.with-parallax > .column-background > .background-wrapper');
2533 }
2534 if (typeof parallaxCols == 'object') {
2535 for (var j = 0; j < parallaxCols.length; j++) {
2536 var section = parallaxCols[j].parentNode,
2537 thisHeight = outerHeight(parallaxCols[j]),
2538 sectionHeight = outerHeight(section),
2539 offSetTop = bodyTop + (section != null ? section.getBoundingClientRect().top : 0),
2540 offSetPosition = wheight + bodyTop - offSetTop;
2541 if (offSetPosition > 0 && offSetPosition < (sectionHeight + wheight)) {
2542 value = ((offSetPosition - wheight) * speedDivider);
2543 value *= .8;
2544 if (Math.abs(value) < (thisHeight - sectionHeight)) {
2545 translateElement(parallaxCols[j], Math.floor(value));
2546 } else {
2547 translateElement(parallaxCols[j], Math.floor(thisHeight - sectionHeight));
2548 }
2549 }
2550 }
2551 }
2552 },
2553 /** Parallax Headers **/
2554 parallaxHeader = function(bodyTop) {
2555 var value;
2556 if (typeof parallaxHeaders == 'object') {
2557 for (var i = 0; i < parallaxHeaders.length; i++) {
2558 var section = parallaxHeaders[i].parentNode,
2559 thisSibling = section.nextSibling,
2560 thisHeight,
2561 sectionHeight,
2562 offSetTop,
2563 offSetPosition;
2564 if (classie.hasClass(parallaxHeaders[i], 'header-carousel-wrapper')) {
2565 getDivChildren(parallaxHeaders[i], '.t-entry-visual-cont', function(item, l, total) {
2566 thisHeight = outerHeight(item);
2567 sectionHeight = outerHeight(section);
2568 offSetTop = bodyTop + section.getBoundingClientRect().top;
2569 offSetPosition = wheight + bodyTop - offSetTop;
2570 if (offSetPosition > 0 && offSetPosition < (sectionHeight + wheight)) {
2571 value = ((offSetPosition - wheight) * speedDivider);
2572 if (Math.abs(value) < (thisHeight - sectionHeight)) {
2573 translateElement(item, Math.floor(value));
2574 }
2575 }
2576 });
2577 } else {
2578 thisHeight = outerHeight(parallaxHeaders[i]);
2579 sectionHeight = outerHeight(section);
2580 offSetTop = bodyTop + section.getBoundingClientRect().top;
2581 offSetPosition = wheight + bodyTop - offSetTop;
2582 if (offSetPosition > 0 && offSetPosition < (sectionHeight + wheight)) {
2583 value = ((offSetPosition - wheight) * speedDivider);
2584 if (Math.abs(value) < (thisHeight - sectionHeight)) {
2585 translateElement(parallaxHeaders[i], Math.floor(value));
2586 }
2587 }
2588 }
2589 }
2590 }
2591 },
2592 /** Header opacity **/
2593 headerOpacity = function(bodyTop) {
2594 if ( UNCODE.isFrontEndEditor ) {
2595 return;
2596 }
2597 if (headerWithOpacity && headerWithOpacity.length) {
2598 var thisHeight = outerHeight(headerWithOpacity[0]);
2599 if (bodyTop > thisHeight / 8) {
2600 if (pageHeader != undefined) classie.addClass(pageHeader, 'header-scrolled');
2601 } else {
2602 if (pageHeader != undefined) classie.removeClass(pageHeader, 'header-scrolled');
2603 }
2604 }
2605 },
2606 /** Show hide scroll top arrow **/
2607 showHideScrollup = function(bodyTop) {
2608 if ( bodyTop != 0 ) {
2609 if (bodyTop > wheight || ((bodyTop + wheight) >= docheight) && docheight > 0) {
2610 classie.addClass(document.body, 'window-scrolled');
2611 classie.removeClass(document.body, 'hide-scrollup');
2612 if (footerScroller && footerScroller[0] != undefined) {
2613 footerScroller[0].style.display = '';
2614 }
2615 } else {
2616 if (classie.hasClass(document.body, 'window-scrolled')) classie.addClass(document.body, 'hide-scrollup');
2617 classie.removeClass(document.body, 'window-scrolled');
2618 }
2619 }
2620 },
2621 /** Fix menu **/
2622 fixMenu = function(){
2623 if ( UNCODE.isFrontEndEditor )
2624 return;
2625 menuwrapper = document.querySelectorAll(".menu-wrapper");
2626 if ( ! classie.hasClass(document.body, 'vmenu') && UNCODE.isFullPage && !UNCODE.isFullPageSnap && classie.hasClass(document.body, 'uncode-fp-menu-hide') ) {
2627 menuwrapper = document.querySelector(".menu-wrapper");
2628 pageHeader = document.getElementById("page-header");
2629 menuwrapper.style.position = 'fixed';
2630 menuwrapper.style.zIndex = '5';
2631 }
2632 },
2633 /** Hide Menu **/
2634 hideMenu = function(bodyTop) {
2635 if ( UNCODE.isFrontEndEditor )
2636 return;
2637 if (UNCODE.menuOpened || bodyTop < 0) return;
2638 if (classie.hasClass(document.body, 'vmenu')) {
2639 if (wwidth < mediaQuery) menuhide = document.querySelector('#masthead .menu-hide-vertical');
2640 else menuhide = null;
2641 }
2642 if (classie.hasClass(document.body, 'hmenu-center')) {
2643 if (wwidth > mediaQuery) menuhide = document.querySelector('#masthead .menu-hide');
2644 else menuhide = document.querySelector('.menu-container-mobile.menu-hide');
2645 }
2646 if (typeof menuhide == 'object' && menuhide != null && mainmenu[0] != undefined) {
2647 var translate,
2648 scrollingDown = true;
2649 /** fix for hmenu-center **/
2650 var sticky_element = (typeof mainmenu.item === 'undefined' ? ((wwidth > mediaQuery) ? mainmenu[0] : mainmenu[1]) : mainmenu[0]);
2651 if (lastScrollValue == bodyTop) return;
2652
2653 if (lastScrollValue > bodyTop) scrollingDown = false;
2654 else scrollingDown = true;
2655 lastScrollValue = bodyTop;
2656
2657 if (!scrollingDown) {
2658 if (!UNCODE.scrolling) {
2659 if ((secmenuHeight == 0) ? bodyTop == 0 : bodyTop < secmenuHeight) {
2660 classie.removeClass(sticky_element.parentNode, 'is_stuck');
2661 if (classie.hasClass(masthead, 'menu-transparent')) {
2662 if ((isMobileTransparent || wwidth > mediaQuery) && !classie.hasClass(masthead.parentNode, 'no-header')) masthead.parentNode.style.height = '0px';
2663 }
2664 if (wwidth < mediaQuery) sticky_element.style.position = 'fixed';
2665 else sticky_element.style.position = '';
2666 hideMenuReset(sticky_element);
2667 clearTimeout(hidingTimer);
2668 }
2669
2670 if (classie.hasClass(menuhide, 'menu-hided')) {
2671 classie.removeClass(menuhide, 'menu-hided');
2672 hidingTimer = setTimeout(function() {
2673 classie.addClass(sticky_element.parentNode, 'is_stuck');
2674 hideMenuReset(sticky_element);
2675 }, 400);
2676 }
2677 }
2678 } else {
2679 if (menusticky.length == 0 && bodyTop < wheight / 3) {
2680 if (sticky_element.style.position == 'fixed') sticky_element.style.position = '';
2681 }
2682 if (bodyTop > wheight / 2) {
2683 clearTimeout(hidingTimer);
2684 if (!classie.hasClass(menuhide, 'menu-hided')) {
2685 classie.addClass(menuhide, 'menu-hided');
2686 classie.addClass(sticky_element.parentNode, 'is_stuck');
2687 if (sticky_element.style.position != 'fixed') {
2688 sticky_element.style.visibility = 'hidden';
2689 sticky_element.style.position = 'fixed';
2690 sticky_element.style.top = '0px';
2691 }
2692 translateElement(menuhide, -UNCODE.menuMobileHeight - 1);
2693 }
2694 }
2695 }
2696 }
2697 },
2698 hideMenuReset = function(sticky_element) {
2699 var topOffset = 0;
2700 if (sticky_element.style.visibility == 'hidden') sticky_element.style.visibility = '';
2701 if (bodyBorder > 0) topOffset += bodyBorder;
2702 if (adminBar != null && window.getComputedStyle(adminBar,null).getPropertyValue("position") != 'fixed') adminBarHeight = 0;
2703 if (adminBarHeight > 0) topOffset += adminBarHeight;
2704 //sticky_element.style.top = topOffset + 'px';
2705 if (!classie.hasClass(document.body, 'boxed-width') && boxWidth > 0) sticky_element.style.width = boxWidth + 'px';
2706 translateElement(menuhide, 0);
2707 },
2708 /** Stick Menu **/
2709 stickMenu = function(bodyTop) {
2710 if (header && mainmenu[0] != undefined) {
2711 if (classie.hasClass(mainmenu[0], 'vmenu-container') && wwidth > mediaQuery) return;
2712 /** fix for hmenu-center **/
2713 var sticky_element = (typeof mainmenu.item === 'undefined' ? ((isMobileTransparent || wwidth > mediaQuery) ? mainmenu[0] : mainmenu[1]) : mainmenu[0]);
2714 if ((secmenuHeight == 0 && (isMobileTransparent || wwidth > mediaQuery)) ? bodyTop > (0 + adminBarHeight) : bodyTop > (secmenuHeight + adminBarHeight)) {
2715 if (!classie.hasClass(sticky_element.parentNode, 'is_stuck')) {
2716 classie.addClass(sticky_element.parentNode, 'is_stuck');
2717 sticky_element.style.position = 'fixed';
2718 var getAnchorTop = bodyBorder;
2719 if (adminBar != null && window.getComputedStyle(adminBar,null).getPropertyValue("position") != 'fixed') adminBarHeight = 0;
2720 if (adminBarHeight > 0) getAnchorTop += adminBarHeight;
2721 sticky_element.style.top = getAnchorTop + 'px';
2722 if (!classie.hasClass(document.body, 'boxed-width') && boxWidth > 0) sticky_element.style.width = boxWidth + 'px';
2723 }
2724 } else {
2725 clearTimeout(hidingTimer);
2726 classie.removeClass(sticky_element.parentNode, 'is_stuck');
2727 sticky_element.style.position = 'fixed';
2728 if (isMobileTransparent || wwidth > mediaQuery) sticky_element.style.position = '';
2729 if (classie.hasClass(document.body, 'hmenu-center')) sticky_element.style.position = 'absolute';
2730 sticky_element.style.top = '';
2731 }
2732 }
2733 },
2734 translateElement = function(element, valueY) {
2735 var translate = 'translate3d(0, ' + valueY + 'px' + ', 0)';
2736 element.style['-webkit-transform'] = translate;
2737 element.style['-moz-transform'] = translate;
2738 element.style['-ms-transform'] = translate;
2739 element.style['-o-transform'] = translate;
2740 element.style['transform'] = translate;
2741 },
2742 setScrollPosition,
2743 scrollFunction = function() {
2744 if ( ! UNCODE.isFullPage ) {
2745 kenburnsHeader(bodyTop);
2746 kenburnsRowCol(bodyTop);
2747 backwashHeader(bodyTop);
2748 backwashRowCol(bodyTop);
2749 if (logoel != undefined && logoel.length && !isMobile) shrinkMenu(bodyTop);
2750 if (menusticky != undefined && menusticky.length) stickMenu(bodyTop);
2751 hideMenu(bodyTop);
2752 if (isMobileParallaxAllowed || !isMobile) {
2753 if (header && menusticky != undefined && menusticky.length)
2754 switchColorsMenu(bodyTop);
2755 parallaxRowCol(bodyTop);
2756 parallaxHeader(bodyTop);
2757 headerOpacity(bodyTop);
2758 visibleRowCol(bodyTop);
2759 }
2760 clearRequestTimeout(setScrollPosition);
2761 setScrollPosition = requestTimeout( function(){
2762 scrollRowHeight_fix = window.pageYOffset;
2763 }, 100 );
2764 }
2765 },
2766 /** Shape Dividers **/
2767 shapeDivider = function() {
2768 var $shape = '.uncode-divider-wrap';
2769
2770 forEachElement($shape, function($el, i) {
2771 var elH = parseInt( $el.getAttribute('data-height') ),
2772 elHunit = $el.getAttribute('data-unit'),
2773 newEl,
2774 $parent = $el.parentNode,
2775 parentH,
2776 $svg = $el.getElementsByTagName('svg')[0];
2777
2778 if ( elHunit == 'px' ) {
2779
2780 switch (true) {
2781 case (wwidth < 1500 && wwidth >= 1180):
2782 newEl = elH*0.8;
2783 break;
2784
2785 case (wwidth < 1180 && wwidth >= 960):
2786 newEl = elH*0.65;
2787 break;
2788
2789 case (wwidth < 960 && wwidth >= 570):
2790 newEl = elH*0.5;
2791 break;
2792
2793 case (wwidth < 570):
2794 newEl = elH*0.25;
2795 break;
2796
2797 default:
2798 newEl = elH;
2799 }
2800
2801 $el.style.height = newEl + elHunit;
2802 }
2803
2804
2805 if ( classie.hasClass($el, 'uncode-divider-preserve-ratio') && ( window.navigator.userAgent.indexOf('MSIE ') !== -1 || window.navigator.userAgent.indexOf('Trident/') !== -1 ) ) {
2806
2807 $svg.setAttribute('preserveAspectRatio','none');
2808
2809 var sizes = $svg.getAttribute('viewBox').split(' '),
2810 svgW = sizes[2],
2811 svgH = sizes[3],
2812 newSvgW;
2813
2814 newSvgW = newEl * ( svgW / svgH );
2815
2816 $svg.style.width = newSvgW + 'px';
2817
2818 }
2819 });
2820 };
2821 if (!noScroll && document.body == null) {
2822 window.addEventListener('scroll', function(e) {
2823 if ( ! UNCODE.isFullPage ) {
2824 bodyTop = document.documentElement.scrollTop || document.body.scrollTop;
2825 scrollFunction();
2826 showHideScrollup(bodyTop);
2827 }
2828 }, false);
2829 }
2830 /** All scrolling functions - End */
2831 /** help functions */
2832 function getClosest(el, tag) {
2833 do {
2834 if (el.className != undefined && el.className.indexOf(tag) > -1) return el;
2835 } while (el = el.parentNode);
2836 // not found :(
2837 return null;
2838 }
2839
2840 function outerHeight(el, includeMargin) {
2841 if (el != null) {
2842 var height = el.offsetHeight;
2843 if (includeMargin) {
2844 var style = el.currentStyle || getComputedStyle(el);
2845 height += parseInt(style.marginTop) + parseInt(style.marginBottom);
2846 }
2847 return height;
2848 }
2849 }
2850
2851 function outerWidth(el, includeMargin) {
2852 var width = el.offsetWidth;
2853 if (includeMargin) {
2854 var style = el.currentStyle || getComputedStyle(el);
2855 width += parseInt(style.marginLeft) + parseInt(style.marginRight);
2856 }
2857 return width;
2858 }
2859 // Replicate jQuery .each method
2860 function forEachElement(selector, fn) {
2861 var elements = document.querySelectorAll(selector);
2862 for (var i = 0; i < elements.length; i++) fn(elements[i], i);
2863 }
2864
2865 function getDivChildren(containerId, selector, fn) {
2866 if (containerId !== null) {
2867 var elements = containerId.querySelectorAll(selector);
2868 for (var i = 0; i < elements.length; i++) fn(elements[i], i, elements.length);
2869 }
2870 }
2871
2872 function hideFooterScroll() {
2873 if (classie.hasClass(document.body, 'hide-scrollup')) footerScroller[0].style.display = "none";
2874 }
2875 document.addEventListener("DOMContentLoaded", function(event) {
2876 UNCODE.adaptive();
2877 boxWrapper = document.querySelectorAll('.box-wrapper');
2878 docheight = boxWrapper[0] != undefined ? boxWrapper[0].offsetHeight : 0;
2879 if (!classie.hasClass(document.body, 'vmenu') && !classie.hasClass(document.body, 'menu-offcanvas')) init_overlay();
2880 kenburnsRows = document.querySelectorAll('.with-kburns > .row-background > .background-wrapper, .with-kburns > .fp-tableCell > .row-background > .background-wrapper, .with-kburns > .fp-tableCell > .fp-scrollable > .fp-scroller > .row-background > .background-wrapper');
2881 kenburnsCols = document.querySelectorAll('.with-kburns > .column-background > .background-wrapper');
2882 backwashRows = document.querySelectorAll('.with-zoomout > .row-background > .background-wrapper, .with-zoomout > .fp-tableCell > .row-background > .background-wrapper, .with-zoomout > .fp-tableCell > .fp-scrollable > .fp-scroller > .row-background > .background-wrapper');
2883 backwashCols = document.querySelectorAll('.with-zoomout > .column-background > .background-wrapper');
2884 if (!UNCODE.isMobile || isMobileParallaxAllowed) {
2885 parallaxRows = document.querySelectorAll('.with-parallax > .row-background > .background-wrapper, .with-parallax > .fp-tableCell > .row-background > .background-wrapper, .with-parallax > .fp-tableCell > .fp-scrollable > .fp-scroller > .row-background > .background-wrapper');
2886 parallaxCols = document.querySelectorAll('.with-parallax > .column-background > .background-wrapper');
2887 }
2888 footerScroller = document.querySelectorAll('.footer-scroll-top');
2889 if (footerScroller && footerScroller[0] != undefined) {
2890 if (transitionEvent) {
2891 footerScroller[0].addEventListener(transitionEvent, hideFooterScroll);
2892 }
2893 }
2894 Array.prototype.forEach.call(document.querySelectorAll('.row-inner'), function(el) {
2895 el.style.height = '';
2896 el.style.marginBottom = '';
2897 });
2898 setRowHeight(document.querySelectorAll('.page-wrapper .row-parent, footer .row-parent'));
2899 });
2900 /** On resize events **/
2901 window.addEventListener("vc-resize", function() {
2902 scrollRowHeight_fix = window.pageYOffset;
2903 Array.prototype.forEach.call(document.querySelectorAll('.row-inner'), function(el) {
2904 el.style.height = '';
2905 el.style.marginBottom = '';
2906 });
2907 setRowHeight(document.querySelectorAll('.page-wrapper .row-parent, footer .row-parent'), false, true);
2908 });
2909 var setIsScrolling;
2910 window.addEventListener("scroll", function() {
2911 UNCODE.setIsScrolling = true;
2912 clearRequestTimeout(setIsScrolling);
2913
2914 setIsScrolling = requestTimeout(function() {
2915 UNCODE.setIsScrolling = false;
2916 }, 66);
2917 });
2918 window.addEventListener("resize", function() {
2919 scrollRowHeight_fix = window.pageYOffset;
2920 docheight = (boxWrapper != undefined && boxWrapper[0] != undefined) ? boxWrapper[0].offsetHeight : 0;
2921 var oldWidth = wwidth;
2922 UNCODE.wwidth = wwidth = window.innerWidth || document.documentElement.clientWidth;
2923 UNCODE.wheight = wheight = (window.innerHeight || document.documentElement.clientHeight) - (bodyBorder * 2);
2924 if ( isSplitMenu && typeof resizeTimer_ === 'undefined' ) centerSplitMenu();
2925 if (isMobile && (oldWidth == wwidth)) return false;
2926 calculateMenuHeight(false);
2927 initBox();
2928 headerHeight('.header-wrapper');
2929 window.dispatchEvent(boxEvent);
2930 scrollFunction();
2931 shapeDivider();
2932 showHideScrollup(bodyTop);
2933 clearTimeout(resizeTimer_);
2934 resizeTimer_ = setTimeout(function() {
2935 if (isSplitMenu) centerSplitMenu();
2936 }, 10);
2937 if ( ! UNCODE.setIsScrolling ) {
2938 clearTimeout(resizeTimer);
2939 resizeTimer = setTimeout(function() {
2940 if ( ! UNCODE.setIsScrolling ) {
2941 UNCODE.wheight = wheight = (window.innerHeight || document.documentElement.clientHeight) - (bodyBorder * 2);
2942 Array.prototype.forEach.call(document.querySelectorAll('.row-inner'), function(el) {
2943 el.style.height = '';
2944 el.style.marginBottom = '';
2945 });
2946 setRowHeight(document.querySelectorAll('.page-wrapper .row-parent, footer .row-parent'), false, true);
2947 }
2948 if (!isMobile) {
2949 initVideoComponent(document.body, '.uncode-video-container.video, .uncode-video-container.self-video');
2950 }
2951 }, 500);
2952 }
2953 });
2954
2955 /**
2956 * On DOM ready
2957 */
2958 window.addEventListener("load", function(){
2959 if (!UNCODE.isMobile) {
2960 setTimeout(function() {
2961 window.dispatchEvent(UNCODE.boxEvent);
2962 Waypoint.refreshAll();
2963 }, 2000);
2964 }
2965 //repeat it for mobile since it changes layout on carousel after DOM loading
2966 if (UNCODE.isMobile && !isMobileParallaxAllowed) {
2967 kenburnsHeader(bodyTop);
2968 kenburnsRowCol(bodyTop);
2969 }
2970 backwashHeader(bodyTop);
2971 backwashRowCol(bodyTop);
2972 showHideScrollup(bodyTop);
2973 if (document.createEvent) { // W3C
2974 var ev = document.createEvent('Event');
2975 ev.initEvent('resize', true, true);
2976 window.dispatchEvent(ev);
2977 } else { // IE
2978 document.fireEvent('onresize');
2979 }
2980 }, false);
2981
2982 var UNCODE = {
2983 bodyTop: bodyTop,
2984 boxEvent: boxEvent,
2985 bodyBorder: bodyBorder,
2986 initBox: initBox,
2987 adminBarHeight: 0,
2988 menuHeight: 0,
2989 menuMobileHeight: 0,
2990 fixMenuHeight: fixMenuHeight,
2991 initHeader: initHeader,
2992 initRow: initRow,
2993 setRowHeight: setRowHeight,
2994 switchColorsMenu: switchColorsMenu,
2995 isMobile: isMobile,
2996 scrolling: false,
2997 menuHiding: false,
2998 menuOpened: false,
2999 menuMobileTriggerEvent: menuMobileTriggerEvent,
3000 mediaQuery: mediaQuery,
3001 initVideoComponent: initVideoComponent,
3002 hideMenu: hideMenu,
3003 wwidth: wwidth,
3004 wheight: wheight,
3005 };
3006 // transport
3007 if (typeof define === 'function' && define.amd) {
3008 // AMD
3009 define(UNCODE);
3010 } else {
3011 // browser global
3012 window.UNCODE = UNCODE;
3013 }
3014
3015 UNCODE.adaptive = function() {
3016 var images = new Array(),
3017 getImages = document.querySelectorAll('.adaptive-async:not(.adaptive-fetching)');
3018 for (var i = 0; i < getImages.length; i++) {
3019 var imageObj = {},
3020 el = getImages[i];
3021 classie.addClass(el, 'adaptive-fetching');
3022 imageObj.unique = el.getAttribute('data-uniqueid');
3023 imageObj.url = el.getAttribute('data-guid');
3024 imageObj.path = el.getAttribute('data-path');
3025 imageObj.singlew = el.getAttribute('data-singlew');
3026 imageObj.singleh = el.getAttribute('data-singleh');
3027 imageObj.origwidth = el.getAttribute('data-width');
3028 imageObj.origheight = el.getAttribute('data-height');
3029 imageObj.crop = el.getAttribute('data-crop');
3030 imageObj.fixed = el.getAttribute('data-fixed') == undefined ? null : el.getAttribute('data-fixed');
3031 imageObj.screen = window.uncodeScreen;
3032 imageObj.images = window.uncodeImages;
3033 images.push(imageObj);
3034 }
3035
3036 var post_data = {
3037 images: JSON.stringify(images),
3038 action: 'get_adaptive_async',
3039 nonce_adaptive_images: SiteParameters.nonce_adaptive_images
3040 };
3041
3042 if (images.length > 0) {
3043 var xhr = new XMLHttpRequest();
3044 xhr.open('POST', SiteParameters.ajax_url, true);
3045 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
3046 xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
3047
3048 xhr.onreadystatechange = function() {
3049 if (xhr.readyState == XMLHttpRequest.DONE) {
3050 if (xhr.status == 200 && xhr.responseText) {
3051 var jsonResponse = JSON.parse(xhr.responseText);
3052
3053 if (jsonResponse.success && jsonResponse.data.images) {
3054 var images = jsonResponse.data.images;
3055
3056 for (var i = 0; i < images.length; i++) {
3057 var val = images[i],
3058 getImage = document.querySelectorAll('[data-uniqueid="'+val.unique+'"]');
3059 for (var j = 0; j < getImage.length; j++) {
3060 var attrScr = getImage[j].getAttribute('src'),
3061 replaceImg = new Image();
3062 replaceImg.source = attrScr;
3063 replaceImg.el = getImage[j];
3064
3065 classie.removeClass(getImage[j], 'adaptive-async');
3066 classie.removeClass(getImage[j], 'adaptive-fetching');
3067
3068 replaceImg.onload = function () {
3069
3070 var _this = this,
3071 parentNode = (_this.el).parentNode,
3072 placeH;
3073
3074 //Workaround for lazy-load flickering on Firefox
3075 if ( typeof parentNode.prepend == 'undefined') {
3076 if (_this.source !== null) {
3077 (_this.el).src = _this.src;
3078 } else {
3079 (_this.el).style.backgroundImage = 'url("'+_this.src+'")';
3080 }
3081
3082 classie.addClass(_this.el, 'async-done');
3083 } else {
3084 if (_this.source !== null) {
3085 placeH = document.createElement("IMG");
3086 placeH.setAttribute('class', 'placeH');
3087 placeH.src = _this.src;
3088 placeH.style.position = 'absolute';
3089 placeH.style.opacity = '0';
3090 } else {
3091 placeH = document.createElement("DIV");
3092 placeH.setAttribute('style', _this.el.getAttribute('style'));
3093 placeH.setAttribute('class', 'placeH ' + _this.el.getAttribute('class'));
3094 placeH.style.backgroundImage = 'url("'+_this.src+'")';
3095 placeH.style.backgroundSize = 'cover';
3096 placeH.style.backgroundPosition = 'center';
3097 placeH.style.position = 'absolute';
3098 placeH.style.top = '0';
3099 placeH.style.width = '100%';
3100 placeH.style.height = '100%';
3101 }
3102
3103 if ( !classie.hasClass( _this.el, 'box-wrapper') ) {
3104 parentNode.prepend(placeH);
3105 }
3106
3107 requestTimeout(function(){
3108 if (_this.source !== null) {
3109 (_this.el).src = _this.src;
3110 } else {
3111 (_this.el).style.backgroundImage = 'url("'+_this.src+'")';
3112 }
3113 if ( !classie.hasClass( _this.el, 'box-wrapper') ) {
3114 parentNode.removeChild(placeH);
3115 }
3116 classie.addClass(_this.el, 'async-done');
3117 }, 250);
3118 }
3119 }
3120 replaceImg.src = val.url;
3121 }
3122 }
3123
3124 } else {
3125 if (SiteParameters.enable_debug == true) {
3126 // This console log is disabled by default
3127 // So nothing is printed in a typical installation
3128 //
3129 // It can be enabled for debugging purposes setting
3130 // the 'uncode_enable_debug_on_js_scripts' filter to true
3131 console.log('There was an error: bad response');
3132 }
3133 }
3134
3135 } else if (xhr.status == 400) {
3136 if (SiteParameters.enable_debug == true) {
3137 // This console log is disabled by default
3138 // So nothing is printed in a typical installation
3139 //
3140 // It can be enabled for debugging purposes setting
3141 // the 'uncode_enable_debug_on_js_scripts' filter to true
3142 console.log('There was an error 400');
3143 }
3144 } else {
3145 if (SiteParameters.enable_debug == true) {
3146 // This console log is disabled by default
3147 // So nothing is printed in a typical installation
3148 //
3149 // It can be enabled for debugging purposes setting
3150 // the 'uncode_enable_debug_on_js_scripts' filter to true
3151 console.log('Something else other than 200 was returned');
3152 }
3153 }
3154 }
3155 }
3156
3157 // Serialize our data
3158 var queryString = "",
3159 arrayLength = Object.keys(post_data).length,
3160 arrayCounter = 0;
3161
3162 for (var key in post_data) {
3163 queryString += key + "=" + post_data[key];
3164
3165 if (arrayCounter < arrayLength - 1) {
3166 queryString += "&";
3167 }
3168
3169 arrayCounter++;
3170 }
3171
3172 xhr.send(queryString);
3173 }
3174 };
3175
3176})(window);
3177
3178/**
3179 * vivus - JavaScript library to make drawing animation on SVG
3180 * @version v0.4.4
3181 * @link https://github.com/maxwellito/vivus
3182 * @license MIT
3183 */
3184
3185'use strict';
3186
3187(function () {
3188
3189 'use strict';
3190
3191/**
3192 * Pathformer
3193 * Beta version
3194 *
3195 * Take any SVG version 1.1 and transform
3196 * child elements to 'path' elements
3197 *
3198 * This code is purely forked from
3199 * https://github.com/Waest/SVGPathConverter
3200 */
3201
3202/**
3203 * Class constructor
3204 *
3205 * @param {DOM|String} element Dom element of the SVG or id of it
3206 */
3207function Pathformer(element) {
3208 // Test params
3209 if (typeof element === 'undefined') {
3210 throw new Error('Pathformer [constructor]: "element" parameter is required');
3211 }
3212
3213 // Set the element
3214 if (element.constructor === String) {
3215 element = document.getElementById(element);
3216 if (!element) {
3217 throw new Error('Pathformer [constructor]: "element" parameter is not related to an existing ID');
3218 }
3219 }
3220 if (element instanceof window.SVGElement ||
3221 element instanceof window.SVGGElement ||
3222 /^svg$/i.test(element.nodeName)) {
3223 this.el = element;
3224 } else {
3225 throw new Error('Pathformer [constructor]: "element" parameter must be a string or a SVGelement');
3226 }
3227
3228 // Start
3229 this.scan(element);
3230}
3231
3232/**
3233 * List of tags which can be transformed
3234 * to path elements
3235 *
3236 * @type {Array}
3237 */
3238Pathformer.prototype.TYPES = ['line', 'ellipse', 'circle', 'polygon', 'polyline', 'rect'];
3239
3240/**
3241 * List of attribute names which contain
3242 * data. This array list them to check if
3243 * they contain bad values, like percentage.
3244 *
3245 * @type {Array}
3246 */
3247Pathformer.prototype.ATTR_WATCH = ['cx', 'cy', 'points', 'r', 'rx', 'ry', 'x', 'x1', 'x2', 'y', 'y1', 'y2'];
3248
3249/**
3250 * Finds the elements compatible for transform
3251 * and apply the liked method
3252 *
3253 * @param {object} options Object from the constructor
3254 */
3255Pathformer.prototype.scan = function (svg) {
3256 var fn, element, pathData, pathDom,
3257 elements = svg.querySelectorAll(this.TYPES.join(','));
3258
3259 for (var i = 0; i < elements.length; i++) {
3260 element = elements[i];
3261 fn = this[element.tagName.toLowerCase() + 'ToPath'];
3262 pathData = fn(this.parseAttr(element.attributes));
3263 pathDom = this.pathMaker(element, pathData);
3264 element.parentNode.replaceChild(pathDom, element);
3265 }
3266};
3267
3268
3269/**
3270 * Read `line` element to extract and transform
3271 * data, to make it ready for a `path` object.
3272 *
3273 * @param {DOMelement} element Line element to transform
3274 * @return {object} Data for a `path` element
3275 */
3276Pathformer.prototype.lineToPath = function (element) {
3277 var newElement = {},
3278 x1 = element.x1 || 0,
3279 y1 = element.y1 || 0,
3280 x2 = element.x2 || 0,
3281 y2 = element.y2 || 0;
3282
3283 newElement.d = 'M' + x1 + ',' + y1 + 'L' + x2 + ',' + y2;
3284 return newElement;
3285};
3286
3287/**
3288 * Read `rect` element to extract and transform
3289 * data, to make it ready for a `path` object.
3290 * The radius-border is not taken in charge yet.
3291 * (your help is more than welcomed)
3292 *
3293 * @param {DOMelement} element Rect element to transform
3294 * @return {object} Data for a `path` element
3295 */
3296Pathformer.prototype.rectToPath = function (element) {
3297 var newElement = {},
3298 x = parseFloat(element.x) || 0,
3299 y = parseFloat(element.y) || 0,
3300 width = parseFloat(element.width) || 0,
3301 height = parseFloat(element.height) || 0;
3302
3303 if (element.rx || element.ry) {
3304 var rx = parseInt(element.rx, 10) || -1,
3305 ry = parseInt(element.ry, 10) || -1;
3306 rx = Math.min(Math.max(rx < 0 ? ry : rx, 0), width/2);
3307 ry = Math.min(Math.max(ry < 0 ? rx : ry, 0), height/2);
3308
3309 newElement.d = 'M ' + (x + rx) + ',' + y + ' ' +
3310 'L ' + (x + width - rx) + ',' + y + ' ' +
3311 'A ' + rx + ',' + ry + ',0,0,1,' + (x + width) + ',' + (y + ry) + ' ' +
3312 'L ' + (x + width) + ',' + (y + height - ry) + ' ' +
3313 'A ' + rx + ',' + ry + ',0,0,1,' + (x + width - rx) + ',' + (y + height) + ' ' +
3314 'L ' + (x + rx) + ',' + (y + height) + ' ' +
3315 'A ' + rx + ',' + ry + ',0,0,1,' + x + ',' + (y + height - ry) + ' ' +
3316 'L ' + x + ',' + (y + ry) + ' ' +
3317 'A ' + rx + ',' + ry + ',0,0,1,' + (x + rx) + ',' + y;
3318 }
3319 else {
3320 newElement.d = 'M' + x + ' ' + y + ' ' +
3321 'L' + (x + width) + ' ' + y + ' ' +
3322 'L' + (x + width) + ' ' + (y + height) + ' ' +
3323 'L' + x + ' ' + (y + height) + ' Z';
3324 }
3325 return newElement;
3326};
3327
3328/**
3329 * Read `polyline` element to extract and transform
3330 * data, to make it ready for a `path` object.
3331 *
3332 * @param {DOMelement} element Polyline element to transform
3333 * @return {object} Data for a `path` element
3334 */
3335Pathformer.prototype.polylineToPath = function (element) {
3336 var newElement = {},
3337 points = element.points.trim().split(' '),
3338 i, path;
3339
3340 // Reformatting if points are defined without commas
3341 if (element.points.indexOf(',') === -1) {
3342 var formattedPoints = [];
3343 for (i = 0; i < points.length; i+=2) {
3344 formattedPoints.push(points[i] + ',' + points[i+1]);
3345 }
3346 points = formattedPoints;
3347 }
3348
3349 // Generate the path.d value
3350 path = 'M' + points[0];
3351 for(i = 1; i < points.length; i++) {
3352 if (points[i].indexOf(',') !== -1) {
3353 path += 'L' + points[i];
3354 }
3355 }
3356 newElement.d = path;
3357 return newElement;
3358};
3359
3360/**
3361 * Read `polygon` element to extract and transform
3362 * data, to make it ready for a `path` object.
3363 * This method rely on polylineToPath, because the
3364 * logic is similar. The path created is just closed,
3365 * so it needs an 'Z' at the end.
3366 *
3367 * @param {DOMelement} element Polygon element to transform
3368 * @return {object} Data for a `path` element
3369 */
3370Pathformer.prototype.polygonToPath = function (element) {
3371 var newElement = Pathformer.prototype.polylineToPath(element);
3372
3373 newElement.d += 'Z';
3374 return newElement;
3375};
3376
3377/**
3378 * Read `ellipse` element to extract and transform
3379 * data, to make it ready for a `path` object.
3380 *
3381 * @param {DOMelement} element ellipse element to transform
3382 * @return {object} Data for a `path` element
3383 */
3384Pathformer.prototype.ellipseToPath = function (element) {
3385 var newElement = {},
3386 rx = parseFloat(element.rx) || 0,
3387 ry = parseFloat(element.ry) || 0,
3388 cx = parseFloat(element.cx) || 0,
3389 cy = parseFloat(element.cy) || 0,
3390 startX = cx - rx,
3391 startY = cy,
3392 endX = parseFloat(cx) + parseFloat(rx),
3393 endY = cy;
3394
3395 newElement.d = 'M' + startX + ',' + startY +
3396 'A' + rx + ',' + ry + ' 0,1,1 ' + endX + ',' + endY +
3397 'A' + rx + ',' + ry + ' 0,1,1 ' + startX + ',' + endY;
3398 return newElement;
3399};
3400
3401/**
3402 * Read `circle` element to extract and transform
3403 * data, to make it ready for a `path` object.
3404 *
3405 * @param {DOMelement} element Circle element to transform
3406 * @return {object} Data for a `path` element
3407 */
3408Pathformer.prototype.circleToPath = function (element) {
3409 var newElement = {},
3410 r = parseFloat(element.r) || 0,
3411 cx = parseFloat(element.cx) || 0,
3412 cy = parseFloat(element.cy) || 0,
3413 startX = cx - r,
3414 startY = cy,
3415 endX = parseFloat(cx) + parseFloat(r),
3416 endY = cy;
3417
3418 newElement.d = 'M' + startX + ',' + startY +
3419 'A' + r + ',' + r + ' 0,1,1 ' + endX + ',' + endY +
3420 'A' + r + ',' + r + ' 0,1,1 ' + startX + ',' + endY;
3421 return newElement;
3422};
3423
3424/**
3425 * Create `path` elements form original element
3426 * and prepared objects
3427 *
3428 * @param {DOMelement} element Original element to transform
3429 * @param {object} pathData Path data (from `toPath` methods)
3430 * @return {DOMelement} Path element
3431 */
3432Pathformer.prototype.pathMaker = function (element, pathData) {
3433 var i, attr, pathTag = document.createElementNS('http://www.w3.org/2000/svg','path');
3434 for(i = 0; i < element.attributes.length; i++) {
3435 attr = element.attributes[i];
3436 if (this.ATTR_WATCH.indexOf(attr.name) === -1) {
3437 pathTag.setAttribute(attr.name, attr.value);
3438 }
3439 }
3440 for(i in pathData) {
3441 pathTag.setAttribute(i, pathData[i]);
3442 }
3443 return pathTag;
3444};
3445
3446/**
3447 * Parse attributes of a DOM element to
3448 * get an object of attribute => value
3449 *
3450 * @param {NamedNodeMap} attributes Attributes object from DOM element to parse
3451 * @return {object} Object of attributes
3452 */
3453Pathformer.prototype.parseAttr = function (element) {
3454 var attr, output = {};
3455 for (var i = 0; i < element.length; i++) {
3456 attr = element[i];
3457 // Check if no data attribute contains '%', or the transformation is impossible
3458 if (this.ATTR_WATCH.indexOf(attr.name) !== -1 && attr.value.indexOf('%') !== -1) {
3459 throw new Error('Pathformer [parseAttr]: a SVG shape got values in percentage. This cannot be transformed into \'path\' tags. Please use \'viewBox\'.');
3460 }
3461 output[attr.name] = attr.value;
3462 }
3463 return output;
3464};
3465
3466 'use strict';
3467
3468var setupEnv, requestAnimFrame, cancelAnimFrame, parsePositiveInt;
3469
3470/**
3471 * Vivus
3472 * Beta version
3473 *
3474 * Take any SVG and make the animation
3475 * to give give the impression of live drawing
3476 *
3477 * This in more than just inspired from codrops
3478 * At that point, it's a pure fork.
3479 */
3480
3481/**
3482 * Class constructor
3483 * option structure
3484 * type: 'delayed'|'sync'|'oneByOne'|'script' (to know if the items must be drawn synchronously or not, default: delayed)
3485 * duration: <int> (in frames)
3486 * start: 'inViewport'|'manual'|'autostart' (start automatically the animation, default: inViewport)
3487 * delay: <int> (delay between the drawing of first and last path)
3488 * dashGap <integer> whitespace extra margin between dashes
3489 * pathTimingFunction <function> timing animation function for each path element of the SVG
3490 * animTimingFunction <function> timing animation function for the complete SVG
3491 * forceRender <boolean> force the browser to re-render all updated path items
3492 * selfDestroy <boolean> removes all extra styling on the SVG, and leaves it as original
3493 *
3494 * The attribute 'type' is by default on 'delayed'.
3495 * - 'delayed'
3496 * all paths are draw at the same time but with a
3497 * little delay between them before start
3498 * - 'sync'
3499 * all path are start and finish at the same time
3500 * - 'oneByOne'
3501 * only one path is draw at the time
3502 * the end of the first one will trigger the draw
3503 * of the next one
3504 *
3505 * All these values can be overwritten individually
3506 * for each path item in the SVG
3507 * The value of frames will always take the advantage of
3508 * the duration value.
3509 * If you fail somewhere, an error will be thrown.
3510 * Good luck.
3511 *
3512 * @constructor
3513 * @this {Vivus}
3514 * @param {DOM|String} element Dom element of the SVG or id of it
3515 * @param {Object} options Options about the animation
3516 * @param {Function} callback Callback for the end of the animation
3517 */
3518function Vivus (element, options, callback) {
3519
3520 setupEnv();
3521
3522 // Setup
3523 this.isReady = false;
3524 this.setElement(element, options);
3525 this.setOptions(options);
3526 this.setCallback(callback);
3527
3528 if (this.isReady) {
3529 this.init();
3530 }
3531}
3532
3533/**
3534 * Timing functions
3535 **************************************
3536 *
3537 * Default functions to help developers.
3538 * It always take a number as parameter (between 0 to 1) then
3539 * return a number (between 0 and 1)
3540 */
3541Vivus.LINEAR = function (x) {return x;};
3542Vivus.EASE = function (x) {return -Math.cos(x * Math.PI) / 2 + 0.5;};
3543Vivus.EASE_OUT = function (x) {return 1 - Math.pow(1-x, 3);};
3544Vivus.EASE_IN = function (x) {return Math.pow(x, 3);};
3545Vivus.EASE_OUT_BOUNCE = function (x) {
3546 var base = -Math.cos(x * (0.5 * Math.PI)) + 1,
3547 rate = Math.pow(base,1.5),
3548 rateR = Math.pow(1 - x, 2),
3549 progress = -Math.abs(Math.cos(rate * (2.5 * Math.PI) )) + 1;
3550 return (1- rateR) + (progress * rateR);
3551};
3552
3553
3554/**
3555 * Setters
3556 **************************************
3557 */
3558
3559/**
3560 * Check and set the element in the instance
3561 * The method will not return anything, but will throw an
3562 * error if the parameter is invalid
3563 *
3564 * @param {DOM|String} element SVG Dom element or id of it
3565 */
3566Vivus.prototype.setElement = function (element, options) {
3567 var onLoad, self;
3568
3569 // Basic check
3570 if (typeof element === 'undefined') {
3571 throw new Error('Vivus [constructor]: "element" parameter is required');
3572 }
3573
3574 // Set the element
3575 if (element.constructor === String) {
3576 element = document.getElementById(element);
3577 if (!element) {
3578 throw new Error('Vivus [constructor]: "element" parameter is not related to an existing ID');
3579 }
3580 }
3581 this.parentEl = element;
3582
3583 // Load the SVG with XMLHttpRequest and extract the SVG
3584 if (options && options.file) {
3585 var self = this;
3586 onLoad = function (e) {
3587 var domSandbox = document.createElement('div');
3588 domSandbox.innerHTML = this.responseText;
3589
3590 var svgTag = domSandbox.querySelector('svg');
3591 if (!svgTag) {
3592 throw new Error('Vivus [load]: Cannot find the SVG in the loaded file : ' + options.file);
3593 }
3594
3595 self.el = svgTag
3596 self.el.setAttribute('width', '100%');
3597 self.el.setAttribute('height', '100%');
3598 self.parentEl.appendChild(self.el)
3599 self.isReady = true;
3600 self.init();
3601 self = null;
3602 }
3603
3604 var oReq = new window.XMLHttpRequest();
3605 oReq.addEventListener('load', onLoad);
3606 oReq.open('GET', options.file);
3607 oReq.send();
3608 return;
3609 }
3610
3611 switch (element.constructor) {
3612 case window.SVGSVGElement:
3613 case window.SVGElement:
3614 case window.SVGGElement:
3615 this.el = element;
3616 this.isReady = true;
3617 break;
3618
3619 case window.HTMLObjectElement:
3620 self = this;
3621 onLoad = function (e) {
3622 if (self.isReady) {
3623 return;
3624 }
3625 self.el = element.contentDocument && element.contentDocument.querySelector('svg');
3626 if (!self.el && e) {
3627 throw new Error('Vivus [constructor]: object loaded does not contain any SVG');
3628 }
3629 else if (self.el) {
3630 if (element.getAttribute('built-by-vivus')) {
3631 self.parentEl.insertBefore(self.el, element);
3632 self.parentEl.removeChild(element);
3633 self.el.setAttribute('width', '100%');
3634 self.el.setAttribute('height', '100%');
3635 }
3636 self.isReady = true;
3637 self.init();
3638 self = null;
3639 }
3640 };
3641
3642 if (!onLoad()) {
3643 element.addEventListener('load', onLoad);
3644 }
3645 break;
3646
3647 default:
3648 throw new Error('Vivus [constructor]: "element" parameter is not valid (or miss the "file" attribute)');
3649 }
3650};
3651
3652/**
3653 * Set up user option to the instance
3654 * The method will not return anything, but will throw an
3655 * error if the parameter is invalid
3656 *
3657 * @param {object} options Object from the constructor
3658 */
3659Vivus.prototype.setOptions = function (options) {
3660 var allowedTypes = ['delayed', 'sync', 'async', 'nsync', 'oneByOne', 'scenario', 'scenario-sync'];
3661 var allowedStarts = ['inViewport', 'manual', 'autostart'];
3662
3663 // Basic check
3664 if (options !== undefined && options.constructor !== Object) {
3665 throw new Error('Vivus [constructor]: "options" parameter must be an object');
3666 }
3667 else {
3668 options = options || {};
3669 }
3670
3671 // Set the animation type
3672 if (options.type && allowedTypes.indexOf(options.type) === -1) {
3673 throw new Error('Vivus [constructor]: ' + options.type + ' is not an existing animation `type`');
3674 }
3675 else {
3676 this.type = options.type || allowedTypes[0];
3677 }
3678
3679 // Set the start type
3680 if (options.start && allowedStarts.indexOf(options.start) === -1) {
3681 throw new Error('Vivus [constructor]: ' + options.start + ' is not an existing `start` option');
3682 }
3683 else {
3684 this.start = options.start || allowedStarts[0];
3685 }
3686
3687 this.isIE = (window.navigator.userAgent.indexOf('MSIE') !== -1 || window.navigator.userAgent.indexOf('Trident/') !== -1 || window.navigator.userAgent.indexOf('Edge/') !== -1 );
3688 this.duration = parsePositiveInt(options.duration, 120);
3689 this.delay = parsePositiveInt(options.delay, null);
3690 //Uncode addition
3691 this.delayStart = parsePositiveInt(options.delayStart, null);
3692 //#END
3693 this.dashGap = parsePositiveInt(options.dashGap, 1);
3694 this.forceRender = options.hasOwnProperty('forceRender') ? !!options.forceRender : this.isIE;
3695 this.reverseStack = !!options.reverseStack;
3696 this.selfDestroy = !!options.selfDestroy;
3697 this.onReady = options.onReady;
3698 this.map = [];
3699 this.frameLength = this.currentFrame = this.delayUnit = this.speed = this.handle = null;
3700
3701 this.ignoreInvisible = options.hasOwnProperty('ignoreInvisible') ? !!options.ignoreInvisible : false;
3702
3703 this.animTimingFunction = options.animTimingFunction || Vivus.LINEAR;
3704 this.pathTimingFunction = options.pathTimingFunction || Vivus.LINEAR;
3705
3706 if (this.delay >= this.duration) {
3707 throw new Error('Vivus [constructor]: delay must be shorter than duration');
3708 }
3709};
3710
3711/**
3712 * Set up callback to the instance
3713 * The method will not return enything, but will throw an
3714 * error if the parameter is invalid
3715 *
3716 * @param {Function} callback Callback for the animation end
3717 */
3718Vivus.prototype.setCallback = function (callback) {
3719 // Basic check
3720 if (!!callback && callback.constructor !== Function) {
3721 throw new Error('Vivus [constructor]: "callback" parameter must be a function');
3722 }
3723 this.callback = callback || function () {};
3724};
3725
3726
3727/**
3728 * Core
3729 **************************************
3730 */
3731
3732/**
3733 * Map the svg, path by path.
3734 * The method return nothing, it just fill the
3735 * `map` array. Each item in this array represent
3736 * a path element from the SVG, with informations for
3737 * the animation.
3738 *
3739 * ```
3740 * [
3741 * {
3742 * el: <DOMobj> the path element
3743 * length: <number> length of the path line
3744 * startAt: <number> time start of the path animation (in frames)
3745 * duration: <number> path animation duration (in frames)
3746 * },
3747 * ...
3748 * ]
3749 * ```
3750 *
3751 */
3752Vivus.prototype.mapping = function () {
3753 var i, paths, path, pAttrs, pathObj, totalLength, lengthMeter, timePoint;
3754 timePoint = totalLength = lengthMeter = 0;
3755 paths = this.el.querySelectorAll('path');
3756
3757 for (i = 0; i < paths.length; i++) {
3758 path = paths[i];
3759 if (this.isInvisible(path)) {
3760 continue;
3761 }
3762 pathObj = {
3763 el: path,
3764 length: Math.ceil(path.getTotalLength())
3765 };
3766 // Test if the path length is correct
3767 if (isNaN(pathObj.length)) {
3768 if (window.console && console.warn) {
3769 console.warn('Vivus [mapping]: cannot retrieve a path element length', path);
3770 }
3771 continue;
3772 }
3773 this.map.push(pathObj);
3774 path.style.strokeDasharray = pathObj.length + ' ' + (pathObj.length + this.dashGap * 2);
3775 path.style.strokeDashoffset = pathObj.length + this.dashGap;
3776 pathObj.length += this.dashGap;
3777 totalLength += pathObj.length;
3778
3779 this.renderPath(i);
3780 }
3781
3782 totalLength = totalLength === 0 ? 1 : totalLength;
3783 this.delay = this.delay === null ? this.duration / 3 : this.delay;
3784 this.delayUnit = this.delay / (paths.length > 1 ? paths.length - 1 : 1);
3785
3786 // Reverse stack if asked
3787 if (this.reverseStack) {
3788 this.map.reverse();
3789 }
3790
3791 for (i = 0; i < this.map.length; i++) {
3792 pathObj = this.map[i];
3793
3794 switch (this.type) {
3795 case 'delayed':
3796 pathObj.startAt = this.delayUnit * i;
3797 pathObj.duration = this.duration - this.delay;
3798 break;
3799
3800 case 'oneByOne':
3801 pathObj.startAt = lengthMeter / totalLength * this.duration;
3802 pathObj.duration = pathObj.length / totalLength * this.duration;
3803 break;
3804
3805 case 'sync':
3806 case 'async':
3807 case 'nsync':
3808 pathObj.startAt = 0;
3809 pathObj.duration = this.duration;
3810 break;
3811
3812 case 'scenario-sync':
3813 path = pathObj.el;
3814 pAttrs = this.parseAttr(path);
3815 pathObj.startAt = timePoint + (parsePositiveInt(pAttrs['data-delay'], this.delayUnit) || 0);
3816 pathObj.duration = parsePositiveInt(pAttrs['data-duration'], this.duration);
3817 timePoint = pAttrs['data-async'] !== undefined ? pathObj.startAt : pathObj.startAt + pathObj.duration;
3818 this.frameLength = Math.max(this.frameLength, (pathObj.startAt + pathObj.duration));
3819 break;
3820
3821 case 'scenario':
3822 path = pathObj.el;
3823 pAttrs = this.parseAttr(path);
3824 pathObj.startAt = parsePositiveInt(pAttrs['data-start'], this.delayUnit) || 0;
3825 pathObj.duration = parsePositiveInt(pAttrs['data-duration'], this.duration);
3826 this.frameLength = Math.max(this.frameLength, (pathObj.startAt + pathObj.duration));
3827 break;
3828 }
3829 lengthMeter += pathObj.length;
3830 this.frameLength = this.frameLength || this.duration;
3831 }
3832};
3833
3834/**
3835 * Interval method to draw the SVG from current
3836 * position of the animation. It update the value of
3837 * `currentFrame` and re-trace the SVG.
3838 *
3839 * It use this.handle to store the requestAnimationFrame
3840 * and clear it one the animation is stopped. So this
3841 * attribute can be used to know if the animation is
3842 * playing.
3843 *
3844 * Once the animation at the end, this method will
3845 * trigger the Vivus callback.
3846 *
3847 */
3848Vivus.prototype.drawer = function () {
3849 var self = this;
3850 this.currentFrame += this.speed;
3851
3852 if (this.currentFrame <= 0) {
3853 this.stop();
3854 this.reset();
3855 } else if (this.currentFrame >= this.frameLength) {
3856 this.stop();
3857 this.currentFrame = this.frameLength;
3858 this.trace();
3859 if (this.selfDestroy) {
3860 this.destroy();
3861 }
3862 } else {
3863 this.trace();
3864 this.handle = requestAnimFrame(function () {
3865 self.drawer();
3866 });
3867 return;
3868 }
3869
3870 this.callback(this);
3871 if (this.instanceCallback) {
3872 this.instanceCallback(this);
3873 this.instanceCallback = null;
3874 }
3875};
3876
3877/**
3878 * Draw the SVG at the current instant from the
3879 * `currentFrame` value. Here is where most of the magic is.
3880 * The trick is to use the `strokeDashoffset` style property.
3881 *
3882 * For optimisation reasons, a new property called `progress`
3883 * is added in each item of `map`. This one contain the current
3884 * progress of the path element. Only if the new value is different
3885 * the new value will be applied to the DOM element. This
3886 * method save a lot of resources to re-render the SVG. And could
3887 * be improved if the animation couldn't be played forward.
3888 *
3889 */
3890Vivus.prototype.trace = function () {
3891 var i, progress, path, currentFrame;
3892 currentFrame = this.animTimingFunction(this.currentFrame / this.frameLength) * this.frameLength;
3893 for (i = 0; i < this.map.length; i++) {
3894 path = this.map[i];
3895 progress = (currentFrame - path.startAt) / path.duration;
3896 progress = this.pathTimingFunction(Math.max(0, Math.min(1, progress)));
3897 if (path.progress !== progress) {
3898 path.progress = progress;
3899 path.el.style.strokeDashoffset = Math.floor(path.length * (1 - progress));
3900 this.renderPath(i);
3901 }
3902 }
3903};
3904
3905/**
3906 * Method forcing the browser to re-render a path element
3907 * from it's index in the map. Depending on the `forceRender`
3908 * value.
3909 * The trick is to replace the path element by it's clone.
3910 * This practice is not recommended because it's asking more
3911 * ressources, too much DOM manupulation..
3912 * but it's the only way to let the magic happen on IE.
3913 * By default, this fallback is only applied on IE.
3914 *
3915 * @param {Number} index Path index
3916 */
3917Vivus.prototype.renderPath = function (index) {
3918 if (this.forceRender && this.map && this.map[index]) {
3919 var pathObj = this.map[index],
3920 newPath = pathObj.el.cloneNode(true);
3921 pathObj.el.parentNode.replaceChild(newPath, pathObj.el);
3922 pathObj.el = newPath;
3923 }
3924};
3925
3926/**
3927 * When the SVG object is loaded and ready,
3928 * this method will continue the initialisation.
3929 *
3930 * This this mainly due to the case of passing an
3931 * object tag in the constructor. It will wait
3932 * the end of the loading to initialise.
3933 *
3934 */
3935Vivus.prototype.init = function () {
3936 // Set object variables
3937 this.frameLength = 0;
3938 this.currentFrame = 0;
3939 this.map = [];
3940
3941 // Start
3942 new Pathformer(this.el);
3943 this.mapping();
3944 this.starter();
3945
3946 if (this.onReady) {
3947 this.onReady(this);
3948 }
3949};
3950
3951/**
3952 * Trigger to start of the animation.
3953 * Depending on the `start` value, a different script
3954 * will be applied.
3955 *
3956 * If the `start` value is not valid, an error will be thrown.
3957 * Even if technically, this is impossible.
3958 *
3959 */
3960Vivus.prototype.starter = function () {
3961 switch (this.start) {
3962 case 'manual':
3963 return;
3964
3965 case 'autostart':
3966 this.play();
3967 break;
3968
3969 case 'inViewport':
3970 var self = this,
3971 listener = function () {
3972 if (self.isInViewport(self.parentEl, 1)) {
3973 self.play();
3974 window.removeEventListener('scroll', listener);
3975 //Uncode addition
3976 window.removeEventListener('fp-slide-changed', listener);
3977 window.removeEventListener('fp-slide-scroll', listener);
3978 //#END
3979 }
3980 };
3981 window.addEventListener('scroll', listener);
3982 //Uncode addition
3983 window.addEventListener('fp-slide-changed', listener);
3984 window.addEventListener('fp-slide-scroll', listener);
3985 //#END
3986 listener();
3987 break;
3988 }
3989};
3990
3991
3992/**
3993 * Controls
3994 **************************************
3995 */
3996
3997/**
3998 * Get the current status of the animation between
3999 * three different states: 'start', 'progress', 'end'.
4000 * @return {string} Instance status
4001 */
4002Vivus.prototype.getStatus = function () {
4003 return this.currentFrame === 0 ? 'start' : this.currentFrame === this.frameLength ? 'end' : 'progress';
4004};
4005
4006/**
4007 * Reset the instance to the initial state : undraw
4008 * Be careful, it just reset the animation, if you're
4009 * playing the animation, this won't stop it. But just
4010 * make it start from start.
4011 *
4012 */
4013Vivus.prototype.reset = function () {
4014 return this.setFrameProgress(0);
4015};
4016
4017/**
4018 * Set the instance to the final state : drawn
4019 * Be careful, it just set the animation, if you're
4020 * playing the animation on rewind, this won't stop it.
4021 * But just make it start from the end.
4022 *
4023 */
4024Vivus.prototype.finish = function () {
4025 return this.setFrameProgress(1);
4026};
4027
4028/**
4029 * Set the level of progress of the drawing.
4030 *
4031 * @param {number} progress Level of progress to set
4032 */
4033Vivus.prototype.setFrameProgress = function (progress) {
4034 progress = Math.min(1, Math.max(0, progress));
4035 this.currentFrame = Math.round(this.frameLength * progress);
4036 this.trace();
4037 return this;
4038};
4039
4040/**
4041 * Play the animation at the desired speed.
4042 * Speed must be a valid number (no zero).
4043 * By default, the speed value is 1.
4044 * But a negative value is accepted to go forward.
4045 *
4046 * And works with float too.
4047 * But don't forget we are in JavaScript, se be nice
4048 * with him and give him a 1/2^x value.
4049 *
4050 * @param {number} speed Animation speed [optional]
4051 */
4052Vivus.prototype.play = function (speed, callback) {
4053 this.instanceCallback = null;
4054
4055 if (speed && typeof speed === 'function') {
4056 this.instanceCallback = speed; // first parameter is actually the callback function
4057 speed = null;
4058 }
4059 else if (speed && typeof speed !== 'number') {
4060 throw new Error('Vivus [play]: invalid speed');
4061 }
4062 // if the first parameter wasn't the callback, check if the seconds was
4063 if (callback && typeof(callback) === 'function' && !this.instanceCallback) {
4064 this.instanceCallback = callback;
4065 }
4066
4067
4068 this.speed = speed || 1;
4069 //Uncode addition
4070 if (!this.handle) {
4071 var $this = this,
4072 delay = (this.delayStart != null) ? this.delayStart : 0;
4073 setTimeout(function() {
4074 $this.drawer();
4075 }, delay);
4076 }
4077 //#END
4078 return this;
4079};
4080
4081/**
4082 * Stop the current animation, if on progress.
4083 * Should not trigger any error.
4084 *
4085 */
4086Vivus.prototype.stop = function () {
4087 if (this.handle) {
4088 cancelAnimFrame(this.handle);
4089 this.handle = null;
4090 }
4091 return this;
4092};
4093
4094/**
4095 * Destroy the instance.
4096 * Remove all bad styling attributes on all
4097 * path tags
4098 *
4099 */
4100Vivus.prototype.destroy = function () {
4101 this.stop();
4102 var i, path;
4103 for (i = 0; i < this.map.length; i++) {
4104 path = this.map[i];
4105 path.el.style.strokeDashoffset = null;
4106 path.el.style.strokeDasharray = null;
4107 this.renderPath(i);
4108 }
4109};
4110
4111
4112/**
4113 * Utils methods
4114 * include methods from Codrops
4115 **************************************
4116 */
4117
4118/**
4119 * Method to best guess if a path should added into
4120 * the animation or not.
4121 *
4122 * 1. Use the `data-vivus-ignore` attribute if set
4123 * 2. Check if the instance must ignore invisible paths
4124 * 3. Check if the path is visible
4125 *
4126 * For now the visibility checking is unstable.
4127 * It will be used for a beta phase.
4128 *
4129 * Other improvments are planned. Like detecting
4130 * is the path got a stroke or a valid opacity.
4131 */
4132Vivus.prototype.isInvisible = function (el) {
4133 var rect,
4134 ignoreAttr = el.getAttribute('data-ignore');
4135
4136 if (ignoreAttr !== null) {
4137 return ignoreAttr !== 'false';
4138 }
4139
4140 if (this.ignoreInvisible) {
4141 rect = el.getBoundingClientRect();
4142 return !rect.width && !rect.height;
4143 }
4144 else {
4145 return false;
4146 }
4147};
4148
4149/**
4150 * Parse attributes of a DOM element to
4151 * get an object of {attributeName => attributeValue}
4152 *
4153 * @param {object} element DOM element to parse
4154 * @return {object} Object of attributes
4155 */
4156Vivus.prototype.parseAttr = function (element) {
4157 var attr, output = {};
4158 if (element && element.attributes) {
4159 for (var i = 0; i < element.attributes.length; i++) {
4160 attr = element.attributes[i];
4161 output[attr.name] = attr.value;
4162 }
4163 }
4164 return output;
4165};
4166
4167/**
4168 * Reply if an element is in the page viewport
4169 *
4170 * @param {object} el Element to observe
4171 * @param {number} h Percentage of height
4172 * @return {boolean}
4173 */
4174Vivus.prototype.isInViewport = function (el, h) {
4175 var scrolled = this.scrollY(),
4176 viewed = scrolled + this.getViewportH(),
4177 elBCR = el.getBoundingClientRect(),
4178 elHeight = elBCR.height,
4179 elTop = scrolled + elBCR.top,
4180 elBottom = elTop + elHeight;
4181
4182 // if 0, the element is considered in the viewport as soon as it enters.
4183 // if 1, the element is considered in the viewport only when it's fully inside
4184 // value in percentage (1 >= h >= 0)
4185 h = h || 0;
4186
4187 return (elTop + elHeight * h) <= viewed && (elBottom) >= scrolled;
4188};
4189
4190
4191/**
4192 * Get the viewport height in pixels
4193 *
4194 * @return {integer} Viewport height
4195 */
4196Vivus.prototype.getViewportH = function () {
4197 var client = this.docElem.clientHeight,
4198 inner = window.innerHeight;
4199
4200 if (client < inner) {
4201 return inner;
4202 }
4203 else {
4204 return client;
4205 }
4206};
4207
4208/**
4209 * Get the page Y offset
4210 *
4211 * @return {integer} Page Y offset
4212 */
4213Vivus.prototype.scrollY = function () {
4214 return window.pageYOffset || this.docElem.scrollTop;
4215};
4216
4217setupEnv = function () {
4218
4219 if (Vivus.prototype.docElem) {
4220 return;
4221 }
4222
4223 /**
4224 * Alias for document element
4225 *
4226 * @type {DOMelement}
4227 */
4228 Vivus.prototype.docElem = window.document.documentElement;
4229
4230 /**
4231 * Alias for `requestAnimationFrame` or
4232 * `setTimeout` function for deprecated browsers.
4233 *
4234 */
4235 requestAnimFrame = (function () {
4236 return (
4237 window.requestAnimationFrame ||
4238 window.webkitRequestAnimationFrame ||
4239 window.mozRequestAnimationFrame ||
4240 window.oRequestAnimationFrame ||
4241 window.msRequestAnimationFrame ||
4242 function(/* function */ callback){
4243 return window.setTimeout(callback, 1000 / 60);
4244 }
4245 );
4246 })();
4247
4248 /**
4249 * Alias for `cancelAnimationFrame` or
4250 * `cancelTimeout` function for deprecated browsers.
4251 *
4252 */
4253 cancelAnimFrame = (function () {
4254 return (
4255 window.cancelAnimationFrame ||
4256 window.webkitCancelAnimationFrame ||
4257 window.mozCancelAnimationFrame ||
4258 window.oCancelAnimationFrame ||
4259 window.msCancelAnimationFrame ||
4260 function(id){
4261 return window.clearTimeout(id);
4262 }
4263 );
4264 })();
4265};
4266
4267/**
4268 * Parse string to integer.
4269 * If the number is not positive or null
4270 * the method will return the default value
4271 * or 0 if undefined
4272 *
4273 * @param {string} value String to parse
4274 * @param {*} defaultValue Value to return if the result parsed is invalid
4275 * @return {number}
4276 *
4277 */
4278parsePositiveInt = function (value, defaultValue) {
4279 var output = parseInt(value, 10);
4280 return (output >= 0) ? output : defaultValue;
4281};
4282
4283
4284 if (typeof define === 'function' && define.amd) {
4285 // AMD. Register as an anonymous module.
4286 define([], function() {
4287 return Vivus;
4288 });
4289 } else if (typeof exports === 'object') {
4290 // Node. Does not work with strict CommonJS, but
4291 // only CommonJS-like environments that support module.exports,
4292 // like Node.
4293 module.exports = Vivus;
4294 } else {
4295 // Browser globals
4296 window.Vivus = Vivus;
4297 }
4298
4299}());
4300
4301(function(global){var startY=0;var enabled=false;var supportsPassiveOption=false;try{var opts=Object.defineProperty({},"passive",{get:function(){supportsPassiveOption=true}});window.addEventListener("test",null,opts)}catch(e){}var handleTouchmove=function(evt){var el=evt.target;while(el!==document.body&&el!==document){var style=window.getComputedStyle(el);if(!style){break}if(el.nodeName==="INPUT"&&el.getAttribute("type")==="range"){return}var scrolling=style.getPropertyValue("-webkit-overflow-scrolling");var overflowY=style.getPropertyValue("overflow-y");var height=parseInt(style.getPropertyValue("height"),10);var isScrollable=scrolling==="touch"&&(overflowY==="auto"||overflowY==="scroll");var canScroll=el.scrollHeight>el.offsetHeight;if(isScrollable&&canScroll){var curY=evt.touches?evt.touches[0].screenY:evt.screenY;var isAtTop=startY<=curY&&el.scrollTop===0;var isAtBottom=startY>=curY&&el.scrollHeight-el.scrollTop===height;if(isAtTop||isAtBottom){evt.preventDefault()}return}el=el.parentNode}evt.preventDefault()};var handleTouchstart=function(evt){startY=evt.touches?evt.touches[0].screenY:evt.screenY};var enable=function(){window.addEventListener("touchstart",handleTouchstart,supportsPassiveOption?{passive:false}:false);window.addEventListener("touchmove",handleTouchmove,supportsPassiveOption?{passive:false}:false);enabled=true};var disable=function(){window.removeEventListener("touchstart",handleTouchstart,false);window.removeEventListener("touchmove",handleTouchmove,false);enabled=false};var isEnabled=function(){return enabled};var testDiv=document.createElement("div");document.documentElement.appendChild(testDiv);testDiv.style.WebkitOverflowScrolling="touch";var scrollSupport="getComputedStyle"in window&&window.getComputedStyle(testDiv)["-webkit-overflow-scrolling"]==="touch";document.documentElement.removeChild(testDiv);if(scrollSupport){enable()}var iNoBounce={enable:enable,disable:disable,isEnabled:isEnabled};if(typeof module!=="undefined"&&module.exports){module.exports=iNoBounce}if(typeof global.define==="function"){(function(define){define("iNoBounce",[],function(){return iNoBounce})})(global.define)}else{global.iNoBounce=iNoBounce}})(this);
4302iNoBounce.disable();
4303
4304/* Font Face Observer v2.1.0 - © Bram Stein. License: BSD-3-Clause */(function(){function l(a,b){document.addEventListener?a.addEventListener("scroll",b,!1):a.attachEvent("scroll",b)}function m(a){document.body?a():document.addEventListener?document.addEventListener("DOMContentLoaded",function c(){document.removeEventListener("DOMContentLoaded",c);a()}):document.attachEvent("onreadystatechange",function k(){if("interactive"==document.readyState||"complete"==document.readyState)document.detachEvent("onreadystatechange",k),a()})};function t(a){this.a=document.createElement("div");this.a.setAttribute("aria-hidden","true");this.a.appendChild(document.createTextNode(a));this.b=document.createElement("span");this.c=document.createElement("span");this.h=document.createElement("span");this.f=document.createElement("span");this.g=-1;this.b.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;";this.c.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;";
4305this.f.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;";this.h.style.cssText="display:inline-block;width:200%;height:200%;font-size:16px;max-width:none;";this.b.appendChild(this.h);this.c.appendChild(this.f);this.a.appendChild(this.b);this.a.appendChild(this.c)}
4306function u(a,b){a.a.style.cssText="max-width:none;min-width:20px;min-height:20px;display:inline-block;overflow:hidden;position:absolute;width:auto;margin:0;padding:0;top:-999px;white-space:nowrap;font-synthesis:none;font:"+b+";"}function z(a){var b=a.a.offsetWidth,c=b+100;a.f.style.width=c+"px";a.c.scrollLeft=c;a.b.scrollLeft=a.b.scrollWidth+100;return a.g!==b?(a.g=b,!0):!1}function A(a,b){function c(){var a=k;z(a)&&a.a.parentNode&&b(a.g)}var k=a;l(a.b,c);l(a.c,c);z(a)};function B(a,b){var c=b||{};this.family=a;this.style=c.style||"normal";this.weight=c.weight||"normal";this.stretch=c.stretch||"normal"}var C=null,D=null,E=null,F=null;function G(){if(null===D)if(J()&&/Apple/.test(window.navigator.vendor)){var a=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))(?:\.([0-9]+))/.exec(window.navigator.userAgent);D=!!a&&603>parseInt(a[1],10)}else D=!1;return D}function J(){null===F&&(F=!!document.fonts);return F}
4307function K(){if(null===E){var a=document.createElement("div");try{a.style.font="condensed 100px sans-serif"}catch(b){}E=""!==a.style.font}return E}function L(a,b){return[a.style,a.weight,K()?a.stretch:"","100px",b].join(" ")}
4308B.prototype.load=function(a,b){var c=this,k=a||"BESbswy",r=0,n=b||3E3,H=(new Date).getTime();return new Promise(function(a,b){if(J()&&!G()){var M=new Promise(function(a,b){function e(){(new Date).getTime()-H>=n?b(Error(""+n+"ms timeout exceeded")):document.fonts.load(L(c,'"'+c.family+'"'),k).then(function(c){1<=c.length?a():setTimeout(e,25)},b)}e()}),N=new Promise(function(a,c){r=setTimeout(function(){c(Error(""+n+"ms timeout exceeded"))},n)});Promise.race([N,M]).then(function(){clearTimeout(r);a(c)},
4309b)}else m(function(){function v(){var b;if(b=-1!=f&&-1!=g||-1!=f&&-1!=h||-1!=g&&-1!=h)(b=f!=g&&f!=h&&g!=h)||(null===C&&(b=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent),C=!!b&&(536>parseInt(b[1],10)||536===parseInt(b[1],10)&&11>=parseInt(b[2],10))),b=C&&(f==w&&g==w&&h==w||f==x&&g==x&&h==x||f==y&&g==y&&h==y)),b=!b;b&&(d.parentNode&&d.parentNode.removeChild(d),clearTimeout(r),a(c))}function I(){if((new Date).getTime()-H>=n)d.parentNode&&d.parentNode.removeChild(d),b(Error(""+
4310n+"ms timeout exceeded"));else{var a=document.hidden;if(!0===a||void 0===a)f=e.a.offsetWidth,g=p.a.offsetWidth,h=q.a.offsetWidth,v();r=setTimeout(I,50)}}var e=new t(k),p=new t(k),q=new t(k),f=-1,g=-1,h=-1,w=-1,x=-1,y=-1,d=document.createElement("div");d.dir="ltr";u(e,L(c,"sans-serif"));u(p,L(c,"serif"));u(q,L(c,"monospace"));d.appendChild(e.a);d.appendChild(p.a);d.appendChild(q.a);document.body.appendChild(d);w=e.a.offsetWidth;x=p.a.offsetWidth;y=q.a.offsetWidth;I();A(e,function(a){f=a;v()});u(e,
4311L(c,'"'+c.family+'",sans-serif'));A(p,function(a){g=a;v()});u(p,L(c,'"'+c.family+'",serif'));A(q,function(a){h=a;v()});u(q,L(c,'"'+c.family+'",monospace'))})})};"object"===typeof module?module.exports=B:(window.FontFaceObserver=B,window.FontFaceObserver.prototype.load=B.prototype.load);}());