1(function($) { 2 3 function HeaderAnimation(el, options) { 4 this.el = el; 5 this.$el = $(el); 6 this.options = { 7 startTop: 1 8 }; 9 $.extend(this.options, options); 10 this.initialize(); 11 } 12 13 HeaderAnimation.prototype = { 14 initialize: function() { 15 var self = this; 16 this.$page = $('#page').length ? $('#page') : $('body'); 17 this.$wrapper = $('#site-header-wrapper'); 18 this.$topArea = $('#top-area'); 19 this.topAreaInSiteHeader = $('#site-header #top-area').length > 0; 20 this.$headerMain = $('.header-main', this.$el); 21 this.hasAdminBar = document.body.className.indexOf('admin-bar') != -1; 22 this.adminBarOffset = 0; 23 this.adminBarHeight = 0; 24 this.topOffset = 0; 25 this.oldScrollY = 0; 26 this.isResponsive = null; 27 this.isResponsiveOld = null; 28 this.elHeight = this.$el.outerHeight(); 29 this.elHeightOld = this.$el.outerHeight(); 30 this.headerInited = false; 31 this.windowWidth = window.innerWidth; 32 33 this.hideWrapper = this.$wrapper.hasClass('site-header-wrapper-transparent'); 34 this.videoBackground = $('.page-title-block .gem-video-background').length && $('.page-title-block .gem-video-background').data('headerup'); 35 36 if(this.$el.hasClass('header-on-slideshow') && $('#main-content > *').first().is('.gem-slideshow, .block-slideshow')) { 37 this.$wrapper.css({position: 'absolute'}); 38 } 39 40 if(this.$el.hasClass('header-on-slideshow') && $('#main-content > *').first().is('.gem-slideshow, .block-slideshow')) { 41 this.$wrapper.addClass('header-on-slideshow'); 42 } else { 43 this.$el.removeClass('header-on-slideshow'); 44 } 45 46 if(this.videoBackground) { 47 this.$el.addClass('header-on-slideshow'); 48 this.$wrapper.addClass('header-on-slideshow'); 49 } 50 51 this.initHeader(); 52 53 $(document).ready(function() { 54 self.updateAdminBarInfo(); 55 self.updateStartTop(); 56 }); 57 58 $(window).scroll(function() { 59 self.scrollHandler(); 60 }); 61 62 if ($('#thegem-perspective').length) { 63 this.$page.scroll(function() { 64 self.scrollHandler(); 65 }); 66 } 67 68 $(window).resize(function() { 69 setTimeout(function() { 70 if (self.windowWidth != $(window).width()) { 71 self.initHeader(); 72 self.scrollHandler(); 73 self.windowWidth = $(window).width(); 74 } 75 }, 0); 76 }); 77 78 //load header fix 79 if (document.readyState === 'complete') { 80 self.$el.addClass('ios-load'); 81 } else { 82 var oldWindowLoad = window.onload; 83 window.onload = function() { 84 if (oldWindowLoad) { 85 oldWindowLoad() 86 } 87 self.$el.addClass('ios-load'); 88 } 89 } 90 }, 91 92 initHeader: function() { 93 this.isResponsiveOld = this.isResponsive; 94 this.isResponsive = window.isResponsiveMenuVisible(); 95 this.elHeightOld = this.elHeight; 96 this.elHeight = this.$el.outerHeight(); 97 98 if (this.isResponsive) { 99 this.$el.addClass('shrink-mobile'); 100 } else { 101 this.$el.removeClass('shrink-mobile'); 102 } 103 104 this.updateAdminBarInfo(); 105 this.updateStartTop(); 106 if (this.isResponsive != this.isResponsiveOld || this.elHeight != this.elHeightOld) { 107 this.initializeStyles(); 108 } 109 }, 110 111 updateAdminBarInfo: function() { 112 if (this.hasAdminBar) { 113 this.adminBarHeight = $('#wpadminbar').outerHeight(); 114 this.adminBarOffset = this.hasAdminBar && $('#wpadminbar').css('position') == 'fixed' ? parseInt(this.adminBarHeight) : 0; 115 } 116 }, 117 118 updateStartTop: function() { 119 if (this.$topArea.length && this.$topArea.is(':visible') && !this.topAreaInSiteHeader) { 120 this.options.startTop = this.$topArea.outerHeight(); 121 } else { 122 this.options.startTop = 1; 123 } 124 125 if (this.hasAdminBar && this.adminBarOffset == 0) { 126 this.options.startTop += this.adminBarHeight; 127 } 128 }, 129 130 setMargin: function($img) { 131 var $small = $img.siblings('img.small'), 132 w = 0; 133 134 if (this.$headerMain.hasClass('logo-position-right')) { 135 w = $small.width(); 136 } else if (this.$headerMain.hasClass('logo-position-center') || this.$headerMain.hasClass('logo-position-menu_center')) { 137 w = $img.width(); 138 var smallWidth = $small.width(), 139 offset = (w - smallWidth) / 2; 140 141 w = smallWidth + offset; 142 $small.css('margin-right', offset + 'px'); 143 } 144 if (!w) { 145 w = $img.width(); 146 } 147 $small.css('margin-left', '-' + w + 'px'); 148 $img.parent().css('min-width', w + 'px'); 149 150 $small.show(); 151 }, 152 153 initializeStyles: function() { 154 var self = this; 155 156 if (this.$headerMain.hasClass('logo-position-menu_center')) { 157 var $img = $('#primary-navigation .menu-item-logo a .logo img.default', this.$el); 158 } else { 159 var $img = $('.site-title .site-logo a .logo img', this.$el); 160 } 161 162 if ($img.length && $img[0].complete) { 163 self.setMargin($img); 164 self.initializeHeight(); 165 } else { 166 $img.on('load error', function() { 167 self.setMargin($img); 168 self.initializeHeight(); 169 }); 170 } 171 }, 172 173 initializeHeight: function() { 174 if (this.hideWrapper) { 175 this.headerInited = true; 176 return false; 177 } 178 179 that = this; 180 181 setTimeout(function() { 182 var shrink = that.$el.hasClass('shrink'); 183 if (shrink) { 184 that.$el.removeClass('shrink').addClass('without-transition'); 185 } 186 var elHeight = that.$el.outerHeight(); 187 188 //load header fix 189 if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) { 190 that.$wrapper.css('min-height', elHeight); 191 } else { 192 that.$wrapper.height(elHeight); 193 } 194 195 if (shrink) { 196 that.$el.addClass('shrink').removeClass('without-transition'); 197 } 198 that.headerInited = true; 199 }, 50); 200 }, 201 202 scrollHandler: function() { 203 if (!this.headerInited || window.gemSettings.fullpageEnabled || $('body').hasClass('vc_editor')) { 204 return; 205 } 206 207 var self = this,
208 scrollY = this.getScrollY(); 209 210 if (scrollY >= this.options.startTop) { 211 if (this.isResponsive && this.$wrapper.hasClass('sticky-header-on-mobile-disabled') && scrollY < this.options.startTop + $('#site-header-wrapper').height()) { 212 return; 213 } 214 if (!this.$el.hasClass('shrink')) { 215 var shrinkClass = 'shrink fixed'; 216 if (window.gemSettings.fillTopArea) { 217 shrinkClass += ' fill'; 218 } 219 if (this.$wrapper.hasClass('sticky-header-on-mobile-disabled')) { 220 shrinkClass += ' hidden hide-immediately'; 221 } 222 this.$el.addClass(shrinkClass); 223 //$('.hamburger-group').not('.hamburger-size-small-original').addClass('hamburger-size-small'); 224 //$('.perspective-toggle, .overlay-toggle').not('.toggle-size-small-original').addClass('toggle-size-small'); 225 } 226 var top = 0; 227 if (this.$page[0].scrollTop > 0) { 228 top += this.$page[0].scrollTop; 229 } else { 230 if (this.hasAdminBar) { 231 top += this.adminBarOffset; 232 } 233 } 234 235 this.$el.css({ 236 top: top != 0 ? top : '' 237 }); 238 } else { 239 if (this.$el.hasClass('shrink')) { 240 this.$el.removeClass('shrink fixed'); 241 //$('.hamburger-group').not('.hamburger-size-small-original').removeClass('hamburger-size-small'); 242 //$('.perspective-toggle, .overlay-toggle').not('.toggle-size-small-original').removeClass('toggle-size-small'); 243 } 244 if (this.hasAdminBar) { 245 this.$el.css({ 246 top: '' 247 }); 248 } 249 } 250 251 if (this.isResponsive && !this.$wrapper.hasClass('sticky-header-on-mobile')) { 252 if (!$('.mobile-menu-slide-wrapper.opened').length && !$('#primary-menu.dl-menuopen').length && !$('.menu-overlay.active').length) { 253 var hideScroll = 300; 254 if (this.$wrapper.hasClass('sticky-header-on-mobile-disabled')) { 255 hideScroll = 0; 256 } 257 if (scrollY - this.oldScrollY > 0 && scrollY > hideScroll && !this.$el.hasClass('hidden')) { 258 self.$el.addClass('hidden'); 259 } 260 if (scrollY - this.oldScrollY < 0 && this.$el.hasClass('hidden')) { 261 if (this.$el.hasClass('hide-immediately')) { 262 self.$el.removeClass('hide-immediately'); 263 } else { 264 self.$el.removeClass('hidden'); 265 } 266 } 267 } else { 268 self.$el.removeClass('hidden'); 269 } 270 } 271 272 this.oldScrollY = scrollY; 273 }, 274 275 getScrollY: function() { 276 return window.pageYOffset || document.documentElement.scrollTop + this.$page[0].scrollTop; 277 }, 278 }; 279 280 $.fn.headerAnimation = function(options) { 281 options = options || {}; 282 return new HeaderAnimation(this.get(0), options); 283 }; 284 285 $('#site-header.animated-header').headerAnimation(); 286 287 $('.menu-item-search a').on('click', function(e){ 288 e.preventDefault(); 289 if ($(this).closest('.menu-item-fullscreen-search-mobile').length) { 290 return; 291 } 292 if($(this).closest('.overlay-menu-wrapper.active').length) { 293 var $primaryMenu = $('#primary-menu'); 294 $primaryMenu.addClass('overlay-search-form-show'); 295 296 if ($primaryMenu.hasClass('no-responsive')) { 297 $primaryMenu.addClass('animated-minisearch'); 298 } 299 300 setTimeout(function() { 301 $(document).on('click.menu-item-search-close', 'body', function(e) { 302 if(!$(e.target).is('.menu-item-search .minisearch *')) { 303 var $primaryMenu = $('#primary-menu'); 304 305 if ($primaryMenu.hasClass('animated-minisearch')) { 306 $primaryMenu.removeClass('animated-minisearch'); 307 308 setTimeout(function() { 309 $primaryMenu.removeClass('overlay-search-form-show'); 310 $(document).off('click.menu-item-search-close'); 311 }, 700); 312 313 } else { 314 $primaryMenu.removeClass('overlay-search-form-show'); 315 $(document).off('click.menu-item-search-close'); 316 } 317 } 318 }); 319 }, 500); 320 } else { 321 $('.menu-item-search').toggleClass('active'); 322 } 323 324 if(!$('#primary-navigation').hasClass('overlay-active')) { 325 $('#searchform-input').focus(); 326 } 327 }); 328 329 $(document).ready(function () { 330 331 var localCache = { 332 data: {}, 333 remove: function (url) { 334 delete localCache.data[url]; 335 }, 336 exist: function (url) { 337 return localCache.data.hasOwnProperty(url) && localCache.data[url] !== null; 338 }, 339 get: function (url) { 340 return localCache.data[url]; 341 },
342 set: function (url, cachedData, callback) { 343 localCache.remove(url); 344 localCache.data[url] = cachedData; 345 if ($.isFunction(callback)) callback(cachedData); 346 } 347 }; 348 349 if (navigator.appVersion.indexOf("Win")!=-1) { 350 $('body').addClass('platform-Windows'); 351 } 352 353 const $fullscreenSearch = $('.thegem-fullscreen-search[data-id="header-search"]'), 354 $fullscreenSearchInput = $('.thegem-fullscreen-searchform-input', $fullscreenSearch), 355 $fullscreenSearchResults = $fullscreenSearch.find('.sf-result'), 356 $fullscreenSearchClose = $fullscreenSearch.find('.sf-close'); 357 358 let ajax, ajaxActive = false; 359 360 const fullscreenSearchTop = () => { 361 var searchTop; 362 if ($('#page').hasClass('vertical-header') && $(window).width() > 979) { 363 searchTop = 0; 364 } else if ($('#site-header').hasClass('fixed')) { 365 searchTop = $('#site-header').outerHeight(); 366 } else { 367 searchTop = $('#site-header').offset().top + $('#site-header').outerHeight() - $(window).scrollTop(); 368 } 369 $fullscreenSearch.css('top', searchTop); 370 }; 371 372 $('.menu-item-fullscreen-search a, .menu-item-fullscreen-search-mobile a').on('click', function(e){ 373 e.preventDefault(); 374 fullscreenSearchTop(); 375 376 $fullscreenSearch.toggleClass('active'); 377 378 if (ajaxActive) { 379 ajax.abort(); 380 ajaxActive = false; 381 } 382 383 $fullscreenSearchInput.val(''); 384 385 if ($('#site-header').hasClass('fixed')) { 386 setTimeout(function () { 387 $fullscreenSearchInput.focus(); 388 }, 500); 389 } else { 390 if ($(window).scrollTop() == 0) { 391 $('html, body').stop().animate({ 392 scrollTop: 0 393 }, 500); 394 } 395 $fullscreenSearchInput.focus(); 396 } 397 398 $fullscreenSearchResults.find('.preloader-new').remove(); 399 $fullscreenSearchResults.find('.result-sections').html(''); 400 401 $('body').toggleClass('fullscreen-search-opened'); 402 403 $('#thegem-perspective.modalview .perspective-menu-close').trigger('click'); 404 405 if ($('.primary-navigation').hasClass('responsive')) { 406 $('.menu-toggle').trigger('click'); 407 } 408 409 if ($(window).width() > 767) { 410 $('.overlay-toggle').trigger('click'); 411 } 412 413 if ($(window).width() > 979) { 414 $('.hamburger-toggle').trigger('click'); 415 $('.vertical-toggle').trigger('click'); 416 } 417 }); 418 419 $fullscreenSearchClose.on('click', function(e){ 420 e.preventDefault(); 421 $('.menu-item-fullscreen-search').removeClass('active'); 422 $fullscreenSearch.removeClass('active'); 423 $('body').removeClass('fullscreen-search-opened'); 424 if (ajaxActive) { 425 ajax.abort(); 426 ajaxActive = false; 427 } 428 $fullscreenSearchInput.val(''); 429 $fullscreenSearchResults.find('.preloader-new').remove(); 430 $fullscreenSearchResults.find('.result-sections').html(''); 431 }); 432 433 $(document).keyup(function(e) { 434 if (e.key === "Escape") { 435 $('.fullscreen-search .sf-close').trigger('click'); 436 } 437 }); 438 439 if ($fullscreenSearch.hasClass('ajax-search')) { 440 441 const $ajaxSearchParams = $('#ajax-search-params'), 442 postTypes = $ajaxSearchParams.data('post-types'), 443 postTypesPpp = $ajaxSearchParams.data('post-types-ppp'); 444 445 const ajaxSearch = (query) => { 446 447 if (!$fullscreenSearchInput.hasClass('styled')) { 448 let styles = $fullscreenSearchInput.data('styles'); 449 styles.forEach(function (style) { 450 $('head').append('<link rel="stylesheet" type="text/css" href="' + style + '">'); 451 }); 452 $fullscreenSearchInput.addClass('styled'); 453 } 454 455 if (ajaxActive) { 456 ajax.abort(); 457 } else { 458 $fullscreenSearchResults.prepend('<div class="preloader-new"><div class="preloader-spin"></div></div>'); 459 } 460 461 ajax = $.ajax({ 462 type: 'post', 463 url: thegem_scripts_data.ajax_url, 464 data: { 465 action: 'thegem_ajax_search', 466 search: query, 467 post_types: postTypes, 468 post_types_ppp: postTypesPpp, 469 }, 470 beforeSend: function () { 471 if (localCache.exist(query)) { 472 $fullscreenSearchResults.find('.preloader-new').remove(); 473 $fullscreenSearchResults.find('.result-sections').html(localCache.get(query)); 474 return false; 475 } else { 476 ajaxActive = true; 477 } 478 }, 479 success: function (response) { 480 ajaxActive = false; 481 $fullscreenSearchResults.find('.preloader-new').remove(); 482 $fullscreenSearchResults.find('.result-sections').html(response); 483 localCache.set(query, response); 484 } 485 }); 486 }; 487 488 $fullscreenSearchInput.on( 'keyup', function() { 489 let query = $(this).val(); 490 491 if (query.length > 2) { 492 ajaxSearch(query); 493 } else { 494 if (ajaxActive) { 495 ajax.abort(); 496 ajaxActive = false; 497 } 498 $fullscreenSearchResults.find('.preloader-new').remove(); 499 $fullscreenSearchResults.find('.result-sections').html(''); 500 } 501 return false; 502 }); 503 504 $('.top-search-item', $fullscreenSearch).on( 'click', function(e) { 505 e.preventDefault(); 506 var query = $(this).data('search'); 507 ajaxSearch(query); 508 $fullscreenSearchInput.val(query); 509 return false; 510 }); 511 } 512 513 514 515 const $verticalMinisearchAjax = $('.vertical-minisearch.menu-item-ajax-search'); 516 517 if ($verticalMinisearchAjax.length) { 518 519 const $ajaxSearchParams = $('#ajax-search-params'), 520 postTypes = $ajaxSearchParams.data('post-types'), 521 postTypesPpp = $ajaxSearchParams.data('post-types-ppp'), 522 $miniSearchForm = $('#searchform', $verticalMinisearchAjax), 523 $miniSearchSubmitIcon = $('.sf-submit-icon', $verticalMinisearchAjax), 524 $miniSearchInput = $('.sf-input', $verticalMinisearchAjax), 525 $miniSearchResults = $('.ajax-minisearch-results', $verticalMinisearchAjax); 526 527 const ajaxMiniSearch = (query) => { 528 529 if (ajaxActive) { 530 ajax.abort(); 531 } 532 $miniSearchForm.addClass('ajax-loading'); 533 534 ajax = $.ajax({
535 type : 'post', 536 url : thegem_scripts_data.ajax_url, 537 data : { 538 action : 'thegem_ajax_search_mini', 539 search : query, 540 post_types : postTypes, 541 post_types_ppp : postTypesPpp, 542 }, 543 beforeSend: function() { 544 if (localCache.exist(query)) { 545 $miniSearchForm.removeClass('ajax-loading'); 546 $miniSearchResults.html( localCache.get(query) ); 547 return false; 548 } else { 549 ajaxActive = true; 550 } 551 }, 552 success: function( response ) { 553 ajaxActive = false; 554 $miniSearchResults.html( response ); 555 $miniSearchForm.removeClass('ajax-loading'); 556 localCache.set(query, response); 557 } 558 }); 559 }; 560 561 const clearAjaxMinisearch = () => { 562 $miniSearchInput.val(''); 563 $miniSearchResults.html(''); 564 $miniSearchSubmitIcon.removeClass('clear'); 565 $miniSearchForm.removeClass('ajax-loading'); 566 if (ajaxActive) { 567 ajax.abort(); 568 ajaxActive = false; 569 } 570 }; 571 572 $miniSearchInput.on( 'keyup', function() { 573 let query = $(this).val(); 574 575 if (query.length > 0) { 576 $miniSearchSubmitIcon.addClass('clear'); 577 } else { 578 $miniSearchSubmitIcon.removeClass('clear'); 579 } 580 581 if (query.length > 2) { 582 ajaxMiniSearch(query); 583 } else { 584 if (ajaxActive) { 585 ajax.abort(); 586 ajaxActive = false; 587 } 588 $miniSearchResults.html(''); 589 $miniSearchForm.removeClass('ajax-loading'); 590 } 591 return false; 592 }); 593 594 $miniSearchSubmitIcon.on('click', function () { 595 if ($(this).hasClass('clear')) { 596 clearAjaxMinisearch(); 597 } 598 }); 599 600 $('.hamburger-toggle, #thegem-perspective .perspective-menu-close, .vertical-toggle').click(function() { 601 clearAjaxMinisearch(); 602 }); 603 604 } 605 }); 606 607})(jQuery);
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.