From b9b9ebeeaef3d6ce6b49e718a3e8438d28f35e35 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Wed, 7 Nov 2012 23:54:03 +0000 Subject: [PATCH] Forms with the class .wp-upload-form will now have their submit button disabled until a file is selected. props kovshenin, helenyhou, lessbloat, SergeyBiryukov, tommcfarlin. fixes #20855. git-svn-id: http://core.svn.wordpress.org/trunk@22459 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/custom-background.php | 2 +- wp-admin/custom-header.php | 2 +- wp-admin/includes/plugin-install.php | 10 +++++----- wp-admin/includes/template.php | 2 +- wp-admin/includes/theme-install.php | 8 ++++---- wp-admin/js/common.js | 16 +++++++++++++++- 6 files changed, 27 insertions(+), 13 deletions(-) diff --git a/wp-admin/custom-background.php b/wp-admin/custom-background.php index 18dd786c70..f6869c952c 100644 --- a/wp-admin/custom-background.php +++ b/wp-admin/custom-background.php @@ -254,7 +254,7 @@ if ( get_background_image() ) { -
+


diff --git a/wp-admin/custom-header.php b/wp-admin/custom-header.php index d1055bd775..7a570e3403 100644 --- a/wp-admin/custom-header.php +++ b/wp-admin/custom-header.php @@ -525,7 +525,7 @@ class Custom_Image_Header { printf( __( 'Suggested height is %1$d pixels.' ) . ' ', get_theme_support( 'custom-header', 'height' ) ); } ?>

- +


diff --git a/wp-admin/includes/plugin-install.php b/wp-admin/includes/plugin-install.php index 452b4df02b..63a5f711f2 100644 --- a/wp-admin/includes/plugin-install.php +++ b/wp-admin/includes/plugin-install.php @@ -142,13 +142,13 @@ function install_search_form( $type_selector = true ) { */ function install_plugins_upload( $page = 1 ) { ?> -

-

- - +

+

+ + - +

-
+

() diff --git a/wp-admin/includes/theme-install.php b/wp-admin/includes/theme-install.php index ff0ce01d92..5c135aa10a 100644 --- a/wp-admin/includes/theme-install.php +++ b/wp-admin/includes/theme-install.php @@ -134,10 +134,10 @@ add_action('install_themes_dashboard', 'install_themes_dashboard'); function install_themes_upload($page = 1) { ?> -

-

- - +

+

+ +
diff --git a/wp-admin/js/common.js b/wp-admin/js/common.js index a7b3c2d487..da9cb4f428 100644 --- a/wp-admin/js/common.js +++ b/wp-admin/js/common.js @@ -249,7 +249,7 @@ $(document).ready( function() { sensitivity: 7, interval: 90 }); - + menu.on('focus.adminmenu', '.wp-submenu a', function(e){ $(e.target).closest('li.menu-top').addClass('opensub'); }).on('blur.adminmenu', '.wp-submenu a', function(e){ @@ -388,6 +388,20 @@ $(document).ready( function() { if ( e.target.scrollIntoView ) e.target.scrollIntoView(false); }); + + // Disable upload buttons until files are selected + (function(){ + var button, input, form = $('form.wp-upload-form'); + if ( ! form.length ) + return; + button = form.find('input[type="submit"]'); + input = form.find('input[type="file"]'); + function toggleUploadButton() { + button.prop('disabled', '' === input.val()); + } + toggleUploadButton(); + input.on('change', toggleUploadButton); + })(); }); // internal use