diff --git a/bootstrap.css b/bootstrap.css index 6411413ff7261965255553a9fb7624f26f099e03..c39a12264fa287ab1a7adbe6a046a91e2f8bd5a8 100644 --- a/bootstrap.css +++ b/bootstrap.css @@ -6,7 +6,7 @@ * http://www.apache.org/licenses/LICENSE-2.0 * * Designed and built with all the love in the world @twitter by @mdo and @fat. - * Date: Mon Dec 12 09:51:27 PST 2011 + * Date: Tue Dec 20 19:08:51 PST 2011 */ html, body { margin: 0; diff --git a/docs/assets/js/application.js b/docs/assets/js/application.js index 74024caa1d8fab6e8fd06c8540af44023b2d049c..dd759bf8b2345a30f5d913f0d8d8a4c06c0cc8ca 100644 --- a/docs/assets/js/application.js +++ b/docs/assets/js/application.js @@ -37,7 +37,7 @@ $(function(){ // POSITION STATIC TWIPSIES // ======================== - $(window).bind( 'load resize', function () { + $(window).on('load resize', function () { $(".twipsies a").each(function () { $(this) .twipsy({ diff --git a/docs/javascript.html b/docs/javascript.html index 964d2f7aaf0c5b9b20f51328f184336629431f80..45a7a2fe8a83196c207b85fbd0d1e2eca35cd1d9 100644 --- a/docs/javascript.html +++ b/docs/javascript.html @@ -93,7 +93,7 @@ ================================================== --> <header class="jumbotron subhead" id="overview"> <h1>Javascript for Bootstrap</h1> - <p class="lead">Bring Bootstrap's components to life with 12 custom, flexible <a href="http://jquery.com/" target="_blank">jQuery</a> plugins. + <p class="lead">Bring Bootstrap's components to life — now with 12 custom <a href="http://jquery.com/" target="_blank">jQuery</a> plugins. </header> @@ -121,36 +121,40 @@ </thead> <tbody> <tr> - <td><a href="./javascript.html#modal">bootstrap-modal.js</a></td> - <td>Our Modal plugin is a <strong>super</strong> slim take on the traditional modal js plugin! We took special care to include only the bare functionality that we require at twitter.</td> + <td><a href="./javascript.html#transition">bootstrap-transition.js</a></td> + <td>The transition plugin is required for adding animation to other bootstrap plugins. Include this plugin (only once) when sliding in modals or fading out alerts.</td> </tr> <tr> - <td><a href="./javascript.html#alert">bootstrap-alert.js</a></td> - <td>The alert plugin is a super tiny class for adding close functionality to alerts.</td> + <td><a href="./javascript.html#modal">bootstrap-modal.js</a></td> + <td>Our Modal plugin is a super slim take on the traditional modal js plugin! We took special care to include only the bare functionality that we require here at twitter.</td> </tr> <tr> <td><a href="./javascript.html#dropdown">bootstrap-dropdown.js</a></td> - <td>This plugin is for adding dropdown interaction to the bootstrap navbar or tabbed navigations.</td> + <td>This plugin is for adding generic dropdown interactions to things like navigation top bars and tabs.</td> </tr> <tr> <td><a href="./javascript.html#scrollspy">bootstrap-scrollspy.js</a></td> - <td>The ScrollSpy plugin is for adding an auto updating nav based on scroll position to the bootstrap navbar.</td> + <td>The ScrollSpy plugin is for automatically updating nav targets based on scroll position.</td> </tr> <tr> <td><a href="./javascript.html#tab">bootstrap-tab.js</a></td> - <td>This plugin adds quick, dynamic tab and pill functionality for cycling through local content.</td> - </tr> + <td>This plugin adds quick, dynamic tab and pill functionality for transitioning through local content.</td> <tr> <td><a href="./javascript.html#twipsy">bootstrap-twipsy.js</a></td> - <td>Based on the excellent jQuery.tipsy plugin written by Jason Frame; twipsy is an updated version, which doesn't rely on images, uses css3 for animations, and data-attributes for local title storage!</td> + <td>Inspired by the excellent jQuery.tipsy plugin written by Jason Frame; twipsy is an updated version, which doesn't rely on images, uses css3 for animations, data-attributes for local title storage, and now jquery 1.7's new event api!</td> </tr> <tr> <td><a href="./javascript.html#popover">bootstrap-popover.js</a></td> <td>The popover plugin provides a simple interface for adding popovers to your application. It extends the <a href="#twipsy">boostrap-twipsy.js</a> plugin, so be sure to grab that file as well when including popovers in your project!</td> </tr> + </tr> + <tr> + <td><a href="./javascript.html#alert">bootstrap-alert.js</a></td> + <td>The alert plugin is a tiny class for adding close functionality to alerts.</td> + </tr> <tr> <td><a href="./javascript.html#button">bootstrap-button.js</a></td> - <td>This plugin offers additional functionality for managing button state.</td> + <td>This plugin offers additional functionality for managing button state in single buttons and button sets.</td> </tr> <tr> <td><a href="./javascript.html#collapse">bootstrap-collapse.js</a></td> @@ -161,7 +165,6 @@ <h3>Is javascript necessary?</h3> <p><strong>Nope!</strong> Bootstrap is designed first and foremost to be a CSS library. This javascript provides a basic interactive layer on top of the included styles.</p> <p>However, for those who do need javascript, we've provided the plugins above to help you understand how to integrate Bootstrap with javascript and to give you a quick, lightweight option for the basic functionality right away.</p> - <p>For more information and to see some live demos, please refer to our <a href="./javascript.html">plugin documentation page</a>.</p> </div> </div> </section> @@ -265,7 +268,7 @@ $('#myModal').modal({ </table> <pre class="prettyprint linenums"> -$('#myModal').bind('hidden', function () { +$('#myModal').on('hidden', function () { // do something ... })</pre> <h3>Demo</h3> @@ -301,7 +304,7 @@ $('#myModal').bind('hidden', function () { </div> <div class="row"> <div class="span3 columns"> - <p>This plugin is for adding dropdown interaction to the Bootstrap navbar or tabbed navigations.</p> + <p>This plugin is for adding generic dropdown interactions to things like navigation top bars and tabs.</p> <a href="../js/bootstrap-dropdown.js" target="_blank" class="btn primary">Download</a> </div> <div class="span9 columns"> @@ -375,7 +378,7 @@ $('#myModal').bind('hidden', function () { </div> <div class="row"> <div class="span3 columns"> - <p>This plugin is for adding the scrollspy (auto updating nav) interaction to the bootstrap navbar.</p> + <p>The ScrollSpy plugin is for automatically updating nav targets based on scroll position.</p> <a href="../js/bootstrap-scrollspy.js" target="_blank" class="btn primary">Download</a> </div> <div class="span9 columns"> @@ -449,7 +452,7 @@ $('#myModal').bind('hidden', function () { </div> <div class="row"> <div class="span3 columns"> - <p>This plugin adds quick, dynamic tab and pill functionality.</p> + <p>This plugin adds quick, dynamic tab and pill functionality for transitioning through local content.</p> <a href="../js/bootstrap-tab.js" target="_blank" class="btn primary">Download</a> </div> <div class="span9 columns"> @@ -510,7 +513,7 @@ $('#myModal').bind('hidden', function () { </table> <pre class="prettyprint linenums"> -$('a[data-toggle="tab"]').bind('shown', function (e) { +$('a[data-toggle="tab"]').on('shown', function (e) { e.target // activated tab e.relatedTarget // previous tab })</pre> @@ -529,22 +532,22 @@ $('a[data-toggle="tab"]').bind('shown', function (e) { </li> </ul> <div id="myTabContent" class="tab-content"> - <div class="active tab-pane" id="home"> + <div class="tab-pane fade in active" id="home"> <p>Raw denim you probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.</p> </div> - <div class="tab-pane" id="profile"> + <div class="tab-pane fade" id="profile"> <p>Food truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin coffee squid. Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-table craft beer twee. Qui photo booth letterpress, commodo enim craft beer mlkshk aliquip jean shorts ullamco ad vinyl cillum PBR. Homo nostrud organic, assumenda labore aesthetic magna delectus mollit. Keytar helvetica VHS salvia yr, vero magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-bit, sustainable jean shorts beard ut DIY ethical culpa terry richardson biodiesel. Art party scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park.</p> </div> - <div class="tab-pane" id="messages"> + <div class="tab-pane fade" id="messages"> <p>Banksy do proident, brooklyn photo booth delectus sunt artisan sed organic exercitation eiusmod four loko. Quis tattooed iphone esse aliqua. Master cleanse vero fixie mcsweeney's. Ethical portland aute, irony food truck pitchfork lomo eu anim. Aesthetic blog DIY, ethical beard leggings tofu consequat whatever cardigan nostrud. Helvetica you probably haven't heard of them carles, marfa veniam occaecat lomo before they sold out in shoreditch scenester sustainable thundercats. Consectetur tofu craft beer, mollit brunch fap echo park pitchfork mustache dolor.</p> </div> - <div class="tab-pane" id="settings"> + <div class="tab-pane fade" id="settings"> <p>Sunt qui biodiesel mollit officia, fanny pack put a bird on it thundercats seitan squid ad wolf bicycle rights blog. Et aute readymade farm-to-table carles 8-bit, nesciunt nulla etsy adipisicing organic ea. Master cleanse mollit high life, next level Austin nesciunt american apparel twee mustache adipisicing reprehenderit hoodie portland irony. Aliqua tofu quinoa +1 commodo eiusmod. High life williamsburg cupidatat twee homo leggings. Four loko vinyl DIY consectetur nisi, marfa retro keffiyeh vegan. Fanny pack viral retro consectetur gentrify fap.</p> </div> - <div class="tab-pane" id="dropdown1"> + <div class="tab-pane fade" id="dropdown1"> <p>Etsy mixtape wayfarers, ethical wes anderson tofu before they sold out mcsweeney's organic lomo retro fanny pack lo-fi farm-to-table readymade. Messenger bag gentrify pitchfork tattooed craft beer, iphone skateboard locavore carles etsy salvia banksy hoodie helvetica. DIY synth PBR banksy irony. Leggings gentrify squid 8-bit cred pitchfork. Williamsburg banh mi whatever gluten-free, carles pitchfork biodiesel fixie etsy retro mlkshk vice blog. Scenester cred you probably haven't heard of them, vinyl craft beer blog stumptown. Pitchfork sustainable tofu synth chambray yr.</p> </div> - <div class="tab-pane" id="dropdown2"> + <div class="tab-pane fade" id="dropdown2"> <p>Trust fund seitan letterpress, keytar raw denim keffiyeh etsy art party before they sold out master cleanse gluten-free squid scenester freegan cosby sweater. Fanny pack portland seitan DIY, art party locavore wolf cliche high life echo park Austin. Cred vinyl keffiyeh DIY salvia PBR, banh mi before they sold out farm-to-table VHS viral locavore cosby sweater. Lomo wolf viral, mustache readymade thundercats keffiyeh craft beer marfa ethical. Wolf salvia freegan, sartorial keffiyeh echo park vegan.</p> </div> </div> @@ -561,7 +564,7 @@ $('a[data-toggle="tab"]').bind('shown', function (e) { </div> <div class="row"> <div class="span3 columns"> - <p>Based on the excellent jQuery.tipsy plugin written by Jason Frame; twipsy is an updated version, which doesn't rely on images, uses css3 for animations, and data-attributes for title storage!</p> + <p>Inspired by the excellent jQuery.tipsy plugin written by Jason Frame; twipsy is an updated version, which doesn't rely on images, uses css3 for animations, data-attributes for local title storage, and now jquery 1.7's new event api!</p> <a href="../js/bootstrap-twipsy.js" target="_blank" class="btn primary">Download</a> </div> <div class="span9 columns"> @@ -591,16 +594,16 @@ $('a[data-toggle="tab"]').bind('shown', function (e) { <td>how to position the tooltip - above | below | left | right</td> </tr> <tr> - <td>live</td> - <td>boolean</td> + <td>selector</td> + <td>string</td> <td>false</td> - <td>use event delegation instead of individual event handlers</td> + <td>If a selector is provided, twipsy objects will be delegated to the specified targets.</td> </tr> <tr> - <td>offset</td> - <td>number</td> - <td>0</td> - <td>pixel offset of tooltip from target element</td> + <td>title</td> + <td>string | function</td> + <td>''</td> + <td>default title value if `title` tag isn't present</td> </tr> <tr> <td>trigger</td> @@ -622,7 +625,8 @@ $('a[data-toggle="tab"]').bind('shown', function (e) { </table> <p><span class="label notice">Notice</span> Individual twipsy instance options can alternatively be specified through the use of data attributes.</code></p> <h3>Markup</h3> - For performance reasons, the Twipsy and Popover data-apis are opt in. If you would like to use them just set the live flag to true, however we recommend you know what you are doing if you do that. :) + <p> + For performance reasons, the Twipsy and Popover data-apis are opt in. If you would like to use them just specify a selector option.</p> <h3>Methods</h3> <h4>$().twipsy(options)</h4> <p>Attaches a twipsy handler to an element collection.</p> @@ -673,12 +677,6 @@ $('a[data-toggle="tab"]').bind('shown', function (e) { <td>true</td> <td>apply a css fade transition to the tooltip</td> </tr> - <tr> - <td>delay</td> - <td>number | object</td> - <td>0</td> - <td>delay before showing/hiding the tooltip (ms)</td> - </tr> <tr> <td>placement</td> <td>string</td> @@ -686,16 +684,10 @@ $('a[data-toggle="tab"]').bind('shown', function (e) { <td>how to position the popover - above | below | left | right</td> </tr> <tr> - <td>live</td> - <td>boolean</td> + <td>selector</td> + <td>string</td> <td>false</td> - <td>use event delegation instead of individual event handlers</td> - </tr> - <tr> - <td>offset</td> - <td>number</td> - <td>0</td> - <td>pixel offset of tooltip from target element</td> + <td>if a selector is provided, twipsy objects will be delegated to the specified targets</td> </tr> <tr> <td>trigger</td> @@ -703,12 +695,34 @@ $('a[data-toggle="tab"]').bind('shown', function (e) { <td>'hover'</td> <td>how tooltip is triggered - hover | focus | manual</td> </tr> + <tr> + <td>title</td> + <td>string | function</td> + <td>''</td> + <td>default title value if `title` attribute isn't present</td> + </tr> + <tr> + <td>content</td> + <td>string | function</td> + <td>''</td> + <td>default content value if `data-content` attribute isn't present</td> + </tr> + <tr> + <td>delay</td> + <td>number | object</td> + <td>0</td> + <td> + <p>delay showing/hiding the popover (ms)</p> + <p>If a number is supplied, delay is applied to both hide/show</p> + <p>Object structure is: <code>delay: { show: 500, hide: 100 }</code></p> + </td> + </tr> </tbody> </table> <p><span class="label notice">Notice</span> Individual popover instance options can alternatively be specified through the use of data attributes.</code></p> <h3>Markup</h3> <p> - For performance reasons, the Twipsy and Popover data-apis are opt in. If you would like to use them just set the live flag to true, however we recommend you know what you are doing if you do that. :) + For performance reasons, the Twipsy and Popover data-apis are opt in. If you would like to use them just specify a the selector option. </p> <h3>Methods</h3> <h4>$().popover(options)</h4> @@ -969,7 +983,7 @@ $('#myCollapsible').collapse({ </table> <pre class="prettyprint linenums"> -$('#myCollapsible').bind('hidden', function () { +$('#myCollapsible').on('hidden', function () { // do something ... })</pre> <h3>Demo</h3> diff --git a/js/README.md b/js/README.md index 107dd1528194e77e54d1845dd9dce2fd483c48b4..061509fd3afc9cf77d6e9ffc70b67cc3e74c2d1f 100644 --- a/js/README.md +++ b/js/README.md @@ -9,11 +9,11 @@ We believe you should be able to use all plugins provided by Bootstrap purely th We acknowledge that this isn't always the most performant and sometimes it may be desirable to turn this functionality off altogether. Therefore, as of 2.0 we provide the ability to disable the data attribute API by unbinding all events on the body namespaced with `'data-api'`. This looks like this: - $('body').unbind('.data-api') + $('body').off('.data-api') To target a specific plugin, just include the plugins name as a namespace along with the data-api namespace like this: - $('body').unbind('.alert.data-api') + $('body').off('.alert.data-api') --- diff --git a/js/bootstrap-alert.js b/js/bootstrap-alert.js index db9116f76138302f57a6b0bff93cc9b1d7223902..af15cbd7be8260fff86b7af70111610cb6aaf56c 100644 --- a/js/bootstrap-alert.js +++ b/js/bootstrap-alert.js @@ -46,7 +46,7 @@ } $.support.transition && $element.hasClass('fade') ? - $element.bind($.support.transition.end, removeElement) : + $element.on($.support.transition.end, removeElement) : removeElement() } diff --git a/js/bootstrap-modal.js b/js/bootstrap-modal.js index 38f4f51a290b04f46ab70fe69bd2a8b0510a8055..f2624ec1c117a60338e3c0149bad8a538532bac5 100644 --- a/js/bootstrap-modal.js +++ b/js/bootstrap-modal.js @@ -96,7 +96,7 @@ function hideWithTransition() { var that = this , timeout = setTimeout(function () { - that.$element.unbind($.support.transition.end) + that.$element.off($.support.transition.end) hideModal.call(that) }, 500) @@ -156,11 +156,11 @@ function escape() { var that = this if (this.isShown && this.options.keyboard) { - $(document).bind('keyup.dismiss.modal', function ( e ) { + $(document).on('keyup.dismiss.modal', function ( e ) { e.which == 27 && that.hide() }) } else if (!this.isShown) { - $(document).unbind('keyup.dismiss.modal') + $(document).off('keyup.dismiss.modal') } } diff --git a/js/bootstrap-popover.js b/js/bootstrap-popover.js index a0495ce699a1a382b2ff92f857ac6db96054c5bf..53edfc8c9d7d876b4f00f0f40f0f4ce36d316580 100644 --- a/js/bootstrap-popover.js +++ b/js/bootstrap-popover.js @@ -63,8 +63,7 @@ , tip: function() { if (!this.$tip) { - this.$tip = $('<div class="popover" />') - .html(this.options.template) + this.$tip = $(this.options.template) } return this.$tip } @@ -90,7 +89,7 @@ $.fn.popover.defaults = $.extend({} , $.fn.twipsy.defaults, { placement: 'right' , content: '' - , template: '<div class="arrow"></div><div class="inner"><h3 class="title"></h3><div class="content"><p></p></div></div>' + , template: '<div class="popover"><div class="arrow"></div><div class="inner"><h3 class="title"></h3><div class="content"><p></p></div></div></div>' }) }( window.jQuery ) \ No newline at end of file diff --git a/js/bootstrap-scrollspy.js b/js/bootstrap-scrollspy.js index 3c271793c0db8de28feff18e1aee1c1a156eeacc..041cfcb45402892c3d975be06f1cdaa790adaa52 100644 --- a/js/bootstrap-scrollspy.js +++ b/js/bootstrap-scrollspy.js @@ -27,7 +27,7 @@ function ScrollSpy( element ) { var process = $.proxy(this.process, this) - this.$scrollElement = $(element).bind('scroll.scroll.data-api', process) + this.$scrollElement = $(element).on('scroll.scroll.data-api', process) this.selector = (this.$scrollElement.attr('data-target') || this.$scrollElement.attr('href') || '') + ' .nav li > a' diff --git a/js/bootstrap-tab.js b/js/bootstrap-tab.js index e0a92816d4155a1fb983b081d0198626e3ef6d48..2f147c59d82df6fad615571fda74c60dfcc11b94 100644 --- a/js/bootstrap-tab.js +++ b/js/bootstrap-tab.js @@ -52,26 +52,45 @@ $href = $(href) this.activate($this.parent('li'), $ul) - this.activate($href, $href.parent()) - - $this.trigger({ - type: 'shown' - , relatedTarget: previous + this.activate($href, $href.parent(), function () { + $this.trigger({ + type: 'shown' + , relatedTarget: previous + }) }) } - , activate: function ( element, container ) { - container - .find('> .active') - .removeClass('active') - .find('> .dropdown-menu > .active') - .removeClass('active') + , activate: function ( element, container, callback) { + var $active = container.find('> .active') + , transition = callback + && $.support.transition + && $active.hasClass('fade') + + function next() { + $active + .removeClass('active') + .find('> .dropdown-menu > .active') + .removeClass('active') - element.addClass('active') + element.addClass('active') - if ( element.parent('.dropdown-menu') ) { - element.closest('li.dropdown').addClass('active') + if (transition) { + element[0].offsetWidth // reflow for transition + element.addClass('in') + } + + if ( element.parent('.dropdown-menu') ) { + element.closest('li.dropdown').addClass('active') + } + + callback && callback() } + + transition ? + $active.one($.support.transition.end, next) : + next() + + $active.removeClass('in') } } diff --git a/js/bootstrap-twipsy.js b/js/bootstrap-twipsy.js index ee9a415fdb534d43bcc6381c21700afe733c078d..ab744b7c5abb93bb44990dc2566f543bb1dfb389 100644 --- a/js/bootstrap-twipsy.js +++ b/js/bootstrap-twipsy.js @@ -167,7 +167,7 @@ } $.support.transition && this.$tip.hasClass('fade') ? - $tip.bind( $.support.transition.end, removeElement) : + $tip.on($.support.transition.end, removeElement) : removeElement() } @@ -196,7 +196,7 @@ } , tip: function () { - return this.$tip = this.$tip || $('<div class="twipsy" />').html(this.options.template) + return this.$tip = this.$tip || $(this.options.template) } , validate: function () { @@ -256,7 +256,7 @@ , placement: 'above' , trigger: 'hover' , title: '' - , template: '<div class="twipsy-arrow"></div><div class="twipsy-inner"></div>' + , template: '<div class="twipsy"><div class="twipsy-arrow"></div><div class="twipsy-inner"></div></div>' } }( window.jQuery ) \ No newline at end of file