PageSourceSearch

https://www.waldeisenbahn.de/wp-content/plugins/event-organiser/js/qtip2.js?ver=3.12.5

js waldeisenbahn.de collected 2026-09-24 23:51:19 UTC 63,332 bytes, 2,132 lines download raw bytes

vendor: 58,271 bytes, lines 1-1967
1/*
2 * qTip2 - Pretty powerful tooltips - v3.0.3
3 * http://qtip2.com
4 *
5 * Copyright (c) 2017
6 * Released under the MIT licenses
7 * http://jquery.org/license
8 *
9 * Date: Mon Aug 28 2017 05:13 EDT-0400
10 * Plugins: viewport
11 * Styles: core
12 */
13/*global window: false, jQuery: false, console: false, define: false */
14
15/* Cache window, document, undefined */
16(function( window, document, undefined ) {
17
18// Uses AMD or browser globals to create a jQuery plugin.
19(function( factory ) {
20	"use strict";
21	if(typeof define === 'function' && define.amd) {
22		define(['jquery'], factory);
23	}
24	else if(jQuery && !jQuery.fn.qtip) {
25		factory(jQuery);
26	}
27}
28(function($) {
29	"use strict"; // Enable ECMAScript "strict" operation for this function. See more: http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/
30;// Munge the primitives - Paul Irish tip
31var TRUE = true,
32FALSE = false,
33NULL = null,
34
35// Common variables
36X = 'x', Y = 'y',
37WIDTH = 'width',
38HEIGHT = 'height',
39
40// Positioning sides
41TOP = 'top',
42LEFT = 'left',
43BOTTOM = 'bottom',
44RIGHT = 'right',
45CENTER = 'center',
46
47// Position adjustment types
48FLIP = 'flip',
49FLIPINVERT = 'flipinvert',
50SHIFT = 'shift',
51
52// Shortcut vars
53QTIP, PROTOTYPE, CORNER, CHECKS,
54PLUGINS = {},
55NAMESPACE = 'qtip',
56ATTR_HAS = 'data-hasqtip',
57ATTR_ID = 'data-qtip-id',
58WIDGET = ['ui-widget', 'ui-tooltip'],
59SELECTOR = '.'+NAMESPACE,
60INACTIVE_EVENTS = 'click dblclick mousedown mouseup mousemove mouseleave mouseenter'.split(' '),
61
62CLASS_FIXED = NAMESPACE+'-fixed',
63CLASS_DEFAULT = NAMESPACE + '-default',
64CLASS_FOCUS = NAMESPACE + '-focus',
65CLASS_HOVER = NAMESPACE + '-hover',
66CLASS_DISABLED = NAMESPACE+'-disabled',
67
68replaceSuffix = '_replacedByqTip',
69oldtitle = 'oldtitle',
70trackingBound,
71
72// Browser detection
73BROWSER = {
74	/*
75	 * IE version detection
76	 *
77	 * Adapted from: http://ajaxian.com/archives/attack-of-the-ie-conditional-comment
78	 * Credit to James Padolsey for the original implemntation!
79	 */
80	ie: (function() {
81		/* eslint-disable no-empty */
82		var v, i;
83		for (
84			v = 4, i = document.createElement('div');
85			(i.innerHTML = '<!--[if gt IE ' + v + ']><i></i><![endif]-->') && i.getElementsByTagName('i')[0];
86			v+=1
87		) {}
88		return v > 4 ? v : NaN;
89		/* eslint-enable no-empty */
90	})(),
91
92	/*
93	 * iOS version detection
94	 */
95	iOS: parseFloat(
96		('' + (/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent) || [0,''])[1])
97		.replace('undefined', '3_2').replace('_', '.').replace('_', '')
98	) || FALSE
99};
100;function QTip(target, options, id, attr) {
101	// Elements and ID
102	this.id = id;
103	this.target = target;
104	this.tooltip = NULL;
105	this.elements = { target: target };
106
107	// Internal constructs
108	this._id = NAMESPACE + '-' + id;
109	this.timers = { img: {} };
110	this.options = options;
111	this.plugins = {};
112
113	// Cache object
114	this.cache = {
115		event: {},
116		target: $(),
117		disabled: FALSE,
118		attr: attr,
119		onTooltip: FALSE,
120		lastClass: ''
121	};
122
123	// Set the initial flags
124	this.rendered = this.destroyed = this.disabled = this.waiting =
125		this.hiddenDuringWait = this.positioning = this.triggering = FALSE;
126}
127PROTOTYPE = QTip.prototype;
128
129PROTOTYPE._when = function(deferreds) {
130	return $.when.apply($, deferreds);
131};
132
133PROTOTYPE.trim = function(string) {
134	return string.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
135}
136
137QTip.isFunction = function(obj) {
138	return typeof obj === "function"
139}
140
141PROTOTYPE.render = function(show) {
142	if(this.rendered || this.destroyed) { return this; } // If tooltip has already been rendered, exit
143
144	var self = this,
145		options = this.options,
146		cache = this.cache,
147		elements = this.elements,
148		text = options.content.text,
149		title = options.content.title,
150		button = options.content.button,
151		posOptions = options.position,
152		deferreds = [];
153
154	// Add ARIA attributes to target
155	$.attr(this.target[0], 'aria-describedby', this._id);
156
157	// Create public position object that tracks current position corners
158	cache.posClass = this._createPosClass(
159		(this.position = { my: posOptions.my, at: posOptions.at }).my
160	);
161
162	// Create tooltip element
163	this.tooltip = elements.tooltip = $('<div/>', {
164		'id': this._id,
165		'class': [ NAMESPACE, CLASS_DEFAULT, options.style.classes, cache.posClass ].join(' '),
166		'width': options.style.width || '',
167		'height': options.style.height || '',
168		'tracking': posOptions.target === 'mouse' && posOptions.adjust.mouse,
169
170		/* ARIA specific attributes */
171		'role': 'alert',
172		'aria-live': 'polite',
173		'aria-atomic': FALSE,
174		'aria-describedby': this._id + '-content',
175		'aria-hidden': TRUE
176	})
177	.toggleClass(CLASS_DISABLED, this.disabled)
178	.attr(ATTR_ID, this.id)
179	.data(NAMESPACE, this)
180	.appendTo(posOptions.container)
181	.append(
182		// Create content element
183		elements.content = $('<div />', {
184			'class': NAMESPACE + '-content',
185			'id': this._id + '-content',
186			'aria-atomic': TRUE
187		})
188	);
189
190	// Set rendered flag and prevent redundant reposition calls for now
191	this.rendered = -1;
192	this.positioning = TRUE;
193
194	// Create title...
195	if(title) {
196		this._createTitle();
197
198		// Update title only if its not a callback (called in toggle if so)
199		if(!QTip.isFunction(title)) {
200			deferreds.push( this._updateTitle(title, FALSE) );
201		}
202	}
203
204	// Create button
205	if(button) { this._createButton(); }
206
207	// Set proper rendered flag and update content if not a callback function (called in toggle)
208	if(!QTip.isFunction(text)) {
209		deferreds.push( this._updateContent(text, FALSE) );
210	}
211	this.rendered = TRUE;
212
213	// Setup widget classes
214	this._setWidget();
215
216	// Initialize 'render' plugins
217	$.each(PLUGINS, function(name) {
218		var instance;
219		if(this.initialize === 'render' && (instance = this(self))) {
220			self.plugins[name] = instance;
221		}
222	});
223
224	// Unassign initial events and assign proper events
225	this._unassignEvents();
226	this._assignEvents();
227
228	// When deferreds have completed
229	this._when(deferreds).then(function() {
230		// tooltiprender event
231		self._trigger('render');
232
233		// Reset flags
234		self.positioning = FALSE;
235
236		// Show tooltip if not hidden during wait period
237		if(!self.hiddenDuringWait && (options.show.ready || show)) {
238			self.toggle(TRUE, cache.event, FALSE);
239		}
240		self.hiddenDuringWait = FALSE;
241	});
242
243	// Expose API
244	QTIP.api[this.id] = this;
245
246	return this;
247};
248
249PROTOTYPE.destroy = function(immediate) {
250	// Set flag the signify destroy is taking place to plugins
251	// and ensure it only gets destroyed once!
252	if(this.destroyed) { return this.target; }
253
254	function process() {
255		if(this.destroyed) { return; }
256		this.destroyed = TRUE;
257
258		var target = this.target,
259			title = target.attr(oldtitle),
260			timer;
261
262		// Destroy tooltip if rendered
263		if(this.rendered) {
264			this.tooltip.stop(1,0).find('*').remove().end().remove();
265		}
266
267		// Destroy all plugins
268		$.each(this.plugins, function() {
269			this.destroy && this.destroy();
270		});
271
272		// Clear timers
273		for (timer in this.timers) {
274			if (this.timers.hasOwnProperty(timer)) {
275				clearTimeout(this.timers[timer]);
276			}
277		}
278
279		// Remove api object and ARIA attributes
280		target.removeData(NAMESPACE)
281			.removeAttr(ATTR_ID)
282			.removeAttr(ATTR_HAS)
283			.removeAttr('aria-describedby');
284
285		// Reset old title attribute if removed
286		if(this.options.suppress && title) {
287			target.attr('title', title).removeAttr(oldtitle);
288		}
289
290		// Remove qTip events associated with this API
291		this._unassignEvents();
292
293		// Remove ID from used id objects, and delete object references
294		// for better garbage collection and leak protection
295		this.options = this.elements = this.cache = this.timers =
296			this.plugins = this.mouse = NULL;
297
298		// Delete epoxsed API object
299		delete QTIP.api[this.id];
300	}
301
302	// If an immediate destroy is needed
303	if((immediate !== TRUE || this.triggering === 'hide') && this.rendered) {
304		this.tooltip.one('tooltiphidden', $.proxy(process, this));
305		!this.triggering && this.hide();
306	}
307
308	// If we're not in the process of hiding... process
309	else { process.call(this); }
310
311	return this.target;
312};
313;function invalidOpt(a) {
314	return a === NULL || typeof a !== 'object';
315}
316
317function invalidContent(c) {
318	return !(QTip.isFunction(c) ||
319            c && c.attr ||
320            c.length ||
321            typeof c === 'object' && c !== NULL && (c.jquery || c.then));
322}
323
324// Option object sanitizer
325function sanitizeOptions(opts) {
326	var content, text, ajax, once;
327
328	if(invalidOpt(opts)) { return FALSE; }
329
330	if(invalidOpt(opts.metadata)) {
331		opts.metadata = { type: opts.metadata };
332	}
333
334	if('content' in opts) {
335		content = opts.content;
336
337		if(invalidOpt(content) || content.jquery || content.done) {
338			text = invalidContent(content) ? FALSE : content;
339			content = opts.content = {
340				text: text
341			};
342		}
343		else { text = content.text; }
344
345		// DEPRECATED - Old content.ajax plugin functionality
346		// Converts it into the proper Deferred syntax
347		if('ajax' in content) {
348			ajax = content.ajax;
349			once = ajax && ajax.once !== FALSE;
350			delete content.ajax;
351
352			content.text = function(event, api) {
353				var loading = text || $(this).attr(api.options.content.attr) || 'Loading...',
354
355				deferred = $.ajax(
356					$.extend({}, ajax, { context: api })
357				)
358				.then(ajax.success, NULL, ajax.error)
359				.then(function(newContent) {
360					if(newContent && once) { api.set('content.text', newContent); }
361					return newContent;
362				},
363				function(xhr, status, error) {
364					if(api.destroyed || xhr.status === 0) { return; }
365					api.set('content.text', status + ': ' + error);
366				});
367
368				return !once ? (api.set('content.text', loading), deferred) : loading;
369			};
370		}
371
372		if('title' in content) {
373			if($.isPlainObject(content.title)) {
374				content.button = content.title.button;
375				content.title = content.title.text;
376			}
377
378			if(invalidContent(content.title || FALSE)) {
379				content.title = FALSE;
380			}
381		}
382	}
383
384	if('position' in opts && invalidOpt(opts.position)) {
385		opts.position = { my: opts.position, at: opts.position };
386	}
387
388	if('show' in opts && invalidOpt(opts.show)) {
389		opts.show = opts.show.jquery ? { target: opts.show } :
390			opts.show === TRUE ? { ready: TRUE } : { event: opts.show };
391	}
392
393	if('hide' in opts && invalidOpt(opts.hide)) {
394		opts.hide = opts.hide.jquery ? { target: opts.hide } : { event: opts.hide };
395	}
396
397	if('style' in opts && invalidOpt(opts.style)) {
398		opts.style = { classes: opts.style };
399	}
400
401	// Sanitize plugin options
402	$.each(PLUGINS, function() {
403		this.sanitize && this.sanitize(opts);
404	});
405
406	return opts;
407}
408
409// Setup builtin .set() option checks
410CHECKS = PROTOTYPE.checks = {
411	builtin: {
412		// Core checks
413		'^id$': function(obj, o, v, prev) {
414			var id = v === TRUE ? QTIP.nextid : v,
415				newId = NAMESPACE + '-' + id;
416
417			if(id !== FALSE && id.length > 0 && !$('#'+newId).length) {
418				this._id = newId;
419
420				if(this.rendered) {
421					this.tooltip[0].id = this._id;
422					this.elements.content[0].id = this._id + '-content';
423					this.elements.title[0].id = this._id + '-title';
424				}
425			}
426			else { obj[o] = prev; }
427		},
428		'^prerender': function(obj, o, v) {
429			v && !this.rendered && this.render(this.options.show.ready);
430		},
431
432		// Content checks
433		'^content.text$': function(obj, o, v) {
434			this._updateContent(v);
435		},
436		'^content.attr$': function(obj, o, v, prev) {
437			if(this.options.content.text === this.target.attr(prev)) {
438				this._updateContent( this.target.attr(v) );
439			}
440		},
441		'^content.title$': function(obj, o, v) {
442			// Remove title if content is null
443			if(!v) { return this._removeTitle(); }
444
445			// If title isn't already created, create it now and update
446			v && !this.elements.title && this._createTitle();
447			this._updateTitle(v);
448		},
449		'^content.button$': function(obj, o, v) {
450			this._updateButton(v);
451		},
452		'^content.title.(text|button)$': function(obj, o, v) {
453			this.set('content.'+o, v); // Backwards title.text/button compat
454		},
455
456		// Position checks
457		'^position.(my|at)$': function(obj, o, v){
458			if('string' === typeof v) {
459				this.position[o] = obj[o] = new CORNER(v, o === 'at');
460			}
461		},
462		'^position.container$': function(obj, o, v){
463			this.rendered && this.tooltip.appendTo(v);
464		},
465
466		// Show checks
467		'^show.ready$': function(obj, o, v) {
468			v && (!this.rendered && this.render(TRUE) || this.toggle(TRUE));
469		},
470
471		// Style checks
472		'^style.classes$': function(obj, o, v, p) {
473			this.rendered && this.tooltip.removeClass(p).addClass(v);
474		},
475		'^style.(width|height)': function(obj, o, v) {
476			this.rendered && this.tooltip.css(o, v);
477		},
478		'^style.widget|content.title': function() {
479			this.rendered && this._setWidget();
480		},
481		'^style.def': function(obj, o, v) {
482			this.rendered && this.tooltip.toggleClass(CLASS_DEFAULT, !!v);
483		},
484
485		// Events check
486		'^events.(render|show|move|hide|focus|blur)$': function(obj, o, v) {
487			this.rendered && this.tooltip[(QTip.isFunction(v) ? '' : 'un') + 'bind']('tooltip'+o, v);
488		},
489
490		// Properties which require event reassignment
491		'^(show|hide|position).(event|target|fixed|inactive|leave|distance|viewport|adjust)': function() {
492			if(!this.rendered) { return; }
493
494			// Set tracking flag
495			var posOptions = this.options.position;
496			this.tooltip.attr('tracking', posOptions.target === 'mouse' && posOptions.adjust.mouse);
497
498			// Reassign events
499			this._unassignEvents();
500			this._assignEvents();
501		}
502	}
503};
504
505// Dot notation converter
506function convertNotation(options, notation) {
507	var i = 0, obj, option = options,
508
509	// Split notation into array
510	levels = notation.split('.');
511
512	// Loop through
513	while(option = option[ levels[i++] ]) {
514		if(i < levels.length) { obj = option; }
515	}
516
517	return [obj || options, levels.pop()];
518}
519
520PROTOTYPE.get = function(notation) {
521	if(this.destroyed) { return this; }
522
523	var o = convertNotation(this.options, notation.toLowerCase()),
524		result = o[0][ o[1] ];
525
526	return result.precedance ? result.string() : result;
527};
528
529function setCallback(notation, args) {
530	var category, rule, match;
531
532	for(category in this.checks) {
533		if (!this.checks.hasOwnProperty(category)) { continue; }
534
535		for(rule in this.checks[category]) {
536			if (!this.checks[category].hasOwnProperty(rule)) { continue; }
537
538			if(match = (new RegExp(rule, 'i')).exec(notation)) {
539				args.push(match);
540
541				if(category === 'builtin' || this.plugins[category]) {
542					this.checks[category][rule].apply(
543						this.plugins[category] || this, args
544					);
545				}
546			}
547		}
548	}
549}
550
551var rmove = /^position\.(my|at|adjust|target|container|viewport)|style|content|show\.ready/i,
552	rrender = /^prerender|show\.ready/i;
553
554PROTOTYPE.set = function(option, value) {
555	if(this.destroyed) { return this; }
556
557	var rendered = this.rendered,
558		reposition = FALSE,
559		options = this.options,
560		name;
561
562	// Convert singular option/value pair into object form
563	if('string' === typeof option) {
564		name = option; option = {}; option[name] = value;
565	}
566	else { option = $.extend({}, option); }
567
568	// Set all of the defined options to their new values
569	$.each(option, function(notation, val) {
570		if(rendered && rrender.test(notation)) {
571			delete option[notation]; return;
572		}
573
574		// Set new obj value
575		var obj = convertNotation(options, notation.toLowerCase()), previous;
576		previous = obj[0][ obj[1] ];
577		obj[0][ obj[1] ] = val && val.nodeType ? $(val) : val;
578
579		// Also check if we need to reposition
580		reposition = rmove.test(notation) || reposition;
581
582		// Set the new params for the callback
583		option[notation] = [obj[0], obj[1], val, previous];
584	});
585
586	// Re-sanitize options
587	sanitizeOptions(options);
588
589	/*
590	 * Execute any valid callbacks for the set options
591	 * Also set positioning flag so we don't get loads of redundant repositioning calls.
592	 */
593	this.positioning = TRUE;
594	$.each(option, $.proxy(setCallback, this));
595	this.positioning = FALSE;
596
597	// Update position if needed
598	if(this.rendered && this.tooltip[0].offsetWidth > 0 && reposition) {
599		this.reposition( options.position.target === 'mouse' ? NULL : this.cache.event );
600	}
601
602	return this;
603};
604;PROTOTYPE._update = function(content, element) {
605	var self = this,
606		cache = this.cache;
607
608	// Make sure tooltip is rendered and content is defined. If not return
609	if(!this.rendered || !content) { return FALSE; }
610
611	// Use function to parse content
612	if(QTip.isFunction(content)) {
613		content = content.call(this.elements.target, cache.event, this) || '';
614	}
615
616	// Handle deferred content
617	if(QTip.isFunction(content.then)) {
618		cache.waiting = TRUE;
619		return content.then(function(c) {
620			cache.waiting = FALSE;
621			return self._update(c, element);
622		}, NULL, function(e) {
623			return self._update(e, element);
624		});
625	}
626
627	// If content is null... return false
628	if(content === FALSE || !content && content !== '') { return FALSE; }
629
630	// Append new content if its a DOM array and show it if hidden
631	if(content.jquery && content.length > 0) {
632		element.empty().append(
633			content.css({ display: 'block', visibility: 'visible' })
634		);
635	}
636
637	// Content is a regular string, insert the new content
638	else { element.html(content); }
639
640	// Wait for content to be loaded, and reposition
641	return this._waitForContent(element).then(function(images) {
642		if(self.rendered && self.tooltip[0].offsetWidth > 0) {
643			self.reposition(cache.event, !images.length);
644		}
645	});
646};
647
648PROTOTYPE._waitForContent = function(element) {
649	var cache = this.cache;
650
651	// Set flag
652	cache.waiting = TRUE;
653
654	// If imagesLoaded is included, ensure images have loaded and return promise
655	return ( $.fn.imagesLoaded ? element.imagesLoaded() : new $.Deferred().resolve([]) )
656		.done(function() { cache.waiting = FALSE; })
657		.promise();
658};
659
660PROTOTYPE._updateContent = function(content, reposition) {
661	this._update(content, this.elements.content, reposition);
662};
663
664PROTOTYPE._updateTitle = function(content, reposition) {
665	if(this._update(content, this.elements.title, reposition) === FALSE) {
666		this._removeTitle(FALSE);
667	}
668};
669
670PROTOTYPE._createTitle = function()
671{
672	var elements = this.elements,
673		id = this._id+'-title';
674
675	// Destroy previous title element, if present
676	if(elements.titlebar) { this._removeTitle(); }
677
678	// Create title bar and title elements
679	elements.titlebar = $('<div />', {
680		'class': NAMESPACE + '-titlebar ' + (this.options.style.widget ? createWidgetClass('header') : '')
681	})
682	.append(
683		elements.title = $('<div />', {
684			'id': id,
685			'class': NAMESPACE + '-title',
686			'aria-atomic': TRUE
687		})
688	)
689	.insertBefore(elements.content)
690
691	// Button-specific events
692	.on('mousedown keydown mouseup keyup mouseout', '.qtip-close', function(event) {
693		$(this).toggleClass('ui-state-active ui-state-focus', event.type.substr(-4) === 'down');
694	})
695	.on('mouseover mouseout', '.qtip-close', function(event){
696		$(this).toggleClass('ui-state-hover', event.type === 'mouseover');
697	});
698
699	// Create button if enabled
700	if(this.options.content.button) { this._createButton(); }
701};
702
703PROTOTYPE._removeTitle = function(reposition)
704{
705	var elements = this.elements;
706
707	if(elements.title) {
708		elements.titlebar.remove();
709		elements.titlebar = elements.title = elements.button = NULL;
710
711		// Reposition if enabled
712		if(reposition !== FALSE) { this.reposition(); }
713	}
714};
715;PROTOTYPE._createPosClass = function(my) {
716	return NAMESPACE + '-pos-' + (my || this.options.position.my).abbrev();
717};
718
719PROTOTYPE.reposition = function(event, effect) {
720	if(!this.rendered || this.positioning || this.destroyed) { return this; }
721
722	// Set positioning flag
723	this.positioning = TRUE;
724
725	var cache = this.cache,
726		tooltip = this.tooltip,
727		posOptions = this.options.position,
728		target = posOptions.target,
729		my = posOptions.my,
730		at = posOptions.at,
731		viewport = posOptions.viewport,
732		container = posOptions.container,
733		adjust = posOptions.adjust,
734		method = adjust.method.split(' '),
735		tooltipWidth = tooltip.outerWidth(FALSE),
736		tooltipHeight = tooltip.outerHeight(FALSE),
737		targetWidth = 0,
738		targetHeight = 0,
739		type = tooltip.css('position'),
740		position = { left: 0, top: 0 },
741		visible = tooltip[0].offsetWidth > 0,
742		isScroll = event && event.type === 'scroll',
743		win = $(window),
744		doc = container[0].ownerDocument,
745		mouse = this.mouse,
746		pluginCalculations, offset, adjusted, newClass;
747
748	// Check if absolute position was passed
749	if(Array.isArray(target) && target.length === 2) {
750		// Force left top and set position
751		at = { x: LEFT, y: TOP };
752		position = { left: target[0], top: target[1] };
753	}
754
755	// Check if mouse was the target
756	else if(target === 'mouse') {
757		// Force left top to allow flipping
758		at = { x: LEFT, y: TOP };
759
760		// Use the mouse origin that caused the show event, if distance hiding is enabled
761		if((!adjust.mouse || this.options.hide.distance) && cache.origin && cache.origin.pageX) {
762			event =  cache.origin;
763		}
764
765		// Use cached event for resize/scroll events
766		else if(!event || event && (event.type === 'resize' || event.type === 'scroll')) {
767			event = cache.event;
768		}
769
770		// Otherwise, use the cached mouse coordinates if available
771		else if(mouse && mouse.pageX) {
772			event = mouse;
773		}
774
775		// Calculate body and container offset and take them into account below
776		if(type !== 'static') { position = container.offset(); }
777		if(doc.body.offsetWidth !== (window.innerWidth || doc.documentElement.clientWidth)) {
778			offset = $(document.body).offset();
779		}
780
781		// Use event coordinates for position
782		position = {
783			left: event.pageX - position.left + (offset && offset.left || 0),
784			top: event.pageY - position.top + (offset && offset.top || 0)
785		};
786
787		// Scroll events are a pain, some browsers
788		if(adjust.mouse && isScroll && mouse) {
789			position.left -= (mouse.scrollX || 0) - win.scrollLeft();
790			position.top -= (mouse.scrollY || 0) - win.scrollTop();
791		}
792	}
793
794	// Target wasn't mouse or absolute...
795	else {
796		// Check if event targetting is being used
797		if(target === 'event') {
798			if(event && event.target && event.type !== 'scroll' && event.type !== 'resize') {
799				cache.target = $(event.target);
800			}
801			else if(!event.target) {
802				cache.target = this.elements.target;
803			}
804		}
805		else if(target !== 'event'){
806			cache.target = $(target.jquery ? target : this.elements.target);
807		}
808		target = cache.target;
809
810		// Parse the target into a jQuery object and make sure there's an element present
811		target = $(target).eq(0);
812		if(target.length === 0) { return this; }
813
814		// Check if window or document is the target
815		else if(target[0] === document || target[0] === window) {
816			targetWidth = BROWSER.iOS ? window.innerWidth : target.width();
817			targetHeight = BROWSER.iOS ? window.innerHeight : target.height();
818
819			if(target[0] === window) {
820				position = {
821					top: (viewport || target).scrollTop(),
822					left: (viewport || target).scrollLeft()
823				};
824			}
825		}
826
827		// Check if the target is an <AREA> element
828		else if(PLUGINS.imagemap && target.is('area')) {
829			pluginCalculations = PLUGINS.imagemap(this, target, at, PLUGINS.viewport ? method : FALSE);
830		}
831
832		// Check if the target is an SVG element
833		else if(PLUGINS.svg && target && target[0].ownerSVGElement) {
834			pluginCalculations = PLUGINS.svg(this, target, at, PLUGINS.viewport ? method : FALSE);
835		}
836
837		// Otherwise use regular jQuery methods
838		else {
839			targetWidth = target.outerWidth(FALSE);
840			targetHeight = target.outerHeight(FALSE);
841			position = target.offset();
842		}
843
844		// Parse returned plugin values into proper variables
845		if(pluginCalculations) {
846			targetWidth = pluginCalculations.width;
847			targetHeight = pluginCalculations.height;
848			offset = pluginCalculations.offset;
849			position = pluginCalculations.position;
850		}
851
852		// Adjust position to take into account offset parents
853		position = this.reposition.offset(target, position, container);
854
855		// Adjust for position.fixed tooltips (and also iOS scroll bug in v3.2-4.0 & v4.3-4.3.2)
856		if(BROWSER.iOS > 3.1 && BROWSER.iOS < 4.1 ||
857			BROWSER.iOS >= 4.3 && BROWSER.iOS < 4.33 ||
858			!BROWSER.iOS && type === 'fixed'
859		){
860			position.left -= win.scrollLeft();
861			position.top -= win.scrollTop();
862		}
863
864		// Adjust position relative to target
865		if(!pluginCalculations || pluginCalculations && pluginCalculations.adjustable !== FALSE) {
866			position.left += at.x === RIGHT ? targetWidth : at.x === CENTER ? targetWidth / 2 : 0;
867			position.top += at.y === BOTTOM ? targetHeight : at.y === CENTER ? targetHeight / 2 : 0;
868		}
869	}
870
871	// Adjust position relative to tooltip
872	position.left += adjust.x + (my.x === RIGHT ? -tooltipWidth : my.x === CENTER ? -tooltipWidth / 2 : 0);
873	position.top += adjust.y + (my.y === BOTTOM ? -tooltipHeight : my.y === CENTER ? -tooltipHeight / 2 : 0);
874
875	// Use viewport adjustment plugin if enabled
876	if(PLUGINS.viewport) {
877		adjusted = position.adjusted = PLUGINS.viewport(
878			this, position, posOptions, targetWidth, targetHeight, tooltipWidth, tooltipHeight
879		);
880
881		// Apply offsets supplied by positioning plugin (if used)
882		if(offset && adjusted.left) { position.left += offset.left; }
883		if(offset && adjusted.top) {  position.top += offset.top; }
884
885		// Apply any new 'my' position
886		if(adjusted.my) { this.position.my = adjusted.my; }
887	}
888
889	// Viewport adjustment is disabled, set values to zero
890	else { position.adjusted = { left: 0, top: 0 }; }
891
892	// Set tooltip position class if it's changed
893	if(cache.posClass !== (newClass = this._createPosClass(this.position.my))) {
894		cache.posClass = newClass;
895		tooltip.removeClass(cache.posClass).addClass(newClass);
896	}
897
898	// tooltipmove event
899	if(!this._trigger('move', [position, viewport.elem || viewport], event)) { return this; }
900	delete position.adjusted;
901
902	// If effect is disabled, target it mouse, no animation is defined or positioning gives NaN out, set CSS directly
903	if(effect === FALSE || !visible || isNaN(position.left) || isNaN(position.top) || target === 'mouse' || !QTip.isFunction(posOptions.effect)) {
904		tooltip.css(position);
905	}
906
907	// Use custom function if provided
908	else if(QTip.isFunction(posOptions.effect)) {
909		posOptions.effect.call(tooltip, this, $.extend({}, position));
910		tooltip.queue(function(next) {
911			// Reset attributes to avoid cross-browser rendering bugs
912			$(this).css({ opacity: '', height: '' });
913			if(BROWSER.ie) { this.style.removeAttribute('filter'); }
914
915			next();
916		});
917	}
918
919	// Set positioning flag
920	this.positioning = FALSE;
921
922	return this;
923};
924
925// Custom (more correct for qTip!) offset calculator
926PROTOTYPE.reposition.offset = function(elem, pos, container) {
927	if(!container[0]) { return pos; }
928
929	var ownerDocument = $(elem[0].ownerDocument),
930		quirks = !!BROWSER.ie && document.compatMode !== 'CSS1Compat',
931		parent = container[0],
932		scrolled, position, parentOffset, overflow;
933
934	function scroll(e, i) {
935		pos.left += i * e.scrollLeft();
936		pos.top += i * e.scrollTop();
937	}
938
939	// Compensate for non-static containers offset
940	do {
941		if((position = $.css(parent, 'position')) !== 'static') {
942			if(position === 'fixed') {
943				parentOffset = parent.getBoundingClientRect();
944				scroll(ownerDocument, -1);
945			}
946			else {
947				parentOffset = $(parent).position();
948				parentOffset.left += parseFloat($.css(parent, 'borderLeftWidth')) || 0;
949				parentOffset.top += parseFloat($.css(parent, 'borderTopWidth')) || 0;
950			}
951
952			pos.left -= parentOffset.left + (parseFloat($.css(parent, 'marginLeft')) || 0);
953			pos.top -= parentOffset.top + (parseFloat($.css(parent, 'marginTop')) || 0);
954
955			// If this is the first parent element with an overflow of "scroll" or "auto", store it
956			if(!scrolled && (overflow = $.css(parent, 'overflow')) !== 'hidden' && overflow !== 'visible') { scrolled = $(parent); }
957		}
958	}
959	while(parent = parent.offsetParent);
960
961	// Compensate for containers scroll if it also has an offsetParent (or in IE quirks mode)
962	if(scrolled && (scrolled[0] !== ownerDocument[0] || quirks)) {
963		scroll(scrolled, 1);
964	}
965
966	return pos;
967};
968
969// Corner class
970var C = (CORNER = PROTOTYPE.reposition.Corner = function(corner, forceY) {
971	corner = ('' + corner).replace(/([A-Z])/, ' $1').replace(/middle/gi, CENTER).toLowerCase();
972	this.x = (corner.match(/left|right/i) || corner.match(/center/) || ['inherit'])[0].toLowerCase();
973	this.y = (corner.match(/top|bottom|center/i) || ['inherit'])[0].toLowerCase();
974	this.forceY = !!forceY;
975
976	var f = corner.charAt(0);
977	this.precedance = f === 't' || f === 'b' ? Y : X;
978}).prototype;
979
980C.invert = function(z, center) {
981	this[z] = this[z] === LEFT ? RIGHT : this[z] === RIGHT ? LEFT : center || this[z];
982};
983
984C.string = function(join) {
985	var x = this.x, y = this.y;
986
987	var result = x !== y ?
988		x === 'center' || y !== 'center' && (this.precedance === Y || this.forceY) ?
989			[y,x] :
990			[x,y] :
991		[x];
992
993	return join !== false ? result.join(' ') : result;
994};
995
996C.abbrev = function() {
997	var result = this.string(false);
998	return result[0].charAt(0) + (result[1] && result[1].charAt(0) || '');
999};
1000
1001C.clone = function() {
1002	return new CORNER( this.string(), this.forceY );
1003};
1004
1005;
1006PROTOTYPE.toggle = function(state, event) {
1007	var cache = this.cache,
1008		options = this.options,
1009		tooltip = this.tooltip;
1010
1011	// Try to prevent flickering when tooltip overlaps show element
1012	if(event) {
1013		if((/over|enter/).test(event.type) && cache.event && (/out|leave/).test(cache.event.type) &&
1014			options.show.target.add(event.target).length === options.show.target.length &&
1015			tooltip.has(event.relatedTarget).length) {
1016			return this;
1017		}
1018
1019		// Cache event
1020		cache.event = $.event.fix(event);
1021	}
1022
1023	// If we're currently waiting and we've just hidden... stop it
1024	this.waiting && !state && (this.hiddenDuringWait = TRUE);
1025
1026	// Render the tooltip if showing and it isn't already
1027	if(!this.rendered) { return state ? this.render(1) : this; }
1028	else if(this.destroyed || this.disabled) { return this; }
1029
1030	var type = state ? 'show' : 'hide',
1031		opts = this.options[type],
1032		posOptions = this.options.position,
1033		contentOptions = this.options.content,
1034		width = this.tooltip.css('width'),
1035		visible = this.tooltip.is(':visible'),
1036		animate = state || opts.target.length === 1,
1037		sameTarget = !event || opts.target.length < 2 || cache.target[0] === event.target,
1038		identicalState, allow, after;
1039
1040	// Detect state if valid one isn't provided
1041	if((typeof state).search('boolean|number')) { state = !visible; }
1042
1043	// Check if the tooltip is in an identical state to the new would-be state
1044	identicalState = !tooltip.is(':animated') && visible === state && sameTarget;
1045
1046	// Fire tooltip(show/hide) event and check if destroyed
1047	allow = !identicalState ? !!this._trigger(type, [90]) : NULL;
1048
1049	// Check to make sure the tooltip wasn't destroyed in the callback
1050	if(this.destroyed) { return this; }
1051
1052	// If the user didn't stop the method prematurely and we're showing the tooltip, focus it
1053	if(allow !== FALSE && state) { this.focus(event); }
1054
1055	// If the state hasn't changed or the user stopped it, return early
1056	if(!allow || identicalState) { return this; }
1057
1058	// Set ARIA hidden attribute
1059	$.attr(tooltip[0], 'aria-hidden', !!!state);
1060
1061	// Execute state specific properties
1062	if(state) {
1063		// Store show origin coordinates
1064		this.mouse && (cache.origin = $.event.fix(this.mouse));
1065
1066		// Update tooltip content & title if it's a dynamic function
1067		if(QTip.isFunction(contentOptions.text)) { this._updateContent(contentOptions.text, FALSE); }
1068		if(QTip.isFunction(contentOptions.title)) { this._updateTitle(contentOptions.title, FALSE); }
1069
1070		// Cache mousemove events for positioning purposes (if not already tracking)
1071		if(!trackingBound && posOptions.target === 'mouse' && posOptions.adjust.mouse) {
1072			$(document).on('mousemove.'+NAMESPACE, null, this._storeMouse);
1073			trackingBound = TRUE;
1074		}
1075
1076		// Update the tooltip position (set width first to prevent viewport/max-width issues)
1077		if(!width) { tooltip.css('width', tooltip.outerWidth(FALSE)); }
1078		this.reposition(event, arguments[2]);
1079		if(!width) { tooltip.css('width', ''); }
1080
1081		// Hide other tooltips if tooltip is solo
1082		if(!!opts.solo) {
1083			(typeof opts.solo === 'string' ? $(opts.solo) : $(SELECTOR, opts.solo))
1084				.not(tooltip).not(opts.target).qtip('hide', new $.Event('tooltipsolo'));
1085		}
1086	}
1087	else {
1088		// Clear show timer if we're hiding
1089		clearTimeout(this.timers.show);
1090
1091		// Remove cached origin on hide
1092		delete cache.origin;
1093
1094		// Remove mouse tracking event if not needed (all tracking qTips are hidden)
1095		if(trackingBound && !$(SELECTOR+'[tracking="true"]:visible', opts.solo).not(tooltip).length) {
1096			$(document).off('mousemove.'+NAMESPACE);
1097			trackingBound = FALSE;
1098		}
1099
1100		// Blur the tooltip
1101		this.blur(event);
1102	}
1103
1104	// Define post-animation, state specific properties
1105	after = $.proxy(function() {
1106		if(state) {
1107			// Prevent antialias from disappearing in IE by removing filter
1108			if(BROWSER.ie) { tooltip[0].style.removeAttribute('filter'); }
1109
1110			// Remove overflow setting to prevent tip bugs
1111			tooltip.css('overflow', '');
1112
1113			// Autofocus elements if enabled
1114			if('string' === typeof opts.autofocus) {
1115				$(this.options.show.autofocus, tooltip).focus();
1116			}
1117
1118			// If set, hide tooltip when inactive for delay period
1119			this.options.show.target.trigger('qtip-'+this.id+'-inactive');
1120		}
1121		else {
1122			// Reset CSS states
1123			tooltip.css({
1124				display: '',
1125				visibility: '',
1126				opacity: '',
1127				left: '',
1128				top: ''
1129			});
1130		}
1131
1132		// tooltipvisible/tooltiphidden events
1133		this._trigger(state ? 'visible' : 'hidden');
1134	}, this);
1135
1136	// If no effect type is supplied, use a simple toggle
1137	if(opts.effect === FALSE || animate === FALSE) {
1138		tooltip[ type ]();
1139		after();
1140	}
1141
1142	// Use custom function if provided
1143	else if(QTip.isFunction(opts.effect)) {
1144		tooltip.stop(1, 1);
1145		opts.effect.call(tooltip, this);
1146		tooltip.queue('fx', function(n) {
1147			after(); n();
1148		});
1149	}
1150
1151	// Use basic fade function by default
1152	else { tooltip.fadeTo(90, state ? 1 : 0, after); }
1153
1154	// If inactive hide method is set, active it
1155	if(state) { opts.target.trigger('qtip-'+this.id+'-inactive'); }
1156
1157	return this;
1158};
1159
1160PROTOTYPE.show = function(event) { return this.toggle(TRUE, event); };
1161
1162PROTOTYPE.hide = function(event) { return this.toggle(FALSE, event); };
1163;PROTOTYPE.focus = function(event) {
1164	if(!this.rendered || this.destroyed) { return this; }
1165
1166	var qtips = $(SELECTOR),
1167		tooltip = this.tooltip,
1168		curIndex = parseInt(tooltip[0].style.zIndex, 10),
1169		newIndex = QTIP.zindex + qtips.length;
1170
1171	// Only update the z-index if it has changed and tooltip is not already focused
1172	if(!tooltip.hasClass(CLASS_FOCUS)) {
1173		// tooltipfocus event
1174		if(this._trigger('focus', [newIndex], event)) {
1175			// Only update z-index's if they've changed
1176			if(curIndex !== newIndex) {
1177				// Reduce our z-index's and keep them properly ordered
1178				qtips.each(function() {
1179					if(this.style.zIndex > curIndex) {
1180						this.style.zIndex = this.style.zIndex - 1;
1181					}
1182				});
1183
1184				// Fire blur event for focused tooltip
1185				qtips.filter('.' + CLASS_FOCUS).qtip('blur', event);
1186			}
1187
1188			// Set the new z-index
1189			tooltip.addClass(CLASS_FOCUS)[0].style.zIndex = newIndex;
1190		}
1191	}
1192
1193	return this;
1194};
1195
1196PROTOTYPE.blur = function(event) {
1197	if(!this.rendered || this.destroyed) { return this; }
1198
1199	// Set focused status to FALSE
1200	this.tooltip.removeClass(CLASS_FOCUS);
1201
1202	// tooltipblur event
1203	this._trigger('blur', [ this.tooltip.css('zIndex') ], event);
1204
1205	return this;
1206};
1207;PROTOTYPE.disable = function(state) {
1208	if(this.destroyed) { return this; }
1209
1210	// If 'toggle' is passed, toggle the current state
1211	if(state === 'toggle') {
1212		state = !(this.rendered ? this.tooltip.hasClass(CLASS_DISABLED) : this.disabled);
1213	}
1214
1215	// Disable if no state passed
1216	else if('boolean' !== typeof state) {
1217		state = TRUE;
1218	}
1219
1220	if(this.rendered) {
1221		this.tooltip.toggleClass(CLASS_DISABLED, state)
1222			.attr('aria-disabled', state);
1223	}
1224
1225	this.disabled = !!state;
1226
1227	return this;
1228};
1229
1230PROTOTYPE.enable = function() { return this.disable(FALSE); };
1231;PROTOTYPE._createButton = function()
1232{
1233	var self = this,
1234		elements = this.elements,
1235		tooltip = elements.tooltip,
1236		button = this.options.content.button,
1237		isString = typeof button === 'string',
1238		close = isString ? button : 'Close tooltip';
1239
1240	if(elements.button) { elements.button.remove(); }
1241
1242	// Use custom button if one was supplied by user, else use default
1243	if(button.jquery) {
1244		elements.button = button;
1245	}
1246	else {
1247		elements.button = $('<a />', {
1248			'class': 'qtip-close ' + (this.options.style.widget ? '' : NAMESPACE+'-icon'),
1249			'title': close,
1250			'aria-label': close
1251		})
1252		.prepend(
1253			$('<span />', {
1254				'class': 'ui-icon ui-icon-close',
1255				'html': '&times;'
1256			})
1257		);
1258	}
1259
1260	// Create button and setup attributes
1261	elements.button.appendTo(elements.titlebar || tooltip)
1262		.attr('role', 'button')
1263		.click(function(event) {
1264			if(!tooltip.hasClass(CLASS_DISABLED)) { self.hide(event); }
1265			return FALSE;
1266		});
1267};
1268
1269PROTOTYPE._updateButton = function(button)
1270{
1271	// Make sure tooltip is rendered and if not, return
1272	if(!this.rendered) { return FALSE; }
1273
1274	var elem = this.elements.button;
1275	if(button) { this._createButton(); }
1276	else { elem.remove(); }
1277};
1278;// Widget class creator
1279function createWidgetClass(cls) {
1280	return WIDGET.concat('').join(cls ? '-'+cls+' ' : ' ');
1281}
1282
1283// Widget class setter method
1284PROTOTYPE._setWidget = function()
1285{
1286	var on = this.options.style.widget,
1287		elements = this.elements,
1288		tooltip = elements.tooltip,
1289		disabled = tooltip.hasClass(CLASS_DISABLED);
1290
1291	tooltip.removeClass(CLASS_DISABLED);
1292	CLASS_DISABLED = on ? 'ui-state-disabled' : 'qtip-disabled';
1293	tooltip.toggleClass(CLASS_DISABLED, disabled);
1294
1295	tooltip.toggleClass('ui-helper-reset '+createWidgetClass(), on).toggleClass(CLASS_DEFAULT, this.options.style.def && !on);
1296
1297	if(elements.content) {
1298		elements.content.toggleClass( createWidgetClass('content'), on);
1299	}
1300	if(elements.titlebar) {
1301		elements.titlebar.toggleClass( createWidgetClass('header'), on);
1302	}
1303	if(elements.button) {
1304		elements.button.toggleClass(NAMESPACE+'-icon', !on);
1305	}
1306};
1307;function delay(callback, duration) {
1308	// If tooltip has displayed, start hide timer
1309	if(duration > 0) {
1310		return setTimeout(
1311			$.proxy(callback, this), duration
1312		);
1313	}
1314	else{ callback.call(this); }
1315}
1316
1317function showMethod(event) {
1318	if(this.tooltip.hasClass(CLASS_DISABLED)) { return; }
1319
1320	// Clear hide timers
1321	clearTimeout(this.timers.show);
1322	clearTimeout(this.timers.hide);
1323
1324	// Start show timer
1325	this.timers.show = delay.call(this,
1326		function() { this.toggle(TRUE, event); },
1327		this.options.show.delay
1328	);
1329}
1330
1331function hideMethod(event) {
1332	if(this.tooltip.hasClass(CLASS_DISABLED) || this.destroyed) { return; }
1333
1334	// Check if new target was actually the tooltip element
1335	var relatedTarget = $(event.relatedTarget),
1336		ontoTooltip = relatedTarget.closest(SELECTOR)[0] === this.tooltip[0],
1337		ontoTarget = relatedTarget[0] === this.options.show.target[0];
1338
1339	// Clear timers and stop animation queue
1340	clearTimeout(this.timers.show);
1341	clearTimeout(this.timers.hide);
1342
1343	// Prevent hiding if tooltip is fixed and event target is the tooltip.
1344	// Or if mouse positioning is enabled and cursor momentarily overlaps
1345	if(this !== relatedTarget[0] &&
1346		(this.options.position.target === 'mouse' && ontoTooltip) ||
1347		this.options.hide.fixed && (
1348			(/mouse(out|leave|move)/).test(event.type) && (ontoTooltip || ontoTarget))
1349		)
1350	{
1351		/* eslint-disable no-empty */
1352		try {
1353			event.preventDefault();
1354			event.stopImmediatePropagation();
1355		} catch(e) {}
1356		/* eslint-enable no-empty */
1357
1358		return;
1359	}
1360
1361	// If tooltip has displayed, start hide timer
1362	this.timers.hide = delay.call(this,
1363		function() { this.toggle(FALSE, event); },
1364		this.options.hide.delay,
1365		this
1366	);
1367}
1368
1369function inactiveMethod(event) {
1370	if(this.tooltip.hasClass(CLASS_DISABLED) || !this.options.hide.inactive) { return; }
1371
1372	// Clear timer
1373	clearTimeout(this.timers.inactive);
1374
1375	this.timers.inactive = delay.call(this,
1376		function(){ this.hide(event); },
1377		this.options.hide.inactive
1378	);
1379}
1380
1381function repositionMethod(event) {
1382	if(this.rendered && this.tooltip[0].offsetWidth > 0) { this.reposition(event); }
1383}
1384
1385// Store mouse coordinates
1386PROTOTYPE._storeMouse = function(event) {
1387	(this.mouse = $.event.fix(event)).type = 'mousemove';
1388	return this;
1389};
1390
1391// Bind events
1392PROTOTYPE._bind = function(targets, events, method, suffix, context) {
1393	if(!targets || !method || !events.length) { return; }
1394	var ns = '.' + this._id + (suffix ? '-'+suffix : '');
1395	$(targets).on(
1396		(events.split ? events : events.join(ns + ' ')) + ns,
1397		null,
1398		$.proxy(method, context || this)
1399	);
1400	return this;
1401};
1402PROTOTYPE._unbind = function(targets, suffix) {
1403	targets && $(targets).off('.' + this._id + (suffix ? '-'+suffix : ''));
1404	return this;
1405};
1406
1407// Global delegation helper
1408function delegate(selector, events, method) {
1409	$(document.body).on(
1410		(events.split ? events : events.join('.'+NAMESPACE + ' ')) + '.'+NAMESPACE,
1411		selector,
1412		function() {
1413			var api = QTIP.api[ $.attr(this, ATTR_ID) ];
1414			api && !api.disabled && method.apply(api, arguments);
1415		}
1416	);
1417}
1418// Event trigger
1419PROTOTYPE._trigger = function(type, args, event) {
1420	var callback = new $.Event('tooltip'+type);
1421	callback.originalEvent = event && $.extend({}, event) || this.cache.event || NULL;
1422
1423	this.triggering = type;
1424	this.tooltip.trigger(callback, [this].concat(args || []));
1425	this.triggering = FALSE;
1426
1427	return !callback.isDefaultPrevented();
1428};
1429
1430PROTOTYPE._bindEvents = function(showEvents, hideEvents, showTargets, hideTargets, showCallback, hideCallback) {
1431	// Get tasrgets that lye within both
1432	var similarTargets = showTargets.filter( hideTargets ).add( hideTargets.filter(showTargets) ),
1433		toggleEvents = [];
1434
1435	// If hide and show targets are the same...
1436	if(similarTargets.length) {
1437
1438		// Filter identical show/hide events
1439		$.each(hideEvents, function(i, type) {
1440			var showIndex = $.inArray(type, showEvents);
1441
1442			// Both events are identical, remove from both hide and show events
1443			// and append to toggleEvents
1444			showIndex > -1 && toggleEvents.push( showEvents.splice( showIndex, 1 )[0] );
1445		});
1446
1447		// Toggle events are special case of identical show/hide events, which happen in sequence
1448		if(toggleEvents.length) {
1449			// Bind toggle events to the similar targets
1450			this._bind(similarTargets, toggleEvents, function(event) {
1451				var state = this.rendered ? this.tooltip[0].offsetWidth > 0 : false;
1452				(state ? hideCallback : showCallback).call(this, event);
1453			});
1454
1455			// Remove the similar targets from the regular show/hide bindings
1456			showTargets = showTargets.not(similarTargets);
1457			hideTargets = hideTargets.not(similarTargets);
1458		}
1459	}
1460
1461	// Apply show/hide/toggle events
1462	this._bind(showTargets, showEvents, showCallback);
1463	this._bind(hideTargets, hideEvents, hideCallback);
1464};
1465
1466PROTOTYPE._assignInitialEvents = function(event) {
1467	var options = this.options,
1468		showTarget = options.show.target,
1469		hideTarget = options.hide.target,
1470		showEvents = options.show.event ? this.trim('' + options.show.event).split(' ') : [],
1471		hideEvents = options.hide.event ? this.trim('' + options.hide.event).split(' ') : [];
1472
1473	// Catch remove/removeqtip events on target element to destroy redundant tooltips
1474	this._bind(this.elements.target, ['remove', 'removeqtip'], function() {
1475		this.destroy(true);
1476	}, 'destroy');
1477
1478	/*
1479	 * Make sure hoverIntent functions properly by using mouseleave as a hide event if
1480	 * mouseenter/mouseout is used for show.event, even if it isn't in the users options.
1481	 */
1482	if(/mouse(over|enter)/i.test(options.show.event) && !/mouse(out|leave)/i.test(options.hide.event)) {
1483		hideEvents.push('mouseleave');
1484	}
1485
1486	/*
1487	 * Also make sure initial mouse targetting works correctly by caching mousemove coords
1488	 * on show targets before the tooltip has rendered. Also set onTarget when triggered to
1489	 * keep mouse tracking working.
1490	 */
1491	this._bind(showTarget, 'mousemove', function(moveEvent) {
1492		this._storeMouse(moveEvent);
1493		this.cache.onTarget = TRUE;
1494	});
1495
1496	// Define hoverIntent function
1497	function hoverIntent(hoverEvent) {
1498		// Only continue if tooltip isn't disabled
1499		if(this.disabled || this.destroyed) { return FALSE; }
1500
1501		// Cache the event data
1502		this.cache.event = hoverEvent && $.event.fix(hoverEvent);
1503		this.cache.target = hoverEvent && $(hoverEvent.target);
1504
1505		// Start the event sequence
1506		clearTimeout(this.timers.show);
1507		this.timers.show = delay.call(this,
1508			function() { this.render(typeof hoverEvent === 'object' || options.show.ready); },
1509			options.prerender ? 0 : options.show.delay
1510		);
1511	}
1512
1513	// Filter and bind events
1514	this._bindEvents(showEvents, hideEvents, showTarget, hideTarget, hoverIntent, function() {
1515		if(!this.timers) { return FALSE; }
1516		clearTimeout(this.timers.show);
1517	});
1518
1519	// Prerendering is enabled, create tooltip now
1520	if(options.show.ready || options.prerender) { hoverIntent.call(this, event); }
1521};
1522
1523// Event assignment method
1524PROTOTYPE._assignEvents = function() {
1525	var self = this,
1526		options = this.options,
1527		posOptions = options.position,
1528
1529		tooltip = this.tooltip,
1530		showTarget = options.show.target,
1531		hideTarget = options.hide.target,
1532		containerTarget = posOptions.container,
1533		viewportTarget = posOptions.viewport,
1534		documentTarget = $(document),
1535		windowTarget = $(window),
1536
1537		showEvents = options.show.event ? this.trim('' + options.show.event).split(' ') : [],
1538		hideEvents = options.hide.event ? this.trim('' + options.hide.event).split(' ') : [];
1539
1540
1541	// Assign passed event callbacks
1542	$.each(options.events, function(name, callback) {
1543		self._bind(tooltip, name === 'toggle' ? ['tooltipshow','tooltiphide'] : ['tooltip'+name], callback, null, tooltip);
1544	});
1545
1546	// Hide tooltips when leaving current window/frame (but not select/option elements)
1547	if(/mouse(out|leave)/i.test(options.hide.event) && options.hide.leave === 'window') {
1548		this._bind(documentTarget, ['mouseout', 'blur'], function(event) {
1549			if(!/select|option/.test(event.target.nodeName) && !event.relatedTarget) {
1550				this.hide(event);
1551			}
1552		});
1553	}
1554
1555	// Enable hide.fixed by adding appropriate class
1556	if(options.hide.fixed) {
1557		hideTarget = hideTarget.add( tooltip.addClass(CLASS_FIXED) );
1558	}
1559
1560	/*
1561	 * Make sure hoverIntent functions properly by using mouseleave to clear show timer if
1562	 * mouseenter/mouseout is used for show.event, even if it isn't in the users options.
1563	 */
1564	else if(/mouse(over|enter)/i.test(options.show.event)) {
1565		this._bind(hideTarget, 'mouseleave', function() {
1566			clearTimeout(this.timers.show);
1567		});
1568	}
1569
1570	// Hide tooltip on document mousedown if unfocus events are enabled
1571	if(('' + options.hide.event).indexOf('unfocus') > -1) {
1572		this._bind(containerTarget.closest('html'), ['mousedown', 'touchstart'], function(event) {
1573			var elem = $(event.target),
1574				enabled = this.rendered && !this.tooltip.hasClass(CLASS_DISABLED) && this.tooltip[0].offsetWidth > 0,
1575				isAncestor = elem.parents(SELECTOR).filter(this.tooltip[0]).length > 0;
1576
1577			if(elem[0] !== this.target[0] && elem[0] !== this.tooltip[0] && !isAncestor &&
1578				!this.target.has(elem[0]).length && enabled
1579			) {
1580				this.hide(event);
1581			}
1582		});
1583	}
1584
1585	// Check if the tooltip hides when inactive
1586	if('number' === typeof options.hide.inactive) {
1587		// Bind inactive method to show target(s) as a custom event
1588		this._bind(showTarget, 'qtip-'+this.id+'-inactive', inactiveMethod, 'inactive');
1589
1590		// Define events which reset the 'inactive' event handler
1591		this._bind(hideTarget.add(tooltip), QTIP.inactiveEvents, inactiveMethod);
1592	}
1593
1594	// Filter and bind events
1595	this._bindEvents(showEvents, hideEvents, showTarget, hideTarget, showMethod, hideMethod);
1596
1597	// Mouse movement bindings
1598	this._bind(showTarget.add(tooltip), 'mousemove', function(event) {
1599		// Check if the tooltip hides when mouse is moved a certain distance
1600		if('number' === typeof options.hide.distance) {
1601			var origin = this.cache.origin || {},
1602				limit = this.options.hide.distance,
1603				abs = Math.abs;
1604
1605			// Check if the movement has gone beyond the limit, and hide it if so
1606			if(abs(event.pageX - origin.pageX) >= limit || abs(event.pageY - origin.pageY) >= limit) {
1607				this.hide(event);
1608			}
1609		}
1610
1611		// Cache mousemove coords on show targets
1612		this._storeMouse(event);
1613	});
1614
1615	// Mouse positioning events
1616	if(posOptions.target === 'mouse') {
1617		// If mouse adjustment is on...
1618		if(posOptions.adjust.mouse) {
1619			// Apply a mouseleave event so we don't get problems with overlapping
1620			if(options.hide.event) {
1621				// Track if we're on the target or not
1622				this._bind(showTarget, ['mouseenter', 'mouseleave'], function(event) {
1623					if(!this.cache) {return FALSE; }
1624					this.cache.onTarget = event.type === 'mouseenter';
1625				});
1626			}
1627
1628			// Update tooltip position on mousemove
1629			this._bind(documentTarget, 'mousemove', function(event) {
1630				// Update the tooltip position only if the tooltip is visible and adjustment is enabled
1631				if(this.rendered && this.cache.onTarget && !this.tooltip.hasClass(CLASS_DISABLED) && this.tooltip[0].offsetWidth > 0) {
1632					this.reposition(event);
1633				}
1634			});
1635		}
1636	}
1637
1638	// Adjust positions of the tooltip on window resize if enabled
1639	if(posOptions.adjust.resize || viewportTarget.length) {
1640		this._bind( $.event.special.resize ? viewportTarget : windowTarget, 'resize', repositionMethod );
1641	}
1642
1643	// Adjust tooltip position on scroll of the window or viewport element if present
1644	if(posOptions.adjust.scroll) {
1645		this._bind( windowTarget.add(posOptions.container), 'scroll', repositionMethod );
1646	}
1647};
1648
1649// Un-assignment method
1650PROTOTYPE._unassignEvents = function() {
1651	var options = this.options,
1652		showTargets = options.show.target,
1653		hideTargets = options.hide.target,
1654		targets = $.grep([
1655			this.elements.target[0],
1656			this.rendered && this.tooltip[0],
1657			options.position.container[0],
1658			options.position.viewport[0],
1659			options.position.container.closest('html')[0], // unfocus
1660			window,
1661			document
1662		], function(i) {
1663			return typeof i === 'object';
1664		});
1665
1666	// Add show and hide targets if they're valid
1667	if(showTargets && showTargets.toArray) {
1668		targets = targets.concat(showTargets.toArray());
1669	}
1670	if(hideTargets && hideTargets.toArray) {
1671		targets = targets.concat(hideTargets.toArray());
1672	}
1673
1674	// Unbind the events
1675	this._unbind(targets)
1676		._unbind(targets, 'destroy')
1677		._unbind(targets, 'inactive');
1678};
1679
1680// Apply common event handlers using delegate (avoids excessive .bind calls!)
1681$(function() {
1682	delegate(SELECTOR, ['mouseenter', 'mouseleave'], function(event) {
1683		var state = event.type === 'mouseenter',
1684			tooltip = $(event.currentTarget),
1685			target = $(event.relatedTarget || event.target),
1686			options = this.options;
1687
1688		// On mouseenter...
1689		if(state) {
1690			// Focus the tooltip on mouseenter (z-index stacking)
1691			this.focus(event);
1692
1693			// Clear hide timer on tooltip hover to prevent it from closing
1694			tooltip.hasClass(CLASS_FIXED) && !tooltip.hasClass(CLASS_DISABLED) && clearTimeout(this.timers.hide);
1695		}
1696
1697		// On mouseleave...
1698		else {
1699			// When mouse tracking is enabled, hide when we leave the tooltip and not onto the show target (if a hide event is set)
1700			if(options.position.target === 'mouse' && options.position.adjust.mouse &&
1701				options.hide.event && options.show.target && !target.closest(options.show.target[0]).length) {
1702				this.hide(event);
1703			}
1704		}
1705
1706		// Add hover class
1707		tooltip.toggleClass(CLASS_HOVER, state);
1708	});
1709
1710	// Define events which reset the 'inactive' event handler
1711	delegate('['+ATTR_ID+']', INACTIVE_EVENTS, inactiveMethod);
1712});
1713;// Initialization method
1714function init(elem, id, opts) {
1715	var obj, posOptions, attr, config, title,
1716
1717	// Setup element references
1718	docBody = $(document.body),
1719
1720	// Use document body instead of document element if needed
1721	newTarget = elem[0] === document ? docBody : elem,
1722
1723	// Grab metadata from element if plugin is present
1724	metadata = elem.metadata ? elem.metadata(opts.metadata) : NULL,
1725
1726	// If metadata type if HTML5, grab 'name' from the object instead, or use the regular data object otherwise
1727	metadata5 = opts.metadata.type === 'html5' && metadata ? metadata[opts.metadata.name] : NULL,
1728
1729	// Grab data from metadata.name (or data-qtipopts as fallback) using .data() method,
1730	html5 = elem.data(opts.metadata.name || 'qtipopts');
1731
1732	// If we don't get an object returned attempt to parse it manualyl without parseJSON
1733	/* eslint-disable no-empty */
1734	try { html5 = typeof html5 === 'string' ? $.parseJSON(html5) : html5; }
1735	catch(e) {}
1736	/* eslint-enable no-empty */
1737
1738	// Merge in and sanitize metadata
1739	config = $.extend(TRUE, {}, QTIP.defaults, opts,
1740		typeof html5 === 'object' ? sanitizeOptions(html5) : NULL,
1741		sanitizeOptions(metadata5 || metadata));
1742
1743	// Re-grab our positioning options now we've merged our metadata and set id to passed value
1744	posOptions = config.position;
1745	config.id = id;
1746
1747	// Setup missing content if none is detected
1748	if('boolean' === typeof config.content.text) {
1749		attr = elem.attr(config.content.attr);
1750
1751		// Grab from supplied attribute if available
1752		if(config.content.attr !== FALSE && attr) { config.content.text = attr; }
1753
1754		// No valid content was found, abort render
1755		else { return FALSE; }
1756	}
1757
1758	// Setup target options
1759	if(!posOptions.container.length) { posOptions.container = docBody; }
1760	if(posOptions.target === FALSE) { posOptions.target = newTarget; }
1761	if(config.show.target === FALSE) { config.show.target = newTarget; }
1762	if(config.show.solo === TRUE) { config.show.solo = posOptions.container.closest('body'); }
1763	if(config.hide.target === FALSE) { config.hide.target = newTarget; }
1764	if(config.position.viewport === TRUE) { config.position.viewport = posOptions.container; }
1765
1766	// Ensure we only use a single container
1767	posOptions.container = posOptions.container.eq(0);
1768
1769	// Convert position corner values into x and y strings
1770	posOptions.at = new CORNER(posOptions.at, TRUE);
1771	posOptions.my = new CORNER(posOptions.my);
1772
1773	// Destroy previous tooltip if overwrite is enabled, or skip element if not
1774	if(elem.data(NAMESPACE)) {
1775		if(config.overwrite) {
1776			elem.qtip('destroy', true);
1777		}
1778		else if(config.overwrite === FALSE) {
1779			return FALSE;
1780		}
1781	}
1782
1783	// Add has-qtip attribute
1784	elem.attr(ATTR_HAS, id);
1785
1786	// Remove title attribute and store it if present
1787	if(config.suppress && (title = elem.attr('title'))) {
1788		// Final attr call fixes event delegatiom and IE default tooltip showing problem
1789		elem.removeAttr('title').attr(oldtitle, title).attr('title', '');
1790	}
1791
1792	// Initialize the tooltip and add API reference
1793	obj = new QTip(elem, config, id, !!attr);
1794	elem.data(NAMESPACE, obj);
1795
1796	return obj;
1797}
1798
1799// jQuery $.fn extension method
1800QTIP = $.fn.qtip = function(options, notation, newValue)
1801{
1802	var command = ('' + options).toLowerCase(), // Parse command
1803		returned = NULL,
1804		args = $.makeArray(arguments).slice(1),
1805		event = args[args.length - 1],
1806		opts = this[0] ? $.data(this[0], NAMESPACE) : NULL;
1807
1808	// Check for API request
1809	if(!arguments.length && opts || command === 'api') {
1810		return opts;
1811	}
1812
1813	// Execute API command if present
1814	else if('string' === typeof options) {
1815		this.each(function() {
1816			var api = $.data(this, NAMESPACE);
1817			if(!api) { return TRUE; }
1818
1819			// Cache the event if possible
1820			if(event && event.timeStamp) { api.cache.event = event; }
1821
1822			// Check for specific API commands
1823			if(notation && (command === 'option' || command === 'options')) {
1824				if(newValue !== undefined || $.isPlainObject(notation)) {
1825					api.set(notation, newValue);
1826				}
1827				else {
1828					returned = api.get(notation);
1829					return FALSE;
1830				}
1831			}
1832
1833			// Execute API command
1834			else if(api[command]) {
1835				api[command].apply(api, args);
1836			}
1837		});
1838
1839		return returned !== NULL ? returned : this;
1840	}
1841
1842	// No API commands. validate provided options and setup qTips
1843	else if('object' === typeof options || !arguments.length) {
1844		// Sanitize options first
1845		opts = sanitizeOptions($.extend(TRUE, {}, options));
1846
1847		return this.each(function(i) {
1848			var api, id;
1849
1850			// Find next available ID, or use custom ID if provided
1851			id = Array.isArray(opts.id) ? opts.id[i] : opts.id;
1852			id = !id || id === FALSE || id.length < 1 || QTIP.api[id] ? QTIP.nextid++ : id;
1853
1854			// Initialize the qTip and re-grab newly sanitized options
1855			api = init($(this), id, opts);
1856			if(api === FALSE) { return TRUE; }
1857			else { QTIP.api[id] = api; }
1858
1859			// Initialize plugins
1860			$.each(PLUGINS, function() {
1861				if(this.initialize === 'initialize') { this(api); }
1862			});
1863
1864			// Assign initial pre-render events
1865			api._assignInitialEvents(event);
1866		});
1867	}
1868};
1869
1870// Expose class
1871$.qtip = QTip;
1872
1873// Populated in render method
1874QTIP.api = {};
1875;$.each({
1876	/* Allow other plugins to successfully retrieve the title of an element with a qTip applied */
1877	attr: function(attr, val) {
1878		if(this.length) {
1879			var self = this[0],
1880				title = 'title',
1881				api = $.data(self, 'qtip');
1882
1883			if(attr === title && api && api.options && 'object' === typeof api && 'object' === typeof api.options && api.options.suppress) {
1884				if(arguments.length < 2) {
1885					return $.attr(self, oldtitle);
1886				}
1887
1888				// If qTip is rendered and title was originally used as content, update it
1889				if(api && api.options.content.attr === title && api.cache.attr) {
1890					api.set('content.text', val);
1891				}
1892
1893				// Use the regular attr method to set, then cache the result
1894				return this.attr(oldtitle, val);
1895			}
1896		}
1897
1898		return $.fn['attr'+replaceSuffix].apply(this, arguments);
1899	},
1900
1901	/* Allow clone to correctly retrieve cached title attributes */
1902	clone: function(keepData) {
1903		// Clone our element using the real clone method
1904		var elems = $.fn['clone'+replaceSuffix].apply(this, arguments);
1905
1906		// Grab all elements with an oldtitle set, and change it to regular title attribute, if keepData is false
1907		if(!keepData) {
1908			elems.filter('['+oldtitle+']').attr('title', function() {
1909				return $.attr(this, oldtitle);
1910			})
1911			.removeAttr(oldtitle);
1912		}
1913
1914		return elems;
1915	}
1916}, function(name, func) {
1917	if(!func || $.fn[name+replaceSuffix]) { return TRUE; }
1918
1919	var old = $.fn[name+replaceSuffix] = $.fn[name];
1920	$.fn[name] = function() {
1921		return func.apply(this, arguments) || old.apply(this, arguments);
1922	};
1923});
1924
1925/* Fire off 'removeqtip' handler in $.cleanData if jQuery UI not present (it already does similar).
1926 * This snippet is taken directly from jQuery UI source code found here:
1927 *     http://code.jquery.com/ui/jquery-ui-git.js
1928 */
1929if(!$.ui) {
1930	$['cleanData'+replaceSuffix] = $.cleanData;
1931	$.cleanData = function( elems ) {
1932		for(var i = 0, elem; (elem = $( elems[i] )).length; i++) {
1933			if(elem.attr(ATTR_HAS)) {
1934				/* eslint-disable no-empty */
1935				try { elem.triggerHandler('removeqtip'); }
1936				catch( e ) {}
1937				/* eslint-enable no-empty */
1938			}
1939		}
1940		$['cleanData'+replaceSuffix].apply(this, arguments);
1941	};
1942}
1943;// qTip version
1944QTIP.version = '3.0.3';
1945
1946// Base ID for all qTips
1947QTIP.nextid = 0;
1948
1949// Inactive events array
1950QTIP.inactiveEvents = INACTIVE_EVENTS;
1951
1952// Base z-index for all qTips
1953QTIP.zindex = 15000;
1954
1955// Define configuration defaults
1956QTIP.defaults = {
1957	prerender: FALSE,
1958	id: FALSE,
1959	overwrite: TRUE,
1960	suppress: TRUE,
1961	content: {
1962		text: TRUE,
1963		attr: 'title',
1964		title: FALSE,
1965		button: FALSE
1966	},
1967	position: {
vendor: 4,761 bytes, lines 1968-2123
1968		my: 'top left',
1969		at: 'bottom right',
1970		target: FALSE,
1971		container: FALSE,
1972		viewport: FALSE,
1973		adjust: {
1974			x: 0, y: 0,
1975			mouse: TRUE,
1976			scroll: TRUE,
1977			resize: TRUE,
1978			method: 'flipinvert flipinvert'
1979		},
1980		effect: function(api, pos) {
1981			$(this).animate(pos, {
1982				duration: 200,
1983				queue: FALSE
1984			});
1985		}
1986	},
1987	show: {
1988		target: FALSE,
1989		event: 'mouseenter',
1990		effect: TRUE,
1991		delay: 90,
1992		solo: FALSE,
1993		ready: FALSE,
1994		autofocus: FALSE
1995	},
1996	hide: {
1997		target: FALSE,
1998		event: 'mouseleave',
1999		effect: TRUE,
2000		delay: 0,
2001		fixed: FALSE,
2002		inactive: FALSE,
2003		leave: 'window',
2004		distance: FALSE
2005	},
2006	style: {
2007		classes: '',
2008		widget: FALSE,
2009		width: FALSE,
2010		height: FALSE,
2011		def: TRUE
2012	},
2013	events: {
2014		render: NULL,
2015		move: NULL,
2016		show: NULL,
2017		hide: NULL,
2018		toggle: NULL,
2019		visible: NULL,
2020		hidden: NULL,
2021		focus: NULL,
2022		blur: NULL
2023	}
2024};
2025;PLUGINS.viewport = function(api, position, posOptions, targetWidth, targetHeight, elemWidth, elemHeight)
2026{
2027	var target = posOptions.target,
2028		tooltip = api.elements.tooltip,
2029		my = posOptions.my,
2030		at = posOptions.at,
2031		adjust = posOptions.adjust,
2032		method = adjust.method.split(' '),
2033		methodX = method[0],
2034		methodY = method[1] || method[0],
2035		viewport = posOptions.viewport,
2036		container = posOptions.container,
2037		adjusted = { left: 0, top: 0 },
2038		fixed, newMy, containerOffset, containerStatic,
2039		viewportWidth, viewportHeight, viewportScroll, viewportOffset;
2040
2041	// If viewport is not a jQuery element, or it's the window/document, or no adjustment method is used... return
2042	if(!viewport.jquery || target[0] === window || target[0] === document.body || adjust.method === 'none') {
2043		return adjusted;
2044	}
2045
2046	// Cach container details
2047	containerOffset = container.offset() || adjusted;
2048	containerStatic = container.css('position') === 'static';
2049
2050	// Cache our viewport details
2051	fixed = tooltip.css('position') === 'fixed';
2052	viewportWidth = viewport[0] === window ? viewport.width() : viewport.outerWidth(FALSE);
2053	viewportHeight = viewport[0] === window ? viewport.height() : viewport.outerHeight(FALSE);
2054	viewportScroll = { left: fixed ? 0 : viewport.scrollLeft(), top: fixed ? 0 : viewport.scrollTop() };
2055	viewportOffset = viewport.offset() || adjusted;
2056
2057	// Generic calculation method
2058	function calculate(side, otherSide, type, adjustment, side1, side2, lengthName, targetLength, elemLength) {
2059		var initialPos = position[side1],
2060			mySide = my[side],
2061			atSide = at[side],
2062			isShift = type === SHIFT,
2063			myLength = mySide === side1 ? elemLength : mySide === side2 ? -elemLength : -elemLength / 2,
2064			atLength = atSide === side1 ? targetLength : atSide === side2 ? -targetLength : -targetLength / 2,
2065			sideOffset = viewportScroll[side1] + viewportOffset[side1] - (containerStatic ? 0 : containerOffset[side1]),
2066			overflow1 = sideOffset - initialPos,
2067			overflow2 = initialPos + elemLength - (lengthName === WIDTH ? viewportWidth : viewportHeight) - sideOffset,
2068			offset = myLength - (my.precedance === side || mySide === my[otherSide] ? atLength : 0) - (atSide === CENTER ? targetLength / 2 : 0);
2069
2070		// shift
2071		if(isShift) {
2072			offset = (mySide === side1 ? 1 : -1) * myLength;
2073
2074			// Adjust position but keep it within viewport dimensions
2075			position[side1] += overflow1 > 0 ? overflow1 : overflow2 > 0 ? -overflow2 : 0;
2076			position[side1] = Math.max(
2077				-containerOffset[side1] + viewportOffset[side1],
2078				initialPos - offset,
2079				Math.min(
2080					Math.max(
2081						-containerOffset[side1] + viewportOffset[side1] + (lengthName === WIDTH ? viewportWidth : viewportHeight),
2082						initialPos + offset
2083					),
2084					position[side1],
2085
2086					// Make sure we don't adjust complete off the element when using 'center'
2087					mySide === 'center' ? initialPos - myLength : 1E9
2088				)
2089			);
2090
2091		}
2092
2093		// flip/flipinvert
2094		else {
2095			// Update adjustment amount depending on if using flipinvert or flip
2096			adjustment *= type === FLIPINVERT ? 2 : 0;
2097
2098			// Check for overflow on the left/top
2099			if(overflow1 > 0 && (mySide !== side1 || overflow2 > 0)) {
2100				position[side1] -= offset + adjustment;
2101				newMy.invert(side, side1);
2102			}
2103
2104			// Check for overflow on the bottom/right
2105			else if(overflow2 > 0 && (mySide !== side2 || overflow1 > 0)  ) {
2106				position[side1] -= (mySide === CENTER ? -offset : offset) + adjustment;
2107				newMy.invert(side, side2);
2108			}
2109
2110			// Make sure we haven't made things worse with the adjustment and reset if so
2111			if(position[side1] < viewportScroll[side1] && -position[side1] > overflow2) {
2112				position[side1] = initialPos; newMy = my.clone();
2113			}
2114		}
2115
2116		return position[side1] - initialPos;
2117	}
2118
2119	// Set newMy if using flip or flipinvert methods
2120	if(methodX !== 'shift' || methodY !== 'shift') { newMy = my.clone(); }
2121
2122	// Adjust position based onviewport and adjustment options
2123	adjusted = {
2124		left: methodX !== 'none' ? calculate( X, Y, methodX, adjust.x, LEFT, RIGHT, WIDTH, targetWidth, elemWidth ) : 0,
2125		top: methodY !== 'none' ? calculate( Y, X, methodY, adjust.y, TOP, BOTTOM, HEIGHT, targetHeight, elemHeight ) : 0,
2126		my: newMy
2127	};
2128
2129	return adjusted;
2130};
2131;}));
2132}( window, document ));

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.