1// Set jQuery to NoConflict Mode 2jQuery.noConflict(); 3 4 5/** 6 * Themewich Theme Functions 7 * 8 * Copyright 2013, Andre Gagnon - http://themewich.com 9 * 10 */ 11(function( $ ){ 12 "use strict"; 13 14 /** 15 * Converts html image to full fixed background 16 * @since v1.0 17 * (c) Copyright 2013 Andre Gagnon - http://themewich.com 18 */ 19 $.fn.parallaxImg = function(){ 20 if ($('body').hasClass('full-width')){ 21 $(this).each(function(){ 22 var $this = jQuery(this), 23 parallaxsrc = $this.attr('src'), 24 closestdiv = $this.closest('div'); 25 26 // Set background div based on image 27 var $parallaxbg = $this.before('<div class="full-bg-image" style="background-image: url('+parallaxsrc+');"></div>'); 28 29 // If there's a caption set 30 if (closestdiv.hasClass('wp-caption')) { 31 closestdiv.removeClass('wp-caption').addClass('post-break has-caption').css('width', 'auto'); 32 } else { // otherwise 33 $('.full-bg-image').wrap('<div class="post-break"></div>'); 34 } 35 $this.remove(); 36 }); 37 } 38 } 39 40 41 /** 42 * Sticky nav menu 43 * @since v1.0 44 * (c) Copyright 2013 Andre Gagnon - http://themewich.com 45 */ 46 $.fn.themewichStickyNav = function(){ 47 var sticky_nav = jQuery(this), 48 nav_container = sticky_nav.closest('.top-nav'), 49 sticky_cells = sticky_nav.find('.cell'), 50 site_container = jQuery('#sitecontainer'), 51 sticky_height; 52 53 // Only run this once 54 if (!sticky_nav.hasClass('stickyloaded')) { 55 56 sticky_height = sticky_nav.find('.container').outerHeight(); 57 58 // Set just the height without padding 59 sticky_cells.css({ 60 'height' : sticky_height + 'px', 61 'padding': 0 62 }); 63 64 // Give nav container a fixed position 65 nav_container.css('position','fixed'); 66 67 // Give site container top padding 68 site_container.css({ 69 'padding-top' : sticky_height + (parseInt(sticky_cells.css('padding-top'))*2)//need to use padding due to fixed background bug in chrome 70 }); 71 72 // Add loaded indicator 73 sticky_nav.addClass('stickyloaded'); 74 } 75 76 function stickyHeader() { 77 sticky_cells.css({ 78 'height' : sticky_height - getScrollTop() 79 }); 80 } 81 82 // Cross browser scrolltop function 83 function getScrollTop(){ 84 if(typeof pageYOffset!= 'undefined'){ 85 //most browsers 86 return pageYOffset; 87 } 88 else{ 89 var B = document.body; //IE 'quirks' 90 var D = document.documentElement; //IE with doctype 91 D = (D.clientHeight)? D: B; 92 return D.scrollTop; 93 } 94 } 95 96 $(window).scroll(stickyHeader); 97 $(document).ready(stickyHeader); 98 99 } 100 101 102 /** 103 * Calls lightbox links 104 * @since v1.0 105 */ 106 $.fn.themewichLightbox = function() { 107 108 jQuery("a.themewich-lightbox").addClass('no-ajaxy'); 109 110 jQuery("a.themewich-lightbox").magnificPopup({ 111 type:'image', 112 closeBtnInside: true, 113 tLoading: '<img src="' + agAjax.get_template_directory_uri + '/images/small-loading.gif"/>', 114 mainClass: 'mfp-zoom-in', 115 removalDelay: 500, //delay removal by X to allow out-animation 116 image: { 117 tError: '<a href="%url%">The image #%curr%</a> could not be loaded.', 118 titleSrc: function(item) { 119 return item.el.find('img').attr('title'); 120 }, 121 markup: '<div class="mfp-figure">'+ 122 '<div class="mfp-close"></div>'+ 123 '<div class="mfp-img"></div>'+ 124 '<div class="mfp-bottom-bar">'+ 125 '<div class="mfp-title-wrapper"><div class="mfp-title"></div></div>'+ 126 '<div class="mfp-counter"></div>'+ 127 '</div>'+ 128 '</div>' // Popup HTML markup. `.mfp-img` div will be replaced with img tag, `.mfp-close` by close button 129 }, 130 callbacks: { 131 imageLoadComplete: function() { 132 var self = this; 133 setTimeout(function() { 134 self.wrap.addClass('mfp-image-loaded'); 135 }, 16); 136 }, 137 close: function() { 138 this.wrap.removeClass('mfp-image-loaded'); 139 } 140 }, 141 closeOnContentClick: true, 142 midClick: true 143 }); 144 145 jQuery('.open-popup-link').magnificPopup({ 146 type: 'inline', 147 148 fixedContentPos: false, 149 fixedBgPos: true, 150 tLoading: '<img src="' + agAjax.get_template_directory_uri + '/images/small-loading.gif"/>', 151 152 overflowY: 'auto', 153 154 closeBtnInside: true, 155 preloader: false, 156 157 midClick: true, 158 removalDelay: 300, 159 mainClass: 'my-mfp-slide-bottom' 160 }); 161 162 jQuery('.gallery').each(function(){ 163 164 jQuery(this).magnificPopup({ 165 delegate: 'a.lightbox-gallery:not(.bx-clone a.lightbox-gallery)', 166 type: 'image', 167 closeBtnInside: true, 168 tLoading: '<img src="' + agAjax.get_template_directory_uri + '/images/small-loading.gif"/>', 169 mainClass: 'mfp-zoom-in', 170 removalDelay: 500, //delay removal by X to allow out-animation 171 gallery: { 172 enabled: true, 173 navigateByImgClick: true, 174 preload: [0,1] // Will preload 0 - before current, and 1 after the current image 175 }, 176 image: { 177 tError: '<a href="%url%">The image #%curr%</a> could not be loaded.', 178 titleSrc: function(item) { 179 return item.el.find('img').attr('title'); 180 }, 181 markup: '<div class="mfp-figure">'+ 182 '<div class="mfp-close"></div>'+ 183 '<div class="mfp-img"></div>'+ 184 '<div class="mfp-bottom-bar">'+ 185 '<div class="mfp-title-wrapper"><div class="mfp-title"></div></div>'+ 186 '<div class="mfp-counter"></div>'+ 187 '</div>'+ 188 '</div>' // Popup HTML markup. `.mfp-img` div will be replaced with img tag, `.mfp-close` by close button 189 }, 190 callbacks: { 191 imageLoadComplete: function() { 192 var self = this; 193 setTimeout(function() { 194 self.wrap.addClass('mfp-image-loaded'); 195 }, 16); 196 }, 197 close: function() { 198 this.wrap.removeClass('mfp-image-loaded'); 199 } 200 }, 201 closeOnContentClick: true, 202 midClick: true 203 }); 204 }); 205 } 206 207 208 /** 209 * Matches title height to box height for centering on hover 210 * @since v1.0 211 * (c) Copyright 2013 Andre Gagnon - http://themewich.com 212 */ 213 $.fn.matchHeight = function() { 214 function match_height() { 215 jQuery('a.postlink .title').not('a.postlink .title.noimages').each(function() { 216 var height = jQuery(this).closest('.postphoto').height(); 217 jQuery(this).css({'height' : height + 'px'} ); 218 }); 219 } 220 match_height(); 221 $(window).resize(function(){ 222 match_height(); 223 }); 224 } 225 226 227 /** 228 * Adds javascript hover effects 229 * @since v1.0 230 * (c) Copyright 2013 Andre Gagnon - http://themewich.com 231 */ 232 $.fn.themewichHovers = function() { 233 234 function hover_overlay_slides() { 235 jQuery('.featured-image a').each(function() { 236 var $this = jQuery(this).parent().find('img'); 237 jQuery(this).hover( function() { 238 $this.stop().animate({opacity : 0.5}, 250, 'easeOutCubic'); 239 }, function() { 240 $this.stop().animate({opacity : 1}, 250, 'easeOutCubic'); 241 }); 242 }); 243 } 244 245 function hover_overlay_isotope() { 246 jQuery('.no-opacity a.postlink').each(function(){ 247 // Hover Function 248 jQuery(this).hover(function(){ 249 jQuery(this).find('.overlay').stop().animate({'opacity' : 0.75}, 500, 'easeOutCubic'); 250 }, function(){ 251 jQuery(this).find('.overlay').stop().animate({'opacity' : 0}, 500, 'easeOutCubic'); 252 }); 253 }); 254 } 255 256 hover_overlay_isotope(); 257 258 function hover_overlay_portfolio() { 259 260 jQuery('a.thumblink').each(function() { 261 jQuery(this).closest('.featured-image').addClass('highlight').addClass('loaded').css({'min-height': '0'}); 262 var $this = jQuery(this).find('img'); 263 $this.hover( function() { 264 $this.stop().animate({opacity : 0.5}, 250, 'easeOutCubic'); 265 }, function() { 266 $this.stop().animate({opacity : 1}, 250, 'easeOutCubic'); 267 }); 268 }); 269 } 270 271 function hide_loading() { 272 jQuery('.featured-image').not('.isobrick .featured-image').css({'background': 'none', 'min-height': '0'}); 273 } 274 275 (function($){ $(window).load(function() { hover_overlay_portfolio(); hover_overlay_images(); hide_loading(); }); })(jQuery); 276 277 278 function hover_overlay_images() { 279 280 jQuery('a img').not('.single-slideshow a img, .featured-image img, .ag_recentprojects_widget a img, .gallery a img, a img.fullimg, a img.fixedimg, .wp-caption a img').each(function() { 281 jQuery(this).hover( function() { 282 var $this = jQuery(this).parent().children('img'); 283 jQuery($this).stop().animate({opacity : 0.5}, 250, 'easeOutCubic'); 284 }, function() { 285 var $this = jQuery(this).parent().children('img'); 286 jQuery($this).stop().animate({opacity : 1}, 250, 'easeOutCubic'); 287 }); 288 289 }); 290 291 } 292 293 } 294 295 296 /** 297 * Responsive slider object 298 * @type {class} 299 */ 300 var themewichSlider = { 301 302 createSlider : function(selector, callback) { 303 304 jQuery(selector).each(function(index) { 305 306 // Get Options from HTML 307 var $this = jQuery(this), 308 $info = $this.closest('.info'), 309 $touch = ($info.hasClass('postphoto')) ? false : true, 310 $window = jQuery(window), 311 autoPlay = $info.hasClass('autoplay') ? true : false, 312 pauseDelay = 5000, 313 pauseDelay = $info.attr('data-pause') ? parseInt($info.attr('data-pause'), 10) : pauseDelay, 314 pauseDelay = $info.hasClass('random') ? (Math.floor(Math.random()*10001) + 3000) : pauseDelay, 315 speedDelay = $info.attr('data-speed') ? parseInt($info.attr('data-speed'), 10) : 500, 316 pagerOption = $info.hasClass('pager') ? true : false, 317 pagerOption = $info.find('.bxslider li').length > 1 ? pagerOption : false, 318 carousel = $info.hasClass('carousel') ? true : false, 319 autoHover = $info.hasClass('hovergo') ? false : true, 320 slideMode = 'fade', 321 slideMode = $info.hasClass('horizontal') ? 'horizontal' : slideMode, 322 slideMode = $info.hasClass('vertical') ? 'vertical' : slideMode, 323 adaptive = $info.hasClass('noadapt') ? false : true; 324 325 if (pagerOption == false) { 326 $info.removeClass('pager'); 327 } 328 329 330 /** 331 * Carousel Slider 332 * @since v1.0 333 */ 334 function carouselSlider() { 335 var slideWidth = 320, 336 slideMargin = 10, 337 totalSlideWidth = slideWidth + slideMargin, 338 noWide = $('body').hasClass('full-width'); 339 340 $this.bxSlider({ 341 //Options 342 adaptiveHeight: adaptive, 343 minSlides: 2, 344 maxSlides: 9, 345 slideWidth: slideWidth, 346 slideMargin: slideMargin, 347 infiniteLoop: true, 348 pager: pagerOption, 349 controls: true, 350 autoControls: true, 351 useCSS: false, //Chrome gets buggy with this enabled 352 touchEnabled: true, 353 captions: false, 354 preloadImages: 'visible', 355 356 //After Slider Load 357 onSliderLoad: function() { 358 359 // Closest info container 360 $info = $this.closest('.info'); 361 362 // Fade in and add overlay effect 363 $this.animate({'opacity': 1}, 500, 'easeOutCubic'); 364 365 // Fade In Controls 366 $info.find('.bx-controls').animate({'opacity': 1}, 500); 367 368 // Remove min-height and loading image 369 $this 370 .animate({'opacity': 1}, 500, function() { 371 $this.closest('div.info') 372 .css({ 373 'min-height': 'none', 374 'background': 'none' 375 }); 376 }); 377 378 // Fix popup issue with cloned slides 379 var $clones = $this.find('.gallery-icon.bx-clone'), 380 $noclones = $this.find('.gallery-icon').not('.gallery-icon.bx-clone'); 381 382 $clones.click(function(e) { 383 var $clickedHref = $(this).find('a').attr('href'); 384 385 $noclones.each(function() { 386 var $link = $(this).find('a'); 387 if ($link.attr('href') == $clickedHref) { 388 $link.click(); 389 } 390 }); 391 e.preventDefault(); 392 }); 393 394 // Callback Function 395 if (callback && typeof(callback) === "function") { 396 callback(); 397 } 398 } 399 }); 400 } 401 402 403 /** 404 * Regular Slider 405 * @since v1.0 406 */ 407 function regularSlider() { 408 409 $this.bxSlider({ 410 // Options 411 adaptiveHeight: adaptive, 412 mode: slideMode, 413 auto: autoPlay, 414 speed: speedDelay, 415 pause: pauseDelay, 416 pager: pagerOption, 417 touchEnabled: $touch, 418 autoHover: autoHover, 419 captions: false, 420 responsive: true, 421 preloadImages: 'visible', 422 423 onSliderLoad: function() { 424 425 // Closest info container 426 $info = $this.closest('.info'); 427 428 // Recall isotope after slides load 429 if ($this.closest('.isotopeliquid').hasClass('isotope')){ 430 $('.isotopeliquid').isotope('reLayout'); 431 $('body').matchHeight(); 432 } else if ($this.closest('.isotopecontainer').hasClass('isotope')) { 433 $('.isotopecontainer').isotope('reLayout'); 434 $('body').matchHeight(); 435 } 436 437 // Center the title vertically 438 if($info.hasClass('titlerotator')) { 439 centerTextSlide($info); 440 $(window).resize(function(){ 441 centerTextSlide($info); 442 }); 443 } 444 445 // Fade In Controls 446 $info.find('.bx-controls').animate({'opacity': 1}, 500); 447 448 // Remove min-height and loading image 449 $this 450 .animate({'opacity': 1}, 500, function() { 451 $this.closest('div.info') 452 .css({ 453 'min-height': 'none', 454 'background': 'none' 455 }); 456 }); 457 458 if (callback && typeof(callback) === "function") { 459 callback(); 460 } 461 } 462 }); 463 464 } 465 466 467 /** 468 * Centers the slide text vertically 469 * @param {selector} $info Selector for the slide options 470 * @return {void} 471 */ 472 function centerTextSlide($info) { 473 if ($info.hasClass('titlerotator') && $info.hasClass('noadapt')) { 474 var $maxheight = $this.closest('.pagetitle').find('.bx-viewport').height(); 475 $this.children('li').each(function(){ 476 var $originalHeight = $(this).height(); 477 $(this).css('padding-top', ($maxheight-$originalHeight)/2); 478 }); 479 } 480 } 481 482 483 /** 484 * Slider initialization 485 */ 486 if (carousel) { 487 carouselSlider(); 488 } else { 489 regularSlider(); 490 } 491 492 }); 493 } 494 } 495 496 497 /** 498 * jQuery Isotope Class 499 * @since v1.0 500 */ 501 if(jQuery().isotope) { 502 503 var themewichIsotope = { 504 505 /** 506 * Full-Width Isotope function 507 * @param {string} selector Container selector 508 * @param {Function} callback Callback function 509 * @since v1.0 510 * (c) Copyright 2013 Andre Gagnon - http://themewich.com 511 */ 512 liquidIsotope : function(selector, callback) { 513 jQuery(selector).each(function() { 514 515 var $this = jQuery(this), 516 maxColNum = $this.attr('data-value'), 517 isoBrick = jQuery('.isobrick'), 518 $body = $('body'), 519 $colnum2, 520 $colWidth; 521 522 // Remove margins 523 isoBrick.css({ 524 'margin-left': 0, 525 'margin-right': 0 526 }); 527 528 529 /** 530 * Sets column number depending on window width 531 */ 532 function setColNum() { 533 var w = $(window).width(), 534 columnNum = 1; 535 536 if (w > 1200) { 537 columnNum = 5; 538 } else if (w > 900) { 539 columnNum = 4; 540 } else if (w > 600) { 541 columnNum = 3; 542 } else if (w > 300) { 543 columnNum = 2; 544 } 545 546 return columnNum; 547 } 548 549 550 /**
551 * Gets column number and divides to get column width 552 * @return {integer} Width of column in pixels 553 */ 554 function getColWidth(){ 555 var w = $this.width(), 556 columnNum = setColNum(), 557 colWidth = Math.floor(w/columnNum); 558 559 return colWidth; 560 } 561 562 563 /** 564 * Sets dynamic size of isotope brick 565 * @var brick selector 566 */ 567 function setBrickSize($isobrick) { 568 var colWidth = getColWidth(); 569 570 // Set width of each brick 571 $this.find('.isobrick').not('.isobrick.noimages').each(function(){ 572 var $brick = $(this), 573 $brickphoto = $brick.find('.postphoto'); 574 575 if ($brick.hasClass('big')) { 576 $brickphoto.css({ 577 'width' : ((colWidth*2)-4) + 'px', 578 'min-height' : (((colWidth*2)-4) * 0.7566) + 'px' 579 }); 580 } else if ($brick.hasClass('slim')) { 581 $brickphoto.css( { 582 'width' : (colWidth-4) + 'px', 583 'min-height' : ((colWidth-4) * 0.5) + 'px' 584 }); 585 } else { 586 $brickphoto.css( { 587 'width' : (colWidth-4) + 'px', 588 'min-height' : ((colWidth-4) * 1.01063) + 'px' 589 }); 590 } 591 }); 592 593 $this.find('.isobrick.noimages').each(function(){ 594 var $brick = $(this), 595 $brickphoto = $brick.find('.postphoto'); 596 597 if ($brick.hasClass('big')) { 598 $brickphoto.css({ 599 'width' : ((colWidth*2)-4) + 'px' 600 }); 601 } else if ($brick.hasClass('slim')) { 602 $brickphoto.css( { 603 'width' : (colWidth-4) + 'px' 604 605 }); 606 } else { 607 $brickphoto.css( { 608 'width' : (colWidth-4) + 'px' 609 }); 610 } 611 }); 612 } 613 614 615 /** 616 * Runs isotope script 617 * @return {void} 618 */ 619 function callIsotope($itemContainer) { 620 var colWidth = getColWidth(); 621 if (maxColNum != '1') { 622 $itemContainer.isotope({ 623 resizable: false, // disable window resizing 624 masonry: { 625 columnWidth: colWidth 626 }, 627 itemSelector : '.isobrick', 628 layoutMode : 'masonry' 629 }, function() { 630 $('body').matchHeight(); 631 }); 632 633 // In case it fires too soon due to css3 animations 634 $itemContainer.bind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd", function(){ 635 if ($itemContainer.hasClass('isotope')) { 636 $itemContainer.isotope('reLayout'); 637 } 638 }); 639 } 640 } 641 642 643 /** 644 * Runs infinite scroll 645 * @return {void} 646 */ 647 function infiniteScroll($selector) { 648 /** 649 * Run infinite scroll 650 */ 651 $selector.infinitescroll({ 652 navSelector : '.more-posts', // selector for the paged navigation 653 nextSelector : '.more-posts a', // selector for the NEXT link (to page 2) 654 itemSelector : '.isobrick', // selector for all items you'll retrieve 655 loading: { 656 finishedMsg: '', 657 img: agAjax.get_template_directory_uri + '/images/loader-horizontal.gif', 658 msgText: '' 659 } 660 }, 661 662 // re-call Isotope as a callback 663 function( newElements ) { 664 console.log(newElements); 665 var $newElements = $(newElements); 666 667 // Fade in more posts button again 668 $('.more-posts').fadeIn(500); 669 670 /** 671 * Prepare new elements before insertion 672 * @return {void} 673 */ 674 $newElements.each(function(){ 675 var $brick = $(this), 676 $brickphoto = $brick.find('.postphoto'); 677 678 // Reset margins 679 $brick.css({ 680 'margin-left': 0, 681 'margin-right': 0 682 }); 683 684 setBrickSize($brickphoto); 685 }); 686 687 // Create slider(s) before insertion 688 $(newElements).addClass('inserted'); 689 themewichSlider.createSlider('.inserted ul.bxslider'); 690 $(newElements).removeClass('inserted'); 691 692 /** 693 * Append content to isotope container 694 * @return {void} 695 */ 696 $selector.isotope( 'insert', $newElements, function(){ 697 // Add ajaxify script again 698 if ($.fn.ajaxify) { 699 $body.ajaxify(); 700 } 701 $body.matchHeight(); 702 $body.themewichHovers(); 703 $selector.isotope('reLayout'); 704 }); 705 } 706 ); 707 708 // kill scroll binding for manual clicking of button 709 $(window).unbind('.infscr'); 710 711 $('.more-posts a').click(function(){ 712 $(document).trigger('retrieve.infscr'); 713 $selector.infinitescroll('retrieve'); 714 return false; 715 }); 716 717 $(document).ajaxError(function(e,xhr,opt){ 718 if(xhr.status==404) { 719 $('.more-posts a').remove(); 720 } 721 }); 722 723 724 if (callback && typeof(callback) === "function") { 725 callback(); 726 } 727 } 728 729 730 /** 731 * Filters items when clicked 732 * @return {void} 733 */ 734 function filterSelector($isocontainer) { 735 $('#filters a, a.filtersort').click(function(e){ 736 e.preventDefault(); 737 $('#filters a').removeClass("active"); 738 739 var $selector = $(this).attr('data-filter'); 740 741 $('#filters a').each(function() { 742 var $filterselect = $(this).attr('data-filter'); 743 if ($filterselect == $selector){ 744 $(this).addClass("active"); 745 } 746 }); 747 748 $isocontainer.isotope({ filter: $selector }); 749 750 }); 751 } 752 753 754 /** 755 * Runs isotope script 756 * @return {void} 757 */ 758 function callMasonry($brick) { 759 // Set brick size 760 setBrickSize($brick); 761 // Run isotope 762 callIsotope($this); 763 } 764 765 766 /** 767 * Call scripts on load 768 */ 769 callMasonry($this.find('.isobrick')); 770 infiniteScroll($this); 771 filterSelector($this); 772 773 774 /** 775 * Call masonry on resize 776 */ 777 $(window).resize(function(){ 778 callMasonry(); 779 }); 780 781 }); 782 }, 783 784 785 /** 786 * Regular fixed-column isotope 787 * @param {string} selector Container selector 788 * @param {Function} callback Callback function 789 * @since v1.0 790 * (c) Copyright 2013 Andre Gagnon - http://themewich.com 791 */ 792 loadIsotope : function(selector, callback) { 793 794 jQuery(selector).each(function() { 795 796 var $this = $(this), 797 columnNumber = $this.attr('data-value'), 798 isoBrick = $('.isobrick'), 799 $body = $('body'), 800 $colnum2; 801 802 // Remove margins 803 isoBrick.css({ 804 'margin-left': 0, 805 'margin-right': 0 806 }); 807 808 809 /** 810 * Get column number 811 */ 812 function findColNum() { 813 // Get column number 814 if ($this.width() < 500 ) { 815 $colnum2 = 2; 816 } else { 817 $colnum2 = columnNumber; 818 } 819 } 820 821 822 /** 823 * Sets dynamic size of isotope brick 824 * @var brick selector 825 */ 826 function setBrickSize($isobrick) { 827 828 var columnWidth = $this.width() / $colnum2 829 830 // Set width of each brick 831 $isobrick.not('.isobrick.noimages').each(function(){ 832 var $brick = $(this), 833 $brickphoto = $brick.find('.postphoto'); 834 835 if ($brick.hasClass('big')) { 836 $brickphoto.css({ 837 'min-height' : (((columnWidth*2)-4) * 0.7566) + 'px' 838 }); 839 } else if ($brick.hasClass('slim')) { 840 $brickphoto.css( { 841 'min-height' : ((columnWidth-4) * 0.5) + 'px' 842 }); 843 } else { 844 $brickphoto.css( { 845 'min-height' : ((columnWidth-4) * 1.01063) + 'px' 846 }); 847 } 848 849 }); 850 } 851 852 853 /** 854 * Run isotope plugin 855 */ 856 function callIsotope() { 857 // Call isotope with selected columns 858 if (columnNumber != '1') { 859 $this.isotope({ 860 masonry: { 861 columnWidth: $this.width() / $colnum2 862 }, 863 itemSelector : '.isobrick', 864 layoutMode : 'masonry' 865 }, function() { 866 $('body').matchHeight(); 867 }); 868 } 869 } 870 871 872 /** 873 * Runs infinite scroll 874 * @return {void} 875 */ 876 function infiniteScroll($selector) { 877 /** 878 * Run infinite scroll 879 */ 880 $selector.infinitescroll({ 881 navSelector : '.more-posts', // selector for the paged navigation 882 nextSelector : '.more-posts a', // selector for the NEXT link (to page 2) 883 itemSelector : '.isobrick', // selector for all items
883you'll retrieve 884 loading: { 885 finishedMsg: '', 886 img: agAjax.get_template_directory_uri + '/images/loader-horizontal.gif', 887 msgText: '' 888 } 889 }, 890 891 // re-call Isotope as a callback 892 function( newElements ) { 893 894 var $newElements = $(newElements); 895 896 // Fade in more posts button again 897 $('.more-posts').fadeIn(500); 898 899 /** 900 * Prepare new elements before insertion 901 * @return {void} 902 */ 903 $newElements.each(function(){ 904 var $brick = $(this), 905 $brickphoto = $brick.find('.postphoto'); 906 907 // Reset margins 908 $brick.css({ 909 'margin-left': 0, 910 'margin-right': 0 911 }); 912 913 setBrickSize($brickphoto); 914 }); 915 916 // Create slider(s) before insertion 917 $(newElements).addClass('inserted'); 918 themewichSlider.createSlider('.inserted ul.bxslider'); 919 $(newElements).removeClass('inserted'); 920 921 /** 922 * Append content to isotope container 923 * @return {void} 924 */ 925 $selector.isotope( 'insert', $newElements, function(){ 926 // Add ajaxify script to new items 927 if ($.fn.ajaxify) { 928 $body.ajaxify(); 929 } 930 $body.matchHeight(); 931 $body.themewichHovers(); 932 $selector.isotope('reLayout'); 933 }); 934 } 935 ); 936 937 // kill scroll binding for manual clicking of button 938 $(window).unbind('.infscr'); 939 940 $('.more-posts a').click(function(){ 941 $(document).trigger('retrieve.infscr'); 942 $selector.infinitescroll('retrieve'); 943 return false; 944 }); 945 946 $(document).ajaxError(function(e,xhr,opt){ 947 if(xhr.status==404) { 948 $('.more-posts a').remove(); 949 } 950 }); 951 952 953 if (callback && typeof(callback) === "function") { 954 callback(); 955 } 956 } 957 958 959 /** 960 * Call isotope functions in correct order 961 */ 962 function runIsotope() { 963 964 // Call Functions 965 findColNum(); 966 setBrickSize($this.find('.isobrick')); 967 callIsotope(); 968 969 // In case it fires too soon due to css3 animations 970 $this.bind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd", function(){ 971 if ($this.hasClass('isotope')) { 972 $this.isotope('reLayout'); 973 } 974 }); 975 } 976 977 978 /** 979 * Run Isotope on load 980 */ 981 runIsotope(); 982 infiniteScroll($this); 983 984 /** 985 * Run Isotope on Resize Event 986 */ 987 $(window).resize(function () { 988 runIsotope(); 989 }); 990 991 992 /** 993 * Filter link when clicked 994 * @return false 995 */ 996 $('#filters a, a.filtersort').click(function(){ 997 $('#filters a').removeClass("active"); 998 999 var $selector = $(this).attr('data-filter'); 1000 1001 $('#filters a').each(function() { 1002 var $filterselect = $(this).attr('data-filter'); 1003 if ($filterselect == $selector){ 1004 $(this).addClass("active"); 1005 } 1006 }); 1007 1008 $this.isotope({ filter: $selector }); 1009 return false; 1010 }); 1011 1012 // Callback 1013 if (callback && typeof(callback) === "function") { 1014 callback(); 1015 } 1016 1017 }); // End Each 1018 1019 } 1020 } 1021 } 1022 1023 1024 /** 1025 * Mobile Nav Helper 1026 * Nav works without this function, this just helps user experience 1027 * @since v1.0 1028 * (c) Copyright 2013 Andre Gagnon - http://themewich.com 1029 */ 1030 $.fn.mobileNav = function() { 1031 1032 var $linkslist = $('div.mobilenavigation:first #mobilenav a'); 1033 1034 function hideMenu() { 1035 $('html, body').stop().animate({scrollTop: 0}, 500, 'easeOutCubic'); 1036 $linkslist.removeClass('display'); 1037 } 1038 1039 function showMenu(selector) { 1040 var $this = $(selector); 1041 1042 var offset = $this.offset().top; 1043 $('html, body').stop().animate({scrollTop:offset}, 500, 'easeOutCubic'); 1044 1045 $linkslist.addClass('display'); 1046 } 1047 1048 1049 $(".scroll").click(function(event){ 1050 showMenu('.mobilenavcontainer'); 1051 event.preventDefault(); 1052 }); 1053 $(".menutop").click(function(event){ 1054 hideMenu(); 1055 event.preventDefault(); 1056 }); 1057 $("#mobilenav .menu-item a").click(function(event){ 1058 hideMenu(); 1059 }); 1060 1061 } 1062 1063 /** 1064 * Scroll to top function 1065 * @param {string} selector Top selector 1066 * @since v1.0 1067 * (c) Copyright 2013 Andre Gagnon - http://themewich.com 1068 */ 1069 $.fn.scrollToTop = function() { 1070 1071 var selector = this, 1072 scroll_pos_test = 50; 1073 1074 $(window).scroll(function () { 1075 1076 var y_scroll_pos = window.pageYOffset, 1077 windowWidth = $(window).width(); 1078 1079 if(y_scroll_pos > scroll_pos_test && windowWidth >= 1130) { 1080 $(selector).fadeIn(500); 1081 $('.iphone').children(selector).css('display', 'none !important'); 1082 } else { 1083 $(selector).fadeOut(500); 1084 } 1085 1086 }); 1087 1088 $(selector).click(function(e){ 1089 $('html, body').animate({scrollTop:0}, 500, 'easeOutCubic'); 1090 e.preventDefault(); 1091 return false;
1092 }); 1093 1094 } 1095 1096 /** 1097 * Hover Helper 1098 * @param {string} selector Top selector 1099 * @since v1.0 1100 * (c) Copyright 2013 Andre Gagnon - http://themewich.com 1101 */ 1102 $.fn.themewichHoverHelper = function() { 1103 var $this = $(this), 1104 $hoverHelper = $('p.hoverhelper').css('opacity', 0).empty(); 1105 1106 $this.each(function(){ 1107 $(this).hover( function() { 1108 var $hovertext = $(this).text(); 1109 $hoverHelper.stop().animate({opacity : 0}, 500, 'easeOutCubic', function() { 1110 $hoverHelper.empty().text($hovertext).stop().animate({opacity : 1}, 500, 'easeOutCubic'); 1111 }); 1112 1113 }, function() { 1114 $hoverHelper.stop().animate({opacity : 0}, 500, 'easeOutCubic'); 1115 }); 1116 }); 1117 } 1118 1119 /** 1120 * Video Wrap Helper 1121 * @since v1.0 1122 * (c) Copyright 2013 Andre Gagnon - http://themewich.com 1123 */ 1124 $.fn.addVideoWrap = function() { 1125 $('.fluid-width-video-wrapper').wrap('<div class="fixed">'); 1126 } 1127 1128 /** 1129 * Height Helper 1130 * @param {string} selector element selector 1131 * @since v1.0 1132 * (c) Copyright 2013 Andre Gagnon - http://themewich.com 1133 */ 1134 $.fn.heightHelper = function() { 1135 var h = ''; 1136 $(this).each(function(){ 1137 var $this = $(this), 1138 w = $(this).width(); 1139 if ($this.closest('.isobrick').hasClass('big')) { 1140 h = w * 0.7566; 1141 } else if ($this.hasClass('slim')) { 1142 h = w * 0.5; 1143 } else { 1144 h = w * 1.01063; 1145 } 1146 $this.css({'min-height' : h+'px'}).attr('data-height', h); 1147 }); 1148 } 1149 1150 1151 /** 1152 * Initialize all scripts here 1153 * 1154 * Comment out script lines to remove functionality 1155 */ 1156 $.fn.themewichScripts = function(){ 1157 1158 // Run theme plugins 1159 if ($.fn.magnificPopup) { 1160 $('body').themewichLightbox(); 1161 } 1162 if ($.fn.fitVids) { 1163 $('body').fitVids(); 1164 } 1165 if ($.fn.superfish) { 1166 $('ul.sf-menu').superfish({ cssArrows: true }); 1167 } 1168 if ($.fn.validate) { 1169 $("#contactform").validate(); 1170 $("#quickform").validate(); 1171 $("#commentsubmit").validate(); 1172 } 1173 if ($.fn.themewichTabs) { 1174 $('ul.tabs').themewichTabs(); 1175 } 1176 if ($.fn.bxSlider && $('ul.bxslider').length) { 1177 themewichSlider.createSlider('ul.bxslider'); 1178 } 1179 if ($.fn.isotope) { 1180 if ($('.isotopecontainer').length) { 1181 themewichIsotope.loadIsotope('.isotopecontainer'); 1182 } 1183 if ($('.isotopeliquid').length) { 1184 themewichIsotope.liquidIsotope('.isotopeliquid'); 1185 } 1186 } 1187 1188 // Run the theme-specific functions 1189 $('img.parallaximg').parallaxImg(); 1190 $('.top-nav').themewichStickyNav(); 1191 $('body').addVideoWrap(); 1192 $('body').mobileNav(); 1193 $('.top').scrollToTop(); 1194 $('body').themewichHovers(); 1195 $('.controls a').themewichHoverHelper(); 1196 } 1197 1198 $(document).ready(function() { 1199 $('body').themewichScripts(); 1200 }); 1201 1202})(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.