ffffng/app/bower_components/bootstrap-sass-official/assets/javascripts/bootstrap/popover.js

124 lines
3.4 KiB
JavaScript
Raw Normal View History

2014-05-12 20:08:19 +02:00
/* ========================================================================
2019-03-29 22:00:08 +01:00
* Bootstrap: popover.js v3.4.1
* https://getbootstrap.com/docs/3.4/javascript/#popovers
2014-05-12 20:08:19 +02:00
* ========================================================================
2019-03-29 22:00:08 +01:00
* Copyright 2011-2019 Twitter, Inc.
2014-05-12 20:08:19 +02:00
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* ======================================================================== */
+function ($) {
'use strict';
// POPOVER PUBLIC CLASS DEFINITION
// ===============================
var Popover = function (element, options) {
this.init('popover', element, options)
}
if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
2019-03-29 22:00:08 +01:00
Popover.VERSION = '3.4.1'
2014-08-10 12:02:48 +02:00
2014-05-12 20:08:19 +02:00
Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, {
placement: 'right',
trigger: 'click',
content: '',
2014-08-10 12:02:48 +02:00
template: '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
2014-05-12 20:08:19 +02:00
})
// NOTE: POPOVER EXTENDS tooltip.js
// ================================
Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)
Popover.prototype.constructor = Popover
Popover.prototype.getDefaults = function () {
return Popover.DEFAULTS
}
Popover.prototype.setContent = function () {
var $tip = this.tip()
var title = this.getTitle()
var content = this.getContent()
2019-03-29 22:00:08 +01:00
if (this.options.html) {
var typeContent = typeof content
if (this.options.sanitize) {
title = this.sanitizeHtml(title)
if (typeContent === 'string') {
content = this.sanitizeHtml(content)
}
}
$tip.find('.popover-title').html(title)
$tip.find('.popover-content').children().detach().end()[
typeContent === 'string' ? 'html' : 'append'
](content)
} else {
$tip.find('.popover-title').text(title)
$tip.find('.popover-content').children().detach().end().text(content)
}
2014-05-12 20:08:19 +02:00
$tip.removeClass('fade top bottom left right in')
// IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
// this manually by checking the contents.
if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide()
}
Popover.prototype.hasContent = function () {
return this.getTitle() || this.getContent()
}
Popover.prototype.getContent = function () {
var $e = this.$element
var o = this.options
return $e.attr('data-content')
|| (typeof o.content == 'function' ?
2019-03-29 22:00:08 +01:00
o.content.call($e[0]) :
o.content)
2014-05-12 20:08:19 +02:00
}
Popover.prototype.arrow = function () {
2014-08-10 12:02:48 +02:00
return (this.$arrow = this.$arrow || this.tip().find('.arrow'))
2014-05-12 20:08:19 +02:00
}
// POPOVER PLUGIN DEFINITION
// =========================
2014-08-10 12:02:48 +02:00
function Plugin(option) {
2014-05-12 20:08:19 +02:00
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.popover')
var options = typeof option == 'object' && option
2016-05-16 13:33:49 +02:00
if (!data && /destroy|hide/.test(option)) return
2014-05-12 20:08:19 +02:00
if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
if (typeof option == 'string') data[option]()
})
}
2014-08-10 12:02:48 +02:00
var old = $.fn.popover
$.fn.popover = Plugin
2014-05-12 20:08:19 +02:00
$.fn.popover.Constructor = Popover
// POPOVER NO CONFLICT
// ===================
$.fn.popover.noConflict = function () {
$.fn.popover = old
return this
}
}(jQuery);