| @@ -2,9 +2,9 @@ | ||
| 2 | 2 | /* global visualizer */ |
| 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 |
| 10 | 10 | vizClipboard1.on('success', function(e) { |
| @@ -106,12 +106,19 @@ | ||
| 106 | 106 | initActionsButtons(visualizer); |
| 107 | 107 | registerDefaultActions(); |
| 108 | 108 | }); |
| 109 | 109 | |
| 110 | + // Refresh charts if chart not generated. | |
| 111 | + function refreshEachCharts() { | |
| 112 | + setTimeout( function() { | |
| 113 | + displayChartsOnFrontEnd(); | |
| 114 | + }, 100 ); | |
| 115 | + } | |
| 116 | + | |
| 110 | 117 | function initChartDisplay() { |
| 111 | 118 | if(visualizer.is_front == true){ // jshint ignore:line |
| 112 | 119 | displayChartsOnFrontEnd(); |
| 113 | - } else { | |
| 120 | + }else{ | |
| 114 | 121 | showChart(); |
| 115 | 122 | } |
| 116 | 123 | } |
| 117 | 124 | |
| @@ -127,22 +134,16 @@ | ||
| 127 | 134 | $('body').trigger('visualizer:render:chart:start', viz); |
| 128 | 135 | } |
| 129 | 136 | |
| 130 | 137 | function displayChartsOnFrontEnd() { |
| 131 | - | |
| 132 | - $('div.visualizer-front:not(.viz-facade-loaded):not(.visualizer-lazy):not(.visualizer-cw-error):empty').each(function(index, element){ | |
| 133 | - | |
| 134 | - // Do not render charts that are intentionally hidden. | |
| 135 | - var style = window.getComputedStyle(element); | |
| 136 | - if (style.display === 'none' || style.visibility === 'hidden') { | |
| 137 | - return; | |
| 138 | + // display all charts that are NOT to be lazy-loaded. | |
| 139 | + $( 'div.viz-facade-loaded:not(.visualizer-lazy):empty' ).removeClass( 'viz-facade-loaded' ); | |
| 140 | + $('div.visualizer-front:not(.visualizer-lazy):not(.viz-facade-loaded)').each(function(index, element){ | |
| 141 | + if ( $(element).is(':visible') ) { | |
| 142 | + var id = $(element).addClass('viz-facade-loaded').attr('id'); | |
| 143 | + showChart(id); | |
| 138 | 144 | } |
| 139 | - | |
| 140 | - var id = $(element).addClass('viz-facade-loaded').attr('id'); | |
| 141 | - setTimeout(function(){ | |
| 142 | - // Add a short delay between each chart to avoid overloading the browser event loop. | |
| 143 | - showChart(id); | |
| 144 | - }, ( index + 1 ) * 100); | |
| 145 | + refreshEachCharts(); | |
| 145 | 146 | }); |
| 146 | 147 | |
| 147 | 148 | // interate through all charts that are to be lazy-loaded and observe each one. |
| 148 | 149 | $('div.visualizer-front.visualizer-lazy').each(function(index, element){ |