var Bunyad_Theme = (function($) { "use strict"; var hasTouch = false; // module return { init: function() { // posts grid var grid = $('.posts-grid').data('grid-count'); if (parseInt(grid) > 0) { $('.posts-grid .column:nth-child(' + grid + 'n)').addClass('last'); } // fit videos to container $('.featured-vid, .post-content').fitVids(); // ratings $('.rate-number').each(function() { var raw = $(this).find('span:not(.progress)').html(), progress = parseFloat(raw); $(this).find('.progress').css('width', (raw.search('%') === -1 ? (Math.round(progress / 10 * 100)) + '%' : progress)) ; }); // social icons widget $('.lower-foot .social-icons a, .share-links a').tooltip({placement: 'top'}); $('.social-icons a').tooltip({placement: 'bottom'}); // news focus block $('.news-focus .subcats a').click(function() { var active = $(this).parents('.subcats').find('a.active'), parent = $(this).parents('.news-focus'); // show the news and hide the other block parent.find('.news-' + active.data('id')).hide(); parent.find('.news-' + $(this).data('id')).fadeIn('slow'); $(this).addClass('active'); active.removeClass('active'); return false; }); $('.modal').on('shown.bs.modal', function() { $(this).css({ 'margin-top': function () { return -($(this).height() / 2); } }); }); // login $(document).on('click', '.user-login', function() { $('.login-modal .modal-content').hide(); $('.login-modal .main-screen').show(); $('#login-modal').modal('show'); return false; }); var change_modal = function(name) { if (!$('.login-modal').is(':visible')) { $('#login-modal').modal('show'); } $('.login-modal .modal-content').hide(); $('.login-modal ' + name).show(); return false; }; $('a.register-modal').click(function() { return change_modal('.register-now'); }); $('a.lost-pass-modal').click(function() { return change_modal('.lost-pass'); }); // setup all sliders this.sliders(); // handle shortcodes this.shortcodes(); // setup mobile navigation this.responsive_nav(); this.touch_nav(); // start the news ticker this.news_ticker(); // setup the lightbox this.lightbox(); // use sticky navigation if enabled this.sticky_nav(); /** * Image scroll animations */ $('.main img, .main-footer img').addClass('no-display'); $('.main img, .main-footer img, .main-featured .row').one('inview', function() { $(this).addClass('appear'); }); $('.review-box ul li .bar').each(function() { $(this).data('width', $(this)[0].style.width).css('width', 0); }); $('.review-box ul li').one('inview', function() { var bar = $(this).find('.bar'); bar.addClass('appear').css('width', bar.data('width')); }); /** * IE fixes */ if ($.browser.msie && 8 == parseInt($.browser.version)) { // fontawesome4 fails to draw sometimes on IE8 $(function() { var $ss = $('#font-awesome-css'); $ss[0].href = $ss[0].href; }); // flickr widget fix - ie8 only $('.flickr-widget .flickr_badge_image:nth-of-type(4n)').css('margin-right', 0); // background image fix for IE8 var bg = $('body').css('background-attachment'), bg_url = $('body').css('background-image').replace(/^url\((['"]?)(.*)\1\)$/, '$2'); if (bg == 'fixed' && bg_url) { $('body').append(''); $('
').appendTo('body'); } // more lackluster ie8 $('.listing > .column:nth-child(odd)').css('clear', 'both'); } // add support for placeholder in IE8/IE9 $('input, textarea').placeholder(); }, news_ticker: function() { $('.trending-ticker ul').each(function() { if (!$(this).find('li.active').length) { $(this).find('li:first').addClass('active'); } var ticker = $(this); window.setInterval(function() { var active = ticker.find('li.active'); active.fadeOut(function() { var next = active.next(); if (!next.length) { next = ticker.find('li:first'); } next.addClass('active').fadeIn(); active.removeClass('active'); }); }, 8000); }); }, responsive_nav: function() { // detect touch capability dynamically $(window).on('touchstart', function() { hasTouch = true; $('body').addClass('touch'); }); // clone navigation for mobile var clone = $('.navigation > div[class$="-container"]').clone().addClass('mobile-menu-container'); clone.find('.menu').addClass('mobile-menu'); clone.appendTo('.navigation'); // register click handlers for mobile menu $('.navigation .mobile .selected').click(function() { $('.navigation .mobile-menu').toggleClass('active'); return false; }); $('.navigation .mobile-menu li > a').each(function() { if ($(this).parent().children('ul').length) { $('').appendTo($(this)); } }); $('.navigation .mobile-menu li .chevron').click(function() { $(this).closest('li').find('ul').first().toggle().parent().toggleClass('active item-active'); return false; }); // add active item var last = $('.mobile-menu .current-menu-item').last().find('> a'); if (last.length) { var selected = $('.navigation .mobile .selected'), current = selected.find('.current'), cur_text = selected.find('.text').text(); if (cur_text.slice(-1) !== ':') { selected.find('.text').text(cur_text + ':'); } current.text(last.text()); } }, touch_nav: function() { var targets = $('.menu:not(.mobile-menu) a'), open_class = 'item-active', child_tag = 'ul, .mega-menu'; targets.each(function() { var $this = $(this), $parent = $this.parent('li'), $siblings = $parent.siblings().find('a'); $this.click(function(e) { if (!hasTouch) { return; } var $this = $(this); e.stopPropagation(); $siblings.parent('li').removeClass(open_class); // has a child? open the menu on tap if (!$this.parent().hasClass(open_class) && $this.next(child_tag).length > 0 && !$this.parents('.mega-menu.links').length) { e.preventDefault(); $this.parent().addClass(open_class); } }); }); // close all menus $(document).click(function(e) { if (!$(e.target).is('.menu') && !$(e.target).parents('.menu').length) { targets.parent('li').removeClass(open_class); } }); }, sticky_nav: function() { var nav = $('.navigation'), nav_top = nav.offset().top; // not enabled? if (!nav.data('sticky-nav')) { return; } var sticky = function() { if (!nav.data('sticky-nav')) { return; } // make it sticky when viewport is scrolled beyond the navigation if ($(window).scrollTop() > nav_top) { nav.addClass('sticky'); } else { nav.removeClass('sticky'); } }; sticky(); $(window).scroll(function() { sticky(); }); }, /** * Setup all the sliders available */ sliders: function() { if (!$.fn.flexslider) { return; } // main slider var slider = $('.main-featured .slider'); $('.main-featured .flexslider').flexslider({ controlNav: true, animationSpeed: slider.data('animation-speed'), animation: slider.data('animation'), slideshowSpeed: slider.data('slide-delay'), manualControls: '.main-featured .flexslider .pages a', pauseOnHover: true, start: function() { $('.main-featured .slider').css('opacity', 1); } }); // carousels / galleries $('.carousel').flexslider({ animation: 'slide', animationLoop: false, itemWidth: 214, itemMargin: 30, minItems: 3, maxItems: 4, controlNav: false, slideshow: false }); $('.gallery-block .flexslider').flexslider({ controlNav: false, pauseOnHover: true }); // for post-galleries $('.gallery-slider .flexslider').flexslider({ controlNav: false, pauseOnHover: true }); }, /** * Register shortcode related events */ shortcodes: function() { // normal tabs $('.tabs-list a').click(function() { var tab = $(this).data('tab'), tabs_data = $(this).closest('.tabs-list').siblings('.tabs-data'), parent = $(this).parent().parent(); parent.find('.active').removeClass('active'); $(this).parent().addClass('active'); tabs_data.find('.tab-posts.active').hide(); tabs_data.find('#recent-tab-' + tab).fadeIn().addClass('active'); return false; }); /** * Shortcode: Tabs */ $('.sc-tabs a').click(function() { // tabs first var tabs = $(this).parents('ul'); tabs.find('.active').removeClass('active'); $(this).parent().addClass('active'); // panes second var panes = tabs.siblings('.sc-tabs-panes'); panes.find('.active').hide().removeClass('active'); panes.find('#sc-pane-' + $(this).data('id')).addClass('active').fadeIn(); return false; }); /** * Shortcode: Accordions & Toggles */ $('.sc-accordion-title > a').click(function() { var container = $(this).parents('.sc-accordions'); container.find('.sc-accordion-title').removeClass('active'); container.find('.sc-accordion-pane').slideUp().removeClass('active'); var pane = $(this).parent().next(); if (!pane.is(':visible')) { $(this).parent().addClass('active'); pane.slideDown(); } return false; }); $('.sc-toggle-title > a').click(function() { $(this).parent().toggleClass('active'); $(this).parent().next().slideToggle().toggleClass('active'); return false; }); }, /** * Setup prettyPhoto */ lightbox: function() { if (!$.fn.prettyPhoto) { return; } (function() { var gal_id = 1; $('.post-content a, .main .featured a').has('img').filter(function() { return $(this).attr('href').match(/\.(jp?g|png|bmp|gif)$/); }).attr('rel', 'prettyPhoto'); $('.gallery-slider, .post-content .gallery, .post-content .tiled-gallery').each(function() { gal_id++; // increment gallery group id $(this).find('img').each(function() { $(this).parents('a') .removeClass('prettyPhoto') .attr('rel', 'prettyPhoto[gal_'+ gal_id +']'); }); }); $("a[rel^='prettyPhoto']").prettyPhoto({social_tools: false}); })(); } }; // end return })(jQuery); // load when ready jQuery(function($) { Bunyad_Theme.init(); }); /** * Plugins and 3rd Party Libraries */ /** * Author Christopher Blum * Based on the idea of Remy Sharp, http://remysharp.com/2009/01/26/element-in-view-event-plugin/ * * License: WTFPL */ (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};qa.top&&c.topa.left&&c.leftc.left?"right":a.left+d.widthc.top?"bottom":a.top+d.height
',trigger:"hover",title:"",delay:0,html:!1},a.fn.tooltip.noConflict=function(){return a.fn.tooltip=c,this}}(window.jQuery); /** * Bootstrap.js by @fat & @mdo * plugins: bootstrap-modal.js * Copyright 2013 Twitter, Inc. * http://www.apache.org/licenses/LICENSE-2.0.txt */ !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-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('