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