Merge branch '1.3-wip' of github.com:twitter/bootstrap into 1.3-wip

This commit is contained in:
Mark Otto 2011-09-12 08:58:46 -07:00
commit 6a5fb52bb1
7 changed files with 63 additions and 69 deletions

View File

@ -1,11 +1,5 @@
$(document).ready(function(){ $(document).ready(function(){
// Scrollspy
// =========
$('body > .topbar').scrollSpy()
// table sort example // table sort example
// ================== // ==================

View File

@ -37,7 +37,7 @@
<!-- Topbar <!-- Topbar
================================================== --> ================================================== -->
<div class="topbar"> <div class="topbar" data-scrollspy="x" >
<div class="topbar-inner"> <div class="topbar-inner">
<div class="container"> <div class="container">
<a class="brand" href="#">Bootstrap</a> <a class="brand" href="#">Bootstrap</a>
@ -1262,7 +1262,7 @@
</div> </div>
<h2>Fixed topbar</h2> <h2>Fixed topbar</h2>
<div class="topbar-wrapper" style="z-index: 5;"> <div class="topbar-wrapper" style="z-index: 5;">
<div class="topbar" data-dropdown> <div class="topbar" data-dropdown="x" >
<div class="topbar-inner"> <div class="topbar-inner">
<div class="container"> <div class="container">
<h3><a href="#">Project Name</a></h3> <h3><a href="#">Project Name</a></h3>
@ -1331,7 +1331,7 @@
<li><a href="#">Messages</a></li> <li><a href="#">Messages</a></li>
<li><a href="#">Settings</a></li> <li><a href="#">Settings</a></li>
<li><a href="#">Contact</a></li> <li><a href="#">Contact</a></li>
<li class="dropdown" data-dropdown> <li class="dropdown" data-dropdown="x">
<a href="#" class="dropdown-toggle">Dropdown</a> <a href="#" class="dropdown-toggle">Dropdown</a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a href="#">Secondary link</a></li> <li><a href="#">Secondary link</a></li>

View File

@ -39,7 +39,7 @@
<!-- Topbar <!-- Topbar
================================================== --> ================================================== -->
<div class="topbar" data-scrollspy> <div class="topbar" data-scrollspy="x" >
<div class="fill"> <div class="fill">
<div class="container"> <div class="container">
<h3><a href="#">Bootstrap JS</a></h3> <h3><a href="#">Bootstrap JS</a></h3>
@ -120,7 +120,7 @@
</tbody> </tbody>
</table> </table>
<h3>Markup</h3> <h3>Markup</h3>
<p>You can activate modals on your page easily without having to write a single line of javascript. Just give an element a <code>data-controls-modal</code> which corresponds to a modal element id, and when clicked, it will launch your modal. To add modal options, just include them as data attributes as well.</p> <p>You can activate modals on your page easily without having to write a single line of javascript. Just give an element a <code>data-controls-modal</code> attribute which corresponds to a modal element id, and when clicked, it will launch your modal. To add modal options, just include them as data attributes as well.</p>
<pre class="prettyprint linenums"> <pre class="prettyprint linenums">
&lt;a class="btn" data-controls-modal="my-modal" data-backdrop="true" &gt;Launch Modal&lt;/a&gt; &lt;a class="btn" data-controls-modal="my-modal" data-backdrop="true" &gt;Launch Modal&lt;/a&gt;
</pre> </pre>
@ -146,19 +146,11 @@ $('#my-modal').modal({
<pre class="prettyprint linenums">$('#my-modal').modal(true)</pre> <pre class="prettyprint linenums">$('#my-modal').modal(true)</pre>
<p><span class="label notice">Notice</span> Alternatively, this can be retrieved with <code>$().data('modal')</code>.</p> <p><span class="label notice">Notice</span> Alternatively, this can be retrieved with <code>$().data('modal')</code>.</p>
<h3>Events</h3> <h3>Events</h3>
<p>Bootstrap's modal class exposes a few events for hooking into modal functionality. The include:</p> <p>Bootstrap's modal class exposes a few events for hooking into modal functionality. </p>
<!-- <ul>
<li><strong>show</strong> - This event fires immediately when the <code>show</code> instance method is called.</li>
<li><strong>shown</strong> - This event is fired when the modal has been made visible to the user (will wait for css transitions to complete).</li>
<li><strong>hide</strong> - This event is fired immediately when the <code>hide</code> instance method has been called.</li>
<li><strong>hidden</strong> - This event is fired when the modal has finished being hidden from the user (will wait for css transitions to complete).</li>
</ul> -->
<table class="zebra-striped"> <table class="zebra-striped">
<thead> <thead>
<tr> <tr>
<th style="width: 150px;">Name</th> <th style="width: 150px;">Event</th>
<th>Description</th> <th>Description</th>
</tr> </tr>
</thead> </thead>
@ -229,7 +221,7 @@ $('#my-modal').bind('hidden', function () {
<pre class="prettyprint linenums"> <pre class="prettyprint linenums">
&lt;ul class="tabs"&gt; &lt;ul class="tabs"&gt;
&lt;li class="active"&gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li class="active"&gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/li&gt;
&lt;li class="dropdown" data-dropdown&gt; &lt;li class="dropdown" data-dropdown="x" &gt;
&lt;a href="#" class="dropdown-toggle"&gt;Dropdown&lt;/a&gt; &lt;a href="#" class="dropdown-toggle"&gt;Dropdown&lt;/a&gt;
&lt;ul class="dropdown-menu"&gt; &lt;ul class="dropdown-menu"&gt;
&lt;li&gt;&lt;a href="#"&gt;Secondary link&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Secondary link&lt;/a&gt;&lt;/li&gt;
@ -247,7 +239,7 @@ $('#my-modal').bind('hidden', function () {
</p> </p>
<h3>Demo</h3> <h3>Demo</h3>
<div class="topbar-wrapper"> <div class="topbar-wrapper">
<div id="topbar-example" class="topbar" data-dropdown> <div id="topbar-example" class="topbar" data-dropdown="x">
<div class="topbar-inner"> <div class="topbar-inner">
<div class="container"> <div class="container">
<h3><a href="#">Project Name</a></h3> <h3><a href="#">Project Name</a></h3>
@ -303,20 +295,20 @@ $('#my-modal').bind('hidden', function () {
<pre class="prettyprint linenums">$('#topbar').dropdown()</pre> <pre class="prettyprint linenums">$('#topbar').dropdown()</pre>
<h3>Markup</h3> <h3>Markup</h3>
<p>To easily add scrollspy behavior to your nav, just add the <code>data-scrollspy</code> attribute to the <code>.topbar</code>. <p>To easily add scrollspy behavior to your nav, just add the <code>data-scrollspy</code> attribute to the <code>.topbar</code>.
<pre class="prettyprint linenums">&lt;div class="topbar" data-scrollspy &gt;...&lt;/div&gt;</pre> <pre class="prettyprint linenums">&lt;div class="topbar" data-scrollspy="x" &gt;...&lt;/div&gt;</pre>
<h3>Methods</h3> <h3>Methods</h3>
<h4>$().scrollspy()</h4> <h4>$().scrollspy()</h4>
<p> <p>
Auto activates navigation buttons by users scroll position. Auto activates navigation buttons by users scroll position.
</p> </p>
<pre class="prettyprint linenums">$('body > .topbar').scrollSpy()</pre> <pre class="prettyprint linenums">$('body > .topbar').scrollSpy()</pre>
<p><span class="label notice">Notice</span> Topbar anchor tags must have resolvable id targets. For example, a <code>&lt;a href="#home"&gt;home&lt;/a&gt;</code> might correspond to a <code>&lt;div id="home"&gt;&lt;/div&gt;</code>. <p><span class="label notice">Notice</span> Topbar anchor tags must have resolvable id targets. For example, a <code>&lt;a href="#home"&gt;home&lt;/a&gt;</code> must correspond to something in the dom like <code>&lt;div id="home"&gt;&lt;/div&gt;</code>.
</p> </p>
<h4>.scrollspy('refresh')</h4> <h4>.scrollspy('refresh')</h4>
<p>The scrollspy caches nav buttons and section coordinates for performance. If you need to update this cache (likely if you have dynamic content) just call this refresh method. If you used the data attribute to define your scrollspy, just call refresh on the body like below.</p> <p>The scrollspy caches nav buttons and section coordinates for performance. If you need to update this cache (likely if you have dynamic content) just call this refresh method. If you used the data attribute to define your scrollspy, just call refresh on the body.</p>
<pre class="prettyprint linenums">$('body').scrollspy('refresh')</pre> <pre class="prettyprint linenums">$('body').scrollspy('refresh')</pre>
<h3>Demo</h3> <h3>Demo</h3>
<p>Look at the topbar navigation on this page.</p> <p>Checkout the the topbar navigation on this page.</p>
</div> </div>
</div> </div>
</section> </section>
@ -338,7 +330,7 @@ $('#my-modal').bind('hidden', function () {
<pre class="prettyprint linenums">$('.tabs').tabs()</pre> <pre class="prettyprint linenums">$('.tabs').tabs()</pre>
<h3>Markup</h3> <h3>Markup</h3>
<p>You can activate a tab or pill navigation without writing any javascript by simply giving them a <code>data-tabs</code> or <code>data-pills</code> attribute.</p> <p>You can activate a tab or pill navigation without writing any javascript by simply giving them a <code>data-tabs</code> or <code>data-pills</code> attribute.</p>
<pre class="prettyprint linenums"> &lt;ul class="tabs" data-tabs &gt;...&lt;/ul&gt;</pre> <pre class="prettyprint linenums"> &lt;ul class="tabs" data-tabs="x" &gt;...&lt;/ul&gt;</pre>
<h3>Methods</h3> <h3>Methods</h3>
<h4>$().tabs or $().pills</h4> <h4>$().tabs or $().pills</h4>
<p> <p>
@ -366,7 +358,7 @@ $('#my-modal').bind('hidden', function () {
&lt;/script&gt;</pre> &lt;/script&gt;</pre>
</p> </p>
<h3>Demo</h3> <h3>Demo</h3>
<ul class="tabs" data-tabs > <ul class="tabs" data-tabs="x" >
<li class="active"><a href="#home">Home</a></li> <li class="active"><a href="#home">Home</a></li>
<li><a href="#profile">Profile</a></li> <li><a href="#profile">Profile</a></li>
<li><a href="#messages">Messages</a></li> <li><a href="#messages">Messages</a></li>
@ -648,11 +640,11 @@ Sunt qui biodiesel mollit officia, fanny pack put a bird on it thundercats seita
<p>Closes an alert.</p> <p>Closes an alert.</p>
<pre class="prettyprint linenums">$(".alert-message").alert('close')</pre> <pre class="prettyprint linenums">$(".alert-message").alert('close')</pre>
<h3>Demo</h3> <h3>Demo</h3>
<div class="alert-message warning fade in" data-alert > <div class="alert-message warning fade in" data-alert="x" >
<a class="close" href="#">&times;</a> <a class="close" href="#">&times;</a>
<p><strong>Holy guacamole!</strong> Best check yo self, youre not looking too good.</p> <p><strong>Holy guacamole!</strong> Best check yo self, youre not looking too good.</p>
</div> </div>
<div class="alert-message block-message error fade in" data-alert > <div class="alert-message block-message error fade in" data-alert="x" >
<a class="close" href="#">&times;</a> <a class="close" href="#">&times;</a>
<p><strong>Oh snap! You got an error!</strong> Change this and that and try again. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum.</p> <p><strong>Oh snap! You got an error!</strong> Change this and that and try again. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum.</p>
<div class="alert-actions"> <div class="alert-actions">

View File

@ -10,7 +10,7 @@
<link rel="stylesheet" href="vendor/qunit.css" type="text/css" media="screen" /> <link rel="stylesheet" href="vendor/qunit.css" type="text/css" media="screen" />
<script src="vendor/qunit.js"></script> <script src="vendor/qunit.js"></script>
<!-- plugin sources --> <!-- plugin sources -->
<script src="../../js/bootstrap-alerts.js"></script> <script src="../../js/bootstrap-alerts.js"></script>
<script src="../../js/bootstrap-dropdown.js"></script> <script src="../../js/bootstrap-dropdown.js"></script>
<script src="../../js/bootstrap-modal.js"></script> <script src="../../js/bootstrap-modal.js"></script>

View File

@ -16,36 +16,37 @@ $(function () {
ok($.fn.modal.defaults, 'default object exposed') ok($.fn.modal.defaults, 'default object exposed')
}) })
test("should insert into dom when modal:show event is called", function () { test("should insert into dom when show method is called", function () {
stop() stop()
$.support.transition = false $.support.transition = false
var div = $("<div id='modal-test'></div>") var div = $("<div id='modal-test'></div>")
div div
.modal() .modal()
.trigger("modal:show") .modal("show")
.bind("modal:shown", function () { .bind("shown", function () {
ok($('#modal-test').length, 'modal insterted into dom') ok($('#modal-test').length, 'modal insterted into dom')
start() start()
div.remove() div.remove()
}) })
}) })
test("should remove from dom when modal:hide is called", function () { test("should hide modal when hide is called", function () {
stop() stop()
$.support.transition = false $.support.transition = false
var div = $("<div id='modal-test'></div>") var div = $("<div id='modal-test'></div>")
div div
.modal() .modal()
.trigger("modal:show") .bind("shown", function () {
.bind("modal:shown", function () { ok($('#modal-test').is(":visible"), 'modal visible')
ok($('#modal-test').length, 'modal insterted into dom') ok($('#modal-test').length, 'modal insterted into dom')
div.trigger("modal:hide") div.modal("hide")
}) })
.bind("modal:hidden", function() { .bind("hidden", function() {
ok(!$('#modal-test').length, 'modal removed from dom') ok(!$('#modal-test').is(":visible"), 'modal hidden')
start() start()
div.remove() div.remove()
}) })
.modal("show")
}) })
test("should toggle when toggle is called", function () { test("should toggle when toggle is called", function () {
@ -54,16 +55,17 @@ $(function () {
var div = $("<div id='modal-test'></div>") var div = $("<div id='modal-test'></div>")
div div
.modal() .modal()
.trigger("modal:toggle") .bind("shown", function () {
.bind("modal:shown", function () { ok($('#modal-test').is(":visible"), 'modal visible')
ok($('#modal-test').length, 'modal insterted into dom') ok($('#modal-test').length, 'modal insterted into dom')
div.trigger("modal:toggle") div.modal("toggle")
}) })
.bind("modal:hidden", function() { .bind("hidden", function() {
ok(!$('#modal-test').length, 'modal removed from dom') ok(!$('#modal-test').is(":visible"), 'modal hidden')
start() start()
div.remove() div.remove()
}) })
.modal("toggle")
}) })
test("should remove from dom when click .close", function () { test("should remove from dom when click .close", function () {
@ -72,15 +74,16 @@ $(function () {
var div = $("<div id='modal-test'><span class='close'></span></div>") var div = $("<div id='modal-test'><span class='close'></span></div>")
div div
.modal() .modal()
.trigger("modal:toggle") .bind("shown", function () {
.bind("modal:shown", function () { ok($('#modal-test').is(":visible"), 'modal visible')
ok($('#modal-test').length, 'modal insterted into dom') ok($('#modal-test').length, 'modal insterted into dom')
div.find('.close').click() div.find('.close').click()
}) })
.bind("modal:hidden", function() { .bind("hidden", function() {
ok(!$('#modal-test').length, 'modal removed from dom') ok(!$('#modal-test').is(":visible"), 'modal hidden')
start() start()
div.remove() div.remove()
}) })
.modal("toggle")
}) })
}) })

View File

@ -14,20 +14,20 @@ $(function () {
test("should render popover element", function () { test("should render popover element", function () {
$.support.transition = false $.support.transition = false
var popover = $('<a href="#" data-title="mdo" data-content="http://twitter.com/mdo">@mdo</a>') var popover = $('<a href="#" title="mdo" data-content="http://twitter.com/mdo">@mdo</a>')
.appendTo('#qunit-runoff') .appendTo('#qunit-runoff')
.popover() .popover()
.trigger('popover:show') .popover('show')
ok($('.popover').length, 'popover was inserted') ok($('.popover').length, 'popover was inserted')
popover.trigger('popover:hide') popover.popover('hide')
ok(!$(".popover").length, 'popover removed') ok(!$(".popover").length, 'popover removed')
$('#qunit-runoff').empty() $('#qunit-runoff').empty()
}) })
test("should store popover instance in popover data object", function () { test("should store popover instance in popover data object", function () {
$.support.transition = false $.support.transition = false
var popover = $('<a href="#" data-title="mdo" data-content="http://twitter.com/mdo">@mdo</a>') var popover = $('<a href="#" title="mdo" data-content="http://twitter.com/mdo">@mdo</a>')
.popover() .popover()
ok(!!popover.data('popover'), 'popover instance exists') ok(!!popover.data('popover'), 'popover instance exists')
@ -38,32 +38,37 @@ $(function () {
var popover = $('<a href="#">@fat</a>') var popover = $('<a href="#">@fat</a>')
.appendTo('#qunit-runoff') .appendTo('#qunit-runoff')
.popover({ .popover({
title: '@fat' title: function () {
, content: 'loves writing tests (╯°□°)╯︵ ┻━┻' return '@fat'
}
, content: function () {
return 'loves writing tests (╯°□°)╯︵ ┻━┻'
}
}) })
.trigger('popover:show')
popover.popover('show')
ok($('.popover').length, 'popover was inserted') ok($('.popover').length, 'popover was inserted')
equals($('.popover .title').text(), '@fat', 'title correctly inserted') equals($('.popover .title').text(), '@fat', 'title correctly inserted')
equals($('.popover .content').text(), 'loves writing tests (╯°□°)╯︵ ┻━┻', 'content correctly inserted') equals($('.popover .content').text(), 'loves writing tests (╯°□°)╯︵ ┻━┻', 'content correctly inserted')
popover.trigger('popover:hide') popover.popover('hide')
ok(!$('.popover').length, 'popover was removed') ok(!$('.popover').length, 'popover was removed')
$('#qunit-runoff').empty() $('#qunit-runoff').empty()
}) })
test("should get title and content from attributes", function () { test("should get title and content from attributes", function () {
$.support.transition = false $.support.transition = false
var popover = $('<a href="#" data-title="@mdo" data-content="loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻" >@mdo</a>') var popover = $('<a href="#" title="@mdo" data-content="loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻" >@mdo</a>')
.appendTo('#qunit-runoff') .appendTo('#qunit-runoff')
.popover() .popover()
.trigger('popover:show') .popover('show')
ok($('.popover').length, 'popover was inserted') ok($('.popover').length, 'popover was inserted')
equals($('.popover .title').text(), '@mdo', 'title correctly inserted') equals($('.popover .title').text(), '@mdo', 'title correctly inserted')
equals($('.popover .content').text(), "loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻", 'content correctly inserted') equals($('.popover .content').text(), "loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻", 'content correctly inserted')
popover.trigger('popover:hide') popover.popover('hide')
ok(!$('.popover').length, 'popover was removed') ok(!$('.popover').length, 'popover was removed')
$('#qunit-runoff').empty() $('#qunit-runoff').empty()
}) })

View File

@ -31,10 +31,10 @@ $(function () {
var twipsy = $('<a href="#" rel="twipsy" title="Another twipsy"></a>') var twipsy = $('<a href="#" rel="twipsy" title="Another twipsy"></a>')
.appendTo('#qunit-runoff') .appendTo('#qunit-runoff')
.twipsy({placement: 'below'}) .twipsy({placement: 'below'})
.trigger('twipsy:show') .twipsy('show')
ok($(".twipsy").hasClass('fade below in'), 'has correct classes applied') ok($(".twipsy").hasClass('fade below in'), 'has correct classes applied')
twipsy.trigger('twipsy:hide') twipsy.twipsy('hide')
ok(!$(".twipsy").length, 'twipsy removed') ok(!$(".twipsy").length, 'twipsy removed')
$('#qunit-runoff').empty() $('#qunit-runoff').empty()
}) })
@ -44,10 +44,10 @@ $(function () {
var twipsy = $('<a href="#" rel="twipsy"></a>') var twipsy = $('<a href="#" rel="twipsy"></a>')
.appendTo('#qunit-runoff') .appendTo('#qunit-runoff')
.twipsy({fallback: '@fat'}) .twipsy({fallback: '@fat'})
.trigger('twipsy:show') .twipsy('show')
equals($(".twipsy").text(), "@fat", 'has correct default text') equals($(".twipsy").text(), "@fat", 'has correct default text')
twipsy.trigger('twipsy:hide') twipsy.twipsy('hide')
ok(!$(".twipsy").length, 'twipsy removed') ok(!$(".twipsy").length, 'twipsy removed')
$('#qunit-runoff').empty() $('#qunit-runoff').empty()
}) })
@ -57,10 +57,10 @@ $(function () {
var twipsy = $('<a href="#" rel="twipsy" title="<b>@fat</b>"></a>') var twipsy = $('<a href="#" rel="twipsy" title="<b>@fat</b>"></a>')
.appendTo('#qunit-runoff') .appendTo('#qunit-runoff')
.twipsy() .twipsy()
.trigger('twipsy:show') .twipsy('show')
ok(!$('.twipsy b').length, 'b tag was not inserted') ok(!$('.twipsy b').length, 'b tag was not inserted')
twipsy.trigger('twipsy:hide') twipsy.twipsy('hide')
ok(!$(".twipsy").length, 'twipsy removed') ok(!$(".twipsy").length, 'twipsy removed')
$('#qunit-runoff').empty() $('#qunit-runoff').empty()
}) })
@ -70,10 +70,10 @@ $(function () {
var twipsy = $('<a href="#" rel="twipsy" title="<b>@fat</b>"></a>') var twipsy = $('<a href="#" rel="twipsy" title="<b>@fat</b>"></a>')
.appendTo('#qunit-runoff') .appendTo('#qunit-runoff')
.twipsy({html: true}) .twipsy({html: true})
.trigger('twipsy:show') .twipsy('show')
ok($('.twipsy b').length, 'b tag was inserted') ok($('.twipsy b').length, 'b tag was inserted')
twipsy.trigger('twipsy:hide') twipsy.twipsy('hide')
ok(!$(".twipsy").length, 'twipsy removed') ok(!$(".twipsy").length, 'twipsy removed')
$('#qunit-runoff').empty() $('#qunit-runoff').empty()
}) })