[ADD] doc: new documentation, with training tutorials, and new scaffolding
[odoo/odoo.git] / doc / _themes / odoodoc / static / bootstrap / js / popover.js
1 /* ========================================================================
2  * Bootstrap: popover.js v3.2.0
3  * http://getbootstrap.com/javascript/#popovers
4  * ========================================================================
5  * Copyright 2011-2014 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.2.0'
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').empty()[ // 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   Popover.prototype.tip = function () {
79     if (!this.$tip) this.$tip = $(this.options.template)
80     return this.$tip
81   }
82
83
84   // POPOVER PLUGIN DEFINITION
85   // =========================
86
87   function Plugin(option) {
88     return this.each(function () {
89       var $this   = $(this)
90       var data    = $this.data('bs.popover')
91       var options = typeof option == 'object' && option
92
93       if (!data && option == 'destroy') return
94       if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
95       if (typeof option == 'string') data[option]()
96     })
97   }
98
99   var old = $.fn.popover
100
101   $.fn.popover             = Plugin
102   $.fn.popover.Constructor = Popover
103
104
105   // POPOVER NO CONFLICT
106   // ===================
107
108   $.fn.popover.noConflict = function () {
109     $.fn.popover = old
110     return this
111   }
112
113 }(jQuery);