PageSourceSearch

https://ives-openscience.eu/wp-content/plugins/diviflash/public/js/contentSwitcher.js?ver=1.2.5

js ives-openscience.eu collected 2026-10-02 14:50:04 UTC 6,126 bytes, 188 lines download raw bytes

1(function ($) {
2
3        var selectors = document.querySelectorAll('.difl_contentswitcher');
4        [].forEach.call(selectors, function (selector) {
5			var container = selector.querySelector('.df-content-switcher-wrapper');
6
7        	var settings = JSON.parse(container.dataset.settings);
8
9			var _elm = $(selector);
10			
11            var toggleSwitch = _elm.find('.df-cs-switch.df-input-label'),
12				input = _elm.find('input.df-cs-toggle-switch'),
13				primarySwitcher = _elm.find('.df-cs-switch.primary'),
14				secondarySwitcher = _elm.find('.df-cs-switch.secondary');
15
16				if(settings.content_switcher_type ==='class_base'){
17					$("." + settings.primary_content_selector).show();
18					$("." + settings.secondary_content_selector).hide();
19				}
20				const animationStatus = settings.enable_animation ? settings.enable_animation : 'on';
21				toggleSwitch.on('click', function(e){
22				
23					if(input.is(':checked')){
24						primarySwitcher.removeClass('active');
25						secondarySwitcher.addClass('active');
26						const secondarySelector = settings.content_switcher_type !=='class_base' ? `.${settings.module_class} .df-cs-content-section`: `.${settings.secondary_content_selector}`
27						df_content_switcher_anime(
28							_elm, 
29							secondarySelector, 
30							settings.content_animation, 
31							parseInt(settings.content_animation_duration),
32							'secondary',
33							animationStatus
34						);
35						if(settings.content_switcher_type ==='class_base'){
36						
37							$("." + settings.primary_content_selector).hide();
38							$("." + settings.secondary_content_selector).show();
39						}
40					}else {
41						secondarySwitcher.removeClass('active');
42						primarySwitcher.addClass('active');
43						const primarySelector = settings.content_switcher_type !=='class_base' ? `.${settings.module_class} .df-cs-content-section` : `.${settings.primary_content_selector}`;
44						df_content_switcher_anime(
45							_elm, 
46							primarySelector,
47							settings.content_animation, 
48							parseInt(settings.content_animation_duration),
49							'primary',
50							animationStatus
51						);
52						if(settings.content_switcher_type ==='class_base'){
53							$("." + settings.primary_content_selector).show();
54							$("." + settings.secondary_content_selector).hide();
55						}
56					}
57				});
58
59				var buttons = _elm.find('.df-cs-button'),
60				contents = _elm.find('.df-cs-content-section');
61			
62				buttons.each(function (index, btn){
63					$(this).on('click', function(e) {
64						e.preventDefault();
65				
66						if($(this).hasClass('active')) {
67							return;
68						}else {
69
70							const classBaseSelector = index === 0 ? `.${settings.primary_content_selector}` : `.${settings.secondary_content_selector}`;
71							const buttonContentSelector = settings.content_switcher_type !=='class_base' ? `.${settings.module_class} .df-cs-content-section` : classBaseSelector;	
72							const contentClass = index !== 0 ? 'secondary' : 'primary';
73							df_content_switcher_anime(
74								_elm, 
75								buttonContentSelector, 
76								settings.content_animation, 
77								parseInt(settings.content_animation_duration),
78								settings.content_switcher_type !=='class_base' ? contentClass : 'class',
79								animationStatus
80							);
81							
82							buttons.removeClass('active');
83							$(this).addClass('active');
84							if(settings.content_switcher_type ==='class_base'){
85
86								if(index === 0){
87									$("." + settings.primary_content_selector).show();
88									$("." + settings.secondary_content_selector).hide();
89						
90								}else{
91									$("."+ settings.primary_content_selector).hide();
92									$("."+ settings.secondary_content_selector).show();
93								}							
94							}else{
95						
96								contents.removeClass('active');
97								_elm.find('.df-cs-content-section:eq('+ index +')').addClass('active');
98								
99							}
100						}
101					} );
102				});
103
104        });
105
106		var animations = {
107			slide_left : {
108				opacity: ['1', '0'],
109				translateX: ['0', '-100px']
110			},
111			slide_right : {
112				opacity: ['1', '0'],
113				translateX: ['0', '100px']
114			},
115			slide_up : {
116				opacity: ['1', '0'],
117				translateY: ['0', '-100px']
118			},
119			slide_down : {
120				opacity: ['1', '0'],
121				translateY: ['0', '100px']
122			},
123			fade_in : {
124				opacity: ['1', '0'],
125			},
126			zoom_left : {
127				opacity: ['1', '0'],
128				scale: ['1', '.5'],
129				transformOrigin: ['0% 50%', '0% 50%'],
130				// duration: 200
131			},
132			zoom_center : {
133				opacity: ['1', '0'],
134				scale: ['1', '.5'],
135				transformOrigin: ['50% 50%', '50% 50%'],
136				// duration: 200
137			},
138			zoom_right : {
139				opacity: ['1', '0'],
140				scale: ['1', '.5'],
141				transformOrigin: ['100% 50%', '100% 50%'],
142				// duration: 200
143			}
144		}
145	
146		function df_content_switcher_anime(element, selector, config = 'slide_left', duration, active_class , animationStatus = 'on'  ) {
147			var object = {
148				targets: selector,
149				direction: 'alternate',
150				easing: 'linear',
151				duration: duration,
152				endDelay: 1,
153				update: function(anim) {
154					if(anim.progress === 100) {
155						if(active_class === 'secondary'){
156							element.find('.df-cs-content-section.secondary').addClass('active');
157							element.find('.df-cs-content-section.primary').removeClass('active');
158	
159						}else{
160							element.find('.df-cs-content-section.primary').addClass('active');
161							element.find('.df-cs-content-section.secondary').removeClass('active');
162						}
163						
164					}
165				}
166			};
167			if(animationStatus === 'on'){
168				var anime_config = Object.assign(object, animations[config]);
169	
170				if( window.anime ) {
171					window.anime(anime_config);
172				}
173			}else{
174				if(active_class === 'secondary'){
175					element.find('.df-cs-content-section.secondary').addClass('active');
176					element.find('.df-cs-content-section.primary').removeClass('active');
177
178				}else{
179					element.find('.df-cs-content-section.primary').addClass('active');
180					element.find('.df-cs-content-section.secondary').removeClass('active');
181				}
182			}
183		
184		} 
185    
186})(jQuery);
187	
188				

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.