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

109 lines
3.1 KiB
JavaScript
Raw Normal View History

2014-05-12 20:08:19 +02:00
/* ========================================================================
2016-05-16 13:33:49 +02:00
* Bootstrap: popover.js v3.3.6
2014-05-12 20:08:19 +02:00
* http://getbootstrap.com/javascript/#popovers
* ========================================================================
2016-05-16 13:33:49 +02:00
* Copyright 2011-2015 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')
2016-05-16 13:33:49 +02:00
Popover.VERSION = '3.3.6'
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()
$tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
2016-05-16 13:33:49 +02:00
$tip.find('.popover-content').children().detach().end()[ // we use append for html objects to maintain js events
2014-05-12 20:08:19 +02:00
this.options.html ? (typeof content == 'string' ? 'html' : 'append') : 'text'
](content)
$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' ?
o.content.call($e[0]) :
o.content)
}
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);