aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Thornton <[email protected]>2012-06-20 12:02:05 -0700
committerJacob Thornton <[email protected]>2012-06-20 12:02:05 -0700
commit1e717991e897e44961d7a70fd3503d79b7ab4d7c (patch)
tree01fc413071e524051e704de44cee8f938dc5200f
parenteb62c977cd78d85b82900267268e13f2314a176b (diff)
parent3a5b4cc7df5f63b39218fbae75d6604e08f89e2a (diff)
downloadbootstrap-1e717991e897e44961d7a70fd3503d79b7ab4d7c.tar.xz
bootstrap-1e717991e897e44961d7a70fd3503d79b7ab4d7c.zip
Merge pull request #3880 from lookfirst/popover-destroy
Add popover / tooltip destroy method
-rw-r--r--docs/templates/pages/javascript.mustache8
-rw-r--r--js/bootstrap-popover.js4
-rw-r--r--js/bootstrap-tooltip.js4
-rw-r--r--js/tests/unit/bootstrap-popover.js10
-rw-r--r--js/tests/unit/bootstrap-tooltip.js9
5 files changed, 34 insertions, 1 deletions
diff --git a/docs/templates/pages/javascript.mustache b/docs/templates/pages/javascript.mustache
index 0a3a7aa80..3e558c4f7 100644
--- a/docs/templates/pages/javascript.mustache
+++ b/docs/templates/pages/javascript.mustache
@@ -755,6 +755,9 @@ $('a[data-toggle="tab"]').on('shown', function (e) {
<h4>.tooltip('toggle')</h4>
<p>{{_i}}Toggles an element's tooltip.{{/i}}</p>
<pre class="prettyprint linenums">$('#element').tooltip('toggle')</pre>
+ <h4>.tooltip('destroy')</h4>
+ <p>{{_i}}Destroys an element's tooltip.{{/i}}</p>
+ <pre class="prettyprint linenums">$('#element').tooltip('destroy')</pre>
</section>
@@ -821,7 +824,7 @@ $('a[data-toggle="tab"]').on('shown', function (e) {
<td>{{_i}}trigger{{/i}}</td>
<td>{{_i}}string{{/i}}</td>
<td>'hover'</td>
- <td>{{_i}}how tooltip is triggered{{/i}} - hover | focus | manual</td>
+ <td>{{_i}}how popover is triggered{{/i}} - hover | focus | manual</td>
</tr>
<tr>
<td>{{_i}}title{{/i}}</td>
@@ -867,6 +870,9 @@ $('a[data-toggle="tab"]').on('shown', function (e) {
<h4>.popover('toggle')</h4>
<p>{{_i}}Toggles an elements popover.{{/i}}</p>
<pre class="prettyprint linenums">$('#element').popover('toggle')</pre>
+ <h4>.popover('destroy')</h4>
+ <p>{{_i}}Destroys an element's popover.{{/i}}</p>
+ <pre class="prettyprint linenums">$('#element').popover('destroy')</pre>
</section>
diff --git a/js/bootstrap-popover.js b/js/bootstrap-popover.js
index c6c1f8b47..fe22ecb47 100644
--- a/js/bootstrap-popover.js
+++ b/js/bootstrap-popover.js
@@ -71,6 +71,10 @@
return this.$tip
}
+ , destroy: function () {
+ this.$element.off().removeData('popover')
+ }
+
})
diff --git a/js/bootstrap-tooltip.js b/js/bootstrap-tooltip.js
index f5f9fad3f..f280e3696 100644
--- a/js/bootstrap-tooltip.js
+++ b/js/bootstrap-tooltip.js
@@ -235,6 +235,10 @@
this[this.tip().hasClass('in') ? 'hide' : 'show']()
}
+ , destroy: function () {
+ this.$element.off().removeData('tooltip')
+ }
+
}
diff --git a/js/tests/unit/bootstrap-popover.js b/js/tests/unit/bootstrap-popover.js
index afd6b170b..6d5d9f7a1 100644
--- a/js/tests/unit/bootstrap-popover.js
+++ b/js/tests/unit/bootstrap-popover.js
@@ -90,4 +90,14 @@ $(function () {
ok(!$('.popover').length, 'popover was removed')
$('#qunit-fixture').empty()
})
+
+ test("should destroy popover", function () {
+ var popover = $('<div/>').popover()
+ ok(popover.data('popover'), 'popover has data')
+ ok(popover.data('events').mouseover && popover.data('events').mouseout, 'popover has hover event')
+ popover.popover('destroy')
+ ok(!popover.data('popover'), 'popover does not have data')
+ ok(!popover.data('events'), 'popover does not have any events')
+ })
+
}) \ No newline at end of file
diff --git a/js/tests/unit/bootstrap-tooltip.js b/js/tests/unit/bootstrap-tooltip.js
index 51e03486e..7852305c1 100644
--- a/js/tests/unit/bootstrap-tooltip.js
+++ b/js/tests/unit/bootstrap-tooltip.js
@@ -128,4 +128,13 @@ $(function () {
}, 200)
})
+ test("should destroy tooltip", function () {
+ var tooltip = $('<div/>').tooltip()
+ ok(tooltip.data('tooltip'), 'tooltip has data')
+ ok(tooltip.data('events').mouseover && tooltip.data('events').mouseout, 'tooltip has hover event')
+ tooltip.tooltip('destroy')
+ ok(!tooltip.data('tooltip'), 'tooltip does not have data')
+ ok(!tooltip.data('events'), 'tooltip does not have any events')
+ })
+
})