1 | /* ========================================================================
|
---|
2 | * Bootstrap: popover.js v3.4.1
|
---|
3 | * https://getbootstrap.com/docs/3.4/javascript/#popovers
|
---|
4 | * ========================================================================
|
---|
5 | * Copyright 2011-2019 Twitter, Inc.
|
---|
6 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
---|
7 | * ======================================================================== */
|
---|
8 |
|
---|
9 |
|
---|
10 | +function ($) {
|
---|
11 | 'use strict';
|
---|
12 |
|
---|
13 | // POPOVER PUBLIC CLASS DEFINITION
|
---|
14 | // ===============================
|
---|
15 |
|
---|
16 | var Popover = function (element, options) {
|
---|
17 | this.init('popover', element, options)
|
---|
18 | }
|
---|
19 |
|
---|
20 | if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
|
---|
21 |
|
---|
22 | Popover.VERSION = '3.4.1'
|
---|
23 |
|
---|
24 | Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, {
|
---|
25 | placement: 'right',
|
---|
26 | trigger: 'click',
|
---|
27 | content: '',
|
---|
28 | template: '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
|
---|
29 | })
|
---|
30 |
|
---|
31 |
|
---|
32 | // NOTE: POPOVER EXTENDS tooltip.js
|
---|
33 | // ================================
|
---|
34 |
|
---|
35 | Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)
|
---|
36 |
|
---|
37 | Popover.prototype.constructor = Popover
|
---|
38 |
|
---|
39 | Popover.prototype.getDefaults = function () {
|
---|
40 | return Popover.DEFAULTS
|
---|
41 | }
|
---|
42 |
|
---|
43 | Popover.prototype.setContent = function () {
|
---|
44 | var $tip = this.tip()
|
---|
45 | var title = this.getTitle()
|
---|
46 | var content = this.getContent()
|
---|
47 |
|
---|
48 | if (this.options.html) {
|
---|
49 | var typeContent = typeof content
|
---|
50 |
|
---|
51 | if (this.options.sanitize) {
|
---|
52 | title = this.sanitizeHtml(title)
|
---|
53 |
|
---|
54 | if (typeContent === 'string') {
|
---|
55 | content = this.sanitizeHtml(content)
|
---|
56 | }
|
---|
57 | }
|
---|
58 |
|
---|
59 | $tip.find('.popover-title').html(title)
|
---|
60 | $tip.find('.popover-content').children().detach().end()[
|
---|
61 | typeContent === 'string' ? 'html' : 'append'
|
---|
62 | ](content)
|
---|
63 | } else {
|
---|
64 | $tip.find('.popover-title').text(title)
|
---|
65 | $tip.find('.popover-content').children().detach().end().text(content)
|
---|
66 | }
|
---|
67 |
|
---|
68 | $tip.removeClass('fade top bottom left right in')
|
---|
69 |
|
---|
70 | // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
|
---|
71 | // this manually by checking the contents.
|
---|
72 | if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide()
|
---|
73 | }
|
---|
74 |
|
---|
75 | Popover.prototype.hasContent = function () {
|
---|
76 | return this.getTitle() || this.getContent()
|
---|
77 | }
|
---|
78 |
|
---|
79 | Popover.prototype.getContent = function () {
|
---|
80 | var $e = this.$element
|
---|
81 | var o = this.options
|
---|
82 |
|
---|
83 | return $e.attr('data-content')
|
---|
84 | || (typeof o.content == 'function' ?
|
---|
85 | o.content.call($e[0]) :
|
---|
86 | o.content)
|
---|
87 | }
|
---|
88 |
|
---|
89 | Popover.prototype.arrow = function () {
|
---|
90 | return (this.$arrow = this.$arrow || this.tip().find('.arrow'))
|
---|
91 | }
|
---|
92 |
|
---|
93 |
|
---|
94 | // POPOVER PLUGIN DEFINITION
|
---|
95 | // =========================
|
---|
96 |
|
---|
97 | function Plugin(option) {
|
---|
98 | return this.each(function () {
|
---|
99 | var $this = $(this)
|
---|
100 | var data = $this.data('bs.popover')
|
---|
101 | var options = typeof option == 'object' && option
|
---|
102 |
|
---|
103 | if (!data && /destroy|hide/.test(option)) return
|
---|
104 | if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
|
---|
105 | if (typeof option == 'string') data[option]()
|
---|
106 | })
|
---|
107 | }
|
---|
108 |
|
---|
109 | var old = $.fn.popover
|
---|
110 |
|
---|
111 | $.fn.popover = Plugin
|
---|
112 | $.fn.popover.Constructor = Popover
|
---|
113 |
|
---|
114 |
|
---|
115 | // POPOVER NO CONFLICT
|
---|
116 | // ===================
|
---|
117 |
|
---|
118 | $.fn.popover.noConflict = function () {
|
---|
119 | $.fn.popover = old
|
---|
120 | return this
|
---|
121 | }
|
---|
122 |
|
---|
123 | }(jQuery);
|
---|