1 /* ===========================================================
2 * bootstrap-popover.js v2.0.4
3 * http://twitter.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 * =========================================================== */
23 "use strict"; // jshint ;_;
26 /* POPOVER PUBLIC CLASS DEFINITION
27 * =============================== */
29 var Popover = function ( element, options ) {
30 this.init('popover', element, options)
34 /* NOTE: POPOVER EXTENDS BOOTSTRAP-TOOLTIP.js
35 ========================================== */
37 Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, {
41 , setContent: function () {
43 , title = this.getTitle()
44 , content = this.getContent()
46 $tip.find('.popover-title')[this.isHTML(title) ? 'html' : 'text'](title)
47 $tip.find('.popover-content > *')[this.isHTML(content) ? 'html' : 'text'](content)
49 $tip.removeClass('fade top bottom left right in')
52 , hasContent: function () {
53 return this.getTitle() || this.getContent()
56 , getContent: function () {
61 content = $e.attr('data-content')
62 || (typeof o.content == 'function' ? o.content.call($e[0]) : o.content)
69 this.$tip = $(this.options.template)
77 /* POPOVER PLUGIN DEFINITION
78 * ======================= */
80 $.fn.popover = function (option) {
81 return this.each(function () {
83 , data = $this.data('popover')
84 , options = typeof option == 'object' && option
85 if (!data) $this.data('popover', (data = new Popover(this, options)))
86 if (typeof option == 'string') data[option]()
90 $.fn.popover.Constructor = Popover
92 $.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, {
95 , template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'