PageSourceSearch

https://www.sencelles.cat/wp-content/themes/enfold/config-template…/toggles/toggles.js?ver=5.4.1

js sencelles.cat collected 2026-10-01 12:26:12 UTC 4,290 bytes, 180 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			//	needed to avoid scroll to top when opening and closing toggles - can be removed when other solution found (readded @since 4.8.4.1)
31			var activeStyle = '',
32				headingStyle = '';
33
34			heading.each(function(i)
35			{
36				var thisheading = $(this),
37					content = thisheading.next(options.content, container);
38
39				function scroll_to_viewport()
40				{
41				    //check if toggle title is in viewport. if not scroll up
42				    var el_offset = content.offset().top,
43				        scoll_target = el_offset - 50 - parseInt($('html').css('margin-top'),10);
44
45				    if(win.scrollTop() > el_offset)
46				    {
47				        $('html:not(:animated),body:not(:animated)').animate({scrollTop: scoll_target},200);
48				    }
49				}
50
51				if(content.css('visibility') != "hidden")
52				{
53					thisheading.addClass('activeTitle').attr('style',activeStyle);
54				}
55
56				thisheading.on('keydown', function(objEvent)
57				{
58					if(objEvent.keyCode === 13)  // if user presses 'enter'
59					{
60						thisheading.trigger('click');
61					}
62				});
63
64				thisheading.on( 'click', function()
65				{
66					if(content.css('visibility') != "hidden")
67					{
68						content.slideUp( 200, function()
69						{
70							content.removeClass('active_tc').attr({style:''});
71							win.trigger('av-height-change');
72							win.trigger('av-content-el-height-changed', this );
73
74							if( preview.length == 0 )
75							{
76								location.replace(thisheading.data('fake-id') + "-closed");
77							}
78						});
79
80						thisheading.removeClass('activeTitle').attr('style',headingStyle);
81
82					}
83					else
84					{
85						if(container.is('.toggle_close_all'))
86						{
87							allContent.not(content).slideUp(200, function()
88							{
89								$(this).removeClass('active_tc').attr({style:''});
90								scroll_to_viewport();
91							});
92
93							heading.removeClass('activeTitle').attr('style',headingStyle);
94						}
95
96						content.addClass('active_tc');
97
98						setTimeout(function()
99						{
100							content.slideDown(200, function()
101							{
102								if(!container.is('.toggle_close_all'))
103								{
104									scroll_to_viewport();
105								}
106
107								win.trigger('av-height-change');
108								win.trigger('av-content-el-height-changed', this );
109							});
110
111						}, 1);
112
113						thisheading.addClass('activeTitle').attr('style',activeStyle);
114
115						if( preview.length == 0 )
116						{
117							location.replace(thisheading.data('fake-id'));
118						}
119					}
120				});
121			});
122
123
124			sortLinks.on( 'click', function(e)
125			{
126				e.preventDefault();
127
128				var show = toggles.filter('[data-tags~="'+$(this).data('tag')+'"]'),
129					hide = toggles.not('[data-tags~="'+$(this).data('tag')+'"]');
130
131				sortLinks.removeClass('activeFilter');
132				$(this).addClass('activeFilter');
133				heading.filter('.activeTitle').trigger('click');
134				show.slideDown();
135				hide.slideUp();
136			});
137
138
139			function trigger_default_open(hash)
140			{
141				if( ! hash && window.location.hash )
142				{
143					hash = window.location.hash;
144				}
145
146				if( ! hash )
147				{
148					return;
149				}
150
151				var open = heading.filter('[data-fake-id="'+hash+'"]');
152
153				if( open.length )
154				{
155					if( !open.is('.activeTitle') )
156					{
157						open.trigger('click');
158					}
159
160					window.scrollTo(0, container.offset().top - 70);
161				}
162			}
163
164			trigger_default_open(false);
165
166			$('a').on( 'click', function()
167			{
168				var hash = $(this).attr('href');
169				if(typeof hash != "undefined" && hash)
170				{
171					hash = hash.replace(/^.*?#/,'');
172					trigger_default_open('#'+hash);
173				}
174			});
175
176		});
177	};
178
179}(jQuery));
180

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.