[wp-trac] [WordPress Trac] #17959: WP-Tab css

WordPress Trac wp-trac at lists.automattic.com
Thu Nov 10 23:28:59 UTC 2011


#17959: WP-Tab css
--------------------------+------------------------------
 Reporter:  WraithKenny   |       Owner:  WraithKenny
     Type:  defect (bug)  |      Status:  accepted
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  UI            |     Version:  3.2
 Severity:  minor         |  Resolution:
 Keywords:  has-patch     |
--------------------------+------------------------------

Comment (by WraithKenny):

 The generic script to achieve it is:
 {{{
 jQuery(document).ready( function($) {
         // wp tabs
         $('.wp-tab-bar a').click(function(event){
                 event.preventDefault();
                 // Limit effect to the container element.
                 var context = $(this).parents('.wp-tab-
 bar').first().parent();
                 $('.wp-tab-bar li', context).removeClass('wp-tab-active');
                 $(this).parents('li').first().addClass('wp-tab-active');
                 $('.wp-tab-panel', context).hide();
                 $( $(this).attr('href'), context ).show();
         });
         // Make setting wp-tab-active optional.
         $('.wp-tab-bar').each(function(){
                 if ( $('.wp-tab-active', this).length )
                         $('.wp-tab-active', this).click();
                 else $('a', this).first().click();
         });
 });


 }}}
 The purpose of doing `.parents('...').first()` is to allow flexibility in
 the markup. Incoming patch adds this script, and makes postbox dependent
 on this script to include it anywhere that postbox is.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/17959#comment:11>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list