app/assets/javascripts/effective_datatables/charts.js.coffee in effective_datatables-2.12.1 vs app/assets/javascripts/effective_datatables/charts.js.coffee in effective_datatables-2.12.2
- old
+ new
@@ -1,13 +1,18 @@
initializeCharts = ->
$charts = $('.effective-datatables-chart:not(.initialized)')
- return unless $charts.length > 0
+ return if $charts.length == 0
- if typeof(google) != 'undefined' && typeof(google.charts) != 'undefined'
- google.charts.load('current', { packages: ['corechart'] })
- google.charts.setOnLoadCallback(renderCharts)
+ if typeof(google) == 'undefined' || typeof(google.charts) == 'undefined'
+ $.getScript 'https://www.gstatic.com/charts/loader.js', -> loadCharts()
+ else
+ loadCharts()
$charts.addClass('initialized')
+
+loadCharts = ->
+ google.charts.load('current', { packages: ['corechart'] })
+ google.charts.setOnLoadCallback(renderCharts)
renderCharts = ->
return if (typeof(google) == 'undefined' || typeof(google.visualization) == 'undefined')
$('.effective-datatables-chart').each ->