PageSourceSearch

https://shibuyahotel.jp/en/js/ui.tabs.js

js shibuyahotel.jp collected 2026-10-07 12:51:37 UTC 17,333 bytes, 571 lines download raw bytes

1var _____WB$wombat$assign$function_____=function(name){return (globalThis._wb_wombat && globalThis._wb_wombat.local_init && globalThis._wb_wombat.local_init(name))||globalThis[name];};if(!globalThis.__WB_pmw){globalThis.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}{
2let window = _____WB$wombat$assign$function_____("window");
3let self = _____WB$wombat$assign$function_____("self");
4let document = _____WB$wombat$assign$function_____("document");
5let location = _____WB$wombat$assign$function_____("location");
6let top = _____WB$wombat$assign$function_____("top");
7let parent = _____WB$wombat$assign$function_____("parent");
8let frames = _____WB$wombat$assign$function_____("frames");
9let opener = _____WB$wombat$assign$function_____("opener");
10/*
11 * jQuery UI Tabs @VERSION
12 *
13 * Copyright (c) 2007, 2008 Klaus Hartl (stilbuero.de)
14 * Dual licensed under the MIT (MIT-LICENSE.txt)
15 * and GPL (GPL-LICENSE.txt) licenses.
16 *
17 * http://docs.jquery.com/UI/Tabs
18 *
19 * Depends:
20 *	ui.core.js
21 */
22(function($) {
23
24$.widget("ui.tabs", {
25	_init: function() {
26		// create tabs
27		this._tabify(true);
28	},
29	_setData: function(key, value) {
30		if ((/^selected/).test(key))
31			this.select(value);
32		else {
33			this.options[key] = value;
34			this._tabify();
35		}
36	},
37	length: function() {
38		return this.$tabs.length;
39	},
40	_tabId: function(a) {
41		return a.title && a.title.replace(/\s/g, '_').replace(/[^A-Za-z0-9\-_:\.]/g, '')
42			|| this.options.idPrefix + $.data(a);
43	},
44	ui: function(tab, panel) {
45		return {
46			options: this.options,
47			tab: tab,
48			panel: panel,
49			index: this.$tabs.index(tab)
50		};
51	},
52	_sanitizeSelector: function(hash) {
53		return hash.replace(/:/g, '\\:'); // we need this because an id may contain a ":"
54	},
55	_cookie: function() {
56		var cookie = this.cookie || (this.cookie = 'ui-tabs-' + $.data(this.element[0]));
57		return $.cookie.apply(null, [cookie].concat($.makeArray(arguments)));
58	},
59	_tabify: function(init) {
60		
61		this.$lis = $('li:has(a[href])', this.element);
62		this.$tabs = this.$lis.map(function() { return $('a', this)[0]; });
63		this.$panels = $([]);
64		
65		var self = this, o = this.options;
66		
67		this.$tabs.each(function(i, a) {
68			// inline tab
69			if (a.hash && a.hash.replace('#', '')) // Safari 2 reports '#' for an empty hash
70				self.$panels = self.$panels.add(self._sanitizeSelector(a.hash));
71			// remote tab
72			else if ($(a).attr('href') != '#') { // prevent loading the page itself if href is just "#"
73				$.data(a, 'href.tabs', a.href);
73 // required for restore on destroy
74				$.data(a, 'load.tabs', a.href); // mutable
75				var id = self._tabId(a);
76				a.href = '#' + id;
77				var $panel = $('#' + id);
78				if (!$panel.length) {
79					$panel = $(o.panelTemplate).attr('id', id).addClass(o.panelClass)
80						.insertAfter(self.$panels[i - 1] || self.element);
81					$panel.data('destroy.tabs', true);
82				}
83				self.$panels = self.$panels.add($panel);
84			}
85			// invalid tab href
86			else
87				o.disabled.push(i + 1);
88		});
89		
90		// initialization from scratch
91		if (init) {
92			
93			// attach necessary classes for styling if not present
94			this.element.addClass(o.navClass);
95			this.$panels.addClass(o.panelClass);
96			
97			// Selected tab
98			// use "selected" option or try to retrieve:
99			// 1. from fragment identifier in url
100			// 2. from cookie
101			// 3. from selected class attribute on <li>
102			if (o.selected === undefined) {
103				if (location.hash) {
104					this.$tabs.each(function(i, a) {
105						if (a.hash == location.hash) {
106							o.selected = i;
107							return false; // break
108						}
109					});
110				}
111				else if (o.cookie) {
112					var index = parseInt(self._cookie(), 10);
113					if (index && self.$tabs[index]) o.selected = index;
114				}
115				else if (self.$lis.filter('.' + o.selectedClass).length)
116					o.selected = self.$lis.index( self.$lis.filter('.' + o.selectedClass)[0] );
117			}
118			o.selected = o.selected === null || o.selected !== undefined ? o.selected : 0; // first tab selected by default
119			
120			// Take disabling tabs via class attribute from HTML
121			// into account and update option properly.
122			// A selected tab cannot become disabled.
123			o.disabled = $.unique(o.disabled.concat(
124				$.map(this.$lis.filter('.' + o.disabledClass),
125					function(n, i) { return self.$lis.index(n); } )
126			)).sort();
127			if ($.inArray(o.selected, o.disabled) != -1)
128				o.disabled.splice($.inArray(o.selected, o.disabled), 1);
129			
130			// highlight selected tab
131			this.$panels.addClass(o.hideClass);
132			this.$lis.removeClass(o.selectedClass);
133			if (o.selected !== null) {
134				this.$panels.eq(o.selected).removeClass(o.hideClass);
135				var classes = [o.selectedClass];
136				if (o.deselectable) classes.push(o.deselectableClass);
137				this.$lis.eq(o.selected).addClass(classes.join(' '));
138				
139				// seems to be expected behavior that the show callback is fired
140				var onShow = function() {
141					self._trigger('show', null,
142						self.ui(self.$tabs[o.selected], self.$panels[o.selected]));
143				};
144				
145				// load if remote tab
146				if ($.data(this.$tabs[o.selected], 'load.tabs'))
147					this.load(o.selected, onShow);
148				// just trigger show event
149				else onShow();
150			}
151			
152			// clean up to avoid memory leaks in certain versions of IE 6
153			$(window).bind('unload', function() {
154				self.$tabs.unbind('.tabs');
155				self.$lis = self.$tabs = self.$panels = null;
156			});
157			
158		}
159		// update selected after add/remove
160		else
161			o.selected = this.$lis.index( this.$lis.filter('.' + o.selectedClass)[0] );
162		
163		// set or update cookie after init and add/remove respectively
164		if (o.cookie) this._cookie(o.selected, o.cookie);
165		
166		// disable tabs
167		for (var i = 0, li; li = this.$lis[i]; i++)
168			$(li)[$.inArray(i, o.disabled) != -1 && !$(li).hasClass(o.selectedClass) ? 'addClass' : 'removeClass'](o.disabledClass);
169		
170		// reset cache if switching from cached to not cached
171		if (o.cache === false) this.$tabs.removeData('cache.tabs');
172		
173		// set up animations
174		var hideFx, showFx;
175		if (o.fx) {
176			if (o.fx.constructor == Array) {
177				hideFx = o.fx[0];
178				showFx = o.fx[1];
179			}
180			else hideFx = showFx = o.fx;
181		}
182		
183		// Reset certain styles left over from animation
184		// and prevent IE's ClearType bug...
185		function resetStyle($el, fx) {
186			$el.css({ display: '' });
187			if ($.browser.msie && fx.opacity) $el[0].style.removeAttribute('filter');
188		}
189
190		// Show a tab...
191		var showTab = showFx ?
192			function(clicked, $show) {
193				$show.animate(showFx, showFx.duration || 'normal', function() {
194					$show.removeClass(o.hideClass);
195					resetStyle($show, showFx);
196					self._trigger('show', null, self.ui(clicked, $show[0]));
197				});
198			} :
199			function(clicked, $show) {
200				$show.removeClass(o.hideClass);
201				self._trigger('show', null, self.ui(clicked, $show[0]));
202			};
203		
204		// Hide a tab, $show is optional...
205		var hideTab = hideFx ? 
206			function(clicked, $hide, $show) {
207				$hide.animate(hideFx, hideFx.duration || 'normal', function() {
208					$hide.addClass(o.hideClass);
209					resetStyle($hide, hideFx);
210					if ($show) showTab(clicked, $show, $hide);
211				});
212			} :
213			function(clicked, $hide, $show) {
214				$hide.addClass(o.hideClass);
215				if ($show) showTab(clicked, $show);
216			};
217		
218		// Switch a tab...
219		function switchTab(clicked, $li, $hide, $show) {
220			var classes = [o.selectedClass];
221			if (o.deselectable) classes.push(o.deselectableClass);
222			$li.addClass(classes.join(' ')).siblings().removeClass(classes.join(' '));
223			hideTab(clicked, $hide, $show);
224		}
225		
226		// attach tab event handler, unbind to avoid duplicates from former tabifying...
227		this.$tabs.unbind('.tabs').bind(o.event + '.tabs', function() {
228			
229			//var trueClick = e.clientX; // add to history only if true click occured, not a triggered click
230			var $li = $(this).parents('li:eq(0)'),
231				$hide = self.$panels.filter(':visible'),
232				$show = $(self._sanitizeSelector(this.hash));
233			
234			// If tab is already selected and not deselectable or tab disabled or 
235			// or is already loading or click callback returns false stop here.
236			// Check if click handler returns false last so that it is not executed
237			// for a disabled or loading tab!
238			if (($li.hasClass(o.selectedClass) && !o.deselectable)
239				|| $li.hasClass(o.disabledClass)
240				|| $(this).hasClass(o.loadingClass)
241				|| self._trigger('select', null, self.ui(this, $show[0])) === false
242				) {
243				this.blur();
244				return false;
245			}
246			
247			o.selected = self.$tabs.index(this);
248			
249			// if tab may be closed
250			if (o.deselectable) {
251				if ($li.hasClass(o.selectedClass)) {
252					self.options.selected = null;
253					$li.removeClass([o.selectedClass, o.deselectableClass].join(' '));
254					self.$panels.stop();
255					hideTab(this, $hide);
256					this.blur();
257					return false;
258				} else if (!$hide.length) {
259					self.$panels.stop();
260					var a = this;
261					self.load(self.$tabs.index(this), function() {
262						$li.addClass([o.selectedClass, o.deselectableClass].join(' '));
263						showTab(a, $show);
264					});
265					this.blur();
266					return false;
267				}
268			}
269			
270			if (o.cookie) self._cookie(o.selected, o.cookie);
271			
272			// stop possibly running animations
273			self.$panels.stop();
274			
275			// show new tab
276			if ($show.length) {
277				var a = this;
278				self.load(self.$tabs.index(this), $hide.length ? 
279					function() {
280						switchTab(a, $li, $hide, $show);
281					} :
282					function() {
283						$li.addClass(o.selectedClass);
284						showTab(a, $show);
285					}
286				);
287			} else
288				throw 'jQuery UI Tabs: Mismatching fragment identifier.';
289				
290			// Prevent IE from keeping other link focussed when using the back button
291			// and remove dotted border from clicked link. This is controlled via CSS
292			// in modern browsers; blur() removes focus from address bar in Firefox
293			// which can become a usability and annoying problem with tabs('rotate').
294			if ($.browser.msie) this.blur();
295			
296			return false;
297			
298		});
299		
300		// disable click if event is configured to something else
301		if (o.event != 'click') this.$tabs.bind('click.tabs', function(){return false;});
302		
303	},
304	add: function(url, label, index) {
305		if (index == undefined)
306			index = this.$tabs.length; // append by default
307		
308		var o = this.options;
309		var $li = $(o.tabTemplate.replace(/#\{href\}/g, url).replace(/#\{label\}/g, label));
310		$li.data('destroy.tabs', true);
311		
312		var id = url.indexOf('#') == 0 ? url.replace('#', '') : this._tabId( $('a:first-child', $li)[0] );
313		
314		// try to find an existing element before creating a new one
315		var $panel = $('#' + id);
316		if (!$panel.length) {
317			$panel = $(o.panelTemplate).attr('id', id)
318				.addClass(o.hideClass)
319				.data('destroy.tabs', true);
320		}
321		$panel.addClass(o.panelClass);
322		if (index >= this.$lis.length) {
323			$li.appendTo(this.element);
324			$panel.appendTo(this.element[0].parentNode);
325		} else {
326			$li.insertBefore(this.$lis[index]);
327			$panel.insertBefore(this.$panels[index]);
328		}
329		
330		o.disabled = $.map(o.disabled,
331			function(n, i) { return n >= index ? ++n : n });
332		
333		this._tabify();
334		
335		if (this.$tabs.length == 1) {
336			$li.addClass(o.selectedClass);
337			$panel.removeClass(o.hideClass);
338			var href = $.data(this.$tabs[0], 'load.tabs');
339			if (href)
340				this.load(index, href);
341		}
342		
343		// callback
344		this._trigger('add', null, this.ui(this.$tabs[index], this.$panels[index]));
345	},
346	remove: function(index) {
347		var o = this.options, $li = this.$lis.eq(index).remove(),
348			$panel = this.$panels.eq(index).remove();
349		
350		// If selected tab was removed focus tab to the right or
351		// in case the last tab was removed the tab to the left.
352		if ($li.hasClass(o.selectedClass) && this.$tabs.length > 1)
353			this.select(index + (index + 1 < this.$tabs.length ? 1 : -1));
354		
355		o.disabled = $.map($.grep(o.disabled, function(n, i) { return n != index; }),
356			function(n, i) { return n >= index ? --n : n });
357		
358		this._tabify();
359		
360		// callback
361		this._trigger('remove', null, this.ui($li.find('a')[0], $panel[0]));
362	},
363	enable: function(index) {
364		var o = this.options;
365		if ($.inArray(index, o.disabled) == -1)
366			return;
367		
368		var $li = this.$lis.eq(index).removeClass(o.disabledClass);
369		if ($.browser.safari) { // fix disappearing tab (that used opacity indicating disabling) after enabling in Safari 2...
370			$li.css('display', 'inline-block');
371			setTimeout(function() {
372				$li.css('display', 'block');
373			}, 0);
374		}
375		
376		o.disabled = $.grep(o.disabled, function(n, i) { return n != index; });
377		
378		// callback
379		this._trigger('enable', null, this.ui(this.$tabs[index], this.$panels[index]));
380	},
381	disable: function(index) {
382		var self = this, o = this.options;
383		if (index != o.selected) { // cannot disable already selected tab
384			this.$lis.eq(index).addClass(o.disabledClass);
385			
386			o.disabled.push(index);
387			o.disabled.sort();
388			
389			// callback
390			this._trigger('disable', null, this.ui(this.$tabs[index], this.$panels[index]));
391		}
392	},
393	select: function(index) {
394		// TODO make null as argument work
395		if (typeof index == 'string')
396			index = this.$tabs.index( this.$tabs.filter('[href$=' + index + ']')[0] );
397		this.$tabs.eq(index).trigger(this.options.event + '.tabs');
398	},
399	load: function(index, callback) { // callback is for internal usage only
400		
401		var self = this, o = this.options, $a = this.$tabs.eq(index), a = $a[0],
402				bypassCache = callback == undefined || callback === false, url = $a.data('load.tabs');
403		
404		callback = callback || function() {};
405		
406		// no remote or from cache - just finish with callback
407		if (!url || !bypassCache && $.data(a, 'cache.tabs')) {
408			callback();
409			return;
410		}
411		
412		// load remote from here on
413		
414		var inner = function(parent) {
415			var $parent = $(parent), $inner = $parent.find('*:last');
416			return $inner.length && $inner.is(':not(img)') && $inner || $parent;
417		};
418		var cleanup = function() {
419			self.$tabs.filter('.' + o.loadingClass).removeClass(o.loadingClass)
420					.each(function() {
421						if (o.spinner)
422							inner(this).parent().html(inner(this).data('label.tabs'));
423					});
424			self.xhr = null;
425		};
426		
427		if (o.spinner) {
428			var label = inner(a).html();
429			inner(a).wrapInner('<em></em>')
430				.find('em').data('label.tabs', label).html(o.spinner);
431		}
432		
433		var ajaxOptions = $.extend({}, o.ajaxOptions, {
434			url: url,
435			success: function(r, s) {
436				$(self._sanitizeSelector(a.hash)).html(r);
437				cleanup();
438				
439				if (o.cache)
440					$.data(a, 'cache.tabs', true); // if loaded once do not load them again
441				
442				// callbacks
443				self._trigger('load', null, self.ui(self.$tabs[index], self.$panels[index]));
444				try {
445					o.ajaxOptions.success(r, s);
446				}
447				catch (e) {}
448				
449				// This callback is required because the switch has to take
450				// place after loading has completed. Call last in order to 
451				// fire load before show callback...
452				callback();
453			}
454		});
455		if (this.xhr) {
456			// terminate pending requests from other tabs and restore tab label
457			this.xhr.abort();
458			cleanup();
459		}
460		$a.addClass(o.loadingClass);
461		self.xhr = $.ajax(ajaxOptions);
462	},
463	url: function(index, url) {
464		this.$tabs.eq(index).removeData('cache.tabs').data('load.tabs', url);
465	},
466	destroy: function() {
467		var o = this.options;
468		this.element.unbind('.tabs')
469			.removeClass(o.navClass).removeData('tabs');
470		this.$tabs.each(function() {
471			var href = $.data(this, 'href.tabs');
472			if (href)
473				this.href = href;
474			var $this = $(this).unbind('.tabs');
475			$.each(['href', 'load', 'cache'], function(i, prefix) {
476				$this.removeData(prefix + '.tabs');
477			});
478		});
479		this.$lis.add(this.$panels).each(function() {
480			if ($.data(this, 'destroy.tabs'))
481				$(this).remove();
482			else
483				$(this).removeClass([o.selectedClass, o.deselectableClass,
484					o.disabledClass, o.panelClass, o.hideClass].join(' '));
485		});
486		if (o.cookie)
487			this._cookie(null, o.cookie);
488	}
489});
490
491$.extend($.ui.tabs, {
492	version: '@VERSION',
493	getter: 'length',
494	defaults: {
495		// basic setup
496		deselectable: false,
497		event: 'click',
498		disabled: [],
499		cookie: null, // e.g. { expires: 7, path: '/', domain: 'jquery.com', secure: true }
500		// Ajax
501		spinner: 'Loading&#8230;',
502		cache: false,
503		idPrefix: 'ui-tabs-',
504		ajaxOptions: null,
505		// animations
506		fx: null, // e.g. { height: 'toggle', opacity: 'toggle', duration: 200 }
507		// templates
508		tabTemplate: '<li><a href="#{href}"><span>#{label}</span></a></li>',
509		panelTemplate: '<div></div>',
510		// CSS class names
511		navClass: 'ui-tabs-nav',
512		selectedClass: 'ui-tabs-selected',
513		deselectableClass: 'ui-tabs-deselectable',
514		disabledClass: 'ui-tabs-disabled',
515		panelClass: 'ui-tabs-panel',
516		hideClass: 'ui-tabs-hide',
517		loadingClass: 'ui-tabs-loading'
518	}
519});
520
521/*
522 * Tabs Extensions
523 */
524
525/*
526 * Rotate
527 */
528$.extend($.ui.tabs.prototype, {
529	rotation: null,
530	rotate: function(ms, continuing) {
531		
532		continuing = continuing || false;
533		
534		var self = this, t = this.options.selected;
535		
536		function start() {
537			self.rotation = setInterval(function() {
538				t = ++t < self.$tabs.length ? t : 0;
539				self.select(t);
540			}, ms);
541		}
542		
543		function stop(e) {
544			if (!e || e.clientX) { // only in case of a true click
545				clearInterval(self.rotation);
546			}
547		}
548		
549		// start interval
550		if (ms) {
551			start();
552			if (!continuing)
553				this.$tabs.bind(this.options.event + '.tabs', stop);
554			else
555				this.$tabs.bind(this.options.event + '.tabs', function() {
556					stop();
557					t = self.options.selected;
558					start();
559				});
560		}
561		// stop interval
562		else {
563			stop();
564			this.$tabs.unbind(this.options.event + '.tabs', stop);
565		}
566	}
567});
568
569})(jQuery);
570
571}

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.