Skip to content

Commit b1c1447

Browse files
Merge pull request #692 from contactashish13/issue-676
Clicking Copy shows the Copied message multiple times
2 parents 9bbcee3 + 3622ceb commit b1c1447

File tree

3 files changed

+93
-85
lines changed

3 files changed

+93
-85
lines changed

classes/Visualizer/Module/Frontend.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ public function renderChart( $atts ) {
375375
'map_api_key' => get_option( 'visualizer-map-api-key' ),
376376
'rest_url' => version_compare( $wp_version, '4.7.0', '>=' ) ? rest_url( 'visualizer/v' . VISUALIZER_REST_VERSION . '/action/#id#/#type#/' ) : '',
377377
'i10n' => array(
378-
'copied' => __( 'Copied!', 'visualizer' ),
378+
'copied' => __( 'The data has been copied to your clipboard. Hit Ctrl-V/Cmd-V in your spreadsheet editor to paste the data.', 'visualizer' ),
379379
),
380380
'page_type' => 'frontend',
381381
'is_front' => true,

js/render-facade.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
function initActionsButtons(v) {
88
if($('a.visualizer-action[data-visualizer-type=copy]').length > 0) {
9+
$('a.visualizer-action[data-visualizer-type=copy]').on('click', function(e) {
10+
e.preventDefault();
11+
});
912
var clipboard = new Clipboard('a.visualizer-action[data-visualizer-type=copy]'); // jshint ignore:line
1013
clipboard.on('success', function(e) {
1114
window.alert(v.i10n['copied']);
@@ -88,24 +91,23 @@
8891
document.body.dispatchEvent(event);
8992
};
9093

91-
// facade loads N times in the library (where N = the number of different chart libraries supported)
94+
// facade loads N times in the library and front end (where N = the number of different chart libraries supported)
9295
// so all charts are also loaded N times
9396
// this will ensure that no matter how many times facade is loaded, it initializes all charts only once.
9497
// fixed as part of the issue to add annotations.
95-
if(visualizer.page_type === 'library'){
96-
if(localStorage.getItem( 'viz-facade-loaded' ) === '1'){
97-
// prevent library from hanging.
98-
setTimeout( function(){
99-
localStorage.removeItem( 'viz-facade-loaded' );
100-
}, 2000);
101-
return;
102-
}
103-
localStorage.setItem( 'viz-facade-loaded', '1');
104-
// remove the flag so that repeated loading of the library does not cause problems.
98+
if(localStorage.getItem( 'viz-facade-loaded' ) === '1'){
99+
// prevent library from hanging.
105100
setTimeout( function(){
106101
localStorage.removeItem( 'viz-facade-loaded' );
107102
}, 2000);
103+
return;
108104
}
105+
localStorage.setItem( 'viz-facade-loaded', '1');
106+
// remove the flag so that repeated loading of the library does not cause problems.
107+
setTimeout( function(){
108+
localStorage.removeItem( 'viz-facade-loaded' );
109+
}, 2000);
110+
109111
$('body').trigger('visualizer:render:chart:start', visualizer);
110112
initActionsButtons(visualizer);
111113
registerDefaultActions();

0 commit comments

Comments
 (0)