1/** 2 * Theme functions file 3 */ 4(function ($) { 5 'use strict'; 6 7 var $document = $(document); 8 var $window = $(window); 9 10 11 /** 12 * Document ready (jQuery) 13 */ 14 $(function () { 15 /** 16 * Header style. 17 */ 18 if ($('.slides > li, .single .has-post-cover, .page .has-post-cover, .single-portfolio_item .slide-background-overlay, .page .is-vimeo-pro-slide, .page .portfolio-header-cover-image, .portfolio-with-post-cover, .blog-with-post-cover').length) { 19 $('.navbar').addClass('page-with-cover'); 20 $('#main').addClass('page-with-cover'); 21 } else { 22 $('.navbar').removeClass('page-with-cover'); 23 } 24 25 26 /** 27 * Activate superfish menu. 28 */ 29 $('.sf-menu').superfish({ 30 'speed': 'fast', 31 'delay' : 0, 32 'speedOut': 0, 33 'disableHI': true, 34 }); 35 36 37 var sticky_menu = zoomOptions.sticky_header; 38 39 if (sticky_menu) { 40 41 $.fn.TopMenuMargin(); 42 43 /** 44 * Activate Headroom. 45 */ 46 $('.site-header').headroom({ 47 tolerance: { 48 up: 0, 49 down: 0 50 }, 51 offset : 70 52 }); 53 54 55 } 56 57 $('<span class="child-arrow"></span>') 58 .on('click', function(e){ 59 e.preventDefault(); 60 61 var $li = $(this).closest('li'), 62 $sub = $li.find('> ul'); 63 64 if ( $sub.is(':visible') ) { 65 $sub.slideUp(); 66 $li.removeClass('open'); 67 } else { 68 $sub.slideDown(); 69 $li.addClass('open'); 70 } 71 }) 72 .appendTo('.side-nav .navbar-nav li.menu-item-has-children > a'); 73 74 /** 75 * Priority+ Navigation Pattern on menus in the header. 76 */ 77 PriorityPlusNavigation(); 78 79 /** 80 * Search form in header. 81 */ 82 if ($(".sb-search").length > 0 && $(".sb-search").children().length > 0) { 83 $(".sb-search").sbSearch(); 84 } 85 86 /** 87 * FitVids - Responsive Videos in posts 88 */ 89 $(".wpzlb-layout, .builder-wrap, .entry-content, .video_cover, .featured_page_content").fitVids(); 90 91 92 93 /** 94 * 95 */ 96 $.fn.responsiveImagesHeader(); 97 $.fn.paralised(); 98 $.fn.sideNav(); 99 100 101 /** 102 * Clickable divs. 103 */ 104 $('.clickable').on('click', function () { 105 window.location.href = $(this).data('href'); 106 }); 107 108 109 }); 110 111 112 $.fn.TopMenuMargin = function () { 113 $(window).on('resize orientationchange', update); 114 115 function update() { 116 117 var $header = $('.site-header'); 118 var $main_content = $('#main, .PP_Wrapper'); 119 120 $main_content.css('paddingTop',$header.outerHeight()); 121 } 122 123 update(); 124 }; 125 126 127 $.fn.singleportfolio = function () { 128 var $singlePort = $('.full-noslider'); 129 $singlePort.each(function (i) { 130 var $this = $(this); 131 132 $window.on('resize focus', dynamicHeightSingle); 133 134 dynamicHeightSingle(); 135 136 function dynamicHeightSingle() { 137 var height = $(window).height() - $('.full-noslider').offset().top - parseInt($('.full-noslider').css('padding-top'), 10); 138 139 /* use different min-height for different borwser widths */ 140 if (height < 300) { 141 height = 300; 142 } else if (height < 500 && $window.width() > 768) { 143 height = 500; 144 } 145 146 $this.find('.entry-cover.cover-fullheight').height(height); 147 } 148 149 }); 150 }; 151 152 153 /** 154 * Simple Parallax plugin. 155 */ 156 $.fn.paralised = function () { 157 var features = { 158 bind: !!(function () { 159 }.bind), 160 rAF: !!(window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame) 161 }; 162 163 if (typeof features === 'undefined' || !features.rAF || !features.bind) return; 164 165 /** 166 * Handles debouncing of events via requestAnimationFrame 167 * @see http://www.html5rocks.com/en/tutorials/speed/animations/ 168 * @param {Function} callback The callback to handle whichever event 169 */ 170 function Debouncer(e) { 171 this.callback = e; 172 this.ticking = false 173 } 174 175 Debouncer.prototype = { 176 constructor: Debouncer, update: function () { 177 this.callback && this.callback(); 178 this.ticking = false 179 }, requestTick: function () { 180 if (!this.ticking) { 181 requestAnimationFrame(this.rafCallback || (this.rafCallback = this.update.bind(this))); 182 this.ticking = true 183 } 184 }, handleEvent: function () { 185 this.requestTick() 186 } 187 } 188 189 var debouncer = new Debouncer(update.bind(this)); 190 191 $(window).on('scroll', debouncer.handleEvent.bind(debouncer)); 192 debouncer.handleEvent(); 193
194 function update() { 195 var scrollPos = $(document).scrollTop(); 196 197 var $postCover = $('.has-post-cover .entry-cover'); 198 var $singlePage = $('.featured_page_wrap--with-background'); 199 200 if ($postCover.length) { 201 var $postCover = $('.entry-cover'); 202 var postCoverBottom = $postCover.position().top + $postCover.outerHeight(); 203 204 if (scrollPos < postCoverBottom) { 205 var x = easeOutSine(scrollPos, 0, 1, postCoverBottom); 206 207 $postCover.find('.entry-header').css({ 208 'top': 30 * (1 - x), 209 'opacity': 1 - easeInQuad(scrollPos, 0, 1, postCoverBottom) 210 }); 211 } 212 } 213 214 $singlePage.each(function (i) { 215 var $this = $(this); 216 var bottom = $this.position().top + $this.outerHeight(); 217 218 var inViewport = (scrollPos + $window.height()) > $this.position().top && scrollPos < bottom; 219 220 if (!inViewport) return; 221 222 var x = easeOutSine(scrollPos + $window.height() - $this.position().top, -1, 2, bottom); 223 224 $this.find('.wpzoom-singlepage').css({ 225 '-webkit-transform': 'translateY(' + (-x * 80) + 'px)', 226 'moz-transform': 'translateY(' + (-x * 80) + 'px)', 227 'transform': 'translateY(' + (-x * 80) + 'px)' 228 }); 229 }); 230 } 231 232 function easeOutSine(t, b, c, d) { 233 return c * Math.sin(t / d * (Math.PI / 2)) + b; 234 } 235 236 function easeInQuad(t, b, c, d) { 237 return c * (t /= d) * t + b; 238 } 239 }; 240 241 242 $.fn.responsiveSliderImages = function () { 243 var forceCssRule = true; 244 245 $(window).on('resize orientationchange', update); 246 247 function update() { 248 var windowWidth = $(window).width(); 249 250 if (windowWidth <= 680) { 251 $('#slider .slides li').each(function () { 252 var bgurl = $(this).css('background-image').match(/^url\(['"]?(.+)["']?\)$/); 253 var smallimg = $(this).data('smallimg'); 254 255 if (bgurl) { 256 bgurl = bgurl[1]; 257 } 258 259 if (bgurl == smallimg) return; 260 261 if (!forceCssRule && $(this).attr('data-vimeo-options')) return; 262 263 $(this).css('background-image', 'url("' + smallimg + '")'); 264 }); 265 } 266 267 if (windowWidth > 680) { 268 $('#slider .slides li').each(function () { 269 var bgurl = $(this).css('background-image').match(/^url\(['"]?(.+)["']?\)$/); 270 var bigimg = $(this).data('bigimg'); 271 272 if (bgurl) { 273 bgurl = bgurl[1]; 274 } 275 276 if (bgurl == bigimg) return; 277 278 if (!forceCssRule && $(this).attr('data-vimeo-options')) return; 279 280 281 $(this).css('background-image', 'url("' + bigimg + '")'); 282 }); 283 } 284 285 forceCssRule = false; 286 } 287 288 update(); 289 }; 290 291 292 293 $.fn.responsiveImagesHeader = function () { 294 var forceCssRule = true; 295 $(window).on('resize orientationchange', update); 296 297 function update() { 298 var windowWidth = $(window).width(); 299 300 if (windowWidth <= 680) { 301 302 $('.entry-cover-image, .portfolio-header-cover-image').each(function () { 303 var bgurl = $(this).css('background-image').match(/^url\(['"]?(.+)["']?\)$/); 304 var smallimg = $(this).data('smallimg'); 305 306 if (bgurl) { 307 bgurl = bgurl[1]; 308 } 309 310 if (bgurl == smallimg) return; 311 312 $(this).css('background-image', 'url("' + smallimg + '")'); 313 }); 314 315 } 316 317 if (windowWidth > 680) { 318 319 $('.entry-cover-image, .portfolio-header-cover-image').each(function () { 320 var bgurl = $(this).css('background-image').match(/^url\(['"]?(.+)["']?\)$/); 321 var bigimg = $(this).data('bigimg'); 322 323 if (bgurl) { 324 bgurl = bgurl[1]; 325 } 326 327 if (bgurl == bigimg) return; 328 329 $(this).css('background-image', 'url("' + bigimg + '")'); 330 }); 331 332 } 333 } 334 335 update(); 336 }; 337 338 339 function PriorityPlusNavigation() { 340 $( '.site-header > .nav' ).each( function() { 341 var $menu = $( this ), 342 $hidden = $( '<li class="priority-plus-hidden"><strong><span>⋯</span></strong><ul class="hidden"></ul></li>' ).appendTo( $menu ), 343 breakWidths = [], 344 numItems = 0, 345 totalSpace = 0, 346 timer; 347 348 $menu.css( { 349 flexWrap: 'wrap', 350 overflow: 'visible' 351 } ); 352 353 $( '> .menu-item', $menu ).outerWidth( function( i, w ) { 354 totalSpace += w; 355 numItems += 1; 356 breakWidths.push( totalSpace ); 357 } ); 358 359 $( window ).resize( check ); 360 361 check(); 362 363 function check() { 364 if ( $menu.is( ':visible' ) ) { 365 var availableSpace = $menu.width() - 80, 366 numVisibleItems = $menu.find( '> .menu-item' ).length, 367 requiredSpace = breakWidths[ numVisibleItems - 1 ]; 368 369 if ( requiredSpace > availableSpace ) { 370 $( '> ul', $hidden ).prepend( $( '> .menu-item', $menu ).last() ); 371 numVisibleItems -= 1; 372 check(); 373 } else if ( availableSpace > breakWidths[ numVisibleItems ] ) { 374 $( '> .menu-item', $menu ).last().after( $( '> ul > li', $hidden ).first() ); 375 numVisibleItems += 1; 376 check(); 377 } 378 379 var hidden = numVisibleItems === numItems; 380 $menu.toggleClass( 'priority-plus-visible', !hidden ); 381 $hidden.toggleClass( 'hidden', hidden ); 382 } 383 } 384 } ); 385 } 386 387 388 $.fn.sideNav = function() { 389 var wasPlaying = false;
390 391 function toggleNav() { 392 $('body').toggleClass('side-nav-open').addClass('side-nav-transitioning'); 393 394 var flex = $('#slider').data('flexslider'); 395 if (flex) { 396 if ($('body').hasClass('side-nav-open')) { 397 wasPlaying = flex.playing; 398 if (flex.playing) { 399 flex.pause(); 400 } 401 } else { 402 if (wasPlaying) { 403 flex.play(); 404 } 405 } 406 } 407 408 var called = false; 409 $('.site').one('transitionend', function () { 410 $('body').removeClass('side-nav-transitioning'); 411 called = true; 412 }); 413 414 setTimeout(function() { 415 if (!called) { 416 $('body').removeClass('side-nav-transitioning'); 417 } 418 419 $window.trigger('resize'); 420 }, 230); 421 } 422 423 /* touchstart: do not allow scrolling main section then overlay is enabled (this is done via css) */ 424 $('.navbar-toggle, .side-nav-overlay').on('click touchend', function (event) { 425 if ($(document.body).hasClass('side-nav-transitioning')) { 426 return; 427 } 428 429 toggleNav(); 430 }); 431 432 /* allow closing sidenav with escape key */ 433 $document.on('keyup', function (event) { 434 if (event.keyCode == 27 && $('body').hasClass('side-nav-open')) { 435 toggleNav(); 436 } 437 }); 438 439 /** 440 * ScrollFix 441 * 442 * https://github.com/joelambert/ScrollFix 443 */ 444 $('.side-nav__scrollable-container').on('touchstart', function (event) { 445 var startTopScroll = this.scrollTop; 446 447 if (startTopScroll <= 0) { 448 this.scrollTop = 1; 449 } 450 451 if (startTopScroll + this.offsetHeight >= this.scrollHeight) { 452 this.scrollTop = this.scrollHeight - this.offsetHeight - 1; 453 } 454 }); 455 }; 456 457 458 459 $.fn.sbSearch = function() { 460 461 /* allow closing sidenav with escape key */ 462 $document.on('keydown', function (event) { 463 464 if (event.keyCode == 27 && $('#sb-search').hasClass('sb-search-open')) { 465 $( "#sb-search" ).removeClass( "sb-search-open" ) 466 } 467 468 }); 469 470 return this.each(function() { 471 new UISearch( this ); 472 }); 473 }; 474 475 476})(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.