PageSourceSearch

https://sccap53.org/wp-content/plugins/custom-page-templates-by-vegacorp/assets/js/init.js?ver=1.1.17

js sccap53.org collected 2026-10-02 10:01:54 UTC 8,480 bytes, 304 lines download raw bytes

1// http://stackoverflow.com/questions/2420970/how-can-i-get-selector-from-jquery-object/15623322#15623322
2!function (e, t) {
3	var n = function (e) {
4		var n = [];
5		for (; e && e.tagName !== t; e = e.parentNode) {
6			if (e.className) {
7				var r = e.className.split(" ");
8				for (var i in r) {
9					if (r.hasOwnProperty(i) && r[i]) {
10						n.unshift(r[i]);
11						n.unshift(".")
12					}
13				}
14			}
15			if (e.id && !/\s/.test(e.id)) {
16				n.unshift(e.id);
17				n.unshift("#")
18			}
19			n.unshift(e.tagName);
20			n.unshift(" > ")
21		}
22		return n.slice(1).join("")
23	};
24	e.fn.getSelector = function (t) {
25		if (true === t) {
26			return n(this[0])
27		} else {
28			return e.map(this, function (e) {
29				return n(e)
30			})
31		}
32	}
33}(window.jQuery)
34
35/**
36 * Find content column and sidebars
37 * @param obj $entryContent parent of placeholder.
38 * @returns obj jQuery elements for left, right sidebars, and content column
39 */
40function vgplFindContentColumns($entryContent, allowForPadding) {
41
42	//		var entryContentWidth = $entryContent.innerWidth() - parseInt($entryContent.css('padding-left').replace('px')) - parseInt($entryContent.css('padding-right').replace('px') );
43	var entryContentWidth = $entryContent.width();
44	var $parents = $entryContent.parents();
45	var $parent, $inmediateParent;
46
47	var padding = (allowForPadding) ? 50 : 0;
48
49	// Find entryContent column and columns container
50	$parents.each(function () {
51		var parentWidth = jQuery(this).outerWidth();
52		if (parentWidth > (entryContentWidth + padding)) {
53			$parent = jQuery(this);
54			return false;
55		} else {
56			$inmediateParent = null;
57			$inmediateParent = jQuery(this);
58		}
59	});
60	
61	if(!$parent){
62		$parent = $parents.first();
63	}
64
65	if (!$inmediateParent || !$inmediateParent.length) {
66		$inmediateParent = $entryContent;
67	}
68
69	var $parentChildren = $parent.children();
70	var $siblings = $parentChildren.not($inmediateParent);
71	var inmediateParentLeft = $inmediateParent.offset().left;
72	var inmediateParentRight = inmediateParentLeft + $inmediateParent.outerWidth();
73
74	// Find theme sidebars
75	var $firstLeft, $lastRight;
76	$siblings.each(function () {
77		var $column = jQuery(this);
78		var columnLeft = $column.offset().left;
79
80		if (columnLeft < inmediateParentLeft) {
81			$firstLeft = $column;
82		} else if (columnLeft > inmediateParentRight) {
83			$lastRight = $column;
84		}
85	});
86
87
88	if ((!$firstLeft || !$firstLeft.length) && (!$lastRight || !$lastRight.length)) {
89		var $possibleSidebarElements = jQuery('.widget, .widget-area, .sidebar, #secondary, .secondary');
90		var parentLeft = $parent.offset().left;
91		var parentRight = parentLeft + $parent.width();
92
93		$leftSidebarElements = $possibleSidebarElements.filter(function () {
94			return jQuery(this).offset().left < parentLeft && !jQuery(this).parents('.vg-page-layout-sidebar').length;
95		});
96		$rightSidebarElements = $possibleSidebarElements.filter(function () {
97			return  jQuery(this).offset().left > parentRight && !jQuery(this).parents('.vg-page-layout-sidebar').length;
98		});
99
100		var $firstLeftSidebarElement = $leftSidebarElements.first();
101		var $firstLeftSidebarElementParents = $firstLeftSidebarElement.parents();
102		var $leftSidebarInmediateParent = null, $leftSidebarParent = null;
103
104		$firstLeftSidebarElementParents.each(function () {
105			var parentWidth = jQuery(this).outerWidth();
106			var parentLeft = jQuery(this).offset().left;
107			if ((parentLeft + parentWidth) > parentLeft) {
108				$leftSidebarParent = jQuery(this);
109
110				if (!$leftSidebarInmediateParent || !$leftSidebarInmediateParent.length) {
111					$leftSidebarInmediateParent = $firstLeftSidebarElement;
112				}
113				return false;
114			} else {
115				$leftSidebarInmediateParent = null;
116				$leftSidebarInmediateParent = jQuery(this);
117			}
118		});
119
120		var $firstRightSidebarElement = $rightSidebarElements.first();
121		var $firstRightSidebarElementParents = $firstRightSidebarElement.parents();
122		var $rightSidebarInmediateParent = null, $rightSidebarParent = null;
123
124		$firstRightSidebarElementParents.each(function () {
125			var parentWidth = jQuery(this).outerWidth();
126			var parentLeft = jQuery(this).offset().left;
127			if (parentLeft < parentRight) {
128				$rightSidebarParent = jQuery(this);
129				if (!$rightSidebarInmediateParent || !$rightSidebarInmediateParent.length) {
130					$rightSidebarInmediateParent = $firstRightSidebarElement;
131				}
132				return false;
133			} else {
134				$rightSidebarInmediateParent = null;
135				$rightSidebarInmediateParent = jQuery(this);
136			}
137		});
138
139		$firstLeft = $leftSidebarInmediateParent,
140				$lastRight = $rightSidebarInmediateParent;
141
142		$sidebars = jQuery().add($firstLeft).add($lastRight);
143		$possibleInmediateParent = $sidebars.first().siblings().first();
144
145		if ($possibleInmediateParent.length) {
146			$inmediateParent = $possibleInmediateParent;
147		}
148	}
149
150	return {
151		$firstLeft: $firstLeft,
152		$lastRight: $lastRight,
153		$inmediateParent: $inmediateParent,
154		$parent: $parent
155	};
156}
157jQuery(document).ready(function () {
158
159	var $marker = jQuery('.vg-page-layout-placeholder');
160
161	if (!$marker.length) {
162		return;
163	}
164	
165	// We need the body to be desktop size, to be able to find the sidebars,
166	// otherwise sidebars appear below the content and the algorithm doesn't consider
167	// them sidebars
168	if( jQuery( window ).width() < 769){
169		var windowSizeWasChanged = true;
170		jQuery( 'body' ).width(1365);
171	}
172	
173	
174	var leftSidebarSelector = $marker.data('left-sidebar-selector');
175	var rightSidebarSelector = $marker.data('right-sidebar-selector');
176	var contentColumnSelector = $marker.data('content-column-selector');
177
178
179
180	var $entryContent = $marker.parent();
181	contentColumns = vgplFindContentColumns($entryContent, false);
182
183	if (!contentColumns.$inmediateParent || !contentColumns.$inmediateParent.length) {
184		contentColumns = vgplFindContentColumns($entryContent, true);
185	}
186
187	// Use settings element if available
188	if (leftSidebarSelector) {
189		var $firstLeft = jQuery(leftSidebarSelector);
190
191		if ($firstLeft.length) {
192			contentColumns.$firstLeft = $firstLeft;
193		} else {
194			contentColumns.$firstLeft = null;
195		}
196	}
197	if (rightSidebarSelector) {
198		var $lastRight = jQuery(rightSidebarSelector);
199
200		if ($lastRight.length) {
201			contentColumns.$lastRight = $lastRight;
202		} else {
203			contentColumns.$lastRight = null;
204		}
205	}
206	if (contentColumnSelector) {
207		var $inmediateParent = jQuery(contentColumnSelector);
208		if ($inmediateParent.length) {
209			contentColumns.$inmediateParent = $inmediateParent;
210		}
211	}
212
213	window.vgplContentColumns = contentColumns;
214	jQuery('body').trigger('vgplInit');
215	
216	// Reset screen width
217	if( windowSizeWasChanged){
218		jQuery( 'body' ).css('width', '');
219	}
220
221	// Hide theme sidebars
222	if (contentColumns.$firstLeft) {
223		contentColumns.$firstLeft.hide();
224	}
225	if (contentColumns.$lastRight) {
226		contentColumns.$lastRight.hide();
227	}
228
229	// Make content column full width. We will add our sidebars inside this column.
230	if (contentColumns.$inmediateParent && contentColumns.$inmediateParent.length) {
231		contentColumns.$inmediateParent.css({
232			width: '100%',
233			'max-width': '100%',
234			'box-sizing': 'border-box',
235			'margin-left': '0',
236			'margin-right': '0',
237		});
238	}
239	if ($entryContent && $entryContent.length) {
240		$entryContent.css({
241			width: '100%',
242			'max-width': '100%',
243			'box-sizing': 'border-box',
244			'margin-left': '0',
245			'margin-right': '0',
246		});
247	}
248
249	// Display our sidebars
250	var $sidebars = $entryContent.find('.vg-page-layout-sidebar');
251
252	if ($sidebars.length) {
253		var asideSidebars = 0;
254		$sidebars.each(function () {
255			var position = jQuery(this).data('position');
256
257			jQuery(this).css({
258				'display': 'block',
259				'float': position
260			});
261
262			if (!position) {
263				jQuery(this).css({
264					'width': '100%'
265				});
266			} else {
267				asideSidebars++;
268			}
269		});
270
271		// Wrap content in div to separate from sidebars
272		$entryContent.children().not($sidebars).wrapAll('<div class="vg-page-layout-content"></div>');
273
274		var $content = $entryContent.find('.vg-page-layout-content');
275
276		if (jQuery('.vg-page-layout-left-sidebar').length) {
277			if (jQuery(window).width() < 769) {
278				$content.insertBefore(jQuery('.vg-page-layout-left-sidebar'));
279			} else {
280				$content.insertAfter(jQuery('.vg-page-layout-left-sidebar'));
281			}
282		}
283		if (jQuery('.vg-page-layout-above-content-sidebar').length) {
284			jQuery('.vg-page-layout-above-content-sidebar').prependTo($content.parent());
285		}
286
287
288		if (jQuery(window).width() > 768) {
289			if (asideSidebars > 1) {
290				$content.css({
291					'width': '50%'
292				});
293
294			} else if (asideSidebars > 0) {
295				$content.css({
296					'width': '75%'
297				});
298			}
299		}
300	}
301
302
303
304});

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.