PageSourceSearch

https://static.olacio.com/js/popover.js

js olacio.com collected 2026-10-02 15:21:20 UTC 18,777 bytes, 544 lines download raw bytes

vendor: 15,301 bytes, lines 1-434
1// delay hover
2
3(function($){
4    $.fn.hoverDelay = function(options){
5        var defaults = {
6            hoverDuring: 200,
7            outDuring: 200,
8            hoverEvent: function(){
9                $.noop();
10            },
11            outEvent: function(){
12                $.noop();
13            }
14        };
15        var sets = $.extend(defaults,options || {});
16        var hoverTimer, outTimer, that = this;
17        return $(this).each(function(){
18            $(this).hover(function(){
19                var arr = [$(this)];
20                clearTimeout(outTimer);
21                hoverTimer = setTimeout(function(){sets.hoverEvent.apply(that, arr)}, sets.hoverDuring);
22            },function(){
23                var arr = [$(this)];
24                clearTimeout(hoverTimer);
25                outTimer = setTimeout(function(){sets.outEvent.apply(that, arr)}, sets.outDuring);
26            });
27        });
28    }
29})(jQuery);
30
31
32/* ========================================================================
33 * Bootstrap: tooltip.js v3.0.3
34 * http://getbootstrap.com/javascript/#tooltip
35 * Inspired by the original jQuery.tipsy by Jason Frame
36 * ========================================================================
37 * Copyright 2013 Twitter, Inc.
38 *
39 * Licensed under the Apache License, Version 2.0 (the "License");
40 * you may not use this file except in compliance with the License.
41 * You may obtain a copy of the License at
42 *
43 * http://www.apache.org/licenses/LICENSE-2.0
44 *
45 * Unless required by applicable law or agreed to in writing, software
46 * distributed under the License is distributed on an "AS IS" BASIS,
47 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
48 * See the License for the specific language governing permissions and
49 * limitations under the License.
50 * ======================================================================== */
51
52
53+function ($) { "use strict";
54
55    // TOOLTIP PUBLIC CLASS DEFINITION
56    // ===============================
57
58    var Tooltip = function (element, options) {
59        this.type       =
60            this.options    =
61                this.enabled    =
62                    this.timeout    =
63                        this.hoverState =
64                            this.$element   = null
65
66        this.init('tooltip', element, options)
67    }
68
69    Tooltip.DEFAULTS = {
70        animation: true
71        , placement: 'top'
72        , selector: false
73        , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
74        , trigger: 'hover focus'
75        , title: ''
76        , delay: 0
77        , html: false
78        , container: false
79        , mouseenterSelector : ''
80        , mouseleaveSelector : ''
81    }
82
83    Tooltip.prototype.init = function (type, element, options) {
84        this.enabled  = true
85        this.type     = type
86        this.$element = $(element)
87        this.options  = this.getOptions(options)
88
89        var triggers = this.options.trigger.split(' ')
90
91        for (var i = triggers.length; i--;) {
92            var trigger = triggers[i]
93
94            if (trigger == 'click') {
95                this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
96            } else if (trigger != 'manual') {
97                var eventIn  = trigger == 'hover' ? 'mouseenter' : 'focus'
98                var eventOut = trigger == 'hover' ? 'mouseleave' : 'blur'
99
100                this.$element.on(eventIn  + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
101                this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
102            }
103            else if(trigger == 'manual'){
104                // maual config on event selector
105                this.$element.on( 'mouseenter.' + this.type, this.options.mouseenterSelector, $.proxy(this.enter, this))
106                this.$element.on( 'mouseleave.' + this.type, this.options.mouseleaveSelector, $.proxy(this.leave, this))
107            }
108
109
110        }
111
112        this.options.selector ?
113            (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
114            this.fixTitle()
115    }
116
117    Tooltip.prototype.getDefaults = function () {
118        return Tooltip.DEFAULTS
119    }
120
121    Tooltip.prototype.getOptions = function (options) {
122        options = $.extend({}, this.getDefaults(), this.$element.data(), options)
123
124        if (options.delay && typeof options.delay == 'number') {
125            options.delay = {
126                show: options.delay
127                , hide: options.delay
128            }
129        }
130
131        return options
132    }
133
134    Tooltip.prototype.getDelegateOptions = function () {
135        var options  = {}
136        var defaults = this.getDefaults()
137
138        this._options && $.each(this._options, function (key, value) {
139            if (defaults[key] != value) options[key] = value
140        })
141
142        return options
143    }
144
145    Tooltip.prototype.enter = function (obj) {
146        var self = obj instanceof this.constructor ?
147            obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type)
148
149        clearTimeout(self.timeout)
150
151        self.hoverState = 'in'
152
153        if (!self.options.delay || !self.options.delay.show) return self.show()
154
155        self.timeout = setTimeout(function () {
156            if (self.hoverState == 'in') self.show()
157        }, self.options.delay.show)
158    }
159
160    Tooltip.prototype.leave = function (obj) {
161        var self = obj instanceof this.constructor ?
162            obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type)
163
164        clearTimeout(self.timeout)
165
166        self.hoverState = 'out'
167
168        if (!self.options.delay || !self.options.delay.hide) return self.hide()
169
170        self.timeout = setTimeout(function () {
171            if (self.hoverState == 'out') self.hide()
172        }, self.options.delay.hide)
173    }
174
175    Tooltip.prototype.show = function () {
176        var e = $.Event('show.bs.'+ this.type)
177
178        if (this.hasContent() && this.enabled) {
179            this.$element.trigger(e)
180
181            if (e.isDefaultPrevented()) return
182
183            var $tip = this.tip()
184
185            this.setContent()
186
187            if (this.options.animation) $tip.addClass('fade')
188
189            var placement = typeof this.options.placement == 'function' ?
190                this.options.placement.call(this, $tip[0], this.$element[0]) :
191                this.options.placement
192
193            var autoToken = /\s?auto?\s?/i
194            var autoPlace = autoToken.test(placement)
195            if (autoPlace) placement = placement.replace(autoToken, '') || 'top'
196
197            $tip
198                .detach()
199                .css({ top: 0, left: 0, display: 'block' })
200                .addClass(placement)
201
202            this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
203
204            var pos          = this.getPosition()
205            var actualWidth  = $tip[0].offsetWidth
206            var actualHeight = $tip[0].offsetHeight
207
208            if (autoPlace) {
209                var $parent = this.$element.parent()
210
211                var orgPlacement = placement
212                var docScroll    = document.documentElement.scrollTop || document.body.scrollTop
213                var parentWidth  = this.options.container == 'body' ? window.innerWidth  : $parent.outerWidth()
214                var parentHeight = this.options.container == 'body' ? window.innerHeight : $parent.outerHeight()
215                var parentLeft   = this.options.container == 'body' ? 0 : $parent.offset().left
216
217                placement = placement == 'bottom' && pos.top   + pos.height  + actualHeight - docScroll > parentHeight  ? 'top'    :
218                    placement == 'top'    && pos.top   - docScroll   - actualHeight < 0                         ? 'bottom' :
219                        placement == 'right'  && pos.right + actualWidth > parentWidth                              ? 'left'   :
220                            placement == 'left'   && pos.left  - actualWidth < parentLeft                               ? 'right'  :
221                                placement
222
223                $tip
224                    .removeClass(orgPlacement)
225                    .addClass(placement)
226            }
227
228            var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
229
230            this.applyPlacement(calculatedOffset, placement)
231            this.$element.trigger('shown.bs.' + this.type)
232        }
233    }
234
235    Tooltip.prototype.applyPlacement = function(offset, placement) {
236        var replace
237        var $tip   = this.tip()
238        var width  = $tip[0].offsetWidth
239        var height = $tip[0].offsetHeight
240
241        // manually read margins because getBoundingClientRect includes difference
242        var marginTop = parseInt($tip.css('margin-top'), 10)
243        var marginLeft = parseInt($tip.css('margin-left'), 10)
244
245        // we must check for NaN for ie 8/9
246        if (isNaN(marginTop))  marginTop  = 0
247        if (isNaN(marginLeft)) marginLeft = 0
248
249        offset.top  = offset.top  + marginTop
250        offset.left = offset.left + marginLeft
251
252        $tip
253            .offset(offset)
254            .addClass('in')
255
256        // check to see if placing tip in new offset caused the tip to resize itself
257        var actualWidth  = $tip[0].offsetWidth
258        var actualHeight = $tip[0].offsetHeight
259
260        if (placement == 'top' && actualHeight != height) {
261            replace = true
262            offset.top = offset.top + height - actualHeight
263        }
264
265        if (/bottom|top/.test(placement)) {
266            var delta = 0
267
268            if (offset.left < 0) {
269                delta       = offset.left * -2
270                offset.left = 0
271
272                $tip.offset(offset)
273
274                actualWidth  = $tip[0].offsetWidth
275                actualHeight = $tip[0].offsetHeight
276            }
277
278            this.replaceArrow(delta - width + actualWidth, actualWidth, 'left')
279        } else {
280            this.replaceArrow(actualHeight - height, actualHeight, 'top')
281        }
282
283        if (replace) $tip.offset(offset)
284    }
285
286    Tooltip.prototype.replaceArrow = function(delta, dimension, position) {
287        this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
288    }
289
290    Tooltip.prototype.setContent = function () {
291        var $tip  = this.tip()
292        var title = this.getTitle()
293
294        $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
295        $tip.removeClass('fade in top bottom left right')
296    }
297
298    Tooltip.prototype.hide = function () {
299        var that = this
300        var $tip = this.tip()
301        var e    = $.Event('hide.bs.' + this.type)
302
303        function complete() {
304            if (that.hoverState != 'in') $tip.detach()
305        }
306
307        this.$element.trigger(e)
308
309        if (e.isDefaultPrevented()) return
310
311        $tip.removeClass('in')
312
313        $.support.transition && this.$tip.hasClass('fade') ?
314            $tip
315                .one($.support.transition.end, complete)
316                .emulateTransitionEnd(150) :
317            complete()
318
319        this.$element.trigger('hidden.bs.' + this.type)
320
321        return this
322    }
323
324    Tooltip.prototype.fixTitle = function () {
325        var $e = this.$element
326        if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
327            $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
328        }
329    }
330
331    Tooltip.prototype.hasContent = function () {
332        return this.getTitle()
333    }
334
335    Tooltip.prototype.getPosition = function () {
336        var el = this.$element[0]
337        return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {
338            width: el.offsetWidth
339            , height: el.offsetHeight
340        }, this.$element.offset())
341    }
342
343    Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
344        return placement == 'bottom' ? { top: pos.top + pos.height,   left: pos.left + pos.width / 2 - actualWidth / 2  } :
345            placement == 'top'    ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2  } :
346                placement == 'left'   ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
347                    /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width   }
348    }
349
350    Tooltip.prototype.getTitle = function () {
351        var title
352        var $e = this.$element
353        var o  = this.options
354
355        title = $e.attr('data-original-title')
356            || (typeof o.title == 'function' ? o.title.call($e[0]) :  o.title)
357
358        return title
359    }
360
361    Tooltip.prototype.tip = function () {
362        return this.$tip = this.$tip || $(this.options.template)
363    }
364
365    Tooltip.prototype.arrow = function () {
366        return this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow')
367    }
368
369    Tooltip.prototype.validate = function () {
370        if (!this.$element[0].parentNode) {
371            this.hide()
372            this.$element = null
373            this.options  = null
374        }
375    }
376
377    Tooltip.prototype.enable = function () {
378        this.enabled = true
379    }
380
381    Tooltip.prototype.disable = function () {
382        this.enabled = false
383    }
384
385    Tooltip.prototype.toggleEnabled = function () {
386        this.enabled = !this.enabled
387    }
388
389    Tooltip.prototype.toggle = function (e) {
390        var self = e ? $(e.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type) : this
391        self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
392    }
393
394    Tooltip.prototype.destroy = function () {
395        this.hide().$element.off('.' + this.type).removeData('bs.' + this.type)
396    }
397
398
399    // TOOLTIP PLUGIN DEFINITION
400    // =========================
401
402    var old = $.fn.tooltip
403
404    $.fn.tooltip = function (option) {
405        return this.each(function () {
406            var $this   = $(this)
407            var data    = $this.data('bs.tooltip')
408            var options = typeof option == 'object' && option
409
410            if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
411            if (typeof option == 'string') data[option]()
412        })
413    }
414
415    $.fn.tooltip.Constructor = Tooltip
416
417
418    // TOOLTIP NO CONFLICT
419    // ===================
420
421    $.fn.tooltip.noConflict = function () {
422        $.fn.tooltip = old
423        return this
424    }
425
426}(jQuery);
427
428/* ========================================================================
429 * Bootstrap: popover.js v3.0.3
430 * http://getbootstrap.com/javascript/#popovers
431 * ========================================================================
432 * Copyright 2013 Twitter, Inc.
433 *
434 * Licensed under the Apache License, Version 2.0 (the "License");
435 * you may not use this file except in compliance with the License.
436 * You may obtain a copy of the License at
437 *
438 * http://www.apache.org/licenses/LICENSE-2.0
439 *
440 * Unless required by applicable law or agreed to in writing, software
441 * distributed under the License is distributed on an "AS IS" BASIS,
442 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
443 * See the License for the specific language governing permissions and
444 * limitations under the License.
445 * ======================================================================== */
446
447
448+function ($) { "use strict";
449
450    // POPOVER PUBLIC CLASS DEFINITION
451    // ===============================
452
453    var Popover = function (element, options) {
454        this.init('popover', element, options)
455    }
456
457    if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
458
459    Popover.DEFAULTS = $.extend({} , $.fn.tooltip.Constructor.DEFAULTS, {
460        placement: 'right'
461        , trigger: 'click'
462        , content: ''
463        , template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
464    })
465
466
467    // NOTE: POPOVER EXTENDS tooltip.js
468    // ================================
469
470    Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)
471
472    Popover.prototype.constructor = Popover
473
474    Popover.prototype.getDefaults = function () {
475        return Popover.DEFAULTS
476    }
477
478    Popover.prototype.setContent = function () {
479        var $tip    = this.tip()
480        var title   = this.getTitle()
481        var content = this.getContent()
482
483        $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
484        $tip.find('.popover-content')[this.options.html ? 'html' : 'text'](content)
485
486        $tip.removeClass('fade top bottom left right in')
487
488        // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
489        // this manually by checking the contents.
490        if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide()
491    }
492
493    Popover.prototype.hasContent = function () {
494        return this.getTitle() || this.getContent()
495    }
496
497    Popover.prototype.getContent = function () {
498        var $e = this.$element
499        var o  = this.options
500
501        return $e.attr('data-content')
502            || (typeof o.content == 'function' ?
503            o.content.call($e[0]) :
504            o.content)
505    }
506
507    Popover.prototype.arrow = function () {
508        return this.$arrow = this.$arrow || this.tip().find('.arrow')
509    }
510
511    Popover.prototype.tip = function () {
512        if (!this.$tip) this.$tip = $(this.options.template)
513        return this.$tip
514    }
515
516
517    // POPOVER PLUGIN DEFINITION
518    // =========================
519
520    var old = $.fn.popover
521
522    $.fn.popover = function (option) {
523        return this.each(function () {
524            var $this   = $(this)
525            var data    = $this.data('bs.popover')
526            var options = typeof option == 'object' && option
527
528            if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
529            if (typeof option == 'string') data[option]()
530        })
531    }
532
533    $.fn.popover.Constructor = Popover
534
535
536    // POPOVER NO CONFLICT
537    // ===================
538
539    $.fn.popover.noConflict = function () {
540        $.fn.popover = old
541        return this
542    }
543
544}(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.