info@54
|
1 |
/* ========================================================================
|
info@54
|
2 |
* Bootstrap: popover.js v3.0.3
|
info@54
|
3 |
* http://getbootstrap.com/javascript/#popovers
|
info@54
|
4 |
* ========================================================================
|
info@54
|
5 |
* Copyright 2013 Twitter, Inc.
|
info@54
|
6 |
*
|
info@54
|
7 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
info@54
|
8 |
* you may not use this file except in compliance with the License.
|
info@54
|
9 |
* You may obtain a copy of the License at
|
info@54
|
10 |
*
|
info@54
|
11 |
* http://www.apache.org/licenses/LICENSE-2.0
|
info@54
|
12 |
*
|
info@54
|
13 |
* Unless required by applicable law or agreed to in writing, software
|
info@54
|
14 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
info@54
|
15 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
info@54
|
16 |
* See the License for the specific language governing permissions and
|
info@54
|
17 |
* limitations under the License.
|
info@54
|
18 |
* ======================================================================== */
|
info@54
|
19 |
|
info@54
|
20 |
|
info@54
|
21 |
+function ($) { "use strict";
|
info@54
|
22 |
|
info@54
|
23 |
// POPOVER PUBLIC CLASS DEFINITION
|
info@54
|
24 |
// ===============================
|
info@54
|
25 |
|
info@54
|
26 |
var Popover = function (element, options) {
|
info@54
|
27 |
this.init('popover', element, options)
|
info@54
|
28 |
}
|
info@54
|
29 |
|
info@54
|
30 |
if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
|
info@54
|
31 |
|
info@54
|
32 |
Popover.DEFAULTS = $.extend({} , $.fn.tooltip.Constructor.DEFAULTS, {
|
info@54
|
33 |
placement: 'right'
|
info@54
|
34 |
, trigger: 'click'
|
info@54
|
35 |
, content: ''
|
info@54
|
36 |
, template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
|
info@54
|
37 |
})
|
info@54
|
38 |
|
info@54
|
39 |
|
info@54
|
40 |
// NOTE: POPOVER EXTENDS tooltip.js
|
info@54
|
41 |
// ================================
|
info@54
|
42 |
|
info@54
|
43 |
Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)
|
info@54
|
44 |
|
info@54
|
45 |
Popover.prototype.constructor = Popover
|
info@54
|
46 |
|
info@54
|
47 |
Popover.prototype.getDefaults = function () {
|
info@54
|
48 |
return Popover.DEFAULTS
|
info@54
|
49 |
}
|
info@54
|
50 |
|
info@54
|
51 |
Popover.prototype.setContent = function () {
|
info@54
|
52 |
var $tip = this.tip()
|
info@54
|
53 |
var title = this.getTitle()
|
info@54
|
54 |
var content = this.getContent()
|
info@54
|
55 |
|
info@54
|
56 |
$tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
|
info@54
|
57 |
$tip.find('.popover-content')[this.options.html ? 'html' : 'text'](content)
|
info@54
|
58 |
|
info@54
|
59 |
$tip.removeClass('fade top bottom left right in')
|
info@54
|
60 |
|
info@54
|
61 |
// IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
|
info@54
|
62 |
// this manually by checking the contents.
|
info@54
|
63 |
if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide()
|
info@54
|
64 |
}
|
info@54
|
65 |
|
info@54
|
66 |
Popover.prototype.hasContent = function () {
|
info@54
|
67 |
return this.getTitle() || this.getContent()
|
info@54
|
68 |
}
|
info@54
|
69 |
|
info@54
|
70 |
Popover.prototype.getContent = function () {
|
info@54
|
71 |
var $e = this.$element
|
info@54
|
72 |
var o = this.options
|
info@54
|
73 |
|
info@54
|
74 |
return $e.attr('data-content')
|
info@54
|
75 |
|| (typeof o.content == 'function' ?
|
info@54
|
76 |
o.content.call($e[0]) :
|
info@54
|
77 |
o.content)
|
info@54
|
78 |
}
|
info@54
|
79 |
|
info@54
|
80 |
Popover.prototype.arrow = function () {
|
info@54
|
81 |
return this.$arrow = this.$arrow || this.tip().find('.arrow')
|
info@54
|
82 |
}
|
info@54
|
83 |
|
info@54
|
84 |
Popover.prototype.tip = function () {
|
info@54
|
85 |
if (!this.$tip) this.$tip = $(this.options.template)
|
info@54
|
86 |
return this.$tip
|
info@54
|
87 |
}
|
info@54
|
88 |
|
info@54
|
89 |
|
info@54
|
90 |
// POPOVER PLUGIN DEFINITION
|
info@54
|
91 |
// =========================
|
info@54
|
92 |
|
info@54
|
93 |
var old = $.fn.popover
|
info@54
|
94 |
|
info@54
|
95 |
$.fn.popover = function (option) {
|
info@54
|
96 |
return this.each(function () {
|
info@54
|
97 |
var $this = $(this)
|
info@54
|
98 |
var data = $this.data('bs.popover')
|
info@54
|
99 |
var options = typeof option == 'object' && option
|
info@54
|
100 |
|
info@54
|
101 |
if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
|
info@54
|
102 |
if (typeof option == 'string') data[option]()
|
info@54
|
103 |
})
|
info@54
|
104 |
}
|
info@54
|
105 |
|
info@54
|
106 |
$.fn.popover.Constructor = Popover
|
info@54
|
107 |
|
info@54
|
108 |
|
info@54
|
109 |
// POPOVER NO CONFLICT
|
info@54
|
110 |
// ===================
|
info@54
|
111 |
|
info@54
|
112 |
$.fn.popover.noConflict = function () {
|
info@54
|
113 |
$.fn.popover = old
|
info@54
|
114 |
return this
|
info@54
|
115 |
}
|
info@54
|
116 |
|
info@54
|
117 |
}(jQuery);
|