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