Consolidate six more js files

git-svn-id: http://svn.automattic.com/wordpress/trunk@9631 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2008-11-12 09:35:50 +00:00
parent 4dc56b14d0
commit 7e200d589d
20 changed files with 63 additions and 101 deletions

View File

@ -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');

View File

@ -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'] ) ) {

View File

@ -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');

View File

@ -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 <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>')),
@ -318,6 +316,7 @@ endif; // posts;
});
});
})(jQuery);
columns.init('page');
/* ]]> */
</script>

View File

@ -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');

View File

@ -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');
/* ]]> */
</script>

View File

@ -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++;

View File

@ -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
});
}

View File

@ -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);

View File

@ -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' ) );
} );
} );

View File

@ -1,3 +0,0 @@
jQuery(document).ready( function($) {
columns.init('link');
});

View File

@ -1,3 +0,0 @@
jQuery(document).ready( function($) {
columns.init('media');
});

View File

@ -1,3 +0,0 @@
jQuery(document).ready( function($) {
columns.init('page');
});

View File

@ -1,3 +0,0 @@
jQuery(document).ready( function($) {
columns.init('post');
});

View File

@ -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');
/* ]]> */
</script>

View File

@ -163,7 +163,6 @@ if( !empty($action) ) {
}
}
wp_enqueue_script('admin-forms');
wp_enqueue_script('plugin-install');
add_thickbox();

View File

@ -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');
/* ]]> */
</script>

View File

@ -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');

View File

@ -184,7 +184,6 @@ default:
}
wp_enqueue_script('admin-users');
wp_enqueue_script('admin-forms');
include('admin-header.php');

View File

@ -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' );