| @@ -60,14 +60,25 @@ | ||
| 60 | 60 | range.select(); |
| 61 | 61 | } |
| 62 | 62 | }); |
| 63 | 63 | |
| 64 | - $('.add-new-h2').click(function () { | |
| 64 | + $('.add-new-chart').click(function () { | |
| 65 | 65 | var wnd = window, |
| 66 | 66 | view = new vmv.Chart({action: vu.create}); |
| 67 | 67 | |
| 68 | + window.parent.addEventListener('message', function(event){ | |
| 69 | + switch(event.data) { | |
| 70 | + case 'visualizer:mediaframe:close': | |
| 71 | + view.close(); | |
| 72 | + break; | |
| 73 | + } | |
| 74 | + }, false); | |
| 75 | + | |
| 76 | + // remove the 'type' while refreshing the library page on creation of a new chart. | |
| 77 | + // this is to avoid cases where users have filtered for chart type A and end up creating chart type B | |
| 78 | + // remove 'vaction' as well so that additional actions are removed | |
| 68 | 79 | wnd.send_to_editor = function () { |
| 69 | - wnd.location.href = vu.base; | |
| 80 | + wnd.location.href = vu.base.replace(/type=[a-zA-Z]*/, '').replace(/vaction/, ''); | |
| 70 | 81 | }; |
| 71 | 82 | view.open(); |
| 72 | 83 | |
| 73 | 84 | return false; |
| @@ -77,9 +88,9 @@ | ||
| 77 | 88 | var wnd = window, |
| 78 | 89 | view = new vmv.Chart({action: vu.edit + '&chart=' + $(this).attr('data-chart')}); |
| 79 | 90 | |
| 80 | 91 | wnd.send_to_editor = function () { |
| 81 | - wnd.location.reload(); | |
| 92 | + wnd.location.href = wnd.location.href.replace(/vaction/, ''); | |
| 82 | 93 | }; |
| 83 | 94 | |
| 84 | 95 | view.open(); |
| 85 | 96 | |
| @@ -105,8 +116,14 @@ | ||
| 105 | 116 | } |
| 106 | 117 | }); |
| 107 | 118 | return false; |
| 108 | 119 | }); |
| 120 | + | |
| 121 | + // if vaction=addnew is found as a GET request parameter, show the modal. | |
| 122 | + if(location.href.indexOf('vaction=addnew') !== -1){ | |
| 123 | + $('.add-new-chart').trigger('click'); | |
| 124 | + } | |
| 125 | + | |
| 109 | 126 | $(window).resize(function () { |
| 110 | 127 | clearTimeout(resizeTimeout); |
| 111 | 128 | resizeTimeout = setTimeout(function () { |
| 112 | 129 | $('.visualizer-chart-canvas').adjust(); |