Revert [7689], gonna try another approach. see #6677

git-svn-id: http://svn.automattic.com/wordpress/trunk@7720 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-04-17 19:32:38 +00:00
parent 35f17e4dea
commit d5f5f07270
7 changed files with 63 additions and 110 deletions

View File

@ -1,28 +0,0 @@
<?php
require('admin.php' );
$post_ID = (int) $_GET['post'];
if ( $post_ID ? !current_user_can( 'edit_post', $post_ID ) : !current_user_can( 'edit_posts' ) )
die();
ob_start();
$popular_ids = wp_popular_terms_checklist('category');
ob_end_clean();
?>
<ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
<?php dropdown_categories( 0, 0, $popular_ids ); ?>
</ul>
<div id="category-add-hidden" style="display: none;">
<input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" tabindex="3" />
<?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?>
<input type="button" id="category-add-sumbit" class="add:categorychecklist:category-add button" value="<?php _e( 'Add' ); ?>" tabindex="3" />
<?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?>
<span id="category-ajax-response"></span>
</div>

View File

@ -219,17 +219,29 @@ endif; ?>
<div id="category-adder" class="wp-hidden-children">
<h4><a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a></h4>
<p id="category-add" class="wp-hidden-child"></p>
<p id="category-add" class="wp-hidden-child">
<input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" tabindex="3" />
<?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?>
<input type="button" id="category-add-sumbit" class="add:categorychecklist:category-add button" value="<?php _e( 'Add' ); ?>" tabindex="3" />
<?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?>
<span id="category-ajax-response"></span>
</p>
</div>
<ul id="category-tabs">
<li class="ui-tabs-selected"><a href="#categories-pop" tabindex="3"><?php _e( 'Most Used' ); ?></a></li>
<li class="wp-no-js-hidden"><a id="category-tabs-all" href="edit-form-advanced-tabs.php?post=<?php echo $post_ID; ?>" tabindex="3"><?php _e( 'All Categories' ); ?></a></li>
<li class="ui-tabs-selected"><a href="#categories-all" tabindex="3"><?php _e( 'All Categories' ); ?></a></li>
<li class="wp-no-js-hidden"><a href="#categories-pop" tabindex="3"><?php _e( 'Most Used' ); ?></a></li>
</ul>
<div id="categories-pop" class="ui-tabs-panel" style="display: none;">
<ul id="categorychecklist-pop" class="categorychecklist form-no-clear" >
<?php $popular_ids = wp_popular_terms_checklist('category'); // If we up the # here we have to do so in edit-form-advanced-tabs.php too ?>
<?php $popular_ids = wp_popular_terms_checklist('category'); ?>
</ul>
</div>
<div id="categories-all" class="ui-tabs-panel">
<ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
<?php dropdown_categories( 0, 0, $popular_ids ); ?>
</ul>
</div>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -194,8 +194,6 @@ 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();
@ -206,7 +204,7 @@ function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10 ) {
<li id="<?php echo $id; ?>" class="popular-category">
<label class="selectit" for="in-<?php echo $id; ?>">
<input id="in-<?php echo $id; ?>" type="checkbox" value="<?php echo (int) $category->term_id; ?>" name="post_category[]" <?php checked( in_array( $category->term_id, $checked_categories ), true ); ?> />
<input id="in-<?php echo $id; ?>" type="checkbox" value="<?php echo (int) $category->term_id; ?>" />
<?php echo wp_specialchars( apply_filters( 'the_category', $category->name ) ); ?>
</label>
</li>

View File

@ -100,79 +100,60 @@ jQuery(document).ready( function() {
jQuery('#newtag').keypress( tag_press_key );
// category 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');
var categoryTabs =jQuery('#category-tabs').tabs();
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;
noSyncChecks = true;
// 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 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( '<option value="' + parseInt( val, 10 ) + '"></option>' ).text( name );
newCatParent.prepend( o );
} );
newCatParentOption.attr( 'selected', true );
} );
};
jQuery('#categorychecklist').wpList( {
alt: '',
response: 'category-ajax-response',
addBefore: catAddBefore,
addAfter: catAddAfter
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( '<option value="' + parseInt( val, 10 ) + '"></option>' ).text( name );
newCatParent.prepend( o );
} );
jQuery('.categorychecklist .popular-category :checkbox').change( syncChecks ).filter( ':checked' ).change();
if ( newCatFocus ) {
jQuery('#newcat').focus();
newCatFocus = false;
}
}
newCatParentOption.attr( 'selected', true );
} );
};
jQuery('#categorychecklist').wpList( {
alt: '',
response: 'category-ajax-response',
addBefore: catAddBefore,
addAfter: catAddAfter
} );
jQuery('#category-add-toggle').click( function() {
jQuery(this).parents('div:first').toggleClass( 'wp-hidden-children' );
categoryTabs.tabsClick( 2 );
categoryTabs.tabsClick( 1 );
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")) {

View File

@ -1269,16 +1269,6 @@ 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;

View File

@ -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'), '20080412' );
$this->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20080411' );
$this->localize( 'post', 'postL10n', array(
'tagsUsed' => __('Tags used on this post:'),
'add' => attribute_escape(__('Add')),