PageSourceSearch

https://alboragro.com/wp-content/plugins/litho-addons/includes/assets/js/accordion.js?ver=3.7

js alboragro.com collected 2026-10-08 10:53:11 UTC 4,243 bytes, 152 lines download raw bytes

1class WidgetHandlerClass extends elementorModules.frontend.handlers.Base {
2		
3	getDefaultSettings() {
4		return {
5			selectors: {
6				tablist: '[role="tablist"]',
7				tabTitle: '.elementor-tab-title',
8				tabContent: '.elementor-tab-content',
9			},
10			classes: {
11				active: 'elementor-active',
12			},
13			showTabFn: 'slideDown',
14			hideTabFn: 'slideUp',
15			toggleSelf: true,
16			hidePrevious: true,
17			autoExpand: true,
18		};
19	}
20
21	getDefaultElements() {
22		const selectors = this.getSettings( 'selectors' );
23
24		return {
25			$tabTitles: this.findElement( selectors.tabTitle ),
26			$tabContents: this.findElement( selectors.tabContent ),
27		};
28	}
29
30	activateDefaultTab() {
31		const settings = this.getSettings();
32
33		if ( ! settings.autoExpand || ( 'editor' === settings.autoExpand && ! this.isEdit ) ) {
34			return;
35		}
36
37		const defaultActiveTab = this.getEditSettings( 'activeItemIndex' ) || 1,
38			originalToggleMethods = {
39				showTabFn: settings.showTabFn,
40				hideTabFn: settings.hideTabFn,
41			};
42
43		// Toggle tabs without animation to avoid jumping
44		this.setSettings( {
45			showTabFn: 'slideDown',
46			hideTabFn: 'slideUp',
47		} );
48
49		this.changeActiveTab( defaultActiveTab );
50
51		// Return back original toggle effects
52		this.setSettings( originalToggleMethods );
53	}
54
55	deactivateActiveTab( tabIndex ) {
56		const settings = this.getSettings(),
57			activeClass = settings.classes.active,
58			activeFilter = tabIndex ? '[data-tab="' + tabIndex + '"]' : '.' + activeClass,
59			$activeTitle = this.elements.$tabTitles.filter( activeFilter ),
60			$activeContent = this.elements.$tabContents.filter( activeFilter );
61
62		$activeTitle.add( $activeContent ).removeClass( activeClass );
63
64		$activeTitle.attr({
65			tabindex: '-1',
66			'aria-selected': 'false',
67			'aria-expanded': 'false'
68		});
69		$activeContent[settings.hideTabFn]();
70	}
71
72	activateTab( tabIndex ) {
73		const settings        = this.getSettings(),
74			activeClass       = settings.classes.active,
75			$requestedTitle   = this.elements.$tabTitles.filter( '[data-tab="' + tabIndex + '"]' ),
76			$requestedContent = this.elements.$tabContents.filter( '[data-tab="' + tabIndex + '"]' ),
77			animationDuration = 'show' === settings.showTabFn ? 0 : 400;
78
79		$requestedTitle.add( $requestedContent ).addClass( activeClass );
80		$requestedTitle.attr( {
81			tabindex: '0',
82			'aria-selected': 'true',
83			'aria-expanded': 'true'
84		});
85		$requestedContent[settings.showTabFn](animationDuration, () => elementorFrontend.elements.$window.trigger('resize'));
86	}
87
88	isActiveTab( tabIndex ) {
89		return this.elements.$tabTitles.filter( '[data-tab="' + tabIndex + '"]' ).hasClass( this.getSettings( 'classes.active' ) );
90	}
91
92	bindEvents() {
93		this.elements.$tabTitles.on( {
94			keydown: ( event ) => {
95				// Support for old markup that includes an `<a>` tag in the tab
96				if (jQuery(event.target).is('a') && `Enter` === event.key) {
97				  event.preventDefault();
98				} // We listen to keydowon event for these keys in order to prevent undesired page scrolling
99
100				if ( 'Enter' === event.key ) {
101					event.preventDefault();
102					this.changeActiveTab( event.currentTarget.getAttribute( 'data-tab' ) );
103				}
104			},
105			click: ( event ) => {
106				event.preventDefault();
107				this.changeActiveTab( event.currentTarget.getAttribute( 'data-tab' ) );
108			},
109		} );
110	}
111
112	onInit( ...args ) {
113		super.onInit( ...args );
114		
115		if ( this.$element.hasClass( 'elementor-default-active-yes' ) ) {
116			this.activateDefaultTab();
117		}
118	}
119
120	onEditSettingsChange( propertyName ) {
121		if ( 'activeItemIndex' === propertyName ) {
122			this.activateDefaultTab();
123		}
124	}
125
126	changeActiveTab( tabIndex ) {
127		const isActiveTab = this.isActiveTab( tabIndex ),
128			settings = this.getSettings();
129
130		if ( ( settings.toggleSelf || ! isActiveTab ) && settings.hidePrevious ) {
131			this.deactivateActiveTab();
132		}
133
134		if ( ! settings.hidePrevious && isActiveTab ) {
135			this.deactivateActiveTab( tabIndex );
136		}
137
138		if ( ! isActiveTab ) {
139			this.activateTab( tabIndex );
140		}
141	}
142}
143
144jQuery( window ).on( 'elementor/frontend/init', () => {
145	 const addHandler = ( $element ) => {
146		 elementorFrontend.elementsHandler.addHandler( WidgetHandlerClass, {
147			$element,
148		 } );
149	 };
150
151	elementorFrontend.hooks.addAction( 'frontend/element_ready/litho-accordion.default', addHandler );
152} );

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.