mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-29 15:47:38 +02:00
Use new jQuery methods when adding, editing and deleting tags with AJAX, fix warning when deleting tags, see #10239
git-svn-id: http://svn.automattic.com/wordpress/trunk@11676 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
1a88d01e90
commit
f385e7da46
@ -213,20 +213,18 @@ case 'delete-cat' :
|
|||||||
die('0');
|
die('0');
|
||||||
break;
|
break;
|
||||||
case 'delete-tag' :
|
case 'delete-tag' :
|
||||||
check_ajax_referer( "delete-tag_$id" );
|
$tag_id = (int) $_POST['tag_ID'];
|
||||||
|
check_ajax_referer( "delete-tag_$tag_id" );
|
||||||
if ( !current_user_can( 'manage_categories' ) )
|
if ( !current_user_can( 'manage_categories' ) )
|
||||||
die('-1');
|
die('-1');
|
||||||
|
|
||||||
if ( !empty($_POST['taxonomy']) )
|
$taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
|
||||||
$taxonomy = $_POST['taxonomy'];
|
|
||||||
else
|
|
||||||
$taxonomy = 'post_tag';
|
|
||||||
|
|
||||||
$tag = get_term( $id, $taxonomy );
|
$tag = get_term( $tag_id, $taxonomy );
|
||||||
if ( !$tag || is_wp_error( $tag ) )
|
if ( !$tag || is_wp_error( $tag ) )
|
||||||
die('1');
|
die('1');
|
||||||
|
|
||||||
if ( wp_delete_term($id, $taxonomy))
|
if ( wp_delete_term($tag_id, $taxonomy))
|
||||||
die('1');
|
die('1');
|
||||||
else
|
else
|
||||||
die('0');
|
die('0');
|
||||||
@ -527,43 +525,16 @@ case 'add-tag' : // From Manage->Tags
|
|||||||
if ( !current_user_can( 'manage_categories' ) )
|
if ( !current_user_can( 'manage_categories' ) )
|
||||||
die('-1');
|
die('-1');
|
||||||
|
|
||||||
if ( '' === trim($_POST['name']) ) {
|
$taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
|
||||||
$x = new WP_Ajax_Response( array(
|
$tag = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST );
|
||||||
'what' => 'tag',
|
|
||||||
'id' => new WP_Error( 'name', __('You did not enter a tag name.') )
|
if ( !$tag || is_wp_error($tag) || (!$tag = get_term( $tag['term_id'], $taxonomy )) ) {
|
||||||
) );
|
echo '<div class="error"><p>' . __('An error has occured. Please reload the page and try again.') . '</p></div>';
|
||||||
$x->send();
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !empty($_POST['taxonomy']) )
|
echo _tag_row( $tag, '', $taxonomy );
|
||||||
$taxonomy = $_POST['taxonomy'];
|
exit;
|
||||||
else
|
|
||||||
$taxonomy = 'post_tag';
|
|
||||||
|
|
||||||
$tag = wp_insert_term($_POST['name'], $taxonomy, $_POST );
|
|
||||||
|
|
||||||
if ( is_wp_error($tag) ) {
|
|
||||||
$x = new WP_Ajax_Response( array(
|
|
||||||
'what' => 'tag',
|
|
||||||
'id' => $tag
|
|
||||||
) );
|
|
||||||
$x->send();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !$tag || (!$tag = get_term( $tag['term_id'], $taxonomy )) )
|
|
||||||
die('0');
|
|
||||||
|
|
||||||
$tag_full_name = $tag->name;
|
|
||||||
$tag_full_name = esc_attr($tag_full_name);
|
|
||||||
|
|
||||||
$x = new WP_Ajax_Response( array(
|
|
||||||
'what' => 'tag',
|
|
||||||
'id' => $tag->term_id,
|
|
||||||
'position' => '-1',
|
|
||||||
'data' => _tag_row( $tag, '', $taxonomy ),
|
|
||||||
'supplemental' => array('name' => $tag_full_name, 'show-link' => sprintf(__( 'Tag <a href="#%s">%s</a> added' ), "tag-$tag->term_id", $tag_full_name))
|
|
||||||
) );
|
|
||||||
$x->send();
|
|
||||||
break;
|
break;
|
||||||
case 'get-tagcloud' :
|
case 'get-tagcloud' :
|
||||||
if ( !current_user_can( 'edit_posts' ) )
|
if ( !current_user_can( 'edit_posts' ) )
|
||||||
@ -1148,10 +1119,7 @@ case 'inline-save-tax':
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case 'tag' :
|
case 'tag' :
|
||||||
if ( !empty($_POST['taxonomy']) )
|
$taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
|
||||||
$taxonomy = $_POST['taxonomy'];
|
|
||||||
else
|
|
||||||
$taxonomy = 'post_tag';
|
|
||||||
|
|
||||||
$tag = get_term( $id, $taxonomy );
|
$tag = get_term( $id, $taxonomy );
|
||||||
$_POST['description'] = $tag->description;
|
$_POST['description'] = $tag->description;
|
||||||
@ -1162,7 +1130,7 @@ case 'inline-save-tax':
|
|||||||
if ( !$tag || is_wp_error( $tag ) )
|
if ( !$tag || is_wp_error( $tag ) )
|
||||||
die( __('Tag not updated.') );
|
die( __('Tag not updated.') );
|
||||||
|
|
||||||
echo _tag_row($tag);
|
echo _tag_row($tag, '', $taxonomy);
|
||||||
} else {
|
} else {
|
||||||
die( __('Tag not updated.') );
|
die( __('Tag not updated.') );
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ case 'addtag':
|
|||||||
if ( !current_user_can('manage_categories') )
|
if ( !current_user_can('manage_categories') )
|
||||||
wp_die(__('Cheatin’ uh?'));
|
wp_die(__('Cheatin’ uh?'));
|
||||||
|
|
||||||
$ret = wp_insert_term($_POST['name'], $taxonomy, $_POST);
|
$ret = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST);
|
||||||
if ( $ret && !is_wp_error( $ret ) ) {
|
if ( $ret && !is_wp_error( $ret ) ) {
|
||||||
wp_redirect('edit-tags.php?message=1#addtag');
|
wp_redirect('edit-tags.php?message=1#addtag');
|
||||||
} else {
|
} else {
|
||||||
@ -155,6 +155,7 @@ if ( isset($_GET['s']) && $_GET['s'] )
|
|||||||
<div id="message" class="updated fade"><p><?php echo $messages[$msg]; ?></p></div>
|
<div id="message" class="updated fade"><p><?php echo $messages[$msg]; ?></p></div>
|
||||||
<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
|
<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
|
||||||
endif; ?>
|
endif; ?>
|
||||||
|
<div id="ajax-response"></div>
|
||||||
|
|
||||||
<form class="search-form" action="" method="get">
|
<form class="search-form" action="" method="get">
|
||||||
<input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" />
|
<input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" />
|
||||||
@ -274,15 +275,14 @@ else
|
|||||||
|
|
||||||
<div class="form-wrap">
|
<div class="form-wrap">
|
||||||
<h3><?php _e('Add a New Tag'); ?></h3>
|
<h3><?php _e('Add a New Tag'); ?></h3>
|
||||||
<div id="ajax-response"></div>
|
<form id="addtag" method="post" action="edit-tags.php" class="validate">
|
||||||
<form name="addtag" id="addtag" method="post" action="edit-tags.php" class="add:the-list: validate">
|
<input type="hidden" name="action" value="add-tag" />
|
||||||
<input type="hidden" name="action" value="addtag" />
|
|
||||||
<input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" />
|
<input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" />
|
||||||
<?php wp_original_referer_field(true, 'previous'); wp_nonce_field('add-tag'); ?>
|
<?php wp_nonce_field('add-tag'); ?>
|
||||||
|
|
||||||
<div class="form-field form-required">
|
<div class="form-field form-required">
|
||||||
<label for="name"><?php _e('Tag name') ?></label>
|
<label for="tag-name"><?php _e('Tag name') ?></label>
|
||||||
<input name="name" id="name" type="text" value="" size="40" aria-required="true" />
|
<input name="tag-name" id="tag-name" type="text" value="" size="40" aria-required="true" />
|
||||||
<p><?php _e('The name is how the tag appears on your site.'); ?></p>
|
<p><?php _e('The name is how the tag appears on your site.'); ?></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -298,7 +298,7 @@ else
|
|||||||
<p><?php _e('The description is not prominent by default, however some themes may show it.'); ?></p>
|
<p><?php _e('The description is not prominent by default, however some themes may show it.'); ?></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="submit"><input type="submit" class="button" name="submit" value="<?php esc_attr_e('Add Tag'); ?>" /></p>
|
<p class="submit"><input type="submit" class="button" name="submit" id="submit" value="<?php esc_attr_e('Add Tag'); ?>" /></p>
|
||||||
<?php do_action('add_tag_form'); ?>
|
<?php do_action('add_tag_form'); ?>
|
||||||
</form></div>
|
</form></div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
@ -663,7 +663,7 @@ function _tag_row( $tag, $class = '', $taxonomy = 'post_tag' ) {
|
|||||||
$actions = array();
|
$actions = array();
|
||||||
$actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
|
$actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
|
||||||
$actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
|
$actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
|
||||||
$actions['delete'] = "<a class='delete:the-list:tag-$tag->term_id submitdelete' href='" . wp_nonce_url("edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id) . "'>" . __('Delete') . "</a>";
|
$actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url("edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id) . "'>" . __('Delete') . "</a>";
|
||||||
$actions = apply_filters('tag_row_actions', $actions, $tag);
|
$actions = apply_filters('tag_row_actions', $actions, $tag);
|
||||||
$action_count = count($actions);
|
$action_count = count($actions);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
@ -730,7 +730,7 @@ function tag_rows( $page = 1, $pagesize = 20, $searchterms = '', $taxonomy = 'po
|
|||||||
$out = '';
|
$out = '';
|
||||||
$count = 0;
|
$count = 0;
|
||||||
foreach( $tags as $tag )
|
foreach( $tags as $tag )
|
||||||
$out .= _tag_row( $tag, ++$count % 2 ? ' class="iedit alternate"' : ' class="iedit"', $taxonomy );
|
$out .= _tag_row( $tag, ++$count % 2 ? ' class="alternate"' : '', $taxonomy );
|
||||||
|
|
||||||
// filter and send to screen
|
// filter and send to screen
|
||||||
echo $out;
|
echo $out;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
jQuery(document).ready(function($) {
|
jQuery(document).ready(function($) {
|
||||||
var options = false, addAfter, addAfter2, delBefore, delAfter;
|
var options = false, addAfter, delBefore, delAfter;
|
||||||
if ( document.forms['addcat'].category_parent )
|
if ( document.forms['addcat'].category_parent )
|
||||||
options = document.forms['addcat'].category_parent.options;
|
options = document.forms['addcat'].category_parent.options;
|
||||||
|
|
||||||
@ -9,14 +9,6 @@ jQuery(document).ready(function($) {
|
|||||||
name = $("<span>" + $('name', r).text() + "</span>").html();
|
name = $("<span>" + $('name', r).text() + "</span>").html();
|
||||||
id = $('cat', r).attr('id');
|
id = $('cat', r).attr('id');
|
||||||
options[options.length] = new Option(name, id);
|
options[options.length] = new Option(name, id);
|
||||||
|
|
||||||
addAfter2( r, settings );
|
|
||||||
}
|
|
||||||
|
|
||||||
addAfter2 = function( x, r ) {
|
|
||||||
var t = $(r.parsed.responses[0].data);
|
|
||||||
if ( t.length == 1 )
|
|
||||||
inlineEditTax.addEvents($(t.id));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delAfter = function( r, settings ) {
|
delAfter = function( r, settings ) {
|
||||||
@ -36,7 +28,7 @@ jQuery(document).ready(function($) {
|
|||||||
if ( options )
|
if ( options )
|
||||||
$('#the-list').wpList( { addAfter: addAfter, delBefore: delBefore, delAfter: delAfter } );
|
$('#the-list').wpList( { addAfter: addAfter, delBefore: delBefore, delAfter: delAfter } );
|
||||||
else
|
else
|
||||||
$('#the-list').wpList({ addAfter: addAfter2, delBefore: delBefore });
|
$('#the-list').wpList({ delBefore: delBefore });
|
||||||
|
|
||||||
$('.delete a[class^="delete"]').click(function(){return false;});
|
$('.delete a[class^="delete"]').click(function(){return false;});
|
||||||
});
|
});
|
||||||
|
@ -1 +1 @@
|
|||||||
jQuery(document).ready(function(d){var b=false,f,e,c,a;if(document.forms.addcat.category_parent){b=document.forms.addcat.category_parent.options}f=function(i,h){var g,j;g=d("<span>"+d("name",i).text()+"</span>").html();j=d("cat",i).attr("id");b[b.length]=new Option(g,j);e(i,h)};e=function(g,i){var h=d(i.parsed.responses[0].data);if(h.length==1){inlineEditTax.addEvents(d(h.id))}};a=function(h,g){var j=d("cat",h).attr("id"),i;for(i=0;i<b.length;i++){if(j==b[i].value){b[i]=null}}};c=function(g){if("undefined"!=showNotice){return showNotice.warn()?g:false}return g};if(b){d("#the-list").wpList({addAfter:f,delBefore:c,delAfter:a})}else{d("#the-list").wpList({addAfter:e,delBefore:c})}d('.delete a[class^="delete"]').click(function(){return false})});
|
jQuery(document).ready(function(d){var b=false,e,c,a;if(document.forms.addcat.category_parent){b=document.forms.addcat.category_parent.options}e=function(h,g){var f,i;f=d("<span>"+d("name",h).text()+"</span>").html();i=d("cat",h).attr("id");b[b.length]=new Option(f,i)};a=function(g,f){var i=d("cat",g).attr("id"),h;for(h=0;h<b.length;h++){if(i==b[h].value){b[h]=null}}};c=function(f){if("undefined"!=showNotice){return showNotice.warn()?f:false}return f};if(b){d("#the-list").wpList({addAfter:e,delBefore:c,delAfter:a})}else{d("#the-list").wpList({delBefore:c})}d('.delete a[class^="delete"]').click(function(){return false})});
|
@ -1,4 +1,4 @@
|
|||||||
var showNotice, adminMenu, columns;
|
var showNotice, adminMenu, columns, validateForm;
|
||||||
(function($){
|
(function($){
|
||||||
// sidebar admin menu
|
// sidebar admin menu
|
||||||
adminMenu = {
|
adminMenu = {
|
||||||
@ -122,6 +122,10 @@ columns = {
|
|||||||
|
|
||||||
$(document).ready(function(){columns.init();});
|
$(document).ready(function(){columns.init();});
|
||||||
|
|
||||||
|
validateForm = function( form ) {
|
||||||
|
return !$( form ).find('.form-required').filter( function() { return $('input:visible', this).val() == ''; } ).addClass( 'form-invalid' ).change( function() { $(this).removeClass( 'form-invalid' ); } ).size();
|
||||||
|
}
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|
||||||
// stub for doing better warnings
|
// stub for doing better warnings
|
||||||
|
File diff suppressed because one or more lines are too long
@ -8,8 +8,10 @@ inlineEditTax = {
|
|||||||
t.type = $('#the-list').attr('className').substr(5);
|
t.type = $('#the-list').attr('className').substr(5);
|
||||||
t.what = '#'+t.type+'-';
|
t.what = '#'+t.type+'-';
|
||||||
|
|
||||||
// get all editable rows
|
$('.editinline').live('click', function(){
|
||||||
t.rows = $('tr.iedit');
|
inlineEditTax.edit(this);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
// prepare the edit row
|
// prepare the edit row
|
||||||
row.keyup(function(e) { if(e.which == 27) return inlineEditTax.revert(); });
|
row.keyup(function(e) { if(e.which == 27) return inlineEditTax.revert(); });
|
||||||
@ -18,9 +20,6 @@ inlineEditTax = {
|
|||||||
$('a.save', row).click(function() { return inlineEditTax.save(this); });
|
$('a.save', row).click(function() { return inlineEditTax.save(this); });
|
||||||
$('input, select', row).keydown(function(e) { if(e.which == 13) return inlineEditTax.save(this); });
|
$('input, select', row).keydown(function(e) { if(e.which == 13) return inlineEditTax.save(this); });
|
||||||
|
|
||||||
// add events
|
|
||||||
t.addEvents(t.rows);
|
|
||||||
|
|
||||||
$('#posts-filter input[type="submit"]').click(function(e){
|
$('#posts-filter input[type="submit"]').click(function(e){
|
||||||
if ( $('form#posts-filter tr.inline-editor').length > 0 )
|
if ( $('form#posts-filter tr.inline-editor').length > 0 )
|
||||||
t.revert();
|
t.revert();
|
||||||
@ -32,12 +31,6 @@ inlineEditTax = {
|
|||||||
$(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el);
|
$(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el);
|
||||||
},
|
},
|
||||||
|
|
||||||
addEvents : function(r) {
|
|
||||||
r.each(function() {
|
|
||||||
$(this).find('a.editinline').click(function() { inlineEditTax.edit(this); return false; });
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
edit : function(id) {
|
edit : function(id) {
|
||||||
var t = this, editRow;
|
var t = this, editRow;
|
||||||
t.revert();
|
t.revert();
|
||||||
@ -77,7 +70,7 @@ inlineEditTax = {
|
|||||||
taxonomy: tax
|
taxonomy: tax
|
||||||
};
|
};
|
||||||
|
|
||||||
fields = $('#edit-'+id+' :input').fieldSerialize();
|
fields = $('#edit-'+id+' :input').serialize();
|
||||||
params = fields + '&' + $.param(params);
|
params = fields + '&' + $.param(params);
|
||||||
|
|
||||||
// make ajax request
|
// make ajax request
|
||||||
@ -93,10 +86,7 @@ inlineEditTax = {
|
|||||||
|
|
||||||
$('#edit-'+id).before(r).remove();
|
$('#edit-'+id).before(r).remove();
|
||||||
row = new_id ? $('#'+new_id) : $(inlineEditTax.what+id);
|
row = new_id ? $('#'+new_id) : $(inlineEditTax.what+id);
|
||||||
row.hide();
|
row.hide().fadeIn();
|
||||||
|
|
||||||
inlineEditTax.addEvents(row);
|
|
||||||
row.fadeIn();
|
|
||||||
} else
|
} else
|
||||||
$('#edit-'+id+' .inline-edit-save .error').html(r).show();
|
$('#edit-'+id+' .inline-edit-save .error').html(r).show();
|
||||||
} else
|
} else
|
||||||
|
@ -1 +1 @@
|
|||||||
(function(a){inlineEditTax={init:function(){var b=this,c=a("#inline-edit");b.type=a("#the-list").attr("className").substr(5);b.what="#"+b.type+"-";b.rows=a("tr.iedit");c.keyup(function(d){if(d.which==27){return inlineEditTax.revert()}});a("a.cancel",c).click(function(){return inlineEditTax.revert()});a("a.save",c).click(function(){return inlineEditTax.save(this)});a("input, select",c).keydown(function(d){if(d.which==13){return inlineEditTax.save(this)}});b.addEvents(b.rows);a('#posts-filter input[type="submit"]').click(function(d){if(a("form#posts-filter tr.inline-editor").length>0){b.revert()}})},toggle:function(c){var b=this;a(b.what+b.getId(c)).css("display")=="none"?b.revert():b.edit(c)},addEvents:function(b){b.each(function(){a(this).find("a.editinline").click(function(){inlineEditTax.edit(this);return false})})},edit:function(d){var c=this,b;c.revert();if(typeof(d)=="object"){d=c.getId(d)}b=a("#inline-edit").clone(true),rowData=a("#inline_"+d);a("td",b).attr("colspan",a(".widefat:first thead th:visible").length);if(a(c.what+d).hasClass("alternate")){a(b).addClass("alternate")}a(c.what+d).hide().after(b);a(':input[name="name"]',b).val(a(".name",rowData).text());a(':input[name="slug"]',b).val(a(".slug",rowData).text());a(b).attr("id","edit-"+d).addClass("inline-editor").show();a(".ptitle",b).eq(0).focus();return false},save:function(e){var d,b,c=a('input[name="taxonomy"]').val()||"";if(typeof(e)=="object"){e=this.getId(e)}a("table.widefat .inline-edit-save .waiting").show();d={action:"inline-save-tax",tax_type:this.type,tax_ID:e,taxonomy:c};b=a("#edit-"+e+" :input").fieldSerialize();d=b+"&"+a.param(d);a.post("admin-ajax.php",d,function(g){var h,f;a("table.widefat .inline-edit-save .waiting").hide();if(g){if(-1!=g.indexOf("<tr")){a(inlineEditTax.what+e).remove();f=a(g).attr("id");a("#edit-"+e).before(g).remove();h=f?a("#"+f):a(inlineEditTax.what+e);h.hide();inlineEditTax.addEvents(h);h.fadeIn()}else{a("#edit-"+e+" .inline-edit-save .error").html(g).show()}}else{a("#edit-"+e+" .inline-edit-save .error").html(inlineEditL10n.error).show()}});return false},revert:function(){var b=a("table.widefat tr.inline-editor").attr("id");if(b){a("table.widefat .inline-edit-save .waiting").hide();a("#"+b).remove();b=b.substr(b.lastIndexOf("-")+1);a(this.what+b).show()}return false},getId:function(c){var d=c.tagName=="TR"?c.id:a(c).parents("tr").attr("id"),b=d.split("-");return b[b.length-1]}};a(document).ready(function(){inlineEditTax.init()})})(jQuery);
|
(function(a){inlineEditTax={init:function(){var b=this,c=a("#inline-edit");b.type=a("#the-list").attr("className").substr(5);b.what="#"+b.type+"-";a(".editinline").live("click",function(){inlineEditTax.edit(this);return false});c.keyup(function(d){if(d.which==27){return inlineEditTax.revert()}});a("a.cancel",c).click(function(){return inlineEditTax.revert()});a("a.save",c).click(function(){return inlineEditTax.save(this)});a("input, select",c).keydown(function(d){if(d.which==13){return inlineEditTax.save(this)}});a('#posts-filter input[type="submit"]').click(function(d){if(a("form#posts-filter tr.inline-editor").length>0){b.revert()}})},toggle:function(c){var b=this;a(b.what+b.getId(c)).css("display")=="none"?b.revert():b.edit(c)},edit:function(d){var c=this,b;c.revert();if(typeof(d)=="object"){d=c.getId(d)}b=a("#inline-edit").clone(true),rowData=a("#inline_"+d);a("td",b).attr("colspan",a(".widefat:first thead th:visible").length);if(a(c.what+d).hasClass("alternate")){a(b).addClass("alternate")}a(c.what+d).hide().after(b);a(':input[name="name"]',b).val(a(".name",rowData).text());a(':input[name="slug"]',b).val(a(".slug",rowData).text());a(b).attr("id","edit-"+d).addClass("inline-editor").show();a(".ptitle",b).eq(0).focus();return false},save:function(e){var d,b,c=a('input[name="taxonomy"]').val()||"";if(typeof(e)=="object"){e=this.getId(e)}a("table.widefat .inline-edit-save .waiting").show();d={action:"inline-save-tax",tax_type:this.type,tax_ID:e,taxonomy:c};b=a("#edit-"+e+" :input").serialize();d=b+"&"+a.param(d);a.post("admin-ajax.php",d,function(g){var h,f;a("table.widefat .inline-edit-save .waiting").hide();if(g){if(-1!=g.indexOf("<tr")){a(inlineEditTax.what+e).remove();f=a(g).attr("id");a("#edit-"+e).before(g).remove();h=f?a("#"+f):a(inlineEditTax.what+e);h.hide().fadeIn()}else{a("#edit-"+e+" .inline-edit-save .error").html(g).show()}}else{a("#edit-"+e+" .inline-edit-save .error").html(inlineEditL10n.error).show()}});return false},revert:function(){var b=a("table.widefat tr.inline-editor").attr("id");if(b){a("table.widefat .inline-edit-save .waiting").hide();a("#"+b).remove();b=b.substr(b.lastIndexOf("-")+1);a(this.what+b).show()}return false},getId:function(c){var d=c.tagName=="TR"?c.id:a(c).parents("tr").attr("id"),b=d.split("-");return b[b.length-1]}};a(document).ready(function(){inlineEditTax.init()})})(jQuery);
|
@ -1,37 +1,45 @@
|
|||||||
jQuery(document).ready(function($) {
|
jQuery(document).ready(function($) {
|
||||||
var options = false, addAfter, addAfter2, delBefore, delAfter;
|
|
||||||
|
|
||||||
addAfter = function( r, settings ) {
|
|
||||||
var name = $("<span>" + $('name', r).text() + "</span>").html(), id = $('tag', r).attr('id');
|
|
||||||
options[options.length] = new Option(name, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
addAfter2 = function( x, r ) {
|
|
||||||
var t = $(r.parsed.responses[0].data);
|
|
||||||
if ( t.length == 1 )
|
|
||||||
inlineEditTax.addEvents($(t.id));
|
|
||||||
}
|
|
||||||
|
|
||||||
delAfter = function( r, settings ) {
|
|
||||||
var id = $('tag', r).attr('id'), o;
|
|
||||||
for ( o = 0; o < options.length; o++ )
|
|
||||||
if ( id == options[o].value )
|
|
||||||
options[o] = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
delBefore = function(s) {
|
|
||||||
s.data.taxonomy = $('input[name="taxonomy"]').val();
|
|
||||||
|
|
||||||
|
$('.delete-tag').live('click', function(e){
|
||||||
|
var t = $(this), tr = t.parents('tr'), r = true, data;
|
||||||
if ( 'undefined' != showNotice )
|
if ( 'undefined' != showNotice )
|
||||||
return showNotice.warn() ? s : false;
|
r = showNotice.warn();
|
||||||
|
if ( r ) {
|
||||||
return s;
|
data = t.attr('href').replace(/[^?]*\?/, '').replace(/action=delete/, 'action=delete-tag');
|
||||||
|
$.post(ajaxurl, data, function(r){
|
||||||
|
if ( '1' == r ) {
|
||||||
|
$('#ajax-response').empty();
|
||||||
|
tr.fadeOut('normal', function(){ tr.remove(); });
|
||||||
|
} else if ( '-1' == r ) {
|
||||||
|
$('#ajax-response').empty().append('<div class="error"><p>' + tagsl10n.noPerm + '</p></div>');
|
||||||
|
tr.children().css('backgroundColor', '');
|
||||||
|
} else {
|
||||||
|
$('#ajax-response').empty().append('<div class="error"><p>' + tagsl10n.broken + '</p></div>');
|
||||||
|
tr.children().css('backgroundColor', '');
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
tr.children().css('backgroundColor', '#f33');
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
if ( options )
|
$('#submit').click(function(){
|
||||||
$('#the-list').wpList( { addAfter: addAfter, delBefore: delBefore, delAfter: delAfter } );
|
var form = $(this).parents('form');
|
||||||
else
|
|
||||||
$('#the-list').wpList({ addAfter: addAfter2, delBefore: delBefore });
|
if ( !validateForm( form ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$.post(ajaxurl, $('#addtag').serialize(), function(r){
|
||||||
|
if ( r.indexOf('<div class="error"') === 0 ) {
|
||||||
|
$('#ajax-response').append(r);
|
||||||
|
} else {
|
||||||
|
$('#ajax-response').empty();
|
||||||
|
$('#the-list').prepend(r);
|
||||||
|
$('input[type="text"]:visible, textarea:visible', form).val('');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
$('.delete a[class^="delete"]').click(function(){return false;});
|
|
||||||
});
|
});
|
@ -1 +1 @@
|
|||||||
jQuery(document).ready(function(d){var b=false,f,e,c,a;f=function(i,h){var g=d("<span>"+d("name",i).text()+"</span>").html(),j=d("tag",i).attr("id");b[b.length]=new Option(g,j)};e=function(g,i){var h=d(i.parsed.responses[0].data);if(h.length==1){inlineEditTax.addEvents(d(h.id))}};a=function(h,g){var j=d("tag",h).attr("id"),i;for(i=0;i<b.length;i++){if(j==b[i].value){b[i]=null}}};c=function(g){g.data.taxonomy=d('input[name="taxonomy"]').val();if("undefined"!=showNotice){return showNotice.warn()?g:false}return g};if(b){d("#the-list").wpList({addAfter:f,delBefore:c,delAfter:a})}else{d("#the-list").wpList({addAfter:e,delBefore:c})}d('.delete a[class^="delete"]').click(function(){return false})});
|
jQuery(document).ready(function(a){a(".delete-tag").live("click",function(g){var b=a(this),f=b.parents("tr"),c=true,d;if("undefined"!=showNotice){c=showNotice.warn()}if(c){d=b.attr("href").replace(/[^?]*\?/,"").replace(/action=delete/,"action=delete-tag");a.post(ajaxurl,d,function(e){if("1"==e){a("#ajax-response").empty();f.fadeOut("normal",function(){f.remove()})}else{if("-1"==e){a("#ajax-response").empty().append('<div class="error"><p>'+tagsl10n.noPerm+"</p></div>");f.children().css("backgroundColor","")}else{a("#ajax-response").empty().append('<div class="error"><p>'+tagsl10n.broken+"</p></div>");f.children().css("backgroundColor","")}}});f.children().css("backgroundColor","#f33")}return false});a("#submit").click(function(){var b=a(this).parents("form");if(!validateForm(b)){return false}a.post(ajaxurl,a("#addtag").serialize(),function(c){if(c.indexOf('<div class="error"')===0){a("#ajax-response").append(c)}else{a("#ajax-response").empty();a("#the-list").prepend(c);a('input[type="text"]:visible, textarea:visible',b).val("")}});return false})});
|
@ -385,7 +385,7 @@ form p.submit a.cancel:hover {
|
|||||||
#postcustomstuff .submit input {
|
#postcustomstuff .submit input {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
font-size: 11px !important;
|
font-size: 11px !important;
|
||||||
line-height: 16px;
|
line-height: 14px;
|
||||||
padding: 2px 8px;
|
padding: 2px 8px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
border-width: 1px;
|
border-width: 1px;
|
||||||
@ -403,9 +403,8 @@ form p.submit a.cancel:hover {
|
|||||||
a.button,
|
a.button,
|
||||||
a.button-primary,
|
a.button-primary,
|
||||||
a.button-secondary {
|
a.button-secondary {
|
||||||
line-height: 1.2em;
|
line-height: 15px;
|
||||||
-webkit-border-radius: 10px;
|
padding: 3px 10px;
|
||||||
padding: 4px 10px;
|
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2416,7 +2415,7 @@ fieldset {
|
|||||||
#replysubmit img.waiting,
|
#replysubmit img.waiting,
|
||||||
.inline-edit-save img.waiting,
|
.inline-edit-save img.waiting,
|
||||||
#commentstatusdiv img.waiting {
|
#commentstatusdiv img.waiting {
|
||||||
padding: 0 10px;
|
padding: 2px 10px 0;
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ function wp_default_scripts( &$scripts ) {
|
|||||||
|
|
||||||
$scripts->add( 'utils', "/wp-admin/js/utils$suffix.js", false, '20090102' );
|
$scripts->add( 'utils', "/wp-admin/js/utils$suffix.js", false, '20090102' );
|
||||||
|
|
||||||
$scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20090609' );
|
$scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20090623' );
|
||||||
$scripts->add_data( 'common', 'group', 1 );
|
$scripts->add_data( 'common', 'group', 1 );
|
||||||
$scripts->localize( 'common', 'commonL10n', array(
|
$scripts->localize( 'common', 'commonL10n', array(
|
||||||
'warnDelete' => __("You are about to delete the selected items.\n 'Cancel' to stop, 'OK' to delete."),
|
'warnDelete' => __("You are about to delete the selected items.\n 'Cancel' to stop, 'OK' to delete."),
|
||||||
@ -216,11 +216,16 @@ function wp_default_scripts( &$scripts ) {
|
|||||||
'l10n_print_after' => 'try{convertEntities(catL10n);}catch(e){};'
|
'l10n_print_after' => 'try{convertEntities(catL10n);}catch(e){};'
|
||||||
) );
|
) );
|
||||||
|
|
||||||
$scripts->add( 'admin-categories', "/wp-admin/js/categories$suffix.js", array('wp-lists'), '20090207' );
|
$scripts->add( 'admin-categories', "/wp-admin/js/categories$suffix.js", array('wp-lists'), '20090623' );
|
||||||
$scripts->add_data( 'admin-categories', 'group', 1 );
|
$scripts->add_data( 'admin-categories', 'group', 1 );
|
||||||
|
|
||||||
$scripts->add( 'admin-tags', "/wp-admin/js/tags$suffix.js", array('wp-lists'), '20090211' );
|
$scripts->add( 'admin-tags', "/wp-admin/js/tags$suffix.js", array('jquery'), '20090623' );
|
||||||
$scripts->add_data( 'admin-tags', 'group', 1 );
|
$scripts->add_data( 'admin-tags', 'group', 1 );
|
||||||
|
$scripts->localize( 'admin-tags', 'tagsl10n', array(
|
||||||
|
'noPerm' => __('You do not have permission to do that.'),
|
||||||
|
'broken' => __('An unidentified error has occurred.'),
|
||||||
|
'l10n_print_after' => 'try{convertEntities(tagsl10n);}catch(e){};'
|
||||||
|
));
|
||||||
|
|
||||||
$scripts->add( 'admin-custom-fields', "/wp-admin/js/custom-fields$suffix.js", array('wp-lists'), '20090106' );
|
$scripts->add( 'admin-custom-fields', "/wp-admin/js/custom-fields$suffix.js", array('wp-lists'), '20090106' );
|
||||||
$scripts->add_data( 'admin-custom-fields', 'group', 1 );
|
$scripts->add_data( 'admin-custom-fields', 'group', 1 );
|
||||||
@ -361,7 +366,7 @@ function wp_default_scripts( &$scripts ) {
|
|||||||
'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};'
|
'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};'
|
||||||
) );
|
) );
|
||||||
|
|
||||||
$scripts->add( 'inline-edit-tax', "/wp-admin/js/inline-edit-tax$suffix.js", array( 'jquery-form' ), '20090211' );
|
$scripts->add( 'inline-edit-tax', "/wp-admin/js/inline-edit-tax$suffix.js", array( 'jquery' ), '20090623' );
|
||||||
$scripts->add_data( 'inline-edit-tax', 'group', 1 );
|
$scripts->add_data( 'inline-edit-tax', 'group', 1 );
|
||||||
$scripts->localize( 'inline-edit-tax', 'inlineEditL10n', array(
|
$scripts->localize( 'inline-edit-tax', 'inlineEditL10n', array(
|
||||||
'error' => __('Error while saving the changes.'),
|
'error' => __('Error while saving the changes.'),
|
||||||
|
Loading…
Reference in New Issue
Block a user