| @@ -10,12 +10,11 @@ | ||
| 10 | 10 | clipboard.on('success', function(e) { |
| 11 | 11 | window.alert(v.i10n['copied']); |
| 12 | 12 | }); |
| 13 | 13 | } |
| 14 | - $('a.visualizer-action[data-visualizer-type!=copy]').off('click').on('click', function(e) { | |
| 14 | + $('a.visualizer-action[data-visualizer-type!=copy]').on('click', function(e) { | |
| 15 | 15 | var type = $(this).attr( 'data-visualizer-type' ); |
| 16 | 16 | var chart = $(this).attr( 'data-visualizer-chart-id' ); |
| 17 | - var container = $(this).attr( 'data-visualizer-container-id' ); | |
| 18 | 17 | var lock = $('.visualizer-front.visualizer-front-' + chart); |
| 19 | 18 | lock.lock(); |
| 20 | 19 | e.preventDefault(); |
| 21 | 20 | $.ajax({ |
| @@ -44,9 +43,19 @@ | ||
| 44 | 43 | $a[0].click(); |
| 45 | 44 | $a.remove(); |
| 46 | 45 | break; |
| 47 | 46 | case 'print': |
| 48 | - $('body').trigger('visualizer:action:specificchart', {action: 'print', id: container, data: data.data.csv}); | |
| 47 | + var iframe = $('<iframe>').attr("name", "print-visualization").attr("id", "print-visualization").css("position", "absolute"); | |
| 48 | + iframe.appendTo($('body')); | |
| 49 | + var iframe_doc = iframe.get(0).contentWindow || iframe.get(0).contentDocument.document || iframe.get(0).contentDocument; | |
| 50 | + iframe_doc.document.open(); | |
| 51 | + iframe_doc.document.write(data.data.csv); | |
| 52 | + iframe_doc.document.close(); | |
| 53 | + setTimeout(function(){ | |
| 54 | + window.frames['print-visualization'].focus(); | |
| 55 | + window.frames['print-visualization'].print(); | |
| 56 | + iframe.remove(); | |
| 57 | + }, 500); | |
| 49 | 58 | break; |
| 50 | 59 | default: |
| 51 | 60 | if(window.visualizer_perform_action) { |
| 52 | 61 | window.visualizer_perform_action(type, chart, data.data); |
| @@ -62,26 +71,9 @@ | ||
| 62 | 71 | |
| 63 | 72 | $(document).ready(function(){ |
| 64 | 73 | $('body').trigger('visualizer:render:chart:start', visualizer); |
| 65 | 74 | initActionsButtons(visualizer); |
| 66 | - registerDefaultActions(); | |
| 67 | 75 | }); |
| 68 | - | |
| 69 | - function registerDefaultActions(){ | |
| 70 | - $('body').off('visualizer:action:specificchart:defaultprint').on('visualizer:action:specificchart:defaultprint', function(event, v){ | |
| 71 | - var iframe = $('<iframe>').attr("name", "print-visualization").attr("id", "print-visualization").css("position", "absolute"); | |
| 72 | - iframe.appendTo($('body')); | |
| 73 | - var iframe_doc = iframe.get(0).contentWindow || iframe.get(0).contentDocument.document || iframe.get(0).contentDocument; | |
| 74 | - iframe_doc.document.open(); | |
| 75 | - iframe_doc.document.write(v.data); | |
| 76 | - iframe_doc.document.close(); | |
| 77 | - setTimeout(function(){ | |
| 78 | - window.frames['print-visualization'].focus(); | |
| 79 | - window.frames['print-visualization'].print(); | |
| 80 | - iframe.remove(); | |
| 81 | - }, 500); | |
| 82 | - }); | |
| 83 | - } | |
| 84 | 76 | })(jQuery, visualizer); |
| 85 | 77 | |
| 86 | 78 | (function ($) { |
| 87 | 79 | $.fn.lock = function () { |