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