PageSourceSearch

https://mediumaquamarine-moose-210270.hostingersite.com/wp-content…/cpt/layouts/layouts.js?reload=1258573956

js mediumaquamarine-moose-210270.hostingersite.com collected 2026-10-03 04:39:44 UTC 16,023 bytes, 411 lines download raw bytes

1/* global jQuery, TRX_ADDONS_STORAGE */
2
3jQuery(document).on('action.ready_trx_addons', function() {
4	"use strict";
5
6	// How to handle fix/unfix rows:
7	// true  - Intersection observers are used
8	// false - a scroll event handler is used
9	var USE_OBSERVERS = trx_addons_apply_filters( 'trx_addons_filter_use_observers_to_fix_rows', true )
10							&& typeof IntersectionObserver != 'undefined';
11
12	// Common objects
13	var $window          = jQuery( window ),
14		$document        = jQuery( document ),
15		$body            = jQuery( 'body' );
16
17	// Return the row 'id' or data-id (if 'id' is empty)
18	function get_id( row ) {
19		return row.attr('id') ? row.attr('id') : row.attr('data-id');
20	}
21
22	// Handle fixed rows
23	//---------------------------------------------------------
24	if ( ! TRX_ADDONS_STORAGE['pagebuilder_preview_mode'] && ! $body.hasClass( 'sc_layouts_row_fixed_inited' ) ) {
25		var rows = jQuery('.sc_layouts_row_fixed'),
26			rows_always = rows.filter('.sc_layouts_row_fixed_always'),
27			rows_delayed = rows.filter('.sc_layouts_row_delay_fixed'),
28			last_scroll_offset = -1;
29		// If page contain fixed rows
30		if ( rows.length > 0 ) {
31			rows.each( function( idx ) {
32				// Add placeholders after each row
33				var row = rows.eq( idx );
34				if ( row.hasClass('sc_layouts_row_hide_unfixed' ) ) {
35					if ( ! row.prev().hasClass('sc_layouts_row_unfixed_placeholder') ) {
36						row.before( '<div class="sc_layouts_row_unfixed_placeholder">'
37										+ ( USE_OBSERVERS ? '<div class="sc_layouts_row_fixed_marker_on"></div>' : '' )
38									+ '</div>');
39					}
40				}
41				if ( ! row.next().hasClass('sc_layouts_row_fixed_placeholder') ) {
42					row.after('<div class="sc_layouts_row_fixed_placeholder" style="background-color:'+row.css('background-color')+';"><div class="sc_layouts_row_fixed_marker_off"></div></div>');
43					if ( USE_OBSERVERS && ! row.hasClass('sc_layouts_row_hide_unfixed' ) ) {
44						row.append('<div class="sc_layouts_row_fixed_marker_on"></div>');
45					}
46				}
47				// Add class 'sc_layouts_row_fixed_with_fullscreen' to the row if it contains the element with class 'search_style_fullscreen'
48				if ( row.find( trx_addons_apply_filters( 'trx_addons_filter_fullscreen_elements', '.search_style_fullscreen,.search_modern' ) ).length > 0 ) {
49					row.addClass( 'sc_layouts_row_fixed_with_fullscreen' );
50				}
51			} );
52			// Add handlers to fix/unfix rows
53			var timedFix = trx_addons_throttle( function() {
54				trx_addons_cpt_layouts_fix_rows( {
55							rows: rows,
56							rows_always: rows_always
57						} );
58			}, 150 );
59			$document
60				.on('action.scroll_trx_addons', function() {
61					trx_addons_cpt_layouts_hide_fixed_rows();
62					if ( ! USE_OBSERVERS ) {
63						trx_addons_cpt_layouts_fix_rows( {
64							rows: rows,
65							rows_always: rows_always
66						} );
67					} else {
68						timedFix();
69					}
70					last_scroll_offset = trx_addons_window_scroll_top();
71				})
72				.on('action.resize_trx_addons', function() {
73					// Update global values
74					trx_addons_cpt_layouts_check_mobile_breakpoint();
75					trx_addons_cpt_layouts_hide_fixed_rows();
76					trx_addons_cpt_layouts_fix_rows( {
77						rows: rows,
78						rows_always: rows_always,
79						resize: true
80					} );
81				});
82			// Add observer to fix/unfix rows
83			if ( USE_OBSERVERS ) {
84				var fixed_rows_observe = function() {
85					rows.each( function( idx ) {
86						var row = rows.eq( idx );
87						var last_fixed_time = row.data('trx-addons-last-fixed-time') || 0;
88						var delay = trx_addons_cpt_layouts_fix_rows_delay( row );
89						var marker_off = row.next().find( '>.sc_layouts_row_fixed_marker_off' );
90						var marker_on  = row.hasClass( 'sc_layouts_row_hide_unfixed' )
91											? row.prev().find( '>.sc_layouts_row_fixed_marker_on' )
92											: row.find( '>.sc_layouts_row_fixed_marker_on' );
93						var observer = row.data( 'trx-addons-fixed-observer' );
94						if ( observer ) {
95							if ( marker_off.length ) observer.unobserve( marker_off.get(0) );
96							if ( marker_on.length ) observer.unobserve( marker_on.get(0) );
97							observer.disconnect();
98							observer = null;
99						}
100						// Skip hidden rows without a class 'sc_layouts_row_hide_unfixed'
101						if ( row.css('display') == 'none' && ! row.hasClass('sc_layouts_row_hide_unfixed' ) ) {
102							return;
103						}
104						// On mobile devices skip rows without a class 'sc_layouts_row_fixed_always'
105						if ( trx_addons_window_width() < TRX_ADDONS_STORAGE['mobile_breakpoint_fixedrows_off']
106							&& ! row.hasClass( 'sc_layouts_row_fixed_always' )
107						) {
108							return;
109						}
110						var row_height = row.hasClass( 'sc_layouts_row_hide_unfixed' ) ? 0 : row.outerHeight();
111						// Create an observer for each row (to pay account an individual settings for delay)
112						observer = new IntersectionObserver( function( entries ) {
113								var time = new Date().getTime();
114								entries.forEach( function( entry ) {
115									var marker = jQuery( entry.target ),
116										marker_offset = marker.offset().top,
117										parent = marker.parent(),
118										row    = parent;
119									if ( parent.hasClass( 'sc_layouts_row_unfixed_placeholder' ) ) {
120										row = row.next();
121									} else if ( parent.hasClass( 'sc_layouts_row_fixed_placeholder' ) ) {
122										row = row.prev();
123									}
124									var animation_off_timeout = trx_addons_cpt_layouts_fix_rows_off_timeout( delay );
125									// marker_off is come in to the viewport
126									if ( row.hasClass( 'sc_layouts_row_fixed_on' ) && entry.isIntersecting ) {
127										if ( time - last_fixed_time > animation_off_timeout && entry.boundingClientRect.top >= entry.rootBounds.top ) {
128											if ( ! row.hasClass( 'sc_layouts_row_fixed_animation_off' ) ) {
129												trx_addons_cpt_layouts_fix_rows( {
130													rows: rows,
131													rows_always: rows_always,
132													force_row: row,
133													force_state: 'off'
134												} );
135												last_fixed_time = time;
136											}
137										}
138
139									// marker_on is go out from the viewport
140									} else if ( ! row.hasClass( 'sc_layouts_row_fixed_on' ) && ! entry.isIntersecting ) {
141										if ( time - last_fixed_time > animation_off_timeout && entry.boundingClientRect.bottom < entry.rootBounds.top ) {
142											trx_addons_cpt_layouts_fix_rows( {
143												rows: rows,
144												rows_always: rows_always,
145												force_row: row,
146												force_state: 'on'
147											} );
148
149											last_fixed_time = time;
150										}
151									}
152								} );
153							}, {
154								root: null,
155								rootMargin: ( delay - trx_addons_fixed_rows_height() + ( ! $body.hasClass('hide_fixed_rows') && row.hasClass( 'sc_layouts_row_fixed_on' ) ? row_height : 0 ) ) + 'px 0px 0px 0px',
156								threshold: 0
157							}
158						);
159						var marker = row.hasClass( 'sc_layouts_row_fixed_on' ) ? marker_off : marker_on;
160						observer.observe( marker.get(0) );
161						row.data( {
162							'trx-addons-fixed-observer': observer,
163							'trx-addons-last-fixed-time': last_fixed_time
164						} );
165					} );
166				};
167				$document.on('action.sc_layouts_row_fixed_on action.sc_layouts_row_fixed_off', fixed_rows_observe );
168				fixed_rows_observe();
169
170			}
171			// Add a class to the body
172			$body.addClass( 'sc_layouts_row_fixed_inited' );
173		}
174	}
175
176	function trx_addons_cpt_layouts_fix_rows_delay( row ) {
177		return trx_addons_apply_filters( 'trx_addons_filter_fixed_rows_delay',
178					row.hasClass( 'sc_layouts_row_delay_fixed' )
179						? Math.max( 300, trx_addons_window_height() / 4 * 3 )
180						: 0
181				);
182	}
183
184	function trx_addons_cpt_layouts_fix_rows_off_timeout( delay ) {
185		return trx_addons_apply_filters( 'trx_addons_filter_sc_layouts_row_fixed_off_timeout',
186					delay > 0 ? 400 : 0,	// Timeout must be equal to the css-animation time (see layouts.[s]css)
187					delay
188				);
189	}
190
191
192	// Hide fixed rows on scroll down
193	function trx_addons_cpt_layouts_hide_fixed_rows() {
194		if ( TRX_ADDONS_STORAGE['hide_fixed_rows'] > 0 && ! window.trx_addons_document_animate_to_busy ) {
195			var scroll_delta = 50;
196			var scroll_offset = trx_addons_window_scroll_top();
197			if ( last_scroll_offset >= 0 ) {
198				var event = '';
199				// Scroll down
200				if ( scroll_offset > last_scroll_offset + scroll_delta ) {
201					if ( scroll_offset > trx_addons_window_height() * ( rows_delayed.length > 0 ? 1.5 : 0.6667 ) && ! $body.hasClass( 'hide_fixed_rows' ) ) {
202						$body.addClass( 'hide_fixed_rows' );
203						event = 'off';
204					}
205				// Scroll up
206				} else if ( scroll_offset < last_scroll_offset - scroll_delta ) {
207					if ( $body.hasClass( 'hide_fixed_rows' ) ) {
208						$body.removeClass( 'hide_fixed_rows' );
209						event = 'on';
210					}
211				}
212				// Trigger event
213				if ( event ) {
214					$document.trigger( 'action.sc_layouts_row_fixed_' + event, [ rows.filter('.sc_layouts_row_fixed_on') ] );
215				}
216			}
217		}
218	}
219
220	// Break fixing on mobile devices (except rows with class 'sc_layouts_row_fixed_always')
221	function trx_addons_cpt_layouts_check_mobile_breakpoint() {
222		if ( trx_addons_window_width() < TRX_ADDONS_STORAGE['mobile_breakpoint_fixedrows_off'] ) {
223			rows.each( function( idx ) {
224				var row = rows.eq( idx );
225				if ( ! row.hasClass( 'sc_layouts_row_fixed_always' ) ) {
226					row.removeClass( 'sc_layouts_row_fixed_on' ).css( { 'top': 'auto' } );
227				}
228			});
229		}
230	}
231
232	// Fix/unfix rows
233	function trx_addons_cpt_layouts_fix_rows( args ) {
234
235		var rows = args.rows,
236			rows_always = args.rows_always,
237			resize = args.resize || false,
238			force_row = args.force_row || null,
239			force_state = args.force_state || '';
240
241		// Break fixing on mobile devices (except rows with class 'sc_layouts_row_fixed_always')
242		if ( trx_addons_window_width() < TRX_ADDONS_STORAGE['mobile_breakpoint_fixedrows_off'] ) {
243			if ( rows_always.length === 0 ) {
244				return;
245			} else {
246				rows = rows_always;
247			}
248		}
249
250		var scroll_offset = trx_addons_window_scroll_top(),
251			scroll_intent = last_scroll_offset - scroll_offset;
252		var rows_offset = trx_addons_adminbar_height();
253
254		rows.each( function( idx ) {
255			var row = rows.eq( idx );
256			var placeholder = row.next();
257			var h = row.outerHeight();
258			if ( ( row.css('display') == 'none' || h === 0 ) && ! row.hasClass('sc_layouts_row_hide_unfixed' ) ) {
259				placeholder.height(0);
260				return;
261			}
262			var ph = row.hasClass( 'sc_layouts_row_fixed_on' ) ? placeholder.outerHeight() : 0;
263			var row_unfixed_placeholder = row.hasClass('sc_layouts_row_hide_unfixed' ) ? row.prev() : false;
264			var delay  = trx_addons_cpt_layouts_fix_rows_delay( row );
265			var animation_off_timeout = trx_addons_cpt_layouts_fix_rows_off_timeout( delay );
266			var offset = parseInt( row.hasClass( 'sc_layouts_row_fixed_on' )
267										? placeholder.offset().top
268										: ( row.hasClass('sc_layouts_row_hide_unfixed' )
269											? row_unfixed_placeholder.offset().top
270											: row.offset().top
271											),
272									10 );
273			if ( isNaN( offset ) ) {
274				offset = 0;
275			}
276
277			// Unfix row
278			if ( ( force_state == 'off' && row.is( force_row ) )
279				|| ( ! force_state && scroll_intent <= 0 && ( scroll_offset + rows_offset < offset + delay || h < ph ) )
280			) {
281				if ( row.hasClass( 'sc_layouts_row_fixed_on' ) ) {
282					if ( animation_off_timeout > 0 ) {
283						row.addClass( 'sc_layouts_row_fixed_animation_off' );
284					}
285					setTimeout( function() {
286						row
287							.removeClass( 'sc_layouts_row_fixed_on'
288											+ ( animation_off_timeout > 0 ? ' sc_layouts_row_fixed_animation_off' : '' ) )
289							.css( { 'top': 'auto' } );
290						$document.trigger( 'action.sc_layouts_row_fixed_off', [ row ] );
291					}, animation_off_timeout );
292				}
293
294			// Fix row
295			} else {
296				if ( ! row.hasClass( 'sc_layouts_row_fixed_on' ) ) {
297					if ( ( force_state == 'on' && row.is( force_row ) )
298						|| ( scroll_intent >= 0 && ( rows_offset + h < trx_addons_window_height() * 0.33 ) )	//! force_state && - if force_state='on' from observer and two fixed rows are near - only one (forced) row is processed
299					) {
300						if ( ! row.hasClass( 'sc_layouts_row_hide_unfixed' ) ) {
301							ph = h;
302							placeholder.height( ph );
303						}
304						row.addClass( 'sc_layouts_row_fixed_on' ).css( { 'top': rows_offset + 'px' } );
305						h = row.outerHeight();
306						if ( ph != h && ! row.hasClass( 'sc_layouts_row_hide_unfixed' ) ) {
307							ph = h;
308							placeholder.height( h );
309						}
310						$document.trigger( 'action.sc_layouts_row_fixed_on', [ row ] );
311					}
312				} else if ( resize && row.hasClass( 'sc_layouts_row_fixed_on' ) && row.offset().top != rows_offset ) {
313					row.css( { 'top': rows_offset + 'px' } );
314				}
315				if ( row.css('display') != 'none' ) {
316					rows_offset += h;
317				}
318			}
319			if ( force_state && row.is( force_row ) ) {
320				force_state = '';
321				force_row = null;
322			}
323		});
324	}
325
326
327	// Layouts as a submenu
328	//---------------------------------------------------------
329
330	// Stretch submenu with layouts
331	window.trx_addons_stretch_submenu = function(menu_item) {
332		var done = false;
333		if ( ! menu_item.length ) {
334			return done;
335		}
336		var parent_class = menu_item.parent().attr('class');
337		if ( TRX_ADDONS_STORAGE['menu_stretch'] == 1
338			&& ! menu_item.hasClass('trx_addons_no_stretch')
339			&& parent_class.indexOf('trx_addons_no_stretch') == -1
340			&& ! menu_item.parents('.sc_layouts_menu').hasClass('sc_layouts_menu_dir_vertical')
341			&& trx_addons_apply_filters( 'trx_addons_filter_stretch_menu',
342											menu_item.hasClass('sc_layouts_submenu')
343												|| parent_class.indexOf('columns-') != -1
344												|| parent_class.indexOf('trx_addons_stretch_') != -1,
345											menu_item
346										)
347		) {
348			var menu = menu_item.parents("ul");
349			if ( menu.length == 1 ) {
350				var $body = jQuery('body'),
351					li = menu_item.parents("li").eq(0),
352					stretch_to = trx_addons_apply_filters( 'trx_addons_filter_stretch_menu_to',
353									li.hasClass( 'trx_addons_stretch_window' )
354										? 'window'
355										: ( li.hasClass( 'trx_addons_stretch_window_boxed' )
356											? 'window_boxed'
357											: 'content'
358											),
359									menu_item
360								),
361					content_wrap_selector = trx_addons_apply_filters( 'trx_addons_filter_stretch_menu_content_wrap_selector', '.content_wrap', menu_item ),
362					content_wrap = jQuery( content_wrap_selector ).eq(0);
363				if ( ! content_wrap.length ) {
364					$body.append( trx_addons_apply_filters( 'trx_addons_filter_stretch_menu_content_wrap_html',
365									'<div class="content_wrap" style="height:0;visibility:hidden;"></div>',
366									menu_item
367								) );
368					content_wrap = jQuery( content_wrap_selector ).eq(0);
369					if ( ! content_wrap.length ) {
370						content_wrap = trx_addons_apply_filters( 'trx_addons_filter_stretch_menu_content_wrap', content_wrap, menu_item );
371					}
372				}
373				if ( content_wrap.length == 1 ) {
374					var bw = $body.innerWidth(),
375						cw = trx_addons_apply_filters( 'trx_addons_filter_stretch_menu_content_wrap_width', content_wrap.innerWidth(), menu_item, content_wrap ),
376						cw_offset = content_wrap.offset().left,
377						li_offset = li.offset().left;
378					menu_item
379						.css( {
380							'width': ( stretch_to == 'window' ? bw : cw ) + 'px',
381							'max-width': 'none',
382							'left': -li_offset + ( stretch_to == 'window' ? 0 : cw_offset ) + 'px',
383							'right': 'auto'
384						} );
385					if ( stretch_to == 'window' ) {
386						menu_item
387							.data( 'reset-style', '.elementor-section-boxed > .elementor-container,.e-con-boxed > .e-con-inner' )
388							.find( '.elementor-section-boxed > .elementor-container,.e-con-boxed > .e-con-inner' ).css( {'max-width': 'none' } );
389					} else if ( stretch_to == 'window_boxed' ) {
390						var bg = menu_item.find('> .sc_layouts_menu_stretch_bg');
391						if ( bg.length === 0 ) {
392							menu_item.append( '<span class="sc_layouts_menu_stretch_bg"></span>' );
393							bg = menu_item.find('> .sc_layouts_menu_stretch_bg');
394							bg.css( {
395								'background-color': menu_item.css('background-color')
396							} );
397						}
398						bg.css( {
399							'left': -(cw_offset + 1) + 'px',
400							'right': -(bw - cw_offset - cw + 1) + 'px'
401						} );
402					}
403					done = true;
404					$document.trigger('action.resize_trx_addons', [menu_item] );
405				}
406			}
407		}
408		return done;
409	};
410
411} );

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.