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'
128+ (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 <[email protected]> (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;
852 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-vert
1026ical')) { 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 if (closestStyle != null && classie.hasClass(closestStyle, 'style-light')) { 1034 switchColorsMenu(0, 'light'); 1035 } else if (getClosest(headerel, 'style-dark') != null) { 1036 switchColorsMenu(0, 'dark'); 1037 } 1038 else { 1039 if (masthead.style.opacity !== 1) masthead.style.opacity = 1; 1040 } 1041 if (classie.hasClass(masthead, 'menu-transparent')) { 1042 if (isMobileTransparent || wwidth > mediaQuery) { 1043 masthead.parentNode.style.height = '0px'; 1044 if (classie.hasClass(masthead, 'menu-add-padding')) { 1045 var headerBlock = getClosest(headerel, 'header-uncode-block'); 1046 if (headerBlock != null) { 1047 var innerRows = headerel.querySelectorAll('.column_parent > .uncol > .uncoltable > .uncell > .uncont, .uncode-slider .column_child > .uncol > .uncoltable > .uncell > .uncont'); 1048 for (var k = 0; k < innerRows.length; k++) { 1049 if (innerRows[k] != undefined) { 1050 if (wwidth > mediaQuery) innerRows[k].style.paddingTop = transmenuHeight + 'px'; 1051 else innerRows[k].style.paddingTop = (transmenuHeight - mastheadMobilePaddingTop) + 'px'; 1052 } 1053 } 1054 } else { 1055 getDivChildren(headerel, '.header-content', function(headerContent, i) { 1056 if (wwidth > mediaQuery) headerContent.style.paddingTop = transmenuHeight + 'px'; 1057 else headerContent.style.paddingTop = (transmenuHeight - mastheadMobilePaddingTop) + 'px'; 1058 }); 1059 } 1060 } 1061 } 1062 } 1063 if (classie.hasClass(headerel, 'uncoltable')) { 1064 break; 1065 } 1066 } 1067 } else { 1068 if (menuwrapper[0] != undefined) classie.addClass(menuwrapper[0], 'no-header'); 1069 classie.removeClass(masthead, 'menu-transparent'); 1070 transmenuHeight = 0; 1071 isMobileTransparent = false; 1072 } 1073 } else { 1074 isMobileTransparent = false; 1075 } 1076 if (typeof transmenuel === 'undefined' || !transmenuel.length) isMobileTransparent = false; 1077 bodyTop = document.documentElement['scrollTop'] || document.body['scrollTop']; 1078 UNCODE.bodyTop = bodyTop; 1079 if (!classie.hasClass(document.body, 'vmenu')) 1080 initBox(); 1081 scrollFunction(); 1082 showHideScrollup(bodyTop); 1083 1084 if ( UNCODE.isMobile ) { 1085 1086 var eventName = 'loadedmetadata'; 1087 eventName = eventName.replace(/^on/, ''); 1088 var elt = document.createElement('video'[eventName]); 1089 var eventIsSupported = ('on'+eventName in elt); 1090 elt = null; 1091 if ( ! eventIsSupported) { 1092 classie.addClass(document.body, 'video-not-supported'); 1093 } 1094 } 1095 }, 1096 initRow = function(currentRow) { 1097 UNCODE.adaptive(); 1098 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 ), 1099 rowParent = el.parentNode, 1100 rowInner = currentRow.parentNode, 1101 percentHeight = el.getAttribute("data-height-ratio"), 1102 minHeight = el.getAttribute("data-minheight"), 1103 calculateHeight, 1104 calculatePadding = 0, 1105 isHeader = false, 1106 isFirst = false, 1107 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; 1108 1109 /** Add class to the row when contains responsive column size */ 1110 getDivChildren(el.parentNode, '.column_parent, .column_child', function(obj, i, total) { 1111 if ((obj.className).indexOf("col-md-") > - 1) { 1112 classie.addClass(obj.parentNode, 'cols-md-responsive'); 1113 } 1114 obj.className = obj.className.replace(/vc_col-sm-(\d{1,2})/g, ""); 1115 if ((obj.className).indexOf("col-sm-") > - 1 && (obj.className).indexOf("col-sm-clear") == - 1) { 1116 classie.addClass(obj.parentNode, 'cols-sm-responsive'); 1117 } 1118 }); 1119 1120 setRowHeight(el); 1121 1122 var elements = 0; 1123 getDivChildren(el, '.row-internal .background-inner', function(obj, i, total) { 1124 elements++; 1125 if (i == 0) { 1126 if (!!obj.style.backgroundImage && obj.style.backgroundImage !== void 0) { 1127 var url = (obj.style.backgroundImage).match(uri_pattern), 1128 image = new Image(); 1129 image.onload = function() { 1130 el.setAttribute('data-imgready', 'true'); 1131 el.dispatchEvent(new CustomEvent('imgLoaded')); 1132 }; 1133 image.src = url[0]; 1134 } else { 1135 el.setAttribute('data-imgready', 'true'); 1136 el.dispatchEvent(new CustomEvent('imgLoaded')); 1137 } 1138 } 1139 }); 1140 if (elements == 0) { 1141 el.setAttribute('data-imgready', 'true'); 1142 } 1143 1144 /** init parallax is not mobile */ 1145 if ( ! UNCODE.isFullPage ) { 1146 bodyTop = document.documentElement['scrollTop'] || document.body['scrollTop']; 1147 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'); 1148 kenburnsCols = el.querySelectorAll('.with-kburns > .column-background > .background-wrapper'); 1149 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'); 1150 backwashCols = el.querySelectorAll('.with-zoomout > .column-background > .background-wrapper'); 1151 if (isMobileParallaxAllowed || !UNCODE.isMobile) {
1152 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'); 1153 parallaxCols = el.querySelectorAll('.with-parallax > .column-background > .background-wrapper'); 1154 visibleRows = el.parentNode.parentNode; 1155 parallaxRowCol(bodyTop); 1156 visibleRowCol(bodyTop); 1157 } else { 1158 if (UNCODE.isMobile) { 1159 kenburnsHeader(bodyTop); 1160 kenburnsRowCol(bodyTop); 1161 backwashHeader(bodyTop); 1162 backwashRowCol(bodyTop); 1163 } 1164 } 1165 } 1166 1167 shapeDivider(); 1168 1169 var wrapLinesWw = wwidth; 1170 1171 //Text animation, automatic lines and highlights 1172 var setWrap; 1173 1174 function word_for_lines(event, $parent_el){ 1175 1176 if ( typeof $parent_el === 'undefined' || $parent_el === null ) { 1177 $parent_el = document.body; 1178 } 1179 1180 var $headings = $parent_el.querySelectorAll('.heading-text'); 1181 1182 for (var head_k = 0; head_k < $headings.length; head_k++) { 1183 var $heading = $headings[head_k], 1184 heading_cont = $heading.innerHTML, 1185 $row = $heading.closest('.row-parent'), 1186 $owl_carousel = $heading.closest('.owl-carousel-wrapper'), 1187 $owl_item = $heading.closest('.owl-item'), 1188 $words = $heading.querySelectorAll('.split-word'), 1189 setWrap; 1190 1191 if ( ! $words.length ) { 1192 if ( $owl_item !== null ) 1193 continue; 1194 } 1195 1196 if ( $owl_carousel === null && typeof event !== 'undefined' && event !== 'resize' && event !== false ) { 1197 continue; 1198 } 1199 1200 if ( $owl_carousel !== null ) { 1201 if ( 1202 ( $owl_item === null ) 1203 || 1204 ( $owl_item !== null && classie.hasClass($owl_item, 'active') && $owl_item.getAttribute('data-index') !== '1' ) 1205 || 1206 ( $owl_item !== null && classie.hasClass($owl_item, 'active') && $owl_item.getAttribute('data-index') === '1' && $owl_item.getAttribute('data-already-reached') === 'true' ) 1207 ) { 1208 continue; 1209 } 1210 } 1211 1212 $heading.innerHTML = heading_cont; 1213 $words = $heading.querySelectorAll('.split-word'); 1214 var lineArray = [], 1215 lineIndex = 0, 1216 lineStart = true, 1217 lineEnd = false, 1218 $text_highlight = $heading.querySelectorAll('.heading-text-highlight'), 1219 $line_wraps = $heading.querySelectorAll('.heading-line-wrap'); 1220 1221 if ( $line_wraps.length && typeof event === 'undefined' ) { 1222 continue; 1223 } 1224 1225 var lettering = function(){ 1226 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'); 1227 1228 for (var i = 0; i < $wraps.length; i++) { 1229 var $wrap = $wraps[i], 1230 $lines = $wrap.querySelectorAll('.heading-line-wrap'), 1231 $words = $wrap.querySelectorAll('.split-word'), 1232 containerDelay = $wrap.getAttribute('data-delay'), 1233 containerSpeed = $wrap.getAttribute('data-speed'), 1234 containerSpeed_val = typeof containerSpeed !== 'undefined' && containerSpeed !== null ? parseFloat(containerSpeed) : 400, 1235 containerInterval = typeof $wrap.getAttribute('data-interval') !== 'undefined' && $wrap.getAttribute('data-interval') !== null ? $wrap.getAttribute('data-interval') : 0, 1236 delayAttr = (containerDelay != undefined) ? containerDelay : 0; 1237 1238 if ( classie.hasClass($wrap, 'already-animated') ) { 1239 continue; 1240 } 1241 1242 if ( classie.hasClass($wrap, 'curtain') ) { 1243 1244 for (var il = 0; il < $lines.length; il++) { 1245 var $line = $lines[il], 1246 $spans = $line.querySelectorAll('.split-word-inner'); 1247 1248 for (var is = 0; is < $spans.length; is++) { 1249 1250 var $span = $spans[is]; 1251 1252 $span.setAttribute('data-delay', ( parseFloat(delayAttr) + ( ( parseFloat(containerInterval) + 100 ) * il ) ) ); 1253 1254 if (typeof containerSpeed_val !== 'undefined' ) { 1255 $span.setAttribute('data-speed', containerSpeed_val); 1256 } 1257 1258 classie.addClass($span, 'animate_when_parent_almost_visible'); 1259 classie.addClass($span, 'text-bottom-t-top'); 1260 1261 if ( is+1 === $spans.length && il+1 === $lines.length ) { 1262 classie.addClass($span, 'anim-tot-checker'); 1263 } 1264 } 1265 1266 } 1267 1268 } else if ( classie.hasClass($wrap, 'single-curtain') ) { 1269 1270 var $spans = $wrap.querySelectorAll('.split-char'); 1271 1272 for (var is = 0; is < $spans.length; is++) { 1273 var $span = $spans[is]; 1274 1275 $span.setAttribute('data-delay', ( parseFloat(delayAttr) + ( ( parseFloat(containerInterval) + 20 ) * is ) ) ); 1276 1277 if (typeof containerSpeed_val !== 'undefined' ) { 1278 $span.setAttribute('data-speed', containerSpeed_val); 1279 } 1280 1281 classie.addClass($span, 'animate_when_parent_almost_visible'); 1282 classie.addClass($span, 'text-bottom-t-top'); 1283 1284 if ( is+1 == $spans.length ) { 1285 classie.addClass($span, 'anim-tot-checker'); 1286 } 1287 }; 1288 1289 } else if ( classie.hasClass($wrap, 'typewriter') ) { 1290 1291 var $spans = $wrap.querySelectorAll('.split-char'); 1292 1293 for (var is = 0; is < $spans.length; is++) { 1294 var $span = $spans[is]; 1295 1296 $span.setAttribute('data-delay', ( parseFloat(delayAttr) + ( ( parseFloat(containerInterval) + 20 ) * is ) ) ); 1297 1298 if (typeof containerSpeed_val !== 'undefined' ) { 1299 $span.setAttribute('data-speed', containerSpeed_val); 1300 } 1301 1302 classie.addClass($span, 'animate_when_parent_almost_visible'); 1303 classie.addClass($span, 'typewriter'); 1304 1305 if ( is+1 == $spans.length ) { 1306 classie.addClass($span, 'anim-tot-checker'); 1307 } 1308 1309 } 1310 1311 } else if ( classie.hasClass($wrap, 'single-slide') ) { 1312 1313 var $spans = $wrap.querySelectorAll('.split-word-inner'); 1314 1315 for (var is = 0; is < $spans.length; is++) { 1316 var $span = $spans[is]; 1317 1318 $span.setAttribute('data-delay', ( parseFloat(delayAttr) + ( ( parseFloat(containerInterval) + 50 ) * is ) ) ); 1319 1320 if (typeof containerSpeed_val !== 'undefined' ) { 1321 $span.setAttribute('data-speed', containerSpeed_val); 1322 } 1323 1324 classie.addClass($span, 'animate_when_parent_almost_visible'); 1325 if ( classie.hasClass(document.body, 'rtl') ) { 1326 classie.addClass($span, 'text-left-t-right'); 1327 } else { 1328 classie.addClass($span, 'text-right-t-left'); 1329 } 1330 1331 if ( is+1 == $spans.length ) { 1332 classie.addClass($span, 'anim-tot-checker'); 1333 } 1334 } 1335 1336 } else if ( classie.hasClass($wrap, 'single-slide-opposite') ) { 1337 1338 var $spans = $wrap.querySelectorAll('.split-word-inner'); 1339 1340 for (var is = 0; is < $spans.length; is++) { 1341 var $span = $spans[is]; 1342 1343 $span.setAttribute('data-delay', ( parseFloat(delayAttr) + ( ( parseFloat(containerInterval) + 50 ) * is ) ) ); 1344 1345 if (typeof containerSpeed_val !== 'undefined' ) { 1346 $span.setAttribute('data-speed', containerSpeed_val); 1347 } 1348 1349 classie.addClass($span, 'animate_when_parent_almost_visible'); 1350 if ( classie.hasClass(document.body, 'rtl') ) { 1351 classie.addClass($span, 'text-left-t-right'); 1352 } else { 1353 classie.addClass($span, 'text-right-t-left'); 1354 } 1355 1356 if ( is+1 == $spans.length ) { 1357 classie.addClass($span, 'anim-tot-checker'); 1358 } 1359 } 1360 1361 } else if ( classie.hasClass($wrap, 'curtain-words') ) { 1362 1363 var $spans = $wrap.querySelectorAll('.split-word-inner'); 1364 1365 for (var is = 0; is < $spans.length; is++) { 1366 var $span = $spans[is]; 1367 1368 $span.setAttribute('data-delay', ( parseFloat(delayAttr) + ( ( parseFloat(containerInterval) + 50 ) * is ) ) ); 1369 1370 if (typeof containerSpeed_val !== 'undefined' ) { 1371 $span.setAttribute('data-speed', containerSpeed_val); 1372 } 1373 1374 classie.addClass($span, 'animate_when_parent_almost_visible'); 1375 classie.addClass($span, 'text-bottom-t-top'); 1376 1377 if ( is+1 == $spans.length ) { 1378 classie.addClass($span, 'anim-tot-checker'); 1379 } 1380 } 1381 } 1382 1383 } 1384 } 1385 1386 var removeOldLines = function(){ 1387 1388 for (var wrap_k = 0; wrap_k < $line_wraps.length; wrap_k++) { 1389 var $line_wrap = $line_wraps[wrap_k]; 1390 var $parent_wrap = $line_wrap.parentNode; 1391 while ( $line_wrap.firstChild ) { 1392 $parent_wrap.insertBefore($line_wrap.firstChild, $line_wrap); 1393 } 1394 $parent_wrap.removeChild($line_wrap); 1395 } 1396 1397 } 1398 1399 var createHighlightSpans = function(){ 1400 for (var high_k = 0; high_k < $text_highlight.length; high_k++) { 1401 var $highlight = $text_highlight[high_k], 1402 atts = $highlight.getAttribute('data-atts'), 1403 objAtts, 1404 styleEl = '', 1405 classEl = '', 1406 animation = false, 1407 hexRe = /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i, 1408 $h_words = $highlight.querySelectorAll('.split-word'); 1409 1410 if ( typeof atts !== 'undefined' && atts != '' ) { 1411 objAtts = JSON.parse(atts); 1412 if ( typeof objAtts.bg != 'undefined' ) { 1413 if ( hexRe.test(objAtts.bg)) { 1414 styleEl += 'background-color:' + objAtts.bg + ';'; 1415 } else { 1416 classEl += ' ' + objAtts.bg; 1417 } 1418 } 1419 if ( typeof objAtts.color != 'undefined' ) { 1420 if ( hexRe.test(objAtts.color)) { 1421 styleEl += 'color:' + objAtts.color + ';'; 1422 } else {
1423 var classChild = objAtts.color; 1424 } 1425 } 1426 if ( typeof objAtts.height != 'undefined' ) { 1427 styleEl += 'height:' + objAtts.height + ';'; 1428 } 1429 if ( typeof objAtts.offset != 'undefined' ) { 1430 styleEl += 'bottom:' + objAtts.offset + ';'; 1431 } 1432 if ( typeof objAtts.opacity != 'undefined' ) { 1433 styleEl += 'opacity:' + objAtts.opacity + ';'; 1434 } 1435 if ( objAtts.animated == 'yes' ) { 1436 animation = true; 1437 } 1438 1439 } 1440 1441 for (var h_words_k = 0; h_words_k < $h_words.length; h_words_k++) { 1442 var $word = $h_words[h_words_k], 1443 $new_el = document.createElement('span'); 1444 1445 if ( typeof classChild !== 'undefined' ) { 1446 classie.addClass($word, objAtts.color); 1447 } 1448 1449 if ( h_words_k === 0 ) { 1450 classie.addClass($word, 'first-highlight'); 1451 } else if ( (h_words_k+1) === $h_words.length ) { 1452 classie.addClass($word, 'last-highlight'); 1453 } 1454 1455 $new_el.className = 'heading-text-highlight-inner' + classEl; 1456 if ( styleEl !== '' ) { 1457 $new_el.setAttribute('style', styleEl); 1458 } 1459 1460 if ( animation ) { 1461 $new_el.setAttribute('data-animated', 'yes'); 1462 } 1463 1464 $word.appendChild($new_el); 1465 1466 }; 1467 1468 var $parent_highlight = $highlight.parentNode; 1469 while ( $highlight.firstChild ) { 1470 $parent_highlight.insertBefore($highlight.firstChild, $highlight); 1471 } 1472 $parent_highlight.removeChild($highlight); 1473 1474 } 1475 1476 } 1477 1478 var createNewLines = function(){ 1479 for (var word_k = 0; word_k < $words.length; word_k++) { 1480 var $word = $words[word_k], 1481 top = $word.offsetTop, 1482 elH = $word.offsetHeight, 1483 $next = typeof $words[(word_k+1)] !== 'undefined' ? $words[(word_k+1)] : null, 1484 nextTop = $next !== null ? $next.offsetTop : null; 1485 1486 if (lineStart) { 1487 lineArray[lineIndex] = [word_k]; 1488 1489 if (nextTop !== null && nextTop > (top + elH/2)) { 1490 lineArray[lineIndex].push(word_k); 1491 lineIndex++; 1492 lineStart = true; 1493 } else { 1494 lineStart = false;
1495 } 1496 } else { 1497 if (nextTop !== null && nextTop > (top + elH/2)) {//tollerance 1498 lineArray[lineIndex].push(word_k); 1499 lineIndex++; 1500 lineStart = true; 1501 } else if ( nextTop === null ) { 1502 lineArray[lineIndex].push(word_k); 1503 } 1504 } 1505 } 1506 1507 for (var i = 0; i < lineArray.length; i++) { 1508 var start = lineArray[i][0], 1509 end = lineArray[i][1] + 1; 1510 1511 var spanWrap = document.createElement('span'); 1512 spanWrap.className = 'heading-line-wrap'; 1513 1514 if (!end) { 1515 window.wrap(spanWrap, $words[start]); 1516 } else { 1517 for (var _i = start; _i < end; _i++) { 1518 if ( typeof $words[_i] !== 'undefined' && $words[_i] !== null ) { 1519 classie.addClass($words[_i], 'heading-temp'); 1520 $words[_i].style.zIndex = end - _i; 1521 } 1522 } 1523 var $towrap = $heading.querySelectorAll('.heading-temp'); 1524 if ( typeof $towrap[0] !== 'undefined' && $towrap[0] !== null ) { 1525 window.wrapAll(spanWrap, $towrap); 1526 for (var _i = 0; _i < $towrap.length; _i++) { 1527 classie.removeClass($towrap[_i], 'heading-temp'); 1528 } 1529 } 1530 } 1531 1532 if ( (i+1) == lineArray.length ) { 1533 classie.addClass($row, 'loaded-split-word'); 1534 } 1535 1536 classie.addClass($heading, 'heading-lined'); 1537 } 1538 lettering(); 1539 1540 } 1541 1542 removeOldLines(); 1543 createHighlightSpans(); 1544 createNewLines(); 1545 1546 $parent_el.addEventListener("owl-carousel-changed", function() { 1547 removeOldLines(); 1548 createHighlightSpans(); 1549 createNewLines(); 1550 }); 1551 1552 if ( event !== 'resize' ) { 1553 document.body.dispatchEvent(new CustomEvent('uncode_waypoints')); 1554 } 1555 1556 } 1557 } 1558 1559 var $h_markup = document.body.querySelectorAll('.font-obs'), 1560 fontArr = new Array(); 1561 1562 for (var i = 0; i < $h_markup.length; i++) { 1563 var font_to_check = $h_markup[i].getAttribute("data-font"); 1564 1565 if ( font_to_check === null ) { 1566 word_for_lines(false, el); 1567 } else { 1568 var font_weight = $h_markup[i].getAttribute("data-weight"); 1569 var font_style = $h_markup[i].getAttribute("data-style"); 1570 1571 if ( font_weight === null ) { 1572 font_weight = 'normal'; 1573 } 1574 1575 if ( font_style === null ) { 1576 font_style = 'normal'; 1577 } 1578 1579 font_to_check = font_to_check.split(','); 1580 1581 var font_val = font_to_check[0].replace(/['"]+/g, ''), 1582 font_key = '\''+font_val+'_'+font_weight+'_'+font_style+'\''; 1583 1584 if ( fontArr.indexOf( font_val+'_'+font_weight ) === -1 ) { 1585 fontArr[font_key] = {'family':font_val,'weight':font_weight,'style':font_style }; 1586 } 1587 } 1588 } 1589 1590 var counter = 0; 1591 1592 for (var key in fontArr) { 1593 if (fontArr.hasOwnProperty(key)) { 1594 var font = new FontFaceObserver(fontArr[key].family, { weight: fontArr[key].weight, style: fontArr[key].style } ); 1595 1596 font.load(null, 10000).then(function (font) { 1597 counter++; 1598 if ( counter == Object.keys(fontArr).length ) { 1599 already_font = true; 1600 requestTimeout(function(){ 1601 word_for_lines(false, el); 1602 }, 10); 1603 } 1604 }, function (error) { 1605 word_for_lines(false, el); 1606 }); 1607 } 1608 } 1609 1610 el.addEventListener("owl-carousel-initialized", function() { 1611 word_for_lines("owl-carousel-initialized", el); 1612 }); 1613 1614 el.addEventListener("vc-shortcodeView-updated", function() { 1615 word_for_lines(false, el); 1616 }); 1617 1618 window.addEventListener("resize", function() { 1619 if ( wwidth != wrapLinesWw ) { 1620 clearRequestTimeout(setWrap); 1621 setWrap = requestTimeout( function(){ 1622 wrapLinesWw = wwidth; 1623 word_for_lines('resize'); 1624 }, 100 ); 1625 } 1626 }); 1627 1628 scrollFunction(); 1629 1630 if ( uaInfo.is('chrome') ) { 1631 1632 var videos = document.querySelectorAll('.wp-video-shortcode'); 1633 for (var i = 0; i < videos.length; i++) { 1634 var video = videos[i]; 1635 if ( typeof video.getAttribute('autoplay') !== 'undefined' && video.getAttribute('autoplay') !== null && ( typeof video.getAttribute('muted') === 'undefined' || video.getAttribute('muted') === null ) ) { 1636 video.oncanplay = function(e) { 1637 video.muted = true; 1638 video.play(); 1639 }; 1640 break; 1641 } 1642 } 1643 1644 } 1645 }, 1646 setRowHeight = function(container, forced, resized) { 1647 var currentTallest = 0, 1648 percentHeight = 0, 1649 minHeight = 0, 1650 el, 1651 child, 1652 hasSubCols = false;
1653 if (container.length == undefined) { 1654 container = [container]; 1655 } 1656 // Loop for each container element to match their heights 1657 for (var i = 0; i < container.length; i++) { 1658 var el = container[i], 1659 $row = el, 1660 totalHeight = 0, 1661 colsArray = new Array(), 1662 calculatePadding = 0, 1663 $rowParent = $row.parentNode, 1664 isHeader = false, 1665 isFirst = false; 1666 $row.oversized = false; 1667 percentHeight = el.getAttribute("data-height-ratio"); 1668 minHeight = el.getAttribute("data-minheight"); 1669 child = (el.firstElementChild || el.firstChild); 1670 var childHeight = outerHeight(child); 1671 /** window height without header **/ 1672 if (!!percentHeight || !!minHeight || forced || (isIE && classie.hasClass(el, 'unequal')) ) { 1673 child.style.height = ''; 1674 if (!!percentHeight) { 1675 if (percentHeight == 'full') { 1676 currentTallest = parseInt(wheight); 1677 } else { 1678 currentTallest = parseInt((wheight * percentHeight) / 100); 1679 } 1680 } else { 1681 currentTallest = el.clientHeight; 1682 } 1683 1684 if (!!minHeight) { 1685 if (currentTallest < minHeight || currentTallest == undefined) currentTallest = parseInt(minHeight); 1686 } 1687 1688 if (getClosest(el, 'header-uncode-block') != null) { 1689 el.setAttribute('data-row-header', 'true'); 1690 isHeader = true; 1691 } else { 1692 if (pageHeader == null) { 1693 var prevRow = $rowParent.previousSibling; 1694 if (prevRow != null && prevRow.innerText == 'UNCODE.initHeader();') { 1695 isFirst = true; 1696 } 1697 } 1698 } 1699 1700 if (classie.hasClass(el, 'row-slider')) { 1701 percentHeight = el.getAttribute("data-height-ratio"); 1702 minHeight = el.getAttribute("data-minheight"); 1703 if (percentHeight == 'full') { 1704 currentTallest = parseInt(wheight); 1705 } else { 1706 currentTallest = parseInt((wheight * percentHeight) / 100); 1707 } 1708 1709 var computedStyleRow = getComputedStyle(el), 1710 computedStyleRowParent = getComputedStyle($rowParent); 1711 calculatePadding -= (parseFloat(computedStyleRow.paddingTop) + parseFloat(computedStyleRowParent.paddingTop)); 1712 calculatePadding -= (parseFloat(computedStyleRow.paddingBottom) + parseFloat(computedStyleRowParent.paddingBottom)); 1713 1714 if (isHeader || isFirst) { 1715 if (isMobileTransparent || wwidth > mediaQuery) currentTallest -= menuHeight - transmenuHeight; 1716 else currentTallest -= menuHeight - secmenuHeight; 1717 currentTallest += calculatePadding; 1718 } else { 1719 if (isMobileTransparent || wwidth > mediaQuery) currentTallest += calculatePadding; 1720 else currentTallest = 'auto'; 1721 } 1722 1723 getDivChildren(el, '.owl-carousel', function(owl, i) { 1724 owl.style.height = (currentTallest == 'auto' ? 'auto' : currentTallest + 'px'); 1725 if (isIE) { 1726 getDivChildren(owl, '.owl-stage', function(owlIn, i) { 1727 owlIn.style.height = (currentTallest == 'auto' ? '100%' : currentTallest + 'px'); 1728 }); 1729 } 1730 }); 1731 if ( UNCODE.isFullPageSnap || classie.hasClass(masthead, 'menu-transparent') ) 1732 continue; 1733 else { 1734 if ( classie.hasClass(document.body, 'uncode-fp-menu-hide') ) { 1735 $rowParent.parentNode.style.paddingTop = menuHeight + 'px'; 1736 } 1737 } 1738 } else { 1739 if (isHeader || isFirst || UNCODE.isFullPage ) { 1740 if ( !( UNCODE.isFullPage && !classie.hasClass(masthead, 'menu-transparent') && classie.hasClass(document.body, 'uncode-fp-menu-hide') && !isHeader && !isFirst ) ) { 1741 if (isMobileTransparent || wwidth > mediaQuery) currentTallest -= menuHeight - transmenuHeight; 1742 else currentTallest -= menuHeight - secmenuHeight; 1743 } 1744 if ( UNCODE.isFullPage && classie.hasClass(document.body, 'uncode-scroll-safe-padding') && classie.hasClass(masthead, 'menu-transparent') && !classie.hasClass(document.body, 'uncode-fp-menu-hide') ) { 1745 var safeMenuHeight = parseFloat(document.body.getAttribute("data-additional-padding")) + parseFloat(menuHeight); 1746 if ( (" " + child.parentNode.className + " ").replace(/[\n\t]/g, " ").indexOf("-top-padding ") < 0 || classie.hasClass(child.parentNode, 'single-top-padding') ) { 1747 classie.addClass(child.parentNode, 'fp-safe-padding-top'); 1748 child.parentNode.style.paddingTop = safeMenuHeight + 'px'; 1749 } 1750 if ( (" " + child.parentNode.className + " ").replace(/[\n\t]/g, " ").indexOf("-bottom-padding ") < 0 || classie.hasClass(child.parentNode, 'single-bottom-padding') ) { 1751 classie.addClass(child.parentNode, 'fp-safe-padding-bottom'); 1752 child.parentNode.style.paddingBottom = safeMenuHeight + 'px'; 1753 } 1754 } 1755 if ( !classie.hasClass(masthead, 'menu-transparent') && classie.hasClass(document.body, 'uncode-fp-menu-hide') && ( isFirst || isHeader ) ) 1756 $rowParent.parentNode.style.paddingTop = menuHeight + 'px'; 1757 1758 var computedStyleRow = getComputedStyle(el), 1759 computedStyleRowParent = getComputedStyle($rowParent); 1760 calculatePadding -= (parseFloat(computedStyleRow.paddingTop) + parseFloat(computedStyleRowParent.paddingTop)); 1761 calculatePadding -= (parseFloat(computedStyleRow.paddingBottom) + parseFloat(computedStyleRowParent.paddingBottom)); 1762 1763 currentTallest += calculatePadding; 1764 1765 } else { 1766 1767 var computedStyleRow = getComputedStyle(el), 1768 computedStyleRowParent = getComputedStyle($rowParent); 1769 calculatePadding -= (parseFloat(computedStyleRow.paddingTop) + parseFloat(computedStyleRowParent.paddingTop)); 1770 calculatePadding -= (parseFloat(computedStyleRow.paddingBottom) + parseFloat(computedStyleRowParent.paddingBottom)); 1771 1772 if (wwidth > mediaQuery) currentTallest += calculatePadding; 1773 else currentTallest = 'auto'; 1774 1775 } 1776 } 1777 if ( UNCODE.isFullPage ) { 1778 currentTallest -= UNCODE.adminBarHeight; 1779 } 1780 if (!!minHeight) { 1781 if (currentTallest < minHeight || currentTallest == 'auto') currentTallest = parseInt(minHeight); 1782 } 1783 1784 child.style.height = (currentTallest == 'auto' ? 'auto' : currentTallest + 'px'); 1785 } else { 1786 currentTallest = 0; 1787 if ( UNCODE.isFrontEndEditor && child !== null ) { 1788 1789 child.style.height = ''; 1790 1791 getDivChildren(el, '.owl-carousel', function(owl, i) { 1792 owl.style.height = ''; 1793 if (isIE) { 1794 getDivChildren(owl, '.owl-stage', function(owlIn, i) { 1795 owlIn.style.height = ''; 1796 }); 1797 } 1798 }); 1799 } 1800 } 1801 1802 if (wwidth > mediaQuery) { 1803 1804 getDivChildren(el, '.column_parent', function(col, i, total) { 1805 var $col = col, 1806 $colHeight = 0, 1807 $colDiff = 0, 1808 $colPercDiff = 100; 1809 $col.oversized = false;
1810 $col.forceHeight = currentTallest; 1811 currentTallest = child.clientHeight; 1812 if ((isHeader || isFirst) && currentTallest != 'auto') currentTallest -= transmenuHeight; 1813 var getFirstCol = null, 1814 getMargin = 0, 1815 getSubMargin = 0; 1816 getDivChildren(col, '.row-child', function(obj, i, total) { 1817 var $colChild = obj, 1818 $colParent = $colChild.parentNode, 1819 computedStyleCol = getComputedStyle($colParent); 1820 parseFloat(computedStyleCol.marginTop); 1821 getSubMargin += parseFloat(computedStyleCol.marginTop); 1822 }); 1823 currentTallest += getSubMargin; 1824 getDivChildren(col, '.row-child', function(obj, i, total) { 1825 var $colChild = obj, 1826 $colInner, 1827 $colParent = $colChild.parentNode, 1828 $uncont = $colParent.parentNode; 1829 for (var it = 0; it < $colChild.childNodes.length; it++) { 1830 if ( ! classie.hasClass($colChild.childNodes[it], 'uncode-divider-wrap') ) { 1831 $colInner = $colChild.childNodes[it]; 1832 break; 1833 } 1834 } 1835 if (i == 0 && total > 1) getFirstCol = $colInner; 1836 $colChild.oversized = false; 1837 percentHeight = $colChild.getAttribute("data-height"); 1838 minHeight = $colChild.getAttribute("data-minheight"); 1839 if (percentHeight != null || minHeight != null) { 1840 if ( ! classie.hasClass($colInner, 'uncode-divider-wrap') ) 1841 $colInner.style.height = ''; 1842 $colParent.style.height = 'auto'; 1843 $uncont.style.height = '100%'; 1844 $colChild.removeAttribute("style"); 1845 var newHeight = (percentHeight != null) ? Math.ceil((currentTallest) * (percentHeight / 100)) : parseInt(minHeight); 1846 var computedStyleCol = getComputedStyle($colParent); 1847 getMargin = parseFloat(computedStyleCol.marginTop); 1848 newHeight -= (getMargin); 1849 $colPercDiff -= (percentHeight != null) ? percentHeight : 0; 1850 if (currentTallest > newHeight) { 1851 var getColHeight = outerHeight($colChild); 1852 if (getColHeight > newHeight) { 1853 $colHeight += getColHeight; 1854 $colDiff += getColHeight; 1855 $colChild.oversized = true; 1856 $col.oversized = true; 1857 $row.oversized = true; 1858 } else { 1859 $colHeight += newHeight; 1860 if ( ! classie.hasClass($colInner, 'uncode-divider-wrap') ) 1861 $colInner.style.height = newHeight + 'px'; 1862 } 1863 } 1864 } else { 1865 $colHeight += outerHeight($colChild); 1866 } 1867 }); 1868 if (getFirstCol != null) { 1869 getFirstCol.style.height = (parseFloat(getFirstCol.style.height) - getMargin) + 'px'; 1870 } 1871 colsArray.push({ 1872 colHeight: $colHeight, 1873 colDiv: $col 1874 }); 1875 $col.colDiff = $colDiff; 1876 $col.colPercDiff = $colPercDiff; 1877 }); 1878 1879 if ($row.oversized) { 1880 child.style.height = ''; 1881 colsArray.sort(function(a, b) { 1882 if (a.colHeight < b.colHeight) return 1; 1883 if (a.colHeight > b.colHeight) return -1; 1884 return 0; 1885 }); 1886 var $totalHeight = 0; 1887 colsArray.forEach(function(col) { 1888 var $col = col.colDiv, 1889 $colHeight = col.colHeight; 1890 getDivChildren($col, '.row-child', function(obj, i, total) { 1891 var $colChild = obj, 1892 $colInner = $colChild.children[0], 1893 percentHeight = $colChild.getAttribute("data-height"), 1894 $colParent = $colChild.parentNode, 1895 $uncont = $colParent.parentNode, 1896 newHeight; 1897 1898 $colHeight = $col.forceHeight - $col.colDiff; 1899 if (percentHeight != null) { 1900 if ($colHeight > 0) { 1901 if ($col.oversized) { 1902 if (!$colChild.oversized) { 1903 newHeight = Math.ceil(($colHeight) * (percentHeight / $col.colPercDiff)); 1904 if (i == total - 1 && total > 1) { 1905 $uncont.style.height = 'auto'; 1906 $colChild.style.display = 'none'; 1907 newHeight = outerHeight($col.parentNode) - outerHeight($uncont); 1908 $uncont.style.height = '100%'; 1909 $colChild.style.display = 'table'; 1910 } 1911 if (newHeight == 0) newHeight = Math.ceil(($col.forceHeight) * (percentHeight / 100)); 1912 $colInner.style.height = newHeight + 'px'; 1913 } 1914 } else {
1915 if ($totalHeight == 0) newHeight = Math.ceil(($colHeight) * (percentHeight / $col.colPercDiff)); 1916 else { 1917 newHeight = Math.ceil(($totalHeight) * (percentHeight / $col.colPercDiff)); 1918 } 1919 if (i == total - 1 && total > 1) { 1920 $uncont.style.height = 'auto'; 1921 $colChild.style.display = 'none'; 1922 newHeight = outerHeight($col.parentNode) - outerHeight($uncont); 1923 $uncont.style.height = '100%'; 1924 $colChild.style.display = 'table'; 1925 } 1926 $colInner.style.height = newHeight + 'px'; 1927 } 1928 } else { 1929 if ($colChild.oversized) { 1930 if ($totalHeight == 0) newHeight = Math.ceil(($colHeight) * (percentHeight / $col.colPercDiff)); 1931 else { 1932 if ($col.colPercDiff == 0) $col.colPercDiff = 100; 1933 newHeight = Math.ceil(($totalHeight) * (percentHeight / $col.colPercDiff)); 1934 } 1935 if (i == total - 1 && total > 1) { 1936 $uncont.style.height = 'auto'; 1937 $colChild.style.display = 'none'; 1938 newHeight = outerHeight($col.parentNode) - outerHeight($uncont); 1939 $uncont.style.height = '100%'; 1940 $colChild.style.display = 'table'; 1941 } 1942 $colInner.style.height = newHeight + 'px'; 1943 } 1944 } 1945 } 1946 }); 1947 var uncell = $col.getElementsByClassName('uncell'); 1948 if (uncell[0] != undefined && $totalHeight == 0) $totalHeight = outerHeight(uncell[0]); 1949 }); 1950 } 1951 if (isFF) { 1952 getDivChildren(el, '.uncoltable', function(col, i, total) { 1953 if (col.style.minHeight != '') { 1954 col.style.height = ''; 1955 } 1956 }); 1957 } 1958 if (resized) { 1959 getDivChildren(el, '.row-child > .row-inner', function(obj, k, total) { 1960 if (obj.style.height == '') { 1961 if (wwidth > mediaQueryMobile) { 1962 var getStyle = (window.getComputedStyle((obj.parentNode), null)), 1963 getInnerHeight = (parseInt(obj.parentNode.clientHeight) - parseInt(getStyle.paddingTop) - parseInt(getStyle.paddingBottom)); 1964 obj.style.height = getInnerHeight + 'px'; 1965 //obj.style.marginBottom = '-1px'; 1966 } 1967 } 1968 }); 1969 getDivChildren(el, '.row-parent > .row-inner', function(obj, k, total) { 1970 if (obj.style.height != '') { 1971 var getStyle = (window.getComputedStyle((obj.parentNode), null)), 1972 getInnerHeight = (parseInt(obj.parentNode.clientHeight) - parseInt(getStyle.paddingTop) - parseInt(getStyle.paddingBottom)), 1973 getTempHeight = parseInt(obj.style.height); 1974 if (getInnerHeight > getTempHeight) { 1975 obj.style.height = getInnerHeight + 'px'; 1976 //obj.style.marginBottom = '-1px'; 1977 } 1978 } 1979 }); 1980 } 1981 } else { 1982 if (isFF) { 1983 getDivChildren(el, '.uncoltable', function(col, i, total) { 1984 if (col.style.minHeight != '') { 1985 col.style.height = ''; 1986 col.style.height = outerHeight(col.parentNode) + 'px'; 1987 } 1988 }); 1989 } 1990 if (isIE && (wwidth > mediaQueryMobile)) { 1991 if (child.style.height == 'auto') { 1992 child.style.height = outerHeight(child) + 'px'; 1993 } 1994 } 1995 } 1996 if (isFF) { 1997 var sliderColumnFix = document.querySelector('.uncode-slider .row-inner > .column_child:only-child'); 1998 if (sliderColumnFix != null) { 1999 if (wwidth > mediaQuery) { 2000 sliderColumnFix.style.setProperty("height", ""); 2001 } else { 2002 sliderColumnFix.style.setProperty("height", ""); 2003 sliderColumnFix.style.setProperty("height", outerHeight(sliderColumnFix.parentNode) + "px", "important"); 2004 } 2005 } 2006 } 2007 }; 2008 window.scroll(0, scrollRowHeight_fix); 2009 }, 2010 headerHeight = function(container) { 2011 forEachElement(container, function(el, i) { 2012 var getHeight = el.getAttribute("data-height"), 2013 newHeight = ((wheight * getHeight) / 100); 2014 if (getHeight != 'fixed' && newHeight != 0) { 2015 if (isMobileTransparent || wwidth > mediaQuery) newHeight -= menuHeight - transmenuHeight; 2016 else newHeight -= menuHeight - secmenuHeight; 2017 el.style.height = newHeight + 'px'; 2018 } 2019 }); 2020 if (masthead != undefined) { 2021 masthead.parentNode.style.height = menuHeight + 'px'; 2022 if (header != undefined && header.length) { 2023 if (classie.hasClass(masthead, 'menu-transparent')) {
2024 if (isMobileTransparent || wwidth > mediaQuery) { 2025 masthead.parentNode.style.height = '0px'; 2026 if (classie.hasClass(masthead, 'menu-add-padding')) { 2027 for (var j = 0; j < header.length; j++) { 2028 var headerel = header[j]; 2029 var headerBlock = getClosest(headerel, 'header-uncode-block'); 2030 if (headerBlock != null) { 2031 var innerRows = headerel.querySelectorAll('.column_parent > .uncol > .uncoltable > .uncell > .uncont, .uncode-slider .column_child > .uncol > .uncoltable > .uncell > .uncont'); 2032 for (var k = 0; k < innerRows.length; k++) { 2033 if (innerRows[k] != undefined) { 2034 if (wwidth > mediaQuery) innerRows[k].style.paddingTop = transmenuHeight + 'px'; 2035 else innerRows[k].style.paddingTop = (transmenuHeight - mastheadMobilePaddingTop) + 'px'; 2036 } 2037 } 2038 } else { 2039 getDivChildren(headerel, '.header-content', function(headerContent, i) { 2040 if (wwidth > mediaQuery) headerContent.style.paddingTop = transmenuHeight + 'px'; 2041 else headerContent.style.paddingTop = (transmenuHeight - mastheadMobilePaddingTop) + 'px'; 2042 }); 2043 } 2044 } 2045 } 2046 } 2047 } 2048 } 2049 } 2050 }, 2051 initVideoComponent = function(container, classTarget) { 2052 if ( UNCODE.isFrontEndEditor ) 2053 return; 2054 getDivChildren(container, classTarget, function(el, i) { 2055 var width = outerWidth(el), 2056 pWidth, // player width, to be defined 2057 height = outerHeight(el), 2058 pHeight, // player height, tbd 2059 $tubularPlayer = (el.getElementsByTagName('iframe').length == 1) ? el.getElementsByTagName('iframe') : el.getElementsByTagName('video'), 2060 ratio = (el.getAttribute("data-ratio") != null) ? Number(el.getAttribute("data-ratio")) : typeof $tubularPlayer[0] !== 'undefined' ? $tubularPlayer[0].getAttribute("data-ratio") : '1.8', 2061 heightOffset = 80, 2062 widthOffset = heightOffset * ratio; 2063 // when screen aspect ratio differs from video, video must center and underlay one dimension 2064 if ($tubularPlayer[0] != undefined) { 2065 if (width / ratio < height) { // if new video height < window height (gap underneath) 2066 pWidth = Math.ceil((height + heightOffset) * ratio); // get new player width 2067 $tubularPlayer[0].style.width = pWidth + widthOffset + 'px'; 2068 $tubularPlayer[0].style.height = height + heightOffset + 'px'; 2069 $tubularPlayer[0].style.left = ((width - pWidth) / 2) - (widthOffset / 2) + 'px'; 2070 $tubularPlayer[0].style.top = '-' + (heightOffset / 2) + 'px'; 2071 $tubularPlayer[0].style.position = 'absolute'; 2072 } else { // new video width < window width (gap to right) 2073 pHeight = Math.ceil(width / ratio); // get new player height 2074 $tubularPlayer[0].style.width = width + widthOffset + 'px'; 2075 $tubularPlayer[0].style.height = pHeight + heightOffset + 'px'; 2076 $tubularPlayer[0].style.left = '-' + (widthOffset / 2) + 'px'; 2077 $tubularPlayer[0].style.top = ((height - pHeight) / 2) - (heightOffset / 2) + 'px'; 2078 $tubularPlayer[0].style.position = 'absolute'; 2079 } 2080 } 2081 }); 2082 }, 2083 init_overlay = function() { 2084 if ( UNCODE.isFrontEndEditor ) 2085 return; 2086 var triggerButton, 2087 closeButtons = new Array(); 2088 function toggleOverlay(btn) { 2089 Array.prototype.forEach.call(document.querySelectorAll('div.overlay'), function(overlay) { 2090 if (btn.getAttribute('data-area') == overlay.getAttribute('data-area')) { 2091 var container = document.querySelector('div.' + btn.getAttribute('data-container')), 2092 inputField = overlay.querySelector('.search-field'); 2093 if (classie.has(overlay, 'open')) { 2094 window.dispatchEvent(menuClose); 2095 overlayOpened = false; 2096 classie.remove(overlay, 'open'); 2097 classie.remove(container, 'overlay-open'); 2098 classie.add(overlay, 'close'); 2099 classie.remove(overlay, 'open-items'); 2100 var onEndTransitionFn = function(ev) { 2101 if (transitionEvent) { 2102 if (ev.propertyName !== 'visibility') return; 2103 this.removeEventListener(transitionEvent, onEndTransitionFn); 2104 } 2105 classie.remove(overlay, 'close'); 2106 }; 2107 if (transitionEvent) { 2108 overlay.addEventListener(transitionEvent, onEndTransitionFn); 2109 } else { 2110 onEndTransitionFn(); 2111 } 2112 } else if (!classie.has(overlay, 'close')) { 2113 window.dispatchEvent(menuOpen); 2114 overlayOpened = true; 2115 classie.add(overlay, 'open'); 2116 classie.add(container, 'overlay-open'); 2117 if (jQuery('body.menu-overlay').length == 0) { 2118 setTimeout(function() { 2119 inputField.focus(); 2120 }, 1000); 2121 } 2122 setTimeout(function() { 2123 if (classie.has(overlay, 'overlay-sequential')) classie.add(overlay, 'open-items'); 2124 }, 800); 2125 } 2126 } 2127 }); 2128 2129 if (classie.hasClass(btn, 'search-icon') || classie.hasClass(btn, 'menu-close-search')) return; 2130 2131 if (classie.hasClass(triggerButton, 'close')) { 2132 UNCODE.menuOpened = false;
2133 classie.removeClass(triggerButton, 'close'); 2134 classie.addClass(triggerButton, 'closing'); 2135 Array.prototype.forEach.call(closeButtons, function(closeButton) { 2136 if (!classie.hasClass(closeButton, 'menu-close-search')) { 2137 classie.removeClass(closeButton, 'close'); 2138 classie.addClass(closeButton, 'closing'); 2139 } 2140 }); 2141 setTimeout(function() { 2142 classie.removeClass(triggerButton, 'closing'); 2143 triggerButton.style.opacity = 1; 2144 Array.prototype.forEach.call(closeButtons, function(closeButton) { 2145 if (!classie.hasClass(closeButton, 'menu-close-search')) { 2146 classie.removeClass(closeButton, 'closing'); 2147 closeButton.style.opacity = 0; 2148 } 2149 }); 2150 }, 800); 2151 } else { 2152 UNCODE.menuOpened = true; 2153 triggerButton.style.opacity = 0; 2154 var getBtnRect = !classie.hasClass(triggerButton, 'search-icon') ? triggerButton.getBoundingClientRect() : null; 2155 Array.prototype.forEach.call(closeButtons, function(closeButton) { 2156 if (!classie.hasClass(closeButton, 'menu-close-search')) { 2157 classie.addClass(triggerButton, 'close'); 2158 if (getBtnRect != null) closeButton.setAttribute('style', 'top:' + getBtnRect.top + 'px; left:'+ getBtnRect.left + 'px !important'); 2159 classie.addClass(closeButton, 'close'); 2160 closeButton.style.opacity = 1; 2161 } 2162 }); 2163 window.addEventListener("resize", function() { 2164 positionCloseBtn(triggerButton, closeButtons); 2165 }); 2166 } 2167 } 2168 function positionCloseBtn(triggerButton, closeButtons){ 2169 var getBtnRect = !classie.hasClass(triggerButton, 'search-icon') ? triggerButton.getBoundingClientRect() : null; 2170 Array.prototype.forEach.call(closeButtons, function(closeButton) { 2171 if (!classie.hasClass(closeButton, 'menu-close-search')) { 2172 if (getBtnRect != null) closeButton.setAttribute('style', 'top:' + getBtnRect.top + 'px; left:'+ getBtnRect.left + 'px !important'); 2173 closeButton.style.opacity = 1; 2174 } 2175 }); 2176 } 2177 (function bindEscape() { 2178 document.onkeydown = function(evt) { 2179 evt = evt || window.event; 2180 var isEscape = false;
2181 if ("key" in evt) { 2182 isEscape = (evt.key == "Escape" || evt.key == "Esc"); 2183 } else { 2184 isEscape = (evt.keyCode == 27); 2185 } 2186 if (isEscape && overlayOpened) { 2187 Array.prototype.forEach.call(closeButtons, function(closeButton) { 2188 if (classie.hasClass(closeButton, 'overlay-close') && classie.hasClass(closeButton, 'menu-button-overlay')) { 2189 closeButton.click(); 2190 } 2191 }); 2192 } 2193 }; 2194 })(); 2195 Array.prototype.forEach.call(document.querySelectorAll('.trigger-overlay'), function(triggerBttn) { 2196 if (UNCODE.menuOpened) return; 2197 triggerBttn.addEventListener('click', function(e) { 2198 triggerButton = e.currentTarget; 2199 if (wwidth < mediaQuery && classie.hasClass(triggerButton, 'search-icon')) { 2200 return true; 2201 } else { 2202 e.stopPropagation(); 2203 if (wwidth > mediaQuery) toggleOverlay(triggerButton); 2204 else { 2205 if (classie.addClass(triggerButton, 'search-icon')) return true; 2206 } 2207 e.preventDefault(); 2208 return false; 2209 } 2210 }, false); 2211 }); 2212 Array.prototype.forEach.call(document.querySelectorAll('.overlay-close'), function(closeBttn) { 2213 closeButtons.push(closeBttn); 2214 closeBttn.addEventListener('click', function(e) { 2215 if (wwidth > mediaQuery) toggleOverlay(closeBttn); 2216 e.preventDefault(); 2217 return false; 2218 }, false); 2219 }); 2220 }, 2221 /** All scrolling functions - Begin */ 2222 /** Shrink menu **/ 2223 shrinkMenu = function(bodyTop) { 2224 if ( UNCODE.isFrontEndEditor ) 2225 return; 2226 var logoShrink, 2227 offset = 100; 2228 for (var i = 0; i < logoel.length; i++) { 2229 if (((secmenuHeight == 0) ? bodyTop > menuHeight : bodyTop > secmenuHeight + offset) && !classie.hasClass(logoel[i], 'shrinked') && (wwidth > mediaQuery)) { 2230 classie.addClass(logoel[i], 'shrinked'); 2231 if (logoMinScale != undefined) { 2232 logoShrink = logolink.children; 2233 Array.prototype.forEach.call(logoShrink, function(singleLogo) { 2234 singleLogo.style.height = logoMinScale + 'px'; 2235 singleLogo.style.lineHeight = logoMinScale + 'px'; 2236 if (classie.hasClass(singleLogo, 'text-logo')) singleLogo.style.fontSize = logoMinScale + 'px'; 2237 }); 2238 } 2239 setTimeout(function() { 2240 calculateMenuHeight(false); 2241 //window.dispatchEvent(new Event('resize')); 2242 }, 300); 2243 } else if ((((secmenuHeight == 0) ? bodyTop == 0 : bodyTop <= secmenuHeight + offset) || (wwidth < mediaQuery)) && classie.hasClass(logoel[i], 'shrinked')) { 2244 classie.removeClass(logoel[i], 'shrinked'); 2245 if (logoMinScale != undefined) { 2246 logoShrink = logolink.children; 2247 Array.prototype.forEach.call(logoShrink, function(singleLogo) { 2248 singleLogo.style.height = singleLogo.getAttribute('data-maxheight') + 'px'; 2249 singleLogo.style.lineHeight = singleLogo.getAttribute('data-maxheight') + 'px'; 2250 if (classie.hasClass(singleLogo, 'text-logo')) singleLogo.style.fontSize = singleLogo.getAttribute('data-maxheight') + 'px'; 2251 }); 2252 } 2253 setTimeout(function() { 2254 calculateMenuHeight(false); 2255 //window.dispatchEvent(new Event('resize')); 2256 }, 300); 2257 } 2258 } 2259 }, 2260 /** Switch colors menu **/ 2261 switchColorsMenu = function(bodyTop, style) { 2262 for (var i = 0; i < transmenuel.length; i++) { 2263 if (masthead.style.opacity !== 1) masthead.style.opacity = 1; 2264 if ((secmenuHeight == 0) ? bodyTop > menuHeight / 2 : bodyTop > secmenuHeight) { 2265 if (classie.hasClass(masthead, 'style-dark-original')) { 2266 logo.className = logo.className.replace("style-light", "style-dark"); 2267 } 2268 if (classie.hasClass(masthead, 'style-light-original')) { 2269 logo.className = logo.className.replace("style-dark", "style-light"); 2270 } 2271 if (style != undefined) { 2272 if (style == 'dark') { 2273 classie.removeClass(transmenuel[i], 'style-light-override'); 2274 } 2275 if (style == 'light') { 2276 classie.removeClass(transmenuel[i], 'style-dark-override'); 2277 } 2278 classie.addClass(transmenuel[i], 'style-' + style + '-override'); 2279 } 2280 } else { 2281 if (style != undefined) { 2282 if (style == 'dark') { 2283 classie.removeClass(transmenuel[i], 'style-light-override'); 2284 } 2285 if (style == 'light') { 2286 classie.removeClass(transmenuel[i], 'style-dark-override'); 2287 } 2288 classie.addClass(transmenuel[i], 'style-' + style + '-override'); 2289 } 2290 } 2291 } 2292 if (pageHeader != undefined) { 2293 if (style != undefined) { 2294 if (classie.hasClass(pageHeader, 'header-style-dark')) { 2295 classie.removeClass(pageHeader, 'header-style-dark'); 2296 } 2297 if (classie.hasClass(pageHeader, 'header-style-light')) { 2298 classie.removeClass(pageHeader, 'header-style-light'); 2299 } 2300 classie.addClass(pageHeader, 'header-style-' + style); 2301 } 2302 } 2303 }, 2304 /** VisibleRows **/ 2305 visibleRowCol = function(bodyTop) { 2306 if ( typeof visibleRows == 'object') { 2307 for (var i = 0; i < visibleRows.length; i++) { 2308 var section = visibleRows[i], 2309 sectionHeight = outerHeight(section), 2310 offSetTop = bodyTop + ( section != null ? section.getBoundingClientRect().top : 0 ), 2311 offSetPosition = wheight + bodyTop - offSetTop; 2312 if (offSetPosition > 0 && offSetPosition < (sectionHeight + wheight)) { 2313 classie.addClass($kenburnsInner[0], 'uncode-scroll-visible'); 2314 visibleRows[i].dispatchEvent(new CustomEvent('enter-row')); 2315 } else { 2316 classie.removeClass($kenburnsInner[0], 'uncode-scroll-visible'); 2317 visibleRows[i].dispatchEvent(new CustomEvent('exit-row')); 2318 } 2319 } 2320 } 2321 }, 2322 /** KenBurns **/ 2323 kenburnsHeader = function(bodyTop) { 2324 var value; 2325 if ( typeof kenburnsHeaders == 'object' && kenburnsHeaders.length ) { 2326 for (var i = 0; i < kenburnsHeaders.length; i++) { 2327 var section = kenburnsHeaders[i].parentNode, 2328 sectionHeight = outerHeight(section), 2329 offSetTop = bodyTop + (section != null ? (classie.hasClass(section.parentNode.parentNode, 'owl-carousel') ? section.parentNode.parentNode.getBoundingClientRect().top : section.getBoundingClientRect().top) : 0), 2330 offSetPosition = wheight + bodyTop - offSetTop, 2331 $kenburnsInner = kenburnsHeaders[i].querySelectorAll('.header-bg'); 2332 if (classie.hasClass(kenburnsHeaders[i], 'header-carousel-wrapper')) { 2333 $kenburnsInner = kenburnsHeaders[i].querySelectorAll('.t-background-cover'); 2334 } 2335 if (offSetPosition > 0 && offSetPosition < (sectionHeight + wheight)) { 2336 for (var i = 0; i < $kenburnsInner.length; i++) { 2337 classie.addClass($kenburnsInner[i], 'uncode-kburns'); 2338 $kenburnsInner[i].dispatchEvent(new CustomEvent('enter-kburns')); 2339 } 2340 } else { 2341 for (var i = 0; i < $kenburnsInner.length; i++) { 2342 classie.removeClass($kenburnsInner[i], 'uncode-kburns'); 2343 $kenburnsInner[i].dispatchEvent(new CustomEvent('exit-kburns')); 2344 } 2345 } 2346 } 2347 } 2348 }, 2349 kenburnsRowCol = function(bodyTop) { 2350 var value; 2351 if ( UNCODE.isFrontEndEditor ) { 2352 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'); 2353 } 2354 if ( typeof kenburnsRows == 'object' && kenburnsRows.length ) { 2355 for (var i = 0; i < kenburnsRows.length; i++) { 2356 var section = kenburnsRows[i].parentNode, 2357 sectionHeight = outerHeight(section), 2358 offSetTop = bodyTop + (section != null ? (classie.hasClass(section.parentNode.parentNode, 'owl-carousel') ? section.parentNode.parentNode.getBoundingClientRect().top : section.getBoundingClientRect().top) : 0), 2359 offSetPosition = wheight + bodyTop - offSetTop, 2360 $kenburnsInner = kenburnsRows[i].querySelectorAll('.background-inner, .header-bg'); 2361 if (offSetPosition > 0 && offSetPosition < (sectionHeight + wheight)) { 2362 classie.addClass($kenburnsInner[0], 'uncode-kburns'); 2363 $kenburnsInner[0].dispatchEvent(new CustomEvent('enter-kburns')); 2364 } else { 2365 classie.removeClass($kenburnsInner[0], 'uncode-kburns'); 2366 $kenburnsInner[0].dispatchEvent(new CustomEvent('exit-kburns')); 2367 } 2368 } 2369 } 2370 if ( UNCODE.isFrontEndEditor ) { 2371 kenburnsCols = document.querySelectorAll('.with-kburns > .column-background > .background-wrapper'); 2372 } 2373 if ( typeof kenburnsCols == 'object' && kenburnsCols.length ) { 2374 for (var j = 0; j < kenburnsCols.length; j++) { 2375 var elm = kenburnsCols[j], 2376 $kenburnsInner = elm.querySelectorAll('.background-inner'); 2377 if (checkVisible(elm)) { 2378 classie.addClass($kenburnsInner[0], 'uncode-kburns'); 2379 $kenburnsInner[0].dispatchEvent(new CustomEvent('enter-kburns')); 2380 } else { 2381 classie.removeClass($kenburnsInner[0], 'uncode-kburns'); 2382 $kenburnsInner[0].dispatchEvent(new CustomEvent('exit-kburns')); 2383 } 2384 } 2385 } 2386 }, 2387 /** Zoom Out BackWash **/ 2388 backwashHeader = function(bodyTop) { 2389 var value; 2390 var onEndAnimationFn = function(ev){ 2391 if (animationEvent) { 2392 if (ev.animationName !== 'backwash') { 2393 return; 2394 } 2395 this.removeEventListener(animationEvent, onEndAnimationFn); 2396 } 2397 classie.addClass(ev.target, 'uncode-zoomout-already'); 2398 } 2399 if ( typeof backwashHeaders == 'object' && backwashHeaders.length ) { 2400 for (var i = 0; i < backwashHeaders.length; i++) { 2401 var section = backwashHeaders[i].parentNode, 2402 sectionHeight = outerHeight(section), 2403 offSetTop = bodyTop + (section != null ? (classie.hasClass(section.parentNode.parentNode, 'owl-carousel') ? section.parentNode.parentNode.getBoundingClientRect().top : section.getBoundingClientRect().top) : 0), 2404 offSetPosition = wheight + bodyTop - offSetTop, 2405 $backwashInner = backwashHeaders[i].querySelectorAll('.header-bg'); 2406 2407 if ( classie.hasClass($backwashInner[0], 'uncode-video-container') ) { 2408 continue; 2409 } 2410 2411 if (classie.hasClass(backwashHeaders[i], 'header-carousel-wrapper')) { 2412 $backwashInner = backwashHeaders[i].querySelectorAll('.t-background-cover'); 2413 } 2414 2415 if (offSetPosition > 0 && offSetPosition < (sectionHeight + wheight)) { 2416 for (var i = 0; i < $backwashInner.length; i++) { 2417 classie.addClass($backwashInner[i], 'uncode-zoomout'); 2418 $backwashInner[i].dispatchEvent(new CustomEvent('enter-zoomout')); 2419 } 2420 } else { 2421 for (var i = 0; i < $backwashInner.length; i++) { 2422 classie.removeClass($backwashInner[i], 'uncode-zoomout'); 2423 $backwashInner[i].dispatchEvent(new CustomEvent('exit-zoomout')); 2424 } 2425 } 2426 for (var i = 0; i < $backwashInner.length; i++) { 2427 $backwashInner[i].addEventListener(animationEvent, onEndAnimationFn); 2428 } 2429 } 2430 } 2431 }, 2432 backwashRowCol = function(bodyTop) { 2433 var value; 2434 var onEndAnimationFn = function(ev){ 2435 if (animationEvent) { 2436 if (ev.animationName !== 'backwash') { 2437 return; 2438 } 2439 this.removeEventListener(animationEvent, onEndAnimationFn); 2440 } 2441 classie.addClass(ev.target, 'uncode-zoomout-already'); 2442 } 2443 if ( UNCODE.isFrontEndEditor ) { 2444 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'); 2445 } 2446 if ( typeof backwashRows == 'object' && backwashRows.length ) { 2447 for (var i = 0; i < backwashRows.length; i++) { 2448 var section = backwashRows[i].parentNode, 2449 sectionHeight = outerHeight(section), 2450 offSetTop = bodyTop + (section != null ? (classie.hasClass(section.parentNode.parentNode, 'owl-carousel') ? section.parentNode.parentNode.getBoundingClientRect().top : section.getBoundingClientRect().top) : 0), 2451 offSetPosition = wheight + bodyTop - offSetTop, 2452 $backwashInner = backwashRows[i].querySelectorAll('.background-inner'); 2453 2454 if ( classie.hasClass($backwashInner[0], 'uncode-video-container') ) { 2455 continue; 2456 } 2457 2458 if (offSetPosition > 0 && offSetPosition < (sectionHeight + wheight) ) { 2459 classie.addClass($backwashInner[0], 'uncode-zoomout'); 2460 $backwashInner[0].dispatchEvent(new CustomEvent('enter-zoomout')); 2461 } else { 2462 classie.removeClass($backwashInner[0], 'uncode-zoomout'); 2463 $backwashInner[0].dispatchEvent(new CustomEvent('exit-zoomout')); 2464 } 2465 $backwashInner[0].addEventListener(animationEvent, onEndAnimationFn); 2466 } 2467 2468 } 2469 if ( UNCODE.isFrontEndEditor ) { 2470 backwashCols = document.querySelectorAll('.with-zoomout > .column-background > .background-wrapper'); 2471 } 2472 if ( typeof backwashCols == 'object' && backwashCols.length ) { 2473 for (var j = 0; j < backwashCols.length; j++) { 2474 var elm = backwashCols[j], 2475 $backwashInner = elm.querySelectorAll('.background-inner'); 2476 if (checkVisible(elm)) { 2477 classie.addClass($backwashInner[0], 'uncode-zoomout'); 2478 $backwashInner[0].dispatchEvent(new CustomEvent('enter-zoomout')); 2479 } else { 2480 classie.removeClass($backwashInner[0], 'uncode-zoomout'); 2481 $backwashInner[0].dispatchEvent(new CustomEvent('exit-zoomout')); 2482 } 2483 $backwashInner[0].addEventListener(animationEvent, onEndAnimationFn); 2484 } 2485 } 2486 }, 2487 /** Parallax Rows **/
2488 parallaxRowCol = function(bodyTop) { 2489 var value; 2490 if ( UNCODE.isFrontEndEditor ) { 2491 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'); 2492 } 2493 if (typeof parallaxRows == 'object') { 2494 for (var i = 0; i < parallaxRows.length; i++) { 2495 var section = parallaxRows[i].parentNode, 2496 thisHeight = outerHeight(parallaxRows[i]), 2497 sectionHeight = outerHeight(section), 2498 offSetTop = bodyTop + (section != null ? (classie.hasClass(section.parentNode.parentNode, 'owl-carousel') ? section.parentNode.parentNode.getBoundingClientRect().top : section.getBoundingClientRect().top) : 0), 2499 offSetPosition = wheight + bodyTop - offSetTop; 2500 if (offSetPosition > 0 && offSetPosition < (sectionHeight + wheight)) { 2501 value = ((offSetPosition - wheight) * speedDivider); 2502 if (Math.abs(value) < (thisHeight - sectionHeight)) {
2503 translateElement(parallaxRows[i], Math.floor(value)); 2504 } else { 2505 translateElement(parallaxRows[i], Math.floor(thisHeight - sectionHeight)); 2506 } 2507 } 2508 } 2509 } 2510 if ( UNCODE.isFrontEndEditor ) { 2511 parallaxCols = document.querySelectorAll('.with-parallax > .column-background > .background-wrapper'); 2512 } 2513 if (typeof parallaxCols == 'object') { 2514 for (var j = 0; j < parallaxCols.length; j++) { 2515 var section = parallaxCols[j].parentNode, 2516 thisHeight = outerHeight(parallaxCols[j]), 2517 sectionHeight = outerHeight(section), 2518 offSetTop = bodyTop + (section != null ? section.getBoundingClientRect().top : 0), 2519 offSetPosition = wheight + bodyTop - offSetTop; 2520 if (offSetPosition > 0 && offSetPosition < (sectionHeight + wheight)) { 2521 value = ((offSetPosition - wheight) * speedDivider); 2522 value *= .8; 2523 if (Math.abs(value) < (thisHeight - sectionHeight)) { 2524 translateElement(parallaxCols[j], Math.floor(value)); 2525 } else { 2526 translateElement(parallaxCols[j], Math.floor(thisHeight - sectionHeight)); 2527 } 2528 } 2529 } 2530 } 2531 }, 2532 /** Parallax Headers **/ 2533 parallaxHeader = function(bodyTop) { 2534 var value; 2535 if (typeof parallaxHeaders == 'object') { 2536 for (var i = 0; i < parallaxHeaders.length; i++) { 2537 var section = parallaxHeaders[i].parentNode, 2538 thisSibling = section.nextSibling, 2539 thisHeight, 2540 sectionHeight, 2541 offSetTop, 2542 offSetPosition; 2543 if (classie.hasClass(parallaxHeaders[i], 'header-carousel-wrapper')) { 2544 getDivChildren(parallaxHeaders[i], '.t-entry-visual-cont', function(item, l, total) { 2545 thisHeight = outerHeight(item); 2546 sectionHeight = outerHeight(section); 2547 offSetTop = bodyTop + section.getBoundingClientRect().top; 2548 offSetPosition = wheight + bodyTop - offSetTop; 2549 if (offSetPosition > 0 && offSetPosition < (sectionHeight + wheight)) { 2550 value = ((offSetPosition - wheight) * speedDivider); 2551 if (Math.abs(value) < (thisHeight - sectionHeight)) { 2552 translateElement(item, Math.floor(value)); 2553 } 2554 } 2555 }); 2556 } else { 2557 thisHeight = outerHeight(parallaxHeaders[i]); 2558 sectionHeight = outerHeight(section); 2559 offSetTop = bodyTop + section.getBoundingClientRect().top; 2560 offSetPosition = wheight + bodyTop - offSetTop; 2561 if (offSetPosition > 0 && offSetPosition < (sectionHeight + wheight)) { 2562 value = ((offSetPosition - wheight) * speedDivider); 2563 if (Math.abs(value) < (thisHeight - sectionHeight)) { 2564 translateElement(parallaxHeaders[i], Math.floor(value)); 2565 } 2566 } 2567 } 2568 } 2569 } 2570 }, 2571 /** Header opacity **/ 2572 headerOpacity = function(bodyTop) { 2573 if ( UNCODE.isFrontEndEditor ) { 2574 return; 2575 } 2576 if (headerWithOpacity && headerWithOpacity.length) { 2577 var thisHeight = outerHeight(headerWithOpacity[0]); 2578 if (bodyTop > thisHeight / 8) { 2579 if (pageHeader != undefined) classie.addClass(pageHeader, 'header-scrolled'); 2580 } else { 2581 if (pageHeader != undefined) classie.removeClass(pageHeader, 'header-scrolled'); 2582 } 2583 } 2584 }, 2585 /** Show hide scroll top arrow **/ 2586 showHideScrollup = function(bodyTop) { 2587 if ( bodyTop != 0 ) { 2588 if (bodyTop > wheight || ((bodyTop + wheight) >= docheight) && docheight > 0) { 2589 classie.addClass(document.body, 'window-scrolled'); 2590 classie.removeClass(document.body, 'hide-scrollup'); 2591 if (footerScroller && footerScroller[0] != undefined) { 2592 footerScroller[0].style.display = ''; 2593 } 2594 } else { 2595 if (classie.hasClass(document.body, 'window-scrolled')) classie.addClass(document.body, 'hide-scrollup'); 2596 classie.removeClass(document.body, 'window-scrolled'); 2597 } 2598 } 2599 }, 2600 /** Fix menu **/ 2601 fixMenu = function(){ 2602 if ( UNCODE.isFrontEndEditor ) 2603 return; 2604 menuwrapper = document.querySelectorAll(".menu-wrapper"); 2605 if ( ! classie.hasClass(document.body, 'vmenu') && UNCODE.isFullPage && !UNCODE.isFullPageSnap && classie.hasClass(document.body, 'uncode-fp-menu-hide') ) { 2606 menuwrapper = document.querySelector(".menu-wrapper"); 2607 pageHeader = document.getElementById("page-header"); 2608 menuwrapper.style.position = 'fixed'; 2609 menuwrapper.style.zIndex = '5'; 2610 } 2611 }, 2612 /** Hide Menu **/ 2613 hideMenu = function(bodyTop) { 2614 if ( UNCODE.isFrontEndEditor ) 2615 return; 2616 if (UNCODE.menuOpened || bodyTop < 0) return; 2617 if (classie.hasClass(document.body, 'vmenu')) { 2618 if (wwidth < mediaQuery) menuhide = document.querySelector('#masthead .menu-hide-vertical'); 2619 else menuhide = null; 2620 } 2621 if (classie.hasClass(document.body, 'hmenu-center')) { 2622 if (wwidth > mediaQuery) menuhide = document.querySelector('#masthead .menu-hide'); 2623 else menuhide = document.querySelector('.menu-container-mobile.menu-hide'); 2624 } 2625 if (typeof menuhide == 'object' && menuhide != null && mainmenu[0] != undefined) { 2626 var translate, 2627 scrollingDown = true; 2628 /** fix for hmenu-center **/ 2629 var sticky_element = (typeof mainmenu.item === 'undefined' ? ((wwidth > mediaQuery) ? mainmenu[0] : mainmenu[1]) : mainmenu[0]); 2630 if (lastScrollValue == bodyTop) return; 2631 2632 if (lastScrollValue > bodyTop) scrollingDown = false;
2633 else scrollingDown = true; 2634 lastScrollValue = bodyTop; 2635 2636 if (!scrollingDown) { 2637 if (!UNCODE.scrolling) { 2638 if ((secmenuHeight == 0) ? bodyTop == 0 : bodyTop < secmenuHeight) { 2639 classie.removeClass(sticky_element.parentNode, 'is_stuck'); 2640 if (classie.hasClass(masthead, 'menu-transparent')) { 2641 if ((isMobileTransparent || wwidth > mediaQuery) && !classie.hasClass(masthead.parentNode, 'no-header')) masthead.parentNode.style.height = '0px'; 2642 } 2643 if (wwidth < mediaQuery) sticky_element.style.position = 'fixed'; 2644 else sticky_element.style.position = ''; 2645 hideMenuReset(sticky_element); 2646 clearTimeout(hidingTimer); 2647 } 2648 2649 if (classie.hasClass(menuhide, 'menu-hided')) { 2650 classie.removeClass(menuhide, 'menu-hided'); 2651 hidingTimer = setTimeout(function() { 2652 classie.addClass(sticky_element.parentNode, 'is_stuck'); 2653 hideMenuReset(sticky_element); 2654 }, 400); 2655 } 2656 } 2657 } else { 2658 if (menusticky.length == 0 && bodyTop < wheight / 3) { 2659 if (sticky_element.style.position == 'fixed') sticky_element.style.position = ''; 2660 } 2661 if (bodyTop > wheight / 2) { 2662 clearTimeout(hidingTimer); 2663 if (!classie.hasClass(menuhide, 'menu-hided')) { 2664 classie.addClass(menuhide, 'menu-hided'); 2665 classie.addClass(sticky_element.parentNode, 'is_stuck'); 2666 if (sticky_element.style.position != 'fixed') { 2667 sticky_element.style.visibility = 'hidden'; 2668 sticky_element.style.position = 'fixed'; 2669 sticky_element.style.top = '0px'; 2670 } 2671 translateElement(menuhide, -UNCODE.menuMobileHeight - 1); 2672 } 2673 } 2674 } 2675 } 2676 }, 2677 hideMenuReset = function(sticky_element) { 2678 var topOffset = 0; 2679 if (sticky_element.style.visibility == 'hidden') sticky_element.style.visibility = ''; 2680 if (bodyBorder > 0) topOffset += bodyBorder; 2681 if (adminBar != null && window.getComputedStyle(adminBar,null).getPropertyValue("position") != 'fixed') adminBarHeight = 0; 2682 if (adminBarHeight > 0) topOffset += adminBarHeight; 2683 //sticky_element.style.top = topOffset + 'px'; 2684 if (!classie.hasClass(document.body, 'boxed-width') && boxWidth > 0) sticky_element.style.width = boxWidth + 'px'; 2685 translateElement(menuhide, 0); 2686 }, 2687 /** Stick Menu **/ 2688 stickMenu = function(bodyTop) { 2689 if (header && mainmenu[0] != undefined) { 2690 if (classie.hasClass(mainmenu[0], 'vmenu-container') && wwidth > mediaQuery) return; 2691 /** fix for hmenu-center **/ 2692 var sticky_element = (typeof mainmenu.item === 'undefined' ? ((isMobileTransparent || wwidth > mediaQuery) ? mainmenu[0] : mainmenu[1]) : mainmenu[0]); 2693 if ((secmenuHeight == 0 && (isMobileTransparent || wwidth > mediaQuery)) ? bodyTop > (0 + adminBarHeight) : bodyTop > (secmenuHeight + adminBarHeight)) { 2694 if (!classie.hasClass(sticky_element.parentNode, 'is_stuck')) { 2695 classie.addClass(sticky_element.parentNode, 'is_stuck'); 2696 sticky_element.style.position = 'fixed'; 2697 var getAnchorTop = bodyBorder; 2698 if (adminBar != null && window.getComputedStyle(adminBar,null).getPropertyValue("position") != 'fixed') adminBarHeight = 0; 2699 if (adminBarHeight > 0) getAnchorTop += adminBarHeight; 2700 sticky_element.style.top = getAnchorTop + 'px'; 2701 if (!classie.hasClass(document.body, 'boxed-width') && boxWidth > 0) sticky_element.style.width = boxWidth + 'px'; 2702 } 2703 } else { 2704 clearTimeout(hidingTimer); 2705 classie.removeClass(sticky_element.parentNode, 'is_stuck'); 2706 sticky_element.style.position = 'fixed'; 2707 if (isMobileTransparent || wwidth > mediaQuery) sticky_element.style.position = ''; 2708 if (classie.hasClass(document.body, 'hmenu-center')) sticky_element.style.position = 'absolute'; 2709 sticky_element.style.top = ''; 2710 } 2711 } 2712 }, 2713 translateElement = function(element, valueY) { 2714 var translate = 'translate3d(0, ' + valueY + 'px' + ', 0)'; 2715 element.style['-webkit-transform'] = translate; 2716 element.style['-moz-transform'] = translate; 2717 element.style['-ms-transform'] = translate; 2718 element.style['-o-transform'] = translate; 2719 element.style['transform'] = translate; 2720 }, 2721 setScrollPosition, 2722 scrollFunction = function() { 2723 if ( ! UNCODE.isFullPage ) { 2724 kenburnsHeader(bodyTop); 2725 kenburnsRowCol(bodyTop); 2726 backwashHeader(bodyTop); 2727 backwashRowCol(bodyTop); 2728 if (logoel != undefined && logoel.length && !isMobile) shrinkMenu(bodyTop); 2729 if (menusticky != undefined && menusticky.length) stickMenu(bodyTop); 2730 hideMenu(bodyTop); 2731 if (isMobileParallaxAllowed || !isMobile) { 2732 if (header && menusticky != undefined && menusticky.length) 2733 switchColorsMenu(bodyTop);
2734 parallaxRowCol(bodyTop); 2735 parallaxHeader(bodyTop); 2736 headerOpacity(bodyTop); 2737 visibleRowCol(bodyTop); 2738 } 2739 clearRequestTimeout(setScrollPosition); 2740 setScrollPosition = requestTimeout( function(){ 2741 scrollRowHeight_fix = window.pageYOffset; 2742 }, 100 ); 2743 } 2744 }, 2745 /** Shape Dividers **/ 2746 shapeDivider = function() { 2747 var $shape = '.uncode-divider-wrap'; 2748 2749 forEachElement($shape, function($el, i) { 2750 var elH = parseInt( $el.getAttribute('data-height') ), 2751 elHunit = $el.getAttribute('data-unit'), 2752 newEl, 2753 $parent = $el.parentNode, 2754 parentH, 2755 $svg = $el.getElementsByTagName('svg')[0]; 2756 2757 if ( elHunit == 'px' ) { 2758 2759 switch (true) { 2760 case (wwidth < 1500 && wwidth >= 1180): 2761 newEl = elH*0.8; 2762 break; 2763 2764 case (wwidth < 1180 && wwidth >= 960): 2765 newEl = elH*0.65; 2766 break; 2767 2768 case (wwidth < 960 && wwidth >= 570): 2769 newEl = elH*0.5; 2770 break; 2771 2772 case (wwidth < 570): 2773 newEl = elH*0.25; 2774 break; 2775 2776 default: 2777 newEl = elH; 2778 } 2779 2780 $el.style.height = newEl + elHunit; 2781 } 2782 2783 2784 if ( classie.hasClass($el, 'uncode-divider-preserve-ratio') && ( window.navigator.userAgent.indexOf('MSIE ') !== -1 || window.navigator.userAgent.indexOf('Trident/') !== -1 ) ) { 2785 2786 $svg.setAttribute('preserveAspectRatio','none'); 2787 2788 var sizes = $svg.getAttribute('viewBox').split(' '), 2789 svgW = sizes[2], 2790 svgH = sizes[3], 2791 newSvgW; 2792 2793 newSvgW = newEl * ( svgW / svgH ); 2794 2795 $svg.style.width = newSvgW + 'px'; 2796 2797 } 2798 }); 2799 }; 2800 if (!noScroll && document.body == null) { 2801 window.addEventListener('scroll', function(e) { 2802 if ( ! UNCODE.isFullPage ) { 2803 bodyTop = document.documentElement.scrollTop || document.body.scrollTop; 2804 scrollFunction(); 2805 showHideScrollup(bodyTop); 2806 } 2807 }, false); 2808 } 2809 /** All scrolling functions - End */ 2810 /** help functions */ 2811 function getClosest(el, tag) { 2812 do { 2813 if (el.className != undefined && el.className.indexOf(tag) > -1) return el; 2814 } while (el = el.parentNode); 2815 // not found :( 2816 return null; 2817 } 2818 2819 function outerHeight(el, includeMargin) { 2820 if (el != null) { 2821 var height = el.offsetHeight; 2822 if (includeMargin) { 2823 var style = el.currentStyle || getComputedStyle(el); 2824 height += parseInt(style.marginTop) + parseInt(style.marginBottom); 2825 } 2826 return height; 2827 } 2828 } 2829 2830 function outerWidth(el, includeMargin) { 2831 var width = el.offsetWidth; 2832 if (includeMargin) { 2833 var style = el.currentStyle || getComputedStyle(el); 2834 width += parseInt(style.marginLeft) + parseInt(style.marginRight); 2835 } 2836 return width; 2837 } 2838 // Replicate jQuery .each method 2839 function forEachElement(selector, fn) { 2840 var elements = document.querySelectorAll(selector); 2841 for (var i = 0; i < elements.length; i++) fn(elements[i], i); 2842 } 2843 2844 function getDivChildren(containerId, selector, fn) { 2845 if (containerId !== null) { 2846 var elements = containerId.querySelectorAll(selector); 2847 for (var i = 0; i < elements.length; i++) fn(elements[i], i, elements.length); 2848 } 2849 } 2850 2851 function hideFooterScroll() { 2852 if (classie.hasClass(document.body, 'hide-scrollup')) footerScroller[0].style.display = "none"; 2853 } 2854 document.addEventListener("DOMContentLoaded", function(event) { 2855 UNCODE.adaptive(); 2856 boxWrapper = document.querySelectorAll('.box-wrapper'); 2857 docheight = boxWrapper[0] != undefined ? boxWrapper[0].offsetHeight : 0; 2858 if (!classie.hasClass(document.body, 'vmenu') && !classie.hasClass(document.body, 'menu-offcanvas')) init_overlay(); 2859 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'); 2860 kenburnsCols = document.querySelectorAll('.with-kburns > .column-background > .background-wrapper'); 2861 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'); 2862 backwashCols = document.querySelectorAll('.with-zoomout > .column-background > .background-wrapper'); 2863 if (!UNCODE.isMobile || isMobileParallaxAllowed) {
2864 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'); 2865 parallaxCols = document.querySelectorAll('.with-parallax > .column-background > .background-wrapper'); 2866 } 2867 footerScroller = document.querySelectorAll('.footer-scroll-top'); 2868 if (footerScroller && footerScroller[0] != undefined) { 2869 if (transitionEvent) { 2870 footerScroller[0].addEventListener(transitionEvent, hideFooterScroll); 2871 } 2872 } 2873 Array.prototype.forEach.call(document.querySelectorAll('.row-inner'), function(el) { 2874 el.style.height = ''; 2875 el.style.marginBottom = ''; 2876 }); 2877 setRowHeight(document.querySelectorAll('.page-wrapper .row-parent, footer .row-parent')); 2878 }); 2879 /** On resize events **/ 2880 window.addEventListener("vc-resize", function() { 2881 scrollRowHeight_fix = window.pageYOffset; 2882 Array.prototype.forEach.call(document.querySelectorAll('.row-inner'), function(el) { 2883 el.style.height = ''; 2884 el.style.marginBottom = ''; 2885 }); 2886 setRowHeight(document.querySelectorAll('.page-wrapper .row-parent, footer .row-parent'), false, true); 2887 }); 2888 var setIsScrolling; 2889 window.addEventListener("scroll", function() { 2890 UNCODE.setIsScrolling = true; 2891 clearRequestTimeout(setIsScrolling); 2892 2893 setIsScrolling = requestTimeout(function() { 2894 UNCODE.setIsScrolling = false; 2895 }, 66); 2896 }); 2897 window.addEventListener("resize", function() { 2898 scrollRowHeight_fix = window.pageYOffset; 2899 docheight = (boxWrapper != undefined && boxWrapper[0] != undefined) ? boxWrapper[0].offsetHeight : 0; 2900 var oldWidth = wwidth; 2901 UNCODE.wwidth = wwidth = window.innerWidth || document.documentElement.clientWidth; 2902 UNCODE.wheight = wheight = (window.innerHeight || document.documentElement.clientHeight) - (bodyBorder * 2); 2903 if ( isSplitMenu && typeof resizeTimer_ === 'undefined' ) centerSplitMenu(); 2904 if (isMobile && (oldWidth == wwidth)) return false; 2905 calculateMenuHeight(false); 2906 initBox(); 2907 headerHeight('.header-wrapper'); 2908 window.dispatchEvent(boxEvent); 2909 scrollFunction(); 2910 shapeDivider(); 2911 showHideScrollup(bodyTop); 2912 clearTimeout(resizeTimer_); 2913 resizeTimer_ = setTimeout(function() { 2914 if (isSplitMenu) centerSplitMenu(); 2915 }, 10); 2916 if ( ! UNCODE.setIsScrolling ) { 2917 clearTimeout(resizeTimer); 2918 resizeTimer = setTimeout(function() { 2919 if ( ! UNCODE.setIsScrolling ) { 2920 UNCODE.wheight = wheight = (window.innerHeight || document.documentElement.clientHeight) - (bodyBorder * 2); 2921 Array.prototype.forEach.call(document.querySelectorAll('.row-inner'), function(el) { 2922 el.style.height = ''; 2923 el.style.marginBottom = ''; 2924 }); 2925 setRowHeight(document.querySelectorAll('.page-wrapper .row-parent, footer .row-parent'), false, true); 2926 } 2927 if (!isMobile) { 2928 initVideoComponent(document.body, '.uncode-video-container.video, .uncode-video-container.self-video'); 2929 } 2930 }, 500); 2931 } 2932 }); 2933 2934 /** 2935 * On DOM ready 2936 */ 2937 window.addEventListener("load", function(){ 2938 if (!UNCODE.isMobile) { 2939 setTimeout(function() { 2940 window.dispatchEvent(UNCODE.boxEvent); 2941 Waypoint.refreshAll(); 2942 }, 2000); 2943 } 2944 //repeat it for mobile since it changes layout on carousel after DOM loading 2945 if (UNCODE.isMobile && !isMobileParallaxAllowed) { 2946 kenburnsHeader(bodyTop); 2947 kenburnsRowCol(bodyTop); 2948 } 2949 backwashHeader(bodyTop); 2950 backwashRowCol(bodyTop); 2951 showHideScrollup(bodyTop); 2952 if (document.createEvent) { // W3C 2953 var ev = document.createEvent('Event'); 2954 ev.initEvent('resize', true, true); 2955 window.dispatchEvent(ev); 2956 } else { // IE 2957 document.fireEvent('onresize'); 2958 } 2959 }, false); 2960 2961 var UNCODE = { 2962 bodyTop: bodyTop, 2963 boxEvent: boxEvent, 2964 bodyBorder: bodyBorder, 2965 initBox: initBox, 2966 adminBarHeight: 0, 2967 menuHeight: 0, 2968 menuMobileHeight: 0, 2969 fixMenuHeight: fixMenuHeight, 2970 initHeader: initHeader, 2971 initRow: initRow, 2972 setRowHeight: setRowHeight, 2973 switchColorsMenu: switchColorsMenu, 2974 isMobile: isMobile, 2975 scrolling: false, 2976 menuHiding: false, 2977 menuOpened: false, 2978 menuMobileTriggerEvent: menuMobileTriggerEvent, 2979 mediaQuery: mediaQuery, 2980 initVideoComponent: initVideoComponent, 2981 hideMenu: hideMenu, 2982 wwidth: wwidth, 2983 wheight: wheight, 2984 }; 2985 // transport 2986 if (typeof define === 'function' && define.amd) { 2987 // AMD 2988 define(UNCODE); 2989 } else { 2990 // browser global 2991 window.UNCODE = UNCODE; 2992 } 2993 2994 UNCODE.adaptive = function() { 2995 var images = new Array(), 2996 getImages = document.querySelectorAll('.adaptive-async:not(.adaptive-fetching)'); 2997 for (var i = 0; i < getImages.length; i++) { 2998 var imageObj = {}, 2999 el = getImages[i]; 3000 classie.addClass(el, 'adaptive-fetching'); 3001 imageObj.unique = el.getAttribute('data-uniqueid'); 3002 imageObj.url = el.getAttribute('data-guid'); 3003 imageObj.path = el.getAttribute('data-path'); 3004 imageObj.singlew = el.getAttribute('data-singlew'); 3005 imageObj.singleh = el.getAttribute('data-singleh'); 3006 imageObj.origwidth = el.getAttribute('data-width'); 3007 imageObj.origheight = el.getAttribute('data-height'); 3008 imageObj.crop = el.getAttribute('data-crop'); 3009 imageObj.fixed = el.getAttribute('data-fixed') == undefined ? null : el.getAttribute('data-fixed'); 3010 imageObj.screen = window.uncodeScreen; 3011 imageObj.images = window.uncodeImages; 3012 images.push(imageObj); 3013 } 3014 3015 var post_data = { 3016 images: JSON.stringify(images), 3017 action: 'get_adaptive_async', 3018 nonce_adaptive_images: SiteParameters.nonce_adaptive_images 3019 }; 3020 3021 if (images.length > 0) { 3022 var xhr = new XMLHttpRequest(); 3023 xhr.open('POST', SiteParameters.ajax_url, true); 3024 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); 3025 xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); 3026 3027 xhr.onreadystatechange = function() { 3028 if (xhr.readyState == XMLHttpRequest.DONE) { 3029 if (xhr.status == 200 && xhr.responseText) { 3030 var jsonResponse = JSON.parse(xhr.responseText); 3031 3032 if (jsonResponse.success && jsonResponse.data.images) { 3033 var images = jsonResponse.data.images; 3034 3035 for (var i = 0; i < images.length; i++) { 3036 var val = images[i], 3037 getImage = document.querySelectorAll('[data-uniqueid="'+val.unique+'"]'); 3038 for (var j = 0; j < getImage.length; j++) { 3039 var attrScr = getImage[j].getAttribute('src'), 3040 replaceImg = new Image(); 3041 replaceImg.source = attrScr; 3042 replaceImg.el = getImage[j]; 3043 3044 classie.removeClass(getImage[j], 'adaptive-async'); 3045 classie.removeClass(getImage[j], 'adaptive-fetching'); 3046 3047 replaceImg.onload = function () { 3048 3049 var _this = this, 3050 parentNode = (_this.el).parentNode, 3051 placeH; 3052 3053 //Workaround for lazy-load flickering on Firefox 3054 if ( typeof parentNode.prepend == 'undefined') { 3055 if (_this.source !== null) { 3056 (_this.el).src = _this.src; 3057 } else { 3058 (_this.el).style.backgroundImage = 'url("'+_this.src+'")'; 3059 } 3060 3061 classie.addClass(_this.el, 'async-done'); 3062 } else { 3063 if (_this.source !== null) { 3064 placeH = document.createElement("IMG"); 3065 placeH.setAttribute('class', 'placeH'); 3066 placeH.src = _this.src; 3067 placeH.style.position = 'absolute'; 3068 placeH.style.opacity = '0'; 3069 } else { 3070 placeH = document.createElement("DIV"); 3071 placeH.setAttribute('style', _this.el.getAttribute('style')); 3072 placeH.setAttribute('class', 'placeH ' + _this.el.getAttribute('class')); 3073 placeH.style.backgroundImage = 'url("'+_this.src+'")'; 3074 placeH.style.backgroundSize = 'cover'; 3075 placeH.style.backgroundPosition = 'center'; 3076 placeH.style.position = 'absolute'; 3077 placeH.style.top = '0'; 3078 placeH.style.width = '100%'; 3079 placeH.style.height = '100%'; 3080 } 3081 3082 if ( !classie.hasClass( _this.el, 'box-wrapper') ) { 3083 parentNode.prepend(placeH); 3084 } 3085 3086 requestTimeout(function(){ 3087 if (_this.source !== null) { 3088 (_this.el).src = _this.src; 3089 } else { 3090 (_this.el).style.backgroundImage = 'url("'+_this.src+'")'; 3091 } 3092 if ( !classie.hasClass( _this.el, 'box-wrapper') ) { 3093 parentNode.removeChild(placeH); 3094 } 3095 classie.addClass(_this.el, 'async-done'); 3096 }, 250); 3097 } 3098 } 3099 replaceImg.src = val.url; 3100 } 3101 } 3102 3103 } else { 3104 if (SiteParameters.enable_debug == true) { 3105 // This console log is disabled by default 3106 // So nothing is printed in a typical installation 3107 // 3108 // It can be enabled for debugging purposes setting 3109 // the 'uncode_enable_debug_on_js_scripts' filter to true 3110 console.log('There was an error: bad response'); 3111 } 3112 } 3113 3114 } else if (xhr.status == 400) { 3115 if (SiteParameters.enable_debug == true) { 3116 // This console log is disabled by default 3117 // So nothing is printed in a typical installation 3118 // 3119 // It can be enabled for debugging purposes setting 3120 // the 'uncode_enable_debug_on_js_scripts' filter to true 3121 console.log('There was an error 400'); 3122 } 3123 } else { 3124 if (SiteParameters.enable_debug == true) { 3125 // This console log is disabled by default 3126 // So nothing is printed in a typical installation 3127 // 3128 // It can be enabled for debugging purposes setting 3129 // the 'uncode_enable_debug_on_js_scripts' filter to true 3130 console.log('Something else other than 200 was returned'); 3131 } 3132 } 3133 } 3134 } 3135 3136 // Serialize our data 3137 var queryString = "", 3138 arrayLength = Object.keys(post_data).length, 3139 arrayCounter = 0; 3140 3141 for (var key in post_data) { 3142 queryString += key + "=" + post_data[key]; 3143 3144 if (arrayCounter < arrayLength - 1) { 3145 queryString += "&"; 3146 } 3147 3148 arrayCounter++; 3149 } 3150 3151 xhr.send(queryString); 3152 } 3153 }; 3154 3155})(window); 3156 3157/** 3158 * vivus - JavaScript library to make drawing animation on SVG 3159 * @version v0.4.4 3160 * @link https://github.com/maxwellito/vivus 3161 * @license MIT 3162 */ 3163 3164'use strict'; 3165 3166(function () { 3167 3168 'use strict'; 3169 3170/** 3171 * Pathformer 3172 * Beta version 3173 * 3174 * Take any SVG version 1.1 and transform 3175 * child elements to 'path' elements 3176 * 3177 * This code is purely forked from 3178 * https://github.com/Waest/SVGPathConverter 3179 */ 3180 3181/** 3182 * Class constructor 3183 * 3184 * @param {DOM|String} element Dom element of the SVG or id of it 3185 */ 3186function Pathformer(element) { 3187 // Test params 3188 if (typeof element === 'undefined') { 3189 throw new Error('Pathformer [constructor]: "element" parameter is required'); 3190 } 3191 3192 // Set the element 3193 if (element.constructor === String) { 3194 element = document.getElementById(element); 3195 if (!element) { 3196 throw new Error('Pathformer [constructor]: "element" parameter is not related to an existing ID'); 3197 } 3198 } 3199 if (element instanceof window.SVGElement || 3200 element instanceof window.SVGGElement || 3201 /^svg$/i.test(element.nodeName)) { 3202 this.el = element; 3203 } else { 3204 throw new Error('Pathformer [constructor]: "element" parameter must be a string or a SVGelement'); 3205 } 3206 3207 // Start 3208 this.scan(element); 3209} 3210 3211/** 3212 * List of tags which can be transformed 3213 * to path elements 3214 * 3215 * @type {Array} 3216 */ 3217Pathformer.prototype.TYPES = ['line', 'ellipse', 'circle', 'polygon', 'polyline', 'rect']; 3218 3219/** 3220 * List of attribute names which contain 3221 * data. This array list them to check if 3222 * they contain bad values, like percentage. 3223 * 3224 * @type {Array} 3225 */ 3226Pathformer.prototype.ATTR_WATCH = ['cx', 'cy', 'points', 'r', 'rx', 'ry', 'x', 'x1', 'x2', 'y', '
vendor: 12,756 bytes, lines 3226-3627
3226y1', 'y2']; 3227 3228/** 3229 * Finds the elements compatible for transform 3230 * and apply the liked method 3231 * 3232 * @param {object} options Object from the constructor 3233 */ 3234Pathformer.prototype.scan = function (svg) { 3235 var fn, element, pathData, pathDom, 3236 elements = svg.querySelectorAll(this.TYPES.join(',')); 3237 3238 for (var i = 0; i < elements.length; i++) { 3239 element = elements[i]; 3240 fn = this[element.tagName.toLowerCase() + 'ToPath']; 3241 pathData = fn(this.parseAttr(element.attributes)); 3242 pathDom = this.pathMaker(element, pathData); 3243 element.parentNode.replaceChild(pathDom, element); 3244 } 3245}; 3246 3247 3248/** 3249 * Read `line` element to extract and transform 3250 * data, to make it ready for a `path` object. 3251 * 3252 * @param {DOMelement} element Line element to transform 3253 * @return {object} Data for a `path` element 3254 */ 3255Pathformer.prototype.lineToPath = function (element) { 3256 var newElement = {}, 3257 x1 = element.x1 || 0, 3258 y1 = element.y1 || 0, 3259 x2 = element.x2 || 0, 3260 y2 = element.y2 || 0; 3261 3262 newElement.d = 'M' + x1 + ',' + y1 + 'L' + x2 + ',' + y2; 3263 return newElement; 3264}; 3265 3266/** 3267 * Read `rect` element to extract and transform 3268 * data, to make it ready for a `path` object. 3269 * The radius-border is not taken in charge yet. 3270 * (your help is more than welcomed) 3271 * 3272 * @param {DOMelement} element Rect element to transform 3273 * @return {object} Data for a `path` element 3274 */ 3275Pathformer.prototype.rectToPath = function (element) { 3276 var newElement = {}, 3277 x = parseFloat(element.x) || 0, 3278 y = parseFloat(element.y) || 0, 3279 width = parseFloat(element.width) || 0, 3280 height = parseFloat(element.height) || 0; 3281 3282 if (element.rx || element.ry) { 3283 var rx = parseInt(element.rx, 10) || -1, 3284 ry = parseInt(element.ry, 10) || -1; 3285 rx = Math.min(Math.max(rx < 0 ? ry : rx, 0), width/2); 3286 ry = Math.min(Math.max(ry < 0 ? rx : ry, 0), height/2); 3287 3288 newElement.d = 'M ' + (x + rx) + ',' + y + ' ' + 3289 'L ' + (x + width - rx) + ',' + y + ' ' + 3290 'A ' + rx + ',' + ry + ',0,0,1,' + (x + width) + ',' + (y + ry) + ' ' + 3291 'L ' + (x + width) + ',' + (y + height - ry) + ' ' + 3292 'A ' + rx + ',' + ry + ',0,0,1,' + (x + width - rx) + ',' + (y + height) + ' ' + 3293 'L ' + (x + rx) + ',' + (y + height) + ' ' + 3294 'A ' + rx + ',' + ry + ',0,0,1,' + x + ',' + (y + height - ry) + ' ' + 3295 'L ' + x + ',' + (y + ry) + ' ' + 3296 'A ' + rx + ',' + ry + ',0,0,1,' + (x + rx) + ',' + y; 3297 } 3298 else { 3299 newElement.d = 'M' + x + ' ' + y + ' ' + 3300 'L' + (x + width) + ' ' + y + ' ' + 3301 'L' + (x + width) + ' ' + (y + height) + ' ' + 3302 'L' + x + ' ' + (y + height) + ' Z'; 3303 } 3304 return newElement; 3305}; 3306 3307/** 3308 * Read `polyline` element to extract and transform 3309 * data, to make it ready for a `path` object. 3310 * 3311 * @param {DOMelement} element Polyline element to transform 3312 * @return {object} Data for a `path` element 3313 */ 3314Pathformer.prototype.polylineToPath = function (element) { 3315 var newElement = {}, 3316 points = element.points.trim().split(' '), 3317 i, path; 3318 3319 // Reformatting if points are defined without commas 3320 if (element.points.indexOf(',') === -1) { 3321 var formattedPoints = []; 3322 for (i = 0; i < points.length; i+=2) { 3323 formattedPoints.push(points[i] + ',' + points[i+1]); 3324 } 3325 points = formattedPoints; 3326 } 3327 3328 // Generate the path.d value 3329 path = 'M' + points[0]; 3330 for(i = 1; i < points.length; i++) { 3331 if (points[i].indexOf(',') !== -1) { 3332 path += 'L' + points[i]; 3333 } 3334 } 3335 newElement.d = path; 3336 return newElement; 3337}; 3338 3339/** 3340 * Read `polygon` element to extract and transform 3341 * data, to make it ready for a `path` object. 3342 * This method rely on polylineToPath, because the 3343 * logic is similar. The path created is just closed, 3344 * so it needs an 'Z' at the end. 3345 * 3346 * @param {DOMelement} element Polygon element to transform 3347 * @return {object} Data for a `path` element 3348 */ 3349Pathformer.prototype.polygonToPath = function (element) { 3350 var newElement = Pathformer.prototype.polylineToPath(element); 3351 3352 newElement.d += 'Z'; 3353 return newElement; 3354}; 3355 3356/** 3357 * Read `ellipse` element to extract and transform 3358 * data, to make it ready for a `path` object. 3359 * 3360 * @param {DOMelement} element ellipse element to transform 3361 * @return {object} Data for a `path` element 3362 */ 3363Pathformer.prototype.ellipseToPath = function (element) { 3364 var newElement = {}, 3365 rx = parseFloat(element.rx) || 0, 3366 ry = parseFloat(element.ry) || 0, 3367 cx = parseFloat(element.cx) || 0, 3368 cy = parseFloat(element.cy) || 0, 3369 startX = cx - rx, 3370 startY = cy, 3371 endX = parseFloat(cx) + parseFloat(rx), 3372 endY = cy; 3373 3374 newElement.d = 'M' + startX + ',' + startY + 3375 'A' + rx + ',' + ry + ' 0,1,1 ' + endX + ',' + endY + 3376 'A' + rx + ',' + ry + ' 0,1,1 ' + startX + ',' + endY; 3377 return newElement; 3378}; 3379 3380/** 3381 * Read `circle` element to extract and transform 3382 * data, to make it ready for a `path` object. 3383 * 3384 * @param {DOMelement} element Circle element to transform 3385 * @return {object} Data for a `path` element 3386 */ 3387Pathformer.prototype.circleToPath = function (element) { 3388 var newElement = {}, 3389 r = parseFloat(element.r) || 0, 3390 cx = parseFloat(element.cx) || 0, 3391 cy = parseFloat(element.cy) || 0, 3392 startX = cx - r, 3393 startY = cy, 3394 endX = parseFloat(cx) + parseFloat(r), 3395 endY = cy; 3396 3397 newElement.d = 'M' + startX + ',' + startY + 3398 'A' + r + ',' + r + ' 0,1,1 ' + endX + ',' + endY + 3399 'A' + r + ',' + r + ' 0,1,1 ' + startX + ',' + endY; 3400 return newElement; 3401}; 3402 3403/** 3404 * Create `path` elements form original element 3405 * and prepared objects 3406 * 3407 * @param {DOMelement} element Original element to transform 3408 * @param {object} pathData Path data (from `toPath` methods) 3409 * @return {DOMelement} Path element 3410 */ 3411Pathformer.prototype.pathMaker = function (element, pathData) { 3412 var i, attr, pathTag = document.createElementNS('http://www.w3.org/2000/svg','path'); 3413 for(i = 0; i < element.attributes.length; i++) { 3414 attr = element.attributes[i]; 3415 if (this.ATTR_WATCH.indexOf(attr.name) === -1) { 3416 pathTag.setAttribute(attr.name, attr.value); 3417 } 3418 } 3419 for(i in pathData) { 3420 pathTag.setAttribute(i, pathData[i]); 3421 } 3422 return pathTag; 3423}; 3424 3425/** 3426 * Parse attributes of a DOM element to 3427 * get an object of attribute => value 3428 * 3429 * @param {NamedNodeMap} attributes Attributes object from DOM element to parse 3430 * @return {object} Object of attributes 3431 */ 3432Pathformer.prototype.parseAttr = function (element) { 3433 var attr, output = {}; 3434 for (var i = 0; i < element.length; i++) { 3435 attr = element[i]; 3436 // Check if no data attribute contains '%', or the transformation is impossible 3437 if (this.ATTR_WATCH.indexOf(attr.name) !== -1 && attr.value.indexOf('%') !== -1) { 3438 throw new Error('Pathformer [parseAttr]: a SVG shape got values in percentage. This cannot be transformed into \'path\' tags. Please use \'viewBox\'.'); 3439 } 3440 output[attr.name] = attr.value; 3441 } 3442 return output; 3443}; 3444 3445 'use strict'; 3446 3447var setupEnv, requestAnimFrame, cancelAnimFrame, parsePositiveInt; 3448 3449/** 3450 * Vivus 3451 * Beta version 3452 * 3453 * Take any SVG and make the animation 3454 * to give give the impression of live drawing 3455 * 3456 * This in more than just inspired from codrops 3457 * At that point, it's a pure fork. 3458 */ 3459 3460/** 3461 * Class constructor 3462 * option structure 3463 * type: 'delayed'|'sync'|'oneByOne'|'script' (to know if the items must be drawn synchronously or not, default: delayed) 3464 * duration: <int> (in frames) 3465 * start: 'inViewport'|'manual'|'autostart' (start automatically the animation, default: inViewport) 3466 * delay: <int> (delay between the drawing of first and last path) 3467 * dashGap <integer> whitespace extra margin between dashes 3468 * pathTimingFunction <function> timing animation function for each path element of the SVG 3469 * animTimingFunction <function> timing animation function for the complete SVG 3470 * forceRender <boolean> force the browser to re-render all updated path items 3471 * selfDestroy <boolean> removes all extra styling on the SVG, and leaves it as original 3472 * 3473 * The attribute 'type' is by default on 'delayed'. 3474 * - 'delayed' 3475 * all paths are draw at the same time but with a 3476 * little delay between them before start 3477 * - 'sync' 3478 * all path are start and finish at the same time 3479 * - 'oneByOne' 3480 * only one path is draw at the time 3481 * the end of the first one will trigger the draw 3482 * of the next one 3483 * 3484 * All these values can be overwritten individually 3485 * for each path item in the SVG 3486 * The value of frames will always take the advantage of 3487 * the duration value. 3488 * If you fail somewhere, an error will be thrown. 3489 * Good luck. 3490 * 3491 * @constructor 3492 * @this {Vivus} 3493 * @param {DOM|String} element Dom element of the SVG or id of it 3494 * @param {Object} options Options about the animation 3495 * @param {Function} callback Callback for the end of the animation 3496 */ 3497function Vivus (element, options, callback) { 3498 3499 setupEnv(); 3500 3501 // Setup 3502 this.isReady = false; 3503 this.setElement(element, options); 3504 this.setOptions(options); 3505 this.setCallback(callback); 3506 3507 if (this.isReady) { 3508 this.init(); 3509 } 3510} 3511 3512/** 3513 * Timing functions 3514 ************************************** 3515 * 3516 * Default functions to help developers. 3517 * It always take a number as parameter (between 0 to 1) then 3518 * return a number (between 0 and 1) 3519 */ 3520Vivus.LINEAR = function (x) {return x;}; 3521Vivus.EASE = function (x) {return -Math.cos(x * Math.PI) / 2 + 0.5;}; 3522Vivus.EASE_OUT = function (x) {return 1 - Math.pow(1-x, 3);}; 3523Vivus.EASE_IN = function (x) {return Math.pow(x, 3);}; 3524Vivus.EASE_OUT_BOUNCE = function (x) { 3525 var base = -Math.cos(x * (0.5 * Math.PI)) + 1, 3526 rate = Math.pow(base,1.5), 3527 rateR = Math.pow(1 - x, 2), 3528 progress = -Math.abs(Math.cos(rate * (2.5 * Math.PI) )) + 1; 3529 return (1- rateR) + (progress * rateR); 3530}; 3531 3532 3533/** 3534 * Setters 3535 ************************************** 3536 */ 3537 3538/** 3539 * Check and set the element in the instance 3540 * The method will not return anything, but will throw an 3541 * error if the parameter is invalid 3542 * 3543 * @param {DOM|String} element SVG Dom element or id of it 3544 */ 3545Vivus.prototype.setElement = function (element, options) { 3546 var onLoad, self; 3547 3548 // Basic check 3549 if (typeof element === 'undefined') { 3550 throw new Error('Vivus [constructor]: "element" parameter is required'); 3551 } 3552 3553 // Set the element 3554 if (element.constructor === String) { 3555 element = document.getElementById(element); 3556 if (!element) { 3557 throw new Error('Vivus [constructor]: "element" parameter is not related to an existing ID'); 3558 } 3559 } 3560 this.parentEl = element; 3561 3562 // Load the SVG with XMLHttpRequest and extract the SVG 3563 if (options && options.file) { 3564 var self = this; 3565 onLoad = function (e) { 3566 var domSandbox = document.createElement('div'); 3567 domSandbox.innerHTML = this.responseText; 3568 3569 var svgTag = domSandbox.querySelector('svg'); 3570 if (!svgTag) { 3571 throw new Error('Vivus [load]: Cannot find the SVG in the loaded file : ' + options.file); 3572 } 3573 3574 self.el = svgTag 3575 self.el.setAttribute('width', '100%'); 3576 self.el.setAttribute('height', '100%'); 3577 self.parentEl.appendChild(self.el) 3578 self.isReady = true; 3579 self.init(); 3580 self = null; 3581 } 3582 3583 var oReq = new window.XMLHttpRequest(); 3584 oReq.addEventListener('load', onLoad); 3585 oReq.open('GET', options.file); 3586 oReq.send(); 3587 return; 3588 } 3589 3590 switch (element.constructor) { 3591 case window.SVGSVGElement: 3592 case window.SVGElement: 3593 case window.SVGGElement: 3594 this.el = element; 3595 this.isReady = true; 3596 break; 3597 3598 case window.HTMLObjectElement: 3599 self = this; 3600 onLoad = function (e) { 3601 if (self.isReady) { 3602 return; 3603 } 3604 self.el = element.contentDocument && element.contentDocument.querySelector('svg'); 3605 if (!self.el && e) { 3606 throw new Error('Vivus [constructor]: object loaded does not contain any SVG'); 3607 } 3608 else if (self.el) { 3609 if (element.getAttribute('built-by-vivus')) { 3610 self.parentEl.insertBefore(self.el, element); 3611 self.parentEl.removeChild(element); 3612 self.el.setAttribute('width', '100%'); 3613 self.el.setAttribute('height', '100%'); 3614 } 3615 self.isReady = true; 3616 self.init(); 3617 self = null; 3618 } 3619 }; 3620 3621 if (!onLoad()) { 3622 element.addEventListener('load', onLoad); 3623 } 3624 break; 3625 3626 default: 3627 throw new Error('Vivus [constructor]: "element" parameter is not val
3627id (or miss the "file" attribute)'); 3628 } 3629}; 3630 3631/** 3632 * Set up user option to the instance 3633 * The method will not return anything, but will throw an 3634 * error if the parameter is invalid 3635 * 3636 * @param {object} options Object from the constructor 3637 */ 3638Vivus.prototype.setOptions = function (options) { 3639 var allowedTypes = ['delayed', 'sync', 'async', 'nsync', 'oneByOne', 'scenario', 'scenario-sync']; 3640 var allowedStarts = ['inViewport', 'manual', 'autostart']; 3641 3642 // Basic check 3643 if (options !== undefined && options.constructor !== Object) { 3644 throw new Error('Vivus [constructor]: "options" parameter must be an object'); 3645 } 3646 else { 3647 options = options || {}; 3648 } 3649 3650 // Set the animation type 3651 if (options.type && allowedTypes.indexOf(options.type) === -1) { 3652 throw new Error('Vivus [constructor]: ' + options.type + ' is not an existing animation `type`'); 3653 } 3654 else { 3655 this.type = options.type || allowedTypes[0]; 3656 } 3657 3658 // Set the start type 3659 if (options.start && allowedStarts.indexOf(options.start) === -1) { 3660 throw new Error('Vivus [constructor]: ' + options.start + ' is not an existing `start` option'); 3661 } 3662 else { 3663 this.start = options.start || allowedStarts[0]; 3664 } 3665 3666 this.isIE = (window.navigator.userAgent.indexOf('MSIE') !== -1 || window.navigator.userAgent.indexOf('Trident/') !== -1 || window.navigator.userAgent.indexOf('Edge/') !== -1 ); 3667 this.duration = parsePositiveInt(options.duration, 120); 3668 this.delay = parsePositiveInt(options.delay, null); 3669 //Uncode addition 3670 this.delayStart = parsePositiveInt(options.delayStart, null); 3671 //#END 3672 this.dashGap = parsePositiveInt(options.dashGap, 1); 3673 this.forceRender = options.hasOwnProperty('forceRender') ? !!options.forceRender : this.isIE; 3674 this.reverseStack = !!options.reverseStack; 3675 this.selfDestroy = !!options.selfDestroy; 3676 this.onReady = options.onReady; 3677 this.map = []; 3678 this.frameLength = this.currentFrame = this.delayUnit = this.speed = this.handle = null; 3679 3680 this.ignoreInvisible = options.hasOwnProperty('ignoreInvisible') ? !!options.ignoreInvisible : false; 3681 3682 this.animTimingFunction = options.animTimingFunction || Vivus.LINEAR; 3683 this.pathTimingFunction = options.pathTimingFunction || Vivus.LINEAR; 3684 3685 if (this.delay >= this.duration) { 3686 throw new Error('Vivus [constructor]: delay must be shorter than duration'); 3687 } 3688}; 3689 3690/** 3691 * Set up callback to the instance 3692 * The method will not return enything, but will throw an 3693 * error if the parameter is invalid 3694 * 3695 * @param {Function} callback Callback for the animation end 3696 */ 3697Vivus.prototype.setCallback = function (callback) { 3698 // Basic check 3699 if (!!callback && callback.constructor !== Function) { 3700 throw new Error('Vivus [constructor]: "callback" parameter must be a function'); 3701 } 3702 this.callback = callback || function () {}; 3703}; 3704 3705 3706/** 3707 * Core 3708 ************************************** 3709 */ 3710 3711/** 3712 * Map the svg, path by path. 3713 * The method return nothing, it just fill the 3714 * `map` array. Each item in this array represent 3715 * a path element from the SVG, with informations for 3716 * the animation. 3717 * 3718 * ``` 3719 * [ 3720 * { 3721 * el: <DOMobj> the path element 3722 * length: <number> length of the path line 3723 * startAt: <number> time start of the path animation (in frames) 3724 * duration: <number> path animation duration (in frames) 3725 * }, 3726 * ... 3727 * ] 3728 * ``` 3729 * 3730 */ 3731Vivus.prototype.mapping = function () { 3732 var i, paths, path, pAttrs, pathObj, totalLength, lengthMeter, timePoint; 3733 timePoint = totalLength = lengthMeter = 0; 3734 paths = this.el.querySelectorAll('path'); 3735 3736 for (i = 0; i < paths.length; i++) { 3737 path = paths[i]; 3738 if (this.isInvisible(path)) { 3739 continue; 3740 } 3741 pathObj = { 3742 el: path, 3743 length: Math.ceil(path.getTotalLength()) 3744 }; 3745 // Test if the path length is correct 3746 if (isNaN(pathObj.length)) { 3747 if (window.console && console.warn) { 3748 console.warn('Vivus [mapping]: cannot retrieve a path element length', path); 3749 } 3750 continue; 3751 } 3752 this.map.push(pathObj); 3753 path.style.strokeDasharray = pathObj.length + ' ' + (pathObj.length + this.dashGap * 2); 3754 path.style.strokeDashoffset = pathObj.length + this.dashGap; 3755 pathObj.length += this.dashGap; 3756 totalLength += pathObj.length; 3757 3758 this.renderPath(i); 3759 } 3760 3761 totalLength = totalLength === 0 ? 1 : totalLength; 3762 this.delay = this.delay === null ? this.duration / 3 : this.delay; 3763 this.delayUnit = this.delay / (paths.length > 1 ? paths.length - 1 : 1); 3764 3765 // Reverse stack if asked 3766 if (this.reverseStack) { 3767 this.map.reverse(); 3768 } 3769 3770 for (i = 0; i < this.map.length; i++) { 3771 pathObj = this.map[i]; 3772 3773 switch (this.type) { 3774 case 'delayed': 3775 pathObj.startAt = this.delayUnit * i; 3776 pathObj.duration = this.duration - this.delay; 3777 break; 3778 3779 case 'oneByOne': 3780 pathObj.startAt = lengthMeter / totalLength * this.duration; 3781 pathObj.duration = pathObj.length / totalLength * this.duration; 3782 break; 3783 3784 case 'sync': 3785 case 'async': 3786 case 'nsync': 3787 pathObj.startAt = 0; 3788 pathObj.duration = this.duration; 3789 break; 3790 3791 case 'scenario-sync': 3792 path = pathObj.el; 3793 pAttrs = this.parseAttr(path); 3794 pathObj.startAt = timePoint + (parsePositiveInt(pAttrs['data-delay'], this.delayUnit) || 0); 3795 pathObj.duration = parsePositiveInt(pAttrs['data-duration'], this.duration); 3796 timePoint = pAttrs['data-async'] !== undefined ? pathObj.startAt : pathObj.startAt + pathObj.duration; 3797 this.frameLength = Math.max(this.frameLength, (pathObj.startAt + pathObj.duration)); 3798 break; 3799 3800 case 'scenario': 3801 path = pathObj.el; 3802 pAttrs = this.parseAttr(path); 3803 pathObj.startAt = parsePositiveInt(pAttrs['data-start'], this.delayUnit) || 0; 3804 pathObj.duration = parsePositiveInt(pAttrs['data-duration'], this.duration); 3805 this.frameLength = Math.max(this.frameLength, (pathObj.startAt + pathObj.duration)); 3806 break; 3807 } 3808 lengthMeter += pathObj.length; 3809 this.frameLength = this.frameLength || this.duration; 3810 } 3811}; 3812 3813/** 3814 * Interval method to draw the SVG from current 3815 * position of the animation. It update the value of 3816 * `currentFrame` and re-trace the SVG. 3817 * 3818 * It use this.handle to store the requestAnimationFrame 3819 * and clear it one the animation is stopped. So this 3820 * attribute can be used to know if the animation is 3821 * playing. 3822 * 3823 * Once the animation at the end, this method will 3824 * trigger the Vivus callback. 3825 * 3826 */ 3827Vivus.prototype.drawer = function () { 3828 var self = this; 3829 this.currentFrame += this.speed; 3830 3831 if (this.currentFrame <= 0) { 3832 this.stop(); 3833 this.reset(); 3834 } else if (this.currentFrame >= this.frameLength) { 3835 this.stop(); 3836 this.currentFrame = this.frameLength; 3837 this.trace();
vendor: 5,092 bytes, lines 3838-4024
3838 if (this.selfDestroy) { 3839 this.destroy(); 3840 } 3841 } else { 3842 this.trace(); 3843 this.handle = requestAnimFrame(function () { 3844 self.drawer(); 3845 }); 3846 return; 3847 } 3848 3849 this.callback(this); 3850 if (this.instanceCallback) { 3851 this.instanceCallback(this); 3852 this.instanceCallback = null; 3853 } 3854}; 3855 3856/** 3857 * Draw the SVG at the current instant from the 3858 * `currentFrame` value. Here is where most of the magic is. 3859 * The trick is to use the `strokeDashoffset` style property. 3860 * 3861 * For optimisation reasons, a new property called `progress` 3862 * is added in each item of `map`. This one contain the current 3863 * progress of the path element. Only if the new value is different 3864 * the new value will be applied to the DOM element. This 3865 * method save a lot of resources to re-render the SVG. And could 3866 * be improved if the animation couldn't be played forward. 3867 * 3868 */ 3869Vivus.prototype.trace = function () { 3870 var i, progress, path, currentFrame; 3871 currentFrame = this.animTimingFunction(this.currentFrame / this.frameLength) * this.frameLength; 3872 for (i = 0; i < this.map.length; i++) { 3873 path = this.map[i]; 3874 progress = (currentFrame - path.startAt) / path.duration; 3875 progress = this.pathTimingFunction(Math.max(0, Math.min(1, progress))); 3876 if (path.progress !== progress) { 3877 path.progress = progress; 3878 path.el.style.strokeDashoffset = Math.floor(path.length * (1 - progress)); 3879 this.renderPath(i); 3880 } 3881 } 3882}; 3883 3884/** 3885 * Method forcing the browser to re-render a path element 3886 * from it's index in the map. Depending on the `forceRender` 3887 * value. 3888 * The trick is to replace the path element by it's clone. 3889 * This practice is not recommended because it's asking more 3890 * ressources, too much DOM manupulation.. 3891 * but it's the only way to let the magic happen on IE. 3892 * By default, this fallback is only applied on IE. 3893 * 3894 * @param {Number} index Path index 3895 */ 3896Vivus.prototype.renderPath = function (index) { 3897 if (this.forceRender && this.map && this.map[index]) { 3898 var pathObj = this.map[index], 3899 newPath = pathObj.el.cloneNode(true); 3900 pathObj.el.parentNode.replaceChild(newPath, pathObj.el); 3901 pathObj.el = newPath; 3902 } 3903}; 3904 3905/** 3906 * When the SVG object is loaded and ready, 3907 * this method will continue the initialisation. 3908 * 3909 * This this mainly due to the case of passing an 3910 * object tag in the constructor. It will wait 3911 * the end of the loading to initialise. 3912 * 3913 */ 3914Vivus.prototype.init = function () { 3915 // Set object variables 3916 this.frameLength = 0; 3917 this.currentFrame = 0; 3918 this.map = []; 3919 3920 // Start 3921 new Pathformer(this.el); 3922 this.mapping(); 3923 this.starter(); 3924 3925 if (this.onReady) { 3926 this.onReady(this); 3927 } 3928}; 3929 3930/** 3931 * Trigger to start of the animation. 3932 * Depending on the `start` value, a different script 3933 * will be applied. 3934 * 3935 * If the `start` value is not valid, an error will be thrown. 3936 * Even if technically, this is impossible. 3937 * 3938 */ 3939Vivus.prototype.starter = function () { 3940 switch (this.start) { 3941 case 'manual': 3942 return; 3943 3944 case 'autostart': 3945 this.play(); 3946 break; 3947 3948 case 'inViewport': 3949 var self = this, 3950 listener = function () { 3951 if (self.isInViewport(self.parentEl, 1)) { 3952 self.play(); 3953 window.removeEventListener('scroll', listener); 3954 //Uncode addition 3955 window.removeEventListener('fp-slide-changed', listener); 3956 window.removeEventListener('fp-slide-scroll', listener); 3957 //#END 3958 } 3959 }; 3960 window.addEventListener('scroll', listener); 3961 //Uncode addition 3962 window.addEventListener('fp-slide-changed', listener); 3963 window.addEventListener('fp-slide-scroll', listener); 3964 //#END 3965 listener(); 3966 break; 3967 } 3968}; 3969 3970 3971/** 3972 * Controls 3973 ************************************** 3974 */ 3975 3976/** 3977 * Get the current status of the animation between 3978 * three different states: 'start', 'progress', 'end'. 3979 * @return {string} Instance status 3980 */ 3981Vivus.prototype.getStatus = function () { 3982 return this.currentFrame === 0 ? 'start' : this.currentFrame === this.frameLength ? 'end' : 'progress'; 3983}; 3984 3985/** 3986 * Reset the instance to the initial state : undraw 3987 * Be careful, it just reset the animation, if you're 3988 * playing the animation, this won't stop it. But just 3989 * make it start from start. 3990 * 3991 */ 3992Vivus.prototype.reset = function () { 3993 return this.setFrameProgress(0); 3994}; 3995 3996/** 3997 * Set the instance to the final state : drawn 3998 * Be careful, it just set the animation, if you're 3999 * playing the animation on rewind, this won't stop it. 4000 * But just make it start from the end. 4001 * 4002 */ 4003Vivus.prototype.finish = function () { 4004 return this.setFrameProgress(1); 4005}; 4006 4007/** 4008 * Set the level of progress of the drawing. 4009 * 4010 * @param {number} progress Level of progress to set 4011 */ 4012Vivus.prototype.setFrameProgress = function (progress) { 4013 progress = Math.min(1, Math.max(0, progress)); 4014 this.currentFrame = Math.round(this.frameLength * progress); 4015 this.trace(); 4016 return this; 4017}; 4018 4019/** 4020 * Play the animation at the desired speed. 4021 * Speed must be a valid number (no zero). 4022 * By default, the speed value is 1. 4023 * But a negative value is accepted to go forward. 4024 *
4025 * And works with float too. 4026 * But don't forget we are in JavaScript, se be nice 4027 * with him and give him a 1/2^x value. 4028 * 4029 * @param {number} speed Animation speed [optional] 4030 */ 4031Vivus.prototype.play = function (speed, callback) { 4032 this.instanceCallback = null; 4033 4034 if (speed && typeof speed === 'function') { 4035 this.instanceCallback = speed; // first parameter is actually the callback function 4036 speed = null; 4037 } 4038 else if (speed && typeof speed !== 'number') { 4039 throw new Error('Vivus [play]: invalid speed'); 4040 } 4041 // if the first parameter wasn't the callback, check if the seconds was 4042 if (callback && typeof(callback) === 'function' && !this.instanceCallback) { 4043 this.instanceCallback = callback; 4044 } 4045 4046 4047 this.speed = speed || 1; 4048 //Uncode addition 4049 if (!this.handle) { 4050 var $this = this, 4051 delay = (this.delayStart != null) ? this.delayStart : 0; 4052 setTimeout(function() { 4053 $this.drawer(); 4054 }, delay); 4055 } 4056 //#END 4057 return this; 4058}; 4059 4060/** 4061 * Stop the current animation, if on progress. 4062 * Should not trigger any error. 4063 * 4064 */ 4065Vivus.prototype.stop = function () { 4066 if (this.handle) { 4067 cancelAnimFrame(this.handle); 4068 this.handle = null; 4069 } 4070 return this; 4071}; 4072 4073/** 4074 * Destroy the instance. 4075 * Remove all bad styling attributes on all 4076 * path tags 4077 * 4078 */ 4079Vivus.prototype.destroy = function () { 4080 this.stop(); 4081 var i, path; 4082 for (i = 0; i < this.map.length; i++) { 4083 path = this.map[i]; 4084 path.el.style.strokeDashoffset = null; 4085 path.el.style.strokeDasharray = null; 4086 this.renderPath(i); 4087 } 4088}; 4089 4090 4091/** 4092 * Utils methods 4093 * include methods from Codrops 4094 ************************************** 4095 */ 4096 4097/** 4098 * Method to best guess if a path should added into 4099 * the animation or not. 4100 * 4101 * 1. Use the `data-vivus-ignore` attribute if set 4102 * 2. Check if the instance must ignore invisible paths 4103 * 3. Check if the path is visible 4104 * 4105 * For now the visibility checking is unstable. 4106 * It will be used for a beta phase. 4107 * 4108 * Other improvments are planned. Like detecting 4109 * is the path got a stroke or a valid opacity. 4110 */ 4111Vivus.prototype.isInvisible = function (el) { 4112 var rect, 4113 ignoreAttr = el.getAttribute('data-ignore'); 4114 4115 if (ignoreAttr !== null) { 4116 return ignoreAttr !== 'false'; 4117 } 4118 4119 if (this.ignoreInvisible) { 4120 rect = el.getBoundingClientRect(); 4121 return !rect.width && !rect.height; 4122 } 4123 else { 4124 return false; 4125 } 4126}; 4127 4128/** 4129 * Parse attributes of a DOM element to 4130 * get an object of {attributeName => attributeValue} 4131 * 4132 * @param {object} element DOM element to parse 4133 * @return {object} Object of attributes 4134 */ 4135Vivus.prototype.parseAttr = function (element) { 4136 var attr, output = {}; 4137 if (element && element.attributes) { 4138 for (var i = 0; i < element.attributes.length; i++) { 4139 attr = element.attributes[i]; 4140 output[attr.name] = attr.value; 4141 } 4142 } 4143 return output; 4144}; 4145 4146/** 4147 * Reply if an element is in the page viewport 4148 * 4149 * @param {object} el Element to observe 4150 * @param {number} h Percentage of height 4151 * @return {boolean} 4152 */ 4153Vivus.prototype.isInViewport = function (el, h) { 4154 var scrolled = this.scrollY(), 4155 viewed = scrolled + this.getViewportH(), 4156 elBCR = el.getBoundingClientRect(), 4157 elHeight = elBCR.height, 4158 elTop = scrolled + elBCR.top, 4159 elBottom = elTop + elHeight; 4160 4161 // if 0, the element is considered in the viewport as soon as it enters. 4162 // if 1, the element is considered in the viewport only when it's fully inside 4163 // value in percentage (1 >= h >= 0) 4164 h = h || 0; 4165 4166 return (elTop + elHeight * h) <= viewed && (elBottom) >= scrolled; 4167}; 4168 4169 4170/** 4171 * Get the viewport height in pixels 4172 * 4173 * @return {integer} Viewport height 4174 */ 4175Vivus.prototype.getViewportH = function () { 4176 var client = this.docElem.clientHeight, 4177 inner = window.innerHeight; 4178 4179 if (client < inner) { 4180 return inner; 4181 } 4182 else { 4183 return client; 4184 } 4185}; 4186 4187/** 4188 * Get the page Y offset 4189 * 4190 * @return {integer} Page Y offset 4191 */ 4192Vivus.prototype.scrollY = function () { 4193 return window.pageYOffset || this.docElem.scrollTop; 4194}; 4195 4196setupEnv = function () { 4197 4198 if (Vivus.prototype.docElem) { 4199 return; 4200 } 4201 4202 /** 4203 * Alias for document element 4204 * 4205 * @type {DOMelement} 4206 */ 4207 Vivus.prototype.docElem = window.document.documentElement; 4208 4209 /** 4210 * Alias for `requestAnimationFrame` or 4211 * `setTimeout` function for deprecated browsers. 4212 * 4213 */ 4214 requestAnimFrame = (function () { 4215 return ( 4216 window.requestAnimationFrame || 4217 window.webkitRequestAnimationFrame || 4218 window.mozRequestAnimationFrame || 4219 window.oRequestAnimationFrame || 4220 window.msRequestAnimationFrame || 4221 function(/* function */ callback){ 4222 return window.setTimeout(callback, 1000 / 60); 4223 } 4224 ); 4225 })(); 4226 4227 /** 4228 * Alias for `cancelAnimationFrame` or 4229 * `cancelTimeout` function for deprecated browsers. 4230 * 4231 */ 4232 cancelAnimFrame = (function () { 4233 return ( 4234 window.cancelAnimationFrame || 4235 window.webkitCancelAnimationFrame || 4236 window.mozCancelAnimationFrame || 4237 window.oCancelAnimationFrame || 4238 window.msCancelAnimationFrame || 4239 function(id){ 4240 return window.clearTimeout(id); 4241 } 4242 ); 4243 })(); 4244}; 4245 4246/** 4247 * Parse string to integer. 4248 * If the number is not positive or null 4249 * the method will return the default value 4250 * or 0 if undefined 4251 * 4252 * @param {string} value String to parse 4253 * @param {*}
4253 defaultValue Value to return if the result parsed is invalid 4254 * @return {number} 4255 * 4256 */ 4257parsePositiveInt = function (value, defaultValue) { 4258 var output = parseInt(value, 10); 4259 return (output >= 0) ? output : defaultValue; 4260}; 4261 4262 4263 if (typeof define === 'function' && define.amd) { 4264 // AMD. Register as an anonymous module. 4265 define([], function() { 4266 return Vivus; 4267 }); 4268 } else if (typeof exports === 'object') { 4269 // Node. Does not work with strict CommonJS, but 4270 // only CommonJS-like environments that support module.exports, 4271 // like Node. 4272 module.exports = Vivus; 4273 } else { 4274 // Browser globals 4275 window.Vivus = Vivus; 4276 } 4277 4278}()); 4279 4280(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); 4281iNoBounce.disable(); 4282 4283/* 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;"; 4284this.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)} 4285function u(a,b){a.a.style.cssText="max-width:none;min-width:20px;min-height:20px;
4285display: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} 4286function 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(" ")} 4287B.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)}, 4288b)}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(""+ 4289n+"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, 4290L(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);}());
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.