]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Add tooltip self-reference to address #12320 13593/head
authorj.corns <jason.corns@classmates.com>
Wed, 14 May 2014 17:36:32 +0000 (10:36 -0700)
committerj.corns <jason.corns@classmates.com>
Wed, 14 May 2014 17:36:32 +0000 (10:36 -0700)
primarily adds a data- attribute to the tooltip (and thus, the popover)
to create a self-reference.

js/tests/unit/popover.js
js/tests/unit/tooltip.js
js/tooltip.js

index 1a095564be8f314afe2f16ff619aef723d73c95d..b28e1f3a7f72059a686d8013d7ff0ebc4f7f22f5 100644 (file)
@@ -46,6 +46,16 @@ $(function () {
     ok(!!popover.data('bs.popover'), 'popover instance exists')
   })
 
+  test('should store popover trigger in popover instance data object', function () {
+    $.support.transition = false
+    var popover = $('<a href="#" title="ResentedHook">@ResentedHook</a>')
+      .appendTo('#qunit-fixture')
+      .bootstrapPopover()
+    popover.bootstrapPopover('show')
+    ok(!!$('.popover').data('bs.popover'), 'popover trigger stored in instance data')
+    $('#qunit-fixture').empty()
+  })
+
   test('should get title and content from options', function () {
     $.support.transition = false
     var popover = $('<a href="#">@fat</a>')
index e579a9ef7f9825cdfa0cb4a68011d71191f680b0..6c24111b8e83999ffabb037578a9ee7c2db91544 100644 (file)
@@ -295,6 +295,17 @@ $(function () {
     ok($('.tooltip').is('.fade.in'), 'tooltip should be toggled in')
   })
 
+  test('should hide shown tooltip when toggle is called on tooltip', function () {
+    var tooltip = $('<a href="#" rel="tooltip" title="tooltip on toggle">@ResentedHook</a>')
+      .appendTo('#qunit-fixture')
+      .bootstrapTooltip({trigger: 'manual'})
+      .bootstrapTooltip('toggle')
+    $('.tooltip', '#qunit-fixture').bootstrapTooltip('toggle')
+    ok($('.tooltip').not('.fade.in'), 'tooltip should be toggled out')
+    tooltip.bootstrapTooltip('hide')
+    $('#qunit-fixture').empty()
+  })
+
   test('should place tooltips inside the body', function () {
     var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>')
       .appendTo('#qunit-fixture')
index d985f96e346583d7ca825a808d69d28fbd43a3a4..076f2fa1cc277576181e7569c641ab1055496145 100644 (file)
         .detach()
         .css({ top: 0, left: 0, display: 'block' })
         .addClass(placement)
+        .data('bs.' + this.type, this)
 
       this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)