mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 17:18:32 +01:00
Fixes for new categories interface from mdawaffe. fixes #5618
git-svn-id: http://svn.automattic.com/wordpress/trunk@6591 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
1f71b9227d
commit
db44305ce1
@ -173,7 +173,7 @@ case 'add-category' : // On the Fly
|
||||
if ( $parent ) // Do these all at once in a second
|
||||
continue;
|
||||
$category = get_category( $cat_id );
|
||||
$category->_is_checked = true;
|
||||
$checked_categories[] = $cat_id;
|
||||
ob_start();
|
||||
dropdown_categories( 0, $category );
|
||||
$data = ob_get_contents();
|
||||
|
@ -125,7 +125,7 @@ else
|
||||
<div id="category-adder" class="wp-hidden-children">
|
||||
<h4><a id="category-add-toggle" href="#category-add"><?php _e( '+ Add New Category' ); ?></a></h4>
|
||||
<p id="category-add" class="wp-hidden-child">
|
||||
<input type="text" name="newcat" id="newcat" class="form-required" value="<?php _e( 'New category name' ); ?>" />
|
||||
<input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" />
|
||||
<?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category') ) ); ?>
|
||||
<a id="category-add-sumbit" class="add:categorychecklist:categorydiv button" href="<?php echo wp_nonce_url( '', 'add-category' ); ?>"><?php _e( 'Add' ); ?></a>
|
||||
<span id="category-ajax-response"></span>
|
||||
|
@ -144,7 +144,7 @@ function get_nested_categories( $default = 0, $parent = 0 ) {
|
||||
$root = array(
|
||||
'children' => get_nested_categories( $default, $parent->term_id ),
|
||||
'cat_ID' => $parent->term_id,
|
||||
'checked' => isset($parent->_is_checked) && $parent->_is_checked,
|
||||
'checked' => in_array( $parent->term_id, $checked_categories ),
|
||||
'cat_name' => get_the_category_by_ID( $parent->term_id )
|
||||
);
|
||||
$result = array( $parent->term_id => $root );
|
||||
|
@ -69,20 +69,16 @@ addLoadEvent( function() {
|
||||
jQuery('#tags-input').hide();
|
||||
tag_update_quickclicks();
|
||||
// add the quickadd form
|
||||
jQuery('#jaxtag').prepend('<span id="ajaxtag"><input type="text" name="newtag" id="newtag" size="16" autocomplete="off" value="'+postL10n.addTag+'" /><input type="button" class="button" id="tagadd" value="' + postL10n.add + '"/><input type="hidden"/><input type="hidden"/><span class="howto">'+postL10n.separate+'</span></span>');
|
||||
jQuery('#jaxtag').prepend('<span id="ajaxtag"><input type="text" name="newtag" id="newtag" class="form-input-tip" size="16" autocomplete="off" value="'+postL10n.addTag+'" /><input type="button" class="button" id="tagadd" value="' + postL10n.add + '"/><input type="hidden"/><input type="hidden"/><span class="howto">'+postL10n.separate+'</span></span>');
|
||||
jQuery('#tagadd').click( tag_flush_to_text );
|
||||
// jQuery('#newtag').keydown( tag_press_key );
|
||||
jQuery('#newtag').focus(function() {
|
||||
if ( this.value == postL10n.addTag ) {
|
||||
this.value = '';
|
||||
this.style.color = '#333';
|
||||
}
|
||||
if ( this.value == postL10n.addTag )
|
||||
jQuery(this).val( '' ).removeClass( 'form-input-tip' );
|
||||
});
|
||||
jQuery('#newtag').blur(function() {
|
||||
if ( this.value == '' ) {
|
||||
this.value = postL10n.addTag;
|
||||
this.style.color = '#999'
|
||||
}
|
||||
if ( this.value == '' )
|
||||
jQuery(this).val( postL10n.addTag ).addClass( 'form-input-tip' );
|
||||
});
|
||||
|
||||
// auto-suggest stuff
|
||||
@ -95,14 +91,25 @@ addLoadEvent( function() {
|
||||
var categoryTabs =jQuery('#category-tabs').tabs();
|
||||
|
||||
// Ajax Cat
|
||||
var newCat = jQuery('#newcat').one( 'focus', function() { jQuery(this).val( '' ) } );
|
||||
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 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());
|
||||
var o = jQuery( '<option value="' + parseInt( t.find(':input').val(), 10 ) + '"></option>' );
|
||||
o.text( jQuery.trim( t.text() ) );
|
||||
jQuery('#newcat_parent').prepend( o );
|
||||
t.find( 'label' ).each( function() {
|
||||
var th = jQuery(this);
|
||||
var id = th.find('input').val();
|
||||
if ( newCatParent.find( 'option[value=' + id + ']' ).size() )
|
||||
return;
|
||||
var name = jQuery.trim( th.text() );
|
||||
var o = jQuery( '<option value="' + parseInt( id, 10 ) + '"></option>' ).text( name );
|
||||
newCatParent.prepend( o );
|
||||
newCatParentOption.attr( 'selected', true );
|
||||
} );
|
||||
} );
|
||||
};
|
||||
jQuery('#categorychecklist').wpList( {
|
||||
|
@ -1090,10 +1090,6 @@ a.view-comment-post-link {
|
||||
background: url(images/xit.gif) no-repeat -10px 0;
|
||||
}
|
||||
|
||||
#newtag {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.howto {
|
||||
font-style: italic;
|
||||
display: block;
|
||||
@ -1284,3 +1280,4 @@ ul.categorychecklist li {
|
||||
/* Global classes */
|
||||
.wp-hidden-children .wp-hidden-child { display: none; }
|
||||
.ui-tabs-hide { display: none; }
|
||||
.form-input-tip { color: #999; }
|
||||
|
@ -267,25 +267,17 @@ var wpList = {
|
||||
list = $(this);
|
||||
e = $(e);
|
||||
|
||||
var old = false; var next = false;
|
||||
var old = false;
|
||||
var _s = { pos: 0, id: 0, oldId: null };
|
||||
if ( 'string' == typeof s ) { s = { what: s }; }
|
||||
s = $.extend(_s, this.wpList.settings, s);
|
||||
|
||||
if ( !e.size() || !s.what ) { return false; }
|
||||
if ( s.oldId ) {
|
||||
old = $('#' + s.what + '-' + s.oldId);
|
||||
next = old.next();
|
||||
old.remove();
|
||||
}
|
||||
if ( s.id ) { $('#' + s.what + '-' + s.id).remove(); }
|
||||
if ( s.oldId ) { old = $('#' + s.what + '-' + s.oldId); }
|
||||
if ( s.id && ( s.id != s.oldId || !old || !old.size() ) ) { $('#' + s.what + '-' + s.id).remove(); }
|
||||
|
||||
if ( old && old.size() ) {
|
||||
if ( next && next.size() ) {
|
||||
next.before(e);
|
||||
} else {
|
||||
list.append(e);
|
||||
}
|
||||
old.replaceWith(e);
|
||||
} else if ( isNaN(s.pos) ) {
|
||||
var ba = 'after';
|
||||
if ( '-' == s.pos.substr(0,1) ) {
|
||||
@ -331,8 +323,6 @@ var wpList = {
|
||||
|
||||
process: function(el) {
|
||||
var list = this;
|
||||
var bl = function() { currentFormEl = false; };
|
||||
var fo = function() { currentFormEl = this; };
|
||||
var a = $("[@class^=add:" + list.id + ":]", el || null)
|
||||
.filter('form').submit( function() { return list.wpList.add(this); } ).end()
|
||||
.not('form').click( function() { return list.wpList.add(this); } ).each( function() {
|
||||
@ -340,16 +330,15 @@ var wpList = {
|
||||
var c = wpList.parseClass(this,'add')[2] || addEl.id;
|
||||
if ( !c ) { return; }
|
||||
var forms = []; var ins = [];
|
||||
$('#' + c + ' :input').click( function() { $(this).unbind( 'blur', bl ).unbind( 'focus', fo ).blur( bl ).focus( fo ).focus(); } ).each( function() {
|
||||
$('#' + c + ' :input').focus( function() { currentFormEl = this; } ).blur( function() { currentFormEl = false; } ).each( function() {
|
||||
ins.push(this);
|
||||
$.merge(forms,$(this).parents('form'));
|
||||
forms = $.unique(forms);
|
||||
} );
|
||||
$(forms).submit( function() {
|
||||
var e = currentFormEl;
|
||||
if ( 0 <= $.inArray(e,ins) ) {
|
||||
if ( 0 <= $.inArray(currentFormEl,ins) ) {
|
||||
$(addEl).trigger( 'click' );
|
||||
$(e).focus();
|
||||
$(currentFormEl).focus();
|
||||
return false;
|
||||
}
|
||||
} );
|
||||
|
@ -60,7 +60,7 @@ class WP_Scripts {
|
||||
'delText' => __('Are you sure you want to delete this %thing%?')
|
||||
) );
|
||||
|
||||
$this->add( 'wp-lists', '/wp-includes/js/wp-lists.js', array('jquery'), '20080109' );
|
||||
$this->add( 'wp-lists', '/wp-includes/js/wp-lists.js', array('jquery'), '20080110' );
|
||||
$this->localize( 'wp-lists', 'wpListL10n', array(
|
||||
'url' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php'
|
||||
) );
|
||||
@ -108,7 +108,7 @@ class WP_Scripts {
|
||||
$this->add( 'admin-forms', '/wp-admin/js/forms.js', array('wp-lists'), '20080108' );
|
||||
$this->add( 'xfn', '/wp-admin/js/xfn.js', false, '3517' );
|
||||
$this->add( 'upload', '/wp-admin/js/upload.js', array('jquery'), '20070518' );
|
||||
$this->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists'), '20080109' );
|
||||
$this->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists'), '20080110' );
|
||||
$this->localize( 'post', 'postL10n', array(
|
||||
'tagsUsed' => __('Tags used on this post:'),
|
||||
'add' => attribute_escape(__('Add')),
|
||||
|
Loading…
Reference in New Issue
Block a user