Advertisement
Guest User

Untitled

a guest
Aug 10th, 2020
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 69.72 KB | None | 0 0
  1. (function ($) {
  2. "use strict";
  3.  
  4. $(document).ready(function () {
  5. var aviabodyclasses = AviaBrowserDetection('html');
  6.  
  7. $.avia_utilities = $.avia_utilities || {};
  8. if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) && 'ontouchstart' in document.documentElement) {
  9. $.avia_utilities.isMobile = true;
  10. }
  11. else {
  12. $.avia_utilities.isMobile = false;
  13. }
  14.  
  15. //activates the hamburger mobile menu
  16. avia_hamburger_menu();
  17.  
  18. //show scroll top but1ton
  19. avia_scroll_top_fade();
  20.  
  21. //calculate width of content
  22. aviaCalcContentWidth();
  23.  
  24. //creates search tooltip
  25. new $.AviaTooltip({ "class": 'avia-search-tooltip', data: 'avia-search-tooltip', event: 'click', position: 'bottom', scope: "body", attach: 'element', within_screen: true });
  26.  
  27. //creates relate posts tooltip
  28. new $.AviaTooltip({ "class": 'avia-related-tooltip', data: 'avia-related-tooltip', scope: ".related_posts, .av-share-box", attach: 'element', delay: 0 });
  29.  
  30. //creates ajax search
  31. new $.AviaAjaxSearch({ scope: '#header, .avia_search_element' });
  32.  
  33. // actiavte portfolio sorting
  34. if ($.fn.avia_iso_sort)
  35. $('.grid-sort-container').avia_iso_sort();
  36.  
  37. // Checks height of content and sidebar and applies shadow class to the higher one
  38. AviaSidebarShaowHelper();
  39.  
  40. $.avia_utilities.avia_ajax_call();
  41.  
  42.  
  43. });
  44.  
  45. $.avia_utilities = $.avia_utilities || {};
  46.  
  47. $.avia_utilities.avia_ajax_call = function (container) {
  48. if (typeof container == 'undefined') { container = 'body'; };
  49.  
  50.  
  51. $('a.avianolink').on('click', function (e) { e.preventDefault(); });
  52. $('a.aviablank').attr('target', '_blank');
  53.  
  54. //activates the prettyphoto lightbox
  55. if ($.fn.avia_activate_lightbox) {
  56. $(container).avia_activate_lightbox();
  57. }
  58.  
  59. //scrollspy for main menu. must be located before smoothscrolling
  60. if ($.fn.avia_scrollspy) {
  61. if (container == 'body') {
  62. $('body').avia_scrollspy({ target: '.main_menu .menu li > a' });
  63. }
  64. else {
  65. $('body').avia_scrollspy('refresh');
  66. }
  67. }
  68.  
  69.  
  70.  
  71. //smooth scrooling
  72. if ($.fn.avia_smoothscroll)
  73. $('a[href*="#"]', container).avia_smoothscroll(container);
  74.  
  75. avia_small_fixes(container);
  76.  
  77. avia_hover_effect(container);
  78.  
  79. avia_iframe_fix(container);
  80.  
  81. //activate html5 video player
  82. if ($.fn.avia_html5_activation && $.fn.mediaelementplayer)
  83. $(".avia_video, .avia_audio", container).avia_html5_activation({ ratio: '16:9' });
  84.  
  85. };
  86.  
  87. // -------------------------------------------------------------------------------------------
  88. // Error log helper
  89. // -------------------------------------------------------------------------------------------
  90.  
  91. $.avia_utilities.log = function (text, type, extra) {
  92. if (typeof console == 'undefined') { return; } if (typeof type == 'undefined') { type = "log"; } type = "AVIA-" + type.toUpperCase();
  93. console.log("[" + type + "] " + text); if (typeof extra != 'undefined') console.log(extra);
  94. };
  95.  
  96.  
  97.  
  98. // -------------------------------------------------------------------------------------------
  99. // keep track of the browser and content width
  100. // -------------------------------------------------------------------------------------------
  101.  
  102.  
  103.  
  104. function aviaCalcContentWidth() {
  105.  
  106. var win = $(window),
  107. width_select = $('html').is('.html_header_sidebar') ? "#main" : "#header",
  108. outer = $(width_select),
  109. outerParent = outer.parents('div:eq(0)'),
  110. the_main = $(width_select + ' .container:first'),
  111. css_block = "",
  112. calc_dimensions = function () {
  113. var css = "",
  114. w_12 = Math.round(the_main.width()),
  115. w_outer = Math.round(outer.width()),
  116. w_inner = Math.round(outerParent.width());
  117.  
  118. //css rules for mega menu
  119. css += " #header .three.units{width:" + (w_12 * 0.25) + "px;}";
  120. css += " #header .six.units{width:" + (w_12 * 0.50) + "px;}";
  121. css += " #header .nine.units{width:" + (w_12 * 0.75) + "px;}";
  122. css += " #header .twelve.units{width:" + (w_12) + "px;}";
  123.  
  124. //css rules for tab sections
  125. css += " .av-framed-box .av-layout-tab-inner .container{width:" + (w_inner) + "px;}";
  126. css += " .html_header_sidebar .av-layout-tab-inner .container{width:" + (w_outer) + "px;}";
  127. css += " .boxed .av-layout-tab-inner .container{width:" + (w_outer) + "px;}";
  128.  
  129. //css rules for submenu container
  130. css += " .av-framed-box#top .av-submenu-container{width:" + (w_inner) + "px;}";
  131.  
  132. //ie8 needs different insert method
  133. try {
  134. css_block.text(css);
  135. }
  136. catch (err) {
  137. css_block.remove();
  138. css_block = $("<style type='text/css' id='av-browser-width-calc'>" + css + "</style>").appendTo('head:first');
  139. }
  140.  
  141. };
  142.  
  143.  
  144.  
  145. if ($('.avia_mega_div').length > 0 || $('.av-layout-tab-inner').length > 0 || $('.av-submenu-container').length > 0) {
  146. css_block = $("<style type='text/css' id='av-browser-width-calc'></style>").appendTo('head:first');
  147. win.on('debouncedresize', calc_dimensions);
  148. calc_dimensions();
  149. }
  150. }
  151.  
  152.  
  153. // -------------------------------------------------------------------------------------------
  154. // Tiny helper for sidebar shadow
  155. // -------------------------------------------------------------------------------------------
  156.  
  157. function AviaSidebarShaowHelper() {
  158.  
  159. var $sidebar_container = $('.sidebar_shadow#top #main .sidebar');
  160. var $content_container = $('.sidebar_shadow .content');
  161.  
  162. if ($sidebar_container.height() >= $content_container.height()) {
  163. $sidebar_container.addClass('av-enable-shadow');
  164. }
  165. else {
  166. $content_container.addClass('av-enable-shadow');
  167. }
  168.  
  169. }
  170.  
  171.  
  172. // -------------------------------------------------------------------------------------------
  173. // modified SCROLLSPY by bootstrap
  174. // -------------------------------------------------------------------------------------------
  175.  
  176.  
  177. function AviaScrollSpy(element, options) {
  178. var self = this;
  179.  
  180. var process = $.proxy(self.process, self)
  181. , refresh = $.proxy(self.refresh, self)
  182. , $element = $(element).is('body') ? $(window) : $(element)
  183. , href;
  184. self.$body = $('body');
  185. self.$win = $(window);
  186. self.options = $.extend({}, $.fn.avia_scrollspy.defaults, options);
  187. self.selector = (self.options.target
  188. || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
  189. || '');
  190.  
  191. self.activation_true = false;
  192.  
  193. if (self.$body.find(self.selector + "[href*='#']").length) {
  194. self.$scrollElement = $element.on('scroll.scroll-spy.data-api', process);
  195. self.$win.on('av-height-change', refresh);
  196. self.$body.on('av_resize_finished', refresh);
  197. self.activation_true = true;
  198. self.checkFirst();
  199.  
  200. setTimeout(function () {
  201. self.refresh();
  202. self.process();
  203.  
  204. }, 100);
  205. }
  206.  
  207. }
  208.  
  209. AviaScrollSpy.prototype = {
  210.  
  211. constructor: AviaScrollSpy
  212. , checkFirst: function () {
  213.  
  214. var current = window.location.href.split('#')[0],
  215. matching_link = this.$body.find(this.selector + "[href='" + current + "']").attr('href', current + '#top');
  216. }
  217. , refresh: function () {
  218.  
  219. if (!this.activation_true) return;
  220.  
  221. var self = this
  222. , $targets;
  223.  
  224. this.offsets = $([]);
  225. this.targets = $([]);
  226.  
  227. $targets = this.$body
  228. .find(this.selector)
  229. .map(function () {
  230. var $el = $(this)
  231. , href = $el.data('target') || $el.attr('href')
  232. , hash = this.hash
  233. , hash = hash.replace(/\//g, "")
  234. , $href = /^#\w/.test(hash) && $(hash);
  235.  
  236. return ($href
  237. && $href.length
  238. && [[$href.position().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href]]) || null;
  239. })
  240. .sort(function (a, b) { return a[0] - b[0]; })
  241. .each(function () {
  242. self.offsets.push(this[0]);
  243. self.targets.push(this[1]);
  244. });
  245.  
  246. }
  247.  
  248. , process: function () {
  249.  
  250. if (!this.offsets) return;
  251. if (isNaN(this.options.offset)) this.options.offset = 0;
  252.  
  253. var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
  254. , scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
  255. , maxScroll = scrollHeight - this.$scrollElement.height()
  256. , offsets = this.offsets
  257. , targets = this.targets
  258. , activeTarget = this.activeTarget
  259. , i;
  260.  
  261. if (scrollTop >= maxScroll) {
  262. return activeTarget != (i = targets.last()[0])
  263. && this.activate(i);
  264. }
  265.  
  266. for (i = offsets.length; i--;) {
  267. activeTarget != targets[i]
  268. && scrollTop >= offsets[i]
  269. && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
  270. && this.activate(targets[i]);
  271. }
  272. }
  273.  
  274. , activate: function (target) {
  275. var active
  276. , selector;
  277.  
  278. this.activeTarget = target;
  279.  
  280. $(this.selector)
  281. .parent('.' + this.options.applyClass)
  282. .removeClass(this.options.applyClass);
  283.  
  284. selector = this.selector
  285. + '[data-target="' + target + '"],'
  286. + this.selector + '[href="' + target + '"]';
  287.  
  288.  
  289.  
  290. active = $(selector)
  291. .parent('li')
  292. .addClass(this.options.applyClass);
  293.  
  294. if (active.parent('.sub-menu').length) {
  295. active = active.closest('li.dropdown_ul_available').addClass(this.options.applyClass);
  296. }
  297.  
  298. active.trigger('activate');
  299. }
  300.  
  301. };
  302.  
  303.  
  304. /* AviaScrollSpy PLUGIN DEFINITION
  305. * =========================== */
  306.  
  307. $.fn.avia_scrollspy = function (option) {
  308. return this.each(function () {
  309. var $this = $(this)
  310. , data = $this.data('scrollspy')
  311. , options = typeof option == 'object' && option;
  312. if (!data) $this.data('scrollspy', (data = new AviaScrollSpy(this, options)));
  313. if (typeof option == 'string') data[option]();
  314. });
  315. };
  316.  
  317. $.fn.avia_scrollspy.Constructor = AviaScrollSpy;
  318.  
  319. $.fn.avia_scrollspy.calc_offset = function () {
  320. var offset_1 = (parseInt($('.html_header_sticky #main').data('scroll-offset'), 10)) || 0,
  321. offset_2 = ($(".html_header_sticky:not(.html_top_nav_header) #header_main_alternate").outerHeight()) || 0,
  322. offset_3 = ($(".html_header_sticky.html_header_unstick_top_disabled #header_meta").outerHeight()) || 0,
  323. offset_4 = 1,
  324. offset_5 = parseInt($('html').css('margin-top'), 10) || 0,
  325. offset_6 = parseInt($('.av-frame-top ').outerHeight(), 10) || 0;
  326.  
  327. return offset_1 + offset_2 + offset_3 + offset_4 + offset_5 + offset_6;
  328. };
  329.  
  330. $.fn.avia_scrollspy.defaults =
  331. {
  332. offset: $.fn.avia_scrollspy.calc_offset(),
  333. applyClass: 'current-menu-item'
  334. };
  335.  
  336.  
  337.  
  338.  
  339.  
  340. // -------------------------------------------------------------------------------------------
  341. // detect browser and add class to body
  342. // -------------------------------------------------------------------------------------------
  343.  
  344. function AviaBrowserDetection(outputClassElement) {
  345.  
  346. //code from the old jquery migrate plugin
  347. var current_browser = {},
  348.  
  349. uaMatch = function (ua) {
  350. ua = ua.toLowerCase();
  351.  
  352. var match = /(edge)\/([\w.]+)/.exec(ua) ||
  353. /(opr)[\/]([\w.]+)/.exec(ua) ||
  354. /(chrome)[ \/]([\w.]+)/.exec(ua) ||
  355. /(iemobile)[\/]([\w.]+)/.exec(ua) ||
  356. /(version)(applewebkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(ua) ||
  357. /(webkit)[ \/]([\w.]+).*(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(ua) ||
  358. /(webkit)[ \/]([\w.]+)/.exec(ua) ||
  359. /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) ||
  360. /(msie) ([\w.]+)/.exec(ua) ||
  361. ua.indexOf("trident") >= 0 && /(rv)(?::| )([\w.]+)/.exec(ua) ||
  362. ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) ||
  363. [];
  364.  
  365. return {
  366. browser: match[5] || match[3] || match[1] || "",
  367. version: match[2] || match[4] || "0",
  368. versionNumber: match[4] || match[2] || "0"
  369. };
  370. };
  371.  
  372. var matched = uaMatch(navigator.userAgent);
  373.  
  374. if (matched.browser) {
  375. current_browser.browser = matched.browser;
  376. current_browser[matched.browser] = true;
  377. current_browser.version = matched.version;
  378. }
  379.  
  380. // Chrome is Webkit, but Webkit is also Safari.
  381. if (current_browser.chrome) {
  382. current_browser.webkit = true;
  383. } else if (current_browser.webkit) {
  384. current_browser.safari = true;
  385. }
  386.  
  387. if (typeof (current_browser) !== 'undefined') {
  388. var bodyclass = '', version = current_browser.version ? parseInt(current_browser.version) : "";
  389.  
  390. if (current_browser.msie || current_browser.rv || current_browser.iemobile) {
  391. bodyclass += 'avia-msie';
  392. } else if (current_browser.webkit) {
  393. bodyclass += 'avia-webkit';
  394. } else if (current_browser.mozilla) {
  395. bodyclass += 'avia-mozilla';
  396. }
  397.  
  398. if (current_browser.version) bodyclass += ' ' + bodyclass + '-' + version + ' ';
  399. if (current_browser.browser) bodyclass += ' avia-' + current_browser.browser + ' avia-' + current_browser.browser + '-' + version + ' ';
  400. }
  401.  
  402. if (outputClassElement) $(outputClassElement).addClass(bodyclass);
  403.  
  404. return bodyclass;
  405. }
  406.  
  407. // -------------------------------------------------------------------------------------------
  408. // html 5 videos
  409. // -------------------------------------------------------------------------------------------
  410. $.fn.avia_html5_activation = function (options) {
  411. var defaults =
  412. {
  413. ratio: '16:9'
  414. };
  415.  
  416. var options = $.extend(defaults, options),
  417. isMobile = $.avia_utilities.isMobile;
  418.  
  419. // if(isMobile) return;
  420.  
  421. this.each(function () {
  422. var fv = $(this),
  423. id_to_apply = '#' + fv.attr('id'),
  424. posterImg = fv.attr('poster');
  425.  
  426.  
  427. fv.mediaelementplayer({
  428. // if the <video width> is not specified, this is the default
  429. defaultVideoWidth: 480,
  430. // if the <video height> is not specified, this is the default
  431. defaultVideoHeight: 270,
  432. // if set, overrides <video width>
  433. videoWidth: -1,
  434. // if set, overrides <video height>
  435. videoHeight: -1,
  436. // width of audio player
  437. audioWidth: 400,
  438. // height of audio player
  439. audioHeight: 30,
  440. // initial volume when the player starts
  441. startVolume: 0.8,
  442. // useful for <audio> player loops
  443. loop: false,
  444. // enables Flash and Silverlight to resize to content size
  445. enableAutosize: false,
  446. // the order of controls you want on the control bar (and other plugins below)
  447. features: ['playpause', 'progress', 'current', 'duration', 'tracks', 'volume'],
  448. // Hide controls when playing and mouse is not over the video
  449. alwaysShowControls: false,
  450. // force iPad's native controls
  451. iPadUseNativeControls: false,
  452. // force iPhone's native controls
  453. iPhoneUseNativeControls: false,
  454. // force Android's native controls
  455. AndroidUseNativeControls: false,
  456. // forces the hour marker (##:00:00)
  457. alwaysShowHours: false,
  458. // show framecount in timecode (##:00:00:00)
  459. showTimecodeFrameCount: false,
  460. // used when showTimecodeFrameCount is set to true
  461. framesPerSecond: 25,
  462. // turns keyboard support on and off for this instance
  463. enableKeyboard: true,
  464. // when this player starts, it will pause other players
  465. pauseOtherPlayers: false,
  466. poster: posterImg,
  467. success: function (mediaElement, domObject, instance) {
  468.  
  469. //make the medialement instance accesible by storing it. usually not necessary but safari has problems since wp version 4.9
  470. $.AviaVideoAPI.players[fv.attr('id').replace(/_html5/, '')] = instance;
  471.  
  472. setTimeout(function () {
  473. if (mediaElement.pluginType == 'flash') {
  474. mediaElement.addEventListener('canplay', function () { fv.trigger('av-mediajs-loaded'); }, false);
  475. }
  476. else {
  477. fv.trigger('av-mediajs-loaded').addClass('av-mediajs-loaded');
  478. }
  479.  
  480. mediaElement.addEventListener('ended', function () { fv.trigger('av-mediajs-ended'); }, false);
  481.  
  482. var html5MediaElement = document.getElementById($(mediaElement).attr('id') + '_html5');
  483. if (html5MediaElement && html5MediaElement !== mediaElement) {
  484. mediaElement.addEventListener("ended", function () {
  485. $(html5MediaElement).trigger('av-mediajs-ended');
  486. });
  487. }
  488.  
  489. }, 10);
  490.  
  491. },
  492. // fires when a problem is detected
  493. error: function () {
  494.  
  495. },
  496.  
  497. // array of keyboard commands
  498. keyActions: []
  499. });
  500.  
  501. });
  502. };
  503.  
  504.  
  505.  
  506. // -------------------------------------------------------------------------------------------
  507. // hover effect for images
  508. // -------------------------------------------------------------------------------------------
  509. function avia_hover_effect(container) {
  510. //hover overlay for mobile device doesnt really make sense. in addition it often slows down the click event
  511. if ($.avia_utilities.isMobile) return;
  512.  
  513. if ($('body').hasClass('av-disable-avia-hover-effect')) {
  514. return;
  515. }
  516.  
  517. var overlay = "", cssTrans = $.avia_utilities.supports('transition');
  518.  
  519. if (container == 'body') {
  520. var elements = $('#main a img').parents('a').not('.noLightbox, .noLightbox a, .avia-gallery-thumb a, .ls-wp-container a, .noHover, .noHover a, .av-logo-container .logo a').add('#main .avia-hover-fx');
  521. }
  522. else {
  523. var elements = $('a img', container).parents('a').not('.noLightbox, .noLightbox a, .avia-gallery-thumb a, .ls-wp-container a, .noHover, .noHover a, .av-logo-container .logo a').add('.avia-hover-fx', container);
  524. }
  525.  
  526. elements.each(function (e) {
  527. var link = $(this),
  528. current = link.find('img:first');
  529.  
  530. if (current.hasClass('alignleft')) link.addClass('alignleft').css({ float: 'left', margin: 0, padding: 0 });
  531. if (current.hasClass('alignright')) link.addClass('alignright').css({ float: 'right', margin: 0, padding: 0 });
  532. if (current.hasClass('aligncenter')) link.addClass('aligncenter').css({ float: 'none', 'text-align': 'center', margin: 0, padding: 0 });
  533.  
  534. if (current.hasClass('alignnone')) {
  535. link.addClass('alignnone').css({ margin: 0, padding: 0 });;
  536. if (!link.css('display') || link.css('display') == 'inline') { link.css({ display: 'inline-block' }); }
  537. }
  538.  
  539. if (!link.css('position') || link.css('position') == 'static') { link.css({ position: 'relative', overflow: 'hidden' }); }
  540.  
  541. var url = link.attr('href'),
  542. span_class = "overlay-type-video",
  543. opa = link.data('opacity') || 0.7,
  544. overlay_offset = 5,
  545. overlay = link.find('.image-overlay');
  546.  
  547. if (url) {
  548. if (url.match(/(jpg|gif|jpeg|png|tif)/)) span_class = "overlay-type-image";
  549. if (!url.match(/(jpg|gif|jpeg|png|\.tif|\.mov|\.swf|vimeo\.com|youtube\.com)/)) span_class = "overlay-type-extern";
  550. }
  551.  
  552. if (!overlay.length) {
  553. overlay = $("<span class='image-overlay " + span_class + "'><span class='image-overlay-inside'></span></span>").appendTo(link);
  554. }
  555.  
  556. link.on('mouseenter', function (e) {
  557. var current = link.find('img:first'),
  558. _self = current.get(0),
  559. outerH = current.outerHeight(),
  560. outerW = current.outerWidth(),
  561. pos = current.position(),
  562. linkCss = link.css('display'),
  563. overlay = link.find('.image-overlay');
  564.  
  565. if (outerH > 100) {
  566.  
  567. if (!overlay.length) {
  568. overlay = $("<span class='image-overlay " + span_class + "'><span class='image-overlay-inside'></span></span>").appendTo(link);
  569.  
  570. }
  571. //can be wrapped into if !overlay.length statement if chrome fixes fade in problem
  572. if (link.height() == 0) { link.addClass(_self.className); _self.className = ""; }
  573. if (!linkCss || linkCss == 'inline') { link.css({ display: 'block' }); }
  574. //end wrap
  575.  
  576. overlay.css({ left: (pos.left - overlay_offset) + parseInt(current.css("margin-left"), 10), top: pos.top + parseInt(current.css("margin-top"), 10) })
  577. .css({ overflow: 'hidden', display: 'block', 'height': outerH, 'width': (outerW + (2 * overlay_offset)) });
  578.  
  579. if (cssTrans === false) overlay.stop().animate({ opacity: opa }, 400);
  580. }
  581. else {
  582. overlay.css({ display: "none" });
  583. }
  584.  
  585. }).on('mouseleave', elements, function () {
  586.  
  587. if (overlay.length) {
  588. if (cssTrans === false) overlay.stop().animate({ opacity: 0 }, 400);
  589. }
  590. });
  591. });
  592. }
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601. // -------------------------------------------------------------------------------------------
  602. // Smooth scrooling when clicking on anchor links
  603. // todo: maybe use https://github.com/ryanburnette/scrollToBySpeed/blob/master/src/scrolltobyspeed.jquery.js in the future
  604. // -------------------------------------------------------------------------------------------
  605.  
  606. (function ($) {
  607. $.fn.avia_smoothscroll = function (apply_to_container) {
  608. if (!this.length) return;
  609.  
  610. var the_win = $(window),
  611. $header = $('#header'),
  612. $main = $('.html_header_top.html_header_sticky #main').not('.page-template-template-blank-php #main'),
  613. $meta = $('.html_header_top.html_header_unstick_top_disabled #header_meta'),
  614. $alt = $('.html_header_top:not(.html_top_nav_header) #header_main_alternate'),
  615. menu_above_logo = $('.html_header_top.html_top_nav_header'),
  616. shrink = $('.html_header_top.html_header_shrinking').length,
  617. frame = $('.av-frame-top'),
  618. fixedMainPadding = 0,
  619. isMobile = $.avia_utilities.isMobile,
  620. sticky_sub = $('.sticky_placeholder:first'),
  621. calc_main_padding = function () {
  622. if ($header.css('position') == "fixed") {
  623. var tempPadding = parseInt($main.data('scroll-offset'), 10) || 0,
  624. non_shrinking = parseInt($meta.outerHeight(), 10) || 0,
  625. non_shrinking2 = parseInt($alt.outerHeight(), 10) || 0;
  626.  
  627. if (tempPadding > 0 && shrink) {
  628. tempPadding = (tempPadding / 2) + non_shrinking + non_shrinking2;
  629. }
  630. else {
  631. tempPadding = tempPadding + non_shrinking + non_shrinking2;
  632. }
  633.  
  634. tempPadding += parseInt($('html').css('margin-top'), 10);
  635. fixedMainPadding = tempPadding;
  636. }
  637. else {
  638. fixedMainPadding = parseInt($('html').css('margin-top'), 10);
  639. }
  640.  
  641. if (frame.length) {
  642. fixedMainPadding += frame.height();
  643. }
  644.  
  645. if (menu_above_logo.length) {
  646. //if menu is above logo and we got a sticky height header
  647. fixedMainPadding = $('.html_header_sticky #header_main_alternate').height() + parseInt($('html').css('margin-top'), 10);
  648. }
  649.  
  650. if (isMobile) {
  651. fixedMainPadding = 0;
  652. }
  653.  
  654. };
  655.  
  656. if (isMobile) shrink = false;
  657.  
  658. calc_main_padding();
  659. the_win.on("debouncedresize av-height-change", calc_main_padding);
  660.  
  661. var hash = window.location.hash.replace(/\//g, "");
  662.  
  663. //if a scroll event occurs at pageload and an anchor is set and a coresponding element exists apply the offset to the event
  664. if (fixedMainPadding > 0 && hash && apply_to_container == 'body' && hash.charAt(1) != "!" && hash.indexOf("=") === -1) {
  665. var scroll_to_el = $(hash), modifier = 0;
  666.  
  667. if (scroll_to_el.length) {
  668. the_win.on('scroll.avia_first_scroll', function () {
  669. setTimeout(function () { //small delay so other scripts can perform necessary resizing
  670. if (sticky_sub.length && scroll_to_el.offset().top > sticky_sub.offset().top) { modifier = sticky_sub.outerHeight() - 3; }
  671. the_win.off('scroll.avia_first_scroll').scrollTop(scroll_to_el.offset().top - fixedMainPadding - modifier);
  672.  
  673. }, 10);
  674. });
  675. }
  676. }
  677.  
  678. return this.each(function () {
  679. $(this).click(function (e) {
  680.  
  681. var newHash = this.hash.replace(/\//g, ""),
  682. clicked = $(this),
  683. data = clicked.data();
  684.  
  685. if (newHash != '' && newHash != '#' && newHash != '#prev' && newHash != '#next' && !clicked.is('.comment-reply-link, #cancel-comment-reply-link, .no-scroll')) {
  686. var container = "", originHash = "";
  687.  
  688. if ("#next-section" == newHash) {
  689. originHash = newHash;
  690. container = clicked.parents('.container_wrap:eq(0)').nextAll('.container_wrap:eq(0)');
  691. newHash = '#' + container.attr('id');
  692. }
  693. else {
  694. container = $(this.hash.replace(/\//g, ""));
  695. }
  696.  
  697.  
  698.  
  699. if (container.length) {
  700. var cur_offset = the_win.scrollTop(),
  701. container_offset = container.offset().top,
  702. target = container_offset - fixedMainPadding,
  703. hash = window.location.hash,
  704. hash = hash.replace(/\//g, ""),
  705. oldLocation = window.location.href.replace(hash, ''),
  706. newLocation = this,
  707. duration = data.duration || 1200,
  708. easing = data.easing || 'easeInOutQuint';
  709.  
  710. if (sticky_sub.length && container_offset > sticky_sub.offset().top) { target -= sticky_sub.outerHeight() - 3; }
  711.  
  712. // make sure it's the same location
  713. if (oldLocation + newHash == newLocation || originHash) {
  714. if (cur_offset != target) // if current pos and target are the same dont scroll
  715. {
  716. if (!(cur_offset == 0 && target <= 0)) // if we are at the top dont try to scroll to top or above
  717. {
  718. the_win.trigger('avia_smooth_scroll_start');
  719.  
  720. // animate to target and set the hash to the window.location after the animation
  721. $('html:not(:animated),body:not(:animated)').animate({ scrollTop: target }, duration, easing, function () {
  722.  
  723. // add new hash to the browser location
  724. //window.location.href=newLocation;
  725. if (window.history.replaceState)
  726. window.history.replaceState("", "", newHash);
  727. });
  728. }
  729. }
  730. // cancel default click action
  731. e.preventDefault();
  732. }
  733. }
  734. }
  735. });
  736. });
  737. };
  738. })(jQuery);
  739.  
  740.  
  741. // -------------------------------------------------------------------------------------------
  742. // iframe fix for firefox and ie so they get proper z index
  743. // -------------------------------------------------------------------------------------------
  744. function avia_iframe_fix(container) {
  745. var iframe = jQuery('iframe[src*="youtube.com"]:not(.av_youtube_frame)', container),
  746. youtubeEmbed = jQuery('iframe[src*="youtube.com"]:not(.av_youtube_frame) object, iframe[src*="youtube.com"]:not(.av_youtube_frame) embed', container).attr('wmode', 'opaque');
  747.  
  748. iframe.each(function () {
  749. var current = jQuery(this),
  750. src = current.attr('src');
  751.  
  752. if (src) {
  753. if (src.indexOf('?') !== -1) {
  754. src += "&wmode=opaque&rel=0";
  755. }
  756. else {
  757. src += "?wmode=opaque&rel=0";
  758. }
  759.  
  760. current.attr('src', src);
  761. }
  762. });
  763. }
  764.  
  765. // -------------------------------------------------------------------------------------------
  766. // small js fixes for pixel perfection :)
  767. // -------------------------------------------------------------------------------------------
  768. function avia_small_fixes(container) {
  769. if (!container) container = document;
  770.  
  771. //make sure that iframes do resize correctly. uses css padding bottom iframe trick
  772. var win = jQuery(window),
  773. iframes = jQuery('.avia-iframe-wrap iframe:not(.avia-slideshow iframe):not( iframe.no_resize):not(.avia-video iframe)', container),
  774. adjust_iframes = function () {
  775. iframes.each(function () {
  776.  
  777. var iframe = jQuery(this), parent = iframe.parent(), proportions = 56.25;
  778.  
  779. if (this.width && this.height) {
  780. proportions = (100 / this.width) * this.height;
  781. parent.css({ "padding-bottom": proportions + "%" });
  782. }
  783. });
  784. };
  785.  
  786. adjust_iframes();
  787.  
  788. }
  789.  
  790. function avia_scroll_top_fade() {
  791. var win = $(window),
  792. timeo = false,
  793. scroll_top = $('#scroll-top-link'),
  794. set_status = function () {
  795. var st = win.scrollTop();
  796.  
  797. if (st < 500) {
  798. scroll_top.removeClass('avia_pop_class');
  799. }
  800. else if (!scroll_top.is('.avia_pop_class')) {
  801. scroll_top.addClass('avia_pop_class');
  802. }
  803. };
  804.  
  805. win.on('scroll', function () { window.requestAnimationFrame(set_status); });
  806. set_status();
  807. }
  808.  
  809. function avia_hamburger_menu() {
  810. var header = $('#header'),
  811. header_main = $('#main .av-logo-container'), //check if we got a top menu that is above the header
  812. menu = $('#avia-menu'),
  813. burger_wrap = $('.av-burger-menu-main a'),
  814. htmlEL = $('html').eq(0),
  815. overlay = $('<div class="av-burger-overlay"></div>'),
  816. overlay_scroll = $('<div class="av-burger-overlay-scroll"></div>').appendTo(overlay),
  817. inner_overlay = $('<div class="av-burger-overlay-inner"></div>').appendTo(overlay_scroll),
  818. bgColor = $('<div class="av-burger-overlay-bg"></div>').appendTo(overlay),
  819. animating = false,
  820. first_level = {},
  821. logo_container = $('.av-logo-container .inner-container'),
  822. menu_in_logo_container = logo_container.find('.main_menu'),
  823. cloneFirst = htmlEL.is('.html_av-submenu-display-click.html_av-submenu-clone, .html_av-submenu-display-hover.html_av-submenu-clone'),
  824. menu_generated = false,
  825. cloned_menu_cnt = 0;
  826.  
  827. /**
  828. * Check for alternate mobile menu
  829. */
  830. var alternate = $('#avia_alternate_menu');
  831. if (alternate.length > 0) {
  832. menu = alternate;
  833. }
  834.  
  835. var set_list_container_height = function () {
  836. //necessary for ios since the height is usually not 100% but 100% - menu bar which can be requested by window.innerHeight
  837. if ($.avia_utilities.isMobile) {
  838. overlay_scroll.outerHeight(window.innerHeight);
  839. }
  840. },
  841. create_list = function (items, append_to) {
  842. if (!items) return;
  843.  
  844. var list, link, current, subitems, megacolumns, sub_current, sub_current_list, new_li, new_ul;
  845.  
  846. items.each(function () {
  847. current = $(this);
  848. subitems = current.find(' > .sub-menu > li'); //find sublists of a regular defined menu
  849. if (subitems.length == 0) {
  850. subitems = current.find(' > .children > li'); //find sublists of a fallback menu
  851. }
  852. megacolumns = current.find('.avia_mega_div > .sub-menu > li.menu-item');
  853.  
  854. // href = '#': we have a custom link that should not link to something - is also in use by megamenu for titles
  855. var cur_menu = current.find('>a');
  856. var clone_events = true;
  857.  
  858. if (cur_menu.length) {
  859. if (cur_menu.get(0).hash == '#' || 'undefined' == typeof cur_menu.attr('href') || cur_menu.attr('href') == '#') {
  860. // eventhandler conflict 'click' by megamenu (returns false) - ignore all handlers
  861. if (subitems.length > 0 || megacolumns.length > 0) {
  862. clone_events = false;
  863. }
  864. }
  865. }
  866.  
  867. link = cur_menu.clone(clone_events).attr('style', '');
  868.  
  869. // megamenus can have '' as url in top menu - allow click event in burger
  870. if ('undefined' == typeof cur_menu.attr('href')) {
  871. link.attr('href', '#');
  872. }
  873.  
  874. new_li = $('<li>').append(link);
  875.  
  876. // Copy user set classes for menu items - these must not start with menu-item, page-item, page_item (used by default classes)
  877. var cls = [];
  878. if ('undefined' != typeof current.attr('class')) {
  879. cls = current.attr('class').split(/\s+/);
  880. $.each(cls, function (index, value) {
  881. if ((value.indexOf('menu-item') != 0) && (value.indexOf('page-item') < 0) && (value.indexOf('page_item') != 0) && (value.indexOf('dropdown_ul') < 0)) {
  882. // 'current-menu-item' is also copied !!
  883. new_li.addClass(value);
  884. }
  885. return true;
  886. });
  887. }
  888.  
  889. if ('undefined' != typeof current.attr('id') && '' != current.attr('id')) {
  890. new_li.addClass(current.attr('id'));
  891. }
  892. else {
  893. // fallback menu has no id -> try to find page id in class
  894. $.each(cls, function (index, value) {
  895. if (value.indexOf('page-item-') >= 0) {
  896. new_li.addClass(value);
  897. return false;
  898. }
  899. });
  900. }
  901.  
  902. append_to.append(new_li);
  903.  
  904. if (subitems.length) {
  905. new_ul = $('<ul class="sub-menu">').appendTo(new_li);
  906.  
  907. if (cloneFirst && (link.get(0).hash != '#' && link.attr('href') != '#')) {
  908. new_li.clone(true).prependTo(new_ul);
  909. }
  910.  
  911. new_li.addClass('av-width-submenu').find('>a').append('<span class="av-submenu-indicator">');
  912.  
  913. create_list(subitems, new_ul);
  914. }
  915. else if (megacolumns.length) //if we got no normal sublists try megamenu columns and sublists
  916. {
  917. new_ul = $('<ul class="sub-menu">').appendTo(new_li);
  918.  
  919. if (cloneFirst && (link.get(0).hash != '#' && link.attr('href') != '#')) {
  920. new_li.clone(true).prependTo(new_ul);
  921. }
  922.  
  923. megacolumns.each(function (iteration) {
  924. var megacolumn = $(this),
  925. mega_current = megacolumn.find('> .sub-menu'), // can be 0 if only a column is used without submenus
  926. mega_title = megacolumn.find('> .mega_menu_title'),
  927. mega_title_link = mega_title.find('a').attr('href') || "#",
  928. current_megas = mega_current.length > 0 ? mega_current.find('>li') : null,
  929. mega_title_set = false,
  930. mega_link = new_li.find('>a'),
  931. hide_enty = '';
  932.  
  933. // ignore columns that have no actual link and no subitems
  934. if ((current_megas === null) || (current_megas.length == 0)) {
  935. if (mega_title_link == '#') {
  936. hide_enty = ' style="display: none;"';
  937. }
  938. }
  939.  
  940. if (iteration == 0) new_li.addClass('av-width-submenu').find('>a').append('<span class="av-submenu-indicator">');
  941.  
  942. //if we got a title split up submenu items into multiple columns
  943. if (mega_title.length && mega_title.text() != "") {
  944. mega_title_set = true;
  945.  
  946. //if we are within the first iteration we got a new submenu, otherwise we start a new one
  947. if (iteration > 0) {
  948. var check_li = new_li.parents('li').eq(0);
  949.  
  950. if (check_li.length) new_li = check_li;
  951.  
  952. new_ul = $('<ul class="sub-menu">').appendTo(new_li);
  953. }
  954.  
  955.  
  956. new_li = $('<li' + hide_enty + '>').appendTo(new_ul);
  957. new_ul = $('<ul class="sub-menu">').appendTo(new_li);
  958.  
  959. $('<a href="' + mega_title_link + '"><span class="avia-bullet"></span><span class="avia-menu-text">' + mega_title.text() + '</span></a>').insertBefore(new_ul);
  960. mega_link = new_li.find('>a');
  961.  
  962. // Clone if we have submenus
  963. if (cloneFirst && (mega_current.length > 0) && (mega_link.length && mega_link.get(0).hash != '#' && mega_link.attr('href') != '#')) {
  964. new_li.clone(true).addClass('av-cloned-title').prependTo(new_ul);
  965. }
  966.  
  967. }
  968.  
  969. // do not append av-submenu-indicator if no submenus (otherwise link action is blocked !!!)
  970. if (mega_title_set && (mega_current.length > 0)) new_li.addClass('av-width-submenu').find('>a').append('<span class="av-submenu-indicator">');
  971. create_list(current_megas, new_ul);
  972. });
  973.  
  974. }
  975.  
  976. });
  977.  
  978. burger_wrap.trigger('avia_burger_list_created');
  979. return list;
  980. };
  981.  
  982. var burger_ul, burger;
  983.  
  984. //prevent scrolling of outer window when scrolling inside
  985. $('body').on('mousewheel DOMMouseScroll touchmove', '.av-burger-overlay-scroll', function (e) {
  986.  
  987. var height = this.offsetHeight,
  988. scrollHeight = this.scrollHeight,
  989. direction = e.originalEvent.wheelDelta;
  990.  
  991. if (scrollHeight != this.clientHeight) {
  992. if ((this.scrollTop >= (scrollHeight - height) && direction < 0) || (this.scrollTop <= 0 && direction > 0)) {
  993. e.preventDefault();
  994. }
  995. }
  996. else {
  997. e.preventDefault();
  998. }
  999. });
  1000.  
  1001. //prevent scrolling for the rest of the screen
  1002. $(document).on('mousewheel DOMMouseScroll touchmove', '.av-burger-overlay-bg, .av-burger-overlay-active .av-burger-menu-main', function (e) {
  1003. e.preventDefault();
  1004. });
  1005.  
  1006. //prevent scrolling on mobile devices
  1007. var touchPos = {};
  1008.  
  1009. $(document).on('touchstart', '.av-burger-overlay-scroll', function (e) {
  1010. touchPos.Y = e.originalEvent.touches[0].clientY;
  1011. });
  1012.  
  1013. $(document).on('touchend', '.av-burger-overlay-scroll', function (e) {
  1014. touchPos = {};
  1015. });
  1016.  
  1017. //prevent rubberband scrolling http://blog.christoffer.me/six-things-i-learnt-about-ios-safaris-rubber-band-scrolling/
  1018. $(document).on('touchmove', '.av-burger-overlay-scroll', function (e) {
  1019. if (!touchPos.Y) {
  1020. touchPos.Y = e.originalEvent.touches[0].clientY;
  1021. }
  1022.  
  1023. var differenceY = e.originalEvent.touches[0].clientY - touchPos.Y,
  1024. element = this,
  1025. top = element.scrollTop,
  1026. totalScroll = element.scrollHeight,
  1027. currentScroll = top + element.offsetHeight,
  1028. direction = differenceY > 0 ? "up" : "down";
  1029.  
  1030. $('body').get(0).scrollTop = touchPos.body;
  1031.  
  1032. if (top <= 0) {
  1033. if (direction == "up") e.preventDefault();
  1034.  
  1035. } else if (currentScroll >= totalScroll) {
  1036. if (direction == "down") e.preventDefault();
  1037. }
  1038. });
  1039.  
  1040. $(window).on('debouncedresize', function (e) {
  1041. // close burger menu when returning to desktop
  1042. if (burger && burger.length) {
  1043. if (!burger_wrap.is(':visible')) {
  1044. burger.filter(".is-active").parents('a').eq(0).trigger('click');
  1045. }
  1046. }
  1047.  
  1048. set_list_container_height();
  1049. });
  1050.  
  1051. //close overlay on overlay click
  1052. $('.html_av-overlay-side').on('click', '.av-burger-overlay-bg', function (e) {
  1053. e.preventDefault();
  1054. burger.parents('a').eq(0).trigger('click');
  1055. });
  1056.  
  1057. //close overlay when smooth scrollign begins
  1058. $(window).on('avia_smooth_scroll_start', function () {
  1059. if (burger && burger.length) {
  1060. burger.filter(".is-active").parents('a').eq(0).trigger('click');
  1061. }
  1062. });
  1063.  
  1064.  
  1065. //toogle hide/show for submenu items
  1066. $('.html_av-submenu-display-hover').on('mouseenter', '.av-width-submenu', function (e) {
  1067. $(this).children("ul.sub-menu").slideDown('fast');
  1068. });
  1069.  
  1070. $('.html_av-submenu-display-hover').on('mouseleave', '.av-width-submenu', function (e) {
  1071. $(this).children("ul.sub-menu").slideUp('fast');
  1072. });
  1073.  
  1074. $('.html_av-submenu-display-hover').on('click', '.av-width-submenu > a', function (e) {
  1075. e.preventDefault();
  1076. e.stopImmediatePropagation();
  1077. });
  1078.  
  1079. // for mobile we use same behaviour as submenu-display-click
  1080. $('.html_av-submenu-display-hover').on('touchstart', '.av-width-submenu > a', function (e) {
  1081. var menu = $(this);
  1082. toggle_submenu(menu, e);
  1083. });
  1084.  
  1085.  
  1086. //toogle hide/show for submenu items
  1087. $('.html_av-submenu-display-click').on('click', '.av-width-submenu > a', function (e) {
  1088. var menu = $(this);
  1089. toggle_submenu(menu, e);
  1090. });
  1091.  
  1092.  
  1093. // close mobile menu if click on active menu item
  1094. $('.html_av-submenu-display-click').on('click', '.av-burger-overlay a', function (e) {
  1095. var loc = window.location.href.match(/(^[^#]*)/)[0];
  1096. var cur = $(this).attr('href').match(/(^[^#]*)/)[0];
  1097.  
  1098. if (cur == loc) {
  1099. e.preventDefault();
  1100. e.stopImmediatePropagation();
  1101.  
  1102. burger.parents('a').eq(0).trigger('click');
  1103. return false;
  1104. }
  1105. return true;
  1106. });
  1107.  
  1108.  
  1109. function toggle_submenu(menu, e) {
  1110. e.preventDefault();
  1111. e.stopImmediatePropagation();
  1112.  
  1113. var parent = menu.parents('li').eq(0);
  1114.  
  1115. parent.toggleClass('av-show-submenu');
  1116.  
  1117. if (parent.is('.av-show-submenu')) {
  1118. parent.children("ul.sub-menu").slideDown('fast');
  1119. }
  1120. else {
  1121. parent.children("ul.sub-menu").slideUp('fast');
  1122. }
  1123. };
  1124.  
  1125.  
  1126. (function normalize_layout() {
  1127. //if we got the menu outside of the main menu container we need to add it to the container as well
  1128. if (menu_in_logo_container.length) return;
  1129.  
  1130. var menu2 = $('#header .main_menu').clone(true),
  1131. ul = menu2.find('ul.av-main-nav'),
  1132. id = ul.attr('id');
  1133.  
  1134. if ('string' == typeof id && '' != id.trim()) {
  1135. ul.attr('id', id + '-' + cloned_menu_cnt++);
  1136. }
  1137. menu2.find('.menu-item:not(.menu-item-avia-special)').remove();
  1138. menu2.insertAfter(logo_container.find('.logo').first());
  1139.  
  1140. //check if we got social icons and append it to the secondary menu
  1141. var social = $('#header .social_bookmarks').clone(true);
  1142. if (!social.length) social = $('.av-logo-container .social_bookmarks').clone(true);
  1143.  
  1144. if (social.length) {
  1145. menu2.find('.avia-menu').addClass('av_menu_icon_beside');
  1146. menu2.append(social);
  1147. }
  1148.  
  1149. //re select the burger menu if we added a new one
  1150. burger_wrap = $('.av-burger-menu-main a');
  1151. }());
  1152.  
  1153. $('body').click(function (e) {
  1154. if ($(e.target).is('.av-hamburger, av-burger-menu-main, av-burger-menu-main a')) return;
  1155.  
  1156. burger = $(this).find('.av-hamburger'),
  1157. animating = true;
  1158.  
  1159. if (burger.is(".is-active")) {
  1160. burger.removeClass("is-active");
  1161. htmlEL.removeClass("av-burger-overlay-active-delayed");
  1162.  
  1163. overlay.animate({ opacity: 0 }, function () {
  1164. overlay.css({ display: 'none' });
  1165. htmlEL.removeClass("av-burger-overlay-active");
  1166. animating = false;
  1167. });
  1168.  
  1169. }
  1170. });
  1171.  
  1172. function close_menu() {
  1173. burger_wrap.click(function (e) {
  1174. if (animating) return;
  1175. burger = $(this).find('.av-hamburger'),
  1176. animating = true;
  1177.  
  1178. if (!menu_generated) {
  1179. menu_generated = true;
  1180. burger.addClass("av-inserted-main-menu");
  1181.  
  1182. burger_ul = $('<ul>').attr({ id: 'av-burger-menu-ul', class: '' });
  1183. var first_level_items = menu.find('> li:not(.menu-item-avia-special)'); //select all first level items that are not special items
  1184. var list = create_list(first_level_items, burger_ul);
  1185.  
  1186. burger_ul.find('.noMobile').remove(); //remove any menu items with the class noMobile so user can filter manually if he wants
  1187. burger_ul.appendTo(inner_overlay);
  1188. first_level = inner_overlay.find('#av-burger-menu-ul > li');
  1189.  
  1190. if ($.fn.avia_smoothscroll) {
  1191. $('a[href*="#"]', overlay).avia_smoothscroll(overlay);
  1192. }
  1193. }
  1194.  
  1195. if (burger.is(".is-active")) {
  1196. burger.removeClass("is-active");
  1197. htmlEL.removeClass("av-burger-overlay-active-delayed");
  1198.  
  1199. overlay.animate({ opacity: 0 }, function () {
  1200. overlay.css({ display: 'none' });
  1201. htmlEL.removeClass("av-burger-overlay-active");
  1202. animating = false;
  1203. });
  1204.  
  1205. }
  1206. else {
  1207. set_list_container_height();
  1208.  
  1209. var offsetTop = header_main.length ? header_main.outerHeight() + header_main.position().top : header.outerHeight() + header.position().top;
  1210.  
  1211. overlay.appendTo($(e.target).parents('.avia-menu'));
  1212.  
  1213. burger_ul.css({ padding: (offsetTop) + "px 0px" });
  1214.  
  1215. first_level.removeClass('av-active-burger-items');
  1216.  
  1217. burger.addClass("is-active");
  1218. htmlEL.addClass("av-burger-overlay-active");
  1219. overlay.css({ display: 'block' }).animate({ opacity: 1 }, function () {
  1220. animating = false;
  1221. });
  1222.  
  1223. setTimeout(function () {
  1224. htmlEL.addClass("av-burger-overlay-active-delayed");
  1225.  
  1226. }, 100);
  1227.  
  1228. first_level.each(function (i) {
  1229. var _self = $(this);
  1230. setTimeout(function () {
  1231. _self.addClass('av-active-burger-items');
  1232. }, (i + 1) * 125);
  1233. });
  1234.  
  1235. }
  1236.  
  1237. e.preventDefault();
  1238. });
  1239. }
  1240.  
  1241. close_menu();
  1242. }
  1243.  
  1244.  
  1245.  
  1246.  
  1247. $.AviaAjaxSearch = function (options) {
  1248. var defaults = {
  1249. delay: 300, //delay in ms until the user stops typing.
  1250. minChars: 3, //dont start searching before we got at least that much characters
  1251. scope: 'body'
  1252.  
  1253. };
  1254.  
  1255. this.options = $.extend({}, defaults, options);
  1256. this.scope = $(this.options.scope);
  1257. this.timer = false;
  1258. this.lastVal = "";
  1259.  
  1260. this.bind_events();
  1261.  
  1262.  
  1263. };
  1264.  
  1265.  
  1266. $.AviaAjaxSearch.prototype =
  1267. {
  1268.  
  1269. bind_events: function () {
  1270. this.scope.on('keyup', '#s:not(".av_disable_ajax_search #s")', $.proxy(this.try_search, this));
  1271. this.scope.on('click', '#s.av-results-parked', $.proxy(this.reset, this));
  1272.  
  1273. },
  1274.  
  1275. try_search: function (e) {
  1276. var form = $(e.currentTarget).parents('form:eq(0)'),
  1277. resultscontainer = form.find('.ajax_search_response');
  1278.  
  1279. clearTimeout(this.timer);
  1280.  
  1281. //only execute search if chars are at least "minChars" and search differs from last one
  1282. if (e.currentTarget.value.length >= this.options.minChars && this.lastVal != $.trim(e.currentTarget.value)) {
  1283. //wait at least "delay" milliseconds to execute ajax. if user types again during that time dont execute
  1284. this.timer = setTimeout($.proxy(this.do_search, this, e), this.options.delay);
  1285.  
  1286. }
  1287. //remove the results container if the input field has been emptied
  1288. else if (e.currentTarget.value.length == 0) {
  1289. this.timer = setTimeout($.proxy(this.reset, this, e), this.options.delay);
  1290. }
  1291.  
  1292. // close on ESC
  1293. if (e.keyCode === 27) {
  1294. this.reset(e);
  1295. }
  1296.  
  1297. },
  1298.  
  1299. reset: function (e) {
  1300. var form = $(e.currentTarget).parents('form:eq(0)'),
  1301. resultscontainer = form.find('.ajax_search_response'),
  1302. alternative_resultscontainer = $(form.attr('data-ajaxcontainer')).find('.ajax_search_response'),
  1303. searchInput = $(e.currentTarget);
  1304.  
  1305. // bring back results that were hidden when user clicked outside the form element
  1306. if ($(e.currentTarget).hasClass('av-results-parked')) {
  1307. resultscontainer.show();
  1308. alternative_resultscontainer.show();
  1309.  
  1310. // in case results container is attached to body
  1311. $('body > .ajax_search_response').show();
  1312. }
  1313. else {
  1314. // remove results and delete the input value
  1315. resultscontainer.remove();
  1316. alternative_resultscontainer.remove();
  1317. searchInput.val('');
  1318.  
  1319. // in case results container is attached to body
  1320. $('body > .ajax_search_response').remove();
  1321. }
  1322.  
  1323.  
  1324. },
  1325.  
  1326. do_search: function (e) {
  1327. var obj = this,
  1328. currentField = $(e.currentTarget).attr("autocomplete", "off"),
  1329. currentFieldWrapper = $(e.currentTarget).parents('.av_searchform_wrapper:eq(0)'),
  1330. currentField_position = currentFieldWrapper.offset(),
  1331. currentField_width = currentFieldWrapper.outerWidth(),
  1332. currentField_height = currentFieldWrapper.outerHeight(),
  1333. form = currentField.parents('form:eq(0)'),
  1334. submitbtn = form.find('#searchsubmit'),
  1335. resultscontainer = form,
  1336. results = resultscontainer.find('.ajax_search_response'),
  1337. loading = $('<div class="ajax_load"><span class="ajax_load_inner"></span></div>'),
  1338. action = form.attr('action'),
  1339. values = form.serialize();
  1340. values += '&action=avia_ajax_search';
  1341.  
  1342. // define results div if not found
  1343. if (!results.length) {
  1344. results = $('<div class="ajax_search_response" style="display:none;"></div>');
  1345. }
  1346.  
  1347. // add class to differentiate betweeen search element and header search
  1348. if (form.attr('id') == 'searchform_element') {
  1349. results.addClass('av_searchform_element_results');
  1350. }
  1351.  
  1352. //check if the form got get parameters applied and also apply them
  1353. if (action.indexOf('?') != -1) {
  1354. action = action.split('?');
  1355. values += "&" + action[1];
  1356. }
  1357.  
  1358. //check if there is a results container defined
  1359. if (form.attr('data-ajaxcontainer')) {
  1360.  
  1361. var rescon = form.attr('data-ajaxcontainer');
  1362.  
  1363. // check if defined container exists
  1364. if ($(rescon).length) {
  1365.  
  1366. // remove previous search results
  1367. $(rescon).find('.ajax_search_response').remove();
  1368.  
  1369. resultscontainer = $(rescon);
  1370. }
  1371.  
  1372. }
  1373.  
  1374. /*
  1375. * For the placement option: "Under the search form - overlay other content",
  1376. * we have to attach the results to the body in order to overlay the other content,
  1377. * and we calculate it's position using the search field
  1378. */
  1379.  
  1380. results_css = {};
  1381.  
  1382. if (form.hasClass('av_results_container_fixed')) {
  1383.  
  1384. // remove previous search results
  1385. $('body').find('.ajax_search_response').remove();
  1386.  
  1387. resultscontainer = $('body');
  1388.  
  1389. // add class and position to results if defined above
  1390. var results_css = {
  1391. top: currentField_position.top + currentField_height,
  1392. left: currentField_position.left,
  1393. width: currentField_width
  1394. };
  1395.  
  1396. // make sure default stylesheet is applied
  1397. results.addClass('main_color');
  1398.  
  1399. // remove results and reset if window is resized
  1400. $(window).resize(function () {
  1401. results.remove();
  1402. $.proxy(this.reset, this);
  1403. currentField.val('');
  1404. });
  1405.  
  1406. }
  1407.  
  1408. // add additional styles
  1409. if (form.attr('data-results_style')) {
  1410. var results_style = JSON.parse(form.attr('data-results_style'));
  1411. results_css = Object.assign(results_css, results_style);
  1412.  
  1413. // add class if font color is applied, so we can use color: inherit
  1414. if ("color" in results_css) {
  1415. results.addClass('av_has_custom_color');
  1416. }
  1417.  
  1418. }
  1419.  
  1420. // apply inline styles
  1421. results.css(results_css);
  1422.  
  1423. // add .container class if resultscontainer in a color section
  1424. if (resultscontainer.hasClass('avia-section')) {
  1425. results.addClass('container');
  1426. }
  1427.  
  1428. // append results to defined container
  1429. results.appendTo(resultscontainer);
  1430.  
  1431.  
  1432. //return if we already hit a no result and user is still typing
  1433. if (results.find('.ajax_not_found').length && e.currentTarget.value.indexOf(this.lastVal) != -1) return;
  1434.  
  1435. this.lastVal = e.currentTarget.value;
  1436.  
  1437. $.ajax({
  1438. url: avia_framework_globals.ajaxurl,
  1439. type: "POST",
  1440. data: values,
  1441. beforeSend: function () {
  1442. // add loader after submit button
  1443. loading.insertAfter(submitbtn);
  1444. form.addClass('ajax_loading_now');
  1445. },
  1446. success: function (response) {
  1447. if (response == 0) response = "";
  1448. results.html(response).show();
  1449. },
  1450. complete: function () {
  1451. loading.remove();
  1452. form.removeClass('ajax_loading_now');
  1453. }
  1454. });
  1455.  
  1456. // Hide search resuls if user clicks anywhere outside the form element
  1457. $(document).on('click', function (e) {
  1458. if (!$(e.target).closest(form).length) {
  1459. if ($(results).is(":visible")) {
  1460. $(results).hide();
  1461. currentField.addClass('av-results-parked');
  1462. }
  1463. }
  1464. });
  1465. }
  1466.  
  1467.  
  1468. };
  1469.  
  1470.  
  1471.  
  1472.  
  1473.  
  1474.  
  1475.  
  1476.  
  1477.  
  1478.  
  1479. $.AviaTooltip = function (options) {
  1480. var defaults = {
  1481. delay: 1500, //delay in ms until the tooltip appears
  1482. delayOut: 300, //delay in ms when instant showing should stop
  1483. delayHide: 0, //delay hiding of tooltip in ms
  1484. "class": "avia-tooltip", //tooltip classname for css styling and alignment
  1485. scope: "body", //area the tooltip should be applied to
  1486. data: "avia-tooltip", //data attribute that contains the tooltip text
  1487. attach: "body", //either attach the tooltip to the "mouse" or to the "element" // todo: implement mouse, make sure that it doesnt overlap with screen borders
  1488. event: 'mouseenter', //mousenter and leave or click and leave
  1489. position: 'top', //top or bottom
  1490. extraClass: 'avia-tooltip-class', //extra class that is defined by a tooltip element data attribute
  1491. permanent: false, // always display the tooltip?
  1492. within_screen: false // if the tooltip is displayed outside the screen adjust its position
  1493.  
  1494. };
  1495.  
  1496. this.options = $.extend({}, defaults, options);
  1497. this.body = $('body');
  1498. this.scope = $(this.options.scope);
  1499. this.tooltip = $('<div class="' + this.options['class'] + ' avia-tt"><span class="avia-arrow-wrap"><span class="avia-arrow"></span></span></div>');
  1500. this.inner = $('<div class="inner_tooltip"></div>').prependTo(this.tooltip);
  1501. this.open = false;
  1502. this.timer = false;
  1503. this.active = false;
  1504.  
  1505. this.bind_events();
  1506. };
  1507.  
  1508. $.AviaTooltip.openTTs = [];
  1509. $.AviaTooltip.openTT_Elements = [];
  1510.  
  1511. $.AviaTooltip.prototype =
  1512. {
  1513. bind_events: function () {
  1514. var perma_tooltips = '.av-permanent-tooltip [data-' + this.options.data + ']',
  1515. default_tooltips = '[data-' + this.options.data + ']:not( .av-permanent-tooltip [data-' + this.options.data + '])';
  1516.  
  1517. this.scope.on('av_permanent_show', perma_tooltips, $.proxy(this.display_tooltip, this));
  1518. $(perma_tooltips).addClass('av-perma-tooltip').trigger('av_permanent_show');
  1519.  
  1520.  
  1521. this.scope.on(this.options.event + ' mouseleave', default_tooltips, $.proxy(this.start_countdown, this));
  1522.  
  1523. if (this.options.event != 'click') {
  1524. this.scope.on('mouseleave', default_tooltips, $.proxy(this.hide_tooltip, this));
  1525. this.scope.on('click', default_tooltips, $.proxy(this.hide_on_click_tooltip, this));
  1526. }
  1527. else {
  1528. this.body.on('mousedown', $.proxy(this.hide_tooltip, this));
  1529. }
  1530.  
  1531. },
  1532.  
  1533. start_countdown: function (e) {
  1534. clearTimeout(this.timer);
  1535.  
  1536. var target = this.options.event == "click" ? e.target : e.currentTarget,
  1537. element = $(target);
  1538.  
  1539. if (e.type == this.options.event) {
  1540. var delay = this.options.event == 'click' ? 0 : this.open ? 0 : this.options.delay;
  1541.  
  1542. this.timer = setTimeout($.proxy(this.display_tooltip, this, e), delay);
  1543. }
  1544. else if (e.type == 'mouseleave') {
  1545. if (!element.hasClass('av-close-on-click-tooltip')) {
  1546. this.timer = setTimeout($.proxy(this.stop_instant_open, this, e), this.options.delayOut);
  1547. }
  1548. }
  1549. e.preventDefault();
  1550. },
  1551.  
  1552. reset_countdown: function (e) {
  1553. clearTimeout(this.timer);
  1554. this.timer = false;
  1555. },
  1556.  
  1557. display_tooltip: function (e) {
  1558. var _self = this,
  1559. target = this.options.event == "click" ? e.target : e.currentTarget,
  1560. element = $(target),
  1561. text = element.data(this.options.data),
  1562. tip_index = element.data('avia-created-tooltip'),
  1563. extraClass = element.data('avia-tooltip-class'),
  1564. attach = this.options.attach == 'element' ? element : this.body,
  1565. offset = this.options.attach == 'element' ? element.position() : element.offset(),
  1566. position = element.data('avia-tooltip-position'),
  1567. align = element.data('avia-tooltip-alignment'),
  1568. force_append = false,
  1569. newTip = false,
  1570. is_new_tip = false;
  1571.  
  1572. text = $.trim(text);
  1573.  
  1574. if (element.is('.av-perma-tooltip')) {
  1575. offset = { top: 0, left: 0 };
  1576. attach = element;
  1577. force_append = true;
  1578. }
  1579.  
  1580. if (text == "") return;
  1581. if (position == "" || typeof position == 'undefined') position = this.options.position;
  1582. if (align == "" || typeof align == 'undefined') align = 'center';
  1583.  
  1584. if (typeof tip_index != 'undefined') {
  1585. newTip = $.AviaTooltip.openTTs[tip_index];
  1586. }
  1587. else {
  1588. this.inner.html(text);
  1589. newTip = this.tooltip.clone();
  1590. is_new_tip = true;
  1591.  
  1592. if (this.options.attach == 'element' && force_append !== true) {
  1593. newTip.insertAfter(attach);
  1594. }
  1595. else {
  1596. newTip.appendTo(attach);
  1597. }
  1598.  
  1599. if (extraClass != "") newTip.addClass(extraClass);
  1600. }
  1601.  
  1602. if (this.open && this.active == newTip) {
  1603. return;
  1604. }
  1605.  
  1606. if (element.hasClass('av-close-on-click-tooltip')) {
  1607. this.hide_all_tooltips();
  1608. }
  1609.  
  1610. this.open = true;
  1611. this.active = newTip;
  1612.  
  1613. if ((newTip.is(':animated:visible') && e.type == 'click') || element.is('.' + this.options['class']) || element.parents('.' + this.options['class']).length != 0) return;
  1614.  
  1615.  
  1616. var animate1 = {}, animate2 = {}, pos1 = "", pos2 = "";
  1617.  
  1618. if (position == "top" || position == "bottom") {
  1619. switch (align) {
  1620. case "left": pos2 = offset.left; break;
  1621. case "right": pos2 = offset.left + element.outerWidth() - newTip.outerWidth(); break;
  1622. default: pos2 = (offset.left + (element.outerWidth() / 2)) - (newTip.outerWidth() / 2); break;
  1623. }
  1624.  
  1625. if (_self.options.within_screen) //used to keep search field inside screen
  1626. {
  1627. var boundary = element.offset().left + (element.outerWidth() / 2) - (newTip.outerWidth() / 2) + parseInt(newTip.css('margin-left'), 10);
  1628. if (boundary < 0) {
  1629. pos2 = pos2 - boundary;
  1630. }
  1631.  
  1632. }
  1633. }
  1634. else {
  1635. switch (align) {
  1636. case "top": pos1 = offset.top; break;
  1637. case "bottom": pos1 = offset.top + element.outerHeight() - newTip.outerHeight(); break;
  1638. default: pos1 = (offset.top + (element.outerHeight() / 2)) - (newTip.outerHeight() / 2); break;
  1639. }
  1640. }
  1641.  
  1642. switch (position) {
  1643. case "top":
  1644. pos1 = offset.top - newTip.outerHeight();
  1645. animate1 = { top: pos1 - 10, left: pos2 };
  1646. animate2 = { top: pos1 };
  1647. break;
  1648. case "bottom":
  1649. pos1 = offset.top + element.outerHeight();
  1650. animate1 = { top: pos1 + 10, left: pos2 };
  1651. animate2 = { top: pos1 };
  1652. break;
  1653. case "left":
  1654. pos2 = offset.left - newTip.outerWidth();
  1655. animate1 = { top: pos1, left: pos2 - 10 };
  1656. animate2 = { left: pos2 };
  1657. break;
  1658. case "right":
  1659. pos2 = offset.left + element.outerWidth();
  1660. animate1 = { top: pos1, left: pos2 + 10 };
  1661. animate2 = { left: pos2 };
  1662. break;
  1663. }
  1664.  
  1665. animate1['display'] = "block";
  1666. animate1['opacity'] = 0;
  1667. animate2['opacity'] = 1;
  1668.  
  1669.  
  1670. newTip.css(animate1).stop().animate(animate2, 200);
  1671. newTip.find('input, textarea').focus();
  1672. if (is_new_tip) {
  1673. $.AviaTooltip.openTTs.push(newTip);
  1674. $.AviaTooltip.openTT_Elements.push(element);
  1675. element.data('avia-created-tooltip', $.AviaTooltip.openTTs.length - 1);
  1676. }
  1677. },
  1678.  
  1679. hide_on_click_tooltip: function (e) {
  1680. if (this.options.event == "click") {
  1681. return;
  1682. }
  1683.  
  1684. var element = $(e.currentTarget);
  1685.  
  1686. if (!element.hasClass('av-close-on-click-tooltip')) {
  1687. return;
  1688. }
  1689.  
  1690. if (!element.find('a')) {
  1691. e.preventDefault();
  1692. }
  1693.  
  1694. // Default behaviour when using mouse - click on active tooltip closes it (moving mouse to another tooltip close others automatically
  1695. // On mobile devices or when using touchscreen we show element on click (= old behaviour) and hide when same element
  1696. var ttip_index = element.data('avia-created-tooltip');
  1697.  
  1698. if ('undefined' != typeof ttip_index) {
  1699. var current = $.AviaTooltip.openTTs[ttip_index];
  1700. if ('undefined' != typeof current && current == this.active) {
  1701. this.hide_all_tooltips();
  1702. }
  1703. }
  1704.  
  1705. },
  1706.  
  1707. hide_all_tooltips: function () {
  1708. var ttip,
  1709. position,
  1710. element;
  1711.  
  1712. for (var index = 0; index < $.AviaTooltip.openTTs.length; ++index) {
  1713. ttip = $.AviaTooltip.openTTs[index];
  1714. element = $.AviaTooltip.openTT_Elements[index];
  1715. position = element.data('avia-tooltip-position'),
  1716. this.animate_hide_tooltip(ttip, position);
  1717. }
  1718.  
  1719. this.open = false;
  1720. this.active = false;
  1721. },
  1722.  
  1723. hide_tooltip: function (e) {
  1724. var element = $(e.currentTarget), newTip, animateTo,
  1725. position = element.data('avia-tooltip-position'),
  1726. align = element.data('avia-tooltip-alignment'),
  1727. newTip = false;
  1728.  
  1729. if (position == "" || typeof position == 'undefined') position = this.options.position;
  1730. if (align == "" || typeof align == 'undefined') align = 'center';
  1731.  
  1732. if (this.options.event == 'click') {
  1733. element = $(e.target);
  1734.  
  1735. if (!element.is('.' + this.options['class']) && element.parents('.' + this.options['class']).length == 0) {
  1736. if (this.active.length) { newTip = this.active; this.active = false; }
  1737. }
  1738. }
  1739. else {
  1740. if (!element.hasClass('av-close-on-click-tooltip')) {
  1741. newTip = element.data('avia-created-tooltip');
  1742. newTip = typeof newTip != 'undefined' ? $.AviaTooltip.openTTs[newTip] : false;
  1743. }
  1744. }
  1745.  
  1746. this.animate_hide_tooltip(newTip, position);
  1747. },
  1748.  
  1749. animate_hide_tooltip: function (ttip, position) {
  1750. if (ttip) {
  1751. var animate = { opacity: 0 };
  1752.  
  1753. switch (position) {
  1754. case "top":
  1755. animate['top'] = parseInt(ttip.css('top'), 10) - 10;
  1756. break;
  1757. case "bottom":
  1758. animate['top'] = parseInt(ttip.css('top'), 10) + 10;
  1759. break;
  1760. case "left":
  1761. animate['left'] = parseInt(ttip.css('left'), 10) - 10;
  1762. break;
  1763. case "right":
  1764. animate['left'] = parseInt(ttip.css('left'), 10) + 10;
  1765. break;
  1766. }
  1767.  
  1768. ttip.animate(animate, 200, function () {
  1769. ttip.css({ display: 'none' });
  1770. });
  1771. }
  1772. },
  1773.  
  1774. stop_instant_open: function (e) {
  1775. this.open = false;
  1776. }
  1777. };
  1778.  
  1779.  
  1780. })(jQuery);
  1781.  
  1782.  
  1783.  
  1784. /*!
  1785. Waypoints - 4.0.1
  1786. Copyright © 2011-2016 Caleb Troughton
  1787. Licensed under the MIT license.
  1788. https://github.com/imakewebthings/waypoints/blob/master/licenses.txt
  1789. */
  1790. !function () { "use strict"; function t(o) { if (!o) throw new Error("No options passed to Waypoint constructor"); if (!o.element) throw new Error("No element option passed to Waypoint constructor"); if (!o.handler) throw new Error("No handler option passed to Waypoint constructor"); this.key = "waypoint-" + e, this.options = t.Adapter.extend({}, t.defaults, o), this.element = this.options.element, this.adapter = new t.Adapter(this.element), this.callback = o.handler, this.axis = this.options.horizontal ? "horizontal" : "vertical", this.enabled = this.options.enabled, this.triggerPoint = null, this.group = t.Group.findOrCreate({ name: this.options.group, axis: this.axis }), this.context = t.Context.findOrCreateByElement(this.options.context), t.offsetAliases[this.options.offset] && (this.options.offset = t.offsetAliases[this.options.offset]), this.group.add(this), this.context.add(this), i[this.key] = this, e += 1 } var e = 0, i = {}; t.prototype.queueTrigger = function (t) { this.group.queueTrigger(this, t) }, t.prototype.trigger = function (t) { this.enabled && this.callback && this.callback.apply(this, t) }, t.prototype.destroy = function () { this.context.remove(this), this.group.remove(this), delete i[this.key] }, t.prototype.disable = function () { return this.enabled = !1, this }, t.prototype.enable = function () { return this.context.refresh(), this.enabled = !0, this }, t.prototype.next = function () { return this.group.next(this) }, t.prototype.previous = function () { return this.group.previous(this) }, t.invokeAll = function (t) { var e = []; for (var o in i) e.push(i[o]); for (var n = 0, r = e.length; r > n; n++)e[n][t]() }, t.destroyAll = function () { t.invokeAll("destroy") }, t.disableAll = function () { t.invokeAll("disable") }, t.enableAll = function () { t.Context.refreshAll(); for (var e in i) i[e].enabled = !0; return this }, t.refreshAll = function () { t.Context.refreshAll() }, t.viewportHeight = function () { return window.innerHeight || document.documentElement.clientHeight }, t.viewportWidth = function () { return document.documentElement.clientWidth }, t.adapters = [], t.defaults = { context: window, continuous: !0, enabled: !0, group: "default", horizontal: !1, offset: 0 }, t.offsetAliases = { "bottom-in-view": function () { return this.context.innerHeight() - this.adapter.outerHeight() }, "right-in-view": function () { return this.context.innerWidth() - this.adapter.outerWidth() } }, window.Waypoint = t }(), function () { "use strict"; function t(t) { window.setTimeout(t, 1e3 / 60) } function e(t) { this.element = t, this.Adapter = n.Adapter, this.adapter = new this.Adapter(t), this.key = "waypoint-context-" + i, this.didScroll = !1, this.didResize = !1, this.oldScroll = { x: this.adapter.scrollLeft(), y: this.adapter.scrollTop() }, this.waypoints = { vertical: {}, horizontal: {} }, t.waypointContextKey = this.key, o[t.waypointContextKey] = this, i += 1, n.windowContext || (n.windowContext = !0, n.windowContext = new e(window)), this.createThrottledScrollHandler(), this.createThrottledResizeHandler() } var i = 0, o = {}, n = window.Waypoint, r = window.onload; e.prototype.add = function (t) { var e = t.options.horizontal ? "horizontal" : "vertical"; this.waypoints[e][t.key] = t, this.refresh() }, e.prototype.checkEmpty = function () { var t = this.Adapter.isEmptyObject(this.waypoints.horizontal), e = this.Adapter.isEmptyObject(this.waypoints.vertical), i = this.element == this.element.window; t && e && !i && (this.adapter.off(".waypoints"), delete o[this.key]) }, e.prototype.createThrottledResizeHandler = function () { function t() { e.handleResize(), e.didResize = !1 } var e = this; this.adapter.on("resize.waypoints", function () { e.didResize || (e.didResize = !0, n.requestAnimationFrame(t)) }) }, e.prototype.createThrottledScrollHandler = function () { function t() { e.handleScroll(), e.didScroll = !1 } var e = this; this.adapter.on("scroll.waypoints", function () { (!e.didScroll || n.isTouch) && (e.didScroll = !0, n.requestAnimationFrame(t)) }) }, e.prototype.handleResize = function () { n.Context.refreshAll() }, e.prototype.handleScroll = function () { var t = {}, e = { horizontal: { newScroll: this.adapter.scrollLeft(), oldScroll: this.oldScroll.x, forward: "right", backward: "left" }, vertical: { newScroll: this.adapter.scrollTop(), oldScroll: this.oldScroll.y, forward: "down", backward: "up" } }; for (var i in e) { var o = e[i], n = o.newScroll > o.oldScroll, r = n ? o.forward : o.backward; for (var s in this.waypoints[i]) { var a = this.waypoints[i][s]; if (null !== a.triggerPoint) { var l = o.oldScroll < a.triggerPoint, h = o.newScroll >= a.triggerPoint, p = l && h, u = !l && !h; (p || u) && (a.queueTrigger(r), t[a.group.id] = a.group) } } } for (var c in t) t[c].flushTriggers(); this.oldScroll = { x: e.horizontal.newScroll, y: e.vertical.newScroll } }, e.prototype.innerHeight = function () { return this.element == this.element.window ? n.viewportHeight() : this.adapter.innerHeight() }, e.prototype.remove = function (t) { delete this.waypoints[t.axis][t.key], this.checkEmpty() }, e.prototype.innerWidth = function () { return this.element == this.element.window ? n.viewportWidth() : this.adapter.innerWidth() }, e.prototype.destroy = function () { var t = []; for (var e in this.waypoints) for (var i in this.waypoints[e]) t.push(this.waypoints[e][i]); for (var o = 0, n = t.length; n > o; o++)t[o].destroy() }, e.prototype.refresh = function () { var t, e = this.element == this.element.window, i = e ? void 0 : this.adapter.offset(), o = {}; this.handleScroll(), t = { horizontal: { contextOffset: e ? 0 : i.left, contextScroll: e ? 0 : this.oldScroll.x, contextDimension: this.innerWidth(), oldScroll: this.oldScroll.x, forward: "right", backward: "left", offsetProp: "left" }, vertical: { contextOffset: e ? 0 : i.top, contextScroll: e ? 0 : this.oldScroll.y, contextDimension: this.innerHeight(), oldScroll: this.oldScroll.y, forward: "down", backward: "up", offsetProp: "top" } }; for (var r in t) { var s = t[r]; for (var a in this.waypoints[r]) { var l, h, p, u, c, d = this.waypoints[r][a], f = d.options.offset, w = d.triggerPoint, y = 0, g = null == w; d.element !== d.element.window && (y = d.adapter.offset()[s.offsetProp]), "function" == typeof f ? f = f.apply(d) : "string" == typeof f && (f = parseFloat(f), d.options.offset.indexOf("%") > -1 && (f = Math.ceil(s.contextDimension * f / 100))), l = s.contextScroll - s.contextOffset, d.triggerPoint = Math.floor(y + l - f), h = w < s.oldScroll, p = d.triggerPoint >= s.oldScroll, u = h && p, c = !h && !p, !g && u ? (d.queueTrigger(s.backward), o[d.group.id] = d.group) : !g && c ? (d.queueTrigger(s.forward), o[d.group.id] = d.group) : g && s.oldScroll >= d.triggerPoint && (d.queueTrigger(s.forward), o[d.group.id] = d.group) } } return n.requestAnimationFrame(function () { for (var t in o) o[t].flushTriggers() }), this }, e.findOrCreateByElement = function (t) { return e.findByElement(t) || new e(t) }, e.refreshAll = function () { for (var t in o) o[t].refresh() }, e.findByElement = function (t) { return o[t.waypointContextKey] }, window.onload = function () { r && r(), e.refreshAll() }, n.requestAnimationFrame = function (e) { var i = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || t; i.call(window, e) }, n.Context = e }(), function () { "use strict"; function t(t, e) { return t.triggerPoint - e.triggerPoint } function e(t, e) { return e.triggerPoint - t.triggerPoint } function i(t) { this.name = t.name, this.axis = t.axis, this.id = this.name + "-" + this.axis, this.waypoints = [], this.clearTriggerQueues(), o[this.axis][this.name] = this } var o = { vertical: {}, horizontal: {} }, n = window.Waypoint; i.prototype.add = function (t) { this.waypoints.push(t) }, i.prototype.clearTriggerQueues = function () { this.triggerQueues = { up: [], down: [], left: [], right: [] } }, i.prototype.flushTriggers = function () { for (var i in this.triggerQueues) { var o = this.triggerQueues[i], n = "up" === i || "left" === i; o.sort(n ? e : t); for (var r = 0, s = o.length; s > r; r += 1) { var a = o[r]; (a.options.continuous || r === o.length - 1) && a.trigger([i]) } } this.clearTriggerQueues() }, i.prototype.next = function (e) { this.waypoints.sort(t); var i = n.Adapter.inArray(e, this.waypoints), o = i === this.waypoints.length - 1; return o ? null : this.waypoints[i + 1] }, i.prototype.previous = function (e) { this.waypoints.sort(t); var i = n.Adapter.inArray(e, this.waypoints); return i ? this.waypoints[i - 1] : null }, i.prototype.queueTrigger = function (t, e) { this.triggerQueues[e].push(t) }, i.prototype.remove = function (t) { var e = n.Adapter.inArray(t, this.waypoints); e > -1 && this.waypoints.splice(e, 1) }, i.prototype.first = function () { return this.waypoints[0] }, i.prototype.last = function () { return this.waypoints[this.waypoints.length - 1] }, i.findOrCreate = function (t) { return o[t.axis][t.name] || new i(t) }, n.Group = i }(), function () { "use strict"; function t(t) { this.$element = e(t) } var e = window.jQuery, i = window.Waypoint; e.each(["innerHeight", "innerWidth", "off", "offset", "on", "outerHeight", "outerWidth", "scrollLeft", "scrollTop"], function (e, i) { t.prototype[i] = function () { var t = Array.prototype.slice.call(arguments); return this.$element[i].apply(this.$element, t) } }), e.each(["extend", "inArray", "isEmptyObject"], function (i, o) { t[o] = e[o] }), i.adapters.push({ name: "jquery", Adapter: t }), i.Adapter = t }(), function () { "use strict"; function t(t) { return function () { var i = [], o = arguments[0]; return t.isFunction(arguments[0]) && (o = t.extend({}, arguments[1]), o.handler = arguments[0]), this.each(function () { var n = t.extend({}, o, { element: this }); "string" == typeof n.context && (n.context = t(this).closest(n.context)[0]), i.push(new e(n)) }), i } } var e = window.Waypoint; window.jQuery && (window.jQuery.fn.waypoint = t(window.jQuery)), window.Zepto && (window.Zepto.fn.waypoint = t(window.Zepto)) }();
  1791.  
  1792. // http://paulirish.com/2011/requestanimationframe-for-smart-animating/ + http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
  1793. // requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel. can be removed if IE9 is no longer supported or all parallax scripts are gone
  1794. // MIT license
  1795. (function () { var lastTime = 0; var vendors = ['ms', 'moz', 'webkit', 'o']; for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame']; window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame'] } if (!window.requestAnimationFrame) window.requestAnimationFrame = function (callback, element) { var currTime = new Date().getTime(); var timeToCall = Math.max(0, 16 - (currTime - lastTime)); var id = window.setTimeout(function () { callback(currTime + timeToCall) }, timeToCall); lastTime = currTime + timeToCall; return id }; if (!window.cancelAnimationFrame) window.cancelAnimationFrame = function (id) { clearTimeout(id) } }());
  1796.  
  1797. jQuery.expr[':'].regex = function (elem, index, match) {
  1798. var matchParams = match[3].split(','),
  1799. validLabels = /^(data|css):/,
  1800. attr = {
  1801. method: matchParams[0].match(validLabels) ?
  1802. matchParams[0].split(':')[0] : 'attr',
  1803. property: matchParams.shift().replace(validLabels, '')
  1804. },
  1805. regexFlags = 'ig',
  1806. regex = new RegExp(matchParams.join('').replace(/^\s+|\s+$/g, ''), regexFlags);
  1807. return regex.test(jQuery(elem)[attr.method](attr.property));
  1808. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement