From 8f6920d116228e2dd2a9698f222dc18a5d15ecb3 Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 28 Jan 2008 20:25:39 +0000 Subject: [PATCH] Fill edit slug box with current slug. Props johnbillion and nbachiyski. fixes #5704 git-svn-id: http://svn.automattic.com/wordpress/trunk@6674 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/js/post.js | 14 ++++++++++++-- wp-includes/script-loader.php | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/wp-admin/js/post.js b/wp-admin/js/post.js index 1525ef4942..6d57882d97 100644 --- a/wp-admin/js/post.js +++ b/wp-admin/js/post.js @@ -66,6 +66,7 @@ function save_postboxes_state() { } function edit_permalink(post_id) { + var i, c = 0; var e = jQuery('#editable-post-name'); var revert_e = e.html(); var real_slug = jQuery('#post_name'); @@ -84,6 +85,7 @@ function edit_permalink(post_id) { jQuery('#sample-permalink').html(data); b.html(revert_b); real_slug.attr('value', new_slug); + make_slugedit_clickable(); }); return false; }); @@ -93,7 +95,11 @@ function edit_permalink(post_id) { real_slug.attr('value', revert_e); return false; }); - e.html('').children('input').keypress(function(e){ + for(i=0; i < revert_e.length; ++i) { + if ('%' == revert_e.charAt(i)) c++; + } + slug_value = (c > revert_e.length/4)? '' : revert_e; + e.html('').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;} @@ -101,6 +107,10 @@ function edit_permalink(post_id) { real_slug.attr('value', this.value)}).focus(); } +function make_slugedit_clickable() { + jQuery('#editable-post-name').click(function() {jQuery('#edit-slug-buttons').children('.edit-slug').click()}); +} + addLoadEvent( function() { jQuery('#tags-input').hide(); tag_update_quickclicks(); @@ -173,5 +183,5 @@ addLoadEvent( function() { } ); jQuery('.categorychecklist :checkbox').change( syncChecks ).filter( ':checked' ).change(); - jQuery('#editable-post-name').click(function() {jQuery('#edit-slug-buttons').children('.edit-slug').click()}); + make_slugedit_clickable(); }); diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index cd9b947d44..26794eb7fd 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -131,7 +131,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'), '20080110' ); + $this->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists'), '20080128' ); $this->localize( 'post', 'postL10n', array( 'tagsUsed' => __('Tags used on this post:'), 'add' => attribute_escape(__('Add')),