| @@ -1,7 +1,5 @@ | ||
| 1 | 1 | /* global visualizer */ |
| 2 | -/* global alert */ | |
| 3 | - | |
| 4 | 2 | (function (wpmv) { |
| 5 | 3 | var vm, vmv; |
| 6 | 4 | |
| 7 | 5 | vm = visualizer.media = {}; |
| @@ -22,13 +20,9 @@ | ||
| 22 | 20 | self.createIframeStates(); |
| 23 | 21 | }, |
| 24 | 22 | |
| 25 | 23 | open: function () { |
| 26 | - try{ | |
| 27 | - wpmv.MediaFrame.prototype.open.apply(this, arguments); | |
| 28 | - }catch(error){ | |
| 29 | - alert(visualizer.i10n.conflict); | |
| 30 | - } | |
| 24 | + wpmv.MediaFrame.prototype.open.apply(this, arguments); | |
| 31 | 25 | this.$el.addClass('hide-menu'); |
| 32 | 26 | } |
| 33 | 27 | }); |
| 34 | 28 | })(wp.media.view); |
| @@ -41,17 +35,9 @@ | ||
| 41 | 35 | var width = $('#visualizer-library').width(), |
| 42 | 36 | margin = width * 0.02; |
| 43 | 37 | |
| 44 | 38 | width *= 0.305; |
| 45 | - $(this).prev( '.visualizer-chart-title' ).width(width - 14); | |
| 46 | - var ChartHeight = width * 0.93; | |
| 47 | - if ( $( '.visualizer-nochart-canvas' ).length === 0 ) { | |
| 48 | - ChartHeight = width * 0.78; | |
| 49 | - if ( $( '#visualizer-sidebar' ).hasClass('one-columns') ) { | |
| 50 | - ChartHeight = width * 0.92; | |
| 51 | - } | |
| 52 | - } | |
| 53 | - $(this).width(width).height( ChartHeight ); | |
| 39 | + $(this).width(width - 14).height(width * 0.75).parent().css('margin-right', margin + 'px').css('margin-bottom', margin + 'px'); | |
| 54 | 40 | }); |
| 55 | 41 | }; |
| 56 | 42 | |
| 57 | 43 | $('.visualizer-chart-canvas').adjust(); |
| @@ -56,27 +42,10 @@ | ||
| 56 | 42 | |
| 57 | 43 | $('.visualizer-chart-canvas').adjust(); |
| 58 | 44 | |
| 59 | 45 | $(document).ready(function () { |
| 60 | - // clears the filters in the library form and submits. | |
| 61 | - $('#viz-lib-reset').on('click', function(e){ | |
| 62 | - e.preventDefault(); | |
| 63 | - $(this).parent('form')[0].reset(); | |
| 64 | - $(this).parent('form').find('.viz-filter').each(function(index, el){ | |
| 65 | - var tag = $(el).prop('tagName').toLowerCase() + (typeof $(el).attr('type') !== 'undefined' ? $(el).attr('type').toLowerCase() : ''); | |
| 66 | - switch(tag){ | |
| 67 | - case 'select': | |
| 68 | - $(el).prop('selectedIndex', 0); | |
| 69 | - break; | |
| 70 | - case 'inputtext': | |
| 71 | - $(el).val(''); | |
| 72 | - break; | |
| 73 | - } | |
| 46 | + $('.visualizer-chart, .visualizer-library-pagination').fadeIn(500); | |
| 74 | 47 | |
| 75 | - }); | |
| 76 | - $(this).parent('form').submit(); | |
| 77 | - }); | |
| 78 | - | |
| 79 | 48 | $('.visualizer-chart-shortcode').click(function (e) { |
| 80 | 49 | var range, selection; |
| 81 | 50 | |
| 82 | 51 | if (window.getSelection && document.createRange) { |
| @@ -91,36 +60,14 @@ | ||
| 91 | 60 | range.select(); |
| 92 | 61 | } |
| 93 | 62 | }); |
| 94 | 63 | |
| 95 | - $( '.visualizer-languages-list' ).on( 'click', '[data-lang_code]', function() { | |
| 96 | - if ( $(this).find( 'i' ).hasClass( 'otgs-ico-add' ) ) { | |
| 97 | - vu.create = vu.create + '&lang=' + $(this).data('lang_code') + '&parent_chart_id=' + $(this).data('chart'); | |
| 98 | - $('.add-new-chart').click(); | |
| 99 | - } else { | |
| 100 | - vu.edit = vu.edit + '&lang=' + $(this).data('lang_code') + '&chart=' + $(this).data('chart'); | |
| 101 | - $('.visualizer-chart-edit').click(); | |
| 102 | - } | |
| 103 | - } ); | |
| 104 | - | |
| 105 | - $('.add-new-chart').click(function () { | |
| 64 | + $('.add-new-h2').click(function () { | |
| 106 | 65 | var wnd = window, |
| 107 | 66 | view = new vmv.Chart({action: vu.create}); |
| 108 | - vu.create = vu.create.replace(/[\?&]lang=[^&]+/, '').replace(/[\?&]parent_chart_id=[^&]+/, ''); | |
| 109 | 67 | |
| 110 | - window.parent.addEventListener('message', function(event){ | |
| 111 | - switch(event.data) { | |
| 112 | - case 'visualizer:mediaframe:close': | |
| 113 | - view.close(); | |
| 114 | - break; | |
| 115 | - } | |
| 116 | - }, false); | |
| 117 | - | |
| 118 | - // remove the 'type' while refreshing the library page on creation of a new chart. | |
| 119 | - // this is to avoid cases where users have filtered for chart type A and end up creating chart type B | |
| 120 | - // remove 'vaction' as well so that additional actions are removed | |
| 121 | 68 | wnd.send_to_editor = function () { |
| 122 | - wnd.location.href = vu.base.replace(/type=[a-zA-Z]*/, '').replace(/vaction/, ''); | |
| 69 | + wnd.location.href = vu.base; | |
| 123 | 70 | }; |
| 124 | 71 | view.open(); |
| 125 | 72 | |
| 126 | 73 | return false; |
| @@ -126,16 +73,13 @@ | ||
| 126 | 73 | return false; |
| 127 | 74 | }); |
| 128 | 75 | |
| 129 | 76 | $('.visualizer-chart-edit').click(function () { |
| 130 | - var wnd = window; | |
| 131 | - var view = new vmv.Chart( { | |
| 132 | - action: vu.edit.indexOf('&chart') != -1 ? vu.edit : vu.edit + '&chart=' + $(this).attr('data-chart') | |
| 133 | - } ); | |
| 134 | - vu.edit = vu.edit.replace(/[\?&]lang=[^&]+/, ''); | |
| 77 | + var wnd = window, | |
| 78 | + view = new vmv.Chart({action: vu.edit + '&chart=' + $(this).attr('data-chart')}); | |
| 135 | 79 | |
| 136 | 80 | wnd.send_to_editor = function () { |
| 137 | - wnd.location.href = wnd.location.href.replace(/vaction/, ''); | |
| 81 | + wnd.location.reload(); | |
| 138 | 82 | }; |
| 139 | 83 | |
| 140 | 84 | view.open(); |
| 141 | 85 | |
| @@ -161,19 +105,8 @@ | ||
| 161 | 105 | } |
| 162 | 106 | }); |
| 163 | 107 | return false; |
| 164 | 108 | }); |
| 165 | - | |
| 166 | - $(".visualizer-chart-image").on("click", function () { | |
| 167 | - $('body').trigger('visualizer:action:specificchart', {action: 'image', id: $(this).attr("data-chart"), data: null, dataObj: {name: $(this).attr("data-chart-title")}}); | |
| 168 | - return false; | |
| 169 | - }); | |
| 170 | - | |
| 171 | - // if vaction=addnew is found as a GET request parameter, show the modal. | |
| 172 | - if(location.href.indexOf('vaction=addnew') !== -1){ | |
| 173 | - $('.add-new-chart').first().trigger('click'); | |
| 174 | - } | |
| 175 | - | |
| 176 | 109 | $(window).resize(function () { |
| 177 | 110 | clearTimeout(resizeTimeout); |
| 178 | 111 | resizeTimeout = setTimeout(function () { |
| 179 | 112 | $('.visualizer-chart-canvas').adjust(); |
| @@ -178,11 +111,6 @@ | ||
| 178 | 111 | resizeTimeout = setTimeout(function () { |
| 179 | 112 | $('.visualizer-chart-canvas').adjust(); |
| 180 | 113 | }, 100); |
| 181 | 114 | }); |
| 182 | - | |
| 183 | - $('.visualizer-error i.error').on('click', function(){ | |
| 184 | - alert( $(this).attr('data-viz-error') ); | |
| 185 | - }); | |
| 186 | - $('.visualizer-chart:not(.visualizer-chart-display), .visualizer-library-pagination').fadeIn(500); | |
| 187 | 115 | }); |
| 188 | 116 | })(jQuery, visualizer.media.view, visualizer.urls); |