| @@ -2,8 +2,10 @@ | ||
| 2 | 2 | /* global visualizer */ |
| 3 | 3 | |
| 4 | 4 | (function($) { |
| 5 | 5 | var all_charts; |
| 6 | + // so that we know which charts belong to our library. | |
| 7 | + var rendered_charts = []; | |
| 6 | 8 | |
| 7 | 9 | function renderChart(id, v) { |
| 8 | 10 | renderSpecificChart(id, all_charts[id], v); |
| 9 | 11 | } |
| @@ -13,8 +15,9 @@ | ||
| 13 | 15 | |
| 14 | 16 | if(chart.library !== 'datatables'){ |
| 15 | 17 | return; |
| 16 | 18 | } |
| 19 | + rendered_charts[id] = 'yes'; | |
| 17 | 20 | |
| 18 | 21 | series = chart.series; |
| 19 | 22 | data = chart.data; |
| 20 | 23 | |
| @@ -34,8 +37,16 @@ | ||
| 34 | 37 | searching: false, |
| 35 | 38 | ordering: true, |
| 36 | 39 | select: false, |
| 37 | 40 | lengthChange: false, |
| 41 | + buttons: { | |
| 42 | + buttons: [{ | |
| 43 | + extend: 'print', | |
| 44 | + text: '', | |
| 45 | + title: '' | |
| 46 | + }] | |
| 47 | + }, | |
| 48 | + dom: 'Bfrtip', | |
| 38 | 49 | }; |
| 39 | 50 | |
| 40 | 51 | if(typeof v.page_type !== 'undefined'){ |
| 41 | 52 | switch(v.page_type){ |
| @@ -56,9 +67,10 @@ | ||
| 56 | 67 | |
| 57 | 68 | var select = { |
| 58 | 69 | info: false |
| 59 | 70 | }; |
| 60 | - $.extend( settings, { select } ); // jshint ignore:line | |
| 71 | + // we cannot use { select } below because https://github.com/Codeinwp/visualizer/issues/357 | |
| 72 | + $.extend( settings, { info: false } ); // jshint ignore:line | |
| 61 | 73 | |
| 62 | 74 | var stripe = ['', '']; |
| 63 | 75 | |
| 64 | 76 | // in preview mode, cssClassNames will not exist when a color is changed. |
| @@ -215,8 +227,20 @@ | ||
| 215 | 227 | $('body').on('visualizer:render:specificchart:start', function(event, v){ |
| 216 | 228 | renderSpecificChart(v.id, v.chart, v.v); |
| 217 | 229 | }); |
| 218 | 230 | |
| 231 | + // front end actions | |
| 232 | + $('body').on('visualizer:action:specificchart', function(event, v){ | |
| 233 | + switch(v.action){ | |
| 234 | + case 'print': | |
| 235 | + var id = v.id; | |
| 236 | + if(typeof rendered_charts[id] === 'undefined'){ | |
| 237 | + return; | |
| 238 | + } | |
| 239 | + $('#' + id + ' .buttons-print').trigger('click'); | |
| 240 | + break; | |
| 241 | + } | |
| 242 | + }); | |
| 219 | 243 | |
| 220 | 244 | })(jQuery); |
| 221 | 245 | |
| 222 | 246 | |