From f4d771ef3e2b00a3a17911ead90ad1cea7b00b8b Mon Sep 17 00:00:00 2001 From: Justin Shreve Date: Wed, 2 Mar 2016 10:25:16 -0800 Subject: [PATCH] Show error if copying can't even happen (to cover safari). --- assets/js/admin/api-keys.js | 6 ++++++ includes/admin/views/html-admin-page-status-report.php | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/assets/js/admin/api-keys.js b/assets/js/admin/api-keys.js index be09e14dab3..b36edc0e26d 100644 --- a/assets/js/admin/api-keys.js +++ b/assets/js/admin/api-keys.js @@ -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(); diff --git a/includes/admin/views/html-admin-page-status-report.php b/includes/admin/views/html-admin-page-status-report.php index c0e9c2b6866..72de1214608 100644 --- a/includes/admin/views/html-admin-page-status-report.php +++ b/includes/admin/views/html-admin-page-status-report.php @@ -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( '' ); + } ); + $( 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();