3
3
/* global jQuery */
4
4
var vizClipboard1 = null ;
5
5
( function ( $ , visualizer ) {
6
-
6
+
7
7
function initActionsButtons ( v ) {
8
8
if ( $ ( 'a.visualizer-chart-shortcode' ) . length > 0 && vizClipboard1 === null ) {
9
9
vizClipboard1 = new ClipboardJS ( 'a.visualizer-chart-shortcode' ) ; // jshint ignore:line
@@ -107,20 +107,10 @@ var vizClipboard1=null;
107
107
registerDefaultActions ( ) ;
108
108
} ) ;
109
109
110
- // Refresh charts if chart not generated.
111
- function refreshEachCharts ( ) {
112
- if ( 'object' === typeof window . fusionAnimationsVars ) {
113
- return ;
114
- }
115
- setTimeout ( function ( ) {
116
- displayChartsOnFrontEnd ( ) ;
117
- } , 100 ) ;
118
- }
119
-
120
110
function initChartDisplay ( ) {
121
111
if ( visualizer . is_front == true ) { // jshint ignore:line
122
112
displayChartsOnFrontEnd ( ) ;
123
- } else {
113
+ } else {
124
114
showChart ( ) ;
125
115
}
126
116
}
@@ -138,14 +128,15 @@ var vizClipboard1=null;
138
128
}
139
129
140
130
function displayChartsOnFrontEnd ( ) {
141
- // display all charts that are NOT to be lazy-loaded.
142
- $ ( 'div.viz-facade-loaded:not(.visualizer-lazy):not(.visualizer-cw-error):empty' ) . removeClass ( 'viz-facade-loaded' ) ;
143
- $ ( 'div.visualizer-front:not(.visualizer-lazy):not(.viz-facade-loaded)' ) . each ( function ( index , element ) {
131
+
132
+ $ ( 'div.visualizer-front:not(.viz-facade-loaded):not(.visualizer-lazy):not(.visualizer-cw-error):empty' ) . each ( function ( index , element ) {
144
133
if ( $ ( element ) . is ( ':visible' ) ) {
145
134
var id = $ ( element ) . addClass ( 'viz-facade-loaded' ) . attr ( 'id' ) ;
146
- showChart ( id ) ;
135
+ setTimeout ( function ( ) {
136
+ // Add a short delay between each chart to avoid overloading the browser event loop.
137
+ showChart ( id ) ;
138
+ } , ( index + 1 ) * 100 ) ;
147
139
}
148
- refreshEachCharts ( ) ;
149
140
} ) ;
150
141
151
142
// interate through all charts that are to be lazy-loaded and observe each one.
0 commit comments