diff --git a/wp-admin/edit-form-advanced-tabs.php b/wp-admin/edit-form-advanced-tabs.php new file mode 100644 index 000000000..34acad882 --- /dev/null +++ b/wp-admin/edit-form-advanced-tabs.php @@ -0,0 +1,28 @@ + + + + + + + diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index 7bafd08e6..d6d059428 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -219,29 +219,17 @@ endif; ?>

-

- - 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?> - - - -

+

- -
-
diff --git a/wp-admin/images/loading.gif b/wp-admin/images/loading.gif new file mode 100644 index 000000000..85b99d46b Binary files /dev/null and b/wp-admin/images/loading.gif differ diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index c34d4fea3..f99e810ce 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -194,6 +194,8 @@ function dropdown_categories( $default = 0, $parent = 0, $popular_ids = array() } function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10 ) { + global $checked_categories; + wp_set_checked_post_categories( $default ); $categories = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number ) ); $popular_ids = array(); @@ -204,7 +206,7 @@ function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10 ) { diff --git a/wp-admin/js/post.js b/wp-admin/js/post.js index 18c9706fa..790cfa4a3 100644 --- a/wp-admin/js/post.js +++ b/wp-admin/js/post.js @@ -100,60 +100,79 @@ jQuery(document).ready( function() { jQuery('#newtag').keypress( tag_press_key ); // category tabs - var categoryTabs =jQuery('#category-tabs').tabs(); + var newCatFocus = false; + var categoryTabs =jQuery('#category-tabs').tabs( { + cache: true, + show: function(ui) { + if ( 'category-tabs-all' != ui.id ) { return; } // only do this for the all tab + var adder = jQuery('#category-add-hidden'); - // Ajax Cat - var newCat = jQuery('#newcat').one( 'focus', function() { jQuery(this).val( '' ).removeClass( 'form-input-tip' ) } ); - jQuery('#category-add-sumbit').click( function() { newCat.focus(); } ); - var newCatParent = false; - var newCatParentOption = false; - var noSyncChecks = false; // prophylactic. necessary? - var syncChecks = function() { - if ( noSyncChecks ) - return; - noSyncChecks = true; - var th = jQuery(this); - var c = th.is(':checked'); - var id = th.val().toString(); - jQuery('#in-category-' + id + ', #in-popular-category-' + id).attr( 'checked', c ); - noSyncChecks = false; - }; - var catAddBefore = function( s ) { - s.data += '&' + jQuery( '#categorychecklist :checked' ).serialize(); - return s; - }; - var catAddAfter = function( r, s ) { - if ( !newCatParent ) newCatParent = jQuery('#newcat_parent'); - if ( !newCatParentOption ) newCatParentOption = newCatParent.find( 'option[value=-1]' ); - jQuery(s.what + ' response_data', r).each( function() { - var t = jQuery(jQuery(this).text()); - t.find( 'label' ).each( function() { - var th = jQuery(this); - var val = th.find('input').val(); - var id = th.find('input')[0].id - jQuery('#' + id).change( syncChecks ); - if ( newCatParent.find( 'option[value=' + val + ']' ).size() ) + if ( !adder.size() ) { return; } // we're already done + + // Put HTML in proper place and set up the wp-lists etc + jQuery('#category-add').html( adder.remove().html() ); + + // Ajax Cat + var newCat = jQuery('#newcat').one( 'focus', function() { jQuery(this).val( '' ).removeClass( 'form-input-tip' ) } ); + jQuery('#category-add-sumbit').click( function() { newCat.focus(); } ); + var newCatParent = false; + var newCatParentOption = false; + var noSyncChecks = false; // prophylactic. necessary? + var syncChecks = function() { + if ( noSyncChecks ) return; - var name = jQuery.trim( th.text() ); - var o = jQuery( '' ).text( name ); - newCatParent.prepend( o ); + noSyncChecks = true; + var th = jQuery(this); + var c = th.is(':checked'); + var id = th.val().toString(); + jQuery('#in-category-' + id + ', #in-popular-category-' + id).attr( 'checked', c ); + noSyncChecks = false; + }; + var catAddBefore = function( s ) { + s.data += '&' + jQuery( '#categorychecklist :checked' ).serialize(); + return s; + }; + var catAddAfter = function( r, s ) { + if ( !newCatParent ) newCatParent = jQuery('#newcat_parent'); + if ( !newCatParentOption ) newCatParentOption = newCatParent.find( 'option[value=-1]' ); + jQuery(s.what + ' response_data', r).each( function() { + var t = jQuery(jQuery(this).text()); + t.find( 'label' ).each( function() { + var th = jQuery(this); + var val = th.find('input').val(); + var id = th.find('input')[0].id + jQuery('#' + id).change( syncChecks ); + if ( newCatParent.find( 'option[value=' + val + ']' ).size() ) + return; + var name = jQuery.trim( th.text() ); + var o = jQuery( '' ).text( name ); + newCatParent.prepend( o ); + } ); + newCatParentOption.attr( 'selected', true ); + } ); + }; + jQuery('#categorychecklist').wpList( { + alt: '', + response: 'category-ajax-response', + addBefore: catAddBefore, + addAfter: catAddAfter } ); - newCatParentOption.attr( 'selected', true ); - } ); - }; - jQuery('#categorychecklist').wpList( { - alt: '', - response: 'category-ajax-response', - addBefore: catAddBefore, - addAfter: catAddAfter + jQuery('.categorychecklist .popular-category :checkbox').change( syncChecks ).filter( ':checked' ).change(); + + if ( newCatFocus ) { + jQuery('#newcat').focus(); + newCatFocus = false; + } + } } ); + jQuery('#category-add-toggle').click( function() { jQuery(this).parents('div:first').toggleClass( 'wp-hidden-children' ); - categoryTabs.tabsClick( 1 ); + categoryTabs.tabsClick( 2 ); jQuery('#newcat').focus(); + newCatFocus = true; return false; } ); - jQuery('.categorychecklist .popular-category :checkbox').change( syncChecks ).filter( ':checked' ).change(); jQuery('.edit-timestamp').click(function () { if (jQuery('#timestampdiv').is(":hidden")) { diff --git a/wp-admin/wp-admin.css b/wp-admin/wp-admin.css index 4cb517992..ccf742d81 100644 --- a/wp-admin/wp-admin.css +++ b/wp-admin/wp-admin.css @@ -1265,6 +1265,16 @@ ul.categorychecklist li { margin: 0; } +ul#category-tabs a { + width: 100%; + display: block; +} + +.ui-tabs-loading { + outline: none; + background: url(../images/loading.gif) no-repeat 0 50%; +} + #linkcategorydiv ul#category-tabs { float: left; width: 120px; diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index eadbb2c43..0daeece70 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -144,7 +144,7 @@ class WP_Scripts { 'save' => __('Save'), 'cancel' => __('Cancel'), ) ); - $this->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20080411' ); + $this->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20080412' ); $this->localize( 'post', 'postL10n', array( 'tagsUsed' => __('Tags used on this post:'), 'add' => attribute_escape(__('Add')),