1var BetterMag = (function($) { 2 "use strict"; 3 4 return { 5 6 init: function(){ 7 8 // Pretty Photo Settings 9 this.prettyPhotoSettings = { 10 social_tools: false, 11 show_title: false, 12 markup: '<div class="pp_pic_holder"> \ 13 <div class="ppt"></div> \ 14 <div class="pp_content_container"> \ 15 <div class="pp_content"> \ 16 <div class="pp_loaderIcon"></div> \ 17 <div class="pp_fade"> \ 18 <a href="#" class="pp_expand" title="Expand the image"></a> \ 19 <a class="pp_close" href="#"></a> \ 20 <div class="pp_hoverContainer"> \ 21 <a class="pp_next" href="#"><i class="fa fa-chevron-right"></i></a> \ 22 <a class="pp_previous" href="#"><i class="fa fa-chevron-left"></i></a> \ 23 </div> \ 24 <div id="pp_full_res"></div> \ 25 <div class="pp_details"> \ 26 <div class="pp_nav"> \ 27 <a href="#" class="pp_arrow_previous"><i class="fa fa-backward"></i></a> \ 28 <p class="currentTextHolder">0/0</p> \ 29 <a href="#" class="pp_arrow_next"><i class="fa fa-forward"></i></a> \ 30 </div> \ 31 <p class="pp_description"></p> \ 32 </div> \ 33 </div> \ 34 </div> \ 35 </div> \ 36 </div> \ 37 <div class="pp_overlay"></div>', 38 gallery_markup: '<div class="pp_gallery"> \ 39 <a href="#" class="pp_arrow_previous"><i class="fa fa-chevron-left"></i></a> \ 40 <div> \ 41 <ul> \ 42 {gallery} \ 43 </ul> \ 44 </div> \ 45 <a href="#" class="pp_arrow_next"><i class="fa fa-chevron-right"></i></a> \ 46 </div>' 47 }; 48 49 // Setup gallery 50 this.gallery(); 51 52 // Setup Widgets and Shortcodes 53 this.setup_widgets(); 54 55 // Setup Sliders 56 this.setup_sliders(); 57 58 // Setup Video Players 59 this.setup_video_players(); 60 61 // Small Fixes With jQuery For Elements Styles 62 this.small_style_fixes(); 63 64 // Setup WooCommerce Related Functionality 65 this.woocommerce(); 66 67 // Setup Gallery Background Slide Show 68 this.setup_gallery_bg_slide_show(); 69 70 // BetterStudio Editor Shortcodes Setup 71 this.betterstudio_editor_shortcodes(); 72 73 // Setup sticky menu 74 this.setup_menu(); 75 76 // Define elements that use elementQuery 77 this.fix_element_query(); 78 79 // Setup Back To Top Button 80 this.back_to_top(); 81 82 // Setup Popup 83 this.popup(); 84 85 86 }, 87 88 89 /** 90 * Setup Menu 91 */ 92 setup_menu: function() { 93 94 BetterMag.setup_responsive_menu(); 95 96 BetterMag.setup_sticky_menu(); 97 98 }, 99 100 101 /** 102 * Setup mobile menu from normal menu 103 */ 104 setup_responsive_menu: function() { 105 106 // clone navigation for mobile 107 var clone = $('.main-menu .main-menu-container').clone().addClass('mobile-menu-container clearfix').removeClass('desktop-menu-container'); 108 109 // Appends cloned menu to page 110 clone.appendTo('.main-menu .container'); 111 112 // Remove modals from mobile menu 113 // TODO Add style for this and not delete 114 clone.find("#login-modal").remove(); 115 116 // Add mobile menu 117 clone.prepend( '<div class="mobile-button"><a href="#"><span class="text">' + better_mag_vars.text_navigation + '</span><span class="current"></span><i class="fa fa-bars"></i></a></div>' ); 118 119 // Show/Hide menu on click mobile-button 120 $('.main-menu .main-menu-container.mobile-menu-container .mobile-button').click(function() { 121 122 $('.main-menu .main-menu-container.mobile-menu-container').toggleClass('active'); 123 124 return false; 125 126 }); 127 128 // Add show children list button 129 $('.main-menu .main-menu-container.mobile-menu-container li > .mega-menu,.main-menu .main-menu-container.mobile-menu-container li > .sub-menu').each(function() { 130 $(this).parent().append('<a href="#" class="children-button"><i class="fa fa-angle-down"></i></a>'); 131 }); 132 133 // Show/Hide children list on click "children-button" 134 $('.main-menu .main-menu-container.mobile-menu-container li a.children-button').click(function() { 135 136 $(this).closest('li').find('.mega-menu,.sub-menu').first().toggle().parent().toggleClass('active item-active'); 137 138 if( $(this).find('.fa-angle-down').length ){ 139 $(this).find('.fa-angle-down').removeClass('fa-angle-down').addClass('fa-angle-up'); 140 }else{ 141 $(this).find('.fa-angle-up').removeClass('fa-angle-up').addClass('fa-angle-down'); 142 } 143 144 return false;
145 }); 146 147 // Adds current menu item name after navigation text 148 var $last_current = $('.main-menu .main-menu-container.mobile-menu-container .current-menu-item').last().find('> a'); 149 if( $last_current.length ){ 150 151 var $mobile_button = $('.main-menu .main-menu-container.mobile-menu-container .mobile-button'), 152 current = $mobile_button.find('.current'), 153 nav_text = $mobile_button.find('.text'); 154 155 // Adds : after navigation text if its not available currently 156 if( nav_text.text().slice(-1) !== ':' ){ 157 nav_text.text( nav_text.text() + ':'); 158 } 159 160 // Set current item text to responsive menu button ( filter just text not elements ) 161 current.text( $last_current.contents() 162 .filter(function() { 163 // 3 equals to Node.TEXT_NODE 164 return this.nodeType == 3; 165 }).text() 166 ); 167 } 168 169 }, 170 171 172 /** 173 * Setup sticky menu 174 */ 175 setup_sticky_menu: function(){ 176 177 var $main_menu = $('.main-menu'); 178 179 // If sticky menu is enable 180 if( ! $main_menu.hasClass( 'sticky-menu' ) ){ 181 return; 182 } 183 184 185 var main_menu_offset_top = $main_menu.offset().top; 186 187 // fix for admin toolbar 188 if( $('body').hasClass('admin-bar') ){ 189 main_menu_offset_top -= 32; 190 } 191 192 var sticky_func = function(){ 193 194 if( $(window).scrollTop() > main_menu_offset_top ) 195 $main_menu.addClass('sticky'); 196 else 197 $main_menu.removeClass('sticky'); 198 199 }; 200 201 sticky_func(); 202 203 $( window ).scroll( function(){ 204 sticky_func(); 205 } ); 206 }, 207 208 209 /** 210 * Setup Widgets and Shortcodes 211 */ 212 setup_widgets: function(){ 213 214 $('.bf-news-ticker').betterNewsTicker(); 215 216 }, 217 218 219 /** 220 * Setup Sliders 221 */ 222 setup_sliders: function(){ 223 224 if( ! $.fn.flexslider ){ 225 return; 226 } 227 228 $('.gallery-slider .flexslider').flexslider({ 229 animation : "fade", 230 prevText : "", 231 nextText : "", 232 controlNav : false 233 }); 234 235 $('.main-slider .flexslider').flexslider({ 236 animation : better_mag_vars.main_slider.animation, 237 slideshowSpeed : better_mag_vars.main_slider.slideshowSpeed, 238 animationSpeed : better_mag_vars.main_slider.animationSpeed, 239 prevText : "", 240 nextText : "", 241 controlNav : true, 242 directionNav: false 243 }); 244 245 $('.gallery-listing.column-3 .flexslider').flexslider({ 246 animation : "slide", 247 animationLoop: true, 248 itemWidth : 200, 249 itemMargin : 20, 250 minItems : 2, 251 maxItems : 3, 252 controlNav : false, 253 animationSpeed: 800 254 }); 255 256 $('.gallery-listing.column-2 .flexslider').flexslider({ 257 animation : "slide", 258 animationLoop: true, 259 itemWidth : 335, 260 itemMargin : 20, 261 minItems : 2, 262 maxItems : 2, 263 controlNav : false, 264 animationSpeed: 800 265 }); 266 267 }, 268 269 270 /** 271 * Setup Video Players 272 */ 273 setup_video_players: function(){ 274 275 $('.single-post .featured, .the-content, .sidebar').fitVids(); 276 277 }, 278 279 280 /** 281 * Setup Gallery Post Format as Background Slide Show 282 */ 283 setup_gallery_bg_slide_show: function(){ 284 285 var $gallery_parent = $( '.single-post .gallery-slider.gallery-as-background-slide-show:first'); 286 287 if( $gallery_parent.length > 0){ 288 289 var images = []; 290 291 $gallery_parent.find( '.slides li img').each( function(){ 292 293 if( typeof $(this).data('img') != 'undefined' ){ 294 images.push( $(this).data('img') ); 295 }else{ 296 images.push( $(this).attr('src') ); 297 } 298 299 }); 300 301 $.backstretch( images, {duration: 7000, fade: 600}); 302 303 } 304 }, 305 306 307 308 /** 309 * Small style fixes with jquery that can't done with css! 310 */ 311 small_style_fixes: function(){ 312 313 // add and remove class "have-focus" for search forms 314 $( ".search-form .search-field" ).on('focusin',function() { $( this ).closest('.search-form').addClass('have-focus'); }); 315 $( ".search-form .search-field" ).on('focusout',function() { $( this ).closest('.search-form').removeClass('have-focus'); }); 316 $( "#searchform #s" ).on('focusin',function() { $( this ).closest('#searchform').addClass('have-focus'); }); 317 $( "#searchform #s" ).on('focusout',function() { $( this ).closest('#searchform').removeClass('have-focus'); }); 318 $( "#bbp-search-form #bbp_search" ).on('focusin',function() { $( this ).closest('#bbp-search-form').addClass('have-focus'); }); 319 $( "#bbp-search-form #bbp_search" ).on('focusout',function() { $( this ).closest('#bbp-search-form').removeClass('have-focus'); }); 320 321 322 // small fix for cauterizing elements in header aside 323 if( ! $('html').hasClass('ie8') && ! $('html').hasClass('ie9') ) 324 $(window).load(function() { 325 $("header.header .row").height(function(){ 326 var logo_height = $("header.header .logo-container").outerHeight(); 327 var aside_logo_height = $("header.header .aside-logo-sidebar").outerHeight(); 328 329 if( logo_height > aside_logo_height ){ 330 return logo_height + 'px'; 331 }else{ 332 return aside_logo_height + 'px'; 333 } 334 }); 335 $("header.header .aside-logo-sidebar").css( 'margin-top', Math.floor( ( $("header.header .aside-logo-sidebar").height() - 5 ) / 2 * -1) + 'px').css('top','50%'); 336 337 }); 338 339 // last-aligned class for selecting first floated li that is noy posiblr with css 340 $( ".main-menu .menu li.alignright").first().addClass('first-aligned'); 341 342 // mega menu height fix 343 $(".main-menu .mega-menu.style-category .mega-menu-links").each(function(){ 344 if( $(this).height() > $(this).closest(".mega-menu").find('.mega-menu-listing-container').height() ){ 345 $(this).closest(".mega-menu").find('.mega-menu-listing-container').height( $(this).height() ); 346 }else{ 347 $(this).height( $(this).closest(".mega-menu").find('.mega-menu-listing-container').height() + 5 ); 348 } 349 }); 350 351 352 // calendar widget fix 353 $(".widget.widget_calendar table td a").each( function(){ 354 $(this).parent().addClass('active-day'); 355 }); 356 357 358 // add active term for tab heading 359 $('.section-heading.tab-heading .nav-tabs li.active').each(function(){ 360 361 var classNames = $(this).attr('class').split(" "); 362 363 var selected_tab_term = ''; 364 365 // find term class 366 jQuery.each( classNames, function( index, value){ 367 if( value.match(/term-/)){ 368 selected_tab_term = value; 369 return false;
370 } 371 }); 372 373 $(this).closest('.section-heading').addClass(selected_tab_term); 374 375 }); 376 377 // add term class to tab heading 378 $('.section-heading.tab-heading .nav-tabs a[data-toggle="tab"]').on('shown.bs.tab', function (e) { 379 380 if( typeof $(e.target).parent().attr('class') == 'undefined' ){ 381 return true; 382 } 383 384 var $parent = $(e.target).closest('.section-heading'), 385 classNames = $(e.target).parent().attr('class').split(" "); 386 387 var selected_tab_term = ''; 388 389 // find term class 390 jQuery.each( classNames, function( index, value){ 391 if( value.match(/term-/)){ 392 selected_tab_term = value; 393 return false; 394 } 395 }); 396 397 // remove term classes from parent 398 jQuery.each( $parent.attr('class').split(" "), function( index, value){ 399 if( value.match(/term-/)){ 400 $parent.removeClass(value); 401 } 402 }); 403 404 $parent.addClass( selected_tab_term ); 405 406 }); 407 408 // Cross Browser Placeholder 409 $('input, textarea').placeholder(); 410 411 // IE 10 detection for style fixing 412 if( $.browser.msie && $.browser.version == 10) { 413 $("html").addClass("ie ie10"); 414 } 415 416 }, 417 418 419 /** 420 * Setup WooCommerce Related Functionality 421 */ 422 woocommerce: function(){ 423 424 // Order list 425 $('.woocommerce-ordering .drop-down li a').click(function(e) { 426 var form = $(this).closest('form'); 427 428 form.find('[name=orderby]').val($(this).parent().data('value')); 429 form.submit(); 430 431 e.preventDefault(); 432 }); 433 434 // Update Menu Cart and Count 435 $(window).on('added_to_cart',function( e, data ){ 436 437 $( '#main-menu > li.shop-cart-item .widget_shopping_cart .widget_shopping_cart_content').replaceWith( data['div.widget_shopping_cart_content'] ); 438 439 $(".bm-wc-cart .items-list .widget_shopping_cart_content").each(function(){ 440 $(this).replaceWith( data['div.widget_shopping_cart_content'] ); 441 }); 442 443 if( typeof data['total-items-in-cart'] != 'undefined' ){ 444 $( '#main-menu > li.shop-cart-item .better-custom-badge ').html( data['total-items-in-cart'] ); 445 446 $(".bm-wc-cart .cart-link .total-items").html( data['total-items-in-cart'] ); 447 448 if( data['total-items-in-cart'] > 0 ){ 449 $(".bm-wc-cart").removeClass('empty-cart').find('.total-items').removeClass('empty'); 450 }else{ 451 $(".bm-wc-cart").addClass('empty-cart').find('.total-items').addClass('empty'); 452 } 453 } 454 455 }); 456 457 $("header.header .widget_shopping_cart").each(function(i,e){ 458 $(this).parent().append("<div class='bm-woocommerce-cart-widget' id='bm-cart-widget-" + i + "'></div>"); 459 $(this).appendTo("#bm-cart-widget-"+i); 460 }); 461 462 }, 463 464 465 /** 466 * BetterStudio Editor Shortcodes Setup 467 */ 468 betterstudio_editor_shortcodes: function(){ 469 470 $('.bs-accordion-shortcode').on( 'show.bs.collapse', function(e) { 471 $(e.target).prev('.panel-heading').addClass('active'); 472 }).on('hide.bs.collapse', function(e) { 473 $(e.target).prev('.panel-heading').removeClass('active'); 474 }); 475 476 }, 477 478 479 /** 480 * Back to top button 481 */ 482 back_to_top: function(){ 483 484 485 if( ! $('body').hasClass( 'enabled_back_to_top' ) ) 486 return; 487 488 var $back_to_top = $('.back-top'); 489 490 $back_to_top.click(function(){ 491 $('body,html').animate({ 492 scrollTop: 0 493 }, 700 494 ); 495 }); 496 497 $(window).scroll(function(){ 498 ( $(this).scrollTop() > 300 ) ? $back_to_top.addClass('is-visible') : $back_to_top.removeClass('is-visible fade-out1 fade-out2 fade-out3 fade-out4'); 499 500 switch ( true ){ 501 502 case ( $(this).scrollTop() > 2400 ): 503 $back_to_top.addClass('fade-out4'); 504 break; 505 506 case ( $(this).scrollTop() > 1700 ): 507 $back_to_top.removeClass('fade-out3').addClass('fade-out3'); 508 break; 509 510 case ( $(this).scrollTop() > 1000 ): 511 $back_to_top.removeClass('fade-out4 fade-out3').addClass('fade-out2'); 512 break; 513 514 case ( $(this).scrollTop() > 500 ): 515 $back_to_top.removeClass('fade-out4 fade-out3 fade-out2').addClass('fade-out1'); 516 break; 517 } 518 519 }); 520 521 // Fix bottom space in box padded style 522 if( $('body').hasClass( 'boxed-padded' ) ){ 523 $(window).scroll(function() { 524 if( ( ( $(window).scrollTop() ) + $(window).height() ) >= ( $(document).height() - 50 ) ) { 525 $('.back-top-wrapper .back-top').addClass('end-page'); 526 }else{ 527 $('.back-top-wrapper .back-top').removeClass('end-page'); 528 } 529 }); 530 } 531 }, 532 533 534 /** 535 * Define elements that use elementQuery on local/cross domain 536 */ 537 fix_element_query: function(){ 538 539 if( typeof elementQuery != 'function' ){ 540 return; 541 } 542 543 elementQuery({ 544 ".bf-news-ticker" :{ "max-width":["250px", "320px"] }, 545 ".section-heading.extended.tab-heading" :{ "max-width":["300px"]} 546 }); 547 548 }, 549 550 551 552 /** 553 * Setup Popup 554 */ 555 popup: function(){ 556 557 // If light box is not active 558 if( ! $('body').hasClass( 'active-lighbox' ) ) 559 return; 560 561 // disabled on mobile screens 562 if( ! $.fn.prettyPhoto || $(window).width() < 700 ) 563 return; 564 565 var filter_only_images = function() { 566 567 if( ! $(this).attr('href') ) 568 return false;
569 570 if( typeof $(this).data('not-rel') != 'undefined') 571 return false; 572 573 return $(this).attr('href').match(/\.(jp?g|png|bmp|gif)$/); 574 }; 575 576 $('.the-content.post-content a, .the-content.page-content a').has('img').filter(filter_only_images).attr('rel', 'prettyPhoto'); 577 578 579 var gallery_id = 1; 580 581 $('.the-content .gallery, .the-content .tiled-gallery').each(function() { 582 583 $(this).find('a').has('img').filter(filter_only_images).attr('rel', 'prettyPhoto[gallery_'+ gallery_id +']'); 584 585 gallery_id++; 586 587 }); 588 589 $("a[rel^='prettyPhoto']").prettyPhoto( BetterMag.prettyPhotoSettings ); 590 }, 591 592 593 /** 594 * Setup Gallery 595 */ 596 gallery: function(){ 597 598 var $fotoramaDiv = jQuery('.fotorama').fotorama({ 599 width: '100%', 600 loop: true, 601 margin: 10, 602 thumbwidth: 85, 603 thumbheight: 45, 604 thumbmargin: 9, 605 transitionduration: 800, 606 arrows: false, 607 click:false, 608 swipe:true 609 }).on('fotorama:show', function(e, fotorama, extra){ 610 611 var $gallery = $(this).closest('.better-gallery'); 612 613 $gallery.find('.count .current').html( fotorama.activeFrame.i ); 614 615 }); 616 617 // Activate light box gallery if active 618 if( $('body').hasClass( 'active-lighbox' ) && $.fn.prettyPhoto || $(window).width() < 700 ){ 619 620 jQuery('.better-gallery').on( 'click', '.slide-link', function(){ 621 622 event.preventDefault(); 623 624 var $gallery = $(this).closest('.better-gallery'); 625 var gallery_id = $gallery.data('gallery-id'); 626 627 var pps = BetterMag.prettyPhotoSettings; 628 629 pps.changepicturecallback = function(){ 630 $('#gallery-' + gallery_id).find('.fotorama').data('fotorama').show( $('.pp_gallery').find('li').index($('.selected')) ); 631 }; 632 633 $.fn.prettyPhoto( pps ); 634 635 $.prettyPhoto.open( window["prt_gal_img_"+gallery_id], window["prt_gal_cap_"+gallery_id], window["prt_gal_cap_"+gallery_id]); 636 637 $.prettyPhoto.changePage( $('#gallery-' + gallery_id).find('.fotorama').data('fotorama').activeFrame.i - 1 ); 638 639 return false; 640 }); 641 642 } 643 644 // Next Button 645 jQuery('.better-gallery .gallery-title .next').click(function(){ 646 647 var fotorama = $(this).closest('.better-gallery').find('.fotorama').data('fotorama'); 648 fotorama.show('>'); 649 650 }); 651 652 // Previous Button 653 jQuery('.better-gallery .gallery-title .prev').click(function(){ 654 655 var fotorama = $(this).closest('.better-gallery').find('.fotorama').data('fotorama'); 656 fotorama.show('<'); 657 658 }); 659 660 } 661 662 663 };// /return 664})(jQuery); 665 666// Load when ready 667jQuery(document).ready(function() { 668 669 BetterMag.init(); 670 671});
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.