mirror of
https://github.com/twbs/bootstrap.git
synced 2025-10-04 09:11:37 +02:00
tests & docs & twipsy too
This commit is contained in:
5
js/bootstrap-twipsy.js
vendored
5
js/bootstrap-twipsy.js
vendored
@@ -119,7 +119,7 @@
|
||||
|
||||
, setContent: function () {
|
||||
var $tip = this.tip()
|
||||
$tip.find('.twipsy-inner')[this.options.html ? 'html' : 'text'](this.getTitle())
|
||||
$tip.find(this.options.contentSelector)[this.options.html ? 'html' : 'text'](this.getTitle())
|
||||
$tip[0].className = 'twipsy'
|
||||
}
|
||||
|
||||
@@ -302,10 +302,11 @@
|
||||
, title: 'title'
|
||||
, trigger: 'hover'
|
||||
, template: '<div class="twipsy-arrow"></div><div class="twipsy-inner"></div>'
|
||||
, contentSelector: '.twipsy-inner'
|
||||
}
|
||||
|
||||
$.fn.twipsy.elementOptions = function(ele, options) {
|
||||
return $.extend({}, options, $(ele).data())
|
||||
}
|
||||
|
||||
}( window.jQuery || window.ender );
|
||||
}( window.jQuery || window.ender );
|
||||
|
25
js/tests/unit/bootstrap-popover.js
vendored
25
js/tests/unit/bootstrap-popover.js
vendored
@@ -73,4 +73,27 @@ $(function () {
|
||||
$('#qunit-runoff').empty()
|
||||
})
|
||||
|
||||
})
|
||||
test("should allow arbitrary template html with title and content selector options", function() {
|
||||
$.support.transition = false
|
||||
var expectedTitle = 'Gotta make you understand'
|
||||
, popover = $('<a href="#">@rvagg</a>')
|
||||
.attr('title', expectedTitle)
|
||||
.data('content', '<p><b>Never gonna give you up</b>,</p><p>Never gonna let you down</p>')
|
||||
.appendTo('#qunit-runoff')
|
||||
.popover({
|
||||
html: true
|
||||
, titleSelector: 'h1'
|
||||
, contentSelector: '.rick > .roll'
|
||||
, template: '<div class="rick"><h1></h1><div class="roll"></div></div>'
|
||||
})
|
||||
.popover('show')
|
||||
|
||||
ok($('.popover > div > h1').length, 'h1 tag was inserted')
|
||||
ok($('.popover > div > h1').text() === expectedTitle)
|
||||
ok($('.popover > .rick > .roll > p').length === 2, 'p > b tags were inserted')
|
||||
popover.popover('hide')
|
||||
ok(!$('.popover').length, 'popover was removed')
|
||||
$('#qunit-runoff').empty()
|
||||
})
|
||||
|
||||
})
|
||||
|
20
js/tests/unit/bootstrap-twipsy.js
vendored
20
js/tests/unit/bootstrap-twipsy.js
vendored
@@ -78,4 +78,22 @@ $(function () {
|
||||
$('#qunit-runoff').empty()
|
||||
})
|
||||
|
||||
})
|
||||
test("should allow arbitrary template html with content selector options", function() {
|
||||
$.support.transition = false
|
||||
var twipsy = $('<a href="#" rel="twipsy" title="<b>@fat</b>"></a>')
|
||||
.appendTo('#qunit-runoff')
|
||||
.twipsy({
|
||||
html: true
|
||||
, contentSelector: 'h1'
|
||||
, template: '<div><h1>Funky Twipsy!</h1><p class="funky"><b>@rvagg was here</b></p></div>'
|
||||
})
|
||||
.twipsy('show')
|
||||
|
||||
ok($('.twipsy h1').length, 'h1 tag was inserted')
|
||||
ok($('.twipsy p>b').length, 'p > b tags were inserted')
|
||||
ok($('.twipsy h1>b').length, 'h1 tag was customised')
|
||||
twipsy.twipsy('hide')
|
||||
ok(!$(".twipsy").length, 'twipsy removed')
|
||||
$('#qunit-runoff').empty()
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user