]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
add dropdown tab selection support
authorJacob Thornton <jacobthornton@gmail.com>
Wed, 5 Oct 2011 05:11:44 +0000 (22:11 -0700)
committerJacob Thornton <jacobthornton@gmail.com>
Wed, 5 Oct 2011 05:11:44 +0000 (22:11 -0700)
docs/javascript.html
js/bootstrap-tabs.js

index 2891c44602aeadd2aa0ee8b635e9bc994a2b1789..3c3c818fe76abc005fe0aba99cf3b824f7de07ae 100644 (file)
@@ -383,6 +383,13 @@ $('#.tabs').bind('change', function (e) {
             <li><a href="#profile">Profile</a></li>
             <li><a href="#messages">Messages</a></li>
             <li><a href="#settings">Settings</a></li>
+            <li class="dropdown" data-dropdown="dropdown">
+              <a href="#" class="dropdown-toggle">Dropdown</a>
+              <ul class="dropdown-menu">
+                <li><a href="#fat">@fat</a></li>
+                <li><a href="#mdo">@mdo</a></li>
+              </ul>
+            </li>
           </ul>
           <div id="my-tab-content" class="tab-content">
             <div class="active" id="home">
@@ -397,6 +404,12 @@ $('#.tabs').bind('change', function (e) {
             <div 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 id="fat">
+              <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 id="mdo">
+              <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>
         </div>
       </div>
index e8e2dc622d3d3b59facac5a049b9a2683e49d18d..9ccf8543658cbe3625ac935a89887a0f5f2b3daa 100644 (file)
 !function( $ ){
 
   function activate ( element, container ) {
-    container.find('> .active').removeClass('active')
+    container
+      .find('> .active')
+      .removeClass('active')
+      .find('> .dropdown-menu > .active')
+      .removeClass('active')
+
     element.addClass('active')
+
+    if ( element.parent('.dropdown-menu') ) {
+      element.closest('li.dropdown').addClass('active')
+    }
   }
 
   function tab( e ) {
     var $this = $(this)
-      , $ul = $this.closest('ul')
+      , $ul = $this.closest('ul:not(.dropdown-menu)')
       , href = $this.attr('href')
       , previous
 
-    if (/^#\w+/.test(href)) {
+    if ( /^#\w+/.test(href) ) {
       e.preventDefault()
 
-      if ($this.parent('li').hasClass('active')) {
+      if ( $this.parent('li').hasClass('active') ) {
         return
       }
 
-      previous = $ul.find('.active a')[0]
+      previous = $ul.find('.active a').last()[0]
       $href = $(href)
 
       activate($this.parent('li'), $ul)