From 7e200d589d9f65a31b213d8ec54aab482ecd210f Mon Sep 17 00:00:00 2001 From: azaozz Date: Wed, 12 Nov 2008 09:35:50 +0000 Subject: [PATCH] Consolidate six more js files git-svn-id: http://svn.automattic.com/wordpress/trunk@9631 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/categories.php | 3 +- wp-admin/edit-comments.php | 3 +- wp-admin/edit-link-categories.php | 3 +- wp-admin/edit-pages.php | 3 +- wp-admin/edit-tags.php | 3 +- wp-admin/edit.php | 3 +- wp-admin/includes/plugin.php | 2 +- wp-admin/js/columns.js | 27 ----------------- wp-admin/js/common.js | 50 +++++++++++++++++++++++++++++++ wp-admin/js/forms.js | 26 ---------------- wp-admin/js/links.js | 3 -- wp-admin/js/media.js | 3 -- wp-admin/js/pages.js | 3 -- wp-admin/js/posts.js | 3 -- wp-admin/link-manager.php | 4 +-- wp-admin/plugins.php | 1 - wp-admin/upload.php | 3 +- wp-admin/user-new.php | 1 - wp-admin/users.php | 1 - wp-includes/script-loader.php | 19 +++--------- 20 files changed, 63 insertions(+), 101 deletions(-) delete mode 100644 wp-admin/js/columns.js delete mode 100644 wp-admin/js/forms.js delete mode 100644 wp-admin/js/links.js delete mode 100644 wp-admin/js/media.js delete mode 100644 wp-admin/js/pages.js delete mode 100644 wp-admin/js/posts.js diff --git a/wp-admin/categories.php b/wp-admin/categories.php index 8ab6c00c05..438e46ca03 100644 --- a/wp-admin/categories.php +++ b/wp-admin/categories.php @@ -117,8 +117,7 @@ if ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) { exit; } -wp_enqueue_script( 'admin-categories' ); -wp_enqueue_script('admin-forms'); +wp_enqueue_script('admin-categories'); if ( current_user_can('manage_categories') ) wp_enqueue_script('inline-edit-tax'); diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php index 3be966dd37..0884094fba 100644 --- a/wp-admin/edit-comments.php +++ b/wp-admin/edit-comments.php @@ -10,8 +10,7 @@ require_once('admin.php'); $title = __('Edit Comments'); -wp_enqueue_script( 'admin-comments' ); -wp_enqueue_script( 'admin-forms' ); +wp_enqueue_script('admin-comments'); enqueue_comment_hotkeys_js(); if ( ( isset( $_REQUEST['delete_all_spam'] ) || isset( $_REQUEST['delete_all_spam2'] ) ) && !empty( $_REQUEST['pagegen_timestamp'] ) ) { diff --git a/wp-admin/edit-link-categories.php b/wp-admin/edit-link-categories.php index 7ad595b208..199f1afe4f 100644 --- a/wp-admin/edit-link-categories.php +++ b/wp-admin/edit-link-categories.php @@ -46,8 +46,7 @@ if ( isset($_GET['action']) && isset($_GET['delete']) ) { $title = __('Link Categories'); -wp_enqueue_script( 'admin-categories' ); -wp_enqueue_script('admin-forms'); +wp_enqueue_script('admin-categories'); if ( current_user_can('manage_categories') ) wp_enqueue_script('inline-edit-tax'); diff --git a/wp-admin/edit-pages.php b/wp-admin/edit-pages.php index 12754fb594..0ecb0e93f5 100644 --- a/wp-admin/edit-pages.php +++ b/wp-admin/edit-pages.php @@ -69,9 +69,7 @@ if ( isset($_GET['action']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] if ( empty($title) ) $title = __('Edit Pages'); $parent_file = 'edit.php'; -wp_enqueue_script('admin-forms'); wp_enqueue_script('inline-edit-post'); -wp_enqueue_script('pages'); $post_stati = array( // array( adj, noun ) 'publish' => array(__('Published'), __('Published pages'), __ngettext_noop('Published (%s)', 'Published (%s)')), @@ -318,6 +316,7 @@ endif; // posts; }); }); })(jQuery); +columns.init('page'); /* ]]> */ diff --git a/wp-admin/edit-tags.php b/wp-admin/edit-tags.php index 5cd8cbe2fc..66c9ba1bb2 100644 --- a/wp-admin/edit-tags.php +++ b/wp-admin/edit-tags.php @@ -115,8 +115,7 @@ if ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) { $can_manage = current_user_can('manage_categories'); -wp_enqueue_script( 'admin-tags' ); -wp_enqueue_script('admin-forms'); +wp_enqueue_script('admin-tags'); if ( $can_manage ) wp_enqueue_script('inline-edit-tax'); diff --git a/wp-admin/edit.php b/wp-admin/edit.php index bf2f9304fe..f34bfcb792 100644 --- a/wp-admin/edit.php +++ b/wp-admin/edit.php @@ -69,9 +69,7 @@ if ( isset($_GET['action']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] if ( empty($title) ) $title = __('Edit Posts'); $parent_file = 'edit.php'; -wp_enqueue_script('admin-forms'); wp_enqueue_script('inline-edit-post'); -wp_enqueue_script('posts'); list($post_stati, $avail_post_stati) = wp_edit_posts_query(); @@ -332,6 +330,7 @@ endif; // posts; }); }); })(jQuery); +columns.init('post'); /* ]]> */ diff --git a/wp-admin/includes/plugin.php b/wp-admin/includes/plugin.php index a7c813c5da..7999bef825 100644 --- a/wp-admin/includes/plugin.php +++ b/wp-admin/includes/plugin.php @@ -568,7 +568,7 @@ function add_object_page( $page_title, $menu_title, $access_level, $file, $funct add_action( $hookname, $function ); if ( empty($icon_url) ) - $icon_url = 'images/menu/generic.png'; + $icon_url = 'images/generic.png'; $_wp_last_object_menu++; diff --git a/wp-admin/js/columns.js b/wp-admin/js/columns.js deleted file mode 100644 index 2625c09f5b..0000000000 --- a/wp-admin/js/columns.js +++ /dev/null @@ -1,27 +0,0 @@ -(function($) { - columns = { - init : function(page) { - $('.hide-column-tog').click( function() { - var column = jQuery(this).val(); - var show = jQuery(this).attr('checked'); - if ( show ) { - jQuery('.column-' + column).show(); - } else { - jQuery('.column-' + column).hide(); - } - save_manage_columns_state(page); - } ); - - } - } -}(jQuery)); - -function save_manage_columns_state(page) { - var hidden = jQuery('.manage-column').filter(':hidden').map(function() { return this.id; }).get().join(','); - jQuery.post(columnsL10n.requestFile, { - action: 'hidden-columns', - hidden: hidden, - hiddencolumnsnonce: jQuery('#hiddencolumnsnonce').val(), - page: page - }); -} \ No newline at end of file diff --git a/wp-admin/js/common.js b/wp-admin/js/common.js index 4e839e1ae9..f5a59ee6a3 100644 --- a/wp-admin/js/common.js +++ b/wp-admin/js/common.js @@ -182,6 +182,30 @@ jQuery(document).ready( function($) { }); return false; }); + + // check all checkboxes + var lastClicked = false; + $( 'table.widefat tbody .check-column :checkbox' ).click( function(e) { + if ( 'undefined' == e.shiftKey ) { return true; } + if ( e.shiftKey ) { + if ( !lastClicked ) { return true; } + var checks = $( lastClicked ).parents( 'form:first' ).find( ':checkbox' ); + var first = checks.index( lastClicked ); + var last = checks.index( this ); + if ( 0 < first && 0 < last && first != last ) { + checks.slice( first, last ).attr( 'checked', $( this ).is( ':checked' ) ? 'checked' : '' ); + } + } + lastClicked = this; + return true; + } ); + + $( 'thead :checkbox, tfoot :checkbox' ).click( function() { + $(this).parents( 'form:first' ).find( 'tbody:visible .check-column :checkbox' ).attr( 'checked', function() { + return $(this).attr( 'checked' ) ? '' : 'checked'; + }); + return false; + }); }); (function($){ @@ -290,6 +314,32 @@ adminMenu = { $(document).ready(function(){adminMenu.init();}); +// show/hide/save table columns +columns = { + init : function(page) { + $('.hide-column-tog').click( function() { + var column = $(this).val(); + var show = $(this).attr('checked'); + if ( show ) { + $('.column-' + column).show(); + } else { + $('.column-' + column).hide(); + } + columns.save_manage_columns_state(page); + } ); + }, + + save_manage_columns_state : function(page) { + var hidden = $('.manage-column').filter(':hidden').map(function() { return this.id; }).get().join(','); + $.post('admin-ajax.php', { + action: 'hidden-columns', + hidden: hidden, + hiddencolumnsnonce: $('#hiddencolumnsnonce').val(), + page: page + }); + } +} + })(jQuery); diff --git a/wp-admin/js/forms.js b/wp-admin/js/forms.js deleted file mode 100644 index add3de4dea..0000000000 --- a/wp-admin/js/forms.js +++ /dev/null @@ -1,26 +0,0 @@ -function checkAll(jQ) { // use attr( checked, fn ) - jQuery(jQ).find( 'tbody:visible .check-column :checkbox' ).attr( 'checked', function() { - return jQuery(this).attr( 'checked' ) ? '' : 'checked'; - } ); -} - -jQuery( function($) { - var lastClicked = false; - $( 'tbody .check-column :checkbox' ).click( function(e) { - if ( 'undefined' == e.shiftKey ) { return true; } - if ( e.shiftKey ) { - if ( !lastClicked ) { return true; } - var checks = $( lastClicked ).parents( 'form:first' ).find( ':checkbox' ); - var first = checks.index( lastClicked ); - var last = checks.index( this ); - if ( 0 < first && 0 < last && first != last ) { - checks.slice( first, last ).attr( 'checked', $( this ).is( ':checked' ) ? 'checked' : '' ); - } - } - lastClicked = this; - return true; - } ); - $( 'thead :checkbox, tfoot :checkbox' ).click( function() { - checkAll( $(this).parents( 'form:first' ) ); - } ); -} ); diff --git a/wp-admin/js/links.js b/wp-admin/js/links.js deleted file mode 100644 index 63fad2e6cb..0000000000 --- a/wp-admin/js/links.js +++ /dev/null @@ -1,3 +0,0 @@ -jQuery(document).ready( function($) { - columns.init('link'); -}); \ No newline at end of file diff --git a/wp-admin/js/media.js b/wp-admin/js/media.js deleted file mode 100644 index d3b77b80b3..0000000000 --- a/wp-admin/js/media.js +++ /dev/null @@ -1,3 +0,0 @@ -jQuery(document).ready( function($) { - columns.init('media'); -}); diff --git a/wp-admin/js/pages.js b/wp-admin/js/pages.js deleted file mode 100644 index ae1e493d48..0000000000 --- a/wp-admin/js/pages.js +++ /dev/null @@ -1,3 +0,0 @@ -jQuery(document).ready( function($) { - columns.init('page'); -}); \ No newline at end of file diff --git a/wp-admin/js/posts.js b/wp-admin/js/posts.js deleted file mode 100644 index 48cb0e5860..0000000000 --- a/wp-admin/js/posts.js +++ /dev/null @@ -1,3 +0,0 @@ -jQuery(document).ready( function($) { - columns.init('post'); -}); \ No newline at end of file diff --git a/wp-admin/link-manager.php b/wp-admin/link-manager.php index 10e0ef1565..9a5aea9e52 100644 --- a/wp-admin/link-manager.php +++ b/wp-admin/link-manager.php @@ -34,9 +34,6 @@ if ( isset($_GET['action']) && isset($_GET['linkcheck']) ) { exit; } -wp_enqueue_script('admin-forms'); -wp_enqueue_script('links'); - wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]')); if ( empty($cat_id) ) @@ -282,6 +279,7 @@ if ( $links ) { }); }); })(jQuery); +columns.init('link'); /* ]]> */ diff --git a/wp-admin/plugins.php b/wp-admin/plugins.php index 79e04a06da..169d9b08fa 100644 --- a/wp-admin/plugins.php +++ b/wp-admin/plugins.php @@ -163,7 +163,6 @@ if( !empty($action) ) { } } -wp_enqueue_script('admin-forms'); wp_enqueue_script('plugin-install'); add_thickbox(); diff --git a/wp-admin/upload.php b/wp-admin/upload.php index f6652a68d9..38a357fe86 100644 --- a/wp-admin/upload.php +++ b/wp-admin/upload.php @@ -102,8 +102,6 @@ if ( isset($_GET['find_detached'] ) ) { $title = __('Media Library'); $parent_file = 'edit.php'; -wp_enqueue_script( 'admin-forms' ); -wp_enqueue_script('media'); if ( ! isset( $_GET['paged'] ) || $_GET['paged'] < 1 ) $_GET['paged'] = 1; @@ -463,6 +461,7 @@ endif; // posts; }); }); })(jQuery); +columns.init('media'); /* ]]> */ diff --git a/wp-admin/user-new.php b/wp-admin/user-new.php index d772f6cc2a..126e10d09f 100644 --- a/wp-admin/user-new.php +++ b/wp-admin/user-new.php @@ -37,7 +37,6 @@ $title = __('Add New User'); $parent_file = 'users.php'; wp_enqueue_script('admin-users'); -wp_enqueue_script('admin-forms'); require_once ('admin-header.php'); diff --git a/wp-admin/users.php b/wp-admin/users.php index 0e40ed562f..2ae136a63e 100644 --- a/wp-admin/users.php +++ b/wp-admin/users.php @@ -184,7 +184,6 @@ default: } wp_enqueue_script('admin-users'); - wp_enqueue_script('admin-forms'); include('admin-header.php'); diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 27dd7f9d69..ce85bd1eea 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -145,8 +145,8 @@ function wp_default_scripts( &$scripts ) { 'add' => attribute_escape(__('Add')), 'how' => __('Separate multiple categories with commas.') ) ); - $scripts->add( 'admin-categories', '/wp-admin/js/categories.js', array('wp-lists', 'columns'), '20080925' ); - $scripts->add( 'admin-tags', '/wp-admin/js/tags.js', array('wp-lists', 'columns'), '20080925' ); + $scripts->add( 'admin-categories', '/wp-admin/js/categories.js', array('wp-lists'), '20080925' ); + $scripts->add( 'admin-tags', '/wp-admin/js/tags.js', array('wp-lists'), '20080925' ); $scripts->add( 'admin-custom-fields', '/wp-admin/js/custom-fields.js', array('wp-lists'), '20070823' ); $scripts->add( 'password-strength-meter', '/wp-admin/js/password-strength-meter.js', array('jquery'), '20081021' ); $scripts->localize( 'password-strength-meter', 'pwsL10n', array( @@ -156,14 +156,13 @@ function wp_default_scripts( &$scripts ) { 'good' => __('Medium'), 'strong' => __('Strong') ) ); - $scripts->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('wp-lists', 'jquery-ui-resizable', 'quicktags', 'columns'), '20081031' ); + $scripts->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('wp-lists', 'jquery-ui-resizable', 'quicktags'), '20081031' ); $scripts->localize( 'admin-comments', 'adminCommentsL10n', array( 'pending' => __('%i% pending'), // must look like: "# blah blah" 'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']), 'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last']), ) ); - $scripts->add( 'admin-users', '/wp-admin/js/users.js', array('wp-lists', 'columns'), '20080925' ); - $scripts->add( 'admin-forms', '/wp-admin/js/forms.js', array('jquery'), '20080729'); + $scripts->add( 'admin-users', '/wp-admin/js/users.js', array('wp-lists'), '20080925' ); $scripts->add( 'xfn', '/wp-admin/js/xfn.js', false, '3517' ); $scripts->add( 'postbox', '/wp-admin/js/postbox.js', array('jquery-ui-sortable'), '20081109' ); $scripts->localize( 'postbox', 'postboxL10n', array( @@ -258,16 +257,6 @@ function wp_default_scripts( &$scripts ) { $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' ); - $scripts->add( 'posts', '/wp-admin/js/posts.js', array('columns'), '20080925' ); - $scripts->add( 'pages', '/wp-admin/js/pages.js', array('columns'), '20080925' ); - $scripts->add( 'links', '/wp-admin/js/links.js', array('columns'), '20080925' ); - $scripts->add( 'media', '/wp-admin/js/media.js', array('columns'), '20080925' ); - - $scripts->add( 'columns', '/wp-admin/js/columns.js', false, '20080910' ); - $scripts->localize( 'columns', 'columnsL10n', array( - 'requestFile' => admin_url('admin-ajax.php'), - ) ); - $scripts->add( 'dashboard', '/wp-admin/js/dashboard.js', array( 'jquery', 'admin-comments', 'postbox' ), '20081016' ); $scripts->add( 'hoverIntent', '/wp-includes/js/hoverIntent.js', array('jquery'), '20081109' );