aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorMark Otto <[email protected]>2013-07-17 23:34:31 -0700
committerMark Otto <[email protected]>2013-07-17 23:34:31 -0700
commit4d73aa60f953e0cb6c3b871d11a5c95617d0ca5b (patch)
tree34e6536894ccc1a1fdd8d9a7d66c1a9b59e2b363 /js
parentd3a139622e50a5bbb29255eaca701d815dee716b (diff)
parent59f847e8eef64c4adbc57a682ad626e068370b30 (diff)
downloadbootstrap-4d73aa60f953e0cb6c3b871d11a5c95617d0ca5b.tar.xz
bootstrap-4d73aa60f953e0cb6c3b871d11a5c95617d0ca5b.zip
Merge branch '3.0.0-wip' of github.com:twitter/bootstrap into 3.0.0-wip
Conflicts: docs/assets/js/bootstrap.min.js
Diffstat (limited to 'js')
-rw-r--r--js/popover.js10
-rw-r--r--js/tests/unit/popover.js20
-rw-r--r--js/tests/unit/tooltip.js38
3 files changed, 63 insertions, 5 deletions
diff --git a/js/popover.js b/js/popover.js
index e58e24908..482985b63 100644
--- a/js/popover.js
+++ b/js/popover.js
@@ -64,11 +64,13 @@
}
Popover.prototype.getContent = function () {
- var content = typeof this.options.content == 'function' ?
- this.options.content.call(this.$element[0]) :
- this.options.content
+ var $e = this.$element
+ var o = this.options
- return content || this.$element.attr('data-content')
+ return $e.attr('data-content')
+ || (typeof o.content == 'function' ?
+ o.content.call($e[0]) :
+ o.content)
}
Popover.prototype.tip = function () {
diff --git a/js/tests/unit/popover.js b/js/tests/unit/popover.js
index fb0017567..767d79864 100644
--- a/js/tests/unit/popover.js
+++ b/js/tests/unit/popover.js
@@ -77,6 +77,26 @@ $(function () {
$('#qunit-fixture').empty()
})
+
+ test("should get title and content from attributes #2", function () {
+ $.support.transition = false
+ var popover = $('<a href="#" title="@mdo" data-content="loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻" >@mdo</a>')
+ .appendTo('#qunit-fixture')
+ .popover({
+ title: 'ignored title option',
+ content: 'ignored content option'
+ })
+ .popover('show')
+
+ ok($('.popover').length, 'popover was inserted')
+ equals($('.popover .popover-title').text(), '@mdo', 'title correctly inserted')
+ equals($('.popover .popover-content').text(), "loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻", 'content correctly inserted')
+
+ popover.popover('hide')
+ ok(!$('.popover').length, 'popover was removed')
+ $('#qunit-fixture').empty()
+ })
+
test("should respect custom classes", function() {
$.support.transition = false
var popover = $('<a href="#">@fat</a>')
diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js
index b2b004d6e..5f7847e92 100644
--- a/js/tests/unit/tooltip.js
+++ b/js/tests/unit/tooltip.js
@@ -296,7 +296,7 @@ $(function () {
$("head").append('<style> .tooltip.right { white-space: nowrap; } .tooltip.right .tooltip-inner { max-width: none; } </style>')
var container = $("<div />").appendTo("body")
- , target = $('<a href="#" rel="tooltip" title="very very very very very very very very long tooltip in one line">To my right</a>')
+ , target = $('<a href="#" rel="tooltip" title="very very very very very very very very long tooltip in one line"></a>')
.appendTo(container)
.tooltip({placement: 'right'})
.tooltip('show')
@@ -305,4 +305,40 @@ $(function () {
ok( Math.round(target.offset().top + target[0].offsetHeight/2 - tooltip[0].offsetHeight/2) === Math.round(tooltip.offset().top) )
target.tooltip('hide')
})
+
+ test("tooltip title test #1", function () {
+ var tooltip = $('<a href="#" rel="tooltip" title="Simple tooltip" style="display: inline-block; position: absolute; top: 0; left: 0;"></a>')
+ .appendTo('#qunit-fixture')
+ .tooltip({
+ })
+ .tooltip('show')
+ equal($('.tooltip').children('.tooltip-inner').text(), 'Simple tooltip', 'title from title attribute is set')
+ tooltip.tooltip('hide')
+ ok(!$(".tooltip").length, 'tooltip removed')
+ })
+
+ test("tooltip title test #2", function () {
+ var tooltip = $('<a href="#" rel="tooltip" title="Simple tooltip" style="display: inline-block; position: absolute; top: 0; left: 0;"></a>')
+ .appendTo('#qunit-fixture')
+ .tooltip({
+ title: 'This is a tooltip with some content'
+ })
+ .tooltip('show')
+ equal($('.tooltip').children('.tooltip-inner').text(), 'Simple tooltip', 'title is set from title attribute while prefered over title option')
+ tooltip.tooltip('hide')
+ ok(!$(".tooltip").length, 'tooltip removed')
+ })
+
+ test("tooltip title test #3", function () {
+ var tooltip = $('<a href="#" rel="tooltip" style="display: inline-block; position: absolute; top: 0; left: 0;"></a>')
+ .appendTo('#qunit-fixture')
+ .tooltip({
+ title: 'This is a tooltip with some content'
+ })
+ .tooltip('show')
+ equal($('.tooltip').children('.tooltip-inner').text(), 'This is a tooltip with some content', 'title from title option is set')
+ tooltip.tooltip('hide')
+ ok(!$(".tooltip").length, 'tooltip removed')
+ })
+
})