PageSourceSearch

https://valueofficefurniture.com.au/wp-content/plugins/woocommerce…/assets/js/jquery.tctabs.js?ver=7.6.1

js valueofficefurniture.com.au collected 2026-09-26 10:54:30 UTC 25,181 bytes, 744 lines download raw bytes

1/**
2 * jQuery Tabs plugin
3 * Creates a tabular interface
4 *
5 * @param {Object} $ The jQuery object
6 * @version: v1.1
7 * @author: ThemeComplete
8 *
9 * Copyright 2022 ThemeComplete
10 */
11( function( $ ) {
12	'use strict';
13
14	var localStorage = $.epoAPI.util.getStorage( 'localStorage' );
15	var confirm = window.confirm;
16
17	var Tabs = function( dom, options ) {
18		this.elements = $( dom );
19		this.last = [];
20		this.current = [];
21		this.enableEvents = true;
22		this.backup = [];
23
24		this.options = $.extend( {}, $.fn.tcTabs.defaults, options );
25
26		if ( this.elements.length > 0 ) {
27			this.init();
28			return this;
29		}
30
31		return false;
32	};
33
34	Tabs.prototype = {
35		constructor: Tabs,
36
37		set: function( options ) {
38			this.options = $.extend( {}, this.options, options );
39			this.init( true );
40		},
41
42		addHeaderEvents: function( t, index, tc, header, theaderswrap, theaders, scrollLeftButton, scrollRightButton, state ) {
43			var additional_events = '';
44			var ithis = this;
45
46			header.off( 'closetab.tmtabs' ).on( 'closetab.tmtabs', function() {
47				var $this = $( this );
48				var _tab = t.find( $this.data( 'tab' ) );
49
50				$this.removeClass( 'closed open' ).addClass( 'closed' );
51				$this
52					.find( '.tm-arrow' )
53					.removeClass( ithis.options.classdown + ' ' + ithis.options.classup )
54					.addClass( ithis.options.classdown );
55				if ( ithis.options.useclasstohide ) {
56					_tab.addClass( 'tm-hide' ).removeClass( 'tm-show' );
57				} else {
58					_tab.hide();
59				}
60				_tab.removeClass( 'tm-animated ' + ithis.options.animationclass );
61				$( window ).trigger( 'tc-closetab.tmtabs', {
62					header: $this,
63					tab: _tab
64				} );
65			} );
66
67			header.off( 'opentab.tmtabs' ).on( 'opentab.tmtabs', function() {
68				var $this = $( this );
69				var _tab = t.find( $this.data( 'tab' ) );
70
71				$this.removeClass( 'closed open' ).addClass( 'open' );
72				$this
73					.find( '.tm-arrow' )
74					.removeClass( ithis.options.classdown + ' ' + ithis.options.classup )
75					.addClass( ithis.options.classup );
76
77				if ( ithis.options.useclasstohide ) {
78					_tab.removeClass( 'tm-hide' ).addClass( 'tm-show' );
79				} else {
80					_tab.show();
81				}
82				_tab.removeClass( 'tm-animated ' + ithis.options.animationclass ).addClass( 'tm-animated ' + ithis.options.animationclass );
83				ithis.current[ index ] = $this.data( 'tab' );
84				$( window ).trigger( 'tc-opentab.tmtabs', {
85					header: $this,
86					tab: ithis.current[ index ],
87					table: _tab
88				} );
89				ithis.scrollIntoView( t, $this, state );
90			} );
91
92			if ( ithis.options.showonhover === true || typeof ithis.options.showonhover === 'function' ) {
93				additional_events = ' mouseover';
94			}
95
96			header.off( 'keydown.tmtabs' ).on( 'keydown.tmtabs', function( e ) {
97				var $this = $( this );
98				var prevnext;
99
100				if ( e.keyCode === 13 ) {
101					$this.trigger( 'click.tmtabs' );
102				}
103				if ( e.keyCode === 40 ) {
104					prevnext = $this.closest( '.tm-box' ).next().find( '.' + ithis.options.header );
105				}
106				if ( e.keyCode === 38 ) {
107					prevnext = $this.closest( '.tm-box' ).prev().find( '.' + ithis.options.header );
108				}
109				if ( prevnext && prevnext.length ) {
110					$this.trigger( 'blur' );
111					prevnext.trigger( ' focus' ).trigger( 'click' );
112					e.preventDefault();
113				}
114			} );
115
116			header.off( 'click.tmtabs' ).on( 'click.tmtabs' + additional_events, function( e ) {
117				var $this = $( this );
118				e.preventDefault();
119				if ( e.type === 'mouseover' && typeof ithis.options.showonhover === 'function' && ! ithis.options.showonhover.call() ) {
120					return;
121				}
122				if ( ithis.current[ index ] === $this.data( 'tab' ) ) {
123					$( window ).trigger( 'tc-isopentab.tmtabs', {
124						header: $this,
125						tab: ithis.current[ index ],
126						table: t.find( ithis.current[ index ] )
127					} );
128					return;
129				}
130				if ( ithis.last[ index ] ) {
131					$( ithis.last[ index ] ).trigger( 'closetab.tmtabs' );
132				}
133				$this.trigger( 'opentab.tmtabs' );
134				ithis.last[ index ] = $this;
135				if ( localStorage ) {
136					localStorage.setItem( 'tmadmintab-' + tc, $this.attr( ithis.options.dataopenattribute ) );
137				}
138				$( window ).trigger( 'tc-tmtabs-clicked', {
139					tc: tc,
140					options: ithis.options,
141					header: $this,
142					tab: ithis.current[ index ],
143					table: t.find( ithis.current[ index ] )
144				} );
145			} );
146
147			header.find( '.' + this.options.deleteheader ).remove();
148			if ( this.options.deletebutton ) {
149				header.append( this.options.deletebuttonhtml );
150				header
151					.find( '.' + this.options.deleteheader )
152					.off( 'click.tmtabs' )
153					.on( 'click.tmtabs', function( e ) {
154						var $t = $( this );
155						var $tmbox = $t.closest( '.tm-box' );
156						var $header = $tmbox.find( '.' + ithis.options.header );
157						var $tab = t.find( '.' + $header.attr( ithis.options.dataattribute ) );
158
159						e.stopPropagation();
160
161						if ( t.find( '.' + ithis.options.headers + ' ' + '.' + ithis.options.header ).length < 2 ) {
162							return;
163						}
164						if ( ithis.options.deleteconfirm ) {
165							if ( ! confirm( window.TMEPOGLOBALADMINJS.i18n_builder_delete ) ) {
166								return;
167							}
168						}
169
170						if ( typeof ithis.options.beforedeletetab === 'function' ) {
171							ithis.options.beforedeletetab.call( t, $t, $tab );
172						}
173
174						$tab.remove();
175						if ( $header.is( '.open' ) ) {
176							if ( $tmbox.next().find( '.' + ithis.options.header ).is( '.closed' ) ) {
177								$tmbox.next().find( '.' + ithis.options.header ).trigger( 'click.tmtabs' );
178							} else if ( $tmbox.prev().find( '.' + ithis.options.header ).is( '.closed' ) ) {
179								$tmbox.prev().find( '.' + ithis.options.header ).trigger( 'click.tmtabs' );
180							}
181						}
182						$tmbox.remove();
183
184						ithis.checkSize( theaderswrap, theaders, scrollLeftButton, scrollRightButton, state, true );
185						if ( typeof ithis.options.afterdeletetab === 'function' ) {
186							ithis.options.afterdeletetab.call( t );
187						}
188					} );
189			}
190
191			header.find( '.' + this.options.editheader ).remove();
192			if ( this.options.editbutton ) {
193				header.append( ithis.options.editbuttonhtml );
194				header
195					.find( '.' + ithis.options.editheader )
196					.off( 'click.tmtabs' )
197					.on( 'click.tmtabs', function( event ) {
198						var $t;
199						var $tab;
200						if ( ithis.enableEvents && typeof ithis.options.oneditbutton === 'function' ) {
201							event.stopPropagation();
202							$t = $( this );
203							$tab = t.find( '.' + $t.closest( '.tm-box' ).find( '.' + ithis.options.header ).attr( ithis.options.dataattribute ) );
204							ithis.options.oneditbutton.call( t, $t, $tab );
205						}
206					} );
207			}
208		},
209
210		initHeader: function( header, t, index, theaderswrap, theaders, scrollLeftButton, scrollRightButton, state ) {
211			var id;
212			var init_open = 0;
213			var tc = t.attr( 'class' );
214
215			header = $( header );
216			id = '.' + header.attr( this.options.dataattribute );
217			header.data( 'tab', id );
218			if ( this.options.useclasstohide ) {
219				t.find( id ).addClass( 'tm-hide' ).removeClass( 'tm-show' );
220			} else {
221				t.find( id ).hide();
222			}
223			t.find( id ).data( 'state', 'closed' );
224			if ( ! init_open && header.is( '.open' ) ) {
225				header.removeClass( 'closed open' ).addClass( 'open' ).data( 'state', 'open' );
226				header
227					.find( '.tm-arrow' )
228					.removeClass( this.options.classdown + ' ' + this.options.classup )
229					.addClass( this.options.classup );
230				if ( this.options.useclasstohide ) {
231					t.find( id ).removeClass( 'tm-hide' ).addClass( 'tm-show' );
232				} else {
233					t.find( id ).show();
234				}
235				t.find( id ).data( 'state', 'open' );
236				init_open = 1;
237				this.current[ index ] = id;
238				this.last[ index ] = header;
239			} else {
240				header.removeClass( 'closed open' ).addClass( 'closed' ).data( 'state', 'closed' );
241			}
242
243			this.addHeaderEvents( t, index, tc, header, theaderswrap, theaders, scrollLeftButton, scrollRightButton, state );
244		},
245
246		checkSize: function( theaderswrap, theaders, scrollLeftButton, scrollRightButton, state, setScrollWidth ) {
247			var panelWidth;
248			var openedHeader;
249			var props = [];
250			var hiddenParents = theaders.parents().addBack().not( ':visible' );
251
252			// When tabs element is hidden its width cannot be calcualted
253			// so we revert the visibility for this procedure only
254			hiddenParents.each( function() {
255				var $this = $( this );
256				var styleDisplay = this.style.display;
257				var cssDisplay = $this.css( 'display' );
258				var styleVisibility = this.style.visibility;
259				var cssVisibility = $this.css( 'visibility' );
260				var obj;
261				var did = false;
262				obj = {
263					styleDisplay: styleDisplay,
264					cssDisplay: cssDisplay,
265					styleVisibility: styleVisibility,
266					cssVisibility: cssVisibility,
267					display: null,
268					visibility: null,
269					element: $this
270				};
271				if ( styleDisplay === 'none' ) {
272					this.style.display = '';
273					obj.display = true;
274					if ( $this.css( 'display' ) === 'none' ) {
275						this.style.display = 'block';
276					}
277					did = true;
278				}
279				if ( styleVisibility === 'hidden' ) {
280					this.style.visibility = '';
281					obj.visibility = true;
282					if ( $this.css( 'visibility' ) === 'hidden' ) {
283						this.style.visibility = 'visible';
284					}
285					did = true;
286				}
287
288				if ( did ) {
289					props.push( obj );
290				}
291			} );
292
293			panelWidth = Math.round( theaders.outerWidth() );
294
295			if ( theaders.is( '.has-scroll-arrows' ) ) {
296				theaders.removeClass( '.has-scroll-arrows' );
297				panelWidth = Math.round( theaderswrap.outerWidth() );
298			}
299
300			if ( setScrollWidth ) {
301				openedHeader = theaders.find( '.' + this.options.header + '.open' );
302				if ( openedHeader.length ) {
303					openedHeader.removeClass( 'open' );
304				}
305				state.scrollWidth = theaders[ 0 ].scrollWidth;
306				if ( openedHeader.length ) {
307					openedHeader.addClass( 'open' );
308				}
309			}
310
311			if ( state.scrollWidth > panelWidth ) {
312				scrollRightButton.addClass( 'scroll-arrow-show' );
313				scrollLeftButton.addClass( 'scroll-arrow-show' );
314				theaders.addClass( 'has-scroll-arrows' );
315
316				if ( state.scrollWidth - panelWidth === theaders.scrollLeft() ) {
317					scrollRightButton.addClass( 'scroll-arrow-disabled scroll-arrow-right-disabled' );
318				} else {
319					scrollRightButton.removeClass( 'scroll-arrow-disabled scroll-arrow-right-disabled' );
320				}
321				if ( theaders.scrollLeft() === 0 ) {
322					scrollLeftButton.addClass( 'scroll-arrow-disabled scroll-arrow-left-disabled' );
323				} else {
324					scrollLeftButton.removeClass( 'scroll-arrow-disabled scroll-arrow-left-disabled' );
325				}
326			} else {
327				scrollRightButton.removeClass( 'scroll-arrow-show' );
328				scrollLeftButton.removeClass( 'scroll-arrow-show' );
329				theaders[ 0 ].scrollLeft = 0;
330				theaders.removeClass( 'has-scroll-arrows' );
331			}
332
333			props.forEach( function( o ) {
334				if ( o.display ) {
335					o.element[ 0 ].style.display = o.styleDisplay;
336				}
337				if ( o.visibility ) {
338					o.element[ 0 ].style.visibility = o.styleVisibility;
339				}
340			} );
341		},
342
343		scrollIntoView: function( t, header, state ) {
344			var left = state.scrollPos;
345			var theaders = t.find( '.' + this.options.headers );
346			var scrollWidth = theaders.width();
347
348			if ( theaders.is( '.has-scroll-arrows' ) && header && typeof ( header ) !== 'undefined' && header.position() && typeof ( header.position() ) !== 'undefined' ) {
349				if ( header.position().left < 0 ) {
350					state.scrollPos = Math.max( left + header.position().left + 1, 0 );
351					theaders.animate( { scrollLeft: ( state.scrollPos + 1 ) + 'px' }, this.options.scrollDuration );
352				} else if ( ( header.position().left + header.outerWidth() ) > scrollWidth ) {
353					state.scrollPos = Math.min( left + ( ( header.position().left + header.outerWidth() ) - scrollWidth ), theaders[ 0 ].scrollWidth - theaders.outerWidth() );
354					theaders.animate( { scrollLeft: ( state.scrollPos - 1 ) + 'px' }, this.options.scrollDuration );
355				}
356			}
357		},
358
359		initElement: function( t, index, state, uniqid ) {
360			var ithis = this;
361			var tc = t.attr( 'class' );
362			var sortableHeader;
363			var theaders;
364			var theaderswrap;
365			var scrollLeftButton;
366			var scrollRightButton;
367			var headers = t.find( '.' + this.options.headers + ' ' + '.' + this.options.header );
368			var ohp = 0;
369			var ohpid = '';
370			var _selected_tab;
371			var vars = {};
372			var initialIndex;
373			var pressHoldTimeout;
374
375			if ( headers.length === 0 ) {
376				return;
377			}
378
379			theaders = t.find( '.' + this.options.headers );
380			theaders.wrap( '<div class="' + this.options.headersWrap + '"></div>' );
381			theaderswrap = t.find( '.' + this.options.headersWrap );
382
383			if ( this.options.scroll ) {
384				theaderswrap.html( '<div class="tc-scroll-left-arrow"></div>' + theaderswrap.html() + '<div class="tc-scroll-right-arrow"></div>' );
385				headers = t.find( '.' + this.options.headers + ' ' + '.' + this.options.header );
386				theaders = t.find( '.' + this.options.headers );
387				scrollLeftButton = t.find( '.tc-scroll-left-arrow' );
388				scrollRightButton = t.find( '.tc-scroll-right-arrow' );
389
390				// Mousewheel support, if present.
391				if ( typeof $.fn.mousewheel === 'function' ) {
392					theaders.mousewheel( function( event, delta ) {
393						// Only do mousewheel scrolling if scrolling is necessary
394						if ( scrollRightButton.css( 'display' ) !== 'none' ) {
395							this.scrollLeft -= ( delta * 30 );
396							state.scrollPos = this.scrollLeft;
397							event.preventDefault();
398						}
399					} );
400				}
401
402				// Set initial scroll position
403				theaders.animate( { scrollLeft: state.scrollPos + 'px' }, 0 );
404
405				this.checkSize( theaderswrap, theaders, scrollLeftButton, scrollRightButton, state, true );
406				$( window ).off( 'resize.tmtabs' + uniqid ).on( 'resize.tmtabs' + uniqid, function() {
407					ithis.checkSize( theaderswrap, theaders, scrollLeftButton, scrollRightButton, state, true );
408				} );
409
410				t.off( 'refresh.tmtabs' + uniqid ).on( 'refresh.tmtabs' + uniqid, function() {
411					ithis.checkSize( theaderswrap, theaders, scrollLeftButton, scrollRightButton, state, true );
412				} );
413
414				// Document load
415				$( function() {
416					ithis.checkSize( theaderswrap, theaders, scrollLeftButton, scrollRightButton, state, true );
417				} );
418
419				scrollRightButton.off( 'mousedown.tmtabs mouseup.tmtabs mouseleave.tmtabs mouseover.tmtabs mouseout.tmtabs' )
420					.on( 'mousedown.tmtabs', function( e ) {
421						var scrollRightFunc = function() {
422							var left = theaders.scrollLeft();
423							state.scrollPos = Math.min( left + ithis.options.scrollDistance, state.scrollWidth - theaders.outerWidth() );
424							theaders.animate(
425								{
426									scrollLeft: state.scrollPos + 'px'
427								},
428								ithis.options.scrollDuration,
429								function() {
430									ithis.checkSize( theaderswrap, theaders, scrollLeftButton, scrollRightButton, state );
431								}
432							);
433						};
434						e.stopPropagation();
435						scrollRightFunc();
436
437						pressHoldTimeout = setInterval( function() {
438							scrollRightFunc();
439						}, ithis.options.scrollDuration );
440					} ).on( 'mouseup.tmtabs mouseleave.tmtabs', function() {
441						clearInterval( pressHoldTimeout );
442					} ).on( 'mouseover.tmtabs', function() {
443						$( this ).addClass( 'scroll-arrow-over scroll-arrow-right-over' );
444					} ).on( 'mouseout.tmtabs', function() {
445						$( this ).removeClass( 'scroll-arrow-over scroll-arrow-right-over' );
446					} );
447
448				scrollLeftButton.off( 'mousedown.tmtabs mouseup.tmtabs mouseleave.tmtabs mouseover.tmtabs mouseout.tmtabs' )
449					.on( 'mousedown.tmtabs', function( e ) {
450						var scrollLeftFunc = function() {
451							var left = theaders.scrollLeft();
452							state.scrollPos = Math.max( left - ithis.options.scrollDistance, 0 );
453							theaders.animate(
454								{
455									scrollLeft: state.scrollPos + 'px'
456								},
457								ithis.options.scrollDuration,
458								function() {
459									ithis.checkSize( theaderswrap, theaders, scrollLeftButton, scrollRightButton, state );
460								}
461							);
462						};
463						e.stopPropagation();
464						scrollLeftFunc();
465
466						pressHoldTimeout = setInterval( function() {
467							scrollLeftFunc();
468						}, ithis.options.scrollDuration );
469					} ).on( 'mouseup.tmtabs mouseleave.tmtabs', function() {
470						clearInterval( pressHoldTimeout );
471					} ).on( 'mouseover.tmtabs', function() {
472						$( this ).addClass( 'scroll-arrow-over scroll-arrow-left-over' );
473					} ).on( 'mouseout.tmtabs', function() {
474						$( this ).removeClass( 'scroll-arrow-over scroll-arrow-left-over' );
475					} );
476			}
477
478			window.location.href.replace( /[?&]+([^=&]+)=([^&]*)/gi, function( m, key, value ) {
479				vars[ key ] = value;
480			} );
481
482			this.last[ index ] = false;
483			this.current[ index ] = '';
484
485			t.data( 'tm-has-tmtabs', 1 );
486
487			headers.each( function( i, header ) {
488				ithis.initHeader( header, t, index, theaderswrap, theaders, scrollLeftButton, scrollRightButton, state );
489			} );
490
491			if ( this.options.sortabletabs ) {
492				sortableHeader = '.' + this.options.headers;
493				if ( t.find( sortableHeader + ' .' + this.options.headers + '-inner' ).length ) {
494					sortableHeader = '.' + this.options.headers + '-inner';
495				}
496				t.find( sortableHeader + ':not(.section_elements ' + sortableHeader + ',.tm-settings-wrap ' + sortableHeader + ',.builder-element-wrap ' + sortableHeader + ')' ).sortablejs( {
497					draggable: '.tm-box:not(.tm-add-box)',
498					handle: '.tm-box:not(.tm-add-box)',
499					onStart: function( evt ) {
500						var ui = $( evt.item );
501						var $tab;
502						$tab = t.find( '.' + ui.closest( '.tm-box' ).find( '.' + ithis.options.header ).attr( ithis.options.dataattribute ) );
503						ohp = ui.index();
504						ohpid = ui.find( '.' + ithis.options.header ).attr( ithis.options.dataopenattribute );
505
506						initialIndex = $.tmEPOAdmin.find_index( true, $tab.find( '.bitem' ).first() );
507
508						if ( typeof ithis.options.beforemovetab === 'function' ) {
509							ithis.options.beforemovetab.call( this, ohp, $tab, initialIndex );
510						}
511						ithis.enableEvents = false;
512					},
513					onEnd: function( evt ) {
514						var ui = $( evt.item );
515						var original_item;
516						var new_index;
517						var replaced_item;
518						var $tab;
519						var originalItemCopy;
520
521						$tab = t.find( '.' + ui.closest( '.tm-box' ).find( '.' + ithis.options.header ).attr( ithis.options.dataattribute ) );
522						original_item = t.find( '.' + ithis.options.slide + '.' + ohpid );
523						new_index = t
524							.find( '.' + ithis.options.headers + ' ' + '.' + ithis.options.header + '[' + ithis.options.dataopenattribute + '=\'' + ohpid + '\']' )
525							.parent()
526							.index();
527						if ( new_index !== ohp ) {
528							replaced_item = t.find( '.' + ithis.options.slide ).eq( new_index );
529							originalItemCopy = original_item.tcClone();
530							originalItemCopy.find( '.bitem' ).remove();
531							if ( new_index > ohp ) {
532								replaced_item.after( originalItemCopy );
533							} else if ( new_index < ohp ) {
534								replaced_item.before( originalItemCopy );
535							}
536							original_item.find( '.bitem' ).toArray().forEach( function( el ) {
537								el = $( el );
538								if ( typeof ithis.options.beforemovebitem === 'function' ) {
539									ithis.options.beforemovebitem.call( this, new_index, ohp, $tab, initialIndex, el );
540								}
541								originalItemCopy.append( el );
542								if ( typeof ithis.options.aftermovebitem === 'function' ) {
543									ithis.options.aftermovebitem.call( this, new_index, ohp, $tab, initialIndex, el );
544								}
545							} );
546							original_item.remove();
547							if ( typeof ithis.options.aftermovetab === 'function' ) {
548								ithis.options.aftermovetab.call( this, new_index, ohp, $tab, initialIndex );
549							}
550						}
551						ithis.enableEvents = true;
552					},
553					filter: '.tm-add-box',
554					ghostClass: 'sortable-ghost',
555					dragClass: 'sortable-drag'
556
557				} );
558			}
559
560			if ( this.options.addbutton ) {
561				theaderswrap.append( this.options.addbuttonhtml );
562				t.addClass( 'has-add-button' ).find( '.' + this.options.addheader ).off( 'click.tmtabs' ).on( 'click.tmtabs', function( e ) {
563					var allHeaders = t.find( '.' + ithis.options.headers + ' ' + '.' + ithis.options.header );
564					var last_header = allHeaders.last();
565					var id = last_header.attr( ithis.options.dataattribute );
566					var last_tab = t.find( '.' + id );
567					var new_header = last_header.tcClone().off( 'closetab.tmtabs opentab.tmtabs click.tmtabs' );
568					var new_tab = last_tab.tcClone().empty();
569					var newid = ithis.options.slide + allHeaders.length;
570
571					e.preventDefault();
572
573					new_header
574						.html( '<span class="tab-text">' + ( t.find( '.' + ithis.options.headers + ' ' + '.' + ithis.options.header ).length + 1 ) + '</span>' )
575						.removeClass( 'closed open' )
576						.addClass( 'closed' )
577						.data( 'tab', '.' + newid )
578						.data( 'state', 'closed' )
579						.attr( ithis.options.dataattribute, newid );
580					new_tab.removeClass( id ).addClass( newid );
581					if ( ithis.options.useclasstohide ) {
582						new_tab.addClass( 'tm-hide' ).removeClass( '.tm-show' );
583					} else {
584						new_tab.hide();
585					}
586					new_tab.removeClass( 'tm-animated ' + ithis.options.animationclass );
587
588					last_header.closest( '.tm-box' ).after( new_header );
589
590					new_header.wrap( '<div class="tm-box"></div>' );
591
592					ithis.addHeaderEvents( t, index, tc, new_header, theaderswrap, theaders, scrollLeftButton, scrollRightButton, state );
593					last_tab.after( new_tab );
594					if ( ithis.options.scroll ) {
595						theaders.animate(
596							{
597								scrollLeft: new_header.width() + 'px'
598							},
599							ithis.options.scrollDuration,
600							function() {
601								ithis.checkSize( theaderswrap, theaders, scrollLeftButton, scrollRightButton, state, true );
602							}
603						);
604					}
605					if ( typeof ithis.options.afteraddtab === 'function' ) {
606						ithis.options.afteraddtab.call( this, new_header, new_tab );
607					}
608				} );
609			} else {
610				theaderswrap.find( '.' + this.options.addheader ).remove();
611			}
612
613			if ( this.options.selectedtab === 'auto' ) {
614				if ( localStorage ) {
615					_selected_tab = localStorage.getItem( 'tmadmintab-' + tc );
616				}
617				if ( vars.selected_tab !== undefined ) {
618					_selected_tab = vars.selected_tab;
619				}
620				if ( vars.menu !== undefined ) {
621					_selected_tab = vars.menu;
622				}
623				if ( _selected_tab === undefined || _selected_tab === null ) {
624					_selected_tab = t.find( '.' + this.options.header ).eq( 0 ).attr( this.options.dataopenattribute );
625				}
626				if ( ! t.find( '.' + this.options.header + '[' + this.options.dataopenattribute + '="' + _selected_tab + '"]' ).is( ':visible' ) ) {
627					t.find( '.' + this.options.header ).eq( 0 ).trigger( 'click.tmtabs' );
628				} else {
629					t.find( '.' + this.options.header + '[' + this.options.dataopenattribute + '="' + _selected_tab + '"]' ).trigger( 'click.tmtabs' );
630				}
631			} else if ( this.options.selectedtab !== false ) {
632				_selected_tab = parseInt( this.options.selectedtab, 10 );
633				t.find( '.' + this.options.header + ':eq(' + _selected_tab + ')' ).trigger( 'click.tmtabs' );
634			}
635		},
636
637		init: function( nobackup ) {
638			var ithis = this;
639			this.elements.each( function( index ) {
640				var t = $( this );
641				var display;
642				var state = {};
643				var backup = t.html();
644				var tmSettingsWrap = $( ithis.options.animateDiv );
645
646				if ( ! nobackup && ithis.backup[ index ] ) {
647					t.html( ithis.backup[ index ] );
648				} else {
649					ithis.backup[ index ] = backup;
650				}
651				state.scrollPos = 0;
652				state.scrollWidth = 0;
653				display = t.css( 'display' );
654				tmSettingsWrap.show();
655				t.show();
656				ithis.initElement( t, index, state, $.epoAPI.math.uniqueid( '' ) );
657				t.css( 'display', display );
658				tmSettingsWrap.addClass( 'appear' );
659			} );
660		}
661	};
662
663	$.fn.tcTabs = function( option ) {
664		var methodReturn;
665		var targets = $( this );
666		var data = targets.data( 'tctabs' );
667		var options;
668		var ret;
669		var args = $.makeArray( arguments );
670		args.splice( 0, 1 );
671
672		if ( typeof option === 'object' ) {
673			options = option;
674		} else {
675			options = {};
676		}
677
678		if ( ! data ) {
679			data = new Tabs( this, options );
680			targets.data( 'tctabs', data );
681		}
682
683		if ( typeof option === 'string' ) {
684			methodReturn = data[ option ].apply( data, args );
685		}
686
687		if ( methodReturn === undefined ) {
688			ret = targets;
689		} else {
690			ret = methodReturn;
691		}
692
693		return ret;
694	};
695
696	$.fn.tcTabs.defaults = {
697		headers: 'tm-tab-headers',
698		headersWrap: 'tc-tab-headers-wrap',
699		header: 'tab-header',
700		slide: 'tc-tab-slide',
701
702		classdown: 'tcfa-angle-down',
703		classup: 'tcfa-angle-up',
704		animationclass: 'appear',
705
706		dataattribute: 'data-id',
707		dataopenattribute: 'data-id',
708		selectedtab: 'auto',
709		showonhover: false,
710		useclasstohide: true,
711		sortabletabs: true,
712
713		addbutton: false,
714		addheader: 'tm-add-tab',
715		addbuttonhtml: '<div class="tm-add-tab"><span class="tmicon tcfa tcfa-plus"></span></div>',
716		afteraddtab: null,
717
718		beforemovetab: null,
719		aftermovetab: null,
720		beforemovebitem: null,
721		aftermovebitem: null,
722
723		deletebutton: false,
724		deletebuttonhtml: '<div class="tm-del-tab"><span class="tcfa tcfa-times"></span></div>',
725		deleteheader: 'tm-del-tab',
726		deleteconfirm: false,
727		beforedeletetab: null,
728		afterdeletetab: null,
729
730		editbutton: false,
731		editbuttonhtml: '<span class="tm-edit-tab"><span class="tcfa tcfa-edit"></span></span>',
732		editheader: 'tm-edit-tab',
733		oneditbutton: null,
734
735		scroll: true,
736		scrollDistance: 300,
737		scrollDuration: 300,
738		animateDiv: ''
739	};
740
741	$.fn.tcTabs.Constructor = Tabs;
742
743	$.fn.tmtabs = $.fn.tcTabs;
744}( window.jQuery ) );

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.