PageSourceSearch

https://www.lsl.lviv.ua/wp-content/plugins/jquery-collapse-o-matic/js/collapse.js?ver=1.6.14

js lsl.lviv.ua collected 2026-09-24 21:13:54 UTC 18,056 bytes, 589 lines download raw bytes

1/*!
2 * Collapse-O-Matic JavaSctipt v1.6.14
3 * http://plugins.twinpictures.de/plugins/collapse-o-matic/
4 *
5 * Copyright 2018, Twinpictures
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, blend, trade,
11 * bake, hack, scramble, difiburlate, digest and/or sell copies of the Software,
12 * and to permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 */
26function collapse_init() {
27	//force collapse
28	jQuery('.force_content_collapse').each(function(index) {
29		jQuery(this).css('display', 'none');
30	});
31
32	//inital collapse
33	jQuery('.collapseomatic:not(.colomat-close)').each(function(index) {
34		var thisid = jQuery(this).attr('id');
35		jQuery('#target-'+thisid).css('display', 'none');
36	});
37
38	//inital swaptitle for pre-expanded elements
39	jQuery('.collapseomatic.colomat-close').each(function(index) {
40		var thisid = jQuery(this).attr('id');
41		if(jQuery("#swap-"+thisid).length > 0){
42			swapTitle(this, "#swap-"+thisid );
43		}
44		if(jQuery("#swapexcerpt-"+thisid).length > 0){
45			swapTitle("#excerpt-"+thisid, "#swapexcerpt-"+thisid);
46		}
47	});
48}
49
50function swapTitle(origObj, swapObj){
51	if(jQuery(origObj).prop("tagName") == 'IMG'){
52		var origsrc = jQuery(origObj).prop('src');
53		var swapsrc = jQuery(swapObj).prop('src');
54
55		jQuery(origObj).prop('src',swapsrc);
56		jQuery(swapObj).prop('src',origsrc);
57	}
58	else{
59		var orightml = jQuery(origObj).html();
60		var swaphtml = jQuery(swapObj).html();
61
62		jQuery(origObj).html(swaphtml);
63		jQuery(swapObj).html(orightml);
64
65		//is cufon involved? if so, do that thing
66		if(swaphtml.indexOf("<cufon") != -1){
67			var trigelem = jQuery(this).get(0).tagName;
68			Cufon.replace(trigelem);
69		}
70	}
71}
72
73function toggleState (obj, id, maptastic, trig_id) {
74	//toggletarget class
75	//jQuery('[id^=target][id$='+id+']').toggleClass('colomat-targ-visable');
76
77	if (maptastic && jQuery('[id^=target][id$='+id+']').hasClass('maptastic') ) {
78		jQuery('[id^=target][id$='+id+']').removeClass('maptastic');
79	}
80
81	//reset effect and duration to default
82	com_effect = colomatslideEffect;
83	com_duration = colomatduration;
84
85	//effect override
86	if( obj.attr('data-animation_effect') ){
87		com_effect = obj.attr('data-animation_effect');
88	}
89
90	//duration override
91	if( obj.attr('data-duration') ){
92		com_duration = obj.attr('data-duration');
93	}
94
95	//if durration is a number, make it a number
96	if( isFinite(com_duration) ){
97		com_duration = parseFloat(com_duration);
98	}
99
100	//slideToggle
101	if(com_effect == 'slideToggle'){
102		//jQuery('[id^=target][id$='+id+']').slideToggle(com_duration, function() {
103		jQuery('#target-'+id).slideToggle(com_duration, function() {
104			// Animation complete.
105			if( jQuery(this).hasClass('colomat-inline') && jQuery(this).is(':visible') ){
106				jQuery(this).css('display', 'inline');
107			}
108
109			//deal with any findme links
110			if(trig_id && jQuery('#'+trig_id).is('.find-me.colomat-close')){
111				//offset_top = jQuery('#find-'+trig_id).attr('name');
112				offset_top = jQuery('#'+trig_id).attr('data-findme');
113
114				if(!offset_top || offset_top == 'auto'){
115					target_offset = jQuery('#'+trig_id).offset();
116					offset_top = target_offset.top;
117				}
118				jQuery('html, body').animate({scrollTop:offset_top}, 500);
119			}
120		});
121	}
122	//slideFade
123	else if(com_effect == 'slideFade'){
124		jQuery('#target-'+id).animate({
125			height: "toggle",
126			opacity: "toggle"
127		}, com_duration, function (){
128			//Animation complete
129			if( jQuery(this).hasClass('colomat-inline') && jQuery(this).is(':visible') ){
130				jQuery(this).css('display', 'inline');
131			}
132
133			//deal with any findme links
134			if(trig_id && jQuery('#'+trig_id).is('.find-me.colomat-close')){
135				//offset_top = jQuery('#find-'+trig_id).attr('name');
136				offset_top = jQuery('#'+trig_id).attr('data-findme');
137
138				if(!offset_top || offset_top == 'auto'){
139					target_offset = jQuery('#'+trig_id).offset();
140					offset_top = target_offset.top;
141				}
142				jQuery('html, body').animate({scrollTop:offset_top}, 500);
143			}
144		});
145	}
146
147	//deal with google maps builder resize
148	if(jQuery('#'+id).hasClass('colomat-close')){
149		jQuery('.google-maps-builder').each(function(index) {
150			map = jQuery(".google-maps-builder")[index];
151			google.maps.event.trigger(map, 'resize');
152		});
153	}
154
155	//callback
156	if ( typeof colomat_callback != 'undefined' ) {
157		colomat_callback();
158	}
159}
160
161function closeOtherGroups(rel){
162	jQuery('.collapseomatic[rel!="' + rel +'"]').each(function(index) {
163		//add close class if open
164		if(jQuery(this).hasClass('colomat-expand-only') && jQuery(this).hasClass('colomat-close')){
165			return;
166		}
167		if(jQuery(this).hasClass('colomat-close') && jQuery(this).attr('rel') !== undefined){
168			jQuery(this).removeClass('colomat-close');
169			var id = jQuery(this).attr('id');
170			//remove parent highlight class
171			jQuery('#parent-'+id).removeClass('colomat-parent-highlight');
172
173			//check if the title needs to be swapped out
174			if(jQuery("#swap-"+id).length > 0){
175				swapTitle(this, "#swap-"+id);
176			}
177
178			//check if the excerpt needs to be swapped out
179			if(jQuery("#swapexcerpt-"+id).length > 0){
180				swapTitle("#exerpt-"+id, "#swapexcerpt-"+id);
181			}
182
183			toggleState (jQuery(this), id, false, false);
184
185			//check if there are nested children that need to be collapsed
186			var ancestors = jQuery('.collapseomatic', '#target-'+id);
187			ancestors.each(function(index) {
188				jQuery(this).removeClass('colomat-close');
189				var thisid = jQuery(this).attr('id');
190				jQuery('#target-'+thisid).css('display', 'none');
191			})
192		}
193	});
194}
195
196function closeOtherMembers(rel, id){
197	jQuery('.collapseomatic[rel="' + rel +'"]').each(function(index) {
198		if(jQuery(this).hasClass('colomat-expand-only') && jQuery(this).hasClass('colomat-close')){
199			return;
200		}
201
202		//add close class if open
203		if(jQuery(this).attr('id') != id && jQuery(this).hasClass('colomat-close') && jQuery(this).attr('rel') !== undefined){
204			//collapse the element
205			jQuery(this).removeClass('colomat-close');
206			var thisid = jQuery(this).attr('id');
207			//remove parent highlight class
208			jQuery('#parent-'+thisid).removeClass('colomat-parent-highlight');
209
210			//check if the title needs to be swapped out
211			if(jQuery("#swap-"+thisid).length > 0){
212				swapTitle(this, "#swap-"+thisid);
213			}
214
215			//check if the excerpt needs to be swapped out
216			if(jQuery("#swapexcerpt-"+thisid).length > 0){
217				swapTitle("#excerpt-"+thisid, "#swapexcerpt-"+thisid);
218			}
219
220			//check for snap-shut
221			if(!jQuery(this).hasClass('colomat-close') && jQuery(this).hasClass('snap-shut')){
222				jQuery('#target-'+thisid).hide();
223			}
224			else{
225				toggleState (jQuery(this), thisid, false, false);
226			}
227
228			//check if there are nested children that need to be collapsed
229			var ancestors = jQuery('.collapseomatic', '#target-'+id);
230			ancestors.each(function(index) {
231				if(jQuery(this).hasClass('colomat-expand-only') && jQuery(this).hasClass('colomat-close')){
232					return;
233				}
234				//deal with extra tirggers
235				var pre_id = id.split('-');
236				if (pre_id[0].indexOf('extra') != '-1') {
237					//console.log('this is an extra trigger');
238					pre = pre_id.splice(0, 1);
239					id = pre_id.join('-');
240
241					//deal with any scroll to links from the Extra Collapse Trigger
242					if(jQuery(this).hasClass('scroll-to-trigger')){
243						var target_offset = jQuery('#'+id).offset();
244						offset_top = target_offset.top;
245					}
246
247					//deal with any scroll to links from the Title Trigger
248					if(jQuery('#'+id).hasClass('scroll-to-trigger')){
249						offset_top = jQuery('#scrollonclose-'+id).attr('name');
250						if (offset_top == 'auto') {
251							var target_offset = jQuery('#'+id).offset();
252							offset_top = target_offset.top;
253						}
254					}
255
256					//toggle master trigger arrow
257					jQuery('#'+id).toggleClass('colomat-close');
258
259					//toggle any other extra trigger arrows
260					jQuery('[id^=extra][id$='+id+']').toggleClass('colomat-close');
261				}
262
263				if(jQuery(this).attr('id').indexOf('bot-') == '-1'){
264					jQuery(this).removeClass('colomat-close');
265					var thisid = jQuery(this).attr('id');
266					//check if the title needs to be swapped out
267					if(jQuery("#swap-"+thisid).length > 0){
268						swapTitle(this, "#swap-"+thisid);
269					}
270					//check if the excerpt needs to be swapped out
271					if(jQuery("#swapexcerpt-"+thisid).length > 0){
272						swapTitle("#excerpt-"+thisid, "#swapexcerpt-"+thisid);
273					}
274					jQuery('#target-'+thisid).css('display', 'none');
275				}
276			})
277		}
278	});
279}
280
281function colomat_expandall(loop_items){
282	if (!loop_items){
283		loop_items = jQuery('.collapseomatic:not(.colomat-close)');
284	}
285	loop_items.each(function(index) {
286		jQuery(this).addClass('colomat-close');
287		var thisid = jQuery(this).attr('id');
288		jQuery('#parent-'+thisid).addClass('colomat-parent-highlight');
289
290		if(jQuery("#swap-"+thisid).length > 0){
291			swapTitle(this, "#swap-"+thisid);
292		}
293
294		if(jQuery("#swapexcerpt-"+thisid).length > 0){
295			swapTitle("#excerpt-"+thisid, "#swapexcerpt-"+thisid);
296		}
297
298		toggleState(jQuery(this), thisid, false, false);
299	});
300}
301
302function colomat_collapseall(loop_items){
303	if (!loop_items){
304		loop_items = jQuery('.collapseomatic.colomat-close');
305	}
306
307	loop_items.each(function(index) {
308		if(jQuery(this).hasClass('colomat-expand-only') && jQuery(this).hasClass('colomat-close')){
309			return;
310		}
311
312		jQuery(this).removeClass('colomat-close');
313		var thisid = jQuery(this).attr('id');
314		jQuery('#parent-'+thisid).removeClass('colomat-parent-highlight');
315
316		if(jQuery("#swap-"+thisid).length > 0){
317			swapTitle(this, "#swap-"+thisid);
318		}
319
320		if(jQuery("#swapexcerpt-"+thisid).length > 0){
321			swapTitle("#excerpt-"+thisid, "#swapexcerpt-"+thisid);
322		}
323
324		toggleState(jQuery(this), thisid, false, false);
325
326	});
327}
328
329
330jQuery(document).ready(function() {
331	//console.log(colomatduration, colomatslideEffect, colomatpauseInit);
332	com_binding = 'click';
333	if(colomattouchstart){
334		com_binding = 'click touchstart';
335	}
336
337	if(colomatpauseInit){
338		init_pause = setTimeout(collapse_init, colomatpauseInit);
339	}
340	else{
341		collapse_init();
342	}
343
344	//jetpack infinite scroll catch-all
345	jQuery( document.body ).on( 'post-load', function () {
346		collapse_init();
347	} );
348
349	//Display the collapse wrapper... use to reverse the show-all on no JavaScript degredation.
350	jQuery('.content_collapse_wrapper').each(function(index) {
351		jQuery(this).css('display', 'inline');
352	});
353
354	//hover
355	jQuery(document).on({
356		mouseenter: function(){
357			//stuff to do on mouseover
358			jQuery(this).addClass('colomat-hover');
359		},
360		mouseleave: function(){
361			//stuff to do on mouseleave
362			jQuery(this).removeClass('colomat-hover');
363		},
364		focusin: function(){
365			//stuff to do on keyboard focus
366			jQuery(this).addClass('colomat-hover');
367		},
368		focusout: function(){
369			//stuff to do on losing keyboard focus
370			jQuery(this).removeClass('colomat-hover');
371		}
372	}, '.collapseomatic'); //pass the element as an argument to .on
373
374	//tabindex enter
375	jQuery(document).on('keypress','.collapseomatic', function(event) {
376		if (event.which == 13) {
377			event.currentTarget.click();
378		};
379	});
380
381	//the main collapse/expand function
382	jQuery(document).on(com_binding, '.collapseomatic', function(event) {
383		var offset_top;
384
385		//alert('phones ringin dude');
386		if(jQuery(this).hasClass('colomat-expand-only') && jQuery(this).hasClass('colomat-close')){
387			return;
388		}
389
390		//highlander must be one
391		if(jQuery(this).attr('rel') && jQuery(this).attr('rel').indexOf('-highlander') != '-1' && jQuery(this).hasClass('must-be-one') && jQuery(this).hasClass('colomat-close')){
392			return;
393		}
394
395		var id = jQuery(this).attr('id');
396
397		//deal with any scroll to links
398		if(jQuery(this).hasClass('colomat-close') && jQuery(this).hasClass('scroll-to-trigger')){
399			offset_top = jQuery('#scrollonclose-'+id).attr('name');
400			if (offset_top == 'auto') {
401				var target_offset = jQuery('#'+id).offset();
402				offset_top = target_offset.top;
403			}
404		}
405
406		var id_arr = id.split('-');
407
408		//deal with extra tirggers
409		if (id_arr[0].indexOf('extra') != '-1') {
410			//console.log('this is an extra trigger');
411			pre = id_arr.splice(0, 1);
412			id = id_arr.join('-');
413
414			//deal with any scroll to links from the Extra Collapse Trigger
415			if(jQuery(this).hasClass('scroll-to-trigger')){
416				var target_offset = jQuery('#'+id).offset();
417				offset_top = target_offset.top;
418			}
419
420			//deal with any scroll to links from the Title Trigger
421			if(jQuery('#'+id).hasClass('scroll-to-trigger')){
422				offset_top = jQuery('#scrollonclose-'+id).attr('name');
423				if (offset_top == 'auto') {
424					var target_offset = jQuery('#'+id).offset();
425					offset_top = target_offset.top;
426				}
427			}
428
429			//toggle master trigger arrow
430			jQuery('#'+id).toggleClass('colomat-close');
431
432			//toggle any other extra trigger arrows
433			jQuery('[id^=extra][id$='+id+']').toggleClass('colomat-close');
434		}
435
436		else if(id.indexOf('bot-') != '-1'){
437			id = id.substr(4);
438			jQuery('#'+id).toggleClass('colomat-close');
439
440			//deal with any scroll to links from the Internal Collapse Trigger
441			if(jQuery(this).hasClass('scroll-to-trigger')){
442				var target_offset = jQuery('#'+id).offset();
443				offset_top = target_offset.top;
444			}
445
446			//deal with any scroll to links from the Title Trigger
447			if(jQuery('#'+id).hasClass('scroll-to-trigger')){
448				offset_top = jQuery('#scrollonclose-'+id).attr('name');
449				if (offset_top == 'auto') {
450					var target_offset = jQuery('#'+id).offset();
451					offset_top = target_offset.top;
452				}
453			}
454		}
455		else{
456			jQuery(this).toggleClass('colomat-close');
457			//toggle any extra triggers
458			jQuery('[id^=extra][id$='+id+']').toggleClass('colomat-close');
459		}
460
461		//check if the title needs to be swapped out
462		if(jQuery("#swap-"+id).length > 0){
463			swapTitle(jQuery('#'+id), "#swap-"+id);
464		}
465
466		//check if the excerpt needs to be swapped out
467		if(jQuery("#swapexcerpt-"+id).length > 0){
468			swapTitle("#excerpt-"+id, "#swapexcerpt-"+id);
469		}
470
471		//add visited class
472		jQuery(this).addClass('colomat-visited');
473
474		//toggle parent highlight class
475		var parentID = 'parent-'+id;
476		jQuery('#' + parentID).toggleClass('colomat-parent-highlight');
477
478		//check for snap-shut
479		if(!jQuery(this).hasClass('colomat-close') && jQuery(this).hasClass('snap-shut')){
480			jQuery('#target-'+id).hide();
481		}
482		else{
483			toggleState (jQuery(this), id, true, id);
484		}
485
486		//deal with grouped items if needed
487		if(jQuery(this).attr('rel') !== undefined){
488			var rel = jQuery(this).attr('rel');
489			if(rel.indexOf('-highlander') != '-1'){
490				closeOtherMembers(rel, id);
491			}
492			else{
493				closeOtherGroups(rel);
494			}
495		}
496
497		if(offset_top){
498			jQuery('html, body').animate({scrollTop:offset_top}, 500);
499		}
500	});
501
502
503	jQuery(document).on(com_binding, '.expandall', function(event) {
504		if(jQuery(this).attr('rel') !== undefined){
505			var rel = jQuery(this).attr('rel');
506			var loop_items = jQuery('.collapseomatic:not(.colomat-close)[rel="' + rel +'"]');
507		}
508		else if(jQuery(this).attr('data-togglegroup') !== undefined){
509			var toggroup = jQuery(this).attr('data-togglegroup');
510			var loop_items = jQuery('.collapseomatic:not(.colomat-close)[data-togglegroup="' + toggroup +'"]');
511		}
512		else{
513			var loop_items = jQuery('.collapseomatic:not(.colomat-close)');
514		}
515
516		colomat_expandall(loop_items);
517	});
518
519	jQuery(document).on(com_binding, '.collapseall', function(event) {
520		if(jQuery(this).attr('rel') !== undefined){
521			var rel = jQuery(this).attr('rel');
522			var loop_items = jQuery('.collapseomatic.colomat-close[rel="' + rel +'"]');
523		}
524		else if(jQuery(this).attr('data-togglegroup') !== undefined){
525			var toggroup = jQuery(this).attr('data-togglegroup');
526			var loop_items = jQuery('.collapseomatic.colomat-close[data-togglegroup="' + toggroup +'"]');
527		}
528		else {
529			var loop_items = jQuery('.collapseomatic.colomat-close');
530		}
531
532		colomat_collapseall(loop_items);
533	});
534
535	//handle new page loads with anchor
536	var fullurl = document.location.toString();
537	hashmaster(fullurl);
538
539	//handle no-link triggers within the same page
540	jQuery(document).on('click', 'a.colomat-nolink', function(event) {
541		event.preventDefault();
542	});
543
544	//manual hashtag changes in url
545	jQuery(window).on('hashchange', function (e) {
546		fullurl = document.location.toString();
547		hashmaster(fullurl);
548	});
549
550	//master url hash funciton
551	function hashmaster(fullurl){
552		// the URL contains an anchor but not a hash-bang
553		if (fullurl.match('#(?!\!)')) {
554			// click the navigation item corresponding to the anchor
555			var anchor_arr = fullurl.split(/#(?!\!)/);
556
557			if(anchor_arr.length > 1){
558				junk = anchor_arr.splice(0, 1);
559				anchor = anchor_arr.join('#');
560			}
561			else{
562				anchor = anchor_arr[0];
563			}
564
565			if( jQuery('#' + anchor).length ){
566				//expand any nested parents
567				jQuery('#' + anchor).parents('.collapseomatic_content').each(function(index) {
568					parent_arr = jQuery(this).attr('id').split('-');
569					junk = parent_arr.splice(0, 1);
570					parent = parent_arr.join('-');
571					if(!jQuery('#' + parent).hasClass('colomat-close')){
572						jQuery('#' + parent).click();
573					}
574				})
575				//now expand the target anchor
576				if(!jQuery('#' + anchor).hasClass('colomat-close')){
577					jQuery('#' + anchor).click();
578				}
579			}
580
581			if(typeof colomatoffset !== 'undefined'){
582				var anchor_offset = jQuery('#' + anchor).offset();
583				colomatoffset = colomatoffset + anchor_offset.top;
584				jQuery('html, body').animate({scrollTop:colomatoffset}, 50);
585			}
586
587		}
588	}
589});

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.