PageSourceSearch

https://dih-squared.eu/sites/all/themes/aurum/js/pi.tooltip.js?sf803x

js dih-squared.eu collected 2026-10-04 02:34:54 UTC 12,316 bytes, 396 lines download raw bytes

vendor: 12,316 bytes, lines 1-396
1/* Aura version: 1.8.5 */�
2
3/* ========================================================================�
4 * PI: pi.tooltip.js v1.0.0�
5 * based on: bootstrap v3.0.0 toltip�
6 * http://twbs.github.com/bootstrap/javascript.html#tooltip�
7 * Inspired by the original jQuery.tipsy by Jason Frame�
8 * ========================================================================�
9 *�
10 * Licensed under the Apache License, Version 2.0 (the "License");�
11 * you may not use this file except in compliance with the License.�
12 * You may obtain a copy of the License at�
13 *�
14 * http://www.apache.org/licenses/LICENSE-2.0�
15 *�
16 * Unless required by applicable law or agreed to in writing, software�
17 * distributed under the License is distributed on an "AS IS" BASIS,�
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.�
19 * See the License for the specific language governing permissions and�
20 * limitations under the License.�
21 * ======================================================================== */�
22�
23�
24(function ($) { "use strict";�
25�
26	// TOOLTIP PUBLIC CLASS DEFINITION�
27	// ===============================�
28�
29	var Tooltip = function (element, options) {�
30		this.type       =�
31			this.options    =�
32				this.enabled    =�
33					this.timeout    =�
34						this.hoverState =�
35							this.$element   = null�
36�
37		this.init('tooltip', element, options)�
38	}�
39�
40	Tooltip.DEFAULTS = {�
41		animation: true�
42		, placement: 'top'�
43		, selector: false�
44		, template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'�
45		, trigger: 'hover focus'�
46		, title: ''�
47		, delay: 0�
48		, html: false�
49		, container: false�
50		, size: 'default'�
51	}�
52�
53	Tooltip.prototype.init = function (type, element, options) {�
54		this.enabled  = true�
55		this.type     = type�
56		this.$element = $(element)�
57		this.options  = this.getOptions(options)�
58�
59		var triggers = this.options.trigger.split(' ')�
60�
61		for (var i = triggers.length; i--;) {�
62			var trigger = triggers[i]�
63�
64			if (trigger == 'click') {�
65				this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))�
66			} else if (trigger != 'manual') {�
67				var eventIn  = trigger == 'hover' ? 'mouseenter' : 'focus'�
68				var eventOut = trigger == 'hover' ? 'mouseleave' : 'blur'�
69�
70				this.$element.on(eventIn  + '.' + this.type, this.options.selector, $.proxy(this.enter, this))�
71				this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))�
72			}�
73		}�
74�
75		this.options.selector ?�
76			(this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :�
77			this.fixTitle()�
78	}�
79�
80	Tooltip.prototype.getDefaults = function () {�
81		return Tooltip.DEFAULTS�
82	}�
83�
84	Tooltip.prototype.getOptions = function (options) {�
85		options = $.extend({}, this.getDefaults(), this.$element.data(), options)�
86�
87		if (options.delay && typeof options.delay == 'number') {�
88			options.delay = {�
89				show: options.delay�
90				, hide: options.delay�
91			}�
92		}�
93�
94		return options�
95	}�
96�
97	Tooltip.prototype.getDelegateOptions = function () {�
98		var options  = {}�
99		var defaults = this.getDefaults()�
100�
101		this._options && $.each(this._options, function (key, value) {�
102			if (defaults[key] != value) options[key] = value�
103		})�
104�
105		return options�
106	}�
107�
108	Tooltip.prototype.enter = function (obj) {�
109		var self = obj instanceof this.constructor ?�
110			obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type)�
111�
112		clearTimeout(self.timeout)�
113�
114		self.hoverState = 'in'�
115�
116		if (!self.options.delay || !self.options.delay.show) return self.show()�
117�
118		self.timeout = setTimeout(function () {�
119			if (self.hoverState == 'in') self.show()�
120		}, self.options.delay.show)�
121	}�
122�
123	Tooltip.prototype.leave = function (obj) {�
124		var self = obj instanceof this.constructor ?�
125			obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type)�
126�
127		clearTimeout(self.timeout)�
128�
129		self.hoverState = 'out'�
130�
131		if (!self.options.delay || !self.options.delay.hide) return self.hide()�
132�
133		self.timeout = setTimeout(function () {�
134			if (self.hoverState == 'out') self.hide()�
135		}, self.options.delay.hide)�
136	}�
137�
138	Tooltip.prototype.show = function () {�
139		var e = $.Event('show.bs.'+ this.type)�
140�
141		if (this.hasContent() && this.enabled) {�
142			this.$element.trigger(e)�
143�
144			if (e.isDefaultPrevented()) return�
145�
146			var $tip = this.tip()�
147�
148			this.setContent()�
149			this.setSize()�
150�
151			if (this.options.animation) $tip.addClass('fade')�
152�
153			var placement = typeof this.options.placement == 'function' ?�
154				this.options.placement.call(this, $tip[0], this.$element[0]) :�
155				this.options.placement�
156�
157			var autoToken = /\s?auto?\s?/i�
158			var autoPlace = autoToken.test(placement)�
159			if (autoPlace) placement = placement.replace(autoToken, '') || 'top'�
160�
161			$tip�
162				.detach()�
163				.css({ top: 0, left: 0, display: 'block' })�
164				.addClass(placement)�
165�
166			this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)�
167�
168			var pos          = this.getPosition()�
169			var actualWidth  = $tip[0].offsetWidth�
170			var actualHeight = $tip[0].offsetHeight�
171�
172			if (autoPlace) {�
173				var $parent = this.$element.parent()�
174�
175				var orgPlacement = placement�
176				var docScroll    = document.documentElement.scrollTop || document.body.scrollTop�
177				var parentWidth  = this.options.container == 'body' ? window.innerWidth  : $parent.outerWidth()�
178				var parentHeight = this.options.container == 'body' ? window.innerHeight : $parent.outerHeight()�
179				var parentLeft   = this.options.container == 'body' ? 0 : $parent.offset().left�
180�
181				placement = placement == 'bottom' && pos.top   + pos.height  + actualHeight - docScroll > parentHeight  ? 'top'    :�
182					placement == 'top'    && pos.top   - docScroll   - actualHeight < 0                         ? 'bottom' :�
183						placement == 'right'  && pos.right + actualWidth > parentWidth                              ? 'left'   :�
184							placement == 'left'   && pos.left  - actualWidth < parentLeft                               ? 'right'  :�
185								placement�
186�
187				$tip�
188					.removeClass(orgPlacement)�
189					.addClass(placement)�
190			}�
191�
192			var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)�
193�
194			this.applyPlacement(calculatedOffset, placement)�
195			this.$element.trigger('shown.bs.' + this.type)�
196		}�
197	}�
198�
199	Tooltip.prototype.applyPlacement = function(offset, placement) {�
200		var replace�
201		var $tip   = this.tip()�
202		var width  = $tip[0].offsetWidth�
203		var height = $tip[0].offsetHeight�
204�
205		// manually read margins because getBoundingClientRect includes difference�
206		var marginTop = parseInt($tip.css('margin-top'), 10)�
207		var marginLeft = parseInt($tip.css('margin-left'), 10)�
208�
209		// we must check for NaN for ie 8/9�
210		if (isNaN(marginTop))  marginTop  = 0�
211		if (isNaN(marginLeft)) marginLeft = 0�
212�
213		offset.top  = offset.top  + marginTop�
214		offset.left = offset.left + marginLeft�
215�
216		$tip�
217			.offset(offset)�
218			.addClass('in')�
219�
220		// check to see if placing tip in new offset caused the tip to resize itself�
221		var actualWidth  = $tip[0].offsetWidth�
222		var actualHeight = $tip[0].offsetHeight�
223�
224		if (placement == 'top' && actualHeight != height) {�
225			replace = true�
226			offset.top = offset.top + height - actualHeight�
227		}�
228�
229		if (/bottom|top/.test(placement)) {�
230			var delta = 0�
231�
232			if (offset.left < 0) {�
233				delta       = offset.left * -2�
234				offset.left = 0�
235�
236				$tip.offset(offset)�
237�
238				actualWidth  = $tip[0].offsetWidth�
239				actualHeight = $tip[0].offsetHeight�
240			}�
241�
242			this.replaceArrow(delta - width + actualWidth, actualWidth, 'left')�
243		} else {�
244			this.replaceArrow(actualHeight - height, actualHeight, 'top')�
245		}�
246�
247		if (replace) $tip.offset(offset)�
248	}�
249�
250	Tooltip.prototype.replaceArrow = function(delta, dimension, position) {�
251		this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')�
252	}�
253�
254	Tooltip.prototype.setContent = function () {�
255		var $tip  = this.tip()�
256		var title = this.getTitle()�
257�
258		$tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)�
259		$tip.removeClass('fade in top bottom left right')�
260	}�
261�
262	Tooltip.prototype.setSize = function () {�
263		if(this.options.size != 'default'){�
264			this.tip().addClass('tooltip-' + this.options.size);�
265		}�
266	}�
267�
268	Tooltip.prototype.hide = function () {�
269		var that = this�
270		var $tip = this.tip()�
271		var e    = $.Event('hide.bs.' + this.type)�
272�
273		function complete() {�
274			if (that.hoverState != 'in') $tip.detach()�
275		}�
276�
277		this.$element.trigger(e)�
278�
279		if (e.isDefaultPrevented()) return�
280�
281		$tip.removeClass('in')�
282�
283		$.support.transition && this.$tip.hasClass('fade') ?�
284			$tip�
285				.one($.support.transition.end, complete)�
286				.emulateTransitionEnd(150) :�
287			complete()�
288�
289		this.$element.trigger('hidden.bs.' + this.type)�
290�
291		return this�
292	}�
293�
294	Tooltip.prototype.fixTitle = function () {�
295		var $e = this.$element�
296		if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {�
297			$e.attr('data-original-title', $e.attr('title') || '').attr('title', '')�
298		}�
299	}�
300�
301	Tooltip.prototype.hasContent = function () {�
302		return this.getTitle()�
303	}�
304�
305	Tooltip.prototype.getPosition = function () {�
306		var el = this.$element[0]�
307		return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {�
308			width: el.offsetWidth�
309			, height: el.offsetHeight�
310		}, this.$element.offset())�
311	}�
312�
313	Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {�
314		return placement == 'bottom' ? { top: pos.top + pos.height,   left: pos.left + pos.width / 2 - actualWidth / 2  } :�
315			placement == 'top'    ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2  } :�
316				placement == 'left'   ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :�
317					/* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width   }�
318	}�
319�
320	Tooltip.prototype.getTitle = function () {�
321		var title�
322		var $e = this.$element�
323		var o  = this.options�
324�
325		title = $e.attr('data-original-title')�
326			|| (typeof o.title == 'function' ? o.title.call($e[0]) :  o.title)�
327�
328		return title�
329	}�
330�
331	Tooltip.prototype.tip = function () {�
332		return this.$tip = this.$tip || $(this.options.template)�
333	}�
334�
335	Tooltip.prototype.arrow = function () {�
336		return this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow')�
337	}�
338�
339	Tooltip.prototype.validate = function () {�
340		if (!this.$element[0].parentNode) {�
341			this.hide()�
342			this.$element = null�
343			this.options  = null�
344		}�
345	}�
346�
347	Tooltip.prototype.enable = function () {�
348		this.enabled = true�
349	}�
350�
351	Tooltip.prototype.disable = function () {�
352		this.enabled = false�
353	}�
354�
355	Tooltip.prototype.toggleEnabled = function () {�
356		this.enabled = !this.enabled�
357	}�
358�
359	Tooltip.prototype.toggle = function (e) {�
360		var self = e ? $(e.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type) : this�
361		self.tip().hasClass('in') ? self.leave(self) : self.enter(self)�
362	}�
363�
364	Tooltip.prototype.destroy = function () {�
365		this.hide().$element.off('.' + this.type).removeData('bs.' + this.type)�
366	}�
367�
368�
369	// TOOLTIP PLUGIN DEFINITION�
370	// =========================�
371�
372	var old = $.fn.tooltip�
373�
374	$.fn.tooltip = function (option) {�
375		return this.each(function () {�
376			var $this   = $(this)�
377			var data    = $this.data('bs.tooltip')�
378			var options = typeof option == 'object' && option�
379�
380			if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))�
381			if (typeof option == 'string') data[option]()�
382		})�
383	}�
384�
385	$.fn.tooltip.Constructor = Tooltip�
386�
387�
388	// TOOLTIP NO CONFLICT�
389	// ===================�
390�
391	$.fn.tooltip.noConflict = function () {�
392		$.fn.tooltip = old�
393		return this�
394	}�
395�
396})(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.