File indexing completed on 2024-05-19 06:00:30

0001 /* ========================================================================
0002  * Bootstrap: popover.js v3.0.3
0003  * http://getbootstrap.com/javascript/#popovers
0004  * ========================================================================
0005  * Copyright 2013 Twitter, Inc.
0006  *
0007  * Licensed under the Apache License, Version 2.0 (the "License");
0008  * you may not use this file except in compliance with the License.
0009  * You may obtain a copy of the License at
0010  *
0011  * http://www.apache.org/licenses/LICENSE-2.0
0012  *
0013  * Unless required by applicable law or agreed to in writing, software
0014  * distributed under the License is distributed on an "AS IS" BASIS,
0015  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0016  * See the License for the specific language governing permissions and
0017  * limitations under the License.
0018  * ======================================================================== */
0019 
0020 
0021 +function ($) { "use strict";
0022 
0023   // POPOVER PUBLIC CLASS DEFINITION
0024   // ===============================
0025 
0026   var Popover = function (element, options) {
0027     this.init('popover', element, options)
0028   }
0029 
0030   if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
0031 
0032   Popover.DEFAULTS = $.extend({} , $.fn.tooltip.Constructor.DEFAULTS, {
0033     placement: 'right'
0034   , trigger: 'click'
0035   , content: ''
0036   , template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
0037   })
0038 
0039 
0040   // NOTE: POPOVER EXTENDS tooltip.js
0041   // ================================
0042 
0043   Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)
0044 
0045   Popover.prototype.constructor = Popover
0046 
0047   Popover.prototype.getDefaults = function () {
0048     return Popover.DEFAULTS
0049   }
0050 
0051   Popover.prototype.setContent = function () {
0052     var $tip    = this.tip()
0053     var title   = this.getTitle()
0054     var content = this.getContent()
0055 
0056     $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
0057     $tip.find('.popover-content')[this.options.html ? 'html' : 'text'](content)
0058 
0059     $tip.removeClass('fade top bottom left right in')
0060 
0061     // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
0062     // this manually by checking the contents.
0063     if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide()
0064   }
0065 
0066   Popover.prototype.hasContent = function () {
0067     return this.getTitle() || this.getContent()
0068   }
0069 
0070   Popover.prototype.getContent = function () {
0071     var $e = this.$element
0072     var o  = this.options
0073 
0074     return $e.attr('data-content')
0075       || (typeof o.content == 'function' ?
0076             o.content.call($e[0]) :
0077             o.content)
0078   }
0079 
0080   Popover.prototype.arrow = function () {
0081     return this.$arrow = this.$arrow || this.tip().find('.arrow')
0082   }
0083 
0084   Popover.prototype.tip = function () {
0085     if (!this.$tip) this.$tip = $(this.options.template)
0086     return this.$tip
0087   }
0088 
0089 
0090   // POPOVER PLUGIN DEFINITION
0091   // =========================
0092 
0093   var old = $.fn.popover
0094 
0095   $.fn.popover = function (option) {
0096     return this.each(function () {
0097       var $this   = $(this)
0098       var data    = $this.data('bs.popover')
0099       var options = typeof option == 'object' && option
0100 
0101       if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
0102       if (typeof option == 'string') data[option]()
0103     })
0104   }
0105 
0106   $.fn.popover.Constructor = Popover
0107 
0108 
0109   // POPOVER NO CONFLICT
0110   // ===================
0111 
0112   $.fn.popover.noConflict = function () {
0113     $.fn.popover = old
0114     return this
0115   }
0116 
0117 }(jQuery);