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