1// When DOM is fully loaded 2jQuery(document).ready(function($) { 3 4 5 /* Enable Strict Mode 6 ---------------------------------------------------------------------- */ 7 "use strict"; 8 9 10 /* Main Settings 11 ---------------------------------------------------------------------- */ 12 13 // Detect Touch Devices 14 var isTouch = ( ( 'ontouchstart' in window ) || ( navigator.msMaxTouchPoints > 0 ) ); 15 16 if ( isTouch ) { 17 18 $( 'body' ).addClass( 'touch-device' ); 19 20 } 21 22 23 /* Navigation 24 ---------------------------------------------------------------------- */ 25 (function() { 26 27 28 /* Top navigation 29 ------------------------- */ 30 31 if ( $( '#nav li' ).length ) { 32 33 // Create top navigation 34 $( document ).on( 'mouseenter', '#nav ul li', function() { 35 var 36 $this = $( this ), 37 $sub = $this.children( 'ul' ); 38 if ( $sub.length ) { 39 $this.addClass('active'); 40 var elm = $('ul:first', this); 41 var off = elm.offset(); 42 var l = off.left; 43 var w = elm.width(); 44 var docH = $('body').height(); 45 var docW = $('body').width(); 46 47 var isEntirelyVisible = (l + w <= docW); 48 49 if (!isEntirelyVisible) { 50 $sub.addClass('edge'); 51 } else { 52 $sub.removeClass('edge'); 53 } 54 } 55 $sub.stop( true, true ).addClass( 'show-list' ); 56 }).on( 'mouseleave', '#nav ul li', function() { 57 $( this ).removeClass( 'active' ).children( 'ul' ).stop( true, true ).removeClass( 'show-list edge' ); 58 }); 59 60 // Add Top nav to main nav 61 $( '#nav ul, #nav li' ).addClass( 'top-nav-el' ); 62 var $top_nav = $( '#nav > ul' ).children().clone(); 63 if ( $( '#main-nav ul' ).length <= 0 ) { 64 $( '#main-nav' ).append( '<ul></ul>' ); 65 $( '#main-nav ul' ).append( $top_nav ); 66 } 67 else { 68 $( $top_nav ).insertBefore( '#main-nav ul > li:first-child:eq(0)' ); 69 } 70 71 } 72 73 // Main navigation 74 // Slidebar 75 var slidebar_scroll = new IScroll( '#slidebar-content', { 76 mouseWheel: true, 77 interactiveScrollbars: true, 78 scrollbars: 'custom', 79 click: true 80 }); 81 82 $( '#main-nav .menu-item-has-children > a' ).each(function(){ 83 $( this ).after('<i class="submenu-trigger icon icon-angle-down"></i>' ); 84 }); 85 86 $( '#main-nav > ul > li' ).addClass( 'first-child' ); 87 $( '#main-nav .submenu-trigger, #main-nav .menu-item-has-children > a[href="#"]' ).on( 'click', function(e){ 88 e.preventDefault(); 89 var li = $( this ).closest('li'), 90 main_index = $( this ).parents( '.first-child' ).index(); 91 $( '#main-nav > ul > li:not(:eq('+main_index+')) ul:visible' ).slideUp(); 92 li.find( ' > ul' ).slideToggle(400); 93 setTimeout( function(){ slidebar_scroll.refresh() }, 400 ); 94 }); 95 96 // Menu Trigger 97 $( '#menu-trigger' ).on( 'click', function(e){ 98 e.preventDefault(); 99 $('body').addClass('slidebar-visible'); 100 }); 101 102 $( '#slidebar-close, #slidebar-layer' ).on( 'click', function( e ){ 103 e.preventDefault(); 104 $('body').removeClass('slidebar-visible'); 105 }); 106 107 // Close Slidebar after click on hash anchor 108 $( document ).on( 'click', '#slidebar-content a', function(e){ 109 if ( $( this ).attr( 'href' ) != '#' ) { 110 $('body').removeClass('slidebar-visible'); 111 } 112 }); 113 114 /* Hash Links 115 ------------------------- */ 116 if ( controls_vars.ajaxed == 0 ) { 117 118 // Jump hash after load 119 var target_hash = location.hash; 120 121 var offset = parseInt( $( '#header' ).css( 'height' ), 10 ); 122 123 if ( target_hash != '' && $( target_hash ).length ) { 124 125 var scroll_offset = $( target_hash ).offset().top + offset; 126 $( 'html, body' ).animate({ 127 scrollTop: scroll_offset 128 }, 900); 129 } 130 131 132 $( document ).on( 'click', '#nav a, #ajax-container a, #slidemenu a, #slidebar-content a', function(e){ 133 var that = $( this ); 134 var url = that.attr( 'href' ); 135 var target_hash = location.hash; 136 137 if ( that.attr( 'href' ) !== '#' ) { 138 139 var hash = url.split('#')[1]; 140 141 if ( hash ) { 142 143 hash = $( this ).attr( 'href' ).replace(/^.*?#/,''); 144 hash = '#' + hash; 145 146 url = url.replace( hash, '' ); 147 offset = $( this ).data( 'offset' ); 148 if ( offset == undefined || offset == '' ) { 149 150 offset = parseInt( $( '#header' ).css( 'height' ), 10 ); 151 offset = -(offset); 152 } 153 } else { 154 hash = ''; 155 } 156 157 if ( url === '' ) { 158 url = ajax_vars.home_url+'/'; 159 } 160 161 if ( url !== window.location.href.split('#')[0] ) { 162 163 window.location.href = url+hash; 164 165 } else { 166 if ( hash !== '' && hash !== '#' ) { 167 var scroll_offset = $( hash ).offset().top + offset; 168 $( 'html, body' ).animate({ 169 scrollTop: scroll_offset 170 }, 900); 171 } 172 } 173 } 174 175 e.preventDefault(); 176 177 178 } ); 179 180 } 181 182 183 })(); 184 185 186 /* Loader 187 ---------------------------------------------------------------------- */ 188 (function() { 189 190 if ( window.location.href.indexOf( 'customize.php' ) > -1 ) { 191 return false; 192 } 193 194 if ( $( '.wpal-loading-layer' ).length <= 0 ) { 195 return false; 196 } 197 198 $( '#site' ).imagesLoaded( { background: true }, function() { 199 $( '.wpal-loading-layer' ).addClass( 'hide-layer' ); 200 setTimeout( function(){ $( '.wpal-loading-layer' ).css( 'visibility', 'hidden' ).removeClass( 'hide-layer show-layer' ); }, 1400); 201 }); 202 203 })(); 204 205 206 /* Small Functions 207 ---------------------------------------------------------------------- */ 208 (function() { 209 210 211 // Scroll Button 212 if ( ! $( 'body' ).hasClass( 'no-scroll' ) ) { 213 $( 'body' ).append('<span id="scroll-button"><i></i></span>'); 214 $( '#scroll-button' ).on( 'click', function(e) { 215 TweenMax.to( window, 1, { scrollTo:{ y:0 }, ease:Power2.easeOut, onComplete: function(){ 216 $( '.intro.quick-scroll > .parallax.image-container' ).css( 'background-position', '50% 0px' ) 217 218 } } ); 219 e.preventDefault; 220 return false; 221 }); 222 } 223 224 // Tooltip 225 $( '.tip.active-tip' ).topTip(); 226 227 228 })(); 229 230 231 /* Ajax Filters 232 ---------------------------------------------------------------------- */ 233 (function() { 234 235 // Open dropdown 236 $( document ).on( 'click', '.filters-wrapper .filter', function(event) { 237 238 event.preventDefault(); 239 240 $( this ).parents( '.filters-wrapper' ).find( '.is-visible' ).not( this ).removeClass( 'is-visible' ); 241 242 $( this ).toggleClass( 'is-visible' ); 243 244 } ); 245 246 // List click action 247 $( document ).on( 'click', '.filter-dropdown-content ul li a', function(event) { 248 249 event.preventDefault(); 250 251 var 252 $filter = $( this ).parents( '.filter' ), 253 $grid = $filter.parents( '.grid-wrapper' ).attr( 'data-grid' ), 254 obj = $.parseJSON( $filter.attr('data-obj') ), 255 cat_name = $( this ).text(), 256 selected_filter = $filter.find( '.filter-title' ).attr( 'data-filter-name' ), 257 hh = 0; 258 259 obj['filter_name'] = $( this ).attr( 'data-filter-name' ); 260 261 if ( $( '#wpadminbar' ).length ) { 262 hh = $( '#wpadminbar' ).outerHeight(); 263 } 264 265 if ( obj.filter_name != selected_filter ) { 266 267 // Clear filters 268 $filter.parents( '.filters-wrapper' ).find( '.filter' ).not( $filter ).each( function(){ 269 var 270 temp_name = $( this ).find('ul li:first-child').text(); 271 $( this ).find( '.filter-title' ).text( temp_name ); 272 $( this ).find( '.filter-title' ).attr( 'data-filter-name', '' ); 273 $( this ).removeClass( 'active' ); 274 }); 275 276 // Classes 277 $filter.addClass( 'loading active' ); 278 $( '.load-more' ).removeClass( 'loaded loading' ); 279 280 if ( $( '#header.always-show-header' ).length ) { 281 var header_height = $( '#header.always-show-header' ).outerHeight(); 282 TweenLite.to( window, 0.4, {scrollTo:{ y:$filter.offset().top-hh-header_height} } ); 283 } else { 284 TweenLite.to( window, 0.4, {scrollTo:{ y:$filter.offset().top-hh } } ); 285 } 286 287 $filter.find( '.filter-title' ).text( cat_name ).attr( 'data-filter-name', obj.filter_name );; 288 $filter.find( '.filter-title' ).attr( 'data-filter-name', obj.filter_name ); 289 290 // Pagenum 291 obj['pagenum'] = 1;
292 $( '.load-more' ).attr( 'data-pagenum', 2 ); 293 294 // Hide messages 295 $( '.ajax-messages .message' ).hide(); 296 $( '.' + $grid ).find( '.masonry-item .active-tip' ).removeClass( 'active-tip' ); 297 $( '.' + $grid ).find( '.masonry-item' ).addClass( 'masonry-item--hide' ); 298 299 setTimeout( function() { 300 // Ajax 301 $.ajax({ 302 url: ajax_action.ajaxurl, 303 type: 'post', 304 data: { 305 action: obj['action'], 306 ajax_nonce : ajax_action.ajax_nonce, 307 obj: obj 308 }, 309 success: function( result ) { 310 311 if ( result == 'Busted!' ) { 312 location.reload(); 313 return false; 314 } 315 316 var 317 $result = $( result ), 318 $container = $( '.' + $grid ); 319 $container.isotope( 'remove', $container.isotope( 'getItemElements' ) ); 320 321 if ( result == 'no_results' ) { 322 $filter.removeClass( 'loading' ); 323 $( '.load-more-wrap' ).addClass( 'hidden' ); 324 return; 325 } 326 327 $result.imagesLoaded( { background: true }, function() { 328 $filter.removeClass( 'loading' ); 329 $container.append( $result ).isotope( 'appended', $result ); 330 $container.isotope( 'layout' ); 331 332 if ( $container.find( '.end-posts' ).length ) { 333 // Hide loader 334 $( '.load-more-wrap' ).addClass( 'hidden' ); 335 } else { 336 $( '.load-more-wrap' ).removeClass( 'hidden' ); 337 } 338 339 var $count = 1; 340 341 var _addClass = function(){ 342 setTimeout( function() { 343 var added_item = $container.find( '.masonry-item' ).eq($count-1); 344 added_item.addClass( 'masonry-item--appear' ); 345 var added_item_tip = added_item.find('.tip'); 346 added_item_tip.addClass( 'active-tip' ); 347 if ( $container.find( '.masonry-item' ).length >= $count ) { 348 349 $count++; 350 351 _addClass(); 352 } 353 }, 200); 354 355 } 356 357 _addClass(); 358 359 }); 360 }, 361 error: function( request, status, error ) { 362 var 363 $container = $( '.' + $grid ); 364 365 $container.isotope( 'remove', $container.isotope( 'getItemElements' ) ); 366 $container.css( 'height', 0 ); 367 $filter.removeClass( 'loading' ); 368 $( '.message.ajax-error' ).fadeIn(400); 369 } 370 }); 371 }, 300); 372 } 373 374 } ); 375 376 377 // Load more post 378 $( document ).on( 'click', '.load-more', function(event) { 379 380 event.preventDefault(); 381 382 if ( ! $( '.filter' ).length ) return; 383 384 var 385 $this = $( this ), 386 $filter, 387 $grid, 388 obj; 389 390 // Check active filter (if exists) 391 if ( $( '.filters-wrapper .filter.active' ).length ) { 392 $filter = $( '.filters-wrapper .filter.active' ); 393 obj = $.parseJSON( $filter.attr('data-obj') ); 394 obj['filter_name'] = $filter.find( '.filter-title' ).attr( 'data-filter-name' ); 395 } else { 396 $filter = $( '.filters-wrapper .filter' ); 397 obj = $.parseJSON( $filter.attr('data-obj') ); 398 obj['filter_name'] = 'all'; 399 } 400 401 // Grid 402 $grid = $filter.parents( '.grid-wrapper' ).attr( 'data-grid' ); 403 404 // Pagenum 405 obj['pagenum'] = parseInt( $this.attr( 'data-pagenum' ) ); 406 407 // Hide messages 408 $( '.ajax-messages .message' ).hide(); 409 410 // Classes 411 $this.addClass( 'loading' ); 412 // Ajax 413 $.ajax({ 414 url: ajax_action.ajaxurl, 415 type: 'post', 416 data: { 417 action: obj['action'], 418 ajax_nonce : ajax_action.ajax_nonce, 419 obj: obj 420 }, 421 success: function( result ) { 422 423 if ( result == 'Busted!' ) { 424 location.reload(); 425 return false; 426 } 427 428 var 429 $result = $( result ), 430 $container = $( '.' + $grid ); 431 432 if ( result == 'no_results' ) { 433 $this.removeClass( 'loading' ); 434 $this.addClass( 'loaded' ); 435 return; 436 } 437 438 $result.imagesLoaded( { background: true }, function() { 439 $container.removeClass( 'new-masonry-item' ); 440 obj['pagenum'] = obj['pagenum'] + 1; 441 $this.attr( 'data-pagenum', obj['pagenum'] ); 442 $this.removeClass( 'loading' ); 443 $container.append( $( $result ).addClass( 'new-masonry-item' ) ).isotope( 'appended', $result ); 444 if ( $container.find( '.end-posts' ).length ) { 445 // Hide loader 446 $this.parent().addClass( 'hidden' ); 447 } else { 448 $this.parent().removeClass( 'hidden' ); 449 } 450 451 $container.isotope( 'layout' ); 452 453 var $count = 1; 454 455 var _addClass = function(){ 456 setTimeout( function() { 457 var added_item = $container.find( '.new-masonry-item' ).eq($count-1); 458 added_item.addClass( 'masonry-item--appear' ); 459 var added_item_tip = added_item.find('.tip'); 460 added_item_tip.addClass( 'active-tip' ); 461 if ( $container.find( '.new-masonry-item' ).length >= $count ) { 462 463 $count++; 464 465 _addClass(); 466 } 467 }, 200); 468 469 } 470 471 _addClass(); 472 });
473 }, 474 error: function( request, status, error ) { 475 var 476 $container = $( '.' + $grid ); 477 478 $this.attr( 'data-pagenum', '2' ); 479 $container.isotope( 'remove', $container.isotope( 'getItemElements' ) ); 480 $container.css( 'height', 0 ); 481 $this.removeClass( 'loading' ); 482 $( '.message.ajax-error' ).fadeIn(400); 483 } 484 }); 485 486 } ); 487 488 489 })(); 490 491 492 493 /* WP Ajax Loader 494 ---------------------------------------------------------------------- */ 495 (function() { 496 497 if ( controls_vars.ajaxed == 0 || window.location.href.indexOf( 'customize.php' ) > -1 ) return false; 498 499 $.WPAjaxLoader({ 500 home_url : controls_vars.home_url, 501 theme_uri : controls_vars.theme_uri, 502 dir : controls_vars.dir, 503 reload_containers : controls_vars.ajax_reload_containers, 504 permalinks : controls_vars.permalinks, 505 ajax_async : controls_vars.ajax_async, 506 ajax_cache : controls_vars.ajax_cache, 507 ajax_events : controls_vars.ajax_events, 508 ajax_elements : controls_vars.ajax_elements, 509 excludes_links : controls_vars.ajax_exclude_links, 510 reload_scripts : controls_vars.ajax_reload_scripts, 511 search_forms : '#searchform,.layer--searchform', 512 loading_animation_time_start : 600, 513 loading_animation_time_end : 600, 514 header_container : '#header', 515 loadStart : function() { 516 517 // Close playlist 518 if ( $( '#scamp_player.sp-show-list' ).length ) { 519 $( '#scamp_player' ).removeClass( 'sp-show-list' ); 520 } 521 // Close Slidebar after page loaded 522 $('body').removeClass('slidebar-visible'); 523 524 // Remove HTML classes 525 $( 'html' ).attr( 'class', '' ); 526 527 }, 528 loadEnd : function(){ 529 530 $( 'body' ).addClass( 'wp-ajax-loader' ); 531 if((typeof YT !== "undefined") && YT && YT.Player){ 532 $( 'body' ).addClass( 'YTAPI' ); 533 }; 534 535 } 536 }); 537 538 $.WPAjaxLoader.init(function(){}); 539 540 })(); 541 542}); 543 544// Load the YouTube API asynchronously 545var tag = document.createElement('script'); 546tag.src = "https://www.youtube.com/iframe_api"; 547var firstScriptTag = document.getElementsByTagName('script')[0]; 548firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); 549 550// Create the player object when API is ready 551window.onYouTubeIframeAPIReady = function () { 552 document.body.className += " YTAPInit"; 553};
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.