PageSourceSearch

https://harrisburgbic.org/wp-content/plugins/trx_addons/components/shortcodes/shortcodes.js

js harrisburgbic.org collected 2026-10-09 01:47:28 UTC 13,734 bytes, 364 lines download raw bytes

1/**
2 * Shortcodes common scripts
3 *
4 * @package WordPress
5 * @subpackage ThemeREX Addons
6 * @since v1.2
7 */
8
9/* global jQuery, TRX_ADDONS_STORAGE */
10
11
12(function() {
13
14	"use strict";
15	
16	// Fullheight elements
17	//jQuery(document).on('action.init_hidden_elements', trx_addons_sc_fullheight);
18	//jQuery(document).on('action.resize_trx_addons', trx_addons_sc_fullheight);
19
20	function trx_addons_sc_fullheight(e, container) {
21	
22		if (container === undefined) container = jQuery('body');
23		if (container === undefined || container.length === undefined || container.length == 0) return;
24	
25		container.find('.trx_addons_stretch_height').each(function () {
26			// If item now invisible
27			if (jQuery(this).parents('div:hidden,article:hidden').length > 0) {
28				return;
29			}
30			var fullheight_item = jQuery( this ),
31				fullheight_row  = jQuery(this).closest('.vc_row,.elementor-section').eq(0);	//'.vc_row-o-full-height,.elementor-section-height-full'
32			if (fullheight_row.hasClass('vc_row-o-full-height') || fullheight_row.hasClass('elementor-section-height-full')) {
33				if (fullheight_row.css('height') != 'auto') {
34					fullheight_item.height( fullheight_row.height() );
35				} else if (fullheight_item.css( 'height' ) != 'auto') {
36					fullheight_item.height( 'auto' );
37				}
38			} else {
39				var wh = jQuery( window ).height() >= 698 && jQuery( window ).width() > 1024
40					? jQuery( window ).height() - trx_addons_fixed_rows_height()
41					: 'auto';
42				if ( wh > 0 ) {
43					if ( fullheight_item.data( 'display' ) != fullheight_item.css( 'display' ) ) {
44						fullheight_item.css( 'display', fullheight_item.data( 'display' ) );
45					}
46					if ( fullheight_item.css( 'height', 'auto' ).outerHeight() <= wh ) {
47						fullheight_item.css( 'height', wh );
48					}
49				} else if ( wh == 'auto' && fullheight_item.css( 'height' ) != 'auto' ) {
50					if (fullheight_item.data( 'display' ) == undefined) {
51						fullheight_item.attr( 'data-display', fullheight_item.css( 'display' ) );
52					}
53					fullheight_item.css( {'height': wh, 'display': 'block'} );
54				}
55			}
56		});
57	}
58
59
60	// Equal height elements
61	jQuery(document).on('action.resize_trx_addons', trx_addons_sc_equalheight);
62
63	function trx_addons_sc_equalheight(e, container) {
64		if (container === undefined) container = jQuery('body');
65		if (container===undefined || container.length === undefined || container.length == 0) return;
66		container.find('[data-equal-height],.trx_addons_equal_height').each(function () {
67			var eh_wrap = jQuery(this);
68			var eh_items_selector = eh_wrap.data('equal-height');
69			if (eh_items_selector === undefined) eh_items_selector = '>*';
70			var max_h = 0;
71			var items = [];
72			var row_y = 0;
73			var i=0;
74			eh_wrap.find(eh_items_selector).each(function() {
75				var el = jQuery(this);
76				el.css('visibility', 'hidden').height('auto');
77				var el_height = el.height();
78				var el_offset = el.offset().top;
79				if (row_y == 0) row_y = el_offset;
80				if (row_y < el_offset) {
81					if (items.length > 0) {
82						if (max_h > 0) {
83							for (i=0; i<items.length; i++)
84								items[i].css('visibility', 'visible').height(max_h);
85						}
86						items = [];
87						max_h = 0;
88					}
89					row_y = el_offset;
90				}
91				if (el_height > max_h) max_h = el_height;
92				items.push(el);
93			});
94			if (items.length > 0) {
95				for (i=0; i<items.length; i++) {
96					items[i].css('visibility', 'visible');
97					if (max_h > 0) items[i].height(max_h);
98				}
99			}
100		});
101	}
102
103	
104	// Pagination in the shortcodes
105	jQuery(document).ready(function() {
106		TRX_ADDONS_STORAGE['pagination_busy'] = false;
107	});
108
109	// Infinite scroll in the shortcodes
110	jQuery( document ).on( 'action.scroll_trx_addons', function(e) {
111		if (TRX_ADDONS_STORAGE['pagination_busy'] || TRX_ADDONS_STORAGE['pagebuilder_preview_mode']) {
112			return;
113		}
114		var link_wrap = jQuery( '.sc_item_pagination_infinite' );
115		if (link_wrap.length == 0) {
116			return;
117		}
118		var posts = link_wrap.siblings('.sc_item_posts_container').eq(0);
119		if (posts.offset().top + posts.height() < jQuery( window ).scrollTop() + jQuery( window ).height() * 1.5) {
120			link_wrap.find( 'a' ).trigger( 'click' );
121		}
122	});
123
124	jQuery(document).on('action.init_hidden_elements', function() {
125		// Load next page by AJAX		
126		jQuery('.sc_item_filters:not(.inited),.sc_item_pagination:not(.inited)')
127			.addClass('inited')
128			.on('click', 'a', function(e) {
129				if (!TRX_ADDONS_STORAGE['pagination_busy']) {
130					TRX_ADDONS_STORAGE['pagination_busy'] = true;
131					var link = jQuery(this),
132						link_wrap = link.parents('.sc_item_filters,.sc_item_pagination'),
133						pagination_wrap = link.parents('.sc_item_pagination'),
134						sc = link_wrap.parent(),
135						posts = link_wrap.siblings('.sc_item_posts_container'),
136						load_more = link_wrap.hasClass('sc_item_pagination_load_more');
137					if (load_more) {
138						var page     = Number( link.data( 'page' ) );
139						var max_page = Number( link.data( 'max-page' ) );
140						if (page > max_page) {
141							return;
142						}
143						link_wrap.addClass('loading');
144					} else {
145						posts.append('<div class="trx_addons_loading"></div>');
146					}
147					jQuery.post(TRX_ADDONS_STORAGE['ajax_url'], {
148						action: 'trx_addons_item_pagination',
149						nonce: TRX_ADDONS_STORAGE['ajax_nonce'],
150						params: link_wrap.data('params'),
151						page: link.parents('.sc_item_filters').length > 0 ? 1 : link.data('page'),
152						filters_active: link.parents('.sc_item_filters').length > 0 
153											? link.data('tab') 
154											: (link_wrap.siblings('.sc_item_filters').find('a.active').length > 0
155												? link_wrap.siblings('.sc_item_filters').find('a.active').data('tab')
156												: 'all'
157												)
158					}).done(function(response) {
159						var rez = {};
160						if (response=='' || response==0) {
161							rez = { error: TRX_ADDONS_STORAGE['msg_ajax_error'] };
162						} else {
163							try {
164								rez = JSON.parse(response);
165							} catch (e) {
166								rez = { error: TRX_ADDONS_STORAGE['msg_ajax_error'] };
167								console.log(response);
168							}
169						}
170						if (rez.error === '') {
171							// Add inline styles
172							if (rez.css !== '') {
173								var	selector = 'trx_addons-inline-styles-inline-css',
174									inline_css = jQuery('#'+selector);
175								if (inline_css.length == 0)
176									jQuery('body').append('<style id="'+selector+'" type="text/css">' + rez.css + '</style>');
177								else
178									inline_css.append(rez.css);
179							}
180							// Append posts
181							if (load_more) {
182								// Append posts to the tabs container
183								if (posts.find('[class*="_tabs_list_item"]').length > 0) {
184									posts.find('[class*="_tabs_list_item"]').parent().append(jQuery(rez.data).find('.sc_item_posts_container [class*="_tabs_list_item"]').parent().html());
185									posts.find('[class$="_tabs_content"]').append(jQuery(rez.data).find('.sc_item_posts_container [class$="_tabs_content"]').html());
186									// Remove active classes in appended items
187									posts.find('[class*="_tabs_list_item_active"]').each(function(idx) {
188										if (idx > 0) {
189											var classes = jQuery(this).attr('class').split(' '),
190												found = false;
191											for (var i=0; i<classes.length; i++) {
192												if (classes[i].indexOf('_tabs_list_item_active') > 0) {
193													classes[i] = '';
194													found = true;
195													break;
196												}
197											}
198											if (found) jQuery(this).attr('class', classes.join(' '));
199										}
200									});
201									posts.find('[class$="_tabs_content"] [class*="_item_active"]').each(function(idx) {
202										if (idx > 0) {
203											var classes = jQuery(this).attr('class').split(' '),
204												found = false;
205											for (var i=0; i<classes.length; i++) {
206												if (classes[i].indexOf('_item_active') > 0) {
207													classes[i] = '';
208													found = true;
209													break;
210												}
211											}
212											if (found) jQuery(this).attr('class', classes.join(' '));
213										}
214									});
215
216								// Append regular posts
217								} else {
218									if (posts.hasClass('masonry_wrap')) {
219										var items = jQuery(rez.data).find('.sc_item_posts_container .masonry_item');
220										if (items.length > 0) {
221											items.addClass( 'just_loaded_items hidden' );
222											posts.append( items );
223											var just_loaded_items = posts.find( '.just_loaded_items' );
224											trx_addons_when_images_loaded(
225												just_loaded_items, function() {
226													just_loaded_items.removeClass( 'hidden' );
227													posts.masonry( 'appended', items ).masonry();
228												}
229											);
230											setTimeout(function() {
231												just_loaded_items.removeClass( 'just_loaded_items hidden' );
232											}, 1000);
233										}
234									} else {
235										posts.append(jQuery(rez.data).find('.sc_item_posts_container').html());
236									}
237								}
238								jQuery(document).trigger('action.init_hidden_elements', [posts]);
239								link.data('page', Number(link.data('page')) + 1);
240								if (link.data('page') > link.data('max-page')) {
241									pagination_wrap.fadeOut();
242								}
243
244							// Replace posts
245							} else {
246								posts.find('.trx_addons_loading').fadeOut();
247								sc.fadeOut(function() {
248									sc.after(jQuery(rez.data).hide());
249									var sc_new = sc.next();
250									sc.remove();
251									sc_new.fadeIn();
252									jQuery(document).trigger('action.init_hidden_elements', [sc_new]);
253								});
254							}
255						} else {
256							alert(rez.error);
257							posts.find('.trx_addons_loading').remove();
258						}
259						if (load_more) pagination_wrap.removeClass('loading');
260						TRX_ADDONS_STORAGE['pagination_busy'] = false;
261					});
262				}
263				e.preventDefault();
264				return false;
265			});
266
267		// Load post's details by AJAX and show in the popup
268		jQuery('.sc_post_details_popup:not(.inited)')
269			.addClass('inited')
270			.on('click', 'a', function(e) {
271				trx_addons_show_post_details(jQuery(this).parents('[data-post_id]'), true);
272				e.preventDefault();
273				return false;
274			});
275		if (jQuery('.sc_post_details_popup.inited').length > 0) {
276			jQuery('body:not(.sc_post_details_popup_inited)')
277				.addClass('sc_post_details_popup_inited')
278				.on('click', '#trx_addons_post_details_popup_overlay, .trx_addons_post_details_popup_close', function(e) {
279					jQuery('#trx_addons_post_details_popup').fadeOut();
280					jQuery('#trx_addons_post_details_popup_overlay').fadeOut();
281				})
282				.on('click', '.trx_addons_post_details_popup_prev,.trx_addons_post_details_popup_next', function(e) {
283					var popup = jQuery('#trx_addons_post_details_popup');
284					var post_item = popup.data('post_item');
285					if (!post_item || post_item.length == 0) return;
286					var posts_items = post_item.parents('.sc_item_columns,.sc_item_slider').find('[data-post_id]');
287					var cur_idx = -1;
288					posts_items.each(function(idx) {
289						if (jQuery(this).data('post_id') == post_item.data('post_id')) cur_idx = idx;
290					});
291					if (cur_idx == -1) return;
292					post_item = jQuery(this).hasClass('trx_addons_post_details_popup_prev') 
293									? (cur_idx > 0 ? posts_items.eq(cur_idx-1) : false)
294									: (cur_idx < posts_items.length-1 ? posts_items.eq(cur_idx+1) : false);
295					if (!post_item || post_item.length == 0) return;
296					popup.fadeOut();
297					trx_addons_show_post_details(post_item, false);
298				});
299		}
300		
301		function trx_addons_show_post_details(post_item, show_overlay) {
302			jQuery.post(TRX_ADDONS_STORAGE['ajax_url'], {
303				action: 'trx_addons_post_details_in_popup',
304				nonce: TRX_ADDONS_STORAGE['ajax_nonce'],
305				post_id: post_item.data('post_id'),
306				post_type: post_item.data('post_type')
307			}).done(function(response) {
308				var rez = {};
309				if (response=='' || response==0) {
310					rez = { error: TRX_ADDONS_STORAGE['msg_ajax_error'] };
311				} else {
312					try {
313						rez = JSON.parse(response);
314					} catch (e) {
315						rez = { error: TRX_ADDONS_STORAGE['msg_ajax_error'] };
316						console.log(response);
317					}
318				}
319				var msg = rez.error === '' ? rez.data : rez.error;
320				var popup = jQuery('#trx_addons_post_details_popup');
321				var overlay = jQuery('#trx_addons_post_details_popup_overlay');
322				if (popup.length == 0) {
323					jQuery('body').append(
324						'<div id="trx_addons_post_details_popup_overlay"></div>'
325						+ '<div id="trx_addons_post_details_popup">'
326							+ '<div class="trx_addons_post_details_content"></div>'
327							+ '<span class="trx_addons_post_details_popup_close trx_addons_icon-cancel"></span>'
328							+ '<span class="trx_addons_post_details_popup_prev trx_addons_icon-left"></span>'
329							+ '<span class="trx_addons_post_details_popup_next trx_addons_icon-right"></span>'
330						+ '</div>');
331					popup = jQuery('#trx_addons_post_details_popup');
332					overlay = jQuery('#trx_addons_post_details_popup_overlay');
333				}
334				popup.data('post_item', post_item).find('.trx_addons_post_details_content').html(msg);
335				if (show_overlay) overlay.fadeIn();
336				popup.fadeIn();
337			});
338		}
339
340		// Typed feature for titles
341		jQuery(document).on('action.scroll_trx_addons', function() {
342			var wt = jQuery(window).scrollTop(),
343				wh = jQuery(window).height();
344			jQuery('.sc_typed_entry:not(.sc_typed_inited)').each(function() {
345				var obj = jQuery(this),
346					ot = obj.offset().top,
347					oh = obj.height();
348				if ( wt <= ot + oh && wt + wh >= ot + oh ) {
349					obj.addClass('sc_typed_inited').typed({
350						contentType: "html",
351						strings: obj.data('strings'),
352						loop: obj.data('loop') == 1,
353						showCursor: obj.data('cursor') == 1,
354						cursorChar: obj.data('cursor-char') != undefined ? obj.data('cursor-char') : '|',
355						typeSpeed: obj.data('speed') > 0 ? (11 - Math.max(1, Math.min(10, obj.data('speed')))) * 10 : 50,
356						backDelay: obj.data('delay') > 0 ? Math.max(0, Math.min(10, obj.data('delay'))) * 1000 : 1000
357					});
358				}
359			});
360		});
361
362	});
363
364})();

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.