diff options
| author | Jacob Thornton <[email protected]> | 2011-11-07 09:58:42 -0800 |
|---|---|---|
| committer | Jacob Thornton <[email protected]> | 2011-11-07 09:58:42 -0800 |
| commit | b37a336417b0ef447eed78a66762be1ac0f0fba4 (patch) | |
| tree | 36dd344d259281aef171fa46cfe9b17e258970aa /js | |
| parent | b15e24e3d460ef2cbe20f13c648b42024be096fa (diff) | |
| parent | 1b43c87eafc8948c517770282a63227cd9c5d792 (diff) | |
| download | bootstrap-b37a336417b0ef447eed78a66762be1ac0f0fba4.tar.xz bootstrap-b37a336417b0ef447eed78a66762be1ac0f0fba4.zip | |
Merge pull request #554 from rvagg/poveropt
optionable selectors for title & content elements
Diffstat (limited to 'js')
| -rw-r--r-- | js/bootstrap-popover.js | 8 | ||||
| -rw-r--r-- | js/tests/unit/bootstrap-popover.js | 25 |
2 files changed, 29 insertions, 4 deletions
diff --git a/js/bootstrap-popover.js b/js/bootstrap-popover.js index c63778415..e8b49af3c 100644 --- a/js/bootstrap-popover.js +++ b/js/bootstrap-popover.js @@ -36,8 +36,8 @@ setContent: function () { var $tip = this.tip() - $tip.find('.title')[this.options.html ? 'html' : 'text'](this.getTitle()) - $tip.find('.content p')[this.options.html ? 'html' : 'text'](this.getContent()) + $tip.find(this.options.titleSelector)[this.options.html ? 'html' : 'text'](this.getTitle()) + $tip.find(this.options.contentSelector)[this.options.html ? 'html' : 'text'](this.getContent()) $tip[0].className = 'popover' } @@ -83,8 +83,10 @@ placement: 'right' , content: 'data-content' , template: '<div class="arrow"></div><div class="inner"><h3 class="title"></h3><div class="content"><p></p></div></div>' + , titleSelector: '.title' + , contentSelector: '.content p' }) $.fn.twipsy.rejectAttrOptions.push( 'content' ) -}( window.jQuery || window.ender );
\ No newline at end of file +}( window.jQuery || window.ender ); diff --git a/js/tests/unit/bootstrap-popover.js b/js/tests/unit/bootstrap-popover.js index 3e13d2fd2..823526727 100644 --- a/js/tests/unit/bootstrap-popover.js +++ b/js/tests/unit/bootstrap-popover.js @@ -73,4 +73,27 @@ $(function () { $('#qunit-runoff').empty() }) -})
\ No newline at end of file + 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) + .attr('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() + }) + +}) |
