1 /* ========================================================================
2 * Bootstrap: popover.js v3.0.0
3 * http://twbs.github.com/bootstrap/javascript.html#popovers
4 * ========================================================================
5 * Copyright 2012 Twitter, Inc.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ======================================================================== */
21 +function ($) { "use strict";
23 // POPOVER PUBLIC CLASS DEFINITION
24 // ===============================
26 var Popover = function (element, options) {
27 this.init('popover', element, options)
30 if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
32 Popover.DEFAULTS = $.extend({} , $.fn.tooltip.Constructor.DEFAULTS, {
36 , template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
40 // NOTE: POPOVER EXTENDS tooltip.js
41 // ================================
43 Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)
45 Popover.prototype.constructor = Popover
47 Popover.prototype.getDefaults = function () {
48 return Popover.DEFAULTS
51 Popover.prototype.setContent = function () {
53 var title = this.getTitle()
54 var content = this.getContent()
56 $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
57 $tip.find('.popover-content')[this.options.html ? 'html' : 'text'](content)
59 $tip.removeClass('fade top bottom left right in')
61 $tip.find('.popover-title:empty').hide()
64 Popover.prototype.hasContent = function () {
65 return this.getTitle() || this.getContent()
68 Popover.prototype.getContent = function () {
69 var $e = this.$element
72 return $e.attr('data-content')
73 || (typeof o.content == 'function' ?
74 o.content.call($e[0]) :
78 Popover.prototype.tip = function () {
79 if (!this.$tip) this.$tip = $(this.options.template)
83 Popover.prototype.destroy = function () {
84 this.hide().$element.off('.' + this.type).removeData(this.type)
88 // POPOVER PLUGIN DEFINITION
89 // =========================
91 var old = $.fn.popover
93 $.fn.popover = function (option) {
94 return this.each(function () {
96 var data = $this.data('bs.popover')
97 var options = typeof option == 'object' && option
99 if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
100 if (typeof option == 'string') data[option]()
104 $.fn.popover.Constructor = Popover
107 // POPOVER NO CONFLICT
108 // ===================
110 $.fn.popover.noConflict = function () {