1/* jshint devel:true */ 2/* global Modernizr, Masonry, imagesLoaded:true */ 3 4 5 6/// FUNCTION TO CHECK IF ELEMENTS EXIST / DOESN'T 7/////////////////////////////////// 8jQuery.fn.exists = function() { 9 return this.length > 0; 10}; 11 12 13 14//////////////////////////////////////////////////////// 15 16///// GLOBAL FUNCTIONS 17 18//////////////////////////////////////////////////////// 19 20 21/** 22 * Some sites switch off the scrolling, this variable allows for that. 23 */ 24var scroll_nav = (scroll_nav === undefined) 25 ? true : scroll_nav; 26 27(function($) { 28 29 30 // global JS object 31 var jsGlobal = function() { 32 33 //global vars 34 //var _this; 35 36 return{ 37 init: function() { 38 39 //napco_set_login_status(); 40 41 napco_window_targets(); 42 43 /// DELAY TIMER 44 /////////////////////////////////// 45 var delaytimer; 46 function delay(callback, ms) { 47 clearTimeout(delaytimer); 48 delaytimer = setTimeout(callback, ms); 49 } 50 51 52 53 54 /// EXPANDING FOOTER 55 /////////////////////////////////// 56 var footerToggle = $('.footer-toggle'); 57 58 footerToggle.on('click', function() { 59 60 if (footerToggle.hasClass('collapsed')) { 61 $(this).removeClass('collapsed'); 62 $(this).addClass('expanded'); 63 $('footer .bot-level').slideDown(400); 64 65 // after expand, scroll down to see 66 delay(function() { 67 $("html, body").animate({ 68 scrollTop: $(document).height() 69 }, "slow"); 70 }, 400); 71 72 // change copy 73 //$('.footer-toggle span').html('Less Information'); 74 75 if ($('html').hasClass('ie8')) { 76 $('footer .bot-level .link-list').columnize({ 77 columns: 2 78 }); 79 } 80 81 } else { 82 $(this).removeClass('expanded'); 83 $(this).addClass('collapsed'); 84 $('footer .bot-level').slideUp(); 85 86 // change copy 87 //$('.footer-toggle span').html('More Information'); 88 } 89 90 }); 91 92 93 /// PLACEHOLDER FIX FOR UNSUPPORTED BROWSERS
94 ////////////////////////////////////////////// 95 if (!Modernizr.input.placeholder) { 96 $("input, textarea").each( 97 function() { 98 if ($(this).val() === "" && $(this).attr("placeholder") !== "") { 99 $(this).val($(this).attr("placeholder")); 100 $(this).focus(function() { 101 if ($(this).val() === $(this).attr("placeholder")) { 102 $(this).val(""); 103 } 104 }); 105 $(this).blur(function() { 106 if ($(this).val() === "") { 107 $(this).val($(this).attr("placeholder")); 108 } 109 }); 110 } 111 }); 112 } 113 114 115 /// STOP SEARCH FORM IF EMPTY 116 ////////////////////////////////////////////// 117 118 $('.search-bar form').on('submit', function(e) { 119 if ($(this).find('input[type="text"]').val().length < 1) { 120 e.preventDefault(); 121 } 122 }); 123 124 125 126 /// STYLE SELECTS
127 ///////////////////////////////////////////// 128 if ($.fn.customSelect) { 129 $('.styled').customSelect(); 130 } 131 132 133 /// COLUMNIZER (IE8) 134 ///////////////////////////////////////////// 135 136 //////////////////////////////////////////////////////////////// 137 //////// This is for the blog more posts ajax call //////////// 138 ////////////////////////////////////////////////////////////// 139 140 $(document).on('click', '#blog-post-more, #blog-post-newer-more', function() { 141 var limit = jQuery( '#blog-posts-limit' ).val(); 142 var start = jQuery( '#blog-posts-start' ).val(); 143 var blog_column_option = jQuery( '#blog-column-option' ).val(); 144 var taxonomy_term_id = jQuery( '#taxonomy-term-id' ).val(); 145 var taxonomy_name = jQuery( '#taxonomy-name' ).val(); 146 var id = $(this).attr('id'); 147 var more_posts = ''; 148 149 if ( id == 'blog-post-newer-more' ) { 150 more_posts = 'newer'; 151 } else if ( id == 'blog-post-more' ) { 152 more_posts = 'older'; 153 } 154 155 156 // This does the ajax request 157 jQuery.ajax({ 158 159 type: 'POST', 160 url: ajax_object.ajaxurl, 161 162 data: { 163 action:'ajax_blog_more_posts', 164 limit: limit, 165 start: start, 166 blog_column_option: blog_column_option, 167 taxonomy_name: taxonomy_name, 168 taxonomy_term_id: taxonomy_term_id, 169 more_posts: more_posts 170 }, 171 success:function(data) { 172 173 if( data != 'error' ) { 174 $('#blog-post-more-div').html(data); 175 } else { 176 if ( blog_column_option == 2 ) { 177 $('#blog-post-more-div').html( '<div class="row feed push-down-40"><div class="col-sm-6"><div class="feed-col">No older posts are there.</div></div></div>' );//code 178 } else if ( blog_column_option == 3 ) { 179 $('#blog-post-more-div').html( '<div class="row feed bgcolor no-pad d"><div class="col-sm-6"><div class="feed-col">No older posts are there.</div></div></div>' );//code 180 } 181 182 } 183 } 184 }); 185 }); 186 187 $(document).on('click', '#author-post-more, #author-post-newer-more', function() { 188 var limit = jQuery( '#blog-posts-limit' ).val(); 189 var start = jQuery( '#blog-posts-start' ).val(); 190 var blog_column_option = jQuery( '#blog-column-option' ).val(); 191 var author_id = jQuery( '#author-id' ).val(); 192 var id = $(this).attr('id'); 193 var more_posts = ''; 194 var trigger = $(this); 195 var trigger_text_folder = trigger.text(); 196 197 if ( id == 'author-post-newer-more' ) { 198 more_posts = 'newer'; 199 } else if ( id == 'author-post-more' ) { 200 more_posts = 'older'; 201 } 202 203 //$('#blog-post-more-div').css('opacity', .25); 204 trigger.text('Loading...'); 205 $('#author-posts-loader').html('<img src="/wp-includes/images/spinner.gif">'); 206 //return; 207 208 209 // This does the ajax request 210 jQuery.ajax({ 211 212 type: 'POST', 213 url: ajax_object.ajaxurl, 214 215 data: { 216 action:'ajax_author_more_posts', 217 limit: limit, 218 start: start, 219 blog_column_option: blog_column_option, 220 author_id: author_id, 221 more_posts: more_posts 222 }, 223 success:function(data) { 224 //$('#blog-post-more-div').css('opacity', 1); 225 $('html, body').animate({ 226 //scrollTop: $('#blog-post-more-div').offset().top - 100 227 }, 250); 228 trigger.text(trigger_text_folder); 229 230 if( data != 'error' ) { 231 //$('#blog-post-more-div').append(data); 232 $('#blog-posts-limit, #blog-posts-start').remove(); 233 $('#author-posts-loader').html('').before(data); 234 } else { 235 if ( blog_column_option == 2 ) { 236 $('#blog-post-more-div').html( '<div class="row feed push-down-40"><div class="col-sm-6"><div class="feed-col">No older posts are there.</div></div></div>' );//code 237 } else if ( blog_column_option == 3 ) { 238 $('#blog-post-more-div').html( '<div class="row feed bgcolor no-pad d"><div class="col-sm-6"><div class="feed-col">No older posts are there.</div></div></div>' );//code 239 } 240 241 } 242 } 243 }); 244 }); 245 246 247 $('.newsletter-subscription-widget').on('submit', function(e){ 248 e.preventDefault(); 249 250 var $form = $(this); 251 252 $(this).css({'opacity':'1'}); 253 $form.find('[type=email]').css({backgroundColor:'#fff'}); 254 255 email_address = $form.find('[type=email]').val(); 256 sitenewsletter = $form.find('[name="sitenewsletter"]').val(); 257 258 if ( ! email_address ) { 259 $form.find('[type=email]').css({backgroundColor:'#fcc'}); 260 return; 261 } 262 263 data = { 264 action : 'sitenewsletter_add_subscribe', 265 email_address : email_address, 266 sitenewsletter : sitenewsletter, 267 } 268 269 $(this).css({'opacity':'0.5'}); 270 271 jQuery.post(napco_data.ajaxurl, data, function(response) { 272 if ( 'OK' == response ) { 273 msg = '<h1>Thank you for subscribing.</h1>'; 274 } else { 275 msg = ''; 276 } 277 $form.parent('.inner-pad').html('<div class="text">'+ msg +'</div>'); 278 }); 279 280 }); 281 282 283 284 285 /* 286 //tax term widget, 3 at a time, some css changes would be necessary as well such as hiding the article elements 287 function show_more_items( $list, limit ) { 288 i = 0; 289 $list.find('article').each(function(){ 290 if ( i == limit ) return false;
291 if ( $(this).is(':hidden') ) { 292 $(this).show(); 293 i++; 294 } 295 }); 296 } 297 298 $('.rail-container.taxonomy-terms .feed-col').each(function(){ 299 limit = 3; 300 show_more_items( $(this), limit ); 301 }); 302 303 $('.load_more.button').on('click', function(){ 304 $list = $(this).parents().find('.feed-col'); 305 limit = 3; 306 show_more_items( $list, limit ); 307 }); 308 //tax term widget, 3 at a time - end 309 */ 310 311 function collapse_term_taxonomy_widget($frame) { 312 frame_offset = $frame.offset(); 313 //frame_height = $frame.height(); 314 315 $third_item = $frame.find('article.post-preview:eq(2)'); 316 317 if ( ! $third_item.length ) return; 318 319 third_item_offset = $third_item.offset(); 320 third_item_height = $third_item.outerHeight(); 321 third_item_bottom = third_item_offset.top + third_item_height; 322 323 frame_new_height = third_item_bottom - frame_offset.top; 324 $frame.height(frame_new_height); 325 } 326 327 $('.rail-container.taxonomy-terms .feed-col').each(function(){ 328 collapse_term_taxonomy_widget( $(this) ); 329 }); 330 331 $('.load_more.button').on('click', function(){ 332 $list = $(this).parent().parent().find('.feed-col'); 333 334 if ( 'expand' == $(this).attr('data-action') ) { 335 $list.slideDown('slow', function() { 336 $(this).css('height', 'inherit'); 337 }); 338 $(this).attr('data-action', 'collapse').text('Show Fewer '+ $(this).data('label')).addClass('expanded'); 339 } else { 340 collapse_term_taxonomy_widget($list); 341 $(this).attr('data-action', 'expand').text('Show More '+ $(this).data('label')).removeClass('expanded'); 342 } 343 }); 344 345 346 /** 347 * Convert footer menu items to headers when appropriate. 348 */ 349 $('.footer nav li:first-of-type').each(function(){ 350 $a_tag = $('a', this); 351 href = $a_tag.attr('href'); 352 if ( ! href || '#' == href ) { 353 $a_tag.replaceWith($a_tag.html()); 354 $(this).wrapInner('<strong>'); 355 } 356 }); 357 358 /** 359 * Hide ad widgets without ads. 360 */ 361 $('aside.doubleclick:has(.ad.napco-ad)').each(function(){ 362 if (!$(this).find('div').length && !$(this).find('script').length) { 363 $(this).hide(); 364 } 365 }); 366 } 367 }; 368 369 }(); 370 371 372 // load on document ready 373 jQuery(function() { 374 jsGlobal.init(); 375 }); 376 377})(jQuery); 378 379 380 381//////////////////////////////////////////////////////// 382 383///// Responsive Nav 384 385//////////////////////////////////////////////////////// 386 387 388(function($) { 389 390 391 // global JS object 392 var jsNav = function() { 393 394 //global vars 395 var self, resizeTimer, navItems, activeNav; 396 397 return{ 398 init: function() { 399 400 // insert menu back buttons 401 $('.menu-item-has-children .sub-menu').prepend('<li class="menu-back menu-item menu-item-type-post_type menu-item-object-page">Back To Main Menu</li>'); 402 $('.menu-item-has-children .sub-menu .sub-menu li.menu-back').html('Back'); 403 404 self = this; 405 406 navItems = $('ul.menu .nav-item'); 407 408 //console.log(navItems); 409 410 // hover states for no-touch nav 411 $(document).on('mouseenter', '.no-touch-view ul.menu li', self.menuOpen); 412 $(document).on('mouseleave', '.no-touch-view ul.menu li', self.menuClose); 413 414 415 // touch toggles 416 $('.trigger-main-nav').click(self.touchButton); 417 $('.toggle-search').click(self.touchSearch); 418 419 420 // navigate touch menus 421 $(document).on('click', '.touch-view ul.menu a', self.menuOpenMobile); 422 $('ul.menu .menu-back').click(self.menuCloseBack); 423 424 425 // exit touch menu 426 $('.exit-touch-menu').click(self.touchButton); 427 428 // This for slider 429 $('.wp-gallery').bjqs({ 430 'width' : '100%', 431 'responsive' : false, 432 'automatic' : false, 433 'nexttext' : '»', 434 'prevtext' : '«', 435 'text-align': 'center' 436 }); 437 438 // This is for author listing toggle on category/blog channel page page 439 $('#load_more_button').on('click', function() { 440 holdSpot = this; 441 topOfElement = $(holdSpot).offset().top; 442 topOfScroll = $(window).scrollTop(); 443 effectiveHeight = topOfElement - topOfScroll; 444 $('.author-listing-div').slideToggle('slow', function() { 445 $('#load_more_button').toggleClass('contributor-up-arrow'); 446 topOfElement = $(holdSpot).offset().top; //finds new position of element 447 $(window).scrollTop(topOfElement - effectiveHeight); //sets scrollTop to position of element minus the original height difference 448 }); 449 450 $(this).text( $(this).text() == 'Show More Contributors' ? "Show Fe
450wer Contributors" : "Show More Contributors"); 451 452 }); 453 454// $('nav.no-touch-view ul#menu-header-menu li.menu-item').on('click', function() { 455// $('a:first-child', this)[0].click(); 456// }); 457 458 // sticky nav 459 $(window).scroll(function() { 460 461 // check if header is there first and for scroll_nav boolean 462 if ($('header').length > 0 && scroll_nav) { 463 464 if ($('html').hasClass('use-touch-sticky')) { 465 466 if ($(window).scrollTop() > $('.top-stick').offset().top - 0) { 467 $('.control-wrap').addClass('touch-sticky'); 468 } else { 469 $('.control-wrap').removeClass('touch-sticky'); 470 } 471 472 } else { 473 474 if ($(window).scrollTop() > $('.bot-stick').offset().top - 1) { 475 $('.bot-layer').addClass('no-touch-sticky'); 476 $('.bot-stick').css({ 477 'height': '42px', 478 'display': 'block' 479 }); 480 napco_adminbar_padding('32px'); 481 } else { 482 $('.bot-layer').removeClass('no-touch-sticky'); 483 $('.bot-stick').css({ 484 'height': '0px', 485 'display': 'block' 486 }); 487 napco_adminbar_padding(0); 488 } 489 490 if ( $('.share-floater-div').length ) { 491 if ($(window).scrollTop() > $('.share-floater-div').offset().top - 1) { 492 $('.share-bar').css({ 493 'position': 'fixed', 494 'top': '95px', 495 'width': '166px' 496 }); 497 } else { 498 $('.share-bar').css({ 499 'position': 'relative', 500 'top': '2px', 501 'width': '100%' 502 }); 503 } 504 } 505 506 if ($(window).scrollTop() > 260) { 507 $('.bot-layer').addClass('staged'); 508 } else { 509 $('.bot-layer').removeClass('staged'); 510 } 511 } 512 513 } 514 515 }); 516 517 518 // resize 519 $(window).on('resize', function() { 520 clearTimeout(resizeTimer); 521 resizeTimer = setTimeout(function() { 522 self.resizeEnd(); 523 }, 100); 524 }); 525 526 527 // set nav class on init 528 if ($('html').hasClass('no-touch') && ($(window).width() > 768)) { 529 530 $('.wp-menu').removeClass('touch-view'); 531 $('.wp-menu').addClass('no-touch-view'); 532 533 } else { 534 535 $('.wp-menu').removeClass('no-touch-view'); 536 $('.wp-menu').addClass('touch-view'); 537 $('html').addClass('use-touch-sticky'); 538 539 } 540 541 /*if ($('html').hasClass('touch') && ($(window).width() > 768)) { 542 $('html').removeClass('touch'); 543 $('html').addClass('no-touch'); 544 }*/ 545 546 //create headers 547 self.createMenuHeaders(); 548 549 }, 550 createMenuHeaders: function() { 551 var thisMenuItems = $('.menu-item-has-children a'); 552 thisMenuItems.each(function() { 553 var thisMenu = $(this).next(); 554 var thisItem = $(thisMenu).find('> .menu-back'); 555 //new placeholder 556 $(thisItem).after('<li class="new-item"></li>'); 557 var packet = $(this).clone(); 558 $(packet).removeClass('menu-item'); 559 packet.prependTo($(thisMenu).find('.new-item')); 560 }); 561 }, 562 resizeEnd: function() { 563 564 if ($('html').hasClass('touch')) { 565 566 $('.wp-menu').removeClass('no-touch-view'); 567 $('.wp-menu').addClass('touch-view'); 568 $('html').addClass('use-touch-sticky'); 569 570 } else { 571 572 if ($(window).width() <= 768) { 573 574 $('.wp-menu').removeClass('no-touch-view'); 575 $('.wp-menu').addClass('touch-view'); 576 $('html').addClass('use-touch-sticky'); 577 578 if ( scroll_nav ) { 579 $('.bot-layer').removeClass('no-touch-sticky'); 580 $('.bot-layer').removeClass('staged'); 581 } 582 583 } else { 584 585 $('.wp-menu').removeClass('touch-view'); 586 $('.wp-menu').addClass('no-touch-view'); 587 $('.pusher').removeClass('active'); 588 $('.site-container').removeClass('pusher-active'); 589 $('.trigger-main-nav').removeClass('active'); 590 $('.control-wrap').removeClass('touch-sticky'); 591 $('.wp-menu').removeClass('open'); 592 $('html').removeClass('use-touch-sticky'); 593 } 594 } 595 596 }, 597 menuOpen: function(e) { 598 599 $(this).children('a').addClass('hoveron'); 600 601 if (self.hasSubNav($(this).parent())) { 602 //console.log('has a sub nav'); 603 //open the subnav 604 e.preventDefault(); 605 activeNav = $(this).children('.sub-menu'); 606 //console.log(activeNav); 607 608 $(activeNav).addClass('open'); 609 } else { 610 //console.log('no sub nav'); 611 } 612 613 }, 614 menuOpenMobile: function(e) { 615 616 $(this).addClass('hoveron'); 617 618 if (self.hasSubNav($(this).parent())) { 619 //console.log('has a sub nav'); 620 //open the subnav 621 e.preventDefault(); 622 activeNav = $(this).next('.sub-menu'); 623 //console.log(activeNav); 624 625 $(activeNav).addClass('open'); 626 } else { 627 //console.log('no sub nav'); 628 } 629 630 }, 631 menuClose: function() { 632 633 $(this).children().removeClass('hoveron'); 634 635 //console.log(openNav); 636 var openNav = $(this).children('.sub-menu'); 637 638 var delaytimer; 639 function delay(callback, ms) { 640 clearTimeout(delaytimer); 641 delaytimer = setTimeout(callback, ms); 642 } 643 644 delay(function() { 645 $(openNav).removeClass('open'); 646 }, 100); 647 648 }, 649 menuCloseBack: function() { 650 651 //console.log(openNav); 652 var openNav = $(this).parent(); 653 $(openNav).removeClass('open'); 654 655 }, 656 hasSubNav: function(element) { 657 658 if ($(element).find('.sub-menu').length > 0) { 659 return true; 660 } 661 662 }, 663 touchButton: function() { 664 665 if ($('.touch-view').hasClass('open')) { 666 667 $('.trigger-main-nav').removeClass('active'); 668 $('.wp-menu').removeClass('open'); 669 $('.pusher').removeClass('active'); 670 $('.site-container').removeClass('pusher-active'); 671 $('.sub-menu').removeClass('open'); 672 673 } else { 674 675 $('.wp-menu').addClass('open'); 676 $('.trigger-main-nav').addClass('active'); 677 $('.pusher').addClass('active'); 678 $('.site-container').addClass('pusher-active'); 679 680 } 681 682 }, 683 touchSearch: function() { 684 685 if ($('.touch-search').hasClass('open')) { 686 687 $('.toggle-search').removeClass('active'); 688 $('.touch-search').removeClass('open'); 689 690 } 691 else { 692 693 $('.touch-search').addClass('open'); 694 $('.toggle-search').addClass('active'); 695 696 } 697 698 } 699 700 }; 701 702 }(); 703 704 705 // load on document ready 706 jQuery(function() { 707 jsNav.init(); 708 }); 709 710 711})(jQuery); 712 713//Commenting out for now. Issue found where only the first nav item was being affected. Most likely an easy fix. 714//@todo fix this 715// 716//(function ($) { 717// 718// $(document).on('mouseenter', '.no-touch-view ul.menu a:first', function () { 719// $("#menu-header-menu li > ul:first li:nth-child(10)").after('<li><a style="font-style: italic;" class="nav-load-more">Load More..</a></li>'); 720// var x = -2; 721// 722// $("#menu-header-menu li > ul:first > li").each(function () { 723// if (x > 8) { 724// 725// $(this).hide(); 726// } else { 727// $(this).show(); 728// } 729// x++; 730// 731// }); 732// }); 733// 734// $(document).on('mouseleave', '.no-touch-view', function () { 735// $(".nav-load-more").remove(); 736// $(".nav-load-less").remove(); 737// }); 738// 739// $(document).on('click', '.nav-load-more', function () { 740// 741// $(this).remove(); 742// 743// var x = -2; 744// $("#menu-header-menu li > ul:first > li").each(function () { 745// if (x < 8) { 746// 747// $(this).hide(); 748// } else { 749// $(this).show(); 750// } 751// x++; 752// }); 753// 754// $("#menu-header-menu li > ul:first").append('<li><a style="font-style: italic;" class="nav-load-less">Load Previous..</a></li>'); 755// 756// }); 757// 758// $(document).on('click', '.nav-load-less', function () { 759// 760// $(this).remove(); 761// 762// var x = -2; 763// $("#menu-header-menu li > ul:first > li").each(function () { 764// if (x < 8) { 765// 766// $(this).show(); 767// } else { 768// $(this).hide(); 769// 770// } 771// x++; 772// }); 773// 774// $("#menu-header-menu li > ul:first li:nth-child(10)").after('<li><a style="font-style: italic;" class="nav-load-more">Load More..</a></li>'); 775// 776// }); 777// 778//})(jQuery); 779 780
781//////////////////////////////////////////////////////// 782 783///// Masonry (for widgets in tablet view only) 784 785//////////////////////////////////////////////////////// 786 787 788(function($) { 789 790 791 // global JS object 792 var masonry = function() { 793 794 //global vars 795 var _this, resizeTimer, container, isActive, msnry; 796 797 return{ 798 init: function() { 799 800 _this = this; 801 802 isActive = false; 803 804 msnry = ''; 805 806 container = document.querySelector('#right-rail'); 807 808 // resize 809 $(window).on('resize', function() { 810 clearTimeout(resizeTimer); 811 resizeTimer = setTimeout(function() { 812 _this.resizeEnd(); 813 }, 100); 814 }); 815 816 817 // set nav class on init 818 if (($(window).width() < 769) && ($(window).width() > 649)) { 819 820 if ($('html').hasClass('ie8')) { 821 822 imagesLoaded(container, function() { 823 824 _this.msnry = new Masonry(container, { 825 itemSelector: '.rail-container', 826 gutter: '.gutter-sizer', 827 isFitWidth: true, 828 isInitLayout: false 829 }); 830 831 }); 832 833 } else { 834 835 imagesLoaded(container, function() { 836 837 _this.msnry = new Masonry(container, { 838 itemSelector: '.rail-container', 839 gutter: '.gutter-sizer', 840 isFitWidth: true, 841 isInitLayout: true 842 }); 843 844 }); 845 846 } 847 848 _this.isActive = true; 849 850 } 851 852 }, 853 resizeEnd: function() { 854 855 if (($(window).width() < 769) && ($(window).width() > 649)) { 856 857 if (_this.isActive) { 858 859 //nothing 860 861 } else { 862 863 _this.msnry = new Masonry(container, { 864 itemSelector: '.rail-container', 865 gutter: '.gutter-sizer', 866 isFitWidth: true 867 }); 868 869 _this.isActive = true; 870 871 } 872 873 } else { 874 875 if (_this.isActive) { 876 877 _this.msnry.destroy(); 878 879 _this.isActive = false; 880 881 } 882 883 } 884 885 } 886 887 }; 888 889 }(); 890 891 892 // load on document ready 893 jQuery(function() { 894 if ($('aside').exists()) { 895 masonry.init(); 896 } 897 }); 898 899 900})(jQuery); 901 902 903 904 905//////////////////////////////////////////////////////// 906 907///// Squares 908 909//////////////////////////////////////////////////////// 910 911 912(function($) { 913 914 915 // global JS object 916 var squares = function() { 917 918 //global vars 919 var _this, css3 = Modernizr.csstransitions; 920 921 return{ 922 init: function() { 923 924 _this = this; 925 926 $('.square').mouseenter(_this.shadeUp); 927 $('.square').mouseleave(_this.shadeDown); 928 929 }, 930 shadeUp: function() { 931 932 if (css3) { 933 934 $(this).addClass('on-css'); 935 936 } else { 937 938 $(this).addClass('on-js'); 939 $(this).find('.shade').animate({ 940 "height": "100%" 941 }, 400); 942 $(this).find('.shade p').animate({ 943 "opacity": "1" 944 }, 400); 945 946 } 947 948 }, 949 shadeDown: function() { 950 951 if (css3) { 952 953 $(this).removeClass('on-css'); 954 955 } else { 956 957 $(this).removeClass('on-js'); 958 $(this).find('.shade').animate({ 959 "height": "35%" 960 }, 400); 961 $(this).find('.shade p').animate({ 962 "opacity": "0" 963 }, 400); 964 965 } 966 967 } 968 969 }; 970 971 }(); 972 973 974 // load on document ready 975 jQuery(function() { 976 squares.init(); 977 }); 978 979 980})(jQuery); 981 982 983 984 985//////////////////////////////////////////////////////// 986 987///// FILTERED SEARCH 988 989//////////////////////////////////////////////////////// 990 991 992(function($) { 993 994 995 // global JS object 996 var filters = function() { 997 998 //global vars 999 var _this, panel, resizeTimer; 1000 1001 return{ 1002 init: function() { 1003 1004 _this = this; 1005 1006 panel = $('.filters .group-head'); 1007 1008 panel.click(_this.slidePanel); 1009 1010 1011 // noUiSlider required 1012 if ($('#radius-slider').exists()) { 1013 $("#radius-slider").noUiSlider({ 1014 start: 10, 1015 range: { 1016 'min': 5, 1017 'max': 100 1018 }, 1019 serialization: { 1020 lower: [ 1021 $.Link({ 1022 target: $("#search-radius"), 1023 method: 'val', 1024 format: { 1025 decimals: 0 1026 } 1027 }) 1028 ] 1029 } 1030 }); 1031 } 1032 1033 1034 // resize 1035 $(window).on('resize', function() { 1036 clearTimeout(resizeTimer); 1037 resizeTimer = setTimeout(function() { 1038 _this.resizeEnd(); 1039 }, 100); 1040 }); 1041 1042 1043 // letters popup 1044 $('.show-letters').click(_this.letters); 1045 $('.close-letters').click(_this.letters); 1046 1047 1048 // toggle map 1049 $('.view-map').click(_this.map); 1050 1051 $('.toggle-filters').click(_this.slideFilters); 1052 1053 }, 1054 slidePanel: function() { 1055 1056 if ($(this).parent('.filter-group').hasClass('open')) { 1057 1058 $('.filter-group').removeClass('open');
1059 $('.group-body').slideUp(400); 1060 1061 } else { 1062 1063 $('.filter-group').removeClass('open'); 1064 $('.group-body').slideUp(400); 1065 1066 $(this).parent('.filter-group').addClass('open'); 1067 $(this).next('.group-body').slideDown(400); 1068 1069 } 1070 1071 }, 1072 letters: function() { 1073 1074 if ($('.letters').hasClass('open')) { 1075 1076 $('.letters').removeClass('open'); 1077 1078 } else { 1079 1080 $('.letters').addClass('open'); 1081 1082 } 1083 1084 }, 1085 map: function() { 1086 1087 var mapWrap = $(this).closest('.result').find('.map-wrap'); 1088 1089 if (mapWrap.hasClass('open')) { 1090 1091 mapWrap.removeClass('open'); 1092 mapWrap.slideUp(400); 1093 1094 $(this).html('View on Map'); 1095 1096 } else { 1097 1098 mapWrap.addClass('open'); 1099 mapWrap.slideDown(400); 1100 1101 $(this).html('Close Map'); 1102 1103 } 1104 1105 }, 1106 slideFilters: function() { 1107 1108 if ($('.toggle-filters').hasClass('active')) { 1109 1110 $('.toggle-filters').removeClass('active'); 1111 1112 } else { 1113 1114 $('.toggle-filters').addClass('active'); 1115 1116 } 1117 1118 if ($('.filters').hasClass('open')) { 1119 1120 $('.filters').removeClass('open').slideUp(600); 1121 $('.clear-filters').hide(); 1122 1123 } else { 1124 1125 $('.filters').addClass('open').slideDown(600); 1126 $('.clear-filters').show(); 1127 } 1128 1129 }, 1130 resizeEnd: function() { 1131 1132 if (($(window).width() > 900)) { 1133 1134 1135 $('.toggle-filters').addClass('active'); 1136 $('.filters').addClass('open').show(); 1137 1138 1139 } else { 1140 1141 $('.toggle-filters').removeClass('active'); 1142 $('.filters').removeClass('open').hide(); 1143 1144 } 1145 1146 } 1147 }; 1148 1149 }(); 1150 1151 1152 // load on document ready 1153 jQuery(function() { 1154 filters.init(); 1155 }); 1156 1157 1158})(jQuery); 1159 1160 1161 1162 1163//////////////////////////////////////////////////////// 1164 1165///// BOXER (MODAL SETTINGS) 1166 1167//////////////////////////////////////////////////////// 1168 1169 1170(function($) { 1171 1172 1173 // global JS object 1174 var boxer = function() { 1175 1176 //global vars 1177 var _this, ssModal; 1178 1179 return{ 1180 init: function() { 1181 1182 _this = this; 1183 1184 ssModal = ''; 1185 1186 $('.boxer').boxer({ 1187 //mobile: true 1188 }); 1189 1190 $('.show-cruise').boxer({ 1191 }); 1192 1193 $('.qv-modal').boxer({ 1194 top: 40, 1195 customClass: 'quick-view-modal', 1196 callback: function() { 1197 1198 $('.close-modal').on('click', function() { 1199 $.boxer('close'); 1200 }); 1201 1202 $('.boxer-container .modal-swiper').attr('id', 'modal-swiper-live'); 1203 1204 _this.modalSwiper(); 1205 } 1206 }); 1207 1208 }, 1209 modalSwiper: function() { 1210 1211 var ssModal = $('#modal-swiper-live').swiper({ 1212 mode: 'horizontal', 1213 loop: false, 1214 calculateHeight: true, 1215 visibilityFullFit: true 1216 }); 1217 1218 // set buttons 1219 $('.modal-img-prev').on('click', function(e) { 1220 e.preventDefault(); 1221 ssModal.swipePrev(); 1222 }); 1223 $('.modal-img-next').on('click', function(e) { 1224 e.preventDefault(); 1225 ssModal.swipeNext(); 1226 }); 1227 1228 // destroy swiper on modal close 1229 $('.close-modal, .prev-modal, .next-modal').on('click', function() { 1230 if (ssModal) { 1231 $('.boxer-container .modal-swiper').attr('id', ''); 1232 ssModal.destroy(); 1233 } 1234 }); 1235 1236 } 1237 }; 1238 1239 }(); 1240 1241 1242 // load on document ready 1243 jQuery(function() { 1244 boxer.init(); 1245 }); 1246 1247 1248})(jQuery); 1249 1250//////////////////////////////////////////////////////// 1251 1252///// Posts ( Media Gallery Bucket Slider ) 1253 1254//////////////////////////////////////////////////////// 1255 1256(function($) { 1257 // global JS object 1258 var bucketCarouselPostMedia = function() { 1259 1260 //global vars 1261 var self, resizeTimer; 1262 1263 return{ 1264 init: function(){ 1265 self = this; 1266 // resize 1267 $(window).on('resize', function() { 1268 clearTimeout(resizeTimer); 1269 resizeTimer = setTimeout(function(){ 1270 $(window).trigger('resizeend'); 1271 },1000); 1272 }); 1273 1274 $(window).on('resizeend', self.resizeEnd); 1275 $(window).trigger('resizeEnd'); 1276 1277 // load swiper 1278 self.pickSize(); 1279 }, 1280 1281 resizeEnd: function(){ 1282 self.pickSize(); 1283 }, 1284 1285 pickSize: function(){ 1286 if ( $('.bucket-carousel-post-media').length ) { 1287 //config for desktop 1288 if ( $(window).width() > 480 ) { 1289 1290 $('.bucket-carousel-post-media').each(function(i,v){ 1291 1292 //get the a unique identifier to be used by JS to identifier 1293 //individual sliders when there are multiple sliders on a page 1294 var swiper_id = $(v).data('swiper-id'); 1295 1296 var bucketCarouselPostMedia = $(v).swiper({ 1297 mode:'horizontal', 1298 loop: false, 1299 slidesPerView: 1, 1300 calculateHeight: true, 1301 onInit : function() { 1302 var imgHeight = $('.bucket-carousel.post-media-images .bucket img').height(); 1303 $('.bucket-carousel.post-media-images.'+ swiper_id +' .bc-next, .bucket-carousel.post-media-images.'+ swiper_id +' .bc-prev').height(imgHeight); 1304 $('.bucket-carousel.post-media-images.'+ swiper_id +' .bc-prev').addClass('disabled'); 1305 }, 1306 onSlideChangeEnd: function() { 1307 if ( bucketCarouselPostMedia.activeIndex === ( bucketCarouselPostMedia.slides.length - 1 ) ) { 1308 $('.bucket-carousel.post-media-images.'+ swiper_id +' .bc-next').addClass('disabled'); 1309 } else { 1310 $('.bucket-carousel.post-media-images.'+ swiper_id +' .bc-next').removeClass('disabled'); 1311 } 1312 if ( bucketCarouselPostMedia.activeIndex === 0 ) { 1313 $('.bucket-carousel.post-media-images.'+ swiper_id +' .bc-prev').addClass('disabled'); 1314 } else { 1315 $('.bucket-carousel.post-media-images.'+ swiper_id +' .bc-prev').removeClass('disabled'); 1316 } 1317 } 1318 }); 1319 1320 bucketCarouselPostMedia.reInit(); 1321 1322 // swiper buttons 1323 $('.bucket-carousel.post-media-images.'+ swiper_id +' .bc-prev').on('click', function(e){ 1324 e.preventDefault(); 1325 bucketCarouselPostMedia.swipePrev(); 1326 }); 1327 $('.bucket-carousel.post-media-images.'+ swiper_id +' .bc-next').on('click', function(e){ 1328 e.preventDefault(); 1329 bucketCarouselPostMedia.swipeNext(); 1330 }); 1331 }); 1332 //config for mobile 1333 } else { 1334 var bucketCarouselPostMedia = $('.bucket-carousel-post-media').swiper({ 1335 mode:'horizontal', 1336 loop: false, 1337 calculateHeight: true, 1338 freeMode: true, 1339 freeModeFluid: true 1340 }); 1341 bucketCarouselPostMedia.reInit(); 1342 } 1343 } 1344 } 1345 }; 1346 }(); 1347 1348 // load on document ready 1349 jQuery(function() { 1350 bucketCarouselPostMedia.init(); 1351 }); 1352})(jQuery); 1353 1354
1355//////////////////////////////////////////////////////// 1356 1357///// Blog_channel ( more blogs bucket Slider ) 1358 1359//////////////////////////////////////////////////////// 1360 1361 1362(function($) { 1363 // global JS object 1364 var bucketCarouselBlogChannelMoreBlogs = function() { 1365 1366 //global vars 1367 var self, resizeTimer; 1368 1369 return{ 1370 init: function() { 1371 1372 self = this; 1373 // resize 1374 $(window).on('resize', function() { 1375 clearTimeout(resizeTimer); 1376 resizeTimer = setTimeout(function() { 1377 $(window).trigger('resizeend'); 1378 }, 1379 1000 1380 ); 1381 }); 1382 1383 $(window).on('resizeend', self.resizeEnd); 1384 $(window).trigger('resizeEnd'); 1385 1386 // load swiper 1387 self.pickSize(); 1388 }, 1389 resizeEnd: function() { 1390 self.pickSize(); 1391 }, 1392 pickSize: function() { 1393 1394 //config for desktop 1395 if ($('#bucket-carousel-more-blogs').length){ 1396 if ($(window).width() > 480) { 1397 1398 var bucketCarouselBlogChannelMoreBlogs = $('#bucket-carousel-more-blogs').swiper({ 1399 mode: 'horizontal', 1400 loop: false, 1401 slidesPerView: 3, 1402 calculateHeight: true, 1403 onInit: function() { 1404 var imgHeight = $('.bucket-carousel.other-staff-writers .bucket img').height(); 1405 $('.bucket-carousel.other-staff-writers .bc-next, .bucket-carousel.other-staff-writers .bc-prev').height(imgHeight); 1406 $('.bucket-carousel.other-staff-writers .bc-prev').addClass('disabled'); 1407 }, 1408 onSlideChangeEnd: function() { 1409 if (bucketCarouselBlogChannelMoreBlogs.activeIndex === (bucketCarouselBlogChannelMoreBlogs.slides.length - 3)) { 1410 $('.bucket-carousel.other-staff-writers .bc-next').addClass('disabled'); 1411 } else { 1412 $('.bucket-carousel.other-staff-writers .bc-next').removeClass('disabled'); 1413 } 1414 if (bucketCarouselBlogChannelMoreBlogs.activeIndex === 0) { 1415 $('.bucket-carousel.other-staff-writers .bc-prev').addClass('disabled'); 1416 } else { 1417 $('.bucket-carousel.other-staff-writers .bc-prev').removeClass('disabled'); 1418 } 1419 } 1420 }); 1421 1422 bucketCarouselBlogChannelMoreBlogs.reInit(); 1423 1424 // swiper buttons 1425 $('.bucket-carousel.other-staff-writers .bc-prev').on('click', function(e) { 1426 e.preventDefault(); 1427 bucketCarouselBlogChannelMoreBlogs.swipePrev(); 1428 }); 1429 $('.bucket-carousel.other-staff-writers .bc-next').on('click', function(e) { 1430 e.preventDefault(); 1431 bucketCarouselBlogChannelMoreBlogs.swipeNext(); 1432 }); 1433 1434 //config for mobile 1435 1436 } else { 1437 1438 var bucketCarouselBlogChannelMoreBlogs = $('#bucket-carousel-more-blogs').swiper({ 1439 mode: 'horizontal', 1440 loop: false, 1441 calculateHeight: true, 1442 freeMode: true, 1443 freeModeFluid: true 1444 }); 1445 1446 bucketCarouselBlogChannelMoreBlogs.reInit(); 1447 } 1448 } 1449 } 1450 }; 1451 1452 }(); 1453 1454 1455 // load on document ready 1456 jQuery(function() { 1457 bucketCarouselBlogChannelMoreBlogs.init(); 1458 }); 1459 1460 1461})(jQuery); 1462 1463var napco_user_logged_in = false; 1464function napco_set_login_status() { 1465 var data = { 1466 action: 'is_user_logged_in' 1467 }; 1468 1469 jQuery.post(napco_data.ajaxurl, data, function(response) { 1470 if (response == 'yes') { 1471 napco_user_logged_in = true; 1472 napco_adminbar_padding('32px'); 1473 } 1474 }); 1475} 1476 1477function napco_admin_post_info(post_id) { 1478 //return; 1479 var data = { 1480 action: 'admin_post_info_bar', 1481 post_id: post_id 1482 }; 1483 jQuery.get(napco_data.ajaxurl, data, function(response) { 1484 jQuery('#post-info-holder').html(response); 1485 }); 1486} 1487 1488function napco_adminbar_padding(padding) { 1489 if ( napco_user_logged_in && jQuery('#wpadminbar').length ) { 1490 //always reset the move again if staged 1491 jQuery('html.no-touch header .bot-layer').css('top', 0); 1492 jQuery('html.no-touch header .bot-layer.staged').css('top', padding); 1493 } 1494} 1495 1496function napco_post_stat(args) { 1497 return; 1498 args.action = 'napco_post_stat'; 1499 jQuery.ajax( 1500 { 1501 type: 'POST', 1502 url: '/wp-admin/admin-ajax.php', 1503 cache: false, 1504 async: true, 1505 data: args, 1506 success: function(data){ 1507 //console.log(data); 1508 } 1509 } 1510 ); 1511} 1512 1513function napco_window_targets() { 1514 jQuery("a[href^=http]").each(function() { 1515 1516 var parts = location.hostname.split('.'); 1517 var subdomain = parts.shift(); 1518 var upperleveldomain = parts.join('.'); 1519 //var sndleveldomain = parts.slice(-2).join('.'); 1520 1521 1522 //domains list 1523 var exclude_domains = [ 1524 location.hostname, 1525 'jobs.'+ upperleveldomain 1526 ]; 1527 1528 skip_this_one = false;
1529 for(i=0; i<exclude_domains.length; i++) { 1530 if(this.href.indexOf(exclude_domains[i]) > -1) { 1531 skip_this_one = true; 1532 continue; 1533 } 1534 } 1535 if ( ! skip_this_one ) { 1536 jQuery(this).attr({ 1537 target: "_blank", 1538 title: "Opens in a new window" 1539 }); 1540 } 1541 }); 1542} 1543 1544jQuery(document).ready(function($) { 1545 $('.search-bar.desktop .mag').click(function (event) { 1546 if ($('.search-bar.desktop input[type=text]').val() === '') { 1547 if ($('.search-bar.desktop .search-outer').is(':hidden')) { 1548 $('.search-bar.desktop .search-outer').fadeIn(); 1549 $('.search-bar.desktop input[type=text]').focus(); 1550 } else { 1551 $('.search-bar.desktop .search-outer').fadeOut(); 1552 } 1553 } else { 1554 $('.search-bar.desktop form').submit(); 1555 } 1556 }); 1557}); 1558 1559jQuery(document).ready(function ($) { 1560 1561 $( "nav.touch-view.wp-menu ul.menu > li:first-child > a" ).after( "<span id='fmenuclose'></span>" ); 1562 $('#fmenuclose').click(function () { 1563 event.preventDefault(); 1564 $('.pusher').removeClass('active'); 1565 $('.trigger-main-nav').removeClass('active'); 1566 $('.touch-view').removeClass('open'); 1567 self.menuClose; 1568 }); 1569 1570 $("#load-more.button").click(function (page) { 1571 1572 $(this).hide(); //hide show more button on click 1573 $('.animation_image').show(); //show loading image 1574 1575 var limit = 8; 1576 var offset = $('.main article.resource').length; 1577 var category = $('#cat-slct option:selected').val(); 1578 var type = ( $('#editorial_type').length ) ? $('#editorial_type').val() : $('#type-slct option:selected').val(); 1579 var s = $('#search_terms').text(); 1580 1581 jQuery.ajax({ 1582 type: 'GET', 1583 url: '/wp-admin/admin-ajax.php', 1584 cache: false, 1585 async: true, 1586 data: { 1587 action: 'load_more_resources', 1588 limit: limit, 1589 offset: offset, 1590 category: category, 1591 type: type, 1592 s: s 1593 }, 1594 success: function (data) { 1595 result = JSON.parse(data); 1596 1597 $.each(result.posts, function (i, post) { 1598 out = ''; 1599 out += '<article class="resource listing">'; 1600 out += '<div class="thumb">'; 1601 out += '<a href="' + post.href + '"><img src="' + post.thumb.widget_thumb_src + '"></a>'; 1602 out += '</div>'; 1603 out += '<div class="info with-thumb">'; 1604 if (typeof post.first_category.name !== 'undefined') { 1605 out += '<p><a href="/resources/category/' + post.first_category.name + '" class="post-blog-cat-label">' + post.first_category.name + '</a></p>'; 1606 } 1607 1608 post_title = (post.truncated_title) ? post.truncated_title : post.post_title; 1609 1610 out += '<h3 class="h6a"><a title="' + post.post_title + '" href="' + post.href + '">' + post_title + '</a></h3>'; 1611 out += '</div>'; 1612 out += '</article>'; 1613 out += '<div class="hr"></div>'; 1614 $('.main.resource-archive').append(out);//code 1615 }); 1616 1617 if (result.more_pages) { 1618 $("#load-more.button").show(); //hide show more button on click 1619 } 1620 1621 $('.animation_image').hide(); //show loading image 1622 1623 } 1624 } 1625 ); 1626 }); 1627 1628 1629 1630 //track outbound links 1631 $("a").on("click", function(e) { 1632 // abandon if link already aborted or analytics is not available 1633 if (e.isDefaultPrevented() || typeof _gaq !== "object") return; 1634 1635 // abandon if no active link or link within domain 1636 var link = $(this); 1637 if (link.length != 1 || window.location.host == link[0].host || ! $(this).attr('href') || $(this).attr('href').indexOf('javascript:') > -1 ) return; 1638 e.preventDefault(); 1639 1640 // cancel event and record outbound link 1641 var fakeLink = document.createElement('a'); 1642 fakeLink.href = $(this).attr('href'); 1643 1644 if ($('#post_type').length) { 1645 pageType = $('#post_type').val(); 1646 } else { 1647 pageType = getMetaTagContentByProperty('pageType'); 1648 } 1649 1650 console.log('Tracking Outbound Link: '+ pageType +' : '+ fakeLink.hostname); 1651 _gaq.push(['_trackEvent', pageType, 'External URL Clicked', fakeLink.hostname]); 1652 1653 //redirect after time to make sure it hits to GA 1654 setTimeout(function() { 1655 window.open( fakeLink.href ); 1656 }, 200); 1657 }); 1658 1659}); 1660 1661 1662function disqus_config() { 1663 this.callbacks.onNewComment = [function(comment) { 1664 args = { 1665 action: 'disqus_comment_inserted', 1666 comment_id: comment.id, 1667 post_id: getMetaTagContentByProperty('pageId'), 1668 } 1669 jQuery.ajax( 1670 { 1671 type: 'GET', 1672 url: napco_data.ajaxurl, 1673 cache: false, 1674 async: true, 1675 data: args, 1676 success: function(result) { 1677 console.log(result); 1678 } 1679 } 1680 ) 1681 }]; 1682} 1683 1684 1685function gatedCookieCheck(cookie_val) { 1686 return; 1687 i = 0; 1688 var x = setInterval(function () { 1689 if (jQuery.cookie('x') == cookie_val) { 1690 url = window.location.href +'/thank-you/'; 1691 window.location.replace(url); 1692 } 1693 i++; 1694 console.log(i); 1695 if (i > 100) 1696 clearInterval(x); 1697 }, 200); 1698}
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.