Show error if copying can't even happen (to cover safari).

This commit is contained in:
Justin Shreve 2016-03-02 10:25:16 -08:00
parent 32eabbc685
commit f4d771ef3e
2 changed files with 13 additions and 0 deletions

View File

@ -65,7 +65,13 @@
}
} );
$( document.body ).on( 'click', css_class, function( e ) {
$( css_class ).parent().find( 'input' ).focus().select();
$( '#copy-error' ).text( woocommerce_admin_api_keys.clipboard_failed );
} );
$( document.body ).on( 'copy', css_class, function( e ) {
$( '#copy-error' ).text( '' );
e.clipboardData.clearData();
e.clipboardData.setData( 'text/plain', $.trim( $( this ).prev( 'input' ).val() ) );
e.preventDefault();

View File

@ -805,7 +805,14 @@ if ( ! defined( 'ABSPATH' ) ) {
});
jQuery( document ).ready( function( $ ) {
$( document.body ).on ( 'click', '#copy-for-support', function( e ) {
$( '#debug-report' ).find( 'textarea' ).focus().select();
$( '#copy-error' ).text( '<?php esc_html_e( 'Copying to clipboard failed. Please press Ctrl/Cmd+C to copy.', 'woocommerce' ); ?>' );
} );
$( document.body ).on( 'copy', '#copy-for-support', function( e ) {
$( '#copy-error' ).text( '' );
e.clipboardData.clearData();
e.clipboardData.setData( 'text/plain', $( '#debug-report' ).find( 'textarea' ).val() );
e.preventDefault();