From 8f407953f779447bda827f89fb1ca592f36b4ab8 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Mon, 28 Jan 2008 21:34:42 +0000 Subject: [PATCH] Move postbox to postbox.js. Don't load cat and tag js for pages. git-svn-id: https://develop.svn.wordpress.org/trunk@6675 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/js/post.js | 31 ++++++++++++------------------- wp-admin/js/postbox.js | 12 ++++++++++++ wp-includes/script-loader.php | 3 ++- 3 files changed, 26 insertions(+), 20 deletions(-) create mode 100644 wp-admin/js/postbox.js diff --git a/wp-admin/js/post.js b/wp-admin/js/post.js index 6d57882d97..1ded0af52a 100644 --- a/wp-admin/js/post.js +++ b/wp-admin/js/post.js @@ -1,4 +1,4 @@ -// this file shoudl contain all the scripts used in the post/edit page +// this file contains all the scripts used in the post/edit page function new_tag_remove_tag() { var id = jQuery( this ).attr( 'id' ); @@ -52,19 +52,6 @@ function tag_press_key( e ) { } } -function add_postbox_toggles() { - jQuery('.postbox h3').prepend('+ '); - jQuery('.togbox').click( function() { jQuery(jQuery(this).parent().parent().get(0)).toggleClass('closed'); save_postboxes_state(); } ); -} - -function save_postboxes_state() { - var closed = jQuery('.postbox').filter('.closed').map(function() { return this.id; }).get().join(','); - jQuery.post(postL10n.requestFile, { - action: 'closed-postboxes', - closed: closed, - cookie: document.cookie}); -} - function edit_permalink(post_id) { var i, c = 0; var e = jQuery('#editable-post-name'); @@ -112,6 +99,17 @@ function make_slugedit_clickable() { } addLoadEvent( function() { + // postboxes + add_postbox_toggles(); + + // If no tags on the page, skip the tag and category stuff. + if ( !jQuery('#tags-input').size() ) { + return; + } + + // Editable slugs + make_slugedit_clickable(); + jQuery('#tags-input').hide(); tag_update_quickclicks(); // add the quickadd form @@ -130,9 +128,6 @@ addLoadEvent( function() { jQuery('#newtag').suggest( 'admin-ajax.php?action=ajax-tag-search', { delay: 500, minchars: 2 } ); jQuery('#newtag').keypress( tag_press_key ); - // postboxes - add_postbox_toggles(); - // category tabs var categoryTabs =jQuery('#category-tabs').tabs(); @@ -182,6 +177,4 @@ addLoadEvent( function() { return false; } ); jQuery('.categorychecklist :checkbox').change( syncChecks ).filter( ':checked' ).change(); - - make_slugedit_clickable(); }); diff --git a/wp-admin/js/postbox.js b/wp-admin/js/postbox.js new file mode 100644 index 0000000000..ad193e4636 --- /dev/null +++ b/wp-admin/js/postbox.js @@ -0,0 +1,12 @@ +function add_postbox_toggles() { + jQuery('.postbox h3').prepend('+ '); + jQuery('.togbox').click( function() { jQuery(jQuery(this).parent().parent().get(0)).toggleClass('closed'); save_postboxes_state(); } ); +} + +function save_postboxes_state() { + var closed = jQuery('.postbox').filter('.closed').map(function() { return this.id; }).get().join(','); + jQuery.post(postL10n.requestFile, { + action: 'closed-postboxes', + closed: closed, + cookie: document.cookie}); +} \ No newline at end of file diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 26794eb7fd..a337830ef3 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -131,7 +131,8 @@ 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'), '20080128' ); + $this->add( 'postbox', '/wp-admin/js/postbox.js', array('jquery'), '20080128' ); + $this->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox'), '20080128' ); $this->localize( 'post', 'postL10n', array( 'tagsUsed' => __('Tags used on this post:'), 'add' => attribute_escape(__('Add')),