1/** 2 * Shortcodes common scripts 3 * 4 * @package ThemeREX Addons 5 * @since v1.2 6 */ 7 8/* global jQuery, TRX_ADDONS_STORAGE */ 9 10 11jQuery( document ).ready(function() { 12 13 "use strict"; 14 15 var $window = jQuery( window ), 16 $document = jQuery( document ), 17 $body = jQuery( 'body' ); 18 19 var $equal_height, 20 $pagination_infinite, 21 $infinite_posts, 22 $typed_entry; 23 24 // Update links and values after the new post added 25 $document.on( 'action.init_hidden_elements', update_jquery_links ); 26 $document.on( 'action.got_ajax_response', update_jquery_links ); 27 var first_run = true; 28 function update_jquery_links(e) { 29 if ( first_run && e && e.namespace == 'init_hidden_elements' ) { 30 first_run = false; 31 return; 32 } 33 $equal_height = jQuery( '[data-equal-height],.trx_addons_equal_height' ); 34 $pagination_infinite = jQuery( '.sc_item_pagination_infinite' ); 35 $infinite_posts = $pagination_infinite.siblings('.sc_item_posts_container'); 36 $typed_entry = jQuery('.sc_typed_entry'); 37 } 38 update_jquery_links(); 39 40 if ( typeof TRX_ADDONS_STORAGE != 'undefined' ) { 41 TRX_ADDONS_STORAGE['pagination_busy'] = false; 42 } 43 44 // Init elements 45 //------------------------------------------ 46 $document.on( 'action.init_hidden_elements', function() { 47 48 // Trigger click on tab hover 49 var last_link = false, 50 last_link_timer = null; 51 jQuery('.sc_item_filters_tabs_open_on_hover:not(.inited)') 52 .addClass('inited') 53 .on('mouseenter', 'a', function(e) { 54 last_link = jQuery(this); 55 if ( last_link_timer !== null ) { 56 clearTimeout( last_link_timer ); 57 } 58 last_link_timer = setTimeout( function() { 59 last_link.trigger( 'click' ); 60 last_link_timer = null; 61 }, 300 ); 62 } ); 63 64 // Save/Restore sc_layouts_popup inner html on tabs switched 65 var popup_html = {}; 66 function trx_addons_save_popup_html( $obj, restore ) { 67 $obj.each( function( idx ) { 68 var id = $obj.eq( idx ).attr( 'id' ); 69 if ( ! id ) { 70 $id = 'sc_popup_' + trx_addons_get_unique_id(); 71 $obj.eq( idx ).attr( 'id', id ); 72 } 73 if ( ! popup_html.hasOwnProperty( id ) ) { 74 popup_html[ id ] = $obj.eq( idx ).html(); 75 } else if ( restore ) { 76 $obj.eq( idx ).html( popup_html[ id ] ); 77 } 78 } ); 79 } 80 81 // Load next page by AJAX 82 jQuery('.sc_item_filters:not(.inited),.sc_item_pagination:not(.inited)') 83 .addClass('inited') 84 .each( function() { 85 var $self = jQuery( this ); 86 if ( $self.hasClass( 'sc_item_filters' ) ) { 87 trx_addons_save_popup_html( $self.parent().find('.sc_layouts_popup') ); 88 } 89 } ) 90 .on('click', 'a', function(e) { 91 var link = jQuery(this); 92 if ( ! link.hasClass( 'active' ) && ! TRX_ADDONS_STORAGE['pagination_busy'] ) { 93 var link_wrap = link.parents('.sc_item_filters,.sc_item_pagination'), 94 load_more = link_wrap.hasClass('sc_item_pagination_load_more'), 95 sc = link_wrap.parent(), 96 set_min_height = trx_addons_apply_filters( 'trx_addons_filter_set_min_height_on_switch_tabs', true, sc ), 97 posts = sc.find('.sc_item_posts_container,.sc_item_slider'), 98 pagination_wrap = sc.find('.sc_item_pagination'); 99 100 // Save posts to the tab's link 101 if ( link_wrap.hasClass('sc_item_filters') ) { 102 var link_active = link_wrap.find('a.active'); 103 if ( ! link_active.data( 'posts' ) ) { 104 link_active.data( 'posts', posts.html() ); 105 } 106 link_active.data( 'pagination', pagination_wrap.length > 0 ? pagination_wrap.clone() : false ); 107 } 108 109 // Show saved posts 110 if ( link_wrap.hasClass('sc_item_filters') && link.data('posts') !== undefined ) { 111 if ( set_min_height ) { 112 sc.data( 'min-height', sc.css( 'min-height' ) ) 113 .css( 'min-height', sc.height() ); 114 } 115 link_active.removeClass( 'active' ).parent().removeClass( 'sc_item_filters_tabs_active' ); 116 link.addClass('active').parent().addClass( 'sc_item_filters_tabs_active' ); 117 if ( pagination_wrap.length > 0 ) { 118 pagination_wrap.fadeOut(); 119 } 120 posts.animate( { opacity: 0 }, 200, function() { 121 $document.trigger( 'action.before_remove_content', [sc] ); 122 trx_addons_replace_posts( posts, link.data('posts') ); 123 trx_addons_replace_pagination( pagination_wrap, link.data('pagination'), posts ); 124 $document.trigger( 'action.after_add_content', [sc] ); 125 posts.find('.inited').removeClass('inited'); 126 posts.find('.popup_inited').removeClass('popup_inited'); 127 posts.find('.swiper-initialized').removeClass('swiper-initialized'); 128 posts.find('.swiper-container-initialized').removeClass('swiper-container-initialized'); 129 pagination_wrap.find('.inited').removeClass('inited'); 130 $document.trigger( 'action.init_hidden_elements', [sc] ); 131 var posts_height = posts.height(); 132 $window.trigger( 'resize' ); 133 setTimeout( function() { 134 posts.animate( { opacity: 1 }, 200, function() { 135 if ( sc.data('min-height') && set_min_height ) { 136 sc.css( 'min-height', sc.data('min-height') ); 137 } 138 if ( posts.height() === 0 ) { 139 posts.height( posts_height ); 140 } 141 } ); 142 }, 400 ); 143 } ); 144 145 // First time load posts to the tab 146 } else { 147 if ( load_more ) { 148 var page = Number( link.data( 'page' ) ); 149 var max_page = Number( link.data( 'max-page' ) ); 150 if (page > max_page) { 151 pagination_wrap.addClass( 'all_items_loaded' ).hide(); 152 return false;
153 } 154 link_wrap.addClass('loading'); 155 } else { 156 posts.append( TRX_ADDONS_STORAGE['loading_layout'] ); 157 } 158 TRX_ADDONS_STORAGE['pagination_busy'] = true; 159 var params = pagination_wrap.length > 0 ? pagination_wrap.data('params') : link_wrap.data('params'); 160 jQuery.post(TRX_ADDONS_STORAGE['ajax_url'], { 161 action: 'trx_addons_item_pagination', 162 nonce: TRX_ADDONS_STORAGE['ajax_nonce'], 163 params: typeof params == 'object' ? JSON.stringify( params ) : params, 164 page: link.parents('.sc_item_filters').length > 0 ? 1 : link.data('page'), 165 filters_active: link.parents('.sc_item_filters').length > 0 166 ? link.data('tab') 167 : (link_wrap.siblings('.sc_item_filters').find('a.active').length > 0 168 ? link_wrap.siblings('.sc_item_filters').find('a.active').data('tab') 169 : 'all' 170 ) 171 }).done( function( response ) { 172 var rez = trx_addons_parse_ajax_response( response ); 173 if (rez.error === '') { 174 // Add inline styles 175 if (rez.css !== '') { 176 var selector = 'trx_addons-inline-styles-inline-css', 177 inline_css = jQuery('#'+selector); 178 if (inline_css.length === 0) 179 jQuery('body').append('<style id="'+selector+'" type="text/css">' + rez.css + '</style>'); 180 else 181 inline_css.append(rez.css); 182 } 183 // Append posts 184 if (load_more) { 185 // Remove 'single_row' class 186 posts.removeClass( 'columns_in_single_row' ); 187 // Append posts to the tabs container 188 if (posts.find('[class*="_tabs_list_item"]').length > 0) { 189 posts.find('[class*="_tabs_list_item"]').parent().append(jQuery(rez.data).find('.sc_item_posts_container [class*="_tabs_list_item"]').parent().html()); 190 posts.find('[class$="_tabs_content"]').append(jQuery(rez.data).find('.sc_item_posts_container [class$="_tabs_content"]').html()); 191 // Remove active classes in appended items 192 posts.find('[class*="_tabs_list_item_active"]').each(function(idx) { 193 if (idx > 0) { 194 var classes = jQuery(this).attr('class').split(' '), 195 found = false; 196 for (var i=0; i<classes.length; i++) { 197 if (classes[i].indexOf('_tabs_list_item_active') > 0) { 198 classes[i] = ''; 199 found = true; 200 break; 201 } 202 } 203 if (found) jQuery(this).attr('class', classes.join(' ')); 204 } 205 }); 206 posts.find('[class$="_tabs_content"] [class*="_item_active"]').each(function(idx) { 207 if (idx > 0) { 208 var classes = jQuery(this).attr('class').split(' '), 209 found = false; 210 for (var i=0; i<classes.length; i++) { 211 if (classes[i].indexOf('_item_active') > 0) { 212 classes[i] = ''; 213 found = true; 214 break; 215 } 216 } 217 if (found) jQuery(this).attr('class', classes.join(' ')); 218 } 219 }); 220 221 // Append regular posts 222 } else { 223 if (posts.hasClass('masonry_wrap')) { 224 var items = jQuery(rez.data).find('.sc_item_posts_container .masonry_item'); 225 if (items.length > 0) { 226 items.addClass( 'just_loaded_items hidden' ); 227 posts.append( items ); 228 var just_loaded_items = posts.find( '.just_loaded_items' ); 229 trx_addons_when_images_loaded( 230 just_loaded_items, function() { 231 just_loaded_items.removeClass( 'hidden' ); 232 posts.masonry( 'appended', items ).masonry(); 233 } 234 ); 235 setTimeout(function() { 236 just_loaded_items.removeClass( 'just_loaded_items hidden' ); 237 }, 1000); 238 } 239 } else { 240 posts.append(jQuery(rez.data).find('.sc_item_posts_container').html()); 241 } 242 } 243 // Save popup containers 244 trx_addons_save_popup_html( posts.find('.sc_layouts_popup') ); 245 // Trigger actions to init added items 246 $document.trigger( 'action.after_add_content', [posts] ); 247 $document.trigger( 'action.init_hidden_elements', [posts] ); 248 $window.trigger( 'resize' ); 249 // Update current page in the pagination link 250 link.data('page', Number(link.data('page')) + 1); 251 if (link.data('page') > link.data('max-page')) { 252 pagination_wrap.addClass( 'all_items_loaded' ).fadeOut(); 253 } 254 // Replace shortcode params in the pagination wrapper 255 if ( pagination_wrap.length > 0 ) { 256 var new_params = jQuery(rez.data).find('.sc_item_pagination').data('params'); 257 if ( new_params ) { 258 pagination_wrap.data( 'params', new_params ); 259 } 260 } 261 262 // Replace posts 263 } else { 264 if ( set_min_height ) { 265 sc.data( 'min-height', sc.css( 'min-height' ) ) 266 .css( 'min-height', sc.height() ); 267 } 268 if ( link_wrap.hasClass('sc_item_filters') ) { 269 link_active.removeClass( 'active' ).parent().removeClass( 'sc_item_filters_tabs_active' ); 270 link.addClass('active').parent().addClass( 'sc_item_filters_tabs_active' ); 271 } else { 272 if ( pagination_wrap.length > 0 ) { 273 pagination_wrap.fadeOut(); 274 } 275 } 276 posts.animate( { opacity: 0 }, 200, function() { 277 var items = jQuery(rez.data).find('.sc_item_posts_container,.sc_item_slider'); 278 // Add trx_addons_columns_wrap if need 279 if ( items.find('[class*="trx_addons_column-"]').length > 0 ) { 280 if ( ! posts.hasClass( 'trx_addons_columns_wrap' ) ) { 281 posts.addClass( 'trx_addons_columns_wrap' ); 282 } 283 } else { 284 posts.removeClass( 'trx_addons_columns_wrap' ); 285 } 286 // Add columns_wrap if need 287 if ( items.find('[class*="column-"]').length > 0 ) { 288 if ( ! posts.hasClass( 'columns_wrap' ) ) { 289 posts.addClass( 'columns_wrap' ); 290 } 291 } else { 292 posts.removeClass( 'columns_wrap' ); 293 } 294 $document.trigger('action.before_remove_content', [sc]); 295 trx_addons_replace_posts( posts, items.html() ); 296 trx_addons_replace_pagination( pagination_wrap, jQuery(rez.data).find('.sc_item_pagination'), posts ); 297 $document.trigger( 'action.after_add_content', [sc] ); 298 $document.trigger( 'action.init_hidden_elements', [sc] ); 299 $window.trigger('resize'); 300 setTimeout( function() { 301 posts.animate( { opacity: 1 }, 200, function() { 302 if ( sc.data('min-height') && set_min_height ) { 303 sc.css( 'min-height', sc.data('min-height') ); 304 $window.trigger( 'resize' ); 305 $window.trigger( 'scroll' ); 306 } 307 } ); 308 }, 400 ); 309 } ); 310 } 311 posts.find('.trx_addons_loading').fadeOut( function() { 312 jQuery( this ).remove(); 313 } ); 314 315 } else { 316 alert(rez.error); 317 posts.find('.trx_addons_loading').remove(); 318 } 319 320 if (load_more) pagination_wrap.removeClass('loading'); 321 322 TRX_ADDONS_STORAGE['pagination_busy'] = false;
323 324 $document.trigger( 'action.got_ajax_response', { 325 action: 'trx_addons_item_pagination', 326 result: rez 327 }); 328 }); 329 } 330 } 331 e.preventDefault(); 332 return false; 333 }); 334 335 function trx_addons_replace_posts( posts, posts_new ) { 336 if ( posts.hasClass('masonry_wrap') && posts_new.indexOf('masonry_item') > 0 ) { 337 var items = posts.find('.masonry_item'); 338 posts.masonry( 'remove', items ); 339 posts.html( posts_new ); 340 posts.find( '.inited' ).removeClass( 'inited' ); 341 posts.find( '.popup_inited' ).removeClass( 'popup_inited' ); 342 posts.find( '.swiper-initialized').removeClass('swiper-initialized' ); 343 posts.find( '.swiper-container-initialized').removeClass('swiper-container-initialized' ); 344 items = posts.find('.masonry_item'); 345 if (items.length > 0) { 346 posts.masonry( 'appended', items ).masonry(); 347 } 348 } else { 349 posts.html( posts_new ); 350 if ( posts.find('>.slider_container').length > 0 ) { 351 posts.removeClass( 'trx_addons_columns_wrap columns_wrap masonry_wrap masonry_1 masonry_2 masonry_3 masonry_4 masonry_5 masonry_6' ); 352 } else if ( posts.find('>[class*="trx_addons_column-"]').length > 0 ) { 353 posts.toggleClass( 'trx_addons_columns_wrap', true ); 354 } else if ( posts.find('>[class*="column-"]').length > 0 ) { 355 posts.toggleClass( 'columns_wrap', true ); 356 } else if ( posts.find('>[class*="masonry_item-1_"]').length > 0 ) { 357 var masonry_items_class = 'masonry_3'; 358 posts.find('>[class*="masonry_item-1_"]').eq(0).attr('class').split(' ').map( function(el) { 359 if ( el.indexOf('masonry_item-1_') === 0 ) { 360 masonry_items_class = 'masonry_' + el.split('_')[2]; 361 } 362 } ); 363 posts.toggleClass( 'masonry_wrap ' + masonry_items_class, true ).removeClass( 'inited' ); 364 } 365 } 366 // Save/restore popup containers 367 trx_addons_save_popup_html( posts.find('.sc_layouts_popup'), true ); 368 } 369 370 function trx_addons_replace_pagination( pagination_wrap, pagination_new, posts ) { 371 if ( pagination_new.length > 0 ) { 372 pagination_new.addClass( 'trx_addons_invisible' ); 373 if ( pagination_wrap.length > 0 ) { 374 pagination_wrap 375 .after( pagination_new ) 376 .next().removeClass('inited') 377 .end().remove(); 378 } else { 379 posts 380 .after( pagination_new ) 381 .next().removeClass('inited'); 382 } 383 setTimeout( function() { 384 pagination_new.fadeIn().removeClass('trx_addons_invisible'); 385 }, 400 ); 386 } else { 387 if ( pagination_wrap.length > 0 ) { 388 pagination_wrap.remove(); 389 } 390 } 391 } 392 393 394 // Load post's details by AJAX and show in the popup 395 jQuery('.sc_post_details_popup:not(.inited)') 396 .addClass('inited') 397 .on('click', 'a', function(e) { 398 trx_addons_show_post_details(jQuery(this).parents('[data-post_id]'), true); 399 e.preventDefault(); 400 return false; 401 }); 402 if (jQuery('.sc_post_details_popup.inited').length > 0) { 403 jQuery('body:not(.sc_post_details_popup_inited)') 404 .addClass('sc_post_details_popup_inited') 405 .on('click', '#trx_addons_post_details_popup_overlay, .trx_addons_post_details_popup_close', function(e) { 406 jQuery('#trx_addons_post_details_popup').fadeOut(); 407 jQuery('#trx_addons_post_details_popup_overlay').fadeOut(); 408 }) 409 .on('click', '.trx_addons_post_details_popup_prev,.trx_addons_post_details_popup_next', function(e) { 410 var popup = jQuery('#trx_addons_post_details_popup'); 411 var post_item = popup.data('post_item'); 412 if (!post_item || post_item.length === 0) return; 413 var posts_items = post_item.parents('.sc_item_columns,.sc_item_slider').find('[data-post_id]'); 414 var cur_idx = -1; 415 posts_items.each(function(idx) { 416 if (jQuery(this).data('post_id') == post_item.data('post_id')) cur_idx = idx; 417 }); 418 if (cur_idx == -1) return; 419 post_item = jQuery(this).hasClass('trx_addons_post_details_popup_prev') 420 ? (cur_idx > 0 ? posts_items.eq(cur_idx-1) : false) 421 : (cur_idx < posts_items.length-1 ? posts_items.eq(cur_idx+1) : false); 422 if (!post_item || post_item.length === 0) return; 423 popup.fadeOut(); 424 trx_addons_show_post_details(post_item, false); 425 }); 426 } 427 428 function trx_addons_show_post_details(post_item, show_overlay) { 429 jQuery.post(TRX_ADDONS_STORAGE['ajax_url'], { 430 action: 'trx_addons_post_details_in_popup', 431 nonce: TRX_ADDONS_STORAGE['ajax_nonce'], 432 post_id: post_item.data('post_id'), 433 post_type: post_item.data('post_type') 434 }).done( function( response ) { 435 var rez = trx_addons_parse_ajax_response( response ); 436 var msg = rez.error === '' ? rez.data : rez.error; 437 var popup = jQuery('#trx_addons_post_details_popup');
438 var overlay = jQuery('#trx_addons_post_details_popup_overlay'); 439 if ( popup.length === 0 ) { 440 jQuery('body').append( 441 '<div id="trx_addons_post_details_popup_overlay"></div>' 442 + '<div id="trx_addons_post_details_popup">' 443 + '<div class="trx_addons_post_details_content"></div>' 444 + '<span class="trx_addons_post_details_popup_close trx_addons_icon-cancel"></span>' 445 + '<span class="trx_addons_post_details_popup_prev trx_addons_icon-left"></span>' 446 + '<span class="trx_addons_post_details_popup_next trx_addons_icon-right"></span>' 447 + '</div>'); 448 popup = jQuery('#trx_addons_post_details_popup'); 449 overlay = jQuery('#trx_addons_post_details_popup_overlay'); 450 } 451 popup.data('post_item', post_item).find('.trx_addons_post_details_content').html(msg); 452 // Load styles and scripts for the popup content 453 var handle, $head = jQuery( 'head' ); 454 if ( rez.error === '' ) { 455 // Load styles (add to the head) 456 if ( rez['css'] ) { 457 for ( handle in rez['css'] ) { 458 if ( jQuery( '#' + handle + '-css' ).length === 0 ) { 459 if ( rez['css'][handle].hasOwnProperty( 'url' ) ) { 460 $head.append( '<link id="' + handle + '-css"' 461 + ' type="text/css"' 462 + ' property="stylesheet"' 463 + ' rel="stylesheet"' 464 + ' href="' + rez['css'][handle]['url'] + '"' 465 + ' media="all">' 466 ); 467 } else if ( rez['css'][handle].hasOwnProperty( 'code' ) ) { 468 $head.append( '<style id="' + handle + '-css" media="all">' 469 + rez['css'][handle]['code'] 470 + '</style>' 471 ); 472 473 } 474 } 475 } 476 } 477 // Load scripts (add to the footer) 478 if ( rez['js'] ) { 479 for ( handle in rez['js'] ) { 480 if ( jQuery( '#' + handle + '-js' ).length === 0 ) { 481 if ( rez['js'][handle].hasOwnProperty( 'url' ) ) { 482 $body.append( '<script id="' + handle + '-js"' 483 + ' type="text/javascript"' 484 + ' src="' + rez['js'][handle]['url'] + '"' 485 + '></script>' 486 ); 487 } else if ( rez['js'][handle].hasOwnProperty( 'code' ) ) { 488 $body.append( '<script id="' + handle + '-js" type="text/javascript">' 489 + rez['js'][handle]['code'] 490 + '</script>' 491 ); 492 } 493 } 494 } 495 } 496 } 497 // Show the popup 498 if (show_overlay) overlay.fadeIn(); 499 popup.fadeIn( function() { 500 if ( Event ) { 501 document.dispatchEvent( new Event( 'DOMContentLoaded' ) ); 502 } 503 $document.trigger( 'action.init_hidden_elements', [popup] ); 504 } ); 505 $document.trigger( 'action.got_ajax_response', { 506 action: 'trx_addons_post_details_in_popup', 507 result: rez 508 }); 509 }); 510 } 511 512 // Featured image as panel 513 jQuery('.sc_blogger_panel .sc_blogger_item:not(.switch_panel_inited),.sc_services_panel .sc_services_item:not(.switch_panel_inited)') 514 .addClass('switch_panel_inited') 515 .on('mouseenter', function() { 516 var $self = jQuery(this), 517 num = $self.data('item-number'), 518 $posts = $self.parents('.sc_item_posts_container'), 519 $old_panel = $posts.find('.sc_panel_thumb_active').removeClass('sc_panel_thumb_active'), 520 $new_panel = $posts.find('.sc_panel_thumb[data-thumb-number="' + num + '"]').addClass('sc_panel_thumb_active'); 521 $document.trigger( 'action.init_hidden_elements', [$new_panel] ); 522 }); 523 524 525 // Cover links 526 jQuery('.sc_cover:not(.inited)').each( function() { 527 var $self = jQuery(this).addClass('inited'); 528 if ( $self.parents('.elementor-editor-active').length ) { 529 return; 530 } 531 var $wrap = $self.parent().hasClass('elementor-widget-container') ? $self.parents('.elementor-widget').eq(0) : $self, 532 wrap_z = $wrap.hasClass('elementor-widget') && $wrap.css('z-index') > 0 ? $wrap.css('z-index') : '', 533 place = $self.data('place'), 534 $placeholder = false; 535 if ( wrap_z > 0 ) { 536 $self.css( 'z-index', wrap_z ); 537 } 538 if ( place == 'p1' ) { 539 if ( ! $wrap.hasClass('sc_cover') ) { 540 $placeholder = $wrap.parent(); 541 } 542 } else if ( place == 'p2' ) { 543 $placeholder = $wrap.parent().parent(); 544 } else if ( place == 'p3' ) { 545 $placeholder = $wrap.parent().parent().parent(); 546 } else if ( place == 'row' ) { 547 $placeholder = $wrap.parents( trx_addons_apply_filters( 'trx_addons_filter_section_selectors', '.wp-block-columns,.elementor-section,.e-parent' ) ).eq(0); 548 } else if ( place == 'column' ) { 549 $placeholder = $wrap.parents( trx_addons_apply_filters( 'trx_addons_filter_column_selectors', '.wp-block-column,.elementor-column,.e-child' ) ).eq(0); 550 } 551 if ( $placeholder && $placeholder.length ) { 552 if ( $placeholder.css('position') == 'static' ) { 553 $placeholder.addClass('sc_cover_link_wrap'); 554 } 555 $self.prependTo( $placeholder.addClass('sc_cover_link_present') ); 556 } else { 557 $placeholder = $wrap.parent().addClass('sc_cover_link_present'); 558 if ( $placeholder.css('position') == 'static' ) { 559 $placeholder.addClass('sc_cover_link_wrap'); 560 } 561 } 562 } ); 563 564 }); 565 566 // Infinite scroll in the shortcodes 567 $document.on( 'action.resize_trx_addons', function() { 568 if ( $infinite_posts.length > 0 ) { 569 $infinite_posts.each( function(idx) { 570 var $self = $infinite_posts.eq(idx); 571 $self.data( { 572 'offset-top': $self.offset().top, 573 'height': $self.height() 574 } ); 575 }); 576 } 577 } ); 578 $document.on( 'action.scroll_trx_addons', function(e) { 579 if ( TRX_ADDONS_STORAGE['pagebuilder_preview_mode'] || $pagination_infinite.length === 0 ) { 580 return; 581 } 582 var done = false;
583 $pagination_infinite.each( function(idx) { 584 if ( done ) return; 585 var $self = $pagination_infinite.eq(idx); 586 if ( $self.hasClass('all_items_loaded') ) return; 587 var posts = $infinite_posts.eq(idx); 588 if ( posts.data('offset-top') + posts.data('height') < trx_addons_window_scroll_top() + trx_addons_window_height() * 1.5) { 589 $self.find( 'a' ).trigger( 'click' ); 590 done = true; 591 } 592 } ); 593 }); 594 595 596 // Typed feature for titles 597 $document.on('action.scroll_trx_addons', function() { 598 if ( $typed_entry.length === 0 ) { 599 return; 600 } 601 var wt = trx_addons_window_scroll_top(), 602 wh = trx_addons_window_height(); 603 604 $typed_entry.each(function(idx) { 605 var obj = $typed_entry.eq(idx); 606 if ( obj.hasClass('sc_typed_inited') ) return; 607 608 var ot = obj.offset().top, 609 oh = obj.height(); 610 if ( wt <= ot + oh && wt + wh >= ot + oh ) { 611 obj.addClass('sc_typed_inited').typed( trx_addons_apply_filters( 'trx_addons_filter_typed_options', { 612 contentType: "html", // 'text' or 'html' (default), but 'html' is default and in this case typing is stopped on the letter '&' (ampersand) - fixed 613 strings: obj.data('strings'), 614 loop: obj.data('loop') == 1, 615 showCursor: obj.data('cursor') == 1, 616 cursorChar: obj.data('cursor-char') != undefined ? obj.data('cursor-char') : '|', 617 typeSpeed: obj.data('speed') > 0 ? (11 - Math.max(1, Math.min(10, obj.data('speed')))) * 10 : 50, 618 backDelay: obj.data('delay') > 0 ? Math.max(0, Math.min(10, obj.data('delay'))) * 1000 : 1000 619 } ) ); 620 } 621 }); 622 }); 623 624 // Equal height elements 625 $document.on('action.resize_trx_addons', function (e, container) { 626 if ( $equal_height.length === 0 ) { 627 return; 628 } 629 $equal_height.each( function () { 630 var eh_wrap = jQuery(this); 631 var eh_items_selector = eh_wrap.data('equal-height'); 632 if (eh_items_selector === undefined) { 633 eh_items_selector = '>*'; 634 } 635 var max_h = 0; 636 var items = []; 637 var row_y = 0; 638 var i = 0; 639 640 eh_wrap.find(eh_items_selector).each(function() { 641 var el = jQuery(this); 642 el.css('visibility', 'hidden').height('auto'); 643 var el_height = el.height(); 644 var el_offset = el.offset().top; 645 if (row_y === 0) row_y = el_offset; 646 if (row_y < el_offset) { 647 if (items.length > 0) { 648 if (max_h > 0) { 649 for (i = 0; i < items.length; i++) 650 items[i].css('visibility', 'visible').height(max_h); 651 } 652 items = []; 653 max_h = 0; 654 } 655 row_y = el_offset; 656 } 657 if (el_height > max_h) max_h = el_height; 658 items.push(el); 659 }); 660 if (items.length > 0) { 661 for (i = 0; i < items.length; i++) { 662 items[i].css('visibility', 'visible'); 663 if (max_h > 0) items[i].height(max_h); 664 } 665 } 666 } ); 667 } ); 668 669} );
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.