Edit permalink in place. Fixes #5679. Hat tip: nbachiyski.

git-svn-id: https://develop.svn.wordpress.org/trunk@6633 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Matt Mullenweg
2008-01-17 16:51:32 +00:00
parent 2b0713315f
commit 098e6672e4
7 changed files with 114 additions and 5 deletions
+38
View File
@@ -65,6 +65,42 @@ function save_postboxes_state() {
cookie: document.cookie});
}
function edit_permalink(post_id) {
var e = jQuery('#editable-post-name');
var revert_e = e.html();
var real_slug = jQuery('#post_name');
var b = jQuery('#edit-slug-buttons');
var revert_b = b.html();
var old_slug = e.children('span').html();
b.html('<a href="" class="save">'+postL10n.save+'</a> <a class="cancel" href="">'+postL10n.cancel+'</a>');
b.children('.save').click(function() {
var new_slug = e.children('input').attr('value');
jQuery.post(postL10n.requestFile, {
action: 'sample-permalink',
post_id: post_id,
new_slug: new_slug,
cookie: document.cookie}, function(data) {
jQuery('#sample-permalink').html(data);
b.html(revert_b);
real_slug.attr('value', new_slug);
});
return false;
});
jQuery('#edit-slug-buttons .cancel').click(function() {
e.html(revert_e);
b.html(revert_b);
real_slug.attr('value', revert_e);
return false;
});
e.html('<input type="text" id="new-post-slug" value="" />').children('input').keypress(function(e){
var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
// on enter, just save the new slug, don't save the post
if (13 == key) {b.children('.save').click();return false;}
if (27 == key) {b.children('.cancel').click();return false;}
real_slug.attr('value', this.value)}).focus();
}
addLoadEvent( function() {
jQuery('#tags-input').hide();
tag_update_quickclicks();
@@ -136,4 +172,6 @@ addLoadEvent( function() {
return false;
} );
jQuery('.categorychecklist :checkbox').change( syncChecks ).filter( ':checked' ).change();
jQuery('#editable-post-name').click(function() {jQuery('#edit-slug-buttons').children('.edit-slug').click()});
});