OSDN Git Service

new repo
[bytom/vapor.git] / tools / side_chain_tool / web / node_modules / bootstrap / js / popover.js
1 /* ========================================================================
2  * Bootstrap: popover.js v3.3.7
3  * http://getbootstrap.com/javascript/#popovers
4  * ========================================================================
5  * Copyright 2011-2016 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.3.7'
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     $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
49     $tip.find('.popover-content').children().detach().end()[ // we use append for html objects to maintain js events
50       this.options.html ? (typeof content == 'string' ? 'html' : 'append') : 'text'
51     ](content)
52
53     $tip.removeClass('fade top bottom left right in')
54
55     // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
56     // this manually by checking the contents.
57     if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide()
58   }
59
60   Popover.prototype.hasContent = function () {
61     return this.getTitle() || this.getContent()
62   }
63
64   Popover.prototype.getContent = function () {
65     var $e = this.$element
66     var o  = this.options
67
68     return $e.attr('data-content')
69       || (typeof o.content == 'function' ?
70             o.content.call($e[0]) :
71             o.content)
72   }
73
74   Popover.prototype.arrow = function () {
75     return (this.$arrow = this.$arrow || this.tip().find('.arrow'))
76   }
77
78
79   // POPOVER PLUGIN DEFINITION
80   // =========================
81
82   function Plugin(option) {
83     return this.each(function () {
84       var $this   = $(this)
85       var data    = $this.data('bs.popover')
86       var options = typeof option == 'object' && option
87
88       if (!data && /destroy|hide/.test(option)) return
89       if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
90       if (typeof option == 'string') data[option]()
91     })
92   }
93
94   var old = $.fn.popover
95
96   $.fn.popover             = Plugin
97   $.fn.popover.Constructor = Popover
98
99
100   // POPOVER NO CONFLICT
101   // ===================
102
103   $.fn.popover.noConflict = function () {
104     $.fn.popover = old
105     return this
106   }
107
108 }(jQuery);