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 17var uaInfo = { 18 ua: '', 19 is: function(t) { 20 return RegExp(t, "i").test(uaInfo.ua); 21 }, 22 version: function(p, n) { 23 n = n.replace(".", "_"); 24 var i = n.indexOf('_'), 25 ver = ""; 26 while (i > 0) { 27 ver += " " + p + n.substring(0, i); 28 i = n.indexOf('_', i + 1); 29 } 30 ver += " " + p + n; 31 return ver; 32 }, 33 getBrowser: function() { 34 var g = 'gecko', 35 w = 'webkit', 36 c = 'chrome', 37 f = 'firefox', 38 s = 'safari', 39 o = 'opera', 40 a = 'android', 41 bb = 'blackberry', 42 dv = 'device_', 43 ua = uaInfo.ua, 44 is = uaInfo.is; 45 return [ 46 (!(/opera|webtv/i.test(ua)) && /msie\s(\d+)/.test(ua)) ? ('ie ie' + (/trident\/4\.0/.test(ua) ? '8' : RegExp.$1)) 47 : is('edge\/') ? 'edge ie' + (/edge\/(\d+)\.(\d+)/.test(ua) ? RegExp.$1 + ' ie' + RegExp.$1 + '_' + RegExp.$2 : '') // IE Edge 48 : is('trident\/') ? 'ie ie'+ (/trident\/.+rv:(\d+)/i.test(ua) ? RegExp.$1 : '') //ie11+ 49 : is('firefox/') ? g + " " + f + (/firefox\/((\d+)(\.(\d+))(\.\d+)*)/.test(ua) ? ' ' + f + RegExp.$2 + ' ' + f + RegExp.$2 + "_" + RegExp.$4 : '') 50 : is('gecko/') ? g 51 : 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 : '')) 52 : is('konqueror') ? 'konqueror' 53 : 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 54 : 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 55 : is('chrome') ? w + ' ' + c + (/chrome\/((\d+)(\.(\d+))(\.\d+)*)/.test(ua) ? ' ' + c + RegExp.$2 + ((RegExp.$4 > 0) ? ' ' + c + RegExp.$2 + "_" + RegExp.$4 : '') : '') 56 : is('iron') ? w + ' iron' 57 : 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 58 : is('mozilla/') ? g : '' 59 ]; 60 }, 61 getPlatform : function() { 62 var wp = 'winphone', 63 a = 'android', 64 bb = 'blackberry', 65 dv = 'device_', 66 67 ua = uaInfo.ua, 68 version = uaInfo.version, 69 is = uaInfo.is; 70 71 return [ 72 is('j2me') ? 'j2me' 73 :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 74 :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 75 :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 76 :is('ipad|ipod|iphone') ? ( 77 (/CPU( iPhone)? OS (\d+[_|\.]\d+([_|\.]\d+)*)/i.test(ua) ? 'ios' + version('ios', RegExp.$2) : '') + ' ' + (/(ip(ad|od|hone))/gi.test(ua) ? RegExp.$1 : "")) //'iphone' 78 //:is('ipod')?'ipod' 79 //:is('ipad')?'ipad' 80 :is('playbook') ? 'playbook' 81 :is('kindle|silk') ? 'kindle' 82 :is('playbook') ? 'playbook' 83 :is('mac') ? 'mac' + (/mac os x ((\d+)[.|_](\d+))/.test(ua) ? (' mac'
83+ (RegExp.$2) + ' mac' + (RegExp.$1).replace('.', "_")) : '') 84 :is('win') ? 'win' + (is('windows nt 10.0') ? ' win10' 85 :is('windows nt 6.3') ? ' win8_1' 86 :is('windows nt 6.2') ? ' win8' 87 :is('windows nt 6.1') ? ' win7' 88 :is('windows nt 6.0') ? ' vista' 89 :is('windows nt 5.2') || is('windows nt 5.1') ? ' win_xp' 90 :is('windows nt 5.0') ? ' win_2k' 91 :is('windows nt 4.0') || is('WinNT4.0') ? ' win_nt' : '') 92 :is('freebsd') ? 'freebsd' 93 :is('x11|linux') ? 'linux' : '' 94 ]; 95 }, 96 getMobile: function() { 97 var is = uaInfo.is; 98 return [ 99 is("android|mobi|mobile|j2me|iphone|ipod|ipad|blackberry|playbook|kindle|silk") ? 'mobile' : '' 100 ]; 101 }, 102 getIpadApp: function() { 103 var is = uaInfo.is; 104 return [ 105 (is('ipad|iphone|ipod') && !is('safari')) ? 'ipad_app' : '' 106 ]; 107 }, 108 getLang: function() { 109 var ua = uaInfo.ua; 110 return [/[; |\[](([a-z]{2})(\-[a-z]{2})?)[)|;|\]]/i.test(ua) ? ('lang_' + RegExp.$2).replace("-", "_") + (RegExp.$3 != '' ? (' ' + 'lang_' + RegExp.$1).replace("-", "_") : '') : '']; 111 } 112} 113var screenInfo = { 114 width: (window.outerWidth || document.documentElement.clientWidth) - 15, 115 height: window.outerHeight || document.documentElement.clientHeight, 116 screens: [0, 768, 980, 1200], 117 screenSize: function() { 118 screenInfo.width = (window.outerWidth || document.documentElement.clientWidth) - 15; 119 screenInfo.height = window.outerHeight || document.documentElement.clientHeight; 120 var screens = screenInfo.screens, 121 i = screens.length, 122 arr = [], 123 maxw, 124 minw; 125 while (i--) { 126 if (screenInfo.width >= screens[i]) { 127 if (i) { 128 arr.push("minw_" + screens[(i)]); 129 } 130 if (i <= 2) { 131 arr.push("maxw_" + (screens[(i) + 1] - 1)); 132 } 133 break; 134 } 135 } 136 return arr; 137 }, 138 getOrientation: function() { 139 return screenInfo.width < screenInfo.height ? ["orientation_portrait"] : ["orientation_landscape"]; 140 }, 141 getInfo: function() { 142 var arr = []; 143 arr = arr.concat(screenInfo.screenSize()); 144 arr = arr.concat(screenInfo.getOrientation()); 145 return arr; 146 }, 147 getPixelRatio: function() { 148 var arr = [], 149 pixelRatio = window.devicePixelRatio ? window.devicePixelRatio : 1; 150 if (pixelRatio > 1) { 151 arr.push('retina_' + parseInt(pixelRatio) + 'x'); 152 arr.push('hidpi'); 153 } else { 154 arr.push('no-hidpi'); 155 } 156 return arr; 157 } 158} 159var dataUriInfo = { 160 data: new Image(), 161 div: document.createElement("div"), 162 isIeLessThan9: false, 163 getImg: function() { 164 dataUriInfo.data.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=="; 165 dataUriInfo.div.innerHTML = "<!--[if lt IE 9]><i></i><![endif]-->"; 166 dataUriInfo.isIeLessThan9 = dataUriInfo.div.getElementsByTagName("i").length == 1; 167 return dataUriInfo.data; 168 }, 169 checkSupport: function() { 170 if (dataUriInfo.data.width != 1 || dataUriInfo.data.height != 1 || dataUriInfo.isIeLessThan9) { 171 return ["no-datauri"]; 172 } else { 173 return ["datauri"]; 174 } 175 } 176} 177 178function css_browser_selector(u, ns) { 179 var html = document.documentElement, 180 b = [] 181 ns = ns ? ns : ""; 182 /* ua */ 183 uaInfo.ua = u.toLowerCase(); 184 var browser = uaInfo.getBrowser(); 185 if (browser == 'gecko') browser = (!(window.ActiveXObject) && "ActiveXObject" in window) ? 'ie ie11' : browser; 186 var pattTouch = /no-touch/g; 187 if (pattTouch.test(html.className)) b = b.concat('no-touch'); 188 else b = b.concat('touch'); 189 var pattAdmin = /admin-mode/g; 190 if (pattAdmin.test(html.className)) b = b.concat('admin-mode'); 191 b = b.concat(browser); 192 b = b.concat(uaInfo.getPlatform()); 193 b = b.concat(uaInfo.getMobile()); 194 b = b.concat(uaInfo.getIpadApp()); 195 b = b.concat(uaInfo.getLang()); 196 /* js */ 197 b = b.concat(['js']); 198 /* pixel ratio */ 199 b = b.concat(screenInfo.getPixelRatio()); 200 /* screen */ 201 b = b.concat(screenInfo.getInfo()); 202 var updateScreen = function() { 203 html.className = html.className.replace(/ ?orientation_\w+/g, "").replace(/ [min|max|cl]+[w|h]_\d+/g, ""); 204 html.className = html.className + ' ' + screenInfo.getInfo().join(' '); 205 } 206 window.addEventListener('resize', updateScreen); 207 window.addEventListener('orientationchange', updateScreen); 208 /* dataURI */ 209 var data = dataUriInfo.getImg(); 210 data.onload = data.onerror = function() { 211 html.className += ' ' + dataUriInfo.checkSupport().join(' '); 212 }
213 /* removendo itens invalidos do array */ 214 b = b.filter(function(e) { 215 return e; 216 }); 217 /* prefixo do namespace */ 218 b[0] = ns ? ns + b[0] : b[0]; 219 html.className = b.join(' ' + ns); 220 return html.className; 221 } 222 // define css_browser_selector_ns before loading this script to assign a namespace 223var css_browser_selector_ns = css_browser_selector_ns || ""; 224// init 225css_browser_selector(navigator.userAgent, css_browser_selector_ns); 226/** 227 * skip-link-focus-fix.js 228 * 229 * Helps with accessibility for keyboard only users. 230 * 231 * Learn more: https://github.com/Automattic/_s/pull/136 232 */ 233(function() { 234 var is_webkit = navigator.userAgent.toLowerCase().indexOf('webkit') > -1, 235 is_opera = navigator.userAgent.toLowerCase().indexOf('opera') > -1, 236 is_ie = navigator.userAgent.toLowerCase().indexOf('msie') > -1; 237 if ((is_webkit || is_opera || is_ie) && document.getElementById && window.addEventListener) { 238 window.addEventListener('hashchange', function() { 239 var id = location.hash.substring(1), 240 element; 241 if (!(/^[A-z0-9_-]+$/.test(id))) { 242 return; 243 } 244 element = document.getElementById(id); 245 if (element) { 246 if (!(/^(?:a|select|input|button|textarea)$/i.test(element.tagName))) { 247 element.tabIndex = -1; 248 } 249 element.focus(); 250 } 251 }, false); 252 } 253})(); 254// Polyfill for creating CustomEvents on IE9/10/11 255// code pulled from: 256// https://github.com/d4tocchini/customevent-polyfill 257// https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent#Polyfill 258try { 259 new CustomEvent("test"); 260} catch (e) { 261 var CustomEvent = function(event, params) { 262 var evt; 263 params = params || { 264 bubbles: false, 265 cancelable: false, 266 detail: undefined 267 }; 268 evt = document.createEvent("CustomEvent"); 269 evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); 270 return evt; 271 }; 272 CustomEvent.prototype = window.Event.prototype; 273 window.CustomEvent = CustomEvent; // expose definition to window 274} 275// Evento - v1.0.0 276// by Erik Royall <[email protected]> (http://erikroyall.github.io) 277// Dual licensed under MIT and GPL 278// Array.prototype.indexOf shim 279// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf 280Array.prototype.indexOf || (Array.prototype.indexOf = function(n) { 281 "use strict"; 282 if (null == this) throw new TypeError; 283 var t, e, o = Object(this), 284 r = o.length >>> 0; 285 if (0 === r) return -1; 286 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; 287 for (e = t >= 0 ? t : Math.max(r - Math.abs(t), 0); r > e; e++) 288 if (e in o && o[e] === n) return e; 289 return -1 290}); 291var evento = function(n) { 292 var t, e, o, r = n, 293 i = r.document, 294 f = {}; 295 return t = function() { 296 return "function" == typeof i.addEventListener ? function(n, t, e) { 297 n.addEventListener(t, e, !1), f[n] = f[n] || {}, f[n][t] = f[n][t] || [], f[n][t].push(e) 298 } : "function" == typeof i.attachEvent ? function(n, t, e) { 299 n.attachEvent(t, e), f[n] = f[n] || {}, f[n][t] = f[n][t] || [], f[n][t].push(e) 300 } : function(n, t, e) { 301 n["on" + t] = e, f[n] = f[n] || {}, f[n][t] = f[n][t] || [], f[n][t].push(e) 302 } 303 }(), e = function() { 304 return "function" == typeof i.removeEventListener ? function(n, t, e) { 305 n.removeEventListener(t, e, !1), Helio.each(f[n][t], function(o) { 306 o === e && (f[n] = f[n] || {}, f[n][t] = f[n][t] || [], f[n][t][f[n][t].indexOf(o)] = void 0) 307 }) 308 } : "function" == typeof i.detachEvent ? function(n, t, e) { 309 n.detachEvent(t, e), Helio.each(f[n][t], function(o) { 310 o === e && (f[n] = f[n] || {}, f[n][t] = f[n][t] || [], f[n][t][f[n][t].indexOf(o)] = void 0) 311 }) 312 } : function(n, t, e) { 313 n["on" + t] = void 0, Helio.each(f[n][t], function(o) { 314 o === e && (f[n] = f[n] || {}, f[n][t] = f[n][t] || [], f[n][t][f[n][t].indexOf(o)] = void 0) 315 }) 316 } 317 }(), o = function(n, t) { 318 f[n] = f[n] || {}, f[n][t] = f[n][t] || []; 319 for (var e = 0, o = f[n][t].length; o > e; e += 1) f[n][t][e]() 320 }, { 321 add: t, 322 remove: e, 323 trigger: o, 324 _handlers: f 325 } 326}(this); 327/* 328 * OKVideo by OKFocus v2.3.2 329 * http://okfoc.us 330 * 331 * Copyright 2014, OKFocus 332 * Licensed under the MIT license. 333 * 334 */ 335var player, OKEvents, options, videoWidth, videoHeight, YTplayers, youtubePlayers = new Array(); 336// youtube player ready 337function onYouTubeIframeAPIReady() { 338 YTplayers = new Array(); 339 jQuery('.no-touch .uncode-video-container.video').each(function() { 340 var playerY; 341 if (jQuery(this).attr('data-provider') == 'youtube') { 342 var id = jQuery(this).attr('data-id'); 343 options = jQuery(window).data('okoptions-' + id); 344 options.time = jQuery(this).attr('data-t'); 345 playerY = new YT.Player('okplayer-' + id, { 346 videoId: options.video ? options.video.id : null, 347 playerVars: { 348 'autohide': 1, 349 'autoplay': 0, //options.autoplay,
350 'disablekb': options.keyControls, 351 'cc_load_policy': options.captions, 352 'controls': options.controls, 353 'enablejsapi': 1, 354 'fs': 0, 355 'modestbranding': 1, 356 'origin': window.location.origin || (window.location.protocol + '//' + window.location.hostname), 357 'iv_load_policy': options.annotations, 358 'loop': options.loop, 359 'showinfo': 0, 360 'rel': 0, 361 'wmode': 'opaque', 362 'hd': options.hd 363 }, 364 events: { 365 'onReady': OKEvents.yt.ready, 366 'onStateChange': OKEvents.yt.onStateChange, 367 'onError': OKEvents.yt.error 368 } 369 }); 370 YTplayers[id] = playerY; 371 playerY.videoId = id; 372 } 373 }); 374} 375// vimeo player ready 376function vimeoPlayerReady(id) { 377 options = jQuery(window).data('okoptions-' + id); 378 var jIframe = options.jobject, 379 iframe = jIframe[0]; 380 jIframe.attr('src', jIframe.data('src')); 381 var playerV = $f(iframe); 382 // hide player until Vimeo hides controls... 383 playerV.addEvent('ready', function(e) { 384 OKEvents.v.onReady(iframe); 385 var carouselContainer = jQuery(iframe).closest('.owl-carousel'); 386 if (carouselContainer.length) { 387 UNCODE.owlPlayVideo(carouselContainer); 388 } 389 // "Do not try to add listeners or call functions before receiving this event." 390 if (OKEvents.utils.isMobile()) { 391 // mobile devices cannot listen for play event 392 OKEvents.v.onPlay(playerV); 393 } else { 394 playerV.addEvent('play', OKEvents.v.onPlay(playerV)); 395 playerV.addEvent('pause', OKEvents.v.onPause); 396 playerV.addEvent('finish', OKEvents.v.onFinish); 397 } 398 if (options.time != null) { 399 playerV.api('seekTo', (options.time).replace('t=', '')); 400 } 401 402 playerV.api('play'); 403 jQuery(iframe).css({ 404 visibility: 'visible', 405 opacity: 1 406 }); 407 408 }); 409} 410OKEvents = { 411 yt: { 412 ready: function(event) { 413 var id = event.target.videoId; 414 youtubePlayers[id] = event.target; 415 event.target.setVolume(options.volume); 416 if (options.autoplay === 1) { 417 if (options.playlist.list) { 418 player.loadPlaylist(options.playlist.list, options.playlist.index, options.playlist.startSeconds, options.playlist.suggestedQuality); 419 } else { 420 var inCarousel = jQuery('#okplayer-' + id).closest('.owl-item'); 421 if (!inCarousel.length || (inCarousel.length && inCarousel.hasClass('active'))) { 422 if (options.time != null) { 423 event.target.seekTo(parseInt(options.time)); 424 } 425 event.target.playVideo(); 426 } else { 427 event.target.pauseVideo(); 428 } 429 } 430 } 431 OKEvents.utils.isFunction(options.onReady) && options.onReady(event.target); 432 }, 433 onStateChange: function(event) { 434 var id = event.target.videoId; 435 switch (event.data) { 436 case -1: 437 OKEvents.utils.isFunction(options.unstarted) && options.unstarted(); 438 break; 439 case 0: 440 OKEvents.utils.isFunction(options.onFinished) && options.onFinished(); 441 options.loop && event.target.playVideo(); 442 break; 443 case 1: 444 OKEvents.utils.isFunction(options.onPlay) && options.onPlay(); 445 setTimeout(function() { 446 UNCODE.initVideoComponent(document.body, '.uncode-video-container.video, .uncode-video-container.self-video'); 447 jQuery('#okplayer-' + id).closest('.uncode-video-container').css('opacity', '1'); 448 }, 300); 449 break; 450 case 2: 451 OKEvents.utils.isFunction(options.onPause) && options.onPause(); 452 break; 453 case 3: 454 OKEvents.utils.isFunction(options.buffering) && options.buffering(); 455 break; 456 case 5: 457 OKEvents.utils.isFunction(options.cued) && options.cued(); 458 break; 459 default: 460 throw "OKVideo: received invalid data from YT player."; 461 } 462 }, 463 error: function(event) { 464 throw event; 465 } 466 }, 467 v: { 468 onReady: function(target) { 469 OKEvents.utils.isFunction(options.onReady) && options.onReady(target); 470 }, 471 onPlay: function(player) { 472 if (!OKEvents.utils.isMobile()) player.api('setVolume', options.volume); 473 OKEvents.utils.isFunction(options.onPlay) && options.onPlay(); 474 jQuery(player.element).closest('.uncode-video-container').css('opacity', '1'); 475 }, 476 onPause: function() { 477 OKEvents.utils.isFunction(options.onPause) && options.onPause(); 478 }, 479 onFinish: function() { 480 OKEvents.utils.isFunction(options.onFinish) && options.onFinish(); 481 } 482 }, 483 utils: { 484 isFunction: function(func) { 485 if (typeof func === 'function') { 486 return true; 487 } else { 488 return false;
489 } 490 }, 491 isMobile: function() { 492 if (navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry)/)) { 493 return true; 494 } else { 495 return false; 496 } 497 } 498 } 499}; 500// DOM class helper 501(function(window) { 502 'use strict'; 503 // class helper functions from bonzo https://github.com/ded/bonzo 504 function classReg(className) { 505 return new RegExp("(^|\\s+)" + className + "(\\s+|$)"); 506 } 507 // classList support for class management 508 // altho to be fair, the api sucks because it won't accept multiple classes at once 509 var hasClass, addClass, removeClass; 510 if ('classList' in document.documentElement) { 511 hasClass = function(elem, c) { 512 if (elem !== null) return elem.classList.contains(c); 513 }; 514 addClass = function(elem, c) { 515 if (elem !== null) elem.classList.add(c); 516 }; 517 removeClass = function(elem, c) { 518 if (elem !== null) elem.classList.remove(c); 519 }; 520 } else { 521 hasClass = function(elem, c) { 522 if (elem !== null) return classReg(c).test(elem.className); 523 }; 524 addClass = function(elem, c) { 525 if (!hasClass(elem, c)) { 526 if (elem !== null) elem.className = elem.className + ' ' + c; 527 } 528 }; 529 removeClass = function(elem, c) { 530 if (elem !== null) elem.className = elem.className.replace(classReg(c), ' '); 531 }; 532 } 533 534 function toggleClass(elem, c) { 535 var fn = hasClass(elem, c) ? removeClass : addClass; 536 fn(elem, c); 537 } 538 var classie = { 539 // full names 540 hasClass: hasClass, 541 addClass: addClass, 542 removeClass: removeClass, 543 toggleClass: toggleClass, 544 // short names 545 has: hasClass, 546 add: addClass, 547 remove: removeClass, 548 toggle: toggleClass 549 }; 550 // transport 551 if (typeof define === 'function' && define.amd) { 552 // AMD 553 define(classie); 554 } else { 555 // browser global 556 window.classie = classie; 557 } 558})(window); 559/* From Modernizr */ 560function whichTransitionEvent() { 561 var t; 562 var el = document.createElement('fakeelement'); 563 var transitions = { 564 'transition': 'transitionend', 565 'OTransition': 'oTransitionEnd', 566 'MozTransition': 'transitionend', 567 'WebkitTransition': 'webkitTransitionEnd' 568 } 569 for (t in transitions) { 570 if (el.style[t] !== undefined) { 571 return transitions[t]; 572 } 573 } 574 } 575/** 576 * Load utils - END 577 */ 578 579/** 580 * Start main js 581 */ 582(function(window, undefined) { 583 'use strict'; 584 // Init variables 585 var bodyTop, 586 scrollbarWidth = false, 587 noScroll = false, 588 boxEvent = new CustomEvent('boxResized'), 589 menuClose = new CustomEvent('menuClose'), 590 menuOpen = new CustomEvent('menuOpen'), 591 bodyBorder = 0, 592 adminBarHeight = 0, 593 boxWidth = 0, 594 boxLeft = 0, 595 parallaxRows, 596 parallaxCols, 597 parallaxHeaders, 598 kenburnsRows, 599 kenburnsCols, 600 visibleRows, 601 headerWithOpacity, 602 speedDivider = SiteParameters.parallax_factor, 603 adminBar, 604 pageHeader, 605 masthead, 606 mastheadMobile, 607 mastheadMobilePaddingTop = 0, 608 maincontainer, 609 menuwrapper, 610 menuhide, 611 menusticky, 612 menuHeight = 0, 613 menuMobileHeight = 0, 614 mainmenu = new Array(), 615 secmenu = new Array(),
616 secmenuHeight = 0, 617 transmenuHeight = 0, 618 header, 619 transmenuel, 620 logo, 621 logoel, 622 logolink, 623 logoMinScale, 624 lastScrollValue = 0, 625 wwidth = window.innerWidth || document.documentElement.clientWidth, 626 wheight = window.innerHeight || document.documentElement.clientHeight, 627 boxWrapper, 628 docheight = 0, 629 isMobile = classie.hasClass(document.documentElement, 'touch') ? true : false, 630 isIE = classie.hasClass(document.documentElement, 'ie') || classie.hasClass(document.documentElement, 'opera12') ? true : false, 631 isFF = classie.hasClass(document.documentElement, 'firefox') ? true : false, 632 isFullPage, 633 isFullPageSnap, 634 transitionEvent = whichTransitionEvent(), 635 footerScroller = false, 636 mediaQuery = 959, 637 mediaQueryMobile = 569, 638 menuOpened = false, 639 overlayOpened = false, 640 menuMobileTriggerEvent = new CustomEvent('menuMobileTrigged'), 641 resizeTimer, 642 hidingTimer, 643 isSplitMenu = false, 644 mainNavMenu, 645 mainNavWrapper, 646 isMobileTransparent = false, 647 checkVisible = function( elm ) { 648 var rect = elm.getBoundingClientRect(); 649 var viewHeight = Math.max(document.documentElement.clientHeight, window.innerHeight); 650 return !(rect.bottom < 0 || rect.top - viewHeight >= 0); 651 }, 652 initBox = function() { 653 var bodyBorderDiv = document.querySelectorAll('.body-borders .top-border'); 654 if (bodyBorderDiv.length) { 655 bodyBorder = outerHeight(bodyBorderDiv[0]); 656 } else bodyBorder = 0; 657 UNCODE.bodyBorder = bodyBorder; 658 UNCODE.isFullPage = classie.hasClass(document.body, 'uncode-fullpage-slide') && !( UNCODE.isMobile && classie.hasClass(document.body, 'uncode-fp-mobile-disable') && window.innerWidth < 570 ); 659 UNCODE.isFullPageSnap = classie.hasClass(document.body, 'uncode-scroll-snap'); 660 if (bodyBorder != 0) { 661 if ( !UNCODE.isFullPage ) { 662 document.documentElement.style.marginTop = bodyBorder + 'px'; 663 } 664 wheight = (window.innerHeight || document.documentElement.clientHeight) - (bodyBorder * 2); 665 } 666 if (!isMobile && !scrollbarWidth) { 667 // Create the measurement node 668 var scrollDiv = document.createElement("div"); 669 scrollDiv.className = "scrollbar-measure"; 670 var dombody = document.body; 671 if (dombody != null) { 672 dombody.appendChild(scrollDiv); 673 // Get the scrollbar width 674 scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth; 675 // Delete the DIV 676 dombody.removeChild(scrollDiv); 677 } 678 } 679 if (!isMobile) { 680 forEachElement('.box-container', function(el, i) { 681 if (!classie.hasClass(el, 'limit-width')) { 682 var elWidth = outerWidth(el), 683 newWidth = 12 * Math.ceil((wwidth - scrollbarWidth) / 12); 684 boxWidth = newWidth - (bodyBorder * 2); 685 boxLeft = (wwidth - boxWidth - scrollbarWidth) / 2; 686 el.style.width = boxWidth + 'px'; 687 el.style.marginLeft = boxLeft + 'px'; 688 if (mainmenu != undefined && mainmenu[0] != undefined) { 689 mainmenu[0].style.width = boxWidth + 'px'; 690 } 691 } 692 }); 693 } 694 695 if (classie.hasClass(document.body, 'menu-mobile-transparent')) isMobileTransparent = true; 696 697 if (!isMobileTransparent) { 698 if (wwidth > mediaQuery && classie.hasClass(document.body, 'menu-force-opacity')) classie.removeClass(document.body, 'menu-force-opacity'); 699 if (wwidth < mediaQuery && !classie.hasClass(document.body, 'menu-force-opacity')) classie.addClass(document.body, 'menu-force-opacity'); 700 } 701 }, 702 fixMenuHeight = function() { 703 if (!classie.hasClass(document.body, 'vmenu')) noScroll = true; 704 705 menuwrapper = document.querySelectorAll(".menu-wrapper"); 706 masthead = document.getElementById("masthead"); 707 if (classie.hasClass(document.body, 'hmenu-center-split')) { 708 mastheadMobile = new Array(document.getElementById("logo-container-mobile"), document.getElementById("main-logo").parentNode); 709 } else mastheadMobile = document.getElementById("logo-container-mobile"); 710 menuhide = document.querySelector('#masthead .menu-hide, .main-header .menu-hide, #masthead .menu-hide-vertical'); 711 menusticky = document.querySelectorAll('.menu-sticky, .menu-sticky-vertical'); 712 transmenuel = document.querySelectorAll('.menu-transparent:not(.vmenu-container)');
713 var menuItemsButton = document.querySelectorAll('.menu-item-button .menu-btn-table'); 714 logo = document.querySelector('#main-logo'); 715 if (logo != undefined) logolink = (logo.firstElementChild || logo.firstChild); 716 if (logolink != undefined) logoMinScale = logolink.getAttribute("data-minheight"); 717 logoel = document.querySelectorAll('.menu-shrink .logo-container'); 718 mainmenu = document.querySelectorAll('.vmenu .vmenu-container, .menu-primary .menu-container'); 719 if (classie.hasClass(document.body, 'hmenu-center')) { 720 var mainmenucenter = document.querySelectorAll('.hmenu-center .menu-container-mobile'); 721 var first_array = Array.prototype.slice.call(mainmenu); 722 var second_array = Array.prototype.slice.call(mainmenucenter); 723 mainmenu = first_array.concat(second_array); 724 } 725 secmenu = document.querySelectorAll('.menu-secondary'); 726 calculateMenuHeight(true); 727 for (var k = 0; k < menuItemsButton.length; k++) { 728 var a_item = menuItemsButton[k].parentNode, 729 buttonHeight = outerHeight(menuItemsButton[k]); 730 a_item.style.height = buttonHeight + 'px'; 731 } 732 if (classie.hasClass(document.body, 'hmenu-center-split')) { 733 mainNavMenu = document.querySelector('#masthead .navbar-main .menu-primary-inner'); 734 mainNavWrapper = document.querySelector('#masthead > .menu-container'); 735 isSplitMenu = true; 736 } 737 fixMenu(); 738 }, 739 calculateMenuHeight = function(first) { 740 menuHeight = transmenuHeight = secmenuHeight = 0; 741 742 if (mastheadMobile != null) { 743 if (mastheadMobile.length === 2) { 744 if (wwidth > mediaQuery) { 745 UNCODE.menuMobileHeight = outerHeight(mastheadMobile[1]); 746 mastheadMobilePaddingTop = parseFloat(getComputedStyle(mastheadMobile[1]).paddingTop); 747 } else { 748 UNCODE.menuMobileHeight = outerHeight(mastheadMobile[0]); 749 mastheadMobilePaddingTop = parseFloat(getComputedStyle(mastheadMobile[0]).paddingTop); 750 } 751 } else { 752 UNCODE.menuMobileHeight = outerHeight(mastheadMobile); 753 mastheadMobilePaddingTop = parseFloat(getComputedStyle(mastheadMobile).paddingTop); 754 } 755 } 756 757 if (wwidth > mediaQuery) { 758 for (var i = 0; i < mainmenu.length; i++) { 759 if (classie.hasClass(document.body, 'hmenu-center') && i === 1) continue; 760 if (!classie.hasClass(masthead, 'masthead-vertical')) { 761 menuHeight = menuHeight + outerHeight(mainmenu[i]); 762 } else menuHeight = 0; 763 764 if (isIE && first) { 765 getDivChildren(mainmenu[i], '.menu-horizontal-inner', function(innerMenu, i) { 766 innerMenu.style.height = menuHeight + 'px'; 767 }); 768 } 769 770 if (classie.hasClass(mainmenu[i].parentNode, 'menu-transparent')) { 771 transmenuHeight += menuHeight; 772 } 773 } 774 775 for (var j = 0; j < secmenu.length; j++) { 776 secmenuHeight += outerHeight(secmenu[j]); 777 } 778 menuHeight += secmenuHeight; 779 } else { 780 menuHeight = UNCODE.menuMobileHeight; 781 if (isMobileTransparent) { 782 for (var i = 0; i < mainmenu.length; i++) { 783 if (classie.hasClass(mainmenu[i].parentNode, 'menu-transparent')) { 784 transmenuHeight += menuHeight; 785 } 786 } 787 } 788 var search_box = document.querySelectorAll('.search-icon .drop-menu'); 789 for (var i = 0; i < search_box.length; i++) { 790 search_box[i].removeAttribute('style'); 791 } 792 } 793 794 795 if (classie.hasClass(document.documentElement, 'admin-mode')) { 796 adminBar = document.getElementById("wpadminbar"); 797 if (wwidth > 600) { 798 if (adminBar != null) adminBarHeight = outerHeight(adminBar); 799 else { 800 if (wwidth > 782) adminBarHeight = 32; 801 else adminBarHeight = 46; 802 } 803 } else adminBarHeight = 0; 804 } 805 UNCODE.adminBarHeight = adminBarHeight; 806 UNCODE.menuHeight = menuHeight; 807 808 if ( UNCODE.isFullPage ) { 809 if ( UNCODE.adminBarHeight > 0 ) 810 document.body.style.marginTop = ( ( UNCODE.adminBarHeight + UNCODE.bodyBorder ) * -1 ) + 'px'; 811 812 document.body.style.paddingTop = ( UNCODE.adminBarHeight + UNCODE.bodyBorder ) + 'px'; 813 } 814 815 if (masthead != undefined) { 816 //masthead.parentNode.style.height = menuHeight + 'px'; 817 if (classie.hasClass(masthead, 'menu-transparent')) { 818 if (wwidth > mediaQuery) masthead.parentNode.style.height = '0px'; 819 } 820 } 821 822 if (typeof menuhide == 'object' && menuhide != null && mainmenu[0] != undefined) { 823 var sticky_element = (typeof mainmenu.item === 'undefined' ? ((wwidth > mediaQuery) ? mainmenu[0] : mainmenu[1]) : mainmenu[0]); 824 if (sticky_element.style.top != '') { 825 sticky_element.style.top = UNCODE.bodyBorder + 'px' 826 } 827 } 828 829 }, 830 centerSplitMenu = function() { 831 if (wwidth > mediaQuery && mainNavMenu) { 832 if (mainNavMenu.style.left == '') { 833 mainNavMenu.style.left = '0px'; 834 var logoPos = logo.parentNode.getBoundingClientRect(); 835 mainNavMenu.style.left = (wwidth / 2) - (logoPos.left + (logoPos.width / 2) ) + 'px'; 836 mainNavWrapper.style.opacity = '1'; 837 } 838 mainNavWrapper.style.opacity = '1'; 839 } 840 }, 841 initHeader = function() { 842 UNCODE.adaptive(); 843 headerHeight('.header-wrapper'); 844 845 parallaxHeaders = document.querySelectorAll('.header-parallax > .header-bg-wrapper > .header-bg'); 846 header = document.querySelectorAll('.header-wrapper.header-uncode-block, .header-wrapper.header-revslider, .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 .col-lg-12 .uncoltable'); 847 headerWithOpacity = document.querySelectorAll('.header-scroll-opacity'); 848 pageHeader = document.getElementById("page-header"); 849 if (pageHeader != undefined) { 850 var backs = pageHeader.querySelectorAll('.header-bg'), 851 backsCarousel = pageHeader.querySelectorAll('.header-uncode-block .background-inner'), 852 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; 853 if (backs.length == 0 && backsCarousel.length == 0) { 854 pageHeader.setAttribute('data-imgready', 'true'); 855 } else { 856 if (backsCarousel.length) { 857 for (var j = 0; j < backsCarousel.length; j++) { 858 if (j == 0) { 859 if (!!backsCarousel[j].style.backgroundImage && backsCarousel[j].style.backgroundImage !== void 0) { 860 var url = (backsCarousel[j].style.backgroundImage).match(uri_pattern), 861 image = new Image(); 862 image.onload = function() { 863 pageHeader.setAttribute('data-imgready', 'true'); 864 }; 865 image.src = url[0]; 866 } else { 867 pageHeader.setAttribute('data-imgready', 'true'); 868 } 869 } 870 } 871 } else { 872 for (var i = 0; i < backs.length; i++) { 873 if (i == 0) { 874 if (!!backs[i].style.backgroundImage && backs[i].style.backgroundImage !== void 0) { 875 var url = (backs[i].style.backgroundImage).match(uri_pattern), 876 image = new Image(); 877 image.onload = function() { 878 pageHeader.setAttribute('data-imgready', 'true'); 879 }; 880 image.src = url[0]; 881 } else { 882 pageHeader.setAttribute('data-imgready', 'true'); 883 } 884 } 885 } 886 } 887 } 888 } 889 890 if (masthead != undefined && !classie.hasClass(masthead, 'masthead-vert
890ical')) { 891 if (header.length) { 892 masthead.parentNode.style.height = menuHeight + 'px'; 893 if (menuwrapper[0] != undefined) classie.addClass(menuwrapper[0], 'with-header'); 894 for (var j = 0; j < header.length; j++) { 895 var headerel = header[j], 896 closestStyle = getClosest(headerel, 'style-light'); 897 if (closestStyle != null && classie.hasClass(closestStyle, 'style-light')) switchColorsMenu(0, 'light'); 898 else if (getClosest(headerel, 'style-dark') != null) switchColorsMenu(0, 'dark'); 899 else { 900 if (masthead.style.opacity !== 1) masthead.style.opacity = 1; 901 } 902 if (classie.hasClass(masthead, 'menu-transparent')) { 903 if (isMobileTransparent || wwidth > mediaQuery) { 904 masthead.parentNode.style.height = '0px'; 905 if (classie.hasClass(masthead, 'menu-add-padding')) { 906 var headerBlock = getClosest(headerel, 'header-uncode-block'); 907 if (headerBlock != null) { 908 var innerRows = headerel.querySelectorAll('.column_parent > .uncol > .uncoltable > .uncell > .uncont, .uncode-slider .column_child > .uncol > .uncoltable > .uncell > .uncont'); 909 for (var k = 0; k < innerRows.length; k++) { 910 if (innerRows[k] != undefined) { 911 if (wwidth > mediaQuery) innerRows[k].style.paddingTop = transmenuHeight + 'px'; 912 else innerRows[k].style.paddingTop = (transmenuHeight - mastheadMobilePaddingTop) + 'px'; 913 } 914 } 915 } else { 916 getDivChildren(headerel, '.header-content', function(headerContent, i) { 917 if (wwidth > mediaQuery) headerContent.style.paddingTop = transmenuHeight + 'px'; 918 else headerContent.style.paddingTop = (transmenuHeight - mastheadMobilePaddingTop) + 'px'; 919 }); 920 } 921 } 922 } 923 } 924 } 925 } else { 926 if (menuwrapper[0] != undefined) classie.addClass(menuwrapper[0], 'no-header'); 927 classie.removeClass(masthead, 'menu-transparent'); 928 transmenuHeight = 0; 929 isMobileTransparent = false; 930 } 931 } else { 932 isMobileTransparent = false; 933 } 934 if (!transmenuel.length) isMobileTransparent = false; 935 bodyTop = document.documentElement['scrollTop'] || document.body['scrollTop']; 936 UNCODE.bodyTop = bodyTop; 937 if (!classie.hasClass(document.body, 'vmenu')) 938 initBox(); 939 scrollFunction(); 940 showHideScrollup(bodyTop); 941 }, 942 initRow = function(currentRow) { 943 UNCODE.adaptive(); 944 var el = currentRow.parentNode.parentNode.getAttribute("data-parent") == 'true' ? currentRow.parentNode : currentRow.parentNode.parentNode, 945 rowParent = el.parentNode, 946 rowInner = currentRow.parentNode, 947 percentHeight = el.getAttribute("data-height-ratio"), 948 minHeight = el.getAttribute("data-minheight"), 949 calculateHeight, 950 calculatePadding = 0, 951 isHeader = false, 952 isFirst = false, 953 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; 954 955 /** Add class to the row when contains responsive column size */ 956 getDivChildren(el.parentNode, '.column_parent, .column_child', function(obj, i, total) { 957 if ((obj.className).indexOf("col-md-") > - 1) classie.addClass(obj.parentNode, 'cols-md-responsive'); 958 if ((obj.className).indexOf("col-sm-") > - 1 && (obj.className).indexOf("col-sm-clear") == - 1) classie.addClass(obj.parentNode, 'cols-sm-responsive'); 959 }); 960 961 setRowHeight(el); 962 963 var elements = 0; 964 getDivChildren(el, '.row-internal .background-inner', function(obj, i, total) { 965 elements++; 966 if (i == 0) { 967 if (!!obj.style.backgroundImage && obj.style.backgroundImage !== void 0) { 968 var url = (obj.style.backgroundImage).match(uri_pattern), 969 image = new Image(); 970 image.onload = function() { 971 el.setAttribute('data-imgready', 'true'); 972 el.dispatchEvent(new CustomEvent('imgLoaded')); 973 }; 974 image.src = url[0]; 975 } else { 976 el.setAttribute('data-imgready', 'true'); 977 el.dispatchEvent(new CustomEvent('imgLoaded')); 978 } 979 } 980 }); 981 if (elements == 0) { 982 el.setAttribute('data-imgready', 'true'); 983 } 984 985 /** init parallax is not mobile */ 986 if ( ! UNCODE.isFullPage ) { 987 bodyTop = document.documentElement['scrollTop'] || document.body['scrollTop']; 988 kenburnsRows = el.parentNode.parentNode.querySelectorAll('.with-kburns > .row-background > .background-wrapper, .with-kburns > .header-bg-wrapper, .with-kburns > .fp-tableCell > .row-background > .background-wrapper, .with-kburns > .fp-tableCell > .fp-scrollable > .fp-scroller > .row-background > .background-wrapper'); 989 kenburnsCols = el.querySelectorAll('.with-kburns > .column-background > .background-wrapper'); 990 if (!UNCODE.isMobile) {
991 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'); 992 parallaxCols = el.querySelectorAll('.with-parallax > .column-background > .background-wrapper'); 993 visibleRows = el.parentNode.parentNode; 994 parallaxRowCol(bodyTop); 995 visibleRowCol(bodyTop); 996 } else { 997 kenburnsRowCol(bodyTop); 998 } 999 } 1000 }, 1001 setRowHeight = function(container, forced, resized) { 1002 var currentTallest = 0, 1003 percentHeight = 0, 1004 minHeight = 0, 1005 el, 1006 child, 1007 hasSubCols = false; 1008 if (container.length == undefined) { 1009 container = [container]; 1010 } 1011 // Loop for each container element to match their heights 1012 for (var i = 0; i < container.length; i++) { 1013 var el = container[i], 1014 $row = el, 1015 totalHeight = 0, 1016 colsArray = new Array(), 1017 calculatePadding = 0, 1018 $rowParent = $row.parentNode, 1019 isHeader = false, 1020 isFirst = false; 1021 $row.oversized = false; 1022 percentHeight = el.getAttribute("data-height-ratio"); 1023 minHeight = el.getAttribute("data-minheight"); 1024 child = (el.firstElementChild || el.firstChild); 1025 var childHeight = outerHeight(child); 1026 /** window height without header **/ 1027 if (!!percentHeight || !!minHeight || forced || (isIE && classie.hasClass(el, 'unequal')) ) { 1028 child.style.height = ''; 1029 if (!!percentHeight) { 1030 if (percentHeight == 'full') { 1031 currentTallest = parseInt(wheight); 1032 } else { 1033 currentTallest = parseInt((wheight * percentHeight) / 100); 1034 } 1035 } else { 1036 currentTallest = el.clientHeight; 1037 } 1038 1039 if (!!minHeight) { 1040 if (currentTallest < minHeight || currentTallest == undefined) currentTallest = parseInt(minHeight); 1041 } 1042 1043 var computedStyleRow = getComputedStyle(el), 1044 computedStyleRowParent = getComputedStyle($rowParent); 1045 calculatePadding -= (parseFloat(computedStyleRow.paddingTop) + parseFloat(computedStyleRowParent.paddingTop)); 1046 calculatePadding -= (parseFloat(computedStyleRow.paddingBottom) + parseFloat(computedStyleRowParent.paddingBottom)); 1047 1048 if (getClosest(el, 'header-uncode-block') != null) { 1049 el.setAttribute('data-row-header', 'true'); 1050 isHeader = true; 1051 } else { 1052 if (pageHeader == null) { 1053 var prevRow = $rowParent.previousSibling; 1054 if (prevRow != null && prevRow.innerText == 'UNCODE.initHeader();') { 1055 isFirst = true; 1056 } 1057 } 1058 } 1059 1060 if (classie.hasClass(el, 'row-slider')) { 1061 percentHeight = el.getAttribute("data-height-ratio"); 1062 minHeight = el.getAttribute("data-minheight"); 1063 if (percentHeight == 'full') { 1064 currentTallest = parseInt(wheight); 1065 } else { 1066 currentTallest = parseInt((wheight * percentHeight) / 100); 1067 } 1068 1069 if (isHeader || isFirst) { 1070 if (isMobileTransparent || wwidth > mediaQuery) currentTallest -= menuHeight - transmenuHeight; 1071 else currentTallest -= menuHeight - secmenuHeight; 1072 currentTallest += calculatePadding; 1073 } else { 1074 if (isMobileTransparent || wwidth > mediaQuery) currentTallest += calculatePadding; 1075 else currentTallest = 'auto'; 1076 } 1077 1078 getDivChildren(el, '.owl-carousel', function(owl, i) { 1079 owl.style.height = (currentTallest == 'auto' ? 'auto' : currentTallest + 'px'); 1080 if (isIE) { 1081 getDivChildren(owl, '.owl-stage', function(owlIn, i) { 1082 owlIn.style.height = (currentTallest == 'auto' ? '100%' : currentTallest + 'px'); 1083 }); 1084 } 1085 }); 1086 if ( UNCODE.isFullPageSnap || classie.hasClass(masthead, 'menu-transparent') ) 1087 continue; 1088 else { 1089 if ( classie.hasClass(document.body, 'uncode-fp-menu-hide') ) { 1090 $rowParent.parentNode.style.paddingTop = menuHeight + 'px'; 1091 } 1092 } 1093 } else { 1094 if (isHeader || isFirst || UNCODE.isFullPage ) { 1095 if ( !( UNCODE.isFullPage && !classie.hasClass(masthead, 'menu-transparent') && classie.hasClass(document.body, 'uncode-fp-menu-hide') && !isHeader && !isFirst ) ) {
1096 if (isMobileTransparent || wwidth > mediaQuery) currentTallest -= menuHeight - transmenuHeight; 1097 else currentTallest -= menuHeight - secmenuHeight; 1098 } 1099 currentTallest += calculatePadding; 1100 if ( UNCODE.isFullPage && classie.hasClass(document.body, 'uncode-scroll-safe-padding') && classie.hasClass(masthead, 'menu-transparent') && !classie.hasClass(document.body, 'uncode-fp-menu-hide') ) { 1101 var safeMenuHeight = parseFloat(document.body.getAttribute("data-additional-padding")) + parseFloat(menuHeight); 1102 if ( (" " + child.parentNode.className + " ").replace(/[\n\t]/g, " ").indexOf("-top-padding ") < 0 || classie.hasClass(child.parentNode, 'single-top-padding') ) { 1103 classie.addClass(child.parentNode, 'fp-safe-padding-top'); 1104 child.parentNode.style.paddingTop = safeMenuHeight + 'px'; 1105 } 1106 if ( (" " + child.parentNode.className + " ").replace(/[\n\t]/g, " ").indexOf("-bottom-padding ") < 0 || classie.hasClass(child.parentNode, 'single-bottom-padding') ) { 1107 classie.addClass(child.parentNode, 'fp-safe-padding-bottom'); 1108 child.parentNode.style.paddingBottom = safeMenuHeight + 'px'; 1109 } 1110 } 1111 if ( !classie.hasClass(masthead, 'menu-transparent') && classie.hasClass(document.body, 'uncode-fp-menu-hide') && ( isFirst || isHeader ) ) 1112 $rowParent.parentNode.style.paddingTop = menuHeight + 'px'; 1113 1114 } else { 1115 if (wwidth > mediaQuery) currentTallest += calculatePadding; 1116 else currentTallest = 'auto'; 1117 1118 } 1119 } 1120 if ( UNCODE.isFullPage ) { 1121 currentTallest -= UNCODE.adminBarHeight; 1122 } 1123 if (!!minHeight) { 1124 if (currentTallest < minHeight || currentTallest == 'auto') currentTallest = parseInt(minHeight); 1125 } 1126 1127 child.style.height = (currentTallest == 'auto' ? 'auto' : currentTallest + 'px'); 1128 } else { 1129 currentTallest = 0; 1130 } 1131 1132 if (wwidth > mediaQuery) { 1133 1134 getDivChildren(el, '.column_parent', function(col, i, total) { 1135 var $col = col, 1136 $colHeight = 0, 1137 $colDiff = 0, 1138 $colPercDiff = 100; 1139 $col.oversized = false; 1140 $col.forceHeight = currentTallest; 1141 currentTallest = child.clientHeight; 1142 if ((isHeader || isFirst) && currentTallest != 'auto') currentTallest -= transmenuHeight; 1143 var getFirstCol = null, 1144 getMargin = 0, 1145 getSubMargin = 0; 1146 getDivChildren(col, '.row-child', function(obj, i, total) { 1147 var $colChild = obj, 1148 $colParent = $colChild.parentNode, 1149 computedStyleCol = getComputedStyle($colParent); 1150 parseFloat(computedStyleCol.marginTop); 1151 getSubMargin += parseFloat(computedStyleCol.marginTop); 1152 }); 1153 currentTallest += getSubMargin; 1154 getDivChildren(col, '.row-child', function(obj, i, total) { 1155 var $colChild = obj, 1156 $colInner = $colChild.children[0], 1157 $colParent = $colChild.parentNode, 1158 $uncont = $colParent.parentNode; 1159 if (i == 0 && total > 1) getFirstCol = $colInner; 1160 $colChild.oversized = false; 1161 percentHeight = $colChild.getAttribute("data-height"); 1162 minHeight = $colChild.getAttribute("data-minheight"); 1163 if (percentHeight != null || minHeight != null) { 1164 $colInner.style.height = ''; 1165 $colParent.style.height = 'auto'; 1166 $uncont.style.height = '100%'; 1167 $colChild.removeAttribute("style"); 1168 var newHeight = (percentHeight != null) ? Math.ceil((currentTallest) * (percentHeight / 100)) : parseInt(minHeight); 1169 var computedStyleCol = getComputedStyle($colParent); 1170 parseFloat(computedStyleCol.marginTop); 1171 getMargin = parseFloat(computedStyleCol.marginTop); 1172 newHeight -= (getMargin); 1173 $colPercDiff -= (percentHeight != null) ? percentHeight : 0; 1174 if (currentTallest > newHeight) { 1175 var getColHeight = outerHeight($colChild); 1176 if (getColHeight > newHeight) { 1177 $colHeight += getColHeight; 1178 $colDiff += getColHeight; 1179 $colChild.oversized = true; 1180 $col.oversized = true; 1181 $row.oversized = true; 1182 } else { 1183 $colHeight += newHeight; 1184 $colInner.style.height = newHeight + 'px'; 1185 } 1186 } 1187 } else { 1188 $colHeight += outerHeight($colChild); 1189 } 1190 }); 1191 if (getFirstCol != null) { 1192 getFirstCol.style.height = (parseFloat(getFirstCol.style.height) - getMargin) + 'px'; 1193 } 1194 colsArray.push({ 1195 colHeight: $colHeight,
1196 colDiv: $col 1197 }); 1198 $col.colDiff = $colDiff; 1199 $col.colPercDiff = $colPercDiff; 1200 }); 1201 1202 if ($row.oversized) { 1203 child.style.height = ''; 1204 colsArray.sort(function(a, b) { 1205 if (a.colHeight < b.colHeight) return 1; 1206 if (a.colHeight > b.colHeight) return -1; 1207 return 0; 1208 }); 1209 var $totalHeight = 0; 1210 colsArray.forEach(function(col) { 1211 var $col = col.colDiv, 1212 $colHeight = col.colHeight; 1213 getDivChildren($col, '.row-child', function(obj, i, total) { 1214 var $colChild = obj, 1215 $colInner = $colChild.children[0], 1216 percentHeight = $colChild.getAttribute("data-height"), 1217 $colParent = $colChild.parentNode, 1218 $uncont = $colParent.parentNode, 1219 newHeight; 1220 1221 $colHeight = $col.forceHeight - $col.colDiff; 1222 if (percentHeight != null) { 1223 if ($colHeight > 0) { 1224 if ($col.oversized) { 1225 if (!$colChild.oversized) { 1226 newHeight = Math.ceil(($colHeight) * (percentHeight / $col.colPercDiff)); 1227 if (i == total - 1 && total > 1) { 1228 $uncont.style.height = 'auto'; 1229 $colChild.style.display = 'none'; 1230 newHeight = outerHeight($col.parentNode) - outerHeight($uncont); 1231 $uncont.style.height = '100%'; 1232 $colChild.style.display = 'table'; 1233 } 1234 if (newHeight == 0) newHeight = Math.ceil(($col.forceHeight) * (percentHeight / 100)); 1235 $colInner.style.height = newHeight + 'px'; 1236 } 1237 } else { 1238 if ($totalHeight == 0) newHeight = Math.ceil(($colHeight) * (percentHeight / $col.colPercDiff)); 1239 else { 1240 newHeight = Math.ceil(($totalHeight) * (percentHeight / $col.colPercDiff)); 1241 } 1242 if (i == total - 1 && total > 1) { 1243 $uncont.style.height = 'auto'; 1244 $colChild.style.display = 'none'; 1245 newHeight = outerHeight($col.parentNode) - outerHeight($uncont); 1246 $uncont.style.height = '100%'; 1247 $colChild.style.display = 'table'; 1248 } 1249 $colInner.style.height = newHeight + 'px'; 1250 } 1251 } else { 1252 if ($colChild.oversized) { 1253 if ($totalHeight == 0) newHeight = Math.ceil(($colHeight) * (percentHeight / $col.colPercDiff)); 1254 else { 1255 if ($col.colPercDiff == 0) $col.colPercDiff = 100; 1256 newHeight = Math.ceil(($totalHeight) * (percentHeight / $col.colPercDiff)); 1257 } 1258 if (i == total - 1 && total > 1) { 1259 $uncont.style.height = 'auto'; 1260 $colChild.style.display = 'none'; 1261 newHeight = outerHeight($col.parentNode) - outerHeight($uncont); 1262 $uncont.style.height = '100%'; 1263 $colChild.style.display = 'table'; 1264 } 1265 $colInner.style.height = newHeight + 'px'; 1266 } 1267 } 1268 } 1269 }); 1270 var uncell = $col.getElementsByClassName('uncell'); 1271 if (uncell[0] != undefined && $totalHeight == 0) $totalHeight = outerHeight(uncell[0]); 1272 }); 1273 } 1274 if (isFF) { 1275 getDivChildren(el, '.uncoltable', function(col, i, total) { 1276 if (col.style.minHeight != '') { 1277 col.style.height = ''; 1278 } 1279 }); 1280 } 1281 if (resized) { 1282 getDivChildren(el, '.row-child > .row-inner', function(obj, k, total) { 1283 if (obj.style.height == '') { 1284 if (wwidth > mediaQueryMobile) { 1285 var getStyle = (window.getComputedStyle((obj.parentNode), null)), 1286 getInnerHeight = (parseInt(obj.parentNode.clientHeight) - parseInt(getStyle.paddingTop) - parseInt(getStyle.paddingBottom)); 1287 obj.style.height = getInnerHeight + 1 + 'px'; 1288 obj.style.marginBottom = '-1px'; 1289 } 1290 } 1291 }); 1292 getDivChildren(el, '.row-parent > .row-inner', function(obj, k, total) { 1293 if (obj.style.height != '') { 1294 var getStyle = (window.getComputedStyle((obj.parentNode), null)), 1295 getInnerHeight = (parseInt(obj.parentNode.clientHeight) - parseInt(getStyle.paddingTop) - parseInt(getStyle.paddingBottom)), 1296 getTempHeight = parseInt(obj.style.height); 1297 if (getInnerHeight > getTempHeight) { 1298 obj.style.height = getInnerHeight + 1 + 'px'; 1299 obj.style.marginBottom = '-1px'; 1300 } 1301 } 1302 }); 1303 } 1304 } else { 1305 if (isFF) { 1306 getDivChildren(el, '.uncoltable', function(col, i, total) { 1307 if (col.style.minHeight != '') { 1308 col.style.height = ''; 1309 col.style.height = outerHeight(col.parentNode) + 'px'; 1310 } 1311 }); 1312 } 1313 if (isIE && (wwidth > mediaQueryMobile)) { 1314 if (child.style.height == 'auto') { 1315 child.style.height = outerHeight(child) + 'px'; 1316 } 1317 } 1318 } 1319 if (isFF) { 1320 var sliderColumnFix = document.querySelector('.uncode-slider .row-inner > .column_child:only-child'); 1321 if (sliderColumnFix != null) { 1322 if (wwidth > mediaQuery) { 1323 sliderColumnFix.style.setProperty("height", ""); 1324 } else { 1325 sliderColumnFix.style.setProperty("height", ""); 1326 sliderColumnFix.style.setProperty("height", outerHeight(sliderColumnFix.parentNode) + "px", "important"); 1327 } 1328 } 1329 } 1330 }; 1331 }, 1332 headerHeight = function(container) {
1333 forEachElement(container, function(el, i) { 1334 var getHeight = el.getAttribute("data-height"), 1335 newHeight = ((wheight * getHeight) / 100); 1336 if (getHeight != 'fixed' && newHeight != 0) { 1337 if (isMobileTransparent || wwidth > mediaQuery) newHeight -= menuHeight - transmenuHeight; 1338 else newHeight -= menuHeight - secmenuHeight; 1339 el.style.height = newHeight + 'px'; 1340 } 1341 }); 1342 if (masthead != undefined) { 1343 masthead.parentNode.style.height = menuHeight + 'px'; 1344 if (header != undefined && header.length) { 1345 if (classie.hasClass(masthead, 'menu-transparent')) { 1346 if (isMobileTransparent || wwidth > mediaQuery) { 1347 masthead.parentNode.style.height = '0px'; 1348 if (classie.hasClass(masthead, 'menu-add-padding')) { 1349 for (var j = 0; j < header.length; j++) { 1350 var headerel = header[j]; 1351 var headerBlock = getClosest(headerel, 'header-uncode-block'); 1352 if (headerBlock != null) { 1353 var innerRows = headerel.querySelectorAll('.column_parent > .uncol > .uncoltable > .uncell > .uncont, .uncode-slider .column_child > .uncol > .uncoltable > .uncell > .uncont'); 1354 for (var k = 0; k < innerRows.length; k++) { 1355 if (innerRows[k] != undefined) { 1356 if (wwidth > mediaQuery) innerRows[k].style.paddingTop = transmenuHeight + 'px'; 1357 else innerRows[k].style.paddingTop = (transmenuHeight - mastheadMobilePaddingTop) + 'px'; 1358 } 1359 } 1360 } else { 1361 getDivChildren(headerel, '.header-content', function(headerContent, i) { 1362 if (wwidth > mediaQuery) headerContent.style.paddingTop = transmenuHeight + 'px'; 1363 else headerContent.style.paddingTop = (transmenuHeight - mastheadMobilePaddingTop) + 'px'; 1364 }); 1365 } 1366 } 1367 } 1368 } 1369 } 1370 } 1371 } 1372 }, 1373 initVideoComponent = function(container, classTarget) { 1374 getDivChildren(container, classTarget, function(el, i) { 1375 var width = outerWidth(el), 1376 pWidth, // player width, to be defined 1377 height = outerHeight(el), 1378 pHeight, // player height, tbd 1379 $tubularPlayer = (el.getElementsByTagName('iframe').length == 1) ? el.getElementsByTagName('iframe') : el.getElementsByTagName('video'), 1380 ratio = (el.getAttribute("data-ratio") != null) ? Number(el.getAttribute("data-ratio")) : $tubularPlayer[0].getAttribute("data-ratio"), 1381 heightOffset = 80, 1382 widthOffset = heightOffset * ratio; 1383 // when screen aspect ratio differs from video, video must center and underlay one dimension 1384 if ($tubularPlayer[0] != undefined) { 1385 if (width / ratio < height) { // if new video height < window height (gap underneath) 1386 pWidth = Math.ceil((height + heightOffset) * ratio); // get new player width 1387 $tubularPlayer[0].style.width = pWidth + widthOffset + 'px'; 1388 $tubularPlayer[0].style.height = height + heightOffset + 'px'; 1389 $tubularPlayer[0].style.left = ((width - pWidth) / 2) - (widthOffset / 2) + 'px'; 1390 $tubularPlayer[0].style.top = '-' + (heightOffset / 2) + 'px'; 1391 $tubularPlayer[0].style.position = 'absolute'; 1392 } else { // new video width < window width (gap to right) 1393 pHeight = Math.ceil(width / ratio); // get new player height 1394 $tubularPlayer[0].style.width = width + widthOffset + 'px'; 1395 $tubularPlayer[0].style.height = pHeight + heightOffset + 'px'; 1396 $tubularPlayer[0].style.left = '-' + (widthOffset / 2) + 'px'; 1397 $tubularPlayer[0].style.top = ((height - pHeight) / 2) - (heightOffset / 2) + 'px'; 1398 $tubularPlayer[0].style.position = 'absolute'; 1399 } 1400 } 1401 }); 1402 }, 1403 init_overlay = function() { 1404 var triggerButton, 1405 closeButtons = new Array(); 1406 function toggleOverlay(btn) { 1407 Array.prototype.forEach.call(document.querySelectorAll('div.overlay'), function(overlay) { 1408 if (btn.getAttribute('data-area') == overlay.getAttribute('data-area')) { 1409 var container = document.querySelector('div.' + btn.getAttribute('data-container')), 1410 inputField = overlay.querySelector('.search-field'); 1411 if (classie.has(overlay, 'open')) { 1412 window.dispatchEvent(menuClose); 1413 overlayOpened = false;
1414 classie.remove(overlay, 'open'); 1415 classie.remove(container, 'overlay-open'); 1416 classie.add(overlay, 'close'); 1417 classie.remove(overlay, 'open-items'); 1418 var onEndTransitionFn = function(ev) { 1419 if (transitionEvent) { 1420 if (ev.propertyName !== 'visibility') return; 1421 this.removeEventListener(transitionEvent, onEndTransitionFn); 1422 } 1423 classie.remove(overlay, 'close'); 1424 }; 1425 if (transitionEvent) { 1426 overlay.addEventListener(transitionEvent, onEndTransitionFn); 1427 } else { 1428 onEndTransitionFn(); 1429 } 1430 } else if (!classie.has(overlay, 'close')) { 1431 window.dispatchEvent(menuOpen); 1432 overlayOpened = true; 1433 classie.add(overlay, 'open'); 1434 classie.add(container, 'overlay-open'); 1435 if (jQuery('body.menu-overlay').length == 0) { 1436 setTimeout(function() { 1437 inputField.focus(); 1438 }, 1000); 1439 } 1440 setTimeout(function() { 1441 if (classie.has(overlay, 'overlay-sequential')) classie.add(overlay, 'open-items'); 1442 }, 800); 1443 } 1444 } 1445 }); 1446 1447 if (classie.hasClass(btn, 'search-icon') || classie.hasClass(btn, 'menu-close-search')) return; 1448 1449 if (classie.hasClass(triggerButton, 'close')) { 1450 UNCODE.menuOpened = false; 1451 classie.removeClass(triggerButton, 'close'); 1452 classie.addClass(triggerButton, 'closing'); 1453 Array.prototype.forEach.call(closeButtons, function(closeButton) { 1454 if (!classie.hasClass(closeButton, 'menu-close-search')) { 1455 classie.removeClass(closeButton, 'close'); 1456 classie.addClass(closeButton, 'closing'); 1457 } 1458 }); 1459 setTimeout(function() { 1460 classie.removeClass(triggerButton, 'closing'); 1461 triggerButton.style.opacity = 1; 1462 Array.prototype.forEach.call(closeButtons, function(closeButton) { 1463 if (!classie.hasClass(closeButton, 'menu-close-search')) { 1464 classie.removeClass(closeButton, 'closing'); 1465 closeButton.style.opacity = 0; 1466 } 1467 }); 1468 }, 800); 1469 } else { 1470 UNCODE.menuOpened = true; 1471 triggerButton.style.opacity = 0; 1472 var getBtnRect = !classie.hasClass(triggerButton, 'search-icon') ? triggerButton.getBoundingClientRect() : null; 1473 Array.prototype.forEach.call(closeButtons, function(closeButton) { 1474 if (!classie.hasClass(closeButton, 'menu-close-search')) { 1475 classie.addClass(triggerButton, 'close'); 1476 if (getBtnRect != null) closeButton.setAttribute('style', 'top:' + getBtnRect.top + 'px; left:'+ getBtnRect.left + 'px !important'); 1477 classie.addClass(closeButton, 'close'); 1478 closeButton.style.opacity = 1; 1479 } 1480 }); 1481 window.addEventListener("resize", function() { 1482 positionCloseBtn(triggerButton, closeButtons); 1483 }); 1484 } 1485 } 1486 function positionCloseBtn(triggerButton, closeButtons){ 1487 var getBtnRect = !classie.hasClass(triggerButton, 'search-icon') ? triggerButton.getBoundingClientRect() : null; 1488 Array.prototype.forEach.call(closeButtons, function(closeButton) { 1489 if (!classie.hasClass(closeButton, 'menu-close-search')) { 1490 if (getBtnRect != null) closeButton.setAttribute('style', 'top:' + getBtnRect.top + 'px; left:'+ getBtnRect.left + 'px !important'); 1491 closeButton.style.opacity = 1; 1492 } 1493 }); 1494 } 1495 (function bindEscape() { 1496 document.onkeydown = function(evt) { 1497 evt = evt || window.event; 1498 var isEscape = false;
1499 if ("key" in evt) { 1500 isEscape = (evt.key == "Escape" || evt.key == "Esc"); 1501 } else { 1502 isEscape = (evt.keyCode == 27); 1503 } 1504 if (isEscape && overlayOpened) { 1505 Array.prototype.forEach.call(closeButtons, function(closeButton) { 1506 if (classie.hasClass(closeButton, 'overlay-close') && classie.hasClass(closeButton, 'menu-button-overlay')) { 1507 closeButton.click(); 1508 } 1509 }); 1510 } 1511 }; 1512 })(); 1513 Array.prototype.forEach.call(document.querySelectorAll('.trigger-overlay'), function(triggerBttn) { 1514 if (UNCODE.menuOpened) return; 1515 triggerBttn.addEventListener('click', function(e) { 1516 triggerButton = e.currentTarget; 1517 if (wwidth < mediaQuery && classie.hasClass(triggerButton, 'search-icon')) { 1518 return true; 1519 } else { 1520 e.stopPropagation(); 1521 if (wwidth > mediaQuery) toggleOverlay(triggerButton); 1522 else { 1523 if (classie.addClass(triggerButton, 'search-icon')) return true; 1524 } 1525 e.preventDefault(); 1526 return false; 1527 } 1528 }, false); 1529 }); 1530 Array.prototype.forEach.call(document.querySelectorAll('.overlay-close'), function(closeBttn) { 1531 closeButtons.push(closeBttn); 1532 closeBttn.addEventListener('click', function(e) { 1533 if (wwidth > mediaQuery) toggleOverlay(closeBttn); 1534 e.preventDefault(); 1535 return false; 1536 }, false); 1537 }); 1538 }, 1539 /** All scrolling functions - Begin */ 1540 /** Shrink menu **/ 1541 shrinkMenu = function(bodyTop) { 1542 var logoShrink, 1543 offset = 100; 1544 for (var i = 0; i < logoel.length; i++) { 1545 if (((secmenuHeight == 0) ? bodyTop > menuHeight : bodyTop > secmenuHeight + offset) && !classie.hasClass(logoel[i], 'shrinked') && (wwidth > mediaQuery)) { 1546 classie.addClass(logoel[i], 'shrinked'); 1547 if (logoMinScale != undefined) { 1548 logoShrink = logolink.children; 1549 Array.prototype.forEach.call(logoShrink, function(singleLogo) { 1550 singleLogo.style.height = logoMinScale + 'px'; 1551 singleLogo.style.lineHeight = logoMinScale + 'px'; 1552 if (classie.hasClass(singleLogo, 'text-logo')) singleLogo.style.fontSize = logoMinScale + 'px'; 1553 }); 1554 } 1555 setTimeout(function() { 1556 calculateMenuHeight(false); 1557 //window.dispatchEvent(new Event('resize')); 1558 }, 300); 1559 } else if ((((secmenuHeight == 0) ? bodyTop == 0 : bodyTop <= secmenuHeight + offset) || (wwidth < mediaQuery)) && classie.hasClass(logoel[i], 'shrinked')) { 1560 classie.removeClass(logoel[i], 'shrinked'); 1561 if (logoMinScale != undefined) { 1562 logoShrink = logolink.children; 1563 Array.prototype.forEach.call(logoShrink, function(singleLogo) { 1564 singleLogo.style.height = singleLogo.getAttribute('data-maxheight') + 'px'; 1565 singleLogo.style.lineHeight = singleLogo.getAttribute('data-maxheight') + 'px'; 1566 if (classie.hasClass(singleLogo, 'text-logo')) singleLogo.style.fontSize = singleLogo.getAttribute('data-maxheight') + 'px'; 1567 }); 1568 } 1569 setTimeout(function() { 1570 calculateMenuHeight(false); 1571 //window.dispatchEvent(new Event('resize')); 1572 }, 300); 1573 } 1574 } 1575 }, 1576 /** Switch colors menu **/ 1577 switchColorsMenu = function(bodyTop, style) { 1578 for (var i = 0; i < transmenuel.length; i++) { 1579 if (masthead.style.opacity !== 1) masthead.style.opacity = 1; 1580 if ((secmenuHeight == 0) ? bodyTop > menuHeight / 2 : bodyTop > secmenuHeight) { 1581 if (classie.hasClass(masthead, 'style-dark-original')) { 1582 logo.className = logo.className.replace("style-light", "style-dark"); 1583 } 1584 if (classie.hasClass(masthead, 'style-light-original')) { 1585 logo.className = logo.className.replace("style-dark", "style-light"); 1586 } 1587 if (style != undefined) { 1588 if (style == 'dark') { 1589 classie.removeClass(transmenuel[i], 'style-light-override'); 1590 } 1591 if (style == 'light') { 1592 classie.removeClass(transmenuel[i], 'style-dark-override'); 1593 } 1594 classie.addClass(transmenuel[i], 'style-' + style + '-override'); 1595 } 1596 } else { 1597 if (style != undefined) { 1598 if (style == 'dark') { 1599 classie.removeClass(transmenuel[i], 'style-light-override'); 1600 } 1601 if (style == 'light') { 1602 classie.removeClass(transmenuel[i], 'style-dark-override'); 1603 } 1604 classie.addClass(transmenuel[i], 'style-' + style + '-override'); 1605 } 1606 } 1607 } 1608 if (pageHeader != undefined) { 1609 if (style != undefined) { 1610 if (classie.hasClass(pageHeader, 'header-style-dark')) { 1611 classie.removeClass(pageHeader, 'header-style-dark'); 1612 } 1613 if (classie.hasClass(pageHeader, 'header-style-light')) { 1614 classie.removeClass(pageHeader, 'header-style-light'); 1615 } 1616 classie.addClass(pageHeader, 'header-style-' + style); 1617 } 1618 } 1619 }, 1620 /** VisibleRows **/ 1621 visibleRowCol = function(bodyTop) { 1622 if ( typeof visibleRows == 'object') { 1623 for (var i = 0; i < visibleRows.length; i++) { 1624 var section = visibleRows[i], 1625 sectionHeight = outerHeight(section), 1626 offSetTop = bodyTop + ( section != null ? section.getBoundingClientRect().top : 0 ), 1627 offSetPosition = wheight + bodyTop - offSetTop; 1628 if (offSetPosition > 0 && offSetPosition < (sectionHeight + wheight)) { 1629 classie.addClass($kenburnsInner[0], 'uncode-scroll-visible'); 1630 visibleRows[i].dispatchEvent(new CustomEvent('enter-row')); 1631 } else { 1632 classie.removeClass($kenburnsInner[0], 'uncode-scroll-visible'); 1633 visibleRows[i].dispatchEvent(new CustomEvent('exit-row')); 1634 } 1635 } 1636 } 1637 }, 1638 /** KenBurns **/ 1639 kenburnsRowCol = function(bodyTop) { 1640 var value; 1641 if ( typeof kenburnsRows == 'object' && kenburnsRows.length ) { 1642 for (var i = 0; i < kenburnsRows.length; i++) { 1643 var section = kenburnsRows[i].parentNode, 1644 sectionHeight = outerHeight(section), 1645 offSetTop = bodyTop + (section != null ? (classie.hasClass(section.parentNode.parentNode, 'owl-carousel') ? section.parentNode.parentNode.getBoundingClientRect().top : section.getBoundingClientRect().top) : 0), 1646 offSetPosition = wheight + bodyTop - offSetTop, 1647 $kenburnsInner = kenburnsRows[i].querySelectorAll('.background-inner, .header-bg'); 1648 if (offSetPosition > 0 && offSetPosition < (sectionHeight + wheight)) { 1649 classie.addClass($kenburnsInner[0], 'uncode-kburns'); 1650 $kenburnsInner[0].dispatchEvent(new CustomEvent('enter-kburns')); 1651 } else { 1652 classie.removeClass($kenburnsInner[0], 'uncode-kburns'); 1653 $kenburnsInner[0].dispatchEvent(new CustomEvent('exit-kburns')); 1654 } 1655 } 1656 } 1657 if ( typeof kenburnsCols == 'object' && kenburnsCols.length ) { 1658 for (var j = 0; j < kenburnsCols.length; j++) { 1659 var elm = kenburnsCols[j], 1660 $kenburnsInner = elm.querySelectorAll('.background-inner'); 1661 if (checkVisible(elm)) { 1662 classie.addClass($kenburnsInner[0], 'uncode-kburns'); 1663 $kenburnsInner[0].dispatchEvent(new CustomEvent('enter-kburns')); 1664 } else { 1665 classie.removeClass($kenburnsInner[0], 'uncode-kburns'); 1666 $kenburnsInner[0].dispatchEvent(new CustomEvent('exit-kburns')); 1667 } 1668 } 1669 } 1670 }, 1671 /** Parallax Rows **/
1672 parallaxRowCol = function(bodyTop) { 1673 var value; 1674 if (typeof parallaxRows == 'object') { 1675 for (var i = 0; i < parallaxRows.length; i++) { 1676 var section = parallaxRows[i].parentNode, 1677 thisHeight = outerHeight(parallaxRows[i]), 1678 sectionHeight = outerHeight(section), 1679 offSetTop = bodyTop + (section != null ? (classie.hasClass(section.parentNode.parentNode, 'owl-carousel') ? section.parentNode.parentNode.getBoundingClientRect().top : section.getBoundingClientRect().top) : 0), 1680 offSetPosition = wheight + bodyTop - offSetTop; 1681 if (offSetPosition > 0 && offSetPosition < (sectionHeight + wheight)) { 1682 value = ((offSetPosition - wheight) * speedDivider); 1683 if (Math.abs(value) < (thisHeight - sectionHeight)) { 1684 translateElement(parallaxRows[i], value); 1685 } else { 1686 translateElement(parallaxRows[i], thisHeight - sectionHeight); 1687 } 1688 } 1689 } 1690 } 1691 if (typeof parallaxCols == 'object') { 1692 for (var j = 0; j < parallaxCols.length; j++) { 1693 var section = parallaxCols[j].parentNode, 1694 thisHeight = outerHeight(parallaxCols[j]), 1695 sectionHeight = outerHeight(section), 1696 offSetTop = bodyTop + (section != null ? section.getBoundingClientRect().top : 0), 1697 offSetPosition = wheight + bodyTop - offSetTop; 1698 if (offSetPosition > 0 && offSetPosition < (sectionHeight + wheight)) { 1699 value = ((offSetPosition - wheight) * speedDivider); 1700 value *= .8; 1701 if (Math.abs(value) < (thisHeight - sectionHeight)) { 1702 translateElement(parallaxCols[j], value); 1703 } else { 1704 translateElement(parallaxCols[j], thisHeight - sectionHeight); 1705 } 1706 } 1707 } 1708 } 1709 }, 1710 /** Parallax Headers **/ 1711 parallaxHeader = function(bodyTop) { 1712 var value; 1713 if (typeof parallaxHeaders == 'object') { 1714 for (var i = 0; i < parallaxHeaders.length; i++) { 1715 var section = parallaxHeaders[i].parentNode, 1716 thisSibling = section.nextSibling, 1717 thisHeight, 1718 sectionHeight, 1719 offSetTop, 1720 offSetPosition; 1721 if (classie.hasClass(parallaxHeaders[i], 'header-carousel-wrapper')) { 1722 getDivChildren(parallaxHeaders[i], '.t-background-cover', function(item, l, total) { 1723 thisHeight = outerHeight(item); 1724 sectionHeight = outerHeight(section); 1725 offSetTop = bodyTop + section.getBoundingClientRect().top; 1726 offSetPosition = wheight + bodyTop - offSetTop; 1727 if (offSetPosition > 0 && offSetPosition < (sectionHeight + wheight)) { 1728 value = ((offSetPosition - wheight) * speedDivider); 1729 if (Math.abs(value) < (thisHeight - sectionHeight)) { 1730 translateElement(item, value); 1731 } 1732 } 1733 }); 1734 } else { 1735 thisHeight = outerHeight(parallaxHeaders[i]); 1736 sectionHeight = outerHeight(section); 1737 offSetTop = bodyTop + section.getBoundingClientRect().top; 1738 offSetPosition = wheight + bodyTop - offSetTop; 1739 if (offSetPosition > 0 && offSetPosition < (sectionHeight + wheight)) { 1740 value = ((offSetPosition - wheight) * speedDivider); 1741 if (Math.abs(value) < (thisHeight - sectionHeight)) { 1742 translateElement(parallaxHeaders[i], value); 1743 } 1744 } 1745 } 1746 } 1747 } 1748 }, 1749 /** Header opacity **/ 1750 headerOpacity = function(bodyTop) { 1751 if (headerWithOpacity && headerWithOpacity.length) { 1752 var thisHeight = outerHeight(headerWithOpacity[0]); 1753 if (bodyTop > thisHeight / 8) { 1754 if (pageHeader != undefined) classie.addClass(pageHeader, 'header-scrolled'); 1755 } else { 1756 if (pageHeader != undefined) classie.removeClass(pageHeader, 'header-scrolled'); 1757 } 1758 } 1759 }, 1760 /** Show hide scroll top arrow **/ 1761 showHideScrollup = function(bodyTop) { 1762 if (bodyTop != 0) { 1763 if (bodyTop > wheight || ((bodyTop + wheight) >= docheight) && docheight > 0) { 1764 classie.addClass(document.body, 'window-scrolled'); 1765 classie.removeClass(document.body, 'hide-scrollup'); 1766 if (footerScroller && footerScroller[0] != undefined) { 1767 footerScroller[0].style.display = ''; 1768 } 1769 } else { 1770 if (classie.hasClass(document.body, 'window-scrolled')) classie.addClass(document.body, 'hide-scrollup'); 1771 classie.removeClass(document.body, 'window-scrolled'); 1772 } 1773 } 1774 }, 1775 /** Fix menu **/ 1776 fixMenu = function(){ 1777 menuwrapper = document.querySelectorAll(".menu-wrapper"); 1778 if ( ! classie.hasClass(document.body, 'vmenu') && UNCODE.isFullPage && !UNCODE.isFullPageSnap && classie.hasClass(document.body, 'uncode-fp-menu-hide') ) { 1779 menuwrapper = document.querySelector(".menu-wrapper"); 1780 pageHeader = document.getElementById("page-header"); 1781 menuwrapper.style.position = 'fixed'; 1782 menuwrapper.style.zIndex = '5'; 1783 } 1784 }, 1785 /** Hide Menu **/ 1786 hideMenu = function(bodyTop) { 1787 if (UNCODE.menuOpened || bodyTop < 0) return; 1788 if (classie.hasClass(document.body, 'vmenu')) { 1789 if (wwidth < mediaQuery) menuhide = document.querySelector('#masthead .menu-hide-vertical'); 1790 else menuhide = null; 1791 } 1792 if (classie.hasClass(document.body, 'hmenu-center')) { 1793 if (wwidth > mediaQuery) menuhide = document.querySelector('#masthead .menu-hide'); 1794 else menuhide = document.querySelector('.menu-container-mobile.menu-hide'); 1795 } 1796 if (typeof menuhide == 'object' && menuhide != null && mainmenu[0] != undefined) { 1797 var translate, 1798 scrollingDown = true; 1799 /** fix for hmenu-center **/ 1800 var sticky_element = (typeof mainmenu.item === 'undefined' ? ((wwidth > mediaQuery) ? mainmenu[0] : mainmenu[1]) : mainmenu[0]); 1801 if (lastScrollValue == bodyTop) return; 1802 1803 if (lastScrollValue > bodyTop) scrollingDown = false;
1804 else scrollingDown = true; 1805 lastScrollValue = bodyTop; 1806 1807 if (!scrollingDown) { 1808 if (!UNCODE.scrolling) { 1809 if ((secmenuHeight == 0) ? bodyTop == 0 : bodyTop < secmenuHeight) { 1810 classie.removeClass(sticky_element.parentNode, 'is_stuck'); 1811 if (classie.hasClass(masthead, 'menu-transparent')) { 1812 if ((isMobileTransparent || wwidth > mediaQuery) && !classie.hasClass(masthead.parentNode, 'no-header')) masthead.parentNode.style.height = '0px'; 1813 } 1814 if (wwidth < mediaQuery) sticky_element.style.position = 'fixed'; 1815 else sticky_element.style.position = ''; 1816 hideMenuReset(sticky_element); 1817 clearTimeout(hidingTimer); 1818 } 1819 1820 if (classie.hasClass(menuhide, 'menu-hided')) { 1821 classie.removeClass(menuhide, 'menu-hided'); 1822 hidingTimer = setTimeout(function() { 1823 classie.addClass(sticky_element.parentNode, 'is_stuck'); 1824 hideMenuReset(sticky_element); 1825 }, 400); 1826 } 1827 } 1828 } else { 1829 if (menusticky.length == 0 && bodyTop < wheight / 3) { 1830 if (sticky_element.style.position == 'fixed') sticky_element.style.position = ''; 1831 } 1832 if (bodyTop > wheight / 2) { 1833 clearTimeout(hidingTimer); 1834 if (!classie.hasClass(menuhide, 'menu-hided')) { 1835 classie.addClass(menuhide, 'menu-hided'); 1836 classie.addClass(sticky_element.parentNode, 'is_stuck'); 1837 if (sticky_element.style.position != 'fixed') { 1838 sticky_element.style.visibility = 'hidden'; 1839 sticky_element.style.position = 'fixed'; 1840 sticky_element.style.top = '0px'; 1841 } 1842 translateElement(menuhide, -UNCODE.menuMobileHeight - 1); 1843 } 1844 } 1845 } 1846 } 1847 }, 1848 hideMenuReset = function(sticky_element) { 1849 var topOffset = 0; 1850 if (sticky_element.style.visibility == 'hidden') sticky_element.style.visibility = ''; 1851 if (bodyBorder > 0) topOffset += bodyBorder; 1852 if (adminBar != null && window.getComputedStyle(adminBar,null).getPropertyValue("position") != 'fixed') adminBarHeight = 0; 1853 if (adminBarHeight > 0) topOffset += adminBarHeight; 1854 //sticky_element.style.top = topOffset + 'px'; 1855 if (!classie.hasClass(document.body, 'boxed-width') && boxWidth > 0) sticky_element.style.width = boxWidth + 'px'; 1856 translateElement(menuhide, 0); 1857 }, 1858 /** Stick Menu **/ 1859 stickMenu = function(bodyTop) { 1860 if (header && mainmenu[0] != undefined) { 1861 if (classie.hasClass(mainmenu[0], 'vmenu-container') && wwidth > mediaQuery) return; 1862 /** fix for hmenu-center **/ 1863 var sticky_element = (typeof mainmenu.item === 'undefined' ? ((isMobileTransparent || wwidth > mediaQuery) ? mainmenu[0] : mainmenu[1]) : mainmenu[0]); 1864 if ((secmenuHeight == 0 && (isMobileTransparent || wwidth > mediaQuery)) ? bodyTop > (0 + adminBarHeight) : bodyTop > (secmenuHeight + adminBarHeight)) { 1865 if (!classie.hasClass(sticky_element.parentNode, 'is_stuck')) { 1866 classie.addClass(sticky_element.parentNode, 'is_stuck'); 1867 sticky_element.style.position = 'fixed'; 1868 var getAnchorTop = bodyBorder; 1869 if (adminBar != null && window.getComputedStyle(adminBar,null).getPropertyValue("position") != 'fixed') adminBarHeight = 0; 1870 if (adminBarHeight > 0) getAnchorTop += adminBarHeight; 1871 sticky_element.style.top = getAnchorTop + 'px'; 1872 if (!classie.hasClass(document.body, 'boxed-width') && boxWidth > 0) sticky_element.style.width = boxWidth + 'px'; 1873 } 1874 } else { 1875 clearTimeout(hidingTimer); 1876 classie.removeClass(sticky_element.parentNode, 'is_stuck'); 1877 sticky_element.style.position = 'fixed'; 1878 if (isMobileTransparent || wwidth > mediaQuery) sticky_element.style.position = ''; 1879 if (classie.hasClass(document.body, 'hmenu-center')) sticky_element.style.position = 'absolute'; 1880 sticky_element.style.top = ''; 1881 } 1882 } 1883 }, 1884 translateElement = function(element, valueY) { 1885 var translate = 'translate3d(0, ' + valueY + 'px' + ', 0)'; 1886 element.style['-webkit-transform'] = translate; 1887 element.style['-moz-transform'] = translate; 1888 element.style['-ms-transform'] = translate; 1889 element.style['-o-transform'] = translate; 1890 element.style['transform'] = translate; 1891 }, 1892 scrollFunction = function() { 1893 if ( ! UNCODE.isFullPage ) { 1894 kenburnsRowCol(bodyTop); 1895 if (logoel != undefined && logoel.length && !isMobile) shrinkMenu(bodyTop); 1896 if (menusticky != undefined && menusticky.length) stickMenu(bodyTop); 1897 hideMenu(bodyTop); 1898 if (!isMobile) { 1899 if (header && menusticky != undefined && menusticky.length) 1900 switchColorsMenu(bodyTop);
1901 parallaxRowCol(bodyTop); 1902 parallaxHeader(bodyTop); 1903 headerOpacity(bodyTop); 1904 visibleRowCol(bodyTop); 1905 } 1906 } 1907 }; 1908 if (!noScroll) { 1909 window.addEventListener('scroll', function(e) { 1910 if ( ! UNCODE.isFullPage ) { 1911 bodyTop = document.documentElement.scrollTop || document.body.scrollTop; 1912 scrollFunction(); 1913 showHideScrollup(bodyTop); 1914 } 1915 }, false); 1916 } 1917 /** All scrolling functions - End */ 1918 /** help functions */ 1919 function getClosest(el, tag) { 1920 do { 1921 if (el.className != undefined && el.className.indexOf(tag) > -1) return el; 1922 } while (el = el.parentNode); 1923 // not found :( 1924 return null; 1925 } 1926 1927 function outerHeight(el, includeMargin) { 1928 if (el != null) { 1929 var height = el.offsetHeight; 1930 if (includeMargin) { 1931 var style = el.currentStyle || getComputedStyle(el); 1932 height += parseInt(style.marginTop) + parseInt(style.marginBottom); 1933 } 1934 return height; 1935 } 1936 } 1937 1938 function outerWidth(el, includeMargin) { 1939 var width = el.offsetWidth; 1940 if (includeMargin) { 1941 var style = el.currentStyle || getComputedStyle(el); 1942 width += parseInt(style.marginLeft) + parseInt(style.marginRight); 1943 } 1944 return width; 1945 } 1946 // Replicate jQuery .each method 1947 function forEachElement(selector, fn) { 1948 var elements = document.querySelectorAll(selector); 1949 for (var i = 0; i < elements.length; i++) fn(elements[i], i); 1950 } 1951 1952 function getDivChildren(containerId, selector, fn) { 1953 if (containerId !== null) { 1954 var elements = containerId.querySelectorAll(selector); 1955 for (var i = 0; i < elements.length; i++) fn(elements[i], i, elements.length); 1956 } 1957 } 1958 1959 function hideFooterScroll() { 1960 if (classie.hasClass(document.body, 'hide-scrollup')) footerScroller[0].style.display = "none"; 1961 } 1962 document.addEventListener("DOMContentLoaded", function(event) { 1963 UNCODE.adaptive(); 1964 boxWrapper = document.querySelectorAll('.box-wrapper'); 1965 docheight = boxWrapper[0] != undefined ? boxWrapper[0].offsetHeight : 0; 1966 if (!classie.hasClass(document.body, 'vmenu') && !classie.hasClass(document.body, 'menu-offcanvas')) init_overlay(); 1967 kenburnsRows = document.querySelectorAll('.with-kburns > .row-background > .background-wrapper, .with-kburns > .header-bg-wrapper, .with-kburns > .fp-tableCell > .row-background > .background-wrapper, .with-kburns > .fp-tableCell > .fp-scrollable > .fp-scroller > .row-background > .background-wrapper'); 1968 kenburnsCols = document.querySelectorAll('.with-kburns > .column-background > .background-wrapper'); 1969 if (!UNCODE.isMobile) { 1970 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'); 1971 parallaxCols = document.querySelectorAll('.with-parallax > .column-background > .background-wrapper'); 1972 } 1973 footerScroller = document.querySelectorAll('.footer-scroll-top'); 1974 if (footerScroller && footerScroller[0] != undefined) { 1975 if (transitionEvent) { 1976 footerScroller[0].addEventListener(transitionEvent, hideFooterScroll); 1977 } 1978 } 1979 Array.prototype.forEach.call(document.querySelectorAll('.row-inner'), function(el) { 1980 el.style.height = ''; 1981 el.style.marginBottom = ''; 1982 }); 1983 setRowHeight(document.querySelectorAll('.page-wrapper .row-parent, footer .row-parent')); 1984 }); 1985 /** On resize events **/ 1986 window.addEventListener("resize", function() { 1987 docheight = (boxWrapper != undefined && boxWrapper[0] != undefined) ? boxWrapper[0].offsetHeight : 0; 1988 var oldWidth = wwidth; 1989 UNCODE.wwidth = wwidth = window.innerWidth || document.documentElement.clientWidth; 1990 UNCODE.wheight = wheight = (window.innerHeight || document.documentElement.clientHeight) - (bodyBorder * 2); 1991 if (isSplitMenu) centerSplitMenu(); 1992 if (isMobile && (oldWidth == wwidth)) return false; 1993 calculateMenuHeight(false); 1994 initBox(); 1995 headerHeight('.header-wrapper'); 1996 window.dispatchEvent(boxEvent); 1997 scrollFunction(); 1998 showHideScrollup(bodyTop); 1999 clearTimeout(resizeTimer); 2000 resizeTimer = setTimeout(function() { 2001 UNCODE.wheight = wheight = (window.innerHeight || document.documentElement.clientHeight) - (bodyBorder * 2); 2002 Array.prototype.forEach.call(document.querySelectorAll('.row-inner'), function(el) { 2003 el.style.height = ''; 2004 el.style.marginBottom = ''; 2005 }); 2006 setRowHeight(document.querySelectorAll('.page-wrapper .row-parent, footer .row-parent'), false, true); 2007 if (!isMobile) { 2008 initVideoComponent(document.body, '.uncode-video-container.video, .uncode-video-container.self-video'); 2009 } 2010 }, 500); 2011 }); 2012 2013 /** 2014 * On DOM ready 2015 */ 2016 window.addEventListener("load", function(){ 2017 if (!UNCODE.isMobile) { 2018 setTimeout(function() { 2019 window.dispatchEvent(UNCODE.boxEvent); 2020 Waypoint.refreshAll(); 2021 }, 2000); 2022 } 2023 //repeat it for mobile since it changes layout on carousel after DOM loading 2024 if (UNCODE.isMobile) { 2025 kenburnsRowCol(bodyTop); 2026 } 2027 showHideScrollup(bodyTop); 2028 if (document.createEvent) { // W3C 2029 var ev = document.createEvent('Event'); 2030 ev.initEvent('resize', true, true); 2031 window.dispatchEvent(ev); 2032 } else { // IE 2033 document.fireEvent('onresize'); 2034 } 2035 }, false); 2036 2037 var UNCODE = { 2038 bodyTop: bodyTop, 2039 boxEvent: boxEvent, 2040 bodyBorder: bodyBorder, 2041 initBox: initBox, 2042 adminBarHeight: 0, 2043 menuHeight: 0, 2044 menuMobileHeight: 0, 2045 fixMenuHeight: fixMenuHeight, 2046 initHeader: initHeader, 2047 initRow: initRow, 2048 setRowHeight: setRowHeight, 2049 switchColorsMenu: switchColorsMenu, 2050 isMobile: isMobile, 2051 scrolling: false, 2052 menuHiding: false, 2053 menuOpened: false, 2054 menuMobileTriggerEvent: menuMobileTriggerEvent, 2055 mediaQuery: mediaQuery, 2056 initVideoComponent: initVideoComponent, 2057 hideMenu: hideMenu, 2058 wwidth: wwidth, 2059 wheight: wheight, 2060 }; 2061 // transport 2062 if (typeof define === 'function' && define.amd) { 2063 // AMD 2064 define(UNCODE); 2065 } else { 2066 // browser global 2067 window.UNCODE = UNCODE; 2068 } 2069 2070 UNCODE.adaptive = function() { 2071 var images = new Array(), 2072 getImages = document.querySelectorAll('.adaptive-async:not(.adaptive-fetching)'); 2073 for (var i = 0; i < getImages.length; i++) { 2074 var imageObj = {}, 2075 el = getImages[i]; 2076 classie.addClass(el, 'adaptive-fetching'); 2077 imageObj.unique = el.getAttribute('data-uniqueid'); 2078 imageObj.url = el.getAttribute('data-guid'); 2079 imageObj.path = el.getAttribute('data-path'); 2080 imageObj.singlew = el.getAttribute('data-singlew'); 2081 imageObj.singleh = el.getAttribute('data-singleh'); 2082 imageObj.origwidth = el.getAttribute('data-width'); 2083 imageObj.origheight = el.getAttribute('data-height'); 2084 imageObj.crop = el.getAttribute('data-crop'); 2085 imageObj.fixed = el.getAttribute('data-fixed') == undefined ? null : el.getAttribute('data-fixed'); 2086 imageObj.screen = window.uncodeScreen; 2087 imageObj.images = window.uncodeImages; 2088 images.push(imageObj); 2089 } 2090 var jsonString = JSON.stringify(images); 2091 var data = new Array(); 2092 data['action'] = 'get_adaptive_async'; 2093 data['images'] = jsonString;
2094 data['cache'] = 'false'; 2095 2096 if (images.length > 0) { 2097 var xmlhttp; 2098 if (window.XMLHttpRequest) { 2099 // code for IE7+, Firefox, Chrome, Opera, Safari 2100 xmlhttp = new XMLHttpRequest(); 2101 } else { 2102 // code for IE6, IE5 2103 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 2104 } 2105 xmlhttp.onreadystatechange = function() { 2106 if (xmlhttp.readyState == XMLHttpRequest.DONE ) { 2107 if(xmlhttp.status == 200){ 2108 var images = JSON.parse(xmlhttp.responseText); 2109 for (var i = 0; i < images.length; i++) { 2110 var val = images[i], 2111 getImage = document.querySelectorAll('[data-uniqueid="'+val.unique+'"]'); 2112 for (var j = 0; j < getImage.length; j++) { 2113 var attrScr = getImage[j].getAttribute('src'), 2114 replaceImg = new Image(); 2115 replaceImg.source = attrScr; 2116 replaceImg.el = getImage[j]; 2117 2118 classie.removeClass(getImage[j], 'adaptive-async'); 2119 classie.removeClass(getImage[j], 'adaptive-fetching'); 2120 2121 replaceImg.onload = function () { 2122 if (this.source !== null) { 2123 (this.el).src = this.src; 2124 } else { 2125 (this.el).style.backgroundImage = 'url("'+this.src+'")'; 2126 } 2127 classie.addClass(this.el, 'async-done'); 2128 } 2129 replaceImg.src = val.url; 2130 } 2131 } 2132 } 2133 else if(xmlhttp.status == 400) { 2134 console.log('There was an error 400') 2135 } 2136 else { 2137 console.log('something else other than 200 was returned') 2138 } 2139 } 2140 } 2141 //Serialize the data 2142 var queryString = "", 2143 arrayLength = Object.keys(data).length, 2144 arrayCounter = 0; 2145 2146 for (var key in data) { 2147 queryString += key + "=" + data[key]; 2148 if(arrayCounter < arrayLength - 1) { 2149 queryString += "&"; 2150 } 2151 arrayCounter++; 2152 } 2153 2154 xmlhttp.open("POST", SiteParameters.theme_directory + '/core/inc/uncode-ajax.php', true); 2155 xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 2156 xmlhttp.send(queryString); 2157 2158 } 2159 }; 2160 2161})(window); 2162 2163/** 2164 * vivus - JavaScript library to make drawing animation on SVG 2165 * @version v0.4.0 2166 * @link https://github.com/maxwellito/vivus 2167 * @license MIT 2168 */ 2169 2170'use strict'; 2171 2172(function (window, document) { 2173 2174 'use strict'; 2175 2176/** 2177 * Pathformer 2178 * Beta version 2179 * 2180 * Take any SVG version 1.1 and transform 2181 * child elements to 'path' elements 2182 * 2183 * This code is purely forked from 2184 * https://github.com/Waest/SVGPathConverter 2185 */ 2186 2187/** 2188 * Class constructor 2189 * 2190 * @param {DOM|String} element Dom element of the SVG or id of it 2191 */ 2192function Pathformer(element) { 2193 // Test params 2194 if (typeof element === 'undefined') { 2195 throw new Error('Pathformer [constructor]: "element" parameter is required'); 2196 } 2197 2198 // Set the element 2199 if (element.constructor === String) { 2200 element = document.getElementById(element); 2201 if (!element) { 2202 throw new Error('Pathformer [constructor]: "element" parameter is not related to an existing ID'); 2203 } 2204 } 2205 if (element.constructor instanceof window.SVGElement || /^svg$/i.test(element.nodeName)) { 2206 this.el = element; 2207 } else { 2208 throw new Error('Pathformer [constructor]: "element" parameter must be a string or a SVGelement'); 2209 } 2210 2211 // Start 2212 this.scan(element); 2213} 2214 2215/** 2216 * List of tags which can be transformed 2217 * to path elements 2218 * 2219 * @type {Array} 2220 */ 2221Pathformer.prototype.TYPES = ['line', 'ellipse', 'circle', 'polygon', 'polyline', 'rect']; 2222 2223/** 2224 * List of attribute names which contain 2225 * data. This array list them to check if 2226 * they contain bad values, like percentage. 2227 * 2228 * @type {Array} 2229 */ 2230Pathformer.prototype.ATTR_WATCH = ['cx', 'cy', 'points', 'r', 'rx', 'ry', 'x', 'x1', 'x2', 'y', '
2230y1', 'y2']; 2231 2232/** 2233 * Finds the elements compatible for transform 2234 * and apply the liked method 2235 * 2236 * @param {object} options Object from the constructor 2237 */ 2238Pathformer.prototype.scan = function (svg) { 2239 var fn, element, pathData, pathDom, 2240 elements = svg.querySelectorAll(this.TYPES.join(',')); 2241 2242 for (var i = 0; i < elements.length; i++) { 2243 element = elements[i]; 2244 fn = this[element.tagName.toLowerCase() + 'ToPath']; 2245 pathData = fn(this.parseAttr(element.attributes)); 2246 pathDom = this.pathMaker(element, pathData); 2247 element.parentNode.replaceChild(pathDom, element); 2248 } 2249}; 2250 2251 2252/** 2253 * Read `line` element to extract and transform 2254 * data, to make it ready for a `path` object. 2255 * 2256 * @param {DOMelement} element Line element to transform 2257 * @return {object} Data for a `path` element 2258 */ 2259Pathformer.prototype.lineToPath = function (element) { 2260 var newElement = {}, 2261 x1 = element.x1 || 0, 2262 y1 = element.y1 || 0, 2263 x2 = element.x2 || 0, 2264 y2 = element.y2 || 0; 2265 2266 newElement.d = 'M' + x1 + ',' + y1 + 'L' + x2 + ',' + y2; 2267 return newElement; 2268}; 2269 2270/** 2271 * Read `rect` element to extract and transform 2272 * data, to make it ready for a `path` object. 2273 * The radius-border is not taken in charge yet. 2274 * (your help is more than welcomed) 2275 * 2276 * @param {DOMelement} element Rect element to transform 2277 * @return {object} Data for a `path` element 2278 */ 2279Pathformer.prototype.rectToPath = function (element) { 2280 var newElement = {}, 2281 x = parseFloat(element.x) || 0, 2282 y = parseFloat(element.y) || 0, 2283 width = parseFloat(element.width) || 0, 2284 height = parseFloat(element.height) || 0; 2285 2286 newElement.d = 'M' + x + ' ' + y + ' '; 2287 newElement.d += 'L' + (x + width) + ' ' + y + ' '; 2288 newElement.d += 'L' + (x + width) + ' ' + (y + height) + ' '; 2289 newElement.d += 'L' + x + ' ' + (y + height) + ' Z'; 2290 return newElement; 2291}; 2292 2293/** 2294 * Read `polyline` element to extract and transform 2295 * data, to make it ready for a `path` object. 2296 * 2297 * @param {DOMelement} element Polyline element to transform 2298 * @return {object} Data for a `path` element 2299 */ 2300Pathformer.prototype.polylineToPath = function (element) { 2301 var newElement = {}, 2302 points = element.points.trim().split(' '), 2303 i, path; 2304 2305 // Reformatting if points are defined without commas 2306 if (element.points.indexOf(',') === -1) { 2307 var formattedPoints = []; 2308 for (i = 0; i < points.length; i+=2) { 2309 formattedPoints.push(points[i] + ',' + points[i+1]); 2310 } 2311 points = formattedPoints; 2312 } 2313 2314 // Generate the path.d value 2315 path = 'M' + points[0]; 2316 for(i = 1; i < points.length; i++) { 2317 if (points[i].indexOf(',') !== -1) { 2318 path += 'L' + points[i]; 2319 } 2320 } 2321 newElement.d = path; 2322 return newElement; 2323}; 2324 2325/** 2326 * Read `polygon` element to extract and transform 2327 * data, to make it ready for a `path` object. 2328 * This method rely on polylineToPath, because the 2329 * logic is similar. The path created is just closed, 2330 * so it needs an 'Z' at the end. 2331 * 2332 * @param {DOMelement} element Polygon element to transform 2333 * @return {object} Data for a `path` element 2334 */ 2335Pathformer.prototype.polygonToPath = function (element) { 2336 var newElement = Pathformer.prototype.polylineToPath(element); 2337 2338 newElement.d += 'Z'; 2339 return newElement; 2340}; 2341 2342/** 2343 * Read `ellipse` element to extract and transform 2344 * data, to make it ready for a `path` object. 2345 * 2346 * @param {DOMelement} element ellipse element to transform 2347 * @return {object} Data for a `path` element 2348 */ 2349Pathformer.prototype.ellipseToPath = function (element) { 2350 var newElement = {}, 2351 rx = parseFloat(element.rx) || 0, 2352 ry = parseFloat(element.ry) || 0, 2353 cx = parseFloat(element.cx) || 0, 2354 cy = parseFloat(element.cy) || 0, 2355 startX = cx - rx, 2356 startY = cy, 2357 endX = parseFloat(cx) + parseFloat(rx), 2358 endY = cy; 2359 2360 newElement.d = 'M' + startX + ',' + startY + 2361 'A' + rx + ',' + ry + ' 0,1,1 ' + endX + ',' + endY + 2362 'A' + rx + ',' + ry + ' 0,1,1 ' + startX + ',' + endY; 2363 return newElement; 2364}; 2365 2366/** 2367 * Read `circle` element to extract and transform 2368 * data, to make it ready for a `path` object. 2369 * 2370 * @param {DOMelement} element Circle element to transform 2371 * @return {object} Data for a `path` element 2372 */ 2373Pathformer.prototype.circleToPath = function (element) { 2374 var newElement = {}, 2375 r = parseFloat(element.r) || 0, 2376 cx = parseFloat(element.cx) || 0, 2377 cy = parseFloat(element.cy) || 0, 2378 startX = cx - r, 2379 startY = cy, 2380 endX = parseFloat(cx) + parseFloat(r), 2381 endY = cy; 2382 2383 newElement.d = 'M' + startX + ',' + startY + 2384 'A' + r + ',' + r + ' 0,1,1 ' + endX + ',' + endY + 2385 'A' + r + ',' + r + ' 0,1,1 ' + startX + ',' + endY; 2386 return newElement; 2387}; 2388 2389/** 2390 * Create `path` elements form original element 2391 * and prepared objects 2392 * 2393 * @param {DOMelement} element Original element to transform 2394 * @param {object} pathData Path data (from `toPath` methods) 2395 * @return {DOMelement} Path element 2396 */ 2397Pathformer.prototype.pathMaker = function (element, pathData) { 2398 var i, attr, pathTag = document.createElementNS('http://www.w3.org/2000/svg','path'); 2399 for(i = 0; i < element.attributes.length; i++) { 2400 attr = element.attributes[i];
vendor: 6,056 bytes, lines 2401-2593
2401 if (this.ATTR_WATCH.indexOf(attr.name) === -1) { 2402 pathTag.setAttribute(attr.name, attr.value); 2403 } 2404 } 2405 for(i in pathData) { 2406 pathTag.setAttribute(i, pathData[i]); 2407 } 2408 return pathTag; 2409}; 2410 2411/** 2412 * Parse attributes of a DOM element to 2413 * get an object of attribute => value 2414 * 2415 * @param {NamedNodeMap} attributes Attributes object from DOM element to parse 2416 * @return {object} Object of attributes 2417 */ 2418Pathformer.prototype.parseAttr = function (element) { 2419 var attr, output = {}; 2420 for (var i = 0; i < element.length; i++) { 2421 attr = element[i]; 2422 // Check if no data attribute contains '%', or the transformation is impossible 2423 if (this.ATTR_WATCH.indexOf(attr.name) !== -1 && attr.value.indexOf('%') !== -1) { 2424 throw new Error('Pathformer [parseAttr]: a SVG shape got values in percentage. This cannot be transformed into \'path\' tags. Please use \'viewBox\'.'); 2425 } 2426 output[attr.name] = attr.value; 2427 } 2428 return output; 2429}; 2430 2431 'use strict'; 2432 2433var requestAnimFrame, cancelAnimFrame, parsePositiveInt; 2434 2435/** 2436 * Vivus 2437 * Beta version 2438 * 2439 * Take any SVG and make the animation 2440 * to give give the impression of live drawing 2441 * 2442 * This in more than just inspired from codrops 2443 * At that point, it's a pure fork. 2444 */ 2445 2446/** 2447 * Class constructor 2448 * option structure 2449 * type: 'delayed'|'sync'|'oneByOne'|'script' (to know if the items must be drawn synchronously or not, default: delayed) 2450 * duration: <int> (in frames) 2451 * start: 'inViewport'|'manual'|'autostart' (start automatically the animation, default: inViewport) 2452 * delay: <int> (delay between the drawing of first and last path) 2453 * dashGap <integer> whitespace extra margin between dashes 2454 * pathTimingFunction <function> timing animation function for each path element of the SVG 2455 * animTimingFunction <function> timing animation function for the complete SVG 2456 * forceRender <boolean> force the browser to re-render all updated path items 2457 * selfDestroy <boolean> removes all extra styling on the SVG, and leaves it as original 2458 * 2459 * The attribute 'type' is by default on 'delayed'. 2460 * - 'delayed' 2461 * all paths are draw at the same time but with a 2462 * little delay between them before start 2463 * - 'sync' 2464 * all path are start and finish at the same time 2465 * - 'oneByOne' 2466 * only one path is draw at the time 2467 * the end of the first one will trigger the draw 2468 * of the next one 2469 * 2470 * All these values can be overwritten individually 2471 * for each path item in the SVG 2472 * The value of frames will always take the advantage of 2473 * the duration value. 2474 * If you fail somewhere, an error will be thrown. 2475 * Good luck. 2476 * 2477 * @constructor 2478 * @this {Vivus} 2479 * @param {DOM|String} element Dom element of the SVG or id of it 2480 * @param {Object} options Options about the animation 2481 * @param {Function} callback Callback for the end of the animation 2482 */ 2483function Vivus (element, options, callback) { 2484 2485 // Setup 2486 this.isReady = false; 2487 this.setElement(element, options); 2488 this.setOptions(options); 2489 this.setCallback(callback); 2490 2491 if (this.isReady) { 2492 this.init(); 2493 } 2494} 2495 2496/** 2497 * Timing functions 2498 ************************************** 2499 * 2500 * Default functions to help developers. 2501 * It always take a number as parameter (between 0 to 1) then 2502 * return a number (between 0 and 1) 2503 */ 2504Vivus.LINEAR = function (x) {return x;}; 2505Vivus.EASE = function (x) {return -Math.cos(x * Math.PI) / 2 + 0.5;}; 2506Vivus.EASE_OUT = function (x) {return 1 - Math.pow(1-x, 3);}; 2507Vivus.EASE_IN = function (x) {return Math.pow(x, 3);}; 2508Vivus.EASE_OUT_BOUNCE = function (x) { 2509 var base = -Math.cos(x * (0.5 * Math.PI)) + 1, 2510 rate = Math.pow(base,1.5), 2511 rateR = Math.pow(1 - x, 2), 2512 progress = -Math.abs(Math.cos(rate * (2.5 * Math.PI) )) + 1; 2513 return (1- rateR) + (progress * rateR); 2514}; 2515 2516 2517/** 2518 * Setters 2519 ************************************** 2520 */ 2521 2522/** 2523 * Check and set the element in the instance 2524 * The method will not return anything, but will throw an 2525 * error if the parameter is invalid 2526 * 2527 * @param {DOM|String} element SVG Dom element or id of it 2528 */ 2529Vivus.prototype.setElement = function (element, options) { 2530 // Basic check 2531 if (typeof element === 'undefined') { 2532 throw new Error('Vivus [constructor]: "element" parameter is required'); 2533 } 2534 2535 // Set the element 2536 if (element.constructor === String) { 2537 element = document.getElementById(element); 2538 if (!element) { 2539 throw new Error('Vivus [constructor]: "element" parameter is not related to an existing ID'); 2540 } 2541 } 2542 this.parentEl = element; 2543 2544 // Create the object element if the property `file` exists in the options object 2545 if (options && options.file) { 2546 var objElm = document.createElement('object'); 2547 objElm.setAttribute('type', 'image/svg+xml'); 2548 objElm.setAttribute('data', options.file); 2549 objElm.setAttribute('built-by-vivus', 'true'); 2550 element.appendChild(objElm); 2551 element = objElm; 2552 } 2553 2554 switch (element.constructor) { 2555 case window.SVGSVGElement: 2556 case window.SVGElement: 2557 this.el = element; 2558 this.isReady = true; 2559 break; 2560 2561 case window.HTMLObjectElement: 2562 // If we have to wait for it 2563 var onLoad, self; 2564 2565 self = this; 2566 onLoad = function (e) { 2567 if (self.isReady) { 2568 return; 2569 } 2570 self.el = element.contentDocument && element.contentDocument.querySelector('svg'); 2571 if (!self.el && e) { 2572 throw new Error('Vivus [constructor]: object loaded does not contain any SVG'); 2573 } 2574 else if (self.el) { 2575 if (element.getAttribute('built-by-vivus')) { 2576 self.parentEl.insertBefore(self.el, element); 2577 self.parentEl.removeChild(element); 2578 self.el.setAttribute('width', '100%'); 2579 self.el.setAttribute('height', '100%'); 2580 } 2581 self.isReady = true; 2582 self.init(); 2583 return true; 2584 } 2585 }; 2586 2587 if (!onLoad()) { 2588 element.addEventListener('load', onLoad); 2589 } 2590 break; 2591 2592 default: 2593 throw new Error('Vivus [constructor]: "element" parameter is not val
2593id (or miss the "file" attribute)'); 2594 } 2595}; 2596 2597/** 2598 * Set up user option to the instance 2599 * The method will not return anything, but will throw an 2600 * error if the parameter is invalid 2601 * 2602 * @param {object} options Object from the constructor 2603 */ 2604Vivus.prototype.setOptions = function (options) { 2605 var allowedTypes = ['delayed', 'sync', 'async', 'nsync', 'oneByOne', 'scenario', 'scenario-sync']; 2606 var allowedStarts = ['inViewport', 'manual', 'autostart']; 2607 2608 // Basic check 2609 if (options !== undefined && options.constructor !== Object) { 2610 throw new Error('Vivus [constructor]: "options" parameter must be an object'); 2611 } 2612 else { 2613 options = options || {}; 2614 } 2615 2616 // Set the animation type 2617 if (options.type && allowedTypes.indexOf(options.type) === -1) { 2618 throw new Error('Vivus [constructor]: ' + options.type + ' is not an existing animation `type`'); 2619 } 2620 else { 2621 this.type = options.type || allowedTypes[0]; 2622 } 2623 2624 // Set the start type 2625 if (options.start && allowedStarts.indexOf(options.start) === -1) { 2626 throw new Error('Vivus [constructor]: ' + options.start + ' is not an existing `start` option'); 2627 } 2628 else { 2629 this.start = options.start || allowedStarts[0]; 2630 } 2631 2632 this.isIE = (window.navigator.userAgent.indexOf('MSIE') !== -1 || window.navigator.userAgent.indexOf('Trident/') !== -1 || window.navigator.userAgent.indexOf('Edge/') !== -1 ); 2633 this.duration = parsePositiveInt(options.duration, 120); 2634 this.delay = parsePositiveInt(options.delay, null); 2635 this.delayStart = parsePositiveInt(options.delayStart, null); 2636 this.dashGap = parsePositiveInt(options.dashGap, 1); 2637 this.forceRender = options.hasOwnProperty('forceRender') ? !!options.forceRender : this.isIE; 2638 this.reverseStack = !!options.reverseStack; 2639 this.selfDestroy = !!options.selfDestroy; 2640 this.onReady = options.onReady; 2641 this.map = []; 2642 this.frameLength = this.currentFrame = this.delayUnit = this.speed = this.handle = null; 2643 2644 this.ignoreInvisible = options.hasOwnProperty('ignoreInvisible') ? !!options.ignoreInvisible : false; 2645 2646 this.animTimingFunction = options.animTimingFunction || Vivus.LINEAR; 2647 this.pathTimingFunction = options.pathTimingFunction || Vivus.LINEAR; 2648 2649 if (this.delay >= this.duration) { 2650 throw new Error('Vivus [constructor]: delay must be shorter than duration'); 2651 } 2652}; 2653 2654/** 2655 * Set up callback to the instance 2656 * The method will not return enything, but will throw an 2657 * error if the parameter is invalid 2658 * 2659 * @param {Function} callback Callback for the animation end 2660 */ 2661Vivus.prototype.setCallback = function (callback) { 2662 // Basic check 2663 if (!!callback && callback.constructor !== Function) { 2664 throw new Error('Vivus [constructor]: "callback" parameter must be a function'); 2665 } 2666 this.callback = callback || function () {}; 2667}; 2668 2669 2670/** 2671 * Core 2672 ************************************** 2673 */ 2674 2675/** 2676 * Map the svg, path by path. 2677 * The method return nothing, it just fill the 2678 * `map` array. Each item in this array represent 2679 * a path element from the SVG, with informations for 2680 * the animation. 2681 * 2682 * ``` 2683 * [ 2684 * { 2685 * el: <DOMobj> the path element 2686 * length: <number> length of the path line 2687 * startAt: <number> time start of the path animation (in frames) 2688 * duration: <number> path animation duration (in frames) 2689 * }, 2690 * ... 2691 * ] 2692 * ``` 2693 * 2694 */ 2695Vivus.prototype.mapping = function () { 2696 var i, paths, path, pAttrs, pathObj, totalLength, lengthMeter, timePoint; 2697 timePoint = totalLength = lengthMeter = 0; 2698 paths = this.el.querySelectorAll('path'); 2699 2700 for (i = 0; i < paths.length; i++) { 2701 path = paths[i]; 2702 if (this.isInvisible(path)) { 2703 continue; 2704 } 2705 pathObj = { 2706 el: path, 2707 length: Math.ceil(path.getTotalLength()) 2708 }; 2709 // Test if the path length is correct 2710 if (isNaN(pathObj.length)) { 2711 if (window.console && console.warn) { 2712 console.warn('Vivus [mapping]: cannot retrieve a path element length', path); 2713 } 2714 continue; 2715 } 2716 this.map.push(pathObj); 2717 path.style.strokeDasharray = pathObj.length + ' ' + (pathObj.length + this.dashGap * 2); 2718 path.style.strokeDashoffset = pathObj.length + this.dashGap; 2719 pathObj.length += this.dashGap; 2720 totalLength += pathObj.length; 2721 2722 this.renderPath(i); 2723 } 2724 2725 totalLength = totalLength === 0 ? 1 : totalLength; 2726 this.delay = this.delay === null ? this.duration / 3 : this.delay; 2727 this.delayUnit = this.delay / (paths.length > 1 ? paths.length - 1 : 1); 2728 2729 // Reverse stack if asked 2730 if (this.reverseStack) { 2731 this.map.reverse(); 2732 } 2733 2734 for (i = 0; i < this.map.length; i++) { 2735 pathObj = this.map[i]; 2736 2737 switch (this.type) { 2738 case 'delayed': 2739 pathObj.startAt = this.delayUnit * i; 2740 pathObj.duration = this.duration - this.delay; 2741 break; 2742 2743 case 'oneByOne': 2744 pathObj.startAt = lengthMeter / totalLength * this.duration; 2745 pathObj.duration = pathObj.length / totalLength * this.duration; 2746 break; 2747 2748 case 'sync': 2749 case 'async': 2750 case 'nsync': 2751 pathObj.startAt = 0; 2752 pathObj.duration = this.duration; 2753 break; 2754 2755 case 'scenario-sync': 2756 path = pathObj.el; 2757 pAttrs = this.parseAttr(path); 2758 pathObj.startAt = timePoint + (parsePositiveInt(pAttrs['data-delay'], this.delayUnit) || 0); 2759 pathObj.duration = parsePositiveInt(pAttrs['data-duration'], this.duration); 2760 timePoint = pAttrs['data-async'] !== undefined ? pathObj.startAt : pathObj.startAt + pathObj.duration; 2761 this.frameLength = Math.max(this.frameLength, (pathObj.startAt + pathObj.duration)); 2762 break; 2763 2764 case 'scenario': 2765 path = pathObj.el; 2766 pAttrs = this.parseAttr(path); 2767 pathObj.startAt = parsePositiveInt(pAttrs['data-start'], this.delayUnit) || 0; 2768 pathObj.duration = parsePositiveInt(pAttrs['data-duration'], this.duration); 2769 this.frameLength = Math.max(this.frameLength, (pathObj.startAt + pathObj.duration)); 2770 break; 2771 } 2772 lengthMeter += pathObj.length; 2773 this.frameLength = this.frameLength || this.duration; 2774 } 2775}; 2776 2777/** 2778 * Interval method to draw the SVG from current 2779 * position of the animation. It update the value of 2780 * `currentFrame` and re-trace the SVG. 2781 * 2782 * It use this.handle to store the requestAnimationFrame 2783 * and clear it one the animation is stopped. So this 2784 * attribute can be used to know if the animation is 2785 * playing. 2786 * 2787 * Once the animation at the end, this method will 2788 * trigger the Vivus callback. 2789 * 2790 */ 2791Vivus.prototype.drawer = function () { 2792 var self = this; 2793 this.currentFrame += this.speed; 2794 2795 if (this.currentFrame <= 0) { 2796 this.stop(); 2797 this.reset(); 2798 } else if (this.currentFrame >= this.frameLength) { 2799 this.stop(); 2800 this.currentFrame = this.frameLength; 2801 this.trace();
vendor: 5,018 bytes, lines 2802-2984
2802 if (this.selfDestroy) { 2803 this.destroy(); 2804 } 2805 } else { 2806 this.trace(); 2807 this.handle = requestAnimFrame(function () { 2808 self.drawer(); 2809 }); 2810 return; 2811 } 2812 2813 this.callback(this); 2814 if (this.instanceCallback) { 2815 this.instanceCallback(this); 2816 this.instanceCallback = null; 2817 } 2818}; 2819 2820/** 2821 * Draw the SVG at the current instant from the 2822 * `currentFrame` value. Here is where most of the magic is. 2823 * The trick is to use the `strokeDashoffset` style property. 2824 * 2825 * For optimisation reasons, a new property called `progress` 2826 * is added in each item of `map`. This one contain the current 2827 * progress of the path element. Only if the new value is different 2828 * the new value will be applied to the DOM element. This 2829 * method save a lot of resources to re-render the SVG. And could 2830 * be improved if the animation couldn't be played forward. 2831 * 2832 */ 2833Vivus.prototype.trace = function () { 2834 var i, progress, path, currentFrame; 2835 currentFrame = this.animTimingFunction(this.currentFrame / this.frameLength) * this.frameLength; 2836 for (i = 0; i < this.map.length; i++) { 2837 path = this.map[i]; 2838 progress = (currentFrame - path.startAt) / path.duration; 2839 progress = this.pathTimingFunction(Math.max(0, Math.min(1, progress))); 2840 if (path.progress !== progress) { 2841 path.progress = progress; 2842 path.el.style.strokeDashoffset = Math.floor(path.length * (1 - progress)); 2843 this.renderPath(i); 2844 } 2845 } 2846}; 2847 2848/** 2849 * Method forcing the browser to re-render a path element 2850 * from it's index in the map. Depending on the `forceRender` 2851 * value. 2852 * The trick is to replace the path element by it's clone. 2853 * This practice is not recommended because it's asking more 2854 * ressources, too much DOM manupulation.. 2855 * but it's the only way to let the magic happen on IE. 2856 * By default, this fallback is only applied on IE. 2857 * 2858 * @param {Number} index Path index 2859 */ 2860Vivus.prototype.renderPath = function (index) { 2861 if (this.forceRender && this.map && this.map[index]) { 2862 var pathObj = this.map[index], 2863 newPath = pathObj.el.cloneNode(true); 2864 pathObj.el.parentNode.replaceChild(newPath, pathObj.el); 2865 pathObj.el = newPath; 2866 } 2867}; 2868 2869/** 2870 * When the SVG object is loaded and ready, 2871 * this method will continue the initialisation. 2872 * 2873 * This this mainly due to the case of passing an 2874 * object tag in the constructor. It will wait 2875 * the end of the loading to initialise. 2876 * 2877 */ 2878Vivus.prototype.init = function () { 2879 // Set object variables 2880 this.frameLength = 0; 2881 this.currentFrame = 0; 2882 this.map = []; 2883 2884 // Start 2885 new Pathformer(this.el); 2886 this.mapping(); 2887 this.starter(); 2888 2889 if (this.onReady) { 2890 this.onReady(this); 2891 } 2892}; 2893 2894/** 2895 * Trigger to start of the animation. 2896 * Depending on the `start` value, a different script 2897 * will be applied. 2898 * 2899 * If the `start` value is not valid, an error will be thrown. 2900 * Even if technically, this is impossible. 2901 * 2902 */ 2903Vivus.prototype.starter = function () { 2904 switch (this.start) { 2905 case 'manual': 2906 return; 2907 2908 case 'autostart': 2909 this.play(); 2910 break; 2911 2912 case 'inViewport': 2913 var self = this, 2914 listener = function () { 2915 if (self.isInViewport(self.parentEl, 1)) { 2916 self.play(); 2917 window.removeEventListener('scroll', listener); 2918 window.removeEventListener('fp-slide-changed', listener); 2919 window.removeEventListener('fp-slide-scroll', listener); 2920 } 2921 }; 2922 window.addEventListener('scroll', listener); 2923 window.addEventListener('fp-slide-changed', listener); 2924 window.addEventListener('fp-slide-scroll', listener); 2925 listener(); 2926 break; 2927 } 2928}; 2929 2930 2931/** 2932 * Controls 2933 ************************************** 2934 */ 2935 2936/** 2937 * Get the current status of the animation between 2938 * three different states: 'start', 'progress', 'end'. 2939 * @return {string} Instance status 2940 */ 2941Vivus.prototype.getStatus = function () { 2942 return this.currentFrame === 0 ? 'start' : this.currentFrame === this.frameLength ? 'end' : 'progress'; 2943}; 2944 2945/** 2946 * Reset the instance to the initial state : undraw 2947 * Be careful, it just reset the animation, if you're 2948 * playing the animation, this won't stop it. But just 2949 * make it start from start. 2950 * 2951 */ 2952Vivus.prototype.reset = function () { 2953 return this.setFrameProgress(0); 2954}; 2955 2956/** 2957 * Set the instance to the final state : drawn 2958 * Be careful, it just set the animation, if you're 2959 * playing the animation on rewind, this won't stop it. 2960 * But just make it start from the end. 2961 * 2962 */ 2963Vivus.prototype.finish = function () { 2964 return this.setFrameProgress(1); 2965}; 2966 2967/** 2968 * Set the level of progress of the drawing. 2969 * 2970 * @param {number} progress Level of progress to set 2971 */ 2972Vivus.prototype.setFrameProgress = function (progress) { 2973 progress = Math.min(1, Math.max(0, progress)); 2974 this.currentFrame = Math.round(this.frameLength * progress); 2975 this.trace(); 2976 return this; 2977}; 2978 2979/** 2980 * Play the animation at the desired speed. 2981 * Speed must be a valid number (no zero). 2982 * By default, the speed value is 1. 2983 * But a negative value is accepted to go forward. 2984 *
2985 * And works with float too. 2986 * But don't forget we are in JavaScript, se be nice 2987 * with him and give him a 1/2^x value. 2988 * 2989 * @param {number} speed Animation speed [optional] 2990 */ 2991Vivus.prototype.play = function (speed, callback) { 2992 this.instanceCallback = null; 2993 2994 if (speed && typeof speed === 'function') { 2995 this.instanceCallback = speed; // first parameter is actually the callback function 2996 speed = null; 2997 } 2998 else if (speed && typeof speed !== 'number') { 2999 throw new Error('Vivus [play]: invalid speed'); 3000 } 3001 // if the first parameter wasn't the callback, check if the seconds was 3002 if (callback && typeof(callback) === 'function' && !this.instanceCallback) { 3003 this.instanceCallback = callback; 3004 } 3005 3006 3007 this.speed = speed || 1; 3008 if (!this.handle) { 3009 var $this = this, 3010 delay = (this.delayStart != null) ? this.delayStart : 0; 3011 setTimeout(function() { 3012 $this.drawer(); 3013 }, delay); 3014 } 3015 return this; 3016}; 3017 3018/** 3019 * Stop the current animation, if on progress. 3020 * Should not trigger any error. 3021 * 3022 */ 3023Vivus.prototype.stop = function () { 3024 if (this.handle) { 3025 cancelAnimFrame(this.handle); 3026 this.handle = null; 3027 } 3028 return this; 3029}; 3030 3031/** 3032 * Destroy the instance. 3033 * Remove all bad styling attributes on all 3034 * path tags 3035 * 3036 */ 3037Vivus.prototype.destroy = function () { 3038 this.stop(); 3039 var i, path; 3040 for (i = 0; i < this.map.length; i++) { 3041 path = this.map[i]; 3042 path.el.style.strokeDashoffset = null; 3043 path.el.style.strokeDasharray = null; 3044 this.renderPath(i); 3045 } 3046}; 3047 3048 3049/** 3050 * Utils methods 3051 * include methods from Codrops 3052 ************************************** 3053 */ 3054 3055/** 3056 * Method to best guess if a path should added into 3057 * the animation or not. 3058 * 3059 * 1. Use the `data-vivus-ignore` attribute if set 3060 * 2. Check if the instance must ignore invisible paths 3061 * 3. Check if the path is visible 3062 * 3063 * For now the visibility checking is unstable. 3064 * It will be used for a beta phase. 3065 * 3066 * Other improvments are planned. Like detecting 3067 * is the path got a stroke or a valid opacity. 3068 */ 3069Vivus.prototype.isInvisible = function (el) { 3070 var rect, 3071 ignoreAttr = el.getAttribute('data-ignore'); 3072 3073 if (ignoreAttr !== null) { 3074 return ignoreAttr !== 'false'; 3075 } 3076 3077 if (this.ignoreInvisible) { 3078 rect = el.getBoundingClientRect(); 3079 return !rect.width && !rect.height; 3080 } 3081 else { 3082 return false; 3083 } 3084}; 3085 3086/** 3087 * Parse attributes of a DOM element to 3088 * get an object of {attributeName => attributeValue} 3089 * 3090 * @param {object} element DOM element to parse 3091 * @return {object} Object of attributes 3092 */ 3093Vivus.prototype.parseAttr = function (element) { 3094 var attr, output = {}; 3095 if (element && element.attributes) { 3096 for (var i = 0; i < element.attributes.length; i++) { 3097 attr = element.attributes[i]; 3098 output[attr.name] = attr.value; 3099 } 3100 } 3101 return output; 3102}; 3103 3104/** 3105 * Reply if an element is in the page viewport 3106 * 3107 * @param {object} el Element to observe 3108 * @param {number} h Percentage of height 3109 * @return {boolean} 3110 */ 3111Vivus.prototype.isInViewport = function (el, h) { 3112 var scrolled = this.scrollY(), 3113 viewed = scrolled + this.getViewportH(), 3114 elBCR = el.getBoundingClientRect(), 3115 elHeight = elBCR.height, 3116 elTop = scrolled + elBCR.top, 3117 elBottom = elTop + elHeight; 3118 3119 // if 0, the element is considered in the viewport as soon as it enters. 3120 // if 1, the element is considered in the viewport only when it's fully inside 3121 // value in percentage (1 >= h >= 0) 3122 h = h || 0; 3123 3124 return (elTop + elHeight * h) <= viewed && (elBottom) >= scrolled; 3125}; 3126 3127/** 3128 * Alias for document element 3129 * 3130 * @type {DOMelement} 3131 */ 3132Vivus.prototype.docElem = window.document.documentElement; 3133 3134/** 3135 * Get the viewport height in pixels 3136 * 3137 * @return {integer} Viewport height 3138 */ 3139Vivus.prototype.getViewportH = function () { 3140 var client = this.docElem.clientHeight, 3141 inner = window.innerHeight; 3142 3143 if (client < inner) { 3144 return inner; 3145 } 3146 else { 3147 return client; 3148 } 3149}; 3150 3151/** 3152 * Get the page Y offset 3153 * 3154 * @return {integer} Page Y offset 3155 */ 3156Vivus.prototype.scrollY = function () { 3157 return window.pageYOffset || this.docElem.scrollTop; 3158}; 3159 3160/** 3161 * Alias for `requestAnimationFrame` or 3162 * `setTimeout` function for deprecated browsers. 3163 * 3164 */ 3165requestAnimFrame = (function () { 3166 return ( 3167 window.requestAnimationFrame || 3168 window.webkitRequestAnimationFrame || 3169 window.mozRequestAnimationFrame || 3170 window.oRequestAnimationFrame || 3171 window.msRequestAnimationFrame || 3172 function(/* function */ callback){ 3173 return window.setTimeout(callback, 1000 / 60); 3174 } 3175 ); 3176})(); 3177 3178/** 3179 * Alias for `cancelAnimationFrame` or 3180 * `cancelTimeout` function for deprecated browsers. 3181 * 3182 */ 3183cancelAnimFrame = (function () { 3184 return ( 3185 window.cancelAnimationFrame || 3186 window.webkitCancelAnimationFrame || 3187 window.mozCancelAnimationFrame || 3188 window.oCancelAnimationFrame || 3189 window.msCancelAnimationFrame || 3190 function(id){ 3191 return window.clearTimeout(id); 3192 } 3193 ); 3194})(); 3195 3196/** 3197 * Parse string to integer. 3198 * If the number is not positive or null 3199 * the method will return the default value 3200 * or 0 if undefined 3201 * 3202 * @param {string} value String to parse 3203 * @param {*}
3203 defaultValue Value to return if the result parsed is invalid 3204 * @return {number} 3205 * 3206 */ 3207parsePositiveInt = function (value, defaultValue) { 3208 var output = parseInt(value, 10); 3209 return (output >= 0) ? output : defaultValue; 3210}; 3211 3212 3213 if (typeof define === 'function' && define.amd) { 3214 // AMD. Register as an anonymous module. 3215 define([], function() { 3216 return Vivus; 3217 }); 3218 } else if (typeof exports === 'object') { 3219 // Node. Does not work with strict CommonJS, but 3220 // only CommonJS-like environments that support module.exports, 3221 // like Node. 3222 module.exports = Vivus; 3223 } else { 3224 // Browser globals 3225 window.Vivus = Vivus; 3226 } 3227 3228}(window, document));
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.