1/* global jQuery:false */ 2/* global YOLANDDESIGN_STORAGE:false */ 3 4jQuery(document).ready(function() { 5 "use strict"; 6 YOLANDDESIGN_STORAGE['theme_init_counter'] = 0; 7 yolanddesign_init_actions(); 8}); 9 10jQuery(window).on('beforeunload', function() { 11 "use strict"; 12 // Show preloader 13 jQuery('#page_preloader').css({display: 'block', opacity: 0}).animate({opacity:0.8}, 300); 14}); 15 16 17// Theme init actions 18function yolanddesign_init_actions() { 19 "use strict"; 20 21 if (YOLANDDESIGN_STORAGE['vc_edit_mode'] && jQuery('.vc_empty-placeholder').length==0 && YOLANDDESIGN_STORAGE['theme_init_counter']++ < 30) { 22 setTimeout(yolanddesign_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 (yolanddesign_is_retina()) { 31 yolanddesign_set_cookie('yolanddesign_retina', 1, 365); 32 } 33 34 yolanddesign_ready_actions(); 35 36 // Add resize handlers after VC row stretch handlers on('resize.vcRowBehaviour', ...) 37 setTimeout(function() { 38 jQuery(window).on('resize.yolanddesign', function() { 39 yolanddesign_resize_actions(); 40 yolanddesign_scroll_actions() 41 }).trigger('resize.yolanddesign'); 42 }, 10); 43 44 // Scroll handlers 45 jQuery(window).on('scroll.yolanddesign', function() { 46 "use strict"; 47 yolanddesign_scroll_actions(); 48 }); 49} 50 51 52 53// Theme first load actions 54//============================================== 55function yolanddesign_ready_actions() { 56 "use strict"; 57 58 // Call theme specific action (if exists) 59 //---------------------------------------------- 60 if (window.yolanddesign_theme_ready_actions) yolanddesign_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 = YOLANDDESIGN_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(YOLANDDESIGN_STORAGE['ajax_url'], { 102 action: 'calendar_change_month', 103 nonce: YOLANDDESIGN_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: YOLANDDESIGN_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 // Prepare menus 154 if (YOLANDDESIGN_STORAGE['menu_cache']) yolanddesign_prepare_menus(); 155 156 // Clone side menu for responsive 157 if (jQuery('ul#menu_side').length > 0) { 158 jQuery('ul#menu_side').clone().removeAttr('id').removeClass('menu_side_nav').addClass('menu_side_responsive').insertAfter('ul#menu_side'); 159 yolanddesign_show_current_menu_item(jQuery('.menu_side_responsive'), jQuery('.sidebar_outer_menu_responsive_button')); 160 } 161 if (jQuery('.header_mobile').length > 0) { 162 jQuery('.header_mobile .menu_main_nav_area ul.menu_main_nav').removeAttr('id'); 163 jQuery('.header_mobile .menu_button').on('click', function(){ 164 jQuery('.header_mobile .side_wrap').toggleClass('open'); 165 jQuery('.header_mobile .mask').toggleClass('show'); 166 jQuery('html').toggleClass('menu_mobile_open'); 167 // Fix for Safari 168 if (yolanddesign_browser_is_ios() && jQuery('body').hasClass('menu_mobile') && jQuery('div.side_wrap').hasClass('open')) { 169 jQuery('body').data('overflow', jQuery('body').css('overflow')).css('overflow', 'hidden'); 170 jQuery('body').data('position', jQuery('body').css('position')).css('position', 'fixed'); 171 } 172 }); 173 jQuery('.header_mobile .mask, .header_mobile .side_wrap .close').on('click', function(){ 174 jQuery('.header_mobile .side_wrap').removeClass('open'); 175 jQuery('.header_mobile .mask').removeClass('show'); 176 jQuery('html').removeClass('menu_mobile_open'); 177 // Fix for Safari 178 if (yolanddesign_browser_is_ios() && jQuery('body').hasClass('menu_mobile') && !jQuery('div.side_wrap').hasClass('open')) { 179 jQuery('body').css('overflow', jQuery('body').data('overflow')); 180 jQuery('body').css('position', jQuery('body').data('position')); 181 } 182 }); 183 } 184 185 // Push menu button 186 jQuery('.menu_pushy_button').on('click', function(e){ 187 "use strict"; 188 jQuery('body').addClass('pushy-active').css('overflow', 'hidden'); 189 jQuery('.site-overlay').fadeIn('fast'); 190 e.preventDefault(); 191 return false;
192 }); 193 jQuery('.pushy .close-pushy,.site-overlay').on('click', function(e){ 194 jQuery('body').removeClass('pushy-active').css('overflow', 'visible'); 195 jQuery('.site-overlay').fadeOut('fast'); 196 e.preventDefault(); 197 return false; 198 }); 199 200 // Side menu widgets button 201 jQuery('.sidebar_outer_widgets_button').on('click', function(e){ 202 "use strict"; 203 jQuery('.sidebar_outer_widgets').slideToggle(); 204 e.preventDefault(); 205 return false; 206 }); 207 208 // Add arrows in responsive menu 209 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>'); 210 211 // Submenu click handler for the responsive menu 212 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) { 213 "use strict"; 214 var is_menu_main = jQuery(this).parents('.menu_main_nav').length > 0; 215 var $a = jQuery(this).hasClass('open_child_menu') ? jQuery(this).parent() : jQuery(this); 216 if ((!is_menu_main || jQuery('body').hasClass('menu_mobile')) && ($a.parent().hasClass('menu-item-has-children') || $a.parent().hasClass('has_children'))) { 217 if ($a.siblings('ul:visible').length > 0) 218 $a.siblings('ul').slideUp().parent().removeClass('opened'); 219 else { 220 jQuery(this).parents('li').siblings('li').find('ul:visible').slideUp().parent().removeClass('opened'); 221 $a.siblings('ul').slideDown().parent().addClass('opened'); 222 } 223 } 224 // Ignore link for parent menu items 225 if (jQuery(this).hasClass('open_child_menu') || $a.attr('href')=='#') { 226 e.preventDefault(); 227 return false; 228 } 229 }); 230 231 232 //Header 9 233 if(jQuery('.top_panel_style_7').length > 0){ 234 var menu_class = jQuery('.top_panel_style_7 .menu_main_nav').attr('class'); 235 var numb = jQuery('.top_panel_style_7 .menu_main_nav > li.menu-item').length; 236 237 if(numb > 1){ 238 jQuery('.top_panel_style_7 .menu_main_nav').addClass('left'); 239 240 // Calculate the average item of a list
241 var center = Math.ceil(numb / 2) + 1; 242 243 // Create new list 244 var right_ul = '<ul class="' + menu_class + ' right"></ul>'; 245 246 // Append new list 247 jQuery('.top_panel_style_7 .menu_main_nav').after(right_ul); 248 249 // Insert items to the new list 250 jQuery('.top_panel_style_7 .menu_main_nav.left > li.menu-item:nth-child(n + ' + center + ')').clone().appendTo('.top_panel_style_7 .menu_main_nav.right'); 251 252 //Remove item from old list 253 jQuery('.top_panel_style_7 .menu_main_nav.left > li.menu-item:nth-child(n + ' + (center) + ')').remove(); 254 255 256 jQuery('.top_panel_style_7 .top_panel_middle .search_wrap').each(function(){ 257 var close = '<div class="close icon-cancel"></div>'; 258 jQuery(this).append(close); 259 260 jQuery(this).find('.close').click(function(){ 261 jQuery('.top_panel_style_7 .top_panel_middle .search_wrap.search_state_opened').removeClass('search_state_opened').addClass('search_state_closed'); 262 }); 263 264 }); 265 266 267 268 } 269 270 } 271 272 // Init superfish menus 273 yolanddesign_init_sfmenu('header .menu_main_nav_area ul.menu_main_nav, ul#menu_user, ul#menu_side, body:not(.woocommerce) .widget_area:not(.footer_wrap) .widget_product_categories ul.product-categories'); 274 275 // Slide effect for main menu 276 if (YOLANDDESIGN_STORAGE['menu_hover']=='slide_line' || YOLANDDESIGN_STORAGE['menu_hover']=='slide_box') { 277 setTimeout(function() { 278 "use strict"; 279 jQuery('.menu_main_nav').spasticNav({ 280 style: YOLANDDESIGN_STORAGE['menu_hover']=='slide_line' ? 'line' : 'box', 281 color: YOLANDDESIGN_STORAGE['accent1_hover'], 282 colorOverride: false 283 }); 284 }, 500); 285 } 286 287 // Show table of contents for the current page 288 if (YOLANDDESIGN_STORAGE['toc_menu'] != 'hide' && YOLANDDESIGN_STORAGE['toc_menu'] != 'no') { 289 yolanddesign_build_page_toc(); 290 } 291 292 // One page mode for menu links (scroll to anchor) 293 jQuery('#toc, ul.menu_main_nav li, ul#menu_user li, ul#menu_side li, ul#menu_footer li, ul#menu_pushy li').on('click', 'a', function(e) { 294 "use strict"; 295 var href = jQuery(this).attr('href'); 296 if (href===undefined) return; 297 var pos = href.indexOf('#'); 298 if (pos < 0 || href.length == 1) return; 299 if (jQuery(href.substr(pos)).length > 0) { 300 var loc = window.location.href; 301 var pos2 = loc.indexOf('#'); 302 if (pos2 > 0) loc = loc.substring(0, pos2); 303 var now = pos==0; 304 if (!now) now = loc == href.substring(0, pos); 305 if (now) { 306 yolanddesign_document_animate_to(href.substr(pos)); 307 yolanddesign_document_set_location(pos==0 ? loc + href : href); 308 e.preventDefault(); 309 return false; 310 } 311 } 312 }); 313 314 315 // Store height of the top and side panels 316 YOLANDDESIGN_STORAGE['top_panel_height'] = 0; //Math.max(0, jQuery('.top_panel_wrap').height()); 317 YOLANDDESIGN_STORAGE['side_panel_height'] = 0; 318 319 320 // Pagination 321 //---------------------------------------------- 322 323 // Page navigation (style slider) 324 jQuery('.pager_cur').on('click', function(e) { 325 "use strict"; 326 jQuery('.pager_slider').slideDown(300, function() { 327 yolanddesign_sc_init(jQuery('.pager_slider').eq(0)); 328 }); 329 e.preventDefault(); 330 return false; 331 }); 332 333 334 // View More button 335 jQuery('#viewmore_link').on('click', function(e) { 336 "use strict"; 337 if (!YOLANDDESIGN_STORAGE['viewmore_busy'] && !jQuery(this).hasClass('viewmore_empty')) { 338 jQuery(this).parent().addClass('loading'); 339 YOLANDDESIGN_STORAGE['viewmore_busy'] = true; 340 jQuery.post(YOLANDDESIGN_STORAGE['ajax_url'], { 341 action: 'view_more_posts', 342 nonce: YOLANDDESIGN_STORAGE['ajax_nonce'], 343 page: YOLANDDESIGN_STORAGE['viewmore_page']+1, 344 data: YOLANDDESIGN_STORAGE['viewmore_data'], 345 vars: YOLANDDESIGN_STORAGE['viewmore_vars'] 346 }).done(function(response) { 347 "use strict"; 348 var rez = {}; 349 try { 350 rez = JSON.parse(response); 351 } catch (e) { 352 rez = { error: YOLANDDESIGN_STORAGE['ajax_error'] }; 353 console.log(response); 354 } 355 jQuery('#viewmore_link').parent().removeClass('loading'); 356 YOLANDDESIGN_STORAGE['viewmore_busy'] = false;
357 if (rez.error === '') { 358 var posts_container = jQuery('.content').eq(0); 359 if (posts_container.find('.isotope_wrap').length > 0) posts_container = posts_container.find('.isotope_wrap').eq(0); 360 if (posts_container.hasClass('isotope_wrap')) { 361 posts_container.data('last-width', 0).append(rez.data); 362 YOLANDDESIGN_STORAGE['isotope_init_counter'] = 0; 363 yolanddesign_init_appended_isotope(posts_container, rez.filters); 364 } else 365 jQuery('#viewmore').before(rez.data); 366 367 YOLANDDESIGN_STORAGE['viewmore_page']++; 368 if (rez.no_more_data==1) { 369 jQuery('#viewmore_link').addClass('viewmore_empty').parent().hide(); 370 } 371 372 yolanddesign_init_post_formats(); 373 yolanddesign_sc_init(posts_container); 374 yolanddesign_scroll_actions(); 375 } 376 }); 377 } 378 e.preventDefault(); 379 return false; 380 }); 381 382 383 // WooCommerce 384 //---------------------------------------------- 385 386 // Change display mode 387 jQuery('.woocommerce,.woocommerce-page').on('click', '.mode_buttons a', function(e) { 388 "use strict"; 389 var mode = jQuery(this).hasClass('woocommerce_thumbs') ? 'thumbs' : 'list'; 390 jQuery.cookie('yolanddesign_shop_mode', mode, {expires: 365, path: '/'}); 391 jQuery(this).siblings('input').val(mode).parents('form').get(0).submit(); 392 e.preventDefault(); 393 return false; 394 }); 395 // Added to cart 396 jQuery('body').bind('added_to_cart', function() { 397 "use strict"; 398 // Update amount on the cart button 399 var total = jQuery('.widget_shopping_cart').eq(0).find('.total .amount').text(); 400 if (total != undefined) { 401 jQuery('.top_panel_cart_button .cart_summa').text(total); 402 } 403 // Update count items on the cart button 404 var cnt = 0; 405 jQuery('.widget_shopping_cart_content').eq(0).find('.cart_list li').each(function() { 406 var q = jQuery(this).find('.quantity').html().split(' ', 2); 407 if (!isNaN(q[0])) 408 cnt += Number(q[0]); 409 }); 410 var items = jQuery('.top_panel_cart_button .cart_items').eq(0).text().split(' ', 2); 411 items[0] = cnt; 412 jQuery('.top_panel_cart_button .cart_items').text(items[0]+' '+items[1]); 413 // Update data-attr on button 414 jQuery('.top_panel_cart_button').data({ 415 'items': cnt ? cnt : 0, 416 'summa': total ? total : 0 417 }); 418 }); 419 // Show cart 420 jQuery('.top_panel_middle .top_panel_cart_button, .header_mobile .top_panel_cart_button').on('click', function(e) { 421 "use strict"; 422 jQuery(this).siblings('.sidebar_cart').slideToggle(); 423 e.preventDefault(); 424 return false; 425 }); 426 // Add buttons to quantity 427 jQuery('.woocommerce div.quantity,.woocommerce-page div.quantity').append('<span class="q_inc"></span><span class="q_dec"></span>'); 428 jQuery('.woocommerce div.quantity').on('click', '>span', function(e) { 429 "use strict"; 430 var f = jQuery(this).siblings('input'); 431 if (jQuery(this).hasClass('q_inc')) { 432 f.val(Math.max(0, parseInt(f.val()))+1); 433 } else { 434 f.val(Math.max(1, Math.max(0, parseInt(f.val()))-1)); 435 } 436 e.preventDefault(); 437 return false; 438 }); 439 // Add stretch behaviour to WooC tabs area 440 jQuery('.single-product .woocommerce-tabs') 441 .addClass('trx-stretch-width scheme_light') 442 .after('<div class="trx-stretch-width-original"></div>'); 443 yolanddesign_stretch_width(); 444 445 446 // Popup login and register windows 447 //---------------------------------------------- 448 jQuery('.popup_link,.popup_login_link,.popup_register_link').addClass('inited').on('click', function(e){ 449 var popup = jQuery(jQuery(this).attr('href')); 450 if (popup.length === 1) { 451 yolanddesign_hide_popup(jQuery(popup.hasClass('popup_login') ? '.popup_registration' : '.popup_login' )); 452 yolanddesign_show_popup(popup); 453 } 454 e.preventDefault(); 455 return false; 456 }); 457 jQuery('.popup_wrap').on('click', '.popup_close', function(e){ 458 var popup = jQuery(this).parent(); 459 if (popup.length === 1) { 460 yolanddesign_hide_popup(popup); 461 } 462 e.preventDefault(); 463 return false; 464 }); 465 466 467 // Forms validation 468 //---------------------------------------------- 469 470 // Login form 471 jQuery('.popup_form.login_form').submit(function(e){ 472 "use strict"; 473 var rez = yolanddesign_login_validate(jQuery(this)); 474 if (!rez) 475 e.preventDefault(); 476 return rez; 477 }); 478 479 // Registration form 480 jQuery('.popup_form.registration_form').submit(function(e){ 481 "use strict"; 482 var rez = yolanddesign_registration_validate(jQuery(this)); 483 if (!rez) 484 e.preventDefault(); 485 return rez; 486 }); 487 488 // Comment form 489 jQuery("form#commentform").submit(function(e) { 490 "use strict"; 491 var rez = yolanddesign_comments_validate(jQuery(this)); 492 if (!rez) 493 e.preventDefault(); 494 return rez; 495 }); 496 497 498 499 // Bookmarks 500 //---------------------------------------------- 501 502 // Add bookmark 503 jQuery('.bookmarks_add').on('click', function(e) { 504 "use strict"; 505 var title = window.document.title.split('|')[0]; 506 var url = window.location.href; 507 var list = jQuery.cookie('yolanddesign_bookmarks'); 508 var exists = false;
509 if (list) { 510 try { 511 list = JSON.parse(list); 512 } catch (e) {} 513 if (list.length) { 514 for (var i=0; i<list.length; i++) { 515 if (list[i].url == url) { 516 exists = true; 517 break; 518 } 519 } 520 } 521 } else 522 list = new Array(); 523 if (!exists) { 524 var message_popup = yolanddesign_message_dialog('<label for="bookmark_title">'+YOLANDDESIGN_STORAGE['strings']['bookmark_title']+'</label><br><input type="text" id="bookmark_title" name="bookmark_title" value="'+title+'">', YOLANDDESIGN_STORAGE['strings']['bookmark_add'], null, 525 function(btn, popup) { 526 "use strict"; 527 if (btn != 1) return; 528 title = message_popup.find('#bookmark_title').val(); 529 list.push({title: title, url: url}); 530 jQuery('.bookmarks_list').append('<li><a href="'+url+'" class="bookmarks_item">'+title+'<span class="bookmarks_delete icon-cancel" title="'+YOLANDDESIGN_STORAGE['strings']['bookmark_del']+'"></span></a></li>'); 531 jQuery.cookie('yolanddesign_bookmarks', JSON.stringify(list), {expires: 365, path: '/'}); 532 setTimeout(function () {yolanddesign_message_success(YOLANDDESIGN_STORAGE['strings']['bookmark_added'], YOLANDDESIGN_STORAGE['strings']['bookmark_add']);}, YOLANDDESIGN_STORAGE['message_timeout']/4); 533 }); 534 } else 535 yolanddesign_message_warning(YOLANDDESIGN_STORAGE['strings']['bookmark_exists'], YOLANDDESIGN_STORAGE['strings']['bookmark_add']); 536 e.preventDefault(); 537 return false; 538 }); 539 540 // Delete bookmark 541 jQuery('.bookmarks_list').on('click', '.bookmarks_delete', function(e) { 542 "use strict"; 543 var idx = jQuery(this).parent().index(); 544 var list = jQuery.cookie('yolanddesign_bookmarks'); 545 if (list) { 546 try { 547 list = JSON.parse(list); 548 } catch (e) {} 549 if (list.length) { 550 list.splice(idx, 1); 551 jQuery.cookie('yolanddesign_bookmarks', JSON.stringify(list), {expires: 365, path: '/'}); 552 } 553 } 554 jQuery(this).parent().remove(); 555 e.preventDefault(); 556 return false; 557 }); 558 559 560 // Other settings 561 //------------------------------------ 562 563 // Scroll to top button 564 jQuery('.scroll_to_top').on('click', function(e) { 565 "use strict"; 566 jQuery('html,body').animate({ 567 scrollTop: 0 568 }, 'slow'); 569 e.preventDefault(); 570 return false; 571 }); 572 573 // AJAX views counter 574 if (YOLANDDESIGN_STORAGE['ajax_views_counter'] !== undefined) { 575 setTimeout(function(){ 576 jQuery.post(YOLANDDESIGN_STORAGE['ajax_url'], { 577 action: 'post_counter', 578 nonce: YOLANDDESIGN_STORAGE['ajax_nonce'], 579 post_id: YOLANDDESIGN_STORAGE['ajax_views_counter']['post_id'], 580 views: YOLANDDESIGN_STORAGE['ajax_views_counter']['post_views'] 581 }); 582 }, 10); 583 } 584 585 // Show system message 586 yolanddesign_show_system_message(); 587 588 // Init post format specific scripts 589 yolanddesign_init_post_formats(); 590 591 // Call sc init action (if exists) 592 if (window.yolanddesign_sc_init_actions) yolanddesign_sc_init_actions(); 593 594 // Init hidden elements (if exists) 595 if (window.yolanddesign_init_hidden_elements) yolanddesign_init_hidden_elements(jQuery('body').eq(0)); 596 597} //end ready 598 599 600 601 602// Scroll actions 603//============================================== 604 605// Do actions when page scrolled 606function yolanddesign_scroll_actions() { 607 "use strict"; 608 609 // Call theme specific action (if exists) 610 //---------------------------------------------- 611 if (window.yolanddesign_theme_scroll_actions) yolanddesign_theme_scroll_actions(); 612 613 var scroll_offset = jQuery(window).scrollTop(); 614 var scroll_to_top_button = jQuery('.scroll_to_top'); 615 var adminbar_height = Math.max(0, jQuery('#wpadminbar').height()); 616 617 if (YOLANDDESIGN_STORAGE['top_panel_height'] < 1) { 618 YOLANDDESIGN_STORAGE['top_panel_height'] = Math.max(0, jQuery('.top_panel_wrap').height()); 619 } 620 621 // Scroll to top button show/hide 622 if (scroll_offset > YOLANDDESIGN_STORAGE['top_panel_height']) 623 scroll_to_top_button.addClass('show'); 624 else 625 scroll_to_top_button.removeClass('show'); 626 627 // Fix/unfix top panel 628 if (!jQuery('body').hasClass('menu_mobile') && YOLANDDESIGN_STORAGE['menu_fixed']) { 629 var slider_height = 0; 630 if (jQuery('.top_panel_below .slider_wrap').length > 0) { 631 slider_height = jQuery('.top_panel_below .slider_wrap').height(); 632 if (slider_height < 10) { 633 slider_height = jQuery('.slider_wrap').hasClass('.slider_fullscreen') ? jQuery(window).height() : YOLANDDESIGN_STORAGE['slider_height']; 634 } 635 } 636 if (scroll_offset <= slider_height + YOLANDDESIGN_STORAGE['top_panel_height']) { 637 if (jQuery('body').hasClass('top_panel_fixed')) { 638 jQuery('body').removeClass('top_panel_fixed'); 639 } 640 } else if (scroll_offset > slider_height + YOLANDDESIGN_STORAGE['top_panel_height']) { 641 if (!jQuery('body').hasClass('top_panel_fixed') && jQuery(document).height() > jQuery(window).height()*1.5) { 642 jQuery('.top_panel_fixed_wrap').height(YOLANDDESIGN_STORAGE['top_panel_height']); 643 jQuery('.top_panel_wrap').css('marginTop', '-150px').animate({'marginTop': 0}, 500); 644 jQuery('body').addClass('top_panel_fixed'); 645 } 646 } 647 } 648 649 // Fix/unfix side panel 650 if (jQuery('.sidebar_outer').length > 0) { 651 if (YOLANDDESIGN_STORAGE['side_panel_height'] == 0) 652 YOLANDDESIGN_STORAGE['side_panel_height'] = jQuery('.sidebar_outer_logo_wrap').outerHeight() + jQuery('.sidebar_outer_menu').outerHeight() + jQuery('.sidebar_outer_widgets').outerHeight(); 653 if (scroll_offset + jQuery(window).height() > YOLANDDESIGN_STORAGE['side_panel_height'] + 100) { 654 if (jQuery('.sidebar_outer').css('position')!=='fixed') { 655 jQuery('.sidebar_outer').css({ 656 'position': 'fixed', 657 'top': Math.min(0, jQuery(window).height() - YOLANDDESIGN_STORAGE['side_panel_height'] - 100) + 'px', 658 }); 659 } 660 } else { 661 if (jQuery('.sidebar_outer').css('position')=='fixed') { 662 jQuery('.sidebar_outer').css({ 663 'position': 'absolute', 664 'top': 0 665 }); 666 } 667 } 668 } 669 670 // TOC current items 671 jQuery('#toc .toc_item').each(function() { 672 "use strict"; 673 var id = jQuery(this).find('a').attr('href'); 674 var pos = id.indexOf('#'); 675 if (pos < 0 || id.length == 1) return; 676 var loc = window.location.href; 677 var pos2 = loc.indexOf('#'); 678 if (pos2 > 0) loc = loc.substring(0, pos2); 679 var now = pos==0; 680 if (!now) now = loc == href.substring(0, pos); 681 if (!now) return; 682 var off = jQuery(id).offset().top; 683 var id_next = jQuery(this).next().find('a').attr('href'); 684 var off_next = id_next ? jQuery(id_next).offset().top : 1000000; 685 if (off < scroll_offset + jQuery(window).height()*0.8 && scroll_offset + YOLANDDESIGN_STORAGE['top_panel_height'] < off_next) 686 jQuery(this).addClass('current'); 687 else 688 jQuery(this).removeClass('current'); 689 }); 690 691 // Infinite pagination 692 yolanddesign_infinite_scroll() 693 694 // Parallax scroll 695 yolanddesign_parallax_scroll(); 696 697 // Call sc scroll actions (if exists) 698 if (window.yolanddesign_sc_scroll_actions) yolanddesign_sc_scroll_actions(); 699} 700 701 702// Infinite Scroll 703function yolanddesign_infinite_scroll() { 704 "use strict"; 705 if (YOLANDDESIGN_STORAGE['viewmore_busy']) return; 706 var infinite = jQuery('#viewmore.pagination_infinite'); 707 if (infinite.length > 0) { 708 var viewmore = infinite.find('#viewmore_link:not(.viewmore_empty)'); 709 if (viewmore.length > 0) { 710 if (jQuery(window).scrollTop() + jQuery(window).height() + 100 >= infinite.offset().top) { 711 viewmore.eq(0).trigger('click'); 712 } 713 } 714 } 715} 716 717// Parallax scroll 718function yolanddesign_parallax_scroll(){ 719 jQuery('.sc_parallax').each(function(){ 720 var windowHeight = jQuery(window).height(); 721 var scrollTops = jQuery(window).scrollTop(); 722 var offsetPrx = Math.max(jQuery(this).offset().top, windowHeight); 723 if ( offsetPrx <= scrollTops + windowHeight ) { 724 var speed = Number(jQuery(this).data('parallax-speed')); 725 var xpos = jQuery(this).data('parallax-x-pos'); 726 var ypos = Math.round((offsetPrx - scrollTops - windowHeight) * speed + (speed < 0 ? windowHeight*speed : 0)); 727 jQuery(this).find('.sc_parallax_content').css('backgroundPosition', xpos+' '+ypos+'px'); 728 // Uncomment next line if you want parallax video (else - video position is static) 729 jQuery(this).find('div.sc_video_bg').css('top', ypos+'px'); 730 } 731 }); 732} 733 734 735 736 737 738// Resize actions 739//============================================== 740 741// Do actions when page scrolled 742function yolanddesign_resize_actions() { 743 "use strict"; 744 745 // Call theme specific action (if exists) 746 //---------------------------------------------- 747 if (window.yolanddesign_theme_resize_actions) yolanddesign_theme_resize_actions(); 748 749 // Reset stored value 750 YOLANDDESIGN_STORAGE['top_panel_height'] = 0; 751 752 yolanddesign_responsive_menu(); 753 yolanddesign_vc_row_fullwidth_to_boxed(); 754 yolanddesign_video_dimensions(); 755 yolanddesign_resize_video_background(); 756 yolanddesign_resize_fullscreen_slider(); 757 yolanddesign_resize_alter_portfolio(); 758 yolanddesign_stretch_width(); 759 760 // Call sc resize actions (if exists) 761 if (window.yolanddesign_sc_resize_actions) yolanddesign_sc_resize_actions(); 762} 763 764// Stretch area to full window width 765function yolanddesign_stretch_width() { 766 jQuery('.trx-stretch-width').each(function() { 767 var $el = jQuery(this); 768 var $el_full = $el.next('.trx-stretch-width-original'); 769 var el_margin_left = parseInt( $el.css( 'margin-left' ), 10 ); 770 var el_margin_right = parseInt( $el.css( 'margin-right' ), 10 ); 771 var offset = 0 - $el_full.offset().left - el_margin_left; 772 var width = jQuery( window ).width(); 773 if (!$el.hasClass('inited')) { 774 $el.addClass('inited invisible'); 775 $el.css({ 776 'position': 'relative', 777 'box-sizing': 'border-box' 778 }); 779 } 780 $el.css({ 781 'left': offset, 782 'width': jQuery( window ).width() 783 }); 784 if ( !$el.hasClass('trx-stretch-content') ) { 785 var padding = Math.max(0, -1*offset); 786 var paddingRight = Math.max(0, width - padding - $el_full.width() + el_margin_left + el_margin_right); 787 $el.css( { 'padding-left': padding + 'px', 'padding-right': paddingRight + 'px' } ); 788 } 789 $el.removeClass('invisible'); 790 }); 791} 792 793// Width vc_row when content boxed 794function yolanddesign_vc_row_fullwidth_to_boxed(){ 795 "use strict"; 796 if (jQuery('body').hasClass('body_style_boxed')) { 797 var width_body = jQuery('body').width(); 798 var width_content = jQuery('.page_wrap').width(); 799 var width_content_wrap = jQuery('.page_content_wrap .content_wrap').width(); 800 var indent = ( width_content - width_content_wrap ) / 2; 801 if ( width_body > width_content ){ 802 jQuery('.vc_row[data-vc-full-width="true"]').each( function() { 803 "use strict";
804 var mrg = parseInt(jQuery(this).css('marginLeft')); 805 jQuery(this).css({ 806 'width': width_content, 807 'left': -indent-mrg, 808 'padding-left': indent+mrg, 809 'padding-right': indent+mrg 810 }); 811 if (jQuery(this).attr('data-vc-stretch-content')) { 812 jQuery(this).css({ 813 'padding-left': 0, 814 'padding-right': 0 815 }); 816 } 817 }); 818 } 819 } 820} 821 822// Check window size and do responsive menu 823function yolanddesign_responsive_menu() { 824 "use strict"; 825 if (yolanddesign_is_responsive_need(YOLANDDESIGN_STORAGE['menu_mobile'])) { 826 if (!jQuery('body').hasClass('menu_mobile')) { 827 jQuery('body').removeClass('top_panel_fixed').addClass('menu_mobile'); 828 jQuery('header.top_panel_wrap ').hide(); 829 jQuery('.header_mobile').show(); 830 831 jQuery('header #popup_login').attr('id', 'popup_login_1'); 832 jQuery('header #popup_registration').attr('id', 'popup_registration_1'); 833 jQuery('.header_mobile #popup_login_1').attr('id', 'popup_login'); 834 jQuery('.header_mobile #popup_registration_1').attr('id', 'popup_registration'); 835 } 836 } else { 837 if (jQuery('body').hasClass('menu_mobile')) { 838 jQuery('body').removeClass('menu_mobile'); 839 jQuery('header.top_panel_wrap ').show(); 840 jQuery('.header_mobile').hide(); 841 842 jQuery('header #popup_login_1').attr('id', 'popup_login'); 843 jQuery('header #popup_registration_1').attr('id', 'popup_registration'); 844 jQuery('.header_mobile #popup_login').attr('id', 'popup_login_1'); 845 jQuery('.header_mobile #popup_registration').attr('id', 'popup_registration_1'); 846 } 847 } 848 849 if (jQuery(window).width() < 640) { 850 var pass = jQuery('.header_mobile .popup_wrap.popup_registration .registration_form > .form_right'); 851 if(pass.length > 0){ 852 jQuery('.header_mobile .popup_wrap.popup_registration .form_left .popup_form_field.email_field').after(pass); 853 } 854 } 855 else{ 856 var pass = jQuery('.header_mobile .popup_wrap.popup_registration .form_left > .form_right'); 857 if(pass.length > 0){ 858 jQuery('.header_mobile .popup_wrap.popup_registration .registration_form').append(pass); 859 } 860 } 861 862 if (!jQuery('.top_panel_wrap').hasClass('menu_show')) jQuery('.top_panel_wrap').addClass('menu_show'); 863 // Show widgets block on the sidebar outer (if sidebar not responsive and widgets are hidden) 864 if (jQuery('.sidebar_outer').length > 0 && jQuery('.sidebar_outer').css('position')=='absolute' && jQuery('.sidebar_outer_widgets:visible').length==0) 865 jQuery('.sidebar_outer_widgets').show(); 866 // Switch popup menu / hierarchical list on product categories list placed in sidebar 867 var cat_menu = jQuery('body:not(.woocommerce) .widget_area:not(.footer_wrap) .widget_product_categories ul.product-categories'); 868 var sb = cat_menu.parents('.widget_area'); 869 if (sb.length > 0 && cat_menu.length > 0) { 870 if (sb.width() == sb.parents('.content_wrap').width()) { 871 if (cat_menu.hasClass('inited')) { 872 cat_menu.removeClass('inited').addClass('plain').superfish('destroy'); 873 cat_menu.find('ul.animated').removeClass('animated').addClass('no_animated'); 874 } 875 } else { 876 if (!cat_menu.hasClass('inited')) { 877 cat_menu.removeClass('plain').addClass('inited'); 878 cat_menu.find('ul.no_animated').removeClass('no_animated').addClass('animated'); 879 yolanddesign_init_sfmenu('body:not(.woocommerce) .widget_area:not(.footer_wrap) .widget_product_categories ul.product-categories'); 880 } 881 } 882 } 883} 884 885 886// Check if responsive menu need 887function yolanddesign_is_responsive_need(max_width) { 888 "use strict"; 889 var rez = false; 890 if (max_width > 0) { 891 var w = window.innerWidth; 892 if (w == undefined) { 893 w = jQuery(window).width()+(jQuery(window).height() < jQuery(document).height() || jQuery(window).scrollTop() > 0 ? 16 : 0); 894 } 895 rez = max_width > w; 896 } 897 return rez; 898} 899 900 901// Fit video frames to document width 902function yolanddesign_video_dimensions() { 903 jQuery('.sc_video_frame').each(function() { 904 "use strict"; 905 if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return; 906 var frame = jQuery(this).eq(0); 907 var player = frame.parent(); 908 var ratio = (frame.data('ratio') ? frame.data('ratio').split(':') : (frame.find('[data-ratio]').length>0 ? frame.find('[data-ratio]').data('ratio').split(':') : [16,9])); 909 ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1]; 910 var w_attr = frame.data('width'); 911 var h_attr = frame.data('height'); 912 if (!w_attr || !h_attr) return; 913 var percent = (''+w_attr).substr(-1)=='%'; 914 w_attr = parseInt(w_attr); 915 h_attr = parseInt(h_attr); 916 var w_real = Math.min(percent || frame.parents('.columns_wrap').length>0 ? 10000 : w_attr, frame.parents('div,article').width()), //player.width(); 917 h_real = Math.round(percent ? w_real/ratio : w_real/w_attr*h_attr); 918 if (parseInt(frame.attr('data-last-width'))==w_real) return; 919 if (percent) { 920 frame.height(h_real); 921 } else { 922 frame.css({'width': w_real+'px', 'height': h_real+'px'}); 923 } 924 frame.attr('data-last-width', w_real); 925 }); 926 jQuery('video.sc_video,video.wp-video-shortcode').each(function() { 927 "use strict"; 928 if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return; 929 var video = jQuery(this).eq(0); 930 var ratio = (video.data('ratio')!=undefined ? video.data('ratio').split(':') : [16,9]); 931 ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1]; 932 var mejs_cont = video.parents('.mejs-video'); 933 var frame = video.parents('.sc_video_frame'); 934 var w_attr = frame.length>0 ? frame.data('width') : video.data('width'); 935 var h_attr = frame.length>0 ? frame.data('height') : video.data('height'); 936 if (!w_attr || !h_attr) { 937 w_attr = video.attr('width'); 938 h_attr = video.attr('height'); 939 if (!w_attr || !h_attr) return;
940 video.data({'width': w_attr, 'height': h_attr}); 941 } 942 var percent = (''+w_attr).substr(-1)=='%'; 943 w_attr = parseInt(w_attr); 944 h_attr = parseInt(h_attr); 945 var w_real = Math.round(mejs_cont.length > 0 ? Math.min(percent ? 10000 : w_attr, mejs_cont.parents('div,article').width()) : video.width()), 946 h_real = Math.round(percent ? w_real/ratio : w_real/w_attr*h_attr); 947 if (parseInt(video.attr('data-last-width'))==w_real) return; 948 if (mejs_cont.length > 0 && mejs) { 949 yolanddesign_set_mejs_player_dimensions(video, w_real, h_real); 950 } 951 if (percent) { 952 video.height(h_real); 953 } else { 954 video.attr({'width': w_real, 'height': h_real}).css({'width': w_real+'px', 'height': h_real+'px'}); 955 } 956 video.attr('data-last-width', w_real); 957 }); 958 jQuery('video.sc_video_bg').each(function() { 959 "use strict"; 960 if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return; 961 var video = jQuery(this).eq(0); 962 var ratio = (video.data('ratio')!=undefined ? video.data('ratio').split(':') : [16,9]); 963 ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1]; 964 var mejs_cont = video.parents('.mejs-video'); 965 var container = mejs_cont.length>0 ? mejs_cont.parent() : video.parent(); 966 var w = container.width(); 967 var h = container.height(); 968 var w1 = Math.ceil(h*ratio); 969 var h1 = Math.ceil(w/ratio); 970 if (video.parents('.sc_parallax').length > 0) { 971 var windowHeight = jQuery(window).height(); 972 var speed = Number(video.parents('.sc_parallax').data('parallax-speed')); 973 var h_add = Math.ceil(Math.abs((windowHeight-h)*speed)); 974 if (h1 < h + h_add) { 975 h1 = h + h_add; 976 w1 = Math.ceil(h1 * ratio); 977 } 978 } 979 if (h1 < h) { 980 h1 = h; 981 w1 = Math.ceil(h1 * ratio); 982 } 983 if (w1 < w) { 984 w1 = w; 985 h1 = Math.ceil(w1 / ratio); 986 } 987 var l = Math.round((w1-w)/2); 988 var t = Math.round((h1-h)/2); 989 if (parseInt(video.attr('data-last-width'))==w1) return; 990 if (mejs_cont.length > 0) { 991 yolanddesign_set_mejs_player_dimensions(video, w1, h1); 992 mejs_cont.css({ 993 //'left': -l+'px', 994 'top': -t+'px' 995 }); 996 } else 997 video.css({ 998 //'left': -l+'px', 999 'top': -t+'px' 1000 }); 1001 video.attr({'width': w1, 'height': h1, 'data-last-width':w1}).css({'width':w1+'px', 'height':h1+'px'}); 1002 if (video.css('opacity')==0) video.animate({'opacity': 1}, 3000); 1003 }); 1004 jQuery('iframe').each(function() { 1005 "use strict"; 1006 if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return; 1007 var iframe = jQuery(this).eq(0); 1008 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])); 1009 ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1]; 1010 var w_attr = iframe.attr('width'); 1011 var h_attr = iframe.attr('height'); 1012 var frame = iframe.parents('.sc_video_frame'); 1013 if (frame.length > 0) { 1014 w_attr = frame.data('width'); 1015 h_attr = frame.data('height'); 1016 } 1017 if (!w_attr || !h_attr) { 1018 return; 1019 } 1020 var percent = (''+w_attr).substr(-1)=='%'; 1021 w_attr = parseInt(w_attr); 1022 h_attr = parseInt(h_attr); 1023 var w_real = frame.length > 0 ? frame.width() : iframe.width(), 1024 h_real = Math.round(percent ? w_real/ratio : w_real/w_attr*h_attr); 1025 if (parseInt(iframe.attr('data-last-width'))==w_real) return; 1026 iframe.css({'width': w_real+'px', 'height': h_real+'px'}); 1027 }); 1028} 1029 1030// Resize fullscreen video background 1031function yolanddesign_resize_video_background() { 1032 "use strict"; 1033 var bg = jQuery('.video_bg'); 1034 if (bg.length < 1) 1035 return; 1036 if (YOLANDDESIGN_STORAGE['media_elements_enabled'] && bg.find('.mejs-video').length == 0) { 1037 setTimeout(yolanddesign_resize_video_background, 100); 1038 return; 1039 } 1040 var video = bg.find('video'); 1041 var ratio = (video.data('ratio')!=undefined ? video.data('ratio').split(':') : [16,9]); 1042 ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1]; 1043 var w = bg.width(); 1044 var h = bg.height(); 1045 var w1 = Math.ceil(h*ratio); 1046 var h1 = Math.ceil(w/ratio); 1047 if (h1 < h) { 1048 h1 = h; 1049 w1 = Math.ceil(h1 * ratio); 1050 } 1051 if (w1 < w) { 1052 w1 = w; 1053 h1 = Math.ceil(w1 / ratio); 1054 } 1055 var l = Math.round((w1-w)/2); 1056 var t = Math.round((h1-h)/2); 1057 if (bg.find('.mejs-container').length > 0) { 1058 yolanddesign_set_mejs_player_dimensions(bg.find('video'), w1, h1);
1059 bg.find('.mejs-container').css({'left': -l+'px', 'top': -t+'px'}); 1060 } else 1061 bg.find('video').css({'left': -l+'px', 'top': -t+'px'}); 1062 bg.find('video').attr({'width': w1, 'height': h1}).css({'width':w1+'px', 'height':h1+'px'}); 1063} 1064 1065// Set Media Elements player dimensions 1066function yolanddesign_set_mejs_player_dimensions(video, w, h) { 1067 "use strict"; 1068 if (mejs) { 1069 for (var pl in mejs.players) { 1070 if (mejs.players[pl].media.src == video.attr('src')) { 1071 if (mejs.players[pl].media.setVideoSize) { 1072 mejs.players[pl].media.setVideoSize(w, h); 1073 } 1074 mejs.players[pl].setPlayerSize(w, h); 1075 mejs.players[pl].setControlsSize(); 1076 } 1077 } 1078 } 1079} 1080 1081// Resize Fullscreen Slider 1082function yolanddesign_resize_fullscreen_slider() { 1083 "use strict"; 1084 var slider_wrap = jQuery('.slider_wrap.slider_fullscreen'); 1085 if (slider_wrap.length < 1) 1086 return; 1087 var slider = slider_wrap.find('.sc_slider_swiper'); 1088 if (slider.length < 1) 1089 return; 1090 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); 1091 slider.height(h); 1092} 1093 1094// Resize Alter portfolio elements 1095function yolanddesign_resize_alter_portfolio() { 1096 "use strict"; 1097 var wrap = jQuery('.isotope_wrap.inited'); 1098 if (wrap.length==0) return; 1099 wrap.each(function() { 1100 "use strict"; 1101 var alter = jQuery(this).find('.post_item_alter'); 1102 if (alter.length==0) return; 1103 var single = alter.find('.post_featured img[data-alter-items-w="1"]').eq(0); 1104 if (single.length != 1) return; 1105 var w_real = single.width(); 1106 var h_real = single.height(); 1107 var space = Number(single.data('alter-item-space')); 1108 var relayout = false; 1109 alter.find('.post_featured img').each(function() { 1110 "use strict"; 1111 var items_w = Number(jQuery(this).data('alter-items-w')); 1112 var items_h = Number(jQuery(this).data('alter-items-h')); 1113 if (items_h > 1) { 1114 jQuery(this).height(Math.round(items_h*h_real+(items_h-1)*(space+1))); 1115 relayout = true; 1116 } else if (items_w > 1) { 1117 jQuery(this).height(h_real); 1118 relayout = true; 1119 } 1120 }); 1121 if (relayout) { 1122 jQuery(this).isotope('layout'); 1123 } 1124 }); 1125} 1126 1127 1128 1129 1130 1131// Navigation 1132//============================================== 1133 1134// Init Superfish menu 1135function yolanddesign_init_sfmenu(selector) { 1136 jQuery(selector).show().each(function() { 1137 if (yolanddesign_is_responsive_need() && (jQuery(this).attr('id')=='menu_main' || jQuery(this).attr('id')=='menu_side')) return; 1138 jQuery(this).addClass('inited').superfish({ 1139 delay: 500, 1140 animation: { 1141 opacity: 'show' 1142 }, 1143 animationOut: { 1144 opacity: 'hide' 1145 }, 1146 speed: YOLANDDESIGN_STORAGE['css_animation'] ? 500 : 200, 1147 speedOut: YOLANDDESIGN_STORAGE['css_animation'] ? 500 : 200,
1148 autoArrows: false, 1149 dropShadows: false, 1150 onBeforeShow: function(ul) { 1151 if (jQuery(this).parents("ul").length > 1){ 1152 var w = jQuery(window).width(); 1153 var par_offset = jQuery(this).parents("ul").offset().left; 1154 var par_width = jQuery(this).parents("ul").outerWidth(); 1155 var ul_width = jQuery(this).outerWidth(); 1156 if (par_offset+par_width+ul_width > w-20 && par_offset-ul_width > 0) 1157 jQuery(this).addClass('submenu_left'); 1158 else 1159 jQuery(this).removeClass('submenu_left'); 1160 } 1161 if (YOLANDDESIGN_STORAGE['css_animation']) { 1162 jQuery(this).removeClass('animated fast '+YOLANDDESIGN_STORAGE['menu_animation_out']); 1163 jQuery(this).addClass('animated fast '+YOLANDDESIGN_STORAGE['menu_animation_in']); 1164 } 1165 }, 1166 onBeforeHide: function(ul) { 1167 if (YOLANDDESIGN_STORAGE['css_animation']) { 1168 jQuery(this).removeClass('animated fast '+YOLANDDESIGN_STORAGE['menu_animation_in']); 1169 jQuery(this).addClass('animated fast '+YOLANDDESIGN_STORAGE['menu_animation_out']); 1170 } 1171 } 1172 }); 1173 }); 1174} 1175 1176 1177// Build page TOC from the tag's id 1178function yolanddesign_build_page_toc() { 1179 "use strict"; 1180 var toc = '', toc_count = 0; 1181 jQuery('[id^="toc_"],.sc_anchor').each(function(idx) { 1182 "use strict"; 1183 var obj = jQuery(this); 1184 var id = obj.attr('id'); 1185 var url = obj.data('url'); 1186 var icon = obj.data('icon'); 1187 if (!icon) icon = 'icon-circle-dot'; 1188 var title = obj.attr('title'); 1189 var description = obj.data('description'); 1190 var separator = obj.data('separator'); 1191 toc_count++; 1192 toc += '<div class="toc_item'+(separator=='yes' ? ' toc_separator' : '')+'">' 1193 +(description ? '<div class="toc_description">'+description+'</div>' : '') 1194 +'<a href="'+(url ? url : '#'+id)+'" class="toc_icon'+(title ? ' with_title' : '')+' '+icon+'">'+(title ? '<span class="toc_title">'+title+'</span>' : '')+'</a>' 1195 +'</div>'; 1196 }); 1197 if (toc_count > (YOLANDDESIGN_STORAGE['toc_menu_home'] ? 1 : 0) + (YOLANDDESIGN_STORAGE['toc_menu_top'] ? 1 : 0)) { 1198 if (jQuery('#toc').length > 0) 1199 jQuery('#toc .toc_inner').html(toc); 1200 else 1201 jQuery('body').append('<div id="toc" class="toc_'+YOLANDDESIGN_STORAGE['toc_menu']+'"><div class="toc_inner">'+toc+'</div></div>'); 1202 } 1203} 1204 1205 1206// Show current page title on the responsive menu button 1207function yolanddesign_show_current_menu_item(menu, button) { 1208 "use strict"; 1209 menu.find('a').each(function () { 1210 var menu_link = jQuery(this); 1211 if (menu_link.text() == "") { 1212 return; 1213 } 1214 if (menu_link.attr('href') == window.location.href) 1215 button.text(menu_link.text()); 1216 }); 1217} 1218 1219 1220// Prepare menus (if menu cache is used) 1221function yolanddesign_prepare_menus() { 1222 "use strict"; 1223 var menus = [ 1224 jQuery('header ul.menu_main_nav'), 1225 jQuery('ul#menu_user'), 1226 jQuery('ul#menu_side'), 1227 jQuery('ul#menu_footer'), 1228 jQuery('ul#menu_pushy') 1229 ]; 1230 var href = window.location.href; 1231 for (var m in menus) { 1232 if (menus[m].length==0) continue; 1233 menus[m].find('li').removeClass('current-menu-ancestor current-menu-parent current-menu-item current_page_item'); 1234 menus[m].find('a[href="'+href+'"]').each(function(idx) { 1235 var li = jQuery(this).parent(); 1236 li.addClass('current-menu-item'); 1237 if (li.hasClass('menu-item-object-page')) li.addClass('current_page_item'); 1238 var cnt = 0; 1239 while ((li = li.parents('li')).length > 0) { 1240 cnt++; 1241 li.addClass('current-menu-ancestor'+(cnt==1 ? ' current-menu-parent' : '')); 1242 } 1243 }); 1244 } 1245} 1246 1247 1248 1249// Isotope 1250//===================================================== 1251 1252// First init isotope containers 1253function yolanddesign_init_isotope() { 1254 "use strict"; 1255 1256 var all_images_complete = true; 1257 1258 // Check if all images in isotope wrapper are loaded 1259 jQuery('.isotope_wrap:not(.inited)').each(function () { 1260 "use strict"; 1261 all_images_complete = all_images_complete && yolanddesign_check_images_complete(jQuery(this)); 1262 }); 1263 // Wait for images loading 1264 if (!all_images_complete && YOLANDDESIGN_STORAGE['isotope_init_counter']++ < 30) { 1265 setTimeout(yolanddesign_init_isotope, 200); 1266 return; 1267 } 1268 1269 // Isotope filters handler 1270 jQuery('.isotope_filters:not(.inited)').addClass('inited').on('click', 'a', function(e) { 1271 "use strict"; 1272 jQuery(this).parents('.isotope_filters').find('a').removeClass('active'); 1273 jQuery(this).addClass('active'); 1274 1275 var selector = jQuery(this).data('filter'); 1276 jQuery(this).parents('.isotope_filters').siblings('.isotope_wrap').eq(0).isotope({ 1277 filter: selector 1278 }); 1279 1280 if (selector == '*') 1281 jQuery('#viewmore_link').fadeIn(); 1282 else 1283 jQuery('#viewmore_link').fadeOut(); 1284 1285 e.preventDefault(); 1286 return false;
1287 }); 1288 1289 // Init isotope script 1290 jQuery('.isotope_wrap:not(.inited)').each(function() { 1291 "use strict"; 1292 1293 var isotope_container = jQuery(this); 1294 1295 // Init shortcodes 1296 yolanddesign_sc_init(isotope_container); 1297 1298 // If in scroll container - no init isotope 1299 if (isotope_container.parents('.sc_scroll').length > 0) { 1300 isotope_container.addClass('inited').find('.isotope_item').animate({opacity: 1}, 200, function () { jQuery(this).addClass('isotope_item_show'); }); 1301 return; 1302 } 1303 1304 // Init isotope with timeout 1305 setTimeout(function() { 1306 isotope_container.addClass('inited').isotope({ 1307 itemSelector: '.isotope_item', 1308 animationOptions: { 1309 duration: 750, 1310 easing: 'linear', 1311 queue: false 1312 } 1313 }); 1314 1315 // Show elements 1316 isotope_container.find('.isotope_item').animate({opacity: 1}, 200, function () { 1317 jQuery(this).addClass('isotope_item_show'); 1318 }); 1319 1320 // Resize Alter portfolio elements 1321 yolanddesign_resize_alter_portfolio(); 1322 1323 }, 500); 1324 1325 }); 1326} 1327 1328function yolanddesign_init_appended_isotope(posts_container, filters) { 1329 "use strict"; 1330 1331 if (posts_container.parents('.sc_scroll_horizontal').length > 0) return; 1332 1333 if (!yolanddesign_check_images_complete(posts_container) && YOLANDDESIGN_STORAGE['isotope_init_counter']++ < 30) { 1334 setTimeout(function() { yolanddesign_init_appended_isotope(posts_container, filters); }, 200); 1335 return; 1336 } 1337 // Add filters 1338 var flt = posts_container.siblings('.isotope_filter'); 1339 for (var i in filters) { 1340 if (flt.find('a[data-filter=".flt_'+i+'"]').length == 0) { 1341 flt.append('<a href="#" class="isotope_filters_button" data-filter=".flt_'+i+'">'+filters[i]+'</a>'); 1342 } 1343 } 1344 // Init shortcodes in added elements 1345 yolanddesign_sc_init(posts_container); 1346 // Get added elements 1347 var elems = posts_container.find('.isotope_item:not(.isotope_item_show)'); 1348 // Notify isotope about added elements with timeout 1349 setTimeout(function() { 1350 posts_container.isotope('appended', elems); 1351 // Show appended elements 1352 elems.animate({opacity: 1}, 200, function () { jQuery(this).addClass('isotope_item_show'); }); 1353 }, 500); 1354} 1355 1356 1357 1358// Post formats init 1359//===================================================== 1360 1361function yolanddesign_init_post_formats() { 1362 "use strict"; 1363 1364 // Call theme specific action (if exists) 1365 if (window.yolanddesign_theme_init_post_formats) yolanddesign_theme_init_post_formats(); 1366 1367 // MediaElement init 1368 yolanddesign_init_media_elements(jQuery('body')); 1369 1370 // Isotope first init 1371 if (jQuery('.isotope_wrap:not(.inited)').length > 0) { 1372 YOLANDDESIGN_STORAGE['isotope_init_counter'] = 0; 1373 yolanddesign_init_isotope(); 1374 } 1375 1376 // Hover Effect 'Dir' 1377 if (jQuery('.isotope_wrap .isotope_item_content.square.effect_dir:not(.inited)').length > 0) { 1378 jQuery('.isotope_wrap .isotope_item_content.square.effect_dir:not(.inited)').each(function() { 1379 jQuery(this).addClass('inited').hoverdir(); 1380 }); 1381 } 1382 1383 // Popup init 1384 if (YOLANDDESIGN_STORAGE['popup_engine'] == 'pretty') { 1385 jQuery("a[href$='jpg'],a[href$='jpeg'],a[href$='png'],a[href$='gif']").attr('rel', 'prettyPhoto[slideshow]'); 1386 var images = jQuery("a[rel*='prettyPhoto']:not(.inited):not(.esgbox):not([data-rel*='pretty']):not([rel*='magnific']):not([data-rel*='magnific'])").addClass('inited'); 1387 try { 1388 images.prettyPhoto({ 1389 social_tools: '', 1390 theme: 'facebook', 1391 deeplinking: false 1392 }); 1393 } catch (e) {}; 1394 } else if (YOLANDDESIGN_STORAGE['popup_engine']=='magnific') { 1395 jQuery("a[href$='jpg'],a[href$='jpeg'],a[href$='png'],a[href$='gif']").attr('rel', 'magnific'); 1396 var images = jQuery("a[rel*='magnific']:not(.inited):not(.esgbox):not(.prettyphoto):not([rel*='pretty']):not([data-rel*='pretty'])").addClass('inited'); 1397 try { 1398 images.magnificPopup({ 1399 type: 'image', 1400 mainClass: 'mfp-img-mobile', 1401 closeOnContentClick: true, 1402 closeBtnInside: true, 1403 fixedContentPos: true, 1404 midClick: true, 1405 //removalDelay: 500, 1406 preloader: true, 1407 tLoading: YOLANDDESIGN_STORAGE['strings']['magnific_loading'], 1408 gallery:{ 1409 enabled: true 1410 }, 1411 image: { 1412 tError: YOLANDDESIGN_STORAGE['strings']['magnific_error'], 1413 verticalFit: true 1414 } 1415 }); 1416 } catch (e) {}; 1417 } 1418 1419 1420 // Add hover icon to products thumbnails 1421 jQuery(".post_item_product .product .images a.woocommerce-main-image:not(.hover_icon)").addClass('hover_icon hover_icon_view'); 1422 1423 1424 // Likes counter
1425 if (jQuery('.post_counters_likes:not(.inited)').length > 0) { 1426 jQuery('.post_counters_likes:not(.inited)') 1427 .addClass('inited') 1428 .on('click', function(e) { 1429 var button = jQuery(this); 1430 var inc = button.hasClass('enabled') ? 1 : -1; 1431 var post_id = button.data('postid'); 1432 var likes = Number(button.data('likes'))+inc; 1433 var cookie_likes = yolanddesign_get_cookie('yolanddesign_likes'); 1434 if (cookie_likes === undefined || cookie_likes===null) cookie_likes = ''; 1435 jQuery.post(YOLANDDESIGN_STORAGE['ajax_url'], { 1436 action: 'post_counter', 1437 nonce: YOLANDDESIGN_STORAGE['ajax_nonce'], 1438 post_id: post_id, 1439 likes: likes 1440 }).done(function(response) { 1441 var rez = {}; 1442 try { 1443 rez = JSON.parse(response); 1444 } catch (e) { 1445 rez = { error: YOLANDDESIGN_STORAGE['ajax_error'] }; 1446 console.log(response); 1447 } 1448 if (rez.error === '') { 1449 if (inc == 1) { 1450 var title = button.data('title-dislike'); 1451 button.removeClass('enabled').addClass('disabled'); 1452 cookie_likes += (cookie_likes.substr(-1)!=',' ? ',' : '') + post_id + ','; 1453 } else { 1454 var title = button.data('title-like'); 1455 button.removeClass('disabled').addClass('enabled'); 1456 cookie_likes = cookie_likes.replace(','+post_id+',', ','); 1457 } 1458 button.data('likes', likes).attr('title', title).find('.post_counters_number').html(likes); 1459 yolanddesign_set_cookie('yolanddesign_likes', cookie_likes, 365); 1460 } else { 1461 yolanddesign_message_warning(YOLANDDESIGN_STORAGE['strings']['error_like']); 1462 } 1463 }); 1464 e.preventDefault(); 1465 return false; 1466 }); 1467 } 1468 1469 // Social share links 1470 if (jQuery('.sc_socials_share:not(.inited)').length > 0) { 1471 jQuery('.sc_socials_share:not(.inited)').each(function() { 1472 "use strict"; 1473 jQuery(this).addClass('inited').on('click', '.social_item_popup > a.social_icons', function(e) { 1474 "use strict"; 1475 var url = jQuery(this).data('link'); 1476 window.open(url, '_blank', 'scrollbars=0, resizable=1, menubar=0, left=100, top=100, width=480, height=400, toolbar=0, status=0'); 1477 e.preventDefault(); 1478 return false; 1479 }); 1480 }); 1481 } 1482 1483 // Add video on thumb click 1484 if (jQuery('.sc_video_play_button:not(.inited)').length > 0) { 1485 jQuery('.sc_video_play_button:not(.inited)').each(function() { 1486 "use strict"; 1487 jQuery(this) 1488 .addClass('inited') 1489 .animate({opacity: 1}, 1000) 1490 .on('click', function (e) { 1491 "use strict"; 1492 if (!jQuery(this).hasClass('sc_video_play_button')) return; 1493 var video = jQuery(this).removeClass('sc_video_play_button hover_icon hover_icon_play').data('video'); 1494 if (video!=='') { 1495 jQuery(this).empty().html(video); 1496 yolanddesign_video_dimensions(); 1497 var video_tag = jQuery(this).find('video'); 1498 var w = video_tag.width(); 1499 var h = video_tag.height(); 1500 yolanddesign_init_media_elements(jQuery(this)); 1501 // Restore WxH attributes, because Chrome broke it! 1502 jQuery(this).find('video').css({'width':w, 'height': h}).attr({'width':w, 'height': h}); 1503 } 1504 e.preventDefault(); 1505 return false; 1506 }); 1507 }); 1508 } 1509} 1510 1511 1512function yolanddesign_init_media_elements(cont) { 1513 if (YOLANDDESIGN_STORAGE['media_elements_enabled'] && cont.find('audio,video').length > 0) { 1514 if (window.mejs) { 1515 window.mejs.MepDefaults.enableAutosize = false; 1516 window.mejs.MediaElementDefaults.enableAutosize = false; 1517 cont.find('audio:not(.wp-audio-shortcode),video:not(.wp-video-shortcode)').each(function() { 1518 if (jQuery(this).parents('.mejs-mediaelement').length == 0) { 1519 var media_tag = jQuery(this); 1520 var settings = { 1521 enableAutosize: true, 1522 videoWidth: -1, // if set, overrides <video width> 1523 videoHeight: -1, // if set, overrides <video height> 1524 audioWidth: '100%', // width of audio player 1525 audioHeight: 30, // height of audio player 1526 success: function(mejs) { 1527 var autoplay, loop; 1528 if ( 'flash' === mejs.pluginType ) { 1529 autoplay = mejs.attributes.autoplay && 'false' !== mejs.attributes.autoplay; 1530 loop = mejs.attributes.loop && 'false' !== mejs.attributes.loop; 1531 autoplay && mejs.addEventListener( 'canplay', function () { 1532 mejs.play(); 1533 }, false ); 1534 loop && mejs.addEventListener( 'ended', function () { 1535 mejs.play(); 1536 }, false ); 1537 } 1538 media_tag.parents('.sc_audio,.sc_video').addClass('inited sc_show'); 1539 } 1540 }; 1541 jQuery(this).mediaelementplayer(settings); 1542 } 1543 }); 1544 } else 1545 setTimeout(function() { yolanddesign_init_media_elements(cont); }, 400); 1546 } 1547} 1548 1549 1550 1551 1552 1553 1554// Popups and system messages 1555//============================================== 1556 1557// Show system message (bubble from previous page) 1558function yolanddesign_show_system_message() { 1559 if (YOLANDDESIGN_STORAGE['system_message'] && YOLANDDESIGN_STORAGE['system_message']['message']) { 1560 if (YOLANDDESIGN_STORAGE['system_message']['status'] == 'success') 1561 yolanddesign_message_success(YOLANDDESIGN_STORAGE['system_message']['message'], YOLANDDESIGN_STORAGE['system_message']['header']); 1562 else if (YOLANDDESIGN_STORAGE['system_message']['status'] == 'info') 1563 yolanddesign_message_info(YOLANDDESIGN_STORAGE['system_message']['message'], YOLANDDESIGN_STORAGE['system_message']['header']); 1564 else if (YOLANDDESIGN_STORAGE['system_message']['status'] == 'error' || YOLANDDESIGN_STORAGE['system_message']['status'] == 'warning') 1565 yolanddesign_message_warning(YOLANDDESIGN_STORAGE['system_message']['message'], YOLANDDESIGN_STORAGE['system_message']['header']); 1566 } 1567} 1568 1569// Toggle popups 1570function yolanddesign_toggle_popup(popup) { 1571 if (popup.css('display')!='none') 1572 yolanddesign_hide_popup(popup); 1573 else 1574 yolanddesign_show_popup(popup); 1575} 1576 1577// Show popups 1578function yolanddesign_show_popup(popup) { 1579 if (popup.css('display')=='none') { 1580 if (false && YOLANDDESIGN_STORAGE['css_animation']) 1581 popup.show().removeClass('animated fast '+YOLANDDESIGN_STORAGE['menu_animation_out']).addClass('animated fast '+YOLANDDESIGN_STORAGE['menu_animation_in']); 1582 else 1583 popup.slideDown(); 1584 } 1585} 1586 1587// Hide popups 1588function yolanddesign_hide_popup(popup) { 1589 if (popup.css('display')!='none') { 1590 if (false && YOLANDDESIGN_STORAGE['css_animation']) 1591 popup.removeClass('animated fast '+YOLANDDESIGN_STORAGE['menu_animation_in']).addClass('animated fast '+YOLANDDESIGN_STORAGE['menu_animation_out']).delay(500).hide(); 1592 else 1593 popup.fadeOut(); 1594 } 1595} 1596 1597 1598 1599 1600// Forms validation 1601//------------------------------------------------------- 1602 1603 1604// Comments form 1605function yolanddesign_comments_validate(form) { 1606 "use strict"; 1607 form.find('input').removeClass('error_fields_class'); 1608 var rules = { 1609 error_message_text: YOLANDDESIGN_STORAGE['strings']['error_global'], // Global error message text (if don't write in checked field) 1610 error_message_show: true, // Display or not error message 1611 error_message_time: 4000, // Error message display time 1612 error_message_class: 'sc_infobox sc_infobox_style_error', // Class appended to error message block 1613 error_fields_class: 'error_fields_class', // Class appended to error fields 1614 exit_after_first_error: false, // Cancel validation and exit after first error 1615 rules: [ 1616 { 1617 field: 'comment', 1618 min_length: { value: 1, message: YOLANDDESIGN_STORAGE['strings']['text_empty'] }, 1619 max_length: { value: YOLANDDESIGN_STORAGE['comments_maxlength'], message: YOLANDDESIGN_STORAGE['strings']['text_long']} 1620 } 1621 ] 1622 }; 1623 if (form.find('.comments_author input[aria-required="true"]').length > 0) { 1624 rules.rules.push( 1625 { 1626 field: 'author', 1627 min_length: { value: 1, message: YOLANDDESIGN_STORAGE['strings']['name_empty']}, 1628 max_length: { value: 60, message: YOLANDDESIGN_STORAGE['strings']['name_long']} 1629 } 1630 ); 1631 } 1632 if (form.find('.comments_email input[aria-required="true"]').length > 0) { 1633 rules.rules.push( 1634 { 1635 field: 'email', 1636 min_length: { value: 7, message: YOLANDDESIGN_STORAGE['strings']['email_empty']}, 1637 max_length: { value: 60, message: YOLANDDESIGN_STORAGE['strings']['email_long']}, 1638 mask: { value: YOLANDDESIGN_STORAGE['email_mask'], message: YOLANDDESIGN_STORAGE['strings']['email_not_val
1638id']} 1639 } 1640 ); 1641 } 1642 var error = yolanddesign_form_validate(form, rules); 1643 return !error; 1644} 1645 1646 1647// Login form 1648function yolanddesign_login_validate(form) { 1649 "use strict"; 1650 form.find('input').removeClass('error_fields_class'); 1651 var error = yolanddesign_form_validate(form, { 1652 error_message_show: true, 1653 error_message_time: 4000, 1654 error_message_class: 'sc_infobox sc_infobox_style_error', 1655 error_fields_class: 'error_fields_class', 1656 exit_after_first_error: true, 1657 rules: [ 1658 { 1659 field: "log", 1660 min_length: { value: 1, message: YOLANDDESIGN_STORAGE['strings']['login_empty'] }, 1661 max_length: { value: 60, message: YOLANDDESIGN_STORAGE['strings']['login_long'] } 1662 }, 1663 { 1664 field: "pwd", 1665 min_length: { value: 4, message: YOLANDDESIGN_STORAGE['strings']['password_empty'] }, 1666 max_length: { value: 30, message: YOLANDDESIGN_STORAGE['strings']['password_long'] } 1667 } 1668 ] 1669 }); 1670 if (!error) { 1671 jQuery.post(YOLANDDESIGN_STORAGE['ajax_url'], { 1672 action: 'login_user', 1673 nonce: YOLANDDESIGN_STORAGE['ajax_nonce'], 1674 remember: form.find('#rememberme').val(), 1675 user_log: form.find('#log').val(), 1676 user_pwd: form.find('#password').val() 1677 }).done(function(response) { 1678 var rez = {}; 1679 try { 1680 rez = JSON.parse(response); 1681 } catch (e) { 1682 rez = { error: YOLANDDESIGN_STORAGE['ajax_error'] }; 1683 console.log(response); 1684 } 1685 var result_box = form.find('.result'); 1686 if (result_box.length==0) result_box = form.siblings('.result'); 1687 if (result_box.length==0) result_box = form.after('<div class="result"></div>').next('.result'); 1688 result_box.toggleClass('sc_infobox_style_error', false).toggleClass('sc_infobox_style_success', false); 1689 if (rez.error === '') { 1690 result_box.addClass('sc_infobox sc_infobox_style_success').html(YOLANDDESIGN_STORAGE['strings']['login_success']); 1691 setTimeout(function() { 1692 location.reload(); 1693 }, 3000); 1694 } else { 1695 result_box.addClass('sc_infobox sc_infobox_style_error').html(YOLANDDESIGN_STORAGE['strings']['login_failed'] + '<br>' + rez.error); 1696 } 1697 result_box.fadeIn().delay(3000).fadeOut(); 1698 }); 1699 } 1700 return false; 1701} 1702 1703 1704// Registration form 1705function yolanddesign_registration_validate(form) { 1706 "use strict"; 1707 form.find('input').removeClass('error_fields_class'); 1708 var error = yolanddesign_form_validate(form, { 1709 error_message_show: true, 1710 error_message_time: 4000, 1711 error_message_class: "sc_infobox sc_infobox_style_error", 1712 error_fields_class: "error_fields_class", 1713 exit_after_first_error: true, 1714 rules: [ 1715 { 1716 field: "registration_agree", 1717 state: { value: 'checked', message: YOLANDDESIGN_STORAGE['strings']['not_agree'] }, 1718 }, 1719 { 1720 field: "registration_username", 1721 min_length: { value: 1, message: YOLANDDESIGN_STORAGE['strings']['login_empty'] }, 1722 max_length: { value: 60, message: YOLANDDESIGN_STORAGE['strings']['login_long'] } 1723 }, 1724 { 1725 field: "registration_email", 1726 min_length: { value: 7, message: YOLANDDESIGN_STORAGE['strings']['email_empty'] }, 1727 max_length: { value: 60, message: YOLANDDESIGN_STORAGE['strings']['email_long'] }, 1728 mask: { value: YOLANDDESIGN_STORAGE['email_mask'], message: YOLANDDESIGN_STORAGE['strings']['email_not_valid'] } 1729 }, 1730 { 1731 field: "registration_pwd", 1732 min_length: { value: 4, message: YOLANDDESIGN_STORAGE['strings']['password_empty'] }, 1733 max_length: { value: 30, message: YOLANDDESIGN_STORAGE['strings']['password_long'] } 1734 }, 1735 { 1736 field: "registration_pwd2", 1737 equal_to: { value: 'registration_pwd', message: YOLANDDESIGN_STORAGE['strings']['password_not_equal'] } 1738 } 1739 ] 1740 }); 1741 if (!error) { 1742 jQuery.post(YOLANDDESIGN_STORAGE['ajax_url'], { 1743 action: 'registration_user', 1744 nonce: YOLANDDESIGN_STORAGE['ajax_nonce'], 1745 user_name: form.find('#registration_username').val(), 1746 user_email: form.find('#registration_email').val(), 1747 user_pwd: form.find('#registration_pwd').val() 1748 }).done(function(response) { 1749 var rez = {}; 1750 try { 1751 rez = JSON.parse(response); 1752 } catch (e) { 1753 rez = { error: YOLANDDESIGN_STORAGE['ajax_error'] }; 1754 console.log(response); 1755 } 1756 var result_box = form.find('.result'); 1757 if (result_box.length==0) result_box = form.siblings('.result'); 1758 if (result_box.length==0) result_box = form.after('<div class="result"></div>').next('.result'); 1759 result_box.toggleClass('sc_infobox_style_error', false).toggleClass('sc_infobox_style_success', false); 1760 if (rez.error === '') { 1761 result_box.addClass('sc_infobox sc_infobox_style_success').html(YOLANDDESIGN_STORAGE['strings']['registration_success']); 1762 setTimeout(function() { 1763 jQuery('.popup_login_link').trigger('click'); 1764 }, 3000); 1765 } else { 1766 result_box.addClass('sc_infobox sc_infobox_style_error').html(YOLANDDESIGN_STORAGE['strings']['registration_failed'] + ' ' + rez.error); 1767 } 1768 result_box.fadeIn().delay(3000).fadeOut(); 1769 }); 1770 } 1771 return false
vendor: 4 bytes, lines 1771-1772
1771; 1772}
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.