1/* global jQuery:false */ 2/* global VEGADAYS_STORAGE:false */ 3 4jQuery(document).ready(function() { 5 "use strict"; 6 VEGADAYS_STORAGE['theme_init_counter'] = 0; 7 vegadays_init_actions(); 8}); 9 10jQuery(window).on('beforeunload', function() { 11 "use strict"; 12 // Show preloader 13 if (jQuery.browser && !jQuery.browser.safari) jQuery('#page_preloader').css({display: 'block', opacity: 0}).animate({opacity:0.8}, 300); 14}); 15 16 17// Theme init actions 18function vegadays_init_actions() { 19 "use strict"; 20 21 if (VEGADAYS_STORAGE['vc_edit_mode'] && jQuery('.vc_empty-placeholder').length==0 && VEGADAYS_STORAGE['theme_init_counter']++ < 30) { 22 setTimeout(vegadays_init_actions, 200); 23 return; 24 } 25 26 // Hide preloader 27 jQuery('#page_preloader').animate({opacity:0}, 500, function() { jQuery(this).css({display: 'none'}); }); 28 29 // Check for Retina display 30 if (vegadays_is_retina()) { 31 vegadays_set_cookie('vegadays_retina', 1, 365); 32 } 33 34 vegadays_ready_actions(); 35 36 // Add resize handlers after VC row stretch handlers on('resize.vcRowBehaviour', ...) 37 setTimeout(function() { 38 jQuery(window).on('resize.vegadays', function() { 39 vegadays_resize_actions(); 40 vegadays_scroll_actions() 41 }).trigger('resize.vegadays'); 42 }, 10); 43 44 // Scroll handlers 45 jQuery(window).on('scroll.vegadays', function() { 46 "use strict"; 47 vegadays_scroll_actions(); 48 }); 49} 50 51 52 53// Theme first load actions 54//============================================== 55function vegadays_ready_actions() { 56 "use strict"; 57 58 // Call theme specific action (if exists) 59 //---------------------------------------------- 60 if (window.vegadays_theme_ready_actions) vegadays_theme_ready_actions(); 61 62 63 // Widgets decoration 64 //---------------------------------------------- 65 66 // Decorate nested lists in widgets and side panels 67 jQuery('.widget ul > li').each(function() { 68 if (jQuery(this).find('ul').length > 0) { 69 jQuery(this).addClass('has_children'); 70 } 71 }); 72 73 74 // Archive widget decoration 75 jQuery('.widget_archive a').each(function() { 76 var val = jQuery(this).html().split(' '); 77 if (val.length > 1) { 78 val[val.length-1] = '<span>' + val[val.length-1] + '</span>'; 79 jQuery(this).html(val.join(' ')) 80 } 81 }); 82 83 84 // Navigate on category change 85 jQuery('.widget_subcategories').on('change', 'select', function() { 86 var dropdown = jQuery(this).get(0); 87 if ( dropdown.options[dropdown.selectedIndex].value > 0 ) { 88 location.href = VEGADAYS_STORAGE['site_url'] + "/?cat="+dropdown.options[dropdown.selectedIndex].value; 89 } 90 }); 91 92 93 // Calendar handlers - change months 94 jQuery('.widget_calendar').on('click', '.month_prev a, .month_next a', function(e) { 95 "use strict"; 96 var calendar = jQuery(this).parents('.wp-calendar'); 97 var m = jQuery(this).data('month'); 98 var y = jQuery(this).data('year'); 99 var l = jQuery(this).data('letter'); 100 var pt = jQuery(this).data('type'); 101 jQuery.post(VEGADAYS_STORAGE['ajax_url'], { 102 action: 'calendar_change_month', 103 nonce: VEGADAYS_STORAGE['ajax_nonce'], 104 letter: l, 105 month: m, 106 year: y, 107 post_type: pt 108 }).done(function(response) { 109 var rez = {}; 110 try { 111 rez = JSON.parse(response); 112 } catch (e) { 113 rez = { error: VEGADAYS_STORAGE['ajax_error'] }; 114 console.log(response); 115 } 116 if (rez.error === '') { 117 calendar.parent().fadeOut(200, function() { 118 jQuery(this).find('.wp-calendar').remove(); 119 jQuery(this).append(rez.data).fadeIn(200); 120 }); 121 } 122 }); 123 e.preventDefault(); 124 return false; 125 }); 126 127 128 // Media setup 129 //---------------------------------------------- 130 131 // Video background init 132 jQuery('.video_background').each(function() { 133 var youtube = jQuery(this).data('youtube-code'); 134 if (youtube) { 135 jQuery(this).tubular({videoId: youtube}); 136 } 137 }); 138 139 140 // Main slider 141 //---------------------------------------------- 142 jQuery('.slider_over_button,.slider_over_close').on('click', function(e) { 143 jQuery(this).parent().toggleClass('opened'); 144 e.preventDefault(); 145 return false; 146 }); 147 148 149 150 // Menu 151 //---------------------------------------------- 152 153 // Clone side menu for responsive 154 if (jQuery('ul#menu_side').length > 0) { 155 jQuery('ul#menu_side').clone().removeAttr('id').removeClass('menu_side_nav').addClass('menu_side_responsive').insertAfter('ul#menu_side'); 156 vegadays_show_current_menu_item(jQuery('.menu_side_responsive'), jQuery('.sidebar_outer_menu_responsive_button')); 157 } 158 if (jQuery('.header_mobile').length > 0) { 159 jQuery('.header_mobile .menu_main_nav_area ul#menu_main').removeAttr('id'); 160 jQuery('.header_mobile .menu_button').on('click', function(){ 161 jQuery('.header_mobile .side_wrap').toggleClass('open'); 162 jQuery('.header_mobile .mask').toggleClass('show'); 163 jQuery('html').toggleClass('menu_mobile_open'); 164 // Fix for Safari 165 if (vegadays_browser_is_ios() && jQuery('body').hasClass('menu_mobile')) { 166 jQuery('body').toggleClass('ios_fixed'); 167 } 168 }); 169 jQuery('.header_mobile .mask, .header_mobile .side_wrap .close').on('click', function(){ 170 jQuery('.header_mobile .side_wrap').removeClass('open'); 171 jQuery('.header_mobile .mask').removeClass('show'); 172 jQuery('html').removeClass('menu_mobile_open'); 173 // Fix for Safari 174 if (vegadays_browser_is_ios() && jQuery('body').hasClass('menu_mobile')) { 175 jQuery('body').removeClass('ios_fixed'); 176 } 177 }); 178 } 179 180 // Push menu button 181 jQuery('.menu_pushy_button').on('click', function(e){ 182 "use strict"; 183 jQuery('body').addClass('pushy-active').css('overflow', 'hidden'); 184 jQuery('.site-overlay').fadeIn('fast'); 185 e.preventDefault(); 186 return false;
187 }); 188 jQuery('.pushy .close-pushy,.site-overlay').on('click', function(e){ 189 jQuery('body').removeClass('pushy-active').css('overflow', 'visible'); 190 jQuery('.site-overlay').fadeOut('fast'); 191 e.preventDefault(); 192 return false; 193 }); 194 195 // Side menu widgets button 196 jQuery('.sidebar_outer_widgets_button').on('click', function(e){ 197 "use strict"; 198 jQuery('.sidebar_outer_widgets').slideToggle(); 199 e.preventDefault(); 200 return false; 201 }); 202 203 // Add arrows in responsive menu 204 jQuery('.header_mobile .menu_main_nav .menu-item-has-children > a, .menu_side_responsive .menu-item-has-children > a, .menu_pushy_nav_area .menu-item-has-children > a, body:not(.woocommerce) .widget_area:not(.footer_wrap) .widget_product_categories ul.product-categories .has_children > a').prepend('<span class="open_child_menu"></span>'); 205 206 // Submenu click handler for the responsive menu 207 jQuery('.header_mobile .menu_main_nav, .menu_side_responsive, .menu_pushy_nav_area, body:not(.woocommerce) .widget_area:not(.footer_wrap) .widget_product_categories').on('click', 'li a,li a .open_child_menu, ul.product-categories.plain li a .open_child_menu', function(e) { 208 "use strict"; 209 var is_menu_main = jQuery(this).parents('.menu_main_nav').length > 0; 210 var $a = jQuery(this).hasClass('open_child_menu') ? jQuery(this).parent() : jQuery(this); 211 if ((!is_menu_main || jQuery('body').hasClass('menu_mobile')) && ($a.parent().hasClass('menu-item-has-children') || $a.parent().hasClass('has_children'))) { 212 if ($a.siblings('ul:visible').length > 0) 213 $a.siblings('ul').slideUp().parent().removeClass('opened'); 214 else { 215 jQuery(this).parents('li').siblings('li').find('ul:visible').slideUp().parent().removeClass('opened'); 216 $a.siblings('ul').slideDown().parent().addClass('opened'); 217 } 218 } 219 // Ignore link for parent menu items 220 if (jQuery(this).hasClass('open_child_menu') || $a.attr('href')=='#') { 221 e.preventDefault(); 222 return false; 223 } 224 }); 225 226 // Init superfish menus 227 vegadays_init_sfmenu('.menu_main_nav_area ul#menu_main, ul#menu_user, ul#menu_side, body:not(.woocommerce) .widget_area:not(.footer_wrap) .widget_product_categories ul.product-categories'); 228 229 // Slide effect for main menu 230 if (VEGADAYS_STORAGE['menu_hover']=='slide_line' || VEGADAYS_STORAGE['menu_hover']=='slide_box') { 231 setTimeout(function() { 232 "use strict"; 233 jQuery('#menu_main').spasticNav({ 234 style: VEGADAYS_STORAGE['menu_hover']=='slide_line' ? 'line' : 'box', 235 color: VEGADAYS_STORAGE['accent1_hover'], 236 colorOverride: false 237 }); 238 }, 500); 239 } 240 241 // Show table of contents for the current page 242 if (VEGADAYS_STORAGE['toc_menu'] != 'hide' && VEGADAYS_STORAGE['toc_menu'] != 'no') { 243 vegadays_build_page_toc(); 244 } 245 246 // One page mode for menu links (scroll to anchor) 247 jQuery('#toc, ul#menu_main li, ul#menu_user li, ul#menu_side li, ul#menu_footer li, ul#menu_pushy li').on('click', 'a', function(e) { 248 "use strict"; 249 var href = jQuery(this).attr('href'); 250 if (href===undefined) return; 251 var pos = href.indexOf('#'); 252 if (pos < 0 || href.length == 1) return; 253 if (jQuery(href.substr(pos)).length > 0) { 254 var loc = window.location.href; 255 var pos2 = loc.indexOf('#'); 256 if (pos2 > 0) loc = loc.substring(0, pos2); 257 var now = pos==0; 258 if (!now) now = loc == href.substring(0, pos); 259 if (now) { 260 vegadays_document_animate_to(href.substr(pos)); 261 vegadays_document_set_location(pos==0 ? loc + href : href); 262 e.preventDefault(); 263 return false; 264 } 265 } 266 }); 267 268 269 // Store height of the top and side panels 270 VEGADAYS_STORAGE['top_panel_height'] = 0; //Math.max(0, jQuery('.top_panel_wrap').height()); 271 VEGADAYS_STORAGE['side_panel_height'] = 0; 272 273 274 // Pagination 275 //---------------------------------------------- 276 277 // Page navigation (style slider) 278 jQuery('.pager_cur').on('click', function(e) { 279 "use strict"; 280 jQuery('.pager_slider').slideDown(300, function() { 281 vegadays_sc_init(jQuery('.pager_slider').eq(0)); 282 }); 283 e.preventDefault(); 284 return false; 285 }); 286 287 288 // View More button 289 jQuery('#viewmore_link').on('click', function(e) { 290 "use strict"; 291 if (!VEGADAYS_STORAGE['viewmore_busy'] && !jQuery(this).hasClass('viewmore_empty')) { 292 jQuery(this).parent().addClass('loading'); 293 VEGADAYS_STORAGE['viewmore_busy'] = true; 294 jQuery.post(VEGADAYS_STORAGE['ajax_url'], { 295 action: 'view_more_posts', 296 nonce: VEGADAYS_STORAGE['ajax_nonce'], 297 page: VEGADAYS_STORAGE['viewmore_page']+1, 298 data: VEGADAYS_STORAGE['viewmore_data'], 299 vars: VEGADAYS_STORAGE['viewmore_vars'] 300 }).done(function(response) { 301 "use strict"; 302 var rez = {};
303 try { 304 rez = JSON.parse(response); 305 } catch (e) { 306 rez = { error: VEGADAYS_STORAGE['ajax_error'] }; 307 console.log(response); 308 } 309 jQuery('#viewmore_link').parent().removeClass('loading'); 310 VEGADAYS_STORAGE['viewmore_busy'] = false; 311 if (rez.error === '') { 312 var posts_container = jQuery('.content').eq(0); 313 if (posts_container.find('.isotope_wrap').length > 0) posts_container = posts_container.find('.isotope_wrap').eq(0); 314 if (posts_container.hasClass('isotope_wrap')) { 315 posts_container.data('last-width', 0).append(rez.data); 316 VEGADAYS_STORAGE['isotope_init_counter'] = 0; 317 vegadays_init_appended_isotope(posts_container, rez.filters); 318 } else 319 jQuery('#viewmore').before(rez.data); 320 321 VEGADAYS_STORAGE['viewmore_page']++; 322 if (rez.no_more_data==1) { 323 jQuery('#viewmore_link').addClass('viewmore_empty').parent().hide(); 324 } 325 326 vegadays_init_post_formats(); 327 vegadays_sc_init(posts_container); 328 vegadays_scroll_actions(); 329 } 330 }); 331 } 332 e.preventDefault(); 333 return false; 334 }); 335 336 337 // WooCommerce 338 //---------------------------------------------- 339 340 // Change display mode 341 jQuery('.woocommerce,.woocommerce-page').on('click', '.mode_buttons a', function(e) { 342 "use strict"; 343 var mode = jQuery(this).hasClass('woocommerce_thumbs') ? 'thumbs' : 'list'; 344 jQuery.cookie('vegadays_shop_mode', mode, {expires: 365, path: '/'}); 345 jQuery(this).siblings('input').val(mode).parents('form').get(0).submit(); 346 e.preventDefault(); 347 return false; 348 }); 349 // Added to cart 350 jQuery('body').bind('added_to_cart', function() { 351 "use strict"; 352 // Update amount on the cart button 353 var total = jQuery('.widget_shopping_cart').eq(0).find('.total .amount').text(); 354 if (total != undefined) { 355 jQuery('.top_panel_cart_button .cart_summa').text(total); 356 } 357 // Update count items on the cart button 358 var cnt = 0; 359 jQuery('.widget_shopping_cart_content').eq(0).find('.cart_list li').each(function() { 360 var q = jQuery(this).find('.quantity').html().split(' ', 2); 361 if (!isNaN(q[0])) 362 cnt += Number(q[0]); 363 }); 364 var items = jQuery('.top_panel_cart_button .cart_items').eq(0).text().split(' ', 2); 365 items[0] = cnt; 366 jQuery('.top_panel_cart_button .cart_items').text(items[0]+' '+items[1]); 367 // Update data-attr on button 368 jQuery('.top_panel_cart_button').data({ 369 'items': cnt ? cnt : 0, 370 'summa': total ? total : 0 371 }); 372 }); 373 // Show cart 374 jQuery('.top_panel_middle .top_panel_cart_button, .header_mobile .top_panel_cart_button').on('click', function(e) { 375 "use strict"; 376 jQuery(this).siblings('.sidebar_cart').slideToggle(); 377 e.preventDefault(); 378 return false; 379 }); 380 // Add buttons to quantity 381 jQuery('.woocommerce div.quantity,.woocommerce-page div.quantity').append('<span class="q_inc"></span><span class="q_dec"></span>'); 382 jQuery('.woocommerce div.quantity').on('click', '>span', function(e) { 383 "use strict"; 384 var f = jQuery(this).siblings('input'); 385 if (jQuery(this).hasClass('q_inc')) { 386 f.val(Math.max(0, parseInt(f.val()))+1); 387 } else { 388 f.val(Math.max(1, Math.max(0, parseInt(f.val()))-1)); 389 } 390 jQuery('.actions .button').removeAttr('disabled'); 391 e.preventDefault(); 392 return false; 393 }); 394 // Add stretch behaviour to WooC tabs area 395 jQuery('.single-product .woocommerce-tabs') 396 .addClass('trx-stretch-width scheme_light') 397 .after('<div class="trx-stretch-width-original"></div>'); 398 vegadays_stretch_width(); 399 400 401 // Popup login and register windows 402 //---------------------------------------------- 403 jQuery('.popup_link,.popup_login_link,.popup_register_link').addClass('inited').on('click', function(e){ 404 var popup = jQuery(jQuery(this).attr('href')); 405 if (popup.length === 1) { 406 vegadays_hide_popup(jQuery(popup.hasClass('popup_login') ? '.popup_registration' : '.popup_login' )); 407 vegadays_show_popup(popup); 408 } 409 e.preventDefault(); 410 return false; 411 }); 412 jQuery('.popup_wrap').on('click', '.popup_close', function(e){ 413 var popup = jQuery(this).parent(); 414 if (popup.length === 1) { 415 vegadays_hide_popup(popup); 416 } 417 e.preventDefault(); 418 return false;
419 }); 420 421 422 // Bookmarks 423 //---------------------------------------------- 424 425 // Add bookmark 426 jQuery('.bookmarks_add').on('click', function(e) { 427 "use strict"; 428 var title = window.document.title.split('|')[0]; 429 var url = window.location.href; 430 var list = jQuery.cookie('vegadays_bookmarks'); 431 var exists = false; 432 if (list) { 433 try { 434 list = JSON.parse(list); 435 } catch (e) {} 436 if (list.length) { 437 for (var i=0; i<list.length; i++) { 438 if (list[i].url == url) { 439 exists = true; 440 break; 441 } 442 } 443 } 444 } else 445 list = new Array(); 446 if (!exists) { 447 var message_popup = vegadays_message_dialog('<label for="bookmark_title">'+VEGADAYS_STORAGE['strings']['bookmark_title']+'</label><br><input type="text" id="bookmark_title" name="bookmark_title" value="'+title+'">', VEGADAYS_STORAGE['strings']['bookmark_add'], null, 448 function(btn, popup) { 449 "use strict"; 450 if (btn != 1) return; 451 title = message_popup.find('#bookmark_title').val(); 452 list.push({title: title, url: url}); 453 jQuery('.bookmarks_list').append('<li><a href="'+url+'" class="bookmarks_item">'+title+'<span class="bookmarks_delete icon-cancel" title="'+VEGADAYS_STORAGE['strings']['bookmark_del']+'"></span></a></li>'); 454 jQuery.cookie('vegadays_bookmarks', JSON.stringify(list), {expires: 365, path: '/'}); 455 setTimeout(function () {vegadays_message_success(VEGADAYS_STORAGE['strings']['bookmark_added'], VEGADAYS_STORAGE['strings']['bookmark_add']);}, VEGADAYS_STORAGE['message_timeout']/4); 456 }); 457 } else 458 vegadays_message_warning(VEGADAYS_STORAGE['strings']['bookmark_exists'], VEGADAYS_STORAGE['strings']['bookmark_add']); 459 e.preventDefault(); 460 return false; 461 }); 462 463 // Delete bookmark 464 jQuery('.bookmarks_list').on('click', '.bookmarks_delete', function(e) { 465 "use strict"; 466 var idx = jQuery(this).parent().index(); 467 var list = jQuery.cookie('vegadays_bookmarks'); 468 if (list) { 469 try { 470 list = JSON.parse(list); 471 } catch (e) {} 472 if (list.length) { 473 list.splice(idx, 1); 474 jQuery.cookie('vegadays_bookmarks', JSON.stringify(list), {expires: 365, path: '/'}); 475 } 476 } 477 jQuery(this).parent().remove(); 478 e.preventDefault(); 479 return false; 480 }); 481 482 483 // Other settings 484 //------------------------------------ 485 486 // Scroll to top button 487 jQuery('.scroll_to_top').on('click', function(e) { 488 "use strict"; 489 jQuery('html,body').animate({ 490 scrollTop: 0 491 }, 'slow'); 492 e.preventDefault(); 493 return false; 494 }); 495 496 // AJAX views counter 497 if (VEGADAYS_STORAGE['ajax_views_counter'] !== undefined) { 498 setTimeout(function(){ 499 jQuery.post(VEGADAYS_STORAGE['ajax_url'], { 500 action: 'post_counter', 501 nonce: VEGADAYS_STORAGE['ajax_nonce'], 502 post_id: VEGADAYS_STORAGE['ajax_views_counter']['post_id'], 503 views: VEGADAYS_STORAGE['ajax_views_counter']['post_views'] 504 }); 505 }, 10); 506 } 507 508 // Show system message 509 vegadays_show_system_message(); 510 511 // Init post format specific scripts 512 vegadays_init_post_formats(); 513 514 // Call sc init action (if exists) 515 if (window.vegadays_sc_init_actions) vegadays_sc_init_actions(); 516 517 // Init hidden elements (if exists) 518 if (window.vegadays_init_hidden_elements) vegadays_init_hidden_elements(jQuery('body').eq(0)); 519 520} //end ready 521 522 523 524 525// Scroll actions 526//============================================== 527 528// Do actions when page scrolled 529function vegadays_scroll_actions() { 530 "use strict"; 531 532 // Call theme specific action (if exists) 533 //---------------------------------------------- 534 if (window.vegadays_theme_scroll_actions) vegadays_theme_scroll_actions(); 535 536 var scroll_offset = jQuery(window).scrollTop(); 537 var scroll_to_top_button = jQuery('.scroll_to_top'); 538 var adminbar_height = Math.max(0, jQuery('#wpadminbar').height()); 539 540 if (VEGADAYS_STORAGE['top_panel_height'] < 1) { 541 VEGADAYS_STORAGE['top_panel_height'] = Math.max(0, jQuery('.top_panel_wrap').height()); 542 } 543 544 // Scroll to top button show/hide 545 if (scroll_offset > VEGADAYS_STORAGE['top_panel_height']) 546 scroll_to_top_button.addClass('show'); 547 else 548 scroll_to_top_button.removeClass('show'); 549 550 // Fix/unfix top panel 551 if (!jQuery('body').hasClass('menu_mobile') && VEGADAYS_STORAGE['menu_fixed']) { 552 var slider_height = 0; 553 if (jQuery('.top_panel_below .slider_wrap').length > 0) { 554 slider_height = jQuery('.top_panel_below .slider_wrap').height(); 555 if (slider_height < 10) { 556 slider_height = jQuery('.slider_wrap').hasClass('.slider_fullscreen') ? jQuery(window).height() : VEGADAYS_STORAGE['slider_height']; 557 } 558 } 559 if (scroll_offset <= slider_height + VEGADAYS_STORAGE['top_panel_height']) { 560 if (jQuery('body').hasClass('top_panel_fixed')) { 561 jQuery('body').removeClass('top_panel_fixed'); 562 } 563 } else if (scroll_offset > slider_height + VEGADAYS_STORAGE['top_panel_height']) { 564 if (!jQuery('body').hasClass('top_panel_fixed') && jQuery(document).height() > jQuery(window).height()*1.5) { 565 jQuery('.top_panel_fixed_wrap').height(VEGADAYS_STORAGE['top_panel_height']); 566 jQuery('.top_panel_wrap').css('marginTop', '-150px').animate({'marginTop': 0}, 500); 567 jQuery('body').addClass('top_panel_fixed'); 568 } 569 } 570 } 571 572 // Fix/unfix side panel 573 if (jQuery('.sidebar_outer').length > 0) { 574 if (VEGADAYS_STORAGE['side_panel_height'] == 0) 575 VEGADAYS_STORAGE['side_panel_height'] = jQuery('.sidebar_outer_logo_wrap').outerHeight() + jQuery('.sidebar_outer_menu').outerHeight() + jQuery('.sidebar_outer_widgets').outerHeight(); 576 if (scroll_offset + jQuery(window).height() > VEGADAYS_STORAGE['side_panel_height'] + 100) { 577 if (jQuery('.sidebar_outer').css('position')!=='fixed') { 578 jQuery('.sidebar_outer').css({ 579 'position': 'fixed', 580 'top': Math.min(0, jQuery(window).height() - VEGADAYS_STORAGE['side_panel_height'] - 100) + 'px', 581 }); 582 } 583 } else { 584 if (jQuery('.sidebar_outer').css('position')=='fixed') { 585 jQuery('.sidebar_outer').css({ 586 'position': 'absolute', 587 'top': 0 588 }); 589 } 590 } 591 } 592 593 // TOC current items 594 jQuery('#toc .toc_item').each(function() { 595 "use strict"; 596 var id = jQuery(this).find('a').attr('href'); 597 var pos = id.indexOf('#'); 598 if (pos < 0 || id.length == 1) return; 599 var loc = window.location.href; 600 var pos2 = loc.indexOf('#'); 601 if (pos2 > 0) loc = loc.substring(0, pos2); 602 var now = pos==0; 603 if (!now) now = loc == href.substring(0, pos); 604 if (!now) return; 605 var off = jQuery(id).offset().top; 606 var id_next = jQuery(this).next().find('a').attr('href'); 607 var off_next = id_next ? jQuery(id_next).offset().top : 1000000; 608 if (off < scroll_offset + jQuery(window).height()*0.8 && scroll_offset + VEGADAYS_STORAGE['top_panel_height'] < off_next) 609 jQuery(this).addClass('current'); 610 else 611 jQuery(this).removeClass('current'); 612 }); 613 614 // Infinite pagination 615 vegadays_infinite_scroll() 616 617 // Parallax scroll 618 vegadays_parallax_scroll(); 619 620 // Call sc scroll actions (if exists) 621 if (window.vegadays_sc_scroll_actions) vegadays_sc_scroll_actions(); 622} 623 624 625// Infinite Scroll 626function vegadays_infinite_scroll() { 627 "use strict"; 628 if (VEGADAYS_STORAGE['viewmore_busy']) return; 629 var infinite = jQuery('#viewmore.pagination_infinite'); 630 if (infinite.length > 0) { 631 var viewmore = infinite.find('#viewmore_link:not(.viewmore_empty)'); 632 if (viewmore.length > 0) { 633 if (jQuery(window).scrollTop() + jQuery(window).height() + 100 >= infinite.offset().top) { 634 viewmore.eq(0).trigger('click'); 635 } 636 } 637 } 638} 639 640// Parallax scroll 641function vegadays_parallax_scroll(){ 642 jQuery('.sc_parallax').each(function(){ 643 var windowHeight = jQuery(window).height(); 644 var scrollTops = jQuery(window).scrollTop(); 645 var offsetPrx = Math.max(jQuery(this).offset().top, windowHeight); 646 if ( offsetPrx <= scrollTops + windowHeight ) { 647 var speed = Number(jQuery(this).data('parallax-speed')); 648 var xpos = jQuery(this).data('parallax-x-pos'); 649 var ypos = Math.round((offsetPrx - scrollTops - windowHeight) * speed + (speed < 0 ? windowHeight*speed : 0)); 650 jQuery(this).find('.sc_parallax_content').css('backgroundPosition', xpos+' '+ypos+'px'); 651 // Uncomment next line if you want parallax video (else - video position is static) 652 jQuery(this).find('div.sc_video_bg').css('top', ypos+'px'); 653 } 654 }); 655} 656 657 658 659 660 661// Resize actions 662//============================================== 663 664// Do actions when page scrolled 665function vegadays_resize_actions() { 666 "use strict"; 667 668 // Call theme specific action (if exists) 669 //---------------------------------------------- 670 if (window.vegadays_theme_resize_actions) vegadays_theme_resize_actions(); 671 672 // Reset stored value 673 VEGADAYS_STORAGE['top_panel_height'] = 0; 674 675 vegadays_responsive_menu(); 676 vegadays_vc_row_fullwidth_to_boxed(); 677 vegadays_video_dimensions(); 678 vegadays_resize_video_background(); 679 vegadays_resize_fullscreen_slider(); 680 vegadays_resize_alter_portfolio(); 681 vegadays_stretch_width(); 682 683 // Call sc resize actions (if exists) 684 if (window.vegadays_sc_resize_actions) vegadays_sc_resize_actions(); 685} 686 687// Stretch area to full window width 688function vegadays_stretch_width() { 689 jQuery('.trx-stretch-width').each(function() { 690 var $el = jQuery(this); 691 var $el_full = $el.next('.trx-stretch-width-original'); 692 var el_margin_left = parseInt( $el.css( 'margin-left' ), 10 ); 693 var el_margin_right = parseInt( $el.css( 'margin-right' ), 10 ); 694 var offset = 0 - $el_full.offset().left - el_margin_left; 695 var width = jQuery( window ).width(); 696 if (!$el.hasClass('inited')) { 697 $el.addClass('inited invisible'); 698 $el.css({ 699 'position': 'relative', 700 'box-sizing': 'border-box' 701 }); 702 } 703 $el.css({ 704 'left': offset, 705 'width': jQuery( window ).width() 706 }); 707 if ( !$el.hasClass('trx-stretch-content') ) { 708 var padding = Math.max(0, -1*offset); 709 var paddingRight = Math.max(0, width - padding - $el_full.width() + el_margin_left + el_margin_right); 710 $el.css( { 'padding-left': padding + 'px', 'padding-right': paddingRight + 'px' } ); 711 } 712 $el.removeClass('invisible'); 713 }); 714} 715 716// Width vc_row when content boxed 717function vegadays_vc_row_fullwidth_to_boxed(){ 718 "use strict"; 719 if (jQuery('body').hasClass('body_style_boxed')) { 720 var width_body = jQuery('body').width(); 721 var width_content = jQuery('.page_wrap').width(); 722 var width_content_wrap = jQuery('.page_content_wrap .content_wrap').width(); 723 var indent = ( width_content - width_content_wrap ) / 2; 724 if ( width_body > width_content ){ 725 jQuery('.vc_row[data-vc-full-width="true"]').each( function() { 726 "use strict";
727 var mrg = parseInt(jQuery(this).css('marginLeft')); 728 jQuery(this).css({ 729 'width': width_content, 730 'left': -indent-mrg, 731 'padding-left': indent+mrg, 732 'padding-right': indent+mrg 733 }); 734 if (jQuery(this).attr('data-vc-stretch-content')) { 735 jQuery(this).css({ 736 'padding-left': 0, 737 'padding-right': 0 738 }); 739 } 740 }); 741 } 742 } 743} 744 745// Check window size and do responsive menu 746function vegadays_responsive_menu() { 747 "use strict"; 748 if (vegadays_is_responsive_need(VEGADAYS_STORAGE['menu_mobile'])) { 749 if (!jQuery('body').hasClass('menu_mobile')) { 750 jQuery('body').removeClass('top_panel_fixed').addClass('menu_mobile'); 751 jQuery('header.top_panel_wrap ').hide(); 752 jQuery('.header_mobile').show(); 753 754 jQuery('header #popup_login').attr('id', 'popup_login_1'); 755 jQuery('header #popup_registration').attr('id', 'popup_registration_1'); 756 jQuery('.header_mobile #popup_login_1').attr('id', 'popup_login'); 757 jQuery('.header_mobile #popup_registration_1').attr('id', 'popup_registration'); 758 } 759 } else { 760 if (jQuery('body').hasClass('menu_mobile')) { 761 jQuery('body').removeClass('menu_mobile'); 762 jQuery('header.top_panel_wrap ').show(); 763 jQuery('.header_mobile').hide(); 764 765 jQuery('header #popup_login_1').attr('id', 'popup_login'); 766 jQuery('header #popup_registration_1').attr('id', 'popup_registration'); 767 jQuery('.header_mobile #popup_login').attr('id', 'popup_login_1'); 768 jQuery('.header_mobile #popup_registration').attr('id', 'popup_registration_1'); 769 } 770 } 771 772 if (jQuery(window).width() < 640) { 773 var pass = jQuery('.header_mobile .popup_wrap.popup_registration .registration_form > .form_right'); 774 if(pass.length > 0){ 775 jQuery('.header_mobile .popup_wrap.popup_registration .form_left .popup_form_field.email_field').after(pass); 776 } 777 } 778 else{ 779 var pass = jQuery('.header_mobile .popup_wrap.popup_registration .form_left > .form_right'); 780 if(pass.length > 0){ 781 jQuery('.header_mobile .popup_wrap.popup_registration .registration_form').append(pass); 782 } 783 } 784 785 if (!jQuery('.top_panel_wrap').hasClass('menu_show')) jQuery('.top_panel_wrap').addClass('menu_show'); 786 // Show widgets block on the sidebar outer (if sidebar not responsive and widgets are hidden) 787 if (jQuery('.sidebar_outer').length > 0 && jQuery('.sidebar_outer').css('position')=='absolute' && jQuery('.sidebar_outer_widgets:visible').length==0) 788 jQuery('.sidebar_outer_widgets').show(); 789 // Switch popup menu / hierarchical list on product categories list placed in sidebar 790 var cat_menu = jQuery('body:not(.woocommerce) .widget_area:not(.footer_wrap) .widget_product_categories ul.product-categories'); 791 var sb = cat_menu.parents('.widget_area'); 792 if (sb.length > 0 && cat_menu.length > 0) { 793 if (sb.width() == sb.parents('.content_wrap').width()) { 794 if (cat_menu.hasClass('inited')) { 795 cat_menu.removeClass('inited').addClass('plain').superfish('destroy'); 796 cat_menu.find('ul.animated').removeClass('animated').addClass('no_animated'); 797 } 798 } else { 799 if (!cat_menu.hasClass('inited')) { 800 cat_menu.removeClass('plain').addClass('inited'); 801 cat_menu.find('ul.no_animated').removeClass('no_animated').addClass('animated'); 802 vegadays_init_sfmenu('body:not(.woocommerce) .widget_area:not(.footer_wrap) .widget_product_categories ul.product-categories'); 803 } 804 } 805 } 806} 807 808 809// Check if responsive menu need 810function vegadays_is_responsive_need(max_width) { 811 "use strict"; 812 var rez = false; 813 if (max_width > 0) { 814 var w = window.innerWidth; 815 if (w == undefined) { 816 w = jQuery(window).width()+(jQuery(window).height() < jQuery(document).height() || jQuery(window).scrollTop() > 0 ? 16 : 0); 817 } 818 rez = max_width > w; 819 } 820 return rez; 821} 822 823 824// Fit video frames to document width 825function vegadays_video_dimensions() { 826 jQuery('.sc_video_frame').each(function() { 827 "use strict"; 828 if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return; 829 var frame = jQuery(this).eq(0); 830 var player = frame.parent(); 831 var ratio = (frame.data('ratio') ? frame.data('ratio').split(':') : (frame.find('[data-ratio]').length>0 ? frame.find('[data-ratio]').data('ratio').split(':') : [16,9])); 832 ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1]; 833 var w_attr = frame.data('width'); 834 var h_attr = frame.data('height'); 835 if (!w_attr || !h_attr) return; 836 var percent = (''+w_attr).substr(-1)=='%'; 837 w_attr = parseInt(w_attr); 838 h_attr = parseInt(h_attr); 839 var w_real = Math.min(percent || frame.parents('.columns_wrap').length>0 ? 10000 : w_attr, frame.parents('div,article').width()), //player.width(); 840 h_real = Math.round(percent ? w_real/ratio : w_real/w_attr*h_attr); 841 if (parseInt(frame.attr('data-last-width'))==w_real) return; 842 if (percent) { 843 frame.height(h_real); 844 } else { 845 frame.css({'width': w_real+'px', 'height': h_real+'px'}); 846 } 847 frame.attr('data-last-width', w_real); 848 }); 849 jQuery('video.sc_video,video.wp-video-shortcode').each(function() { 850 "use strict"; 851 if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return; 852 var video = jQuery(this).eq(0); 853 var ratio = (video.data('ratio')!=undefined ? video.data('ratio').split(':') : [16,9]); 854 ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1]; 855 var mejs_cont = video.parents('.mejs-video'); 856 var frame = video.parents('.sc_video_frame'); 857 var w_attr = frame.length>0 ? frame.data('width') : video.data('width'); 858 var h_attr = frame.length>0 ? frame.data('height') : video.data('height'); 859 if (!w_attr || !h_attr) { 860 w_attr = video.attr('width'); 861 h_attr = video.attr('height'); 862 if (!w_attr || !h_attr) return;
863 video.data({'width': w_attr, 'height': h_attr}); 864 } 865 var percent = (''+w_attr).substr(-1)=='%'; 866 w_attr = parseInt(w_attr); 867 h_attr = parseInt(h_attr); 868 var w_real = Math.round(mejs_cont.length > 0 ? Math.min(percent ? 10000 : w_attr, mejs_cont.parents('div,article').width()) : video.width()), 869 h_real = Math.round(percent ? w_real/ratio : w_real/w_attr*h_attr); 870 if (parseInt(video.attr('data-last-width'))==w_real) return; 871 if (mejs_cont.length > 0 && mejs) { 872 vegadays_set_mejs_player_dimensions(video, w_real, h_real); 873 } 874 if (percent) { 875 video.height(h_real); 876 } else { 877 video.attr({'width': w_real, 'height': h_real}).css({'width': w_real+'px', 'height': h_real+'px'}); 878 } 879 video.attr('data-last-width', w_real); 880 }); 881 jQuery('video.sc_video_bg').each(function() { 882 "use strict"; 883 if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return; 884 var video = jQuery(this).eq(0); 885 var ratio = (video.data('ratio')!=undefined ? video.data('ratio').split(':') : [16,9]); 886 ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1]; 887 var mejs_cont = video.parents('.mejs-video'); 888 var container = mejs_cont.length>0 ? mejs_cont.parent() : video.parent(); 889 var w = container.width(); 890 var h = container.height(); 891 var w1 = Math.ceil(h*ratio); 892 var h1 = Math.ceil(w/ratio); 893 if (video.parents('.sc_parallax').length > 0) { 894 var windowHeight = jQuery(window).height(); 895 var speed = Number(video.parents('.sc_parallax').data('parallax-speed')); 896 var h_add = Math.ceil(Math.abs((windowHeight-h)*speed)); 897 if (h1 < h + h_add) { 898 h1 = h + h_add; 899 w1 = Math.ceil(h1 * ratio); 900 } 901 } 902 if (h1 < h) { 903 h1 = h; 904 w1 = Math.ceil(h1 * ratio); 905 } 906 if (w1 < w) { 907 w1 = w; 908 h1 = Math.ceil(w1 / ratio); 909 } 910 var l = Math.round((w1-w)/2); 911 var t = Math.round((h1-h)/2); 912 if (parseInt(video.attr('data-last-width'))==w1) return; 913 if (mejs_cont.length > 0) { 914 vegadays_set_mejs_player_dimensions(video, w1, h1); 915 mejs_cont.css({ 916 //'left': -l+'px', 917 'top': -t+'px' 918 }); 919 } else 920 video.css({ 921 //'left': -l+'px', 922 'top': -t+'px' 923 }); 924 video.attr({'width': w1, 'height': h1, 'data-last-width':w1}).css({'width':w1+'px', 'height':h1+'px'}); 925 if (video.css('opacity')==0) video.animate({'opacity': 1}, 3000); 926 }); 927 jQuery('iframe').each(function() { 928 "use strict"; 929 if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return; 930 var iframe = jQuery(this).eq(0); 931 var ratio = (iframe.data('ratio')!=undefined ? iframe.data('ratio').split(':') : (iframe.find('[data-ratio]').length>0 ? iframe.find('[data-ratio]').data('ratio').split(':') : [16,9])); 932 ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1]; 933 var w_attr = iframe.attr('width'); 934 var h_attr = iframe.attr('height'); 935 var frame = iframe.parents('.sc_video_frame'); 936 if (frame.length > 0) { 937 w_attr = frame.data('width'); 938 h_attr = frame.data('height'); 939 } 940 if (!w_attr || !h_attr) { 941 return; 942 } 943 var percent = (''+w_attr).substr(-1)=='%'; 944 w_attr = parseInt(w_attr); 945 h_attr = parseInt(h_attr); 946 var w_real = frame.length > 0 ? frame.width() : iframe.width(), 947 h_real = Math.round(percent ? w_real/ratio : w_real/w_attr*h_attr); 948 if (parseInt(iframe.attr('data-last-width'))==w_real) return; 949 iframe.css({'width': w_real+'px', 'height': h_real+'px'}); 950 }); 951} 952 953// Resize fullscreen video background 954function vegadays_resize_video_background() { 955 "use strict"; 956 var bg = jQuery('.video_bg'); 957 if (bg.length < 1) 958 return; 959 if (VEGADAYS_STORAGE['media_elements_enabled'] && bg.find('.mejs-video').length == 0) { 960 setTimeout(vegadays_resize_video_background, 100); 961 return; 962 } 963 var video = bg.find('video'); 964 var ratio = (video.data('ratio')!=undefined ? video.data('ratio').split(':') : [16,9]); 965 ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1]; 966 var w = bg.width(); 967 var h = bg.height(); 968 var w1 = Math.ceil(h*ratio); 969 var h1 = Math.ceil(w/ratio); 970 if (h1 < h) { 971 h1 = h; 972 w1 = Math.ceil(h1 * ratio); 973 } 974 if (w1 < w) { 975 w1 = w; 976 h1 = Math.ceil(w1 / ratio); 977 } 978 var l = Math.round((w1-w)/2); 979 var t = Math.round((h1-h)/2); 980 if (bg.find('.mejs-container').length > 0) { 981 vegadays_set_mejs_player_dimensions(bg.find('video'), w1, h1);
982 bg.find('.mejs-container').css({'left': -l+'px', 'top': -t+'px'}); 983 } else 984 bg.find('video').css({'left': -l+'px', 'top': -t+'px'}); 985 bg.find('video').attr({'width': w1, 'height': h1}).css({'width':w1+'px', 'height':h1+'px'}); 986} 987 988// Set Media Elements player dimensions 989function vegadays_set_mejs_player_dimensions(video, w, h) { 990 "use strict"; 991 if (mejs) { 992 for (var pl in mejs.players) { 993 if (mejs.players[pl].media.src == video.attr('src')) { 994 if (mejs.players[pl].media.setVideoSize) { 995 mejs.players[pl].media.setVideoSize(w, h); 996 } 997 mejs.players[pl].setPlayerSize(w, h); 998 mejs.players[pl].setControlsSize(); 999 } 1000 } 1001 } 1002} 1003 1004// Resize Fullscreen Slider 1005function vegadays_resize_fullscreen_slider() { 1006 "use strict"; 1007 var slider_wrap = jQuery('.slider_wrap.slider_fullscreen'); 1008 if (slider_wrap.length < 1) 1009 return; 1010 var slider = slider_wrap.find('.sc_slider_swiper'); 1011 if (slider.length < 1) 1012 return; 1013 var h = jQuery(window).height() - jQuery('#wpadminbar').height() - (jQuery('body').hasClass('top_panel_above') && !jQuery('body').hasClass('.top_panel_fixed') ? jQuery('.top_panel_wrap').height() : 0); 1014 slider.height(h); 1015} 1016 1017// Resize Alter portfolio elements 1018function vegadays_resize_alter_portfolio() { 1019 "use strict"; 1020 var wrap = jQuery('.isotope_wrap.inited'); 1021 if (wrap.length==0) return; 1022 wrap.each(function() { 1023 "use strict"; 1024 var alter = jQuery(this).find('.post_item_alter'); 1025 if (alter.length==0) return; 1026 var single = alter.find('.post_featured img[data-alter-items-w="1"]').eq(0); 1027 if (single.length != 1) return; 1028 var w_real = single.width(); 1029 var h_real = single.height(); 1030 var space = Number(single.data('alter-item-space')); 1031 var relayout = false; 1032 alter.find('.post_featured img').each(function() { 1033 "use strict"; 1034 var items_w = Number(jQuery(this).data('alter-items-w')); 1035 var items_h = Number(jQuery(this).data('alter-items-h')); 1036 if (items_h > 1) { 1037 jQuery(this).height(Math.round(items_h*h_real+(items_h-1)*(space+1))); 1038 relayout = true; 1039 } else if (items_w > 1) { 1040 jQuery(this).height(h_real); 1041 relayout = true; 1042 } 1043 }); 1044 if (relayout) { 1045 jQuery(this).isotope('layout'); 1046 } 1047 }); 1048} 1049 1050 1051 1052 1053 1054// Navigation 1055//============================================== 1056 1057// Init Superfish menu 1058function vegadays_init_sfmenu(selector) { 1059 jQuery(selector).show().each(function() { 1060 if (vegadays_is_responsive_need() && (jQuery(this).attr('id')=='menu_main' || jQuery(this).attr('id')=='menu_side')) return; 1061 jQuery(this).addClass('inited').superfish({ 1062 delay: 500, 1063 animation: { 1064 opacity: 'show' 1065 }, 1066 animationOut: { 1067 opacity: 'hide' 1068 }, 1069 speed: VEGADAYS_STORAGE['css_animation'] ? 500 : 200, 1070 speedOut: VEGADAYS_STORAGE['css_animation'] ? 500 : 200,
1071 autoArrows: false, 1072 dropShadows: false, 1073 onBeforeShow: function(ul) { 1074 if (jQuery(this).parents("ul").length > 1){ 1075 var w = jQuery(window).width(); 1076 var par_offset = jQuery(this).parents("ul").offset().left; 1077 var par_width = jQuery(this).parents("ul").outerWidth(); 1078 var ul_width = jQuery(this).outerWidth(); 1079 if (par_offset+par_width+ul_width > w-20 && par_offset-ul_width > 0) 1080 jQuery(this).addClass('submenu_left'); 1081 else 1082 jQuery(this).removeClass('submenu_left'); 1083 } 1084 if (VEGADAYS_STORAGE['css_animation']) { 1085 jQuery(this).removeClass('animated fast '+VEGADAYS_STORAGE['menu_animation_out']); 1086 jQuery(this).addClass('animated fast '+VEGADAYS_STORAGE['menu_animation_in']); 1087 } 1088 }, 1089 onBeforeHide: function(ul) { 1090 if (VEGADAYS_STORAGE['css_animation']) { 1091 jQuery(this).removeClass('animated fast '+VEGADAYS_STORAGE['menu_animation_in']); 1092 jQuery(this).addClass('animated fast '+VEGADAYS_STORAGE['menu_animation_out']); 1093 } 1094 } 1095 }); 1096 }); 1097} 1098 1099 1100// Build page TOC from the tag's id 1101function vegadays_build_page_toc() { 1102 "use strict"; 1103 var toc = '', toc_count = 0; 1104 jQuery('[id^="toc_"],.sc_anchor').each(function(idx) { 1105 "use strict"; 1106 var obj = jQuery(this); 1107 var id = obj.attr('id'); 1108 var url = obj.data('url'); 1109 var icon = obj.data('icon'); 1110 if (!icon) icon = 'icon-circle-dot'; 1111 var title = obj.attr('title'); 1112 var description = obj.data('description'); 1113 var separator = obj.data('separator'); 1114 toc_count++; 1115 toc += '<div class="toc_item'+(separator=='yes' ? ' toc_separator' : '')+'">' 1116 +(description ? '<div class="toc_description">'+description+'</div>' : '') 1117 +'<a href="'+(url ? url : '#'+id)+'" class="toc_icon'+(title ? ' with_title' : '')+' '+icon+'">'+(title ? '<span class="toc_title">'+title+'</span>' : '')+'</a>' 1118 +'</div>'; 1119 }); 1120 if (toc_count > (VEGADAYS_STORAGE['toc_menu_home'] ? 1 : 0) + (VEGADAYS_STORAGE['toc_menu_top'] ? 1 : 0)) { 1121 if (jQuery('#toc').length > 0) 1122 jQuery('#toc .toc_inner').html(toc); 1123 else 1124 jQuery('body').append('<div id="toc" class="toc_'+VEGADAYS_STORAGE['toc_menu']+'"><div class="toc_inner">'+toc+'</div></div>'); 1125 } 1126} 1127 1128 1129// Show current page title on the responsive menu button 1130function vegadays_show_current_menu_item(menu, button) { 1131 "use strict"; 1132 menu.find('a').each(function () { 1133 var menu_link = jQuery(this); 1134 if (menu_link.text() == "") { 1135 return; 1136 } 1137 if (menu_link.attr('href') == window.location.href) 1138 button.text(menu_link.text()); 1139 }); 1140} 1141 1142 1143 1144// Isotope 1145//===================================================== 1146 1147// First init isotope containers 1148function vegadays_init_isotope() { 1149 "use strict"; 1150 1151 var all_images_complete = true; 1152 1153 // Check if all images in isotope wrapper are loaded 1154 jQuery('.isotope_wrap:not(.inited)').each(function () { 1155 "use strict"; 1156 all_images_complete = all_images_complete && vegadays_check_images_complete(jQuery(this)); 1157 }); 1158 // Wait for images loading 1159 if (!all_images_complete && VEGADAYS_STORAGE['isotope_init_counter']++ < 30) { 1160 setTimeout(vegadays_init_isotope, 200); 1161 return; 1162 } 1163 1164 // Isotope filters handler 1165 jQuery('.isotope_filters:not(.inited)').addClass('inited').on('click', 'a', function(e) { 1166 "use strict"; 1167 jQuery(this).parents('.isotope_filters').find('a').removeClass('active'); 1168 jQuery(this).addClass('active'); 1169 1170 var selector = jQuery(this).data('filter'); 1171 jQuery(this).parents('.isotope_filters').siblings('.isotope_wrap').eq(0).isotope({ 1172 filter: selector 1173 }); 1174 1175 if (selector == '*') 1176 jQuery('#viewmore_link').fadeIn(); 1177 else 1178 jQuery('#viewmore_link').fadeOut(); 1179 1180 e.preventDefault(); 1181 return false; 1182 }); 1183 1184 // Init isotope script 1185 jQuery('.isotope_wrap:not(.inited)').each(function() { 1186 "use strict"; 1187 1188 var isotope_container = jQuery(this); 1189 1190 // Init shortcodes 1191 vegadays_sc_init(isotope_container); 1192 1193 // If in scroll container - no init isotope 1194 if (isotope_container.parents('.sc_scroll').length > 0) { 1195 isotope_container.addClass('inited').find('.isotope_item').animate({opacity: 1}, 200, function () { jQuery(this).addClass('isotope_item_show'); }); 1196 return; 1197 } 1198 1199 // Init isotope with timeout 1200 setTimeout(function() { 1201 isotope_container.addClass('inited').isotope({ 1202 itemSelector: '.isotope_item', 1203 animationOptions: { 1204 duration: 750, 1205 easing: 'linear', 1206 queue: false 1207 } 1208 }); 1209 1210 // Show elements 1211 isotope_container.find('.isotope_item').animate({opacity: 1}, 200, function () { 1212 jQuery(this).addClass('isotope_item_show'); 1213 }); 1214 1215 // Resize Alter portfolio elements 1216 vegadays_resize_alter_portfolio(); 1217 1218 }, 500); 1219 1220 }); 1221} 1222 1223function vegadays_init_appended_isotope(posts_container, filters) { 1224 "use strict"; 1225 1226 if (posts_container.parents('.sc_scroll_horizontal').length > 0) return; 1227 1228 if (!vegadays_check_images_complete(posts_container) && VEGADAYS_STORAGE['isotope_init_counter']++ < 30) { 1229 setTimeout(function() { vegadays_init_appended_isotope(posts_container, filters); }, 200); 1230 return; 1231 }
1232 // Add filters 1233 var flt = posts_container.siblings('.isotope_filter'); 1234 for (var i in filters) { 1235 if (flt.find('a[data-filter=".flt_'+i+'"]').length == 0) { 1236 flt.append('<a href="#" class="isotope_filters_button" data-filter=".flt_'+i+'">'+filters[i]+'</a>'); 1237 } 1238 } 1239 // Init shortcodes in added elements 1240 vegadays_sc_init(posts_container); 1241 // Get added elements 1242 var elems = posts_container.find('.isotope_item:not(.isotope_item_show)'); 1243 // Notify isotope about added elements with timeout 1244 setTimeout(function() { 1245 posts_container.isotope('appended', elems); 1246 // Show appended elements 1247 elems.animate({opacity: 1}, 200, function () { jQuery(this).addClass('isotope_item_show'); }); 1248 }, 500); 1249} 1250 1251 1252 1253// Post formats init 1254//===================================================== 1255 1256function vegadays_init_post_formats() { 1257 "use strict"; 1258 1259 // Call theme specific action (if exists) 1260 if (window.vegadays_theme_init_post_formats) vegadays_theme_init_post_formats(); 1261 1262 // MediaElement init 1263 vegadays_init_media_elements(jQuery('body')); 1264 1265 // Isotope first init 1266 if (jQuery('.isotope_wrap:not(.inited)').length > 0) { 1267 VEGADAYS_STORAGE['isotope_init_counter'] = 0; 1268 vegadays_init_isotope(); 1269 } 1270 1271 // Hover Effect 'Dir' 1272 if (jQuery('.isotope_wrap .isotope_item_content.square.effect_dir:not(.inited)').length > 0) { 1273 jQuery('.isotope_wrap .isotope_item_content.square.effect_dir:not(.inited)').each(function() { 1274 jQuery(this).addClass('inited').hoverdir(); 1275 }); 1276 } 1277 1278 // Popup init 1279 if (VEGADAYS_STORAGE['popup_engine'] == 'pretty') { 1280 jQuery("a[href$='jpg'],a[href$='jpeg'],a[href$='png'],a[href$='gif']").attr('rel', 'prettyPhoto[slideshow]'); 1281 var images = jQuery("a[rel*='prettyPhoto']:not(.inited):not(.esgbox):not([data-rel*='pretty']):not([rel*='magnific']):not([data-rel*='magnific'])").addClass('inited'); 1282 try { 1283 images.prettyPhoto({ 1284 social_tools: '', 1285 theme: 'facebook', 1286 deeplinking: false 1287 }); 1288 } catch (e) {}; 1289 } else if (VEGADAYS_STORAGE['popup_engine']=='magnific') { 1290 jQuery("a[href$='jpg'],a[href$='jpeg'],a[href$='png'],a[href$='gif']").attr('rel', 'magnific'); 1291 var images = jQuery("a[rel*='magnific']:not(.inited):not(.esgbox):not(.prettyphoto):not([rel*='pretty']):not([data-rel*='pretty'])").addClass('inited'); 1292 try { 1293 images.magnificPopup({ 1294 type: 'image', 1295 mainClass: 'mfp-img-mobile', 1296 closeOnContentClick: true, 1297 closeBtnInside: true, 1298 fixedContentPos: true, 1299 midClick: true, 1300 //removalDelay: 500, 1301 preloader: true, 1302 tLoading: VEGADAYS_STORAGE['strings']['magnific_loading'], 1303 gallery:{ 1304 enabled: true 1305 }, 1306 image: { 1307 tError: VEGADAYS_STORAGE['strings']['magnific_error'], 1308 verticalFit: true 1309 } 1310 }); 1311 } catch (e) {}; 1312 } 1313 1314 1315 // Add hover icon to products thumbnails 1316 jQuery(".post_item_product .product .images a.woocommerce-main-image:not(.hover_icon)").addClass('hover_icon hover_icon_view'); 1317 1318 1319 // Likes counter 1320 if (jQuery('.post_counters_likes:not(.inited)').length > 0) { 1321 jQuery('.post_counters_likes:not(.inited)') 1322 .addClass('inited') 1323 .on('click', function(e) { 1324 var button = jQuery(this); 1325 var inc = button.hasClass('enabled') ? 1 : -1; 1326 var post_id = button.data('postid'); 1327 var likes = Number(button.data('likes'))+inc; 1328 var cookie_likes = vegadays_get_cookie('vegadays_likes'); 1329 if (cookie_likes === undefined || cookie_likes===null) cookie_likes = ''; 1330 jQuery.post(VEGADAYS_STORAGE['ajax_url'], { 1331 action: 'post_counter', 1332 nonce: VEGADAYS_STORAGE['ajax_nonce'], 1333 post_id: post_id, 1334 likes: likes 1335 }).done(function(response) { 1336 var rez = {}; 1337 try { 1338 rez = JSON.parse(response); 1339 } catch (e) { 1340 rez = { error: VEGADAYS_STORAGE['ajax_error'] }; 1341 console.log(response); 1342 } 1343 if (rez.error === '') { 1344 if (inc == 1) { 1345 var title = button.data('title-dislike'); 1346 button.removeClass('enabled').addClass('disabled'); 1347 cookie_likes += (cookie_likes.substr(-1)!=',' ? ',' : '') + post_id + ','; 1348 } else { 1349 var title = button.data('title-like'); 1350 button.removeClass('disabled').addClass('enabled'); 1351 cookie_likes = cookie_likes.replace(','+post_id+',', ','); 1352 }
1353 button.data('likes', likes).attr('title', title).find('.post_counters_number').html(likes); 1354 vegadays_set_cookie('vegadays_likes', cookie_likes, 365); 1355 } else { 1356 vegadays_message_warning(VEGADAYS_STORAGE['strings']['error_like']); 1357 } 1358 }); 1359 e.preventDefault(); 1360 return false; 1361 }); 1362 } 1363 1364 // Social share links 1365 if (jQuery('.sc_socials_share:not(.inited)').length > 0) { 1366 jQuery('.sc_socials_share:not(.inited)').each(function() { 1367 "use strict"; 1368 jQuery(this).addClass('inited').on('click', '.social_item_popup > a.social_icons', function(e) { 1369 "use strict"; 1370 var url = jQuery(this).data('link'); 1371 window.open(url, '_blank', 'scrollbars=0, resizable=1, menubar=0, left=100, top=100, width=480, height=400, toolbar=0, status=0'); 1372 e.preventDefault(); 1373 return false; 1374 }); 1375 }); 1376 } 1377 1378 // Add video on thumb click 1379 if (jQuery('.sc_video_play_button:not(.inited)').length > 0) { 1380 jQuery('.sc_video_play_button:not(.inited)').each(function() { 1381 "use strict"; 1382 jQuery(this) 1383 .addClass('inited') 1384 .animate({opacity: 1}, 1000) 1385 .on('click', function (e) { 1386 "use strict"; 1387 if (!jQuery(this).hasClass('sc_video_play_button')) return; 1388 var video = jQuery(this).removeClass('sc_video_play_button hover_icon hover_icon_play').data('video'); 1389 if (video!=='') { 1390 jQuery(this).empty().html(video); 1391 vegadays_video_dimensions(); 1392 var video_tag = jQuery(this).find('video'); 1393 var w = video_tag.width(); 1394 var h = video_tag.height(); 1395 vegadays_init_media_elements(jQuery(this)); 1396 // Restore WxH attributes, because Chrome broke it! 1397 jQuery(this).find('video').css({'width':w, 'height': h}).attr({'width':w, 'height': h}); 1398 } 1399 e.preventDefault(); 1400 return false; 1401 }); 1402 }); 1403 } 1404} 1405 1406 1407function vegadays_init_media_elements(cont) { 1408 if (VEGADAYS_STORAGE['media_elements_enabled'] && cont.find('audio,video').length > 0) { 1409 if (window.mejs) { 1410 window.mejs.MepDefaults.enableAutosize = false; 1411 window.mejs.MediaElementDefaults.enableAutosize = false; 1412 cont.find('audio:not(.wp-audio-shortcode),video:not(.wp-video-shortcode)').each(function() { 1413 if (jQuery(this).parents('.mejs-mediaelement').length == 0) { 1414 var media_tag = jQuery(this); 1415 var settings = { 1416 enableAutosize: true, 1417 videoWidth: -1, // if set, overrides <video width> 1418 videoHeight: -1, // if set, overrides <video height> 1419 audioWidth: '100%', // width of audio player 1420 audioHeight: 30, // height of audio player 1421 success: function(mejs) { 1422 var autoplay, loop; 1423 if ( 'flash' === mejs.pluginType ) { 1424 autoplay = mejs.attributes.autoplay && 'false' !== mejs.attributes.autoplay; 1425 loop = mejs.attributes.loop && 'false' !== mejs.attributes.loop; 1426 autoplay && mejs.addEventListener( 'canplay', function () { 1427 mejs.play(); 1428 }, false ); 1429 loop && mejs.addEventListener( 'ended', function () { 1430 mejs.play(); 1431 }, false ); 1432 } 1433 media_tag.parents('.sc_audio,.sc_video').addClass('inited sc_show'); 1434 } 1435 }; 1436 jQuery(this).mediaelementplayer(settings); 1437 } 1438 }); 1439 } else 1440 setTimeout(function() { vegadays_init_media_elements(cont); }, 400); 1441 } 1442} 1443 1444 1445 1446 1447 1448 1449// Popups and system messages 1450//============================================== 1451 1452// Show system message (bubble from previous page) 1453function vegadays_show_system_message() { 1454 if (VEGADAYS_STORAGE['system_message'] && VEGADAYS_STORAGE['system_message']['message']) { 1455 if (VEGADAYS_STORAGE['system_message']['status'] == 'success') 1456 vegadays_message_success(VEGADAYS_STORAGE['system_message']['message'], VEGADAYS_STORAGE['system_message']['header']); 1457 else if (VEGADAYS_STORAGE['system_message']['status'] == 'info') 1458 vegadays_message_info(VEGADAYS_STORAGE['system_message']['message'], VEGADAYS_STORAGE['system_message']['header']); 1459 else if (VEGADAYS_STORAGE['system_message']['status'] == 'error' || VEGADAYS_STORAGE['system_message']['status'] == 'warning') 1460 vegadays_message_warning(VEGADAYS_STORAGE['system_message']['message'], VEGADAYS_STORAGE['system_message']['header']); 1461 } 1462} 1463 1464// Toggle popups 1465function vegadays_toggle_popup(popup) { 1466 if (popup.css('display')!='none') 1467 vegadays_hide_popup(popup); 1468 else 1469 vegadays_show_popup(popup); 1470} 1471 1472// Show popups 1473function vegadays_show_popup(popup) { 1474 if (popup.css('display')=='none') { 1475 if (false && VEGADAYS_STORAGE['css_animation']) 1476 popup.show().removeClass('animated fast '+VEGADAYS_STORAGE['menu_animation_out']).addClass('animated fast '+VEGADAYS_STORAGE['menu_animation_in']); 1477 else 1478 popup.slideDown(); 1479 } 1480} 1481 1482// Hide popups 1483function vegadays_hide_popup(popup) { 1484 if (popup.css('display')!='none') { 1485 if (false && VEGADAYS_STORAGE['css_animation']) 1486 popup.removeClass('animated fast '+VEGADAYS_STORAGE['menu_animation_in']).addClass('animated fast '+VEGADAYS_STORAGE['menu_animation_out']).delay(500).hide(); 1487 else 1488 popup.fadeOut(); 1489 } 1490}
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.