Make uploader selection "sticky"

git-svn-id: http://svn.automattic.com/wordpress/trunk@10844 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2009-03-27 08:36:51 +00:00
parent 3ca8d791a8
commit d2f10cfa07
4 changed files with 28 additions and 21 deletions

View File

@ -1267,6 +1267,14 @@ function media_upload_form( $errors = null ) {
$post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0; $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
?> ?>
<script type="text/javascript">
//<!--
jQuery(document).ready(function($){
$('.upload-html-bypass a').click(function(){deleteUserSetting('uploader');swfuploadPreLoad(0);return false;});
$('.upload-flash-bypass a').click(function(){setUserSetting('uploader', '1');swfuploadPreLoad(1);return false;});
});
//-->
</script>
<div id="media-upload-notice"> <div id="media-upload-notice">
<?php if (isset($errors['upload_notice']) ) { ?> <?php if (isset($errors['upload_notice']) ) { ?>
<?php echo $errors['upload_notice']; ?> <?php echo $errors['upload_notice']; ?>
@ -1340,12 +1348,11 @@ SWFUpload.onload = function() {
<p id="async-upload-wrap"> <p id="async-upload-wrap">
<input type="file" name="async-upload" id="async-upload" /> <input type="submit" class="button" name="html-upload" value="<?php echo attribute_escape(__('Upload')); ?>" /> <a href="#" onclick="return top.tb_remove();"><?php _e('Cancel'); ?></a> <input type="file" name="async-upload" id="async-upload" /> <input type="submit" class="button" name="html-upload" value="<?php echo attribute_escape(__('Upload')); ?>" /> <a href="#" onclick="return top.tb_remove();"><?php _e('Cancel'); ?></a>
</p> </p>
<div class="clear"></div>
<br class="clear" />
<?php if ( is_lighttpd_before_150() ): ?> <?php if ( is_lighttpd_before_150() ): ?>
<p><?php _e('If you want to use all capabilities of the uploader, like uploading multiple files at once, please upgrade to lighttpd 1.5.'); ?></p> <p><?php _e('If you want to use all capabilities of the uploader, like uploading multiple files at once, please upgrade to lighttpd 1.5.'); ?></p>
<?php endif;?> <?php endif;?>
<?php do_action('post-html-upload-ui'); ?> <?php do_action('post-html-upload-ui', $flash); ?>
</div> </div>
<?php do_action('post-upload-ui'); ?> <?php do_action('post-upload-ui'); ?>
<?php <?php
@ -2037,16 +2044,15 @@ function media_upload_flash_bypass() {
* *
* @since unknown * @since unknown
*/ */
function media_upload_html_bypass() { function media_upload_html_bypass($flash = true) {
echo '<p class="upload-html-bypass">'; echo '<p class="upload-html-bypass">';
if ( array_key_exists('flash', $_REQUEST) ) _e('You are using the Browser uploader.');
if ( $flash ) {
// the user manually selected the browser uploader, so let them switch back to Flash // the user manually selected the browser uploader, so let them switch back to Flash
printf( __('You are using the Browser uploader. Try the <a href="%s">Flash uploader</a> instead.'), clean_url(add_query_arg('flash', 1)) ); echo ' ';
else printf( __('Try the <a href="%s">Flash uploader</a> instead.'), clean_url(add_query_arg('flash', 1)) );
// the user probably doesn't have Flash }
printf( __('You are using the Browser uploader.') ); echo "</p>\n";
echo '</p>';
} }
add_action('post-flash-upload-ui', 'media_upload_flash_bypass'); add_action('post-flash-upload-ui', 'media_upload_flash_bypass');
@ -2070,8 +2076,6 @@ function media_upload_bypass_url($url) {
add_filter('media_upload_form_url', 'media_upload_bypass_url'); add_filter('media_upload_form_url', 'media_upload_bypass_url');
add_filter('async_upload_image', 'get_media_item', 10, 2); add_filter('async_upload_image', 'get_media_item', 10, 2);
add_filter('async_upload_audio', 'get_media_item', 10, 2); add_filter('async_upload_audio', 'get_media_item', 10, 2);
add_filter('async_upload_video', 'get_media_item', 10, 2); add_filter('async_upload_video', 'get_media_item', 10, 2);

View File

@ -206,12 +206,15 @@ function fileDialogComplete(num_files_queued) {
} }
} }
function swfuploadPreLoad() { function swfuploadPreLoad(a) {
var swfupload_element = jQuery('#'+swfu.customSettings.swfupload_element_id).get(0); if ( typeof(a) == 'undefined' && typeof(getUserSetting) == 'function' )
jQuery('#' + swfu.customSettings.degraded_element_id).hide(); a = getUserSetting('uploader');
// Doing this directly because jQuery().show() seems to have timing problems
if ( swfupload_element && ! swfupload_element.style.display ) if ( !a ) {
swfupload_element.style.display = 'block'; jQuery('#' + swfu.customSettings.swfupload_element_id).show();
jQuery('#' + swfu.customSettings.degraded_element_id).hide();
} else
swfuploadLoadFailed();
} }
function swfuploadLoadFailed() { function swfuploadLoadFailed() {

File diff suppressed because one or more lines are too long

View File

@ -178,7 +178,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'swfupload-queue', false, array('swfupload') ); $scripts->add( 'swfupload-queue', false, array('swfupload') );
} }
$scripts->add( 'swfupload-handlers', "/wp-includes/js/swfupload/handlers$suffix.js", array('swfupload'), '2.2.0-20081201'); $scripts->add( 'swfupload-handlers', "/wp-includes/js/swfupload/handlers$suffix.js", array('swfupload'), '2.2.0-20090327');
// these error messages came from the sample swfupload js, they might need changing. // these error messages came from the sample swfupload js, they might need changing.
$scripts->localize( 'swfupload-handlers', 'swfuploadL10n', array( $scripts->localize( 'swfupload-handlers', 'swfuploadL10n', array(
'queue_limit_exceeded' => __('You have attempted to queue too many files.'), 'queue_limit_exceeded' => __('You have attempted to queue too many files.'),