2015-01-03 22:58:44 +01:00
|
|
|
/** =======================================================================
|
|
|
|
* Bootstrap: popover.js v4.0.0
|
2013-10-29 18:10:47 +01:00
|
|
|
* http://getbootstrap.com/javascript/#popovers
|
2013-05-22 04:30:33 +02:00
|
|
|
* ========================================================================
|
2015-01-01 01:23:48 +01:00
|
|
|
* Copyright 2011-2015 Twitter, Inc.
|
2013-12-19 00:28:08 +01:00
|
|
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
2015-01-03 22:58:44 +01:00
|
|
|
* ========================================================================
|
|
|
|
* @fileoverview - Bootstrap's popover plugin - extends tooltip.
|
|
|
|
*
|
|
|
|
* Public Methods & Properties:
|
|
|
|
*
|
|
|
|
* + $.popover
|
|
|
|
* + $.popover.noConflict
|
|
|
|
* + $.popover.Constructor
|
|
|
|
* + $.popover.Constructor.VERSION
|
|
|
|
* + $.popover.Constructor.Defaults
|
|
|
|
* + $.popover.Constructor.Defaults.container
|
|
|
|
* + $.popover.Constructor.Defaults.animation
|
|
|
|
* + $.popover.Constructor.Defaults.placement
|
|
|
|
* + $.popover.Constructor.Defaults.selector
|
|
|
|
* + $.popover.Constructor.Defaults.template
|
|
|
|
* + $.popover.Constructor.Defaults.trigger
|
|
|
|
* + $.popover.Constructor.Defaults.title
|
|
|
|
* + $.popover.Constructor.Defaults.content
|
|
|
|
* + $.popover.Constructor.Defaults.delay
|
|
|
|
* + $.popover.Constructor.Defaults.html
|
|
|
|
* + $.popover.Constructor.Defaults.viewport
|
|
|
|
* + $.popover.Constructor.Defaults.viewport.selector
|
|
|
|
* + $.popover.Constructor.Defaults.viewport.padding
|
|
|
|
* + $.popover.Constructor.prototype.enable
|
|
|
|
* + $.popover.Constructor.prototype.disable
|
|
|
|
* + $.popover.Constructor.prototype.destroy
|
|
|
|
* + $.popover.Constructor.prototype.toggleEnabled
|
|
|
|
* + $.popover.Constructor.prototype.toggle
|
|
|
|
* + $.popover.Constructor.prototype.show
|
|
|
|
* + $.popover.Constructor.prototype.hide
|
|
|
|
*
|
|
|
|
* ========================================================================
|
|
|
|
*/
|
2011-08-28 02:22:49 +02:00
|
|
|
|
|
|
|
|
2015-01-03 22:58:44 +01:00
|
|
|
'use strict';
|
2014-06-10 07:18:05 +02:00
|
|
|
|
2011-08-28 02:22:49 +02:00
|
|
|
|
2015-01-03 22:58:44 +01:00
|
|
|
if (!Tooltip) throw new Error('Popover requires tooltip.js')
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Our tooltip class.
|
|
|
|
* @param {Element!} element
|
|
|
|
* @param {Object=} opt_config
|
|
|
|
* @constructor
|
|
|
|
* @extends {Tooltip}
|
|
|
|
*/
|
|
|
|
var Popover = function (element, opt_config) {
|
|
|
|
Tooltip.apply(this, arguments)
|
|
|
|
}
|
|
|
|
Bootstrap.inherits(Popover, Tooltip)
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @const
|
|
|
|
* @type {string}
|
|
|
|
*/
|
|
|
|
Popover['VERSION'] = '4.0.0'
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @const
|
|
|
|
* @type {Object}
|
|
|
|
*/
|
|
|
|
Popover['Defaults'] = $.extend({}, $.fn['tooltip']['Constructor']['Defaults'], {
|
|
|
|
'placement': 'right',
|
|
|
|
'trigger': 'click',
|
|
|
|
'content': '',
|
|
|
|
'template': '<div class="popover" role="tooltip"><div class="popover-arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @const
|
|
|
|
* @type {string}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
Popover._NAME = 'popover'
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @const
|
|
|
|
* @type {string}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
Popover._DATA_KEY = 'bs.popover'
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @const
|
|
|
|
* @enum {string}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
Popover._Event = {
|
|
|
|
HIDE : 'hide.bs.popover',
|
|
|
|
HIDDEN : 'hidden.bs.popover',
|
|
|
|
SHOW : 'show.bs.popover',
|
|
|
|
SHOWN : 'shown.bs.popover'
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @const
|
|
|
|
* @enum {string}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
Popover._ClassName = {
|
|
|
|
FADE : 'fade',
|
|
|
|
IN : 'in'
|
|
|
|
}
|
2011-11-21 03:19:50 +01:00
|
|
|
|
2011-08-28 02:22:49 +02:00
|
|
|
|
2015-01-03 22:58:44 +01:00
|
|
|
/**
|
|
|
|
* @const
|
|
|
|
* @enum {string}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
Popover._Selector = {
|
|
|
|
TITLE : '.popover-title',
|
|
|
|
CONTENT : '.popover-content',
|
|
|
|
ARROW : '.popover-arrow'
|
|
|
|
}
|
2012-04-15 01:29:53 +02:00
|
|
|
|
2015-01-03 22:58:44 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const
|
|
|
|
* @type {Function}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
Popover._JQUERY_NO_CONFLICT = $.fn[Popover._NAME]
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {Object|string=} opt_config
|
|
|
|
* @this {jQuery}
|
|
|
|
* @return {jQuery}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
Popover._jQueryInterface = function (opt_config) {
|
|
|
|
return this.each(function () {
|
|
|
|
var data = $(this).data(Popover._DATA_KEY)
|
|
|
|
var config = typeof opt_config === 'object' ? opt_config : null
|
|
|
|
|
|
|
|
if (!data && opt_config === 'destroy') {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!data) {
|
|
|
|
data = new Popover(this, config)
|
|
|
|
$(this).data(Popover._DATA_KEY, data)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof opt_config === 'string') {
|
|
|
|
data[opt_config]()
|
|
|
|
}
|
2014-06-23 20:07:18 +02:00
|
|
|
})
|
2015-01-03 22:58:44 +01:00
|
|
|
}
|
2011-09-11 07:24:31 +02:00
|
|
|
|
2011-08-28 02:22:49 +02:00
|
|
|
|
2015-01-03 22:58:44 +01:00
|
|
|
/**
|
|
|
|
* @return {string}
|
|
|
|
* @protected
|
|
|
|
*/
|
|
|
|
Popover.prototype.getName = function () {
|
|
|
|
return Popover._NAME
|
|
|
|
}
|
2011-12-01 07:42:22 +01:00
|
|
|
|
2011-11-21 06:36:26 +01:00
|
|
|
|
2015-01-03 22:58:44 +01:00
|
|
|
/**
|
|
|
|
* @override
|
|
|
|
*/
|
|
|
|
Popover.prototype.getDataKey = function () {
|
|
|
|
return Popover._DATA_KEY
|
|
|
|
}
|
2011-11-21 06:36:26 +01:00
|
|
|
|
2011-08-28 02:22:49 +02:00
|
|
|
|
2015-01-03 22:58:44 +01:00
|
|
|
/**
|
|
|
|
* @override
|
|
|
|
*/
|
|
|
|
Popover.prototype.getEventObject = function () {
|
|
|
|
return Popover._Event
|
|
|
|
}
|
2011-11-21 03:19:50 +01:00
|
|
|
|
2013-06-21 01:01:59 +02:00
|
|
|
|
2015-01-03 22:58:44 +01:00
|
|
|
/**
|
|
|
|
* @override
|
|
|
|
*/
|
|
|
|
Popover.prototype.getArrowElement = function () {
|
|
|
|
return (this.arrow = this.arrow || $(this.getTipElement()).find(Popover._Selector.ARROW)[0])
|
|
|
|
}
|
2011-08-28 02:22:49 +02:00
|
|
|
|
2011-12-21 03:02:47 +01:00
|
|
|
|
2015-01-03 22:58:44 +01:00
|
|
|
/**
|
|
|
|
* @override
|
|
|
|
*/
|
|
|
|
Popover.prototype.setContent = function () {
|
|
|
|
var tip = this.getTipElement()
|
|
|
|
var title = this.getTitle()
|
|
|
|
var content = this._getContent()
|
|
|
|
var titleElement = $(tip).find(Popover._Selector.TITLE)[0]
|
|
|
|
|
|
|
|
if (titleElement) {
|
|
|
|
titleElement[this.config['html'] ? 'innerHTML' : 'innerText'] = title
|
2014-06-23 20:07:18 +02:00
|
|
|
}
|
2011-08-28 02:22:49 +02:00
|
|
|
|
2015-01-03 22:58:44 +01:00
|
|
|
// we use append for html objects to maintain js events
|
|
|
|
$(tip).find(Popover._Selector.CONTENT).children().detach().end()[
|
|
|
|
this.config['html'] ? (typeof content == 'string' ? 'html' : 'append') : 'text'
|
|
|
|
](content)
|
2011-08-28 02:22:49 +02:00
|
|
|
|
2015-01-03 22:58:44 +01:00
|
|
|
$(tip)
|
|
|
|
.removeClass(Popover._ClassName.FADE)
|
|
|
|
.removeClass(Popover._ClassName.IN)
|
2013-08-05 02:22:49 +02:00
|
|
|
|
2015-01-03 22:58:44 +01:00
|
|
|
for (var direction in Tooltip.Direction) {
|
|
|
|
$(tip).removeClass(Popover._NAME + '-' + Tooltip.Direction[direction])
|
2014-06-23 20:07:18 +02:00
|
|
|
}
|
2015-01-03 22:58:44 +01:00
|
|
|
}
|
2012-06-19 04:25:54 +02:00
|
|
|
|
2011-11-21 03:19:50 +01:00
|
|
|
|
2015-01-03 22:58:44 +01:00
|
|
|
/**
|
|
|
|
* @override
|
|
|
|
*/
|
|
|
|
Popover.prototype.isWithContent = function () {
|
|
|
|
return this.getTitle() || this._getContent()
|
|
|
|
}
|
2011-08-28 02:22:49 +02:00
|
|
|
|
2013-05-17 02:18:15 +02:00
|
|
|
|
2015-01-03 22:58:44 +01:00
|
|
|
/**
|
|
|
|
* @override
|
|
|
|
*/
|
|
|
|
Popover.prototype.getTipElement = function () {
|
|
|
|
return (this.tip = this.tip || $(this.config['template'])[0])
|
|
|
|
}
|
2011-08-28 02:22:49 +02:00
|
|
|
|
2014-04-22 07:03:33 +02:00
|
|
|
|
2015-01-03 22:58:44 +01:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
Popover.prototype._getContent = function () {
|
|
|
|
return this.element.getAttribute('data-content')
|
|
|
|
|| (typeof this.config['content'] == 'function' ?
|
|
|
|
this.config['content'].call(this.element) :
|
|
|
|
this.config['content'])
|
|
|
|
}
|
2011-12-21 03:02:47 +01:00
|
|
|
|
2012-12-07 23:06:01 +01:00
|
|
|
|
|
|
|
|
2015-01-03 22:58:44 +01:00
|
|
|
/**
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
* jQuery Interface + noConflict implementaiton
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @const
|
|
|
|
* @type {Function}
|
|
|
|
*/
|
|
|
|
$.fn[Popover._NAME] = Popover._jQueryInterface
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @const
|
|
|
|
* @type {Function}
|
|
|
|
*/
|
|
|
|
$.fn[Popover._NAME]['Constructor'] = Popover
|
2014-06-12 20:11:04 +02:00
|
|
|
|
2012-12-07 23:06:01 +01:00
|
|
|
|
2015-01-03 22:58:44 +01:00
|
|
|
/**
|
|
|
|
* @const
|
|
|
|
* @type {Function}
|
|
|
|
*/
|
|
|
|
$.fn[Popover._NAME]['noConflict'] = function () {
|
|
|
|
$.fn[Popover._NAME] = Popover._JQUERY_NO_CONFLICT
|
|
|
|
return this
|
|
|
|
}
|