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