PageSourceSearch

https://columbiagames.com/wp-content/themes/enfold/config-template…/toggles/toggles.js?ver=7.1.2

js columbiagames.com collected 2026-09-24 10:00:03 UTC 6,418 bytes, 242 lines download raw bytes

1// -------------------------------------------------------------------------------------------
2// Toggle shortcode javascript
3// -------------------------------------------------------------------------------------------
4(function($)
5{
6	"use strict";
7
8	$.fn.avia_sc_toggle = function(options)
9	{
10		var defaults =
11		{
12			single: '.single_toggle',
13			heading: '.toggler',
14			content: '.toggle_wrap',
15			sortContainer:'.taglist'
16		};
17
18		var win = $(window),
19			options = $.extend(defaults, options);
20
21		return this.each(function()
22		{
23			var container = $(this).addClass('enable_toggles'),
24				toggles = $(options.single, container),
25				heading = $(options.heading, container),
26				allContent = $(options.content, container),
27				sortLinks = $(options.sortContainer + " a", container),
28				preview = $( '#av-admin-preview' );
29
30
31
32			//	needed to avoid scroll to top when opening and closing toggles - can be removed when other solution found (readded @since 4.8.4.1)
33			var activeStyle = '',
34				headingStyle = '';
35
36			heading.each(function(i)
37			{
38				var thisheading = $(this),
39					content = thisheading.hasClass( 'av-title-below' ) ? thisheading.prev( options.content, container ) : thisheading.next( options.content, container ),
40					slideSpeed = parseInt( thisheading.data( 'slide-speed' ) );
41
42				slideSpeed = isNaN( slideSpeed ) ? 200 : slideSpeed;
43
44				function scroll_to_viewport()
45				{
46				    //check if toggle title is in viewport. if not scroll up
47				    var el_offset = content.offset().top,
48				        scoll_target = el_offset - 50 - parseInt($('html').css('margin-top'),10);
49
50				    if(win.scrollTop() > el_offset)
51				    {
52				        $('html:not(:animated),body:not(:animated)').animate( {scrollTop: scoll_target}, slideSpeed );
53				    }
54				}
55
56				if( content.css('visibility') != "hidden" )
57				{
58					thisheading.addClass('activeTitle').attr('style',activeStyle);
59				}
60
61				thisheading.on('keydown', function(objEvent)
62				{
63					// user presses 'enter' or space https://www.w3.org/WAI/ARIA/apg/patterns/accordion/#keyboardinteraction
64					if( objEvent.keyCode === 13 || objEvent.keyCode === 32 )  // if user presses 'enter' or space
65					{
66						thisheading.trigger('click');
67					}
68				});
69
70				thisheading.on( 'click', function()
71				{
72					if( content.css('visibility') != "hidden" )
73					{
74						content.slideUp( slideSpeed, function()
75						{
76							content.removeClass('active_tc').attr({style:''});
77							win.trigger('av-height-change');
78							win.trigger('av-content-el-height-changed', this );
79
80							if( preview.length == 0 )
81							{
82								location.replace( thisheading.data('fake-id') + "-closed" );
83							}
84						});
85
86						thisheading.removeClass('activeTitle').attr('style', headingStyle);
87					}
88					else
89					{
90						if( container.is('.toggle_close_all') )
91						{
92							allContent.not(content).slideUp( slideSpeed, function()
93							{
94								$(this).removeClass('active_tc').attr({style:''});
95								scroll_to_viewport();
96							});
97
98							heading.removeClass('activeTitle').attr('style',headingStyle);
99						}
100
101						content.addClass('active_tc');
102
103						setTimeout(function()
104						{
105							content.slideDown( slideSpeed, function()
106							{
107								if( ! container.is('.toggle_close_all') )
108								{
109									scroll_to_viewport();
110								}
111
112								win.trigger( 'av-height-change' );
113								win.trigger( 'av-content-el-height-changed', this );
114							});
115
116						}, 1);
117
118						thisheading.addClass('activeTitle').attr( 'style', activeStyle );
119
120						if( preview.length == 0 )
121						{
122							location.replace(thisheading.data('fake-id'));
123						}
124					}
125
126				});
127			});
128
129			sortLinks.on( 'click', function(e)
130			{
131				e.preventDefault();
132
133				var show = toggles.filter('[data-tags~="' + $(this).data('tag') + '"]'),
134					hide = toggles.not('[data-tags~="' + $(this).data('tag') + '"]');
135
136				sortLinks.removeClass('activeFilter');
137				$(this).addClass('activeFilter');
138				heading.filter('.activeTitle').trigger('click');
139				show.slideDown();
140				hide.slideUp();
141			});
142
143			function changeTitleAria()
144			{
145				heading.each( function( i )
146				{
147					let $heading = $(this),
148						title_open = $heading.attr( 'data-title-open' ),
149						title = $heading.attr( 'data-title' ),
150						aria_collapsed = $heading.attr( 'data-aria_collapsed' ),
151						aria_expanded = $heading.attr( 'data-aria_expanded' ),
152						content = $heading.hasClass( 'av-title-below' ) ? $heading.prev( options.content, container ) : $heading.next( options.content, container ),
153						titleHasHtml = false,
154						currentTitle = $heading.contents()[0].data;
155
156					if( ! title )
157					{
158						title = '***';
159					}
160
161					if( ! aria_collapsed )
162					{
163						aria_collapsed = 'Expand Toggle';
164					}
165
166					if( ! aria_expanded )
167					{
168						aria_expanded = 'Collapse Toggle';
169					}
170
171					//	limitation - html markup breaks exchange logic because contents()[0] ends with first markup
172					titleHasHtml = title.indexOf( '<' ) >= 0;
173
174					if( content.css('visibility') != "hidden" )
175					{
176						if( title_open && ! titleHasHtml && currentTitle != title_open )
177						{
178							$heading.contents()[0].data = title_open;
179						}
180						$heading.attr( 'aria-expanded', 'true' );
181						$heading.attr( 'aria-label', aria_expanded );
182						content.attr( { 'aria-hidden': 'false', tabindex: 0 } );
183					}
184					else
185					{
186						if( title_open && ! titleHasHtml && currentTitle != title )
187						{
188							$heading.contents()[0].data = title;
189						}
190
191						$heading.attr( 'aria-expanded', 'false' );
192						$heading.attr( 'aria-label', aria_collapsed );
193						content.attr( { 'aria-hidden': 'true', tabindex: -1 } );
194					}
195				});
196
197				setTimeout( function(){ changeTitleAria(); }, 150 );
198			}
199
200			function trigger_default_open(hash)
201			{
202				if( ! hash && window.location.hash )
203				{
204					hash = window.location.hash;
205				}
206
207				if( ! hash )
208				{
209					return;
210				}
211
212				var open = heading.filter('[data-fake-id="' + hash + '"]');
213
214				if( open.length )
215				{
216					if( ! open.is('.activeTitle') )
217					{
218						open.trigger('click');
219					}
220
221					window.scrollTo(0, container.offset().top - 70);
222				}
223			}
224
225			changeTitleAria();
226			trigger_default_open(false);
227
228			$('a').on( 'click', function()
229			{
230				var hash = $(this).attr('href');
231				if(typeof hash != "undefined" && hash)
232				{
233					hash = hash.replace( /^.*?#/,'' );
234					trigger_default_open( '#' + hash );
235				}
236			});
237
238		});
239	};
240
241}(jQuery));
242

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.