1/** 2 * SmartMag JS functions & 3rd party libraries 3 */ 4 5var Bunyad_Theme = (function($) { 6 "use strict"; 7 8 var hasTouch = false, 9 responsive_menu = false; 10 11 // module 12 return { 13 14 init: function() 15 { 16 17 // posts grid 18 var grid = $('.posts-grid').data('grid-count'); 19 if (parseInt(grid) > 0) { 20 $('.posts-grid .column:nth-child(' + grid + 'n)').addClass('last'); 21 } 22 23 // fit videos to container 24 $('.featured-vid, .post-content').fitVids(); 25 26 // ratings 27 $('.rate-number').each(function() { 28 var raw = $(this).find('span:not(.progress)').html(), 29 progress = parseFloat(raw); 30 31 $(this).find('.progress').css('width', (raw.search('%') === -1 ? (Math.round(progress / 10 * 100)) + '%' : progress)) ; 32 }); 33 34 // social icons widget 35 $('.lower-foot .social-icons a, .share-links a').tooltip({placement: 'top'}); 36 $('.social-icons a').tooltip({placement: 'bottom'}); 37 38 // news focus block 39 $('.news-focus .subcats a').click(function() { 40 41 if ($(this).hasClass('active')) { 42 return false; 43 } 44 45 var active = $(this).parents('.subcats').find('a.active'), 46 parent = $(this).parents('.news-focus'); 47 48 // show the news and hide the other block 49 parent.find('.news-' + active.data('id')).hide(); 50 parent.find('.news-' + $(this).data('id')).fadeIn('slow'); 51 52 $(this).addClass('active'); 53 active.removeClass('active'); 54 55 return false; 56 }); 57 58 $('.modal').on('shown.bs.modal', function() { 59 $(this).css({ 60 'margin-top': function () { 61 return -($(this).height() / 2); 62 } 63 }); 64 }); 65 66 // login 67 $(document).on('click', '.user-login', function() { 68 69 $('.login-modal .modal-content').hide(); 70 $('.login-modal .main-screen').show(); 71 72 $('#login-modal').modal('show'); 73 74 return false; 75 }); 76 77 var change_modal = function(name) { 78 79 if (!$('.login-modal').is(':visible')) { 80 $('#login-modal').modal('show'); 81 } 82 83 $('.login-modal .modal-content').hide(); 84 $('.login-modal ' + name).show(); 85 86 return false; 87 88 }; 89 90 $('a.register-modal').click(function() { 91 return change_modal('.register-now'); 92 }); 93 94 $('a.lost-pass-modal').click(function() { 95 return change_modal('.lost-pass'); 96 }); 97 98 // setup all sliders 99 this.sliders(); 100 101 // handle shortcodes 102 this.shortcodes(); 103 104 // setup mobile navigation 105 this.responsive_nav(); 106 this.touch_nav(); 107 108 // start the news ticker 109 this.news_ticker(); 110 111 // setup the lightbox 112 this.lightbox(); 113 114 // use sticky navigation if enabled 115 this.sticky_nav(); 116 117 // use sticky sidebar if enabled 118 this.sticky_sidebar(); 119 120 // user ratings 121 this.user_ratings(); 122 123 // infinite scroll if enabled 124 this.infinite_scroll(); 125 126 /** 127 * Image scroll animations 128 */ 129 $('.main img, .main-footer img').addClass('no-display'); 130 131 $('.main img, .main-footer img, .main-featured .row').one('inview', function() { 132 $(this).addClass('appear'); 133 }); 134 135 $('.review-box ul li .bar').each(function() { 136 $(this).data('width', $(this)[0].style.width).css('width', 0); 137 }); 138 139 $('.review-box ul li').one('inview', function() { 140 var bar = $(this).find('.bar'); 141 bar.addClass('appear').css('width', bar.data('width')); 142 }); 143 144 145 /** 146 * IE fixes 147 */ 148 if ($.browser.msie && 8 == parseInt($.browser.version)) { 149 150 $('.main img, .main-footer img').addClass('no-display'); 151 $('.main img, .main-footer img, .main-featured .row').unbind('inview'); 152 153 // fontawesome4 fails to draw sometimes on IE8 154 $(function() { 155 var $ss = $('#smartmag-font-awesome-css'); 156 $ss[0].href = $ss[0].href; 157 }); 158 159 // flickr widget fix - ie8 only 160 $('.flickr-widget .flickr_badge_image:nth-of-type(4n)').css('margin-right', 0); 161 162 // background image fix for IE8 163 var bg = $('body').css('background-attachment'), 164 bg_url = $('body').css('background-image').replace(/^url\((['"]?)(.*)\1\)$/, '$2'); 165 166 if (bg == 'fixed' && bg_url) { 167 168 $('body').append('<style type="text/css">.bg-overlay { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + bg_url + '\', sizingMethod=\'scale\'); \ 169 -ms-filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + bg_url + '\', sizingMethod=\'scale\')"; }</style>'); 170 171 $('<div class="bg-overlay"></div>').appendTo('body'); 172 } 173 174 // more lackluster ie8 175 $('.listing > .column:nth-child(odd)').css('clear', 'both'); 176 } 177 178 // add support for placeholder in IE8/IE9 179 $('input, textarea').placeholder(); 180 181 /** 182 * Mobile devices "background-attachment: fixed" support 183 */ 184 if ($(window).width() < 1128) { 185 186 var bg = $('body').css('background-attachment'), 187 bg_image = $('body').css('background-image'); 188 189 if (bg == 'fixed' && bg_image) { 190 $('body').css('background-image', 'none').append( 191 $('<div class="background-cover">' + '</div>').css('background-image', bg_image) 192 ); 193 } 194 } 195 196 /** 197 * Woocommerce 198 */ 199 $('.woocommerce-ordering .drop li a').click(function(e) { 200 var form = $(this).closest('form'); 201 202 form.find('[name=orderby]').val($(this).parent().data('value')); 203 form.submit(); 204 205 e.preventDefault(); 206 }); 207 208 $('body').on('added_to_cart', function() { 209 $('.menu .widget_shopping_cart').css('opacity', ''); 210 }); 211 212 if ($('.menu .cart_list .empty').length) { 213 $('.menu .cart_list').remove(); 214 } 215 216 // safari 5.x fix 217 if (!!navigator.userAgent.match('Safari/') && !!navigator.userAgent.match('Version/5.')) { 218 $('.navigation .menu ul, .navigation .mega-menu').css('-webkit-transition', 'none'); 219 } 220 221 // add android class 222 if (navigator.userAgent.match(/android/i)) { 223 $('body').addClass('android'); 224 } 225 226 }, 227 228 news_ticker: function() 229 { 230 $('.trending-ticker ul').each(function() { 231 232 if (!$(this).find('li.active').length) { 233 $(this).find('li:first').addClass('active'); 234 } 235 236 var ticker = $(this); 237 238 window.setInterval(function() { 239 240 var active = ticker.find('li.active'); 241 active.fadeOut(function() { 242 243 var next = active.next(); 244 if (!next.length) { 245 next = ticker.find('li:first'); 246 } 247 248 next.addClass('active').fadeIn(); 249 active.removeClass('active'); 250 }); 251 252 253 254 }, 8000); 255 }); 256 }, 257 258 responsive_nav: function() 259 { 260 // detect touch capability dynamically 261 $(window).on('touchstart', function() { 262 hasTouch = true; 263 $('body').addClass('touch'); 264 }); 265 266 this.init_responsive_nav(); 267 var that = this; 268 269 $(window).on('resize orientationchange', function() { 270 that.init_responsive_nav(); 271 }); 272 }, 273 274 /** 275 * Setup the responsive nav events and markup 276 */ 277 init_responsive_nav: function() { 278 279 if ($(window).width() > 799 || responsive_menu) { 280 return; 281 } 282 283 // set responsive initialized 284 responsive_menu = true; 285 286 // clone navigation for mobile 287 var clone = $('.navigation > div[class$="-container"]').clone().addClass('mobile-menu-container'), 288 mobile_search = false, 289 off_canvas = ($('.navigation .mobile').data('type') == 'off-canvas'); 290 291 // off-canvas setup? 292 if (off_canvas) { 293 clone.addClass('off-canvas');
294 clone.find('.menu').prepend($('<li class="close"><a href="#"><span>' + $('.navigation .selected .text').text() + '</span> <i class="fa fa-times"></i></a></li>')); 295 $('body').addClass('nav-off-canvas'); 296 } 297 298 clone.find('.menu').addClass('mobile-menu'); 299 clone.appendTo('.navigation'); 300 301 302 // mobile search? 303 if ($('.navigation .mobile').data('search')) { 304 mobile_search = true; 305 } 306 307 // register click handlers for mobile menu 308 $('.navigation .mobile .selected').click(function(e) { 309 310 // search active? 311 if ($(e.target).hasClass('hamburger') || !mobile_search || !$(this).find('.search .query').is(':visible')) { 312 313 if (off_canvas) { 314 $('.navigation .mobile-menu').addClass('active'); 315 $('body').toggleClass('off-canvas-active'); 316 } 317 else { 318 $('.navigation .mobile-menu').toggleClass('active'); 319 } 320 321 return false; 322 } 323 }); 324 325 // off-canvas close 326 $('.off-canvas .close').click(function() { 327 $('body').toggleClass('off-canvas-active'); 328 }); 329 330 331 // add mobile search 332 if (mobile_search && $('.top-bar .search').length) { 333 334 $('.navigation .mobile .selected').append($('.top-bar .search')[0].outerHTML); 335 $('.mobile .search .search-button').click(function() { 336 337 if (!$('.mobile .search .query').is(':visible')) { 338 $('.navigation .mobile .selected .current, .navigation .mobile .selected .text').toggle(); 339 $('.mobile .search').toggleClass('active'); 340 341 return false; 342 } 343 }); 344 } 345 346 // setup mobile menu click handlers 347 $('.navigation .mobile-menu li > a').each(function() { 348 349 if ($(this).parent().children('ul').length) { 350 $('<a href="#" class="chevron"><i class="fa fa-angle-down"></i></a>').appendTo($(this)); 351 } 352 }); 353 354 $('.navigation .mobile-menu li .chevron').click(function() { 355 $(this).closest('li').find('ul').first().toggle().parent().toggleClass('active item-active'); 356 return false; 357 }); 358 359 // add active item 360 var last = $('.mobile-menu .current-menu-item').last().find('> a'); 361 if (last.length) { 362 363 var selected = $('.navigation .mobile .selected'), 364 current = selected.find('.current'), 365 cur_text = selected.find('.text').text(); 366 367 if (cur_text.slice(-1) !== ':') { 368 selected.find('.text').text(cur_text + ':'); 369 } 370 371 current.text(last.text()); 372 } 373 }, 374 375 touch_nav: function() { 376 377 var targets = $('.menu:not(.mobile-menu) a'), 378 open_class = 'item-active', 379 child_tag = 'ul, .mega-menu'; 380 381 targets.each(function() { 382 383 var $this = $(this), 384 $parent = $this.parent('li'), 385 $siblings = $parent.siblings().find('a'); 386 387 $this.click(function(e) { 388 389 if (!hasTouch) { 390 return; 391 } 392 393 var $this = $(this); 394 e.stopPropagation(); 395 396 $siblings.parent('li').removeClass(open_class); 397 398 // has a child? open the menu on tap 399 if (!$this.parent().hasClass(open_class) && $this.next(child_tag).length > 0 && !$this.parents('.mega-menu.links').length) { 400 e.preventDefault(); 401 $this.parent().addClass(open_class); 402 } 403 }); 404 }); 405 406 // close all menus 407 $(document).click(function(e) { 408 if (!$(e.target).is('.menu') && !$(e.target).parents('.menu').length) { 409 targets.parent('li').removeClass(open_class); 410 } 411 }); 412 }, 413 414 sticky_nav: function() 415 { 416 var nav = $('.navigation'), 417 nav_top = nav.offset().top; 418 419 // not enabled? 420 if (!nav.data('sticky-nav')) { 421 return; 422 } 423 424 if (nav.find('.sticky-logo').length) { 425 nav.addClass('has-logo'); 426 } 427 428 var sticky = function() { 429 430 if (!nav.data('sticky-nav') || $(window).width() < 800) { 431 return; 432 } 433 434 // make it sticky when viewport is scrolled beyond the navigation 435 if ($(window).scrollTop() > nav_top) { 436 437 if (!nav.hasClass('sticky')) { 438 nav.addClass('sticky no-transition'); 439 440 setTimeout(function() { 441 nav.removeClass('no-transition'); 442 }, 100); 443 } 444 445 } else { 446 nav.removeClass('sticky'); 447 } 448 }; 449 450 sticky(); 451 452 $(window).scroll(function() { 453 sticky(); 454 }); 455 456 }, 457 458 /** 459 * Setup sticky sidebar 460 */ 461 sticky_sidebar: function() 462 { 463 var sticky = $('.sidebar').data('sticky'); 464 if (!sticky) { 465 return; 466 } 467 468 $('.main .sidebar').theiaStickySidebar({minWidth: 800, updateSidebarHeight: false}); 469 }, 470 471 /** 472 * Setup all the sliders available 473 */ 474 sliders: function() 475 { 476 if (!$.fn.flexslider) { 477 return; 478 } 479 480 var is_rtl = ($('html').attr('dir') == 'rtl' ? true : false); 481
482 // main slider 483 var slider = $('.main-featured .slider'); 484 485 $('.main-featured .flexslider').flexslider({ 486 controlNav: true, 487 animationSpeed: slider.data('animation-speed'), 488 animation: slider.data('animation'), 489 slideshowSpeed: slider.data('slide-delay'), 490 manualControls: '.main-featured .flexslider .pages a', 491 pauseOnHover: true, 492 start: function() { 493 $('.main-featured .slider').css('opacity', 1); 494 }, 495 rtl: is_rtl 496 }); 497 498 // main slider dynamic pagination - if not at default of 5 499 var pages = $('.main-featured .pages'), 500 number = parseInt(pages.data('number')); 501 502 if (number && number != 5) { 503 var width = (100 - ((number + 1) * 0.284900285)) / number; // 100 - (slides + 1 * margin-left) / slides 504 pages.find('a').css('width', width + '%'); 505 } 506 507 508 // carousels / galleries 509 $('.carousel').flexslider({ 510 animation: 'slide', 511 animationLoop: false, 512 itemWidth: 214, 513 itemMargin: 30, 514 minItems: 3, 515 maxItems: 4, 516 controlNav: false, 517 slideshow: false, 518 rtl: is_rtl 519 520 }); 521 522 $('.gallery-block .flexslider').flexslider({ 523 controlNav: false, 524 pauseOnHover: true, 525 rtl: is_rtl 526 }); 527 528 // for post-galleries 529 $('.gallery-slider .flexslider').flexslider({ 530 controlNav: false, 531 pauseOnHover: true, 532 rtl: is_rtl 533 }); 534 535 // post galleries in post cover 536 $('.post-cover .gallery-slider li, .post-cover .featured').each(function() { 537 var img = $(this).find('img'); 538 $(this).css('background-image', 'url("' + img.attr('src') + '")'); 539 img.addClass('hidden'); 540 }); 541 542 /** 543 * Post Content Slideshow: AJAX 544 */ 545 var slideshow_cache = {}, 546 slideshow_wrap = '.post-slideshow .post-pagination-next'; 547 548 if ($(slideshow_wrap).length && $(slideshow_wrap).data('type') == 'ajax') { 549 550 var processing; 551 552 $('.main-content').on('click', '.post-slideshow .post-pagination-next .links a', function() { 553 554 // showing on home-page? 555 if ($('body').hasClass('page')) { 556 return; 557 } 558 559 // abort existing request 560 if (processing && processing.hasOwnProperty('abort')) { 561 processing.abort(); 562 } 563 564 var parent = $(this).closest('.post-slideshow'), 565 url = $(this).attr('href'); 566 567 parent.find('.content-page').removeClass('active').addClass('hidden previous'); 568 569 var show_slide = function(data) { 570 571 // change browser url 572 if (history.pushState) { 573 history.pushState({}, '', url); 574 } 575 576 var page = $(data).find('.post-slideshow'); 577 578 if (page.length) { 579 parent.find('.post-pagination-next').html(page.find('.post-pagination-next').html()); 580 parent.find('.content-page').after(page.find('.content-page').addClass('hidden loading')); 581 582 setTimeout(function() { 583 parent.find('.content-page.previous').remove(); 584 parent.find('.content-page.loading').removeClass('previous hidden loading'); 585 }, 1); 586 } 587 588 processing = null; 589 590 }; 591 592 // in cache? 593 if (slideshow_cache[url]) { 594 show_slide(slideshow_cache[url]); 595 } 596 else { 597 598 // get via ajax 599 processing = $.get(url, function(data) { 600 slideshow_cache[url] = data; 601 show_slide(data); 602 603 }); 604 } 605 606 return false; 607 }); 608 609 // keyboard nav 610 $(document).on('keyup', function(e) { 611 if (e.which == 37) { 612 $(slideshow_wrap).find('.prev').parent().click(); 613 } 614 else if (e.which == 39) { 615 $(slideshow_wrap).find('.next').parent().click(); 616 } 617 }); 618 619 } // end slideshow wrap 620 621 }, 622 623 /** 624 * Register shortcode related events 625 */ 626 shortcodes: function() 627 { 628 // normal tabs 629 $('.tabs-list a').click(function() { 630 631 var tab = $(this).data('tab'), 632 tabs_data = $(this).closest('.tabs-list').siblings('.tabs-data'), 633 parent = $(this).parent().parent(), 634 active = parent.find('.active'); 635 636 if (!active.length) { 637 active = parent.find('li:first-child'); 638 } 639 640 active.removeClass('active').addClass('inactive'); 641 $(this).parent().addClass('active').removeClass('inactive'); 642 643 // hide current and show the clicked one 644 var active_data = tabs_data.find('.tab-posts.active'); 645 if (!active_data.length) { 646 active_data = tabs_data.find('.tab-posts:first-child'); 647 } 648 649 active_data.hide(); 650 651 tabs_data.find('#recent-tab-' + tab).fadeIn().addClass('active').removeClass('inactive'); 652 653 return false;
654 655 }); 656 657 /** 658 * Shortcode: Tabs 659 */ 660 $('.sc-tabs a').click(function() { 661 662 // tabs first 663 var tabs = $(this).parents('ul'); 664 tabs.find('.active').removeClass('active'); 665 $(this).parent().addClass('active'); 666 667 // panes second 668 var panes = tabs.siblings('.sc-tabs-panes'); 669 670 panes.find('.active').hide().removeClass('active'); 671 panes.find('#sc-pane-' + $(this).data('id')).addClass('active').fadeIn(); 672 673 return false; 674 }); 675 676 /** 677 * Shortcode: Accordions & Toggles 678 */ 679 $('.sc-accordion-title > a').click(function() { 680 681 var container = $(this).parents('.sc-accordions'); 682 container.find('.sc-accordion-title').removeClass('active'); 683 container.find('.sc-accordion-pane').slideUp().removeClass('active'); 684 685 var pane = $(this).parent().next(); 686 if (!pane.is(':visible')) { 687 $(this).parent().addClass('active'); 688 pane.slideDown().addClass('active'); 689 } 690 691 return false; 692 }); 693 694 $('.sc-toggle-title > a').click(function() { 695 $(this).parent().toggleClass('active'); 696 $(this).parent().next().slideToggle().toggleClass('active'); 697 698 return false; 699 }); 700 701 }, 702 703 /** 704 * User Ratings handling 705 */ 706 user_ratings: function() 707 { 708 709 var compute_percent = function(e) { 710 711 712 var offset = $(this).offset(), 713 position, percent; 714 715 // count from right for RTL 716 if ($('html').attr('dir') == 'rtl') { 717 offset.left = offset.left + $(this).outerWidth(); 718 } 719 720 position = Math.abs(e.pageX - Math.max(0, offset.left)); 721 percent = Math.min(100, Math.round(position / $(this).width() * 100)); 722 723 return percent; 724 }; 725 726 // percent or points? 727 var is_points = true, 728 scale = parseInt($('.review-box .value-title').text()) || 10; 729 730 if ($('.review-box .overall .percent').length) { 731 is_points = false; 732 } 733 734 // update the bar and percent/points on hover 735 $('.user-ratings .main-stars, .user-ratings .rating-bar').on('mousemove mouseenter mouseleave', 736 function(e) { 737 738 // set main variables 739 var bar = $(this).find('span'), 740 user_ratings = $(this).closest('.user-ratings'); 741 742 bar.css('transition', 'none'); 743 744 if (user_ratings.hasClass('voted')) { 745 return; 746 } 747 748 // hover over? 749 if (e.type == 'mouseleave') { 750 bar.css('width', bar.data('orig-width')); 751 user_ratings.find('.hover-number').hide(); 752 user_ratings.find('.rating').show(); 753 return; 754 } 755 756 var percent = compute_percent.call(this, e); 757 758 if (!bar.data('orig-width')) { 759 bar.data('orig-width', bar[0].style.width); 760 } 761 762 bar.css('width', percent + '%'); 763 user_ratings.find('.rating').hide(); 764 user_ratings.find('.hover-number').show().text((is_points ? +parseFloat(percent / 100 * scale).toFixed(1) : percent + '%')); 765 } 766 ); 767 768 // add the rating 769 $('.user-ratings .main-stars, .user-ratings .rating-bar').on('click', function(e) { 770 771 // set main variables 772 var bar = $(this).find('span'), 773 user_ratings = $(this).closest('.user-ratings'); 774 775 if (user_ratings.hasClass('voted')) { 776 return; 777 } 778 779 // setup ajax post data 780 var post_data = { 781 'action': 'bunyad_rate', 782 'id': user_ratings.data('post-id'), 783 'rating': compute_percent.call(this, e) 784 }; 785 786 // get current votes 787 var votes = user_ratings.find('.number'), 788 cur_votes = parseInt(votes.text()) || 0; 789 790 user_ratings.css('opacity', '0.3'); 791 bar.data('orig-width', bar[0].style.width); 792 793 // add to votes and disable further voting 794 votes.text((cur_votes + 1).toString()); 795 796 $(this).trigger('mouseleave'); 797 user_ratings.addClass('voted'); 798 799 $.post(Bunyad.ajaxurl, post_data, function(data) { 800 801 // update data 802 if (data === Object(data)) { 803 804 // change rating 805 var cur_rating = user_ratings.find('.rating').text(); 806 user_ratings.find('.rating').text( cur_rating.search('%') !== -1 ? data.percent + ' %' : data.decimal ); 807 808 bar.css('width', data.percent + '%'); 809 bar.data('orig-width', data.percent); 810 } 811 812 user_ratings.hide().css('opacity', 1).fadeIn('slow'); 813 }, 'json'); 814 }); 815 }, 816 817 /** 818 * Infinite Scroll 819 */ 820 infinite_scroll: function() 821 { 822 // require jquery plugin 823 if (!$.fn.infinitescroll) { 824 return; 825 } 826 827 $('.listing-classic, .listing, .listing-alt, .list-timeline').filter(function() { if ($(this).data('infinite')) { return true; } }).each(function() { 828 var that = this, 829 data_sel = '[data-infinite="' + $(this).data('infinite') + '"]', 830 timeline = false, 831 instance, 832 opts; 833 834 // infinitescroll options 835 var options = { 836 loading: { 837 finishedMsg: '',
838 msg: $('<div class="ajax-loading"><div class="spinner"><span></span><span></span><span></span></div>') 839 }, 840 navSelector: '.main-pagination', 841 nextSelector: '.main-pagination .next', 842 itemSelector: data_sel + ' > .column,' + data_sel + ' > .post,' + data_sel + ' > .post,' + data_sel + ' > .month' 843 }; 844 845 // is timeline listing? 846 if ($(this).hasClass('list-timeline')) { 847 timeline = true; 848 options.appendCallback = false; 849 } 850 851 /** 852 * Main callback when data is loaded via $.infinitescroll 853 */ 854 var callback = function(data) { 855 856 // handle timeline listing 857 if (timeline == true) { 858 859 $(data).each(function() { 860 var month = $(this).data('month'), 861 existing = $(data_sel + ' .month[data-month="' + month + '"] .posts'); 862 863 // month container exists 864 if (existing.length) { 865 existing.append($(this).find('.posts article')); 866 } 867 else { 868 $(data_sel).append($(this)); 869 } 870 }); 871 } 872 873 // re-bind the inview image animations 874 $(that).find('img').addClass('no-display').one('inview', function() { 875 $(this).addClass('appear'); 876 }); 877 878 $(window).trigger('checkInView.inview'); 879 $(window).trigger('resize'); // for sticky sidebar 880 }; 881 882 // setup infinitescroll instance and set callbacks 883 instance = new $.infinitescroll(options, callback, this); 884 opts = instance.options; 885 886 // overwrite start event 887 opts.loading.start = function() { 888 889 $(opts.loading.msg).insertAfter(that).show(); 890 instance.beginAjax(opts); 891 892 // for sticky sidebar 893 $(window).trigger('resize'); 894 }; 895 896 opts.errorCallback = function() { 897 $(opts.loading.msg).hide(); 898 899 // for sticky sidebar 900 $(window).trigger('resize'); 901 }; 902 903 // hide pagination if valid infinite scroll page 904 if (!opts.state.isInvalidPage) { 905 $(this).parent().find('.main-pagination').hide(); 906 } 907 }); 908 909 }, 910 911 912 /** 913 * Setup prettyPhoto 914 */ 915 lightbox: function() { 916 917 // disabled on mobile screens 918 if (!$.fn.prettyPhoto || $(window).width() < 700) { 919 return; 920 } 921 922 var filter_images = function() { 923 924 if (!$(this).attr('href')) { 925 return false; 926 } 927 928 return $(this).attr('href').match(/\.(jpe?g|png|bmp|gif)$/); 929 }; 930 931 (function() { 932 var gal_id = 1; 933 934 $('.post-content a, .main .featured a').has('img').filter(filter_images).attr('rel', 'prettyPhoto'); 935 936 $('.gallery-slider, .post-content .gallery, .post-content .tiled-gallery').each(function() { 937 gal_id++; // increment gallery group id 938 939 $(this).find('a').has('img').filter(filter_images) 940 .attr('rel', 'prettyPhoto[gal_'+ gal_id +']'); 941 }); 942 943 $("a[rel^='prettyPhoto']").prettyPhoto({social_tools: false}); 944 945 })(); 946 947 // WooCommerce lightbox 948 $('a[data-rel^="prettyPhoto"], a.zoom').prettyPhoto({hook: 'data-rel', social_tools: false}); 949 950 } 951 }; // end return 952 953})(jQuery); 954 955// load when ready 956jQuery(function($) { 957 958 Bunyad_Theme.init(); 959 960 // requestAnimationFrame pollyfill 961 var requestAnimationFrame = ( 962 window.requestAnimationFrame 963 || window.webkitRequestAnimationFrame 964 || window.mozRequestAnimationFrame 965 || function(callback) { return setTimeout(callback, 1000 / 60); } 966 ); 967}); 968 969/** 970 * Live Search Handler 971 */ 972var Bunyad_Live_Search = (function($) { 973 "use strict"; 974 975 var cache = {}, timer, element; 976 977 return { 978 979 init: function() { 980 981 var self = this, 982 search = $('.live-search-query'); 983 984 if (!search.length) { 985 return; 986 } 987 988 // turn off browser's own auto-complete 989 $('.live-search-query').attr('autocomplete', 'off'); 990 991 // setup the live search on key press 992 $('.live-search-query').on('keyup', function() { 993 994 element = $(this).parent(); 995 996 var query = $(this).val(), result; 997 998 999 // clear existing debounce 1000 clearTimeout(timer); 1001 1002 // minimum of 1 character 1003 if (query.length < 1) { 1004 self.add_result(''); 1005 return; 1006 } 1007 1008 // debounce to prevent excessive ajax queris 1009 timer = setTimeout(function() { 1010 self.process(query); 1011 }, 250); 1012 }); 1013 1014 // setup hide 1015 $(document).on('click', function(e) { 1016 1017 var results = $('.live-search-results'); 1018 1019 if (results.is(':visible') && !$(e.target).closest('.search').length) { 1020 results.removeClass('fade-in'); 1021 } 1022 }); 1023 }, 1024 1025 /** 1026 * Process the search query 1027 */ 1028 process: function(query) { 1029 1030 var self = this; 1031 1032 // have it in cache? 1033 if (query in cache) { 1034 self.add_result(cache[query]); 1035 } 1036 else { 1037 $.get(Bunyad.ajaxurl, {action: 'bunyad_live_search', 'query': query}, function(data) { 1038 1039 // add to cache and add results 1040 cache[query] = data; 1041 self.add_result(data); 1042 }); 1043 } 1044 }, 1045 1046 /** 1047 * Add live results to the container 1048 */ 1049 add_result: function(result) { 1050 1051 if (!element.find('.live-search-results').length) { 1052 element.append($('<div class="live-search-results"></div>')); 1053 } 1054 1055 var container = element.find('.live-search-results'); 1056 1057 if (!result) { 1058 container.removeClass('fade-in'); 1059 return; 1060 } 1061 1062 // add the html result 1063 container.html(result); 1064 1065 requestAnimationFrame(function() { 1066 container.addClass('fade-in'); 1067 }); 1068 1069 } 1070 }; 1071 1072})(jQuery); 1073 1074// fire up when ready 1075jQuery(function() { 1076 Bunyad_Live_Search.init(); 1077}); 1078 1079/** 1080 * Plugins and 3rd Party Libraries 1081 */ 1082
1083/** 1084 * Author Christopher Blum 1085 * Based on the idea of Remy Sharp, http://remysharp.com/2009/01/26/element-in-view-event-plugin/ 1086 * 1087 * License: WTFPL 1088 */ 1089(function(b){function t(){var e,a={height:k.innerHeight,width:k.innerWidth};a.height||!(e=l.compatMode)&&b.support.boxModel||(e="CSS1Compat"===e?f:l.body,a={height:e.clientHeight,width:e.clientWidth});return a}function u(){var e=b(),g,q=0;b.each(m,function(a,b){var c=b.data.selector,d=b.$element;e=e.add(c?d.find(c):d)});if(g=e.length)for(d=d||t(),a=a||{top:k.pageYOffset||f.scrollTop||l.body.scrollTop,left:k.pageXOffset||f.scrollLeft||l.body.scrollLeft};q<g;q++)if(b.contains(f,e[q])){var h=b(e[q]),n=h.height(),p=h.width(),c=h.offset(),r=h.data("inview");if(!a||!d)break;c.top+n>a.top&&c.top<a.top+d.height&&c.left+p>a.left&&c.left<a.left+d.width?(p=a.left>c.left?"right":a.left+d.width<c.left+p?"left":"both",n=a.top>c.top?"bottom":a.top+d.height<c.top+n?"top":"both",c=p+"-"+n,r&&r===c||h.data("inview",c).trigger("inview",[!0,p,n])):r&&h.data("inview",!1).trigger("inview",[!1])}}var m={},d,a,l=document,k=window,f=l.documentElement,s=b.expando,g;b.event.special.inview={add:function(a){m[a.guid+"-"+this[s]]={data:a,$element:b(this)};g||b.isEmptyObject(m)||(g=setInterval(u,250))},remove:function(a){try{delete m[a.guid+"-"+this[s]]}catch(d){}b.isEmptyObject(m)&&(clearInterval(g),g=null)}};b(k).bind("scroll resize",function(){d=a=null});!f.addEventListener&&f.attachEvent&&f.attachEvent("onfocusin",function(){a=null})})(jQuery); 1090 1091/** 1092* Bootstrap.js by @fat & @mdo 1093* plugins: bootstrap-tooltip.js 1094* Copyright 2012 Twitter, Inc. 1095* http://www.apache.org/licenses/LICENSE-2.0.txt 1096*/ 1097!function(a){var b=function(a,b){this.init("tooltip",a,b)};b.prototype={constructor:b,init:function(b,c,d){var e,f;this.type=b,this.$element=a(c),this.options=this.getOptions(d),this.enabled=!0,this.options.trigger=="click"?this.$element.on("click."+this.type,this.options.selector,a.proxy(this.toggle,this)):this.options.trigger!="manual"&&(e=this.options.trigger=="hover"?"mouseenter":"focus",f=this.options.trigger=="hover"?"mouseleave":"blur",this.$element.on(e+"."+this.type,this.options.selector,a.proxy(this.enter,this)),this.$element.on(f+"."+this.type,this.options.selector,a.proxy(this.leave,this))),this.options.selector?this._options=a.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},getOptions:function(b){return b=a.extend({},a.fn[this.type].defaults,b,this.$element.data()),b.delay&&typeof b.delay=="number"&&(b.delay={show:b.delay,hide:b.delay}),b},enter:function(b){var c=a(b.currentTarget)[this.type](this._options).data(this.type);if(!c.options.delay||!c.options.delay.show)return c.show();clearTimeout(this.timeout),c.hoverState="in",this.timeout=setTimeout(function(){c.hoverState=="in"&&c.show()},c.options.delay.show)},leave:function(b){var c=a(b.currentTarget)[this.type](this._options).data(this.type);this.timeout&&clearTimeout(this.timeout);if(!c.options.delay||!c.options.delay.hide)return c.hide();c.hoverState="out",this.timeout=setTimeout(function(){c.hoverState=="out"&&c.hide()},c.options.delay.hide)},show:function(){var a,b,c,d,e,f,g;if(this.hasContent()&&this.enabled){a=this.tip(),this.setContent(),this.options.animation&&a.addClass("fade"),f=typeof this.options.placement=="function"?this.options.placement.call(this,a[0],this.$element[0]):this.options.placement,b=/in/.test(f),a.detach().css({top:0,left:0,display:"block"}).insertAfter(this.$element),c=this.getPosition(b),d=a[0].offsetWidth,e=a[0].offsetHeight;switch(b?f.split(" ")[1]:f){case"bottom":g={top:c.top+c.height,left:c.left+c.width/2-d/2};break;case"top":g={top:c.top-e,left:c.left+c.width/2-d/2};break;case"left":g={top:c.top+c.height/2-e/2,left:c.left-d};break;case"right":g={top:c.top+c.height/2-e/2,left:c.left+c.width}}a.offset(g).addClass(f).addClass("in")}},setContent:function(){var a=this.tip(),b=this.getTitle();a.find(".tooltip-inner")[this.options.html?"html":"text"](b),a.removeClass("fade in top bottom left right")},hide:function(){function d(){var b=setTimeout(function(){c.off(a.support.transition.end).detach()},500);c.one(a.support.transition.end,function(){clearTimeout(b),c.detach()})}var b=this,c=this.tip();return c.removeClass("in"),a.support.transition&&this.$tip.hasClass("fade")?d():c.detach(),this},fixTitle:function(){var a=this.$element;(a.attr("title")||typeof a.attr("data-original-title")!="string")&&a.attr("data-original-title",a.attr("title")||"").removeAttr("title")},hasContent:function(){return this.getTitle()},getPosition:function(b){return a.extend({},b?{top:0,left:0}:this.$element.offset(),{width:this.$element[0].offsetWidth,height:this.$element[0].offsetHeight})},getTitle:function(){var a,b=this.$element,c=this.options;return a=b.attr("data-original-title")||(typeof c.title=="function"?c.title.call(b[0]):c.title),a},tip:function(){return this.$tip=this.$tip||a(this.options.template)},validate:function(){this.$element[0].parentNode||(this.hide(),this.$element=null,this.options=null)},enable:function(){this.enabled=!0},disable:function(){this.enabled=!1},toggleEnabled:function(){this.enabled=!this.enabled},toggle:function(b){var c=a(b.currentTarget)[this.type](this._options).data(this.type);c[c.tip().hasClass("in")?"hide":"show"]()},destroy:function(){this.hide().$element.off("."+this.type).removeData(this.type)}};var c=a.fn.tooltip;a.fn.tooltip=function(c){return this.each(function(){var d=a(this),e=d.data("tooltip"),f=typeof c=="object"&&c;e||d.data("tooltip",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.tooltip.Constructor=b,a.fn.tooltip.defaults={animation:!0,placement:"top",selector:!1,template:'<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',trigger:"hover",title:"",delay:0,html:!1},a.fn.tooltip.noConflict=function(){return a.fn.tooltip=c,this}}(window.jQuery); 1098 1099/** 1100* Bootstrap.js by @fat & @mdo 1101* plugins: bootstrap-modal.js 1102* Copyright 2013 Twitter, Inc. 1103* http://www.apache.org/licenses/LICENSE-2.0.txt 1104*/ 1105!function(a){var b=function(b,c){this.options=c,this.$element=a(b).delegate('[data-dismiss="modal"]',"click.dismiss.modal",a.proxy(this.hide,this)),this.options.remote&&this.$element.find(".modal
1105-body").load(this.options.remote)};b.prototype={constructor:b,toggle:function(){return this[this.isShown?"hide":"show"]()},show:function(){var b=this,c=a.Event("show");this.$element.trigger(c);if(this.isShown||c.isDefaultPrevented())return;this.isShown=!0,this.escape(),this.backdrop(function(){var c=a.support.transition&&b.$element.hasClass("fade");b.$element.parent().length||b.$element.appendTo(document.body),b.$element.show(),c&&b.$element[0].offsetWidth,b.$element.addClass("in").attr("aria-hidden",!1),b.enforceFocus(),c?b.$element.one(a.support.transition.end,function(){b.$element.focus().trigger("shown")}):b.$element.focus().trigger("shown")})},hide:function(b){b&&b.preventDefault();var c=this;b=a.Event("hide"),this.$element.trigger(b);if(!this.isShown||b.isDefaultPrevented())return;this.isShown=!1,this.escape(),a(document).off("focusin.modal"),this.$element.removeClass("in").attr("aria-hidden",!0),a.support.transition&&this.$element.hasClass("fade")?this.hideWithTransition():this.hideModal()},enforceFocus:function(){var b=this;a(document).on("focusin.modal",function(a){b.$element[0]!==a.target&&!b.$element.has(a.target).length&&b.$element.focus()})},escape:function(){var a=this;this.isShown&&this.options.keyboard?this.$element.on("keyup.dismiss.modal",function(b){b.which==27&&a.hide()}):this.isShown||this.$element.off("keyup.dismiss.modal")},hideWithTransition:function(){var b=this,c=setTimeout(function(){b.$element.off(a.support.transition.end),b.hideModal()},500);this.$element.one(a.support.transition.end,function(){clearTimeout(c),b.hideModal()})},hideModal:function(){var a=this;this.$element.hide(),this.backdrop(function(){a.removeBackdrop(),a.$element.trigger("hidden")})},removeBackdrop:function(){this.$backdrop&&this.$backdrop.remove(),this.$backdrop=null},backdrop:function(b){var c=this,d=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var e=a.support.transition&&d;this.$backdrop=a('<div class="modal-backdrop '+d+'" />').appendTo(document.body),this.$backdrop.click(this.options.backdrop=="static"?a.proxy(this.$element[0].focus,this.$element[0]):a.proxy(this.hide,this)),e&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in");if(!b)return;e?this.$backdrop.one(a.support.transition.end,b):b()}else!this.isShown&&this.$backdrop?(this.$backdrop.removeClass("in"),a.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one(a.support.transition.end,b):b()):b&&b()}};var c=a.fn.modal;a.fn.modal=function(c){return this.each(function(){var d=a(this),e=d.data("modal"),f=a.extend({},a.fn.modal.defaults,d.data(),typeof c=="object"&&c);e||d.data("modal",e=new b(this,f)),typeof c=="string"?e[c]():f.show&&e.show()})},a.fn.modal.defaults={backdrop:!0,keyboard:!0,show:!0},a.fn.modal.Constructor=b,a.fn.modal.noConflict=function(){return a.fn.modal=c,this},a(document).on("click.modal.data-api",'[data-toggle="modal"]',function(b){var c=a(this),d=c.attr("href"),e=a(c.attr("data-target")||d&&d.replace(/.*(?=#[^\s]+$)/,"")),f=e.data("modal")?"toggle":a.extend({remote:!/#/.test(d)&&d},e.data(),c.data());b.preventDefault(),e.modal(f).one("hide",function(){c.focus()})})}(window.jQuery); 1106 1107/*! 1108* FitVids 1.1 1109* 1110* Copyright 2013, Chris Coyier - http://css-tricks.com + Dave Rupert - http://daverupert.com 1111* Credit to Thierry Koblentz - http://www.alistapart.com/articles/creating-intrinsic-ratios-for-video/ 1112* Released under the WTFPL license - http://sam.zoy.org/wtfpl/ 1113* 1114*/ 1115;(function($){$.fn.fitVids=function(options){var settings={customSelector:null,ignore:null};if(!document.getElementById("fit-vids-style")){var head=document.head||document.getElementsByTagName("head")[0];var css=".fluid-width-video-wrapper{width:100%;position:relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top:0;left:0;width:100%;height:100%;}";var div=document.createElement("div");div.innerHTML='<p>x</p><style id="fit-vids-style">'+css+"</style>";head.appendChild(div.childNodes[1])}if(options){$.extend(settings,options)}return this.each(function(){var selectors=['iframe[src*="player.vimeo.com"]','
1115iframe[src*="youtube.com"]','iframe[src*="youtube-nocookie.com"]','iframe[src*="kickstarter.com"][src*="video.html"]',"object","embed"];if(settings.customSelector){selectors.push(settings.customSelector)}var ignoreList=".fitvidsignore";if(settings.ignore){ignoreList=ignoreList+", "+settings.ignore}var $allVideos=$(this).find(selectors.join(","));$allVideos=$allVideos.not("object object");$allVideos=$allVideos.not(ignoreList);$allVideos.each(function(){var $this=$(this);if($this.parents(ignoreList).length>0){return}if(this.tagName.toLowerCase()==="embed"&&$this.parent("object").length||$this.parent(".fluid-width-video-wrapper").length){return}if((!$this.css("height")&&!$this.css("width"))&&(isNaN($this.attr("height"))||isNaN($this.attr("width")))){$this.attr("height",9);$this.attr("width",16)}var height=(this.tagName.toLowerCase()==="object"||($this.attr("height")&&!isNaN(parseInt($this.attr("height"),10))))?parseInt($this.attr("height"),10):$this.height(),width=!isNaN(parseInt($this.attr("width"),10))?parseInt($this.attr("width"),10):$this.width(),aspectRatio=height/width;if(!$this.attr("id")){var videoID="fitvid"+Math.floor(Math.random()*999999);$this.attr("id",videoID)}$this.wrap('<div class="fluid-width-video-wrapper"></div>').parent(".fluid-width-video-wrapper").css("padding-top",(aspectRatio*100)+"%");$this.removeAttr("height").removeAttr("width")})})}})(window.jQuery||window.Zepto); 1116 1117/** 1118 * Plus/minus polyfill for numbers - used in WooCommerce 1119 * 1120 * Author Bryce Adams 1121 */ 1122!function($){$("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass("buttons_added").append('<input type="button" value="+" class="plus" />').prepend('<input type="button" value="-" class="minus" />'),$(document).on("click",".plus, .minus",function(){var t=$(this).closest(".quantity").find(".qty"),a=parseFloat(t.val()),n=parseFloat(t.attr("max")),s=parseFloat(t.attr("min")),e=t.attr("step");a&&""!==a&&"NaN"!==a||(a=0),(""===n||"NaN"===n)&&(n=""),(""===s||"NaN"===s)&&(s=0),("any"===e||""===e||void 0===e||"NaN"===parseFloat(e))&&(e=1),$(this).is(".plus")?t.val(n&&(n==a||a>n)?n:a+parseFloat(e)):s&&(s==a||s>a)?t.val(s):a>0&&t.val(a-parseFloat(e)),t.trigger("change")})}(jQuery); 1123 1124 1125/*! http://mths.be/placeholder v2.0.7 by @mathias */ 1126(function(q,f,d){function r(b){var a={},c=/^jQuery\d+$/;d.each(b.attributes,function(b,d){d.specified&&!c.test(d.name)&&(a[d.name]=d.value)});return a}function g(b,a){var c=d(this);if(this.value==c.attr("placeholder")&&c.hasClass("placeholder"))if(c.data("placeholder-password")){c=c.hide().next().show().attr("id",c.removeAttr("id").data("placeholder-id"));if(!0===b)return c[0].value=a;c.focus()}else this.value="",c.removeClass("placeholder"),this==m()&&this.select()}function k(){var b,a=d(this),c=this.id;if(""==this.value){if("password"==this.type){if(!a.data("placeholder-textinput")){try{b=a.clone().attr({type:"text"})}catch(e){b=d("<input>").attr(d.extend(r(this),{type:"text"}))}b.removeAttr("name").data({"placeholder-password":a,"placeholder-id":c}).bind("focus.placeholder",g);a.data({"placeholder-textinput":b,"placeholder-id":c}).before(b)}a=a.removeAttr("id").hide().prev().attr("id",c).show()}a.addClass("placeholder");a[0].value=a.attr("placeholder")}else a.removeClass("placeholder")}function m(){try{return f.activeElement}catch(b){}}var h="placeholder"in f.createElement("input"),l="placeholder"in f.createElement("textarea"),e=d.fn,n=d.valHooks,p=d.propHooks;h&&l?(e=e.placeholder=function(){return this},e.input=e.textarea=!0):(e=e.placeholder=function(){this.filter((h?"textarea":":input")+"[placeholder]").not(".placeholder").bind({"focus.placeholder":g,"blur.placeholder":k}).data("placeholder-enabled",!0).trigger("blur.placeholder");return this},e.input=h,e.textarea=l,e={get:function(b){var a=d(b),c=a.data("placeholder-password");return c?c[0].value:a.data("placeholder-enabled")&&a.hasClass("placeholder")?"":b.value},set:function(b,a){var c=d(b),e=c.data("placeholder-password");if(e)return e[0].value=a;if(!c.data("placeholder-enabled"))return b.value=a;""==a?(b.value=a,b!=m()&&k.call(b)):c.hasClass("placeholder")?g.call(b,!0,a)||(b.value=a):b.value=a;return c}},h||(n.input=e,p.value=e),l||(n.textarea=e,p.value=e),d(function(){d(f).delegate("form","submit.placeholder",function(){var b=d(".placeholder",this).each(g);setTimeout(function(){b.each(k)},10)})}),d(q).bind("beforeunload.placeholder",function(){d(".placeholder").each(function(){this.value=""})}))})(this,document,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.