| @@ -45,11 +45,8 @@ | ||
| 45 | 45 | (function ($, vmv, vu) { |
| 46 | 46 | var resizeTimeout; |
| 47 | 47 | |
| 48 | 48 | $.fn.adjust = function () { |
| 49 | - if ( $( '#visualizer-library' ).hasClass( 'view-list' ) ) { | |
| 50 | - return this; | |
| 51 | - } | |
| 52 | 49 | return $(this).each(function () { |
| 53 | 50 | var width = $('#visualizer-library').width(), |
| 54 | 51 | margin = width * 0.02; |
| 55 | 52 | |
| @@ -87,55 +84,8 @@ | ||
| 87 | 84 | }); |
| 88 | 85 | $(this).parent('form').submit(); |
| 89 | 86 | }); |
| 90 | 87 | |
| 91 | - // Copy shortcode when clicking the code display in list view. | |
| 92 | - $( document ).on( 'click', '.viz-shortcode-display', function () { | |
| 93 | - var text = $( this ).text(); | |
| 94 | - var el = this; | |
| 95 | - | |
| 96 | - // Fallback copy method using a temporary textarea. Returns true on success. | |
| 97 | - var fallbackCopy = function ( value ) { | |
| 98 | - var ta = document.createElement( 'textarea' ); | |
| 99 | - ta.value = value; | |
| 100 | - document.body.appendChild( ta ); | |
| 101 | - ta.select(); | |
| 102 | - var succeeded = false; | |
| 103 | - try { | |
| 104 | - succeeded = document.execCommand( 'copy' ); | |
| 105 | - } catch ( e ) { | |
| 106 | - succeeded = false; | |
| 107 | - } | |
| 108 | - document.body.removeChild( ta ); | |
| 109 | - return succeeded; | |
| 110 | - }; | |
| 111 | - | |
| 112 | - // Apply temporary "copied" feedback. | |
| 113 | - var showCopiedFeedback = function () { | |
| 114 | - $( el ).addClass( 'viz-shortcode-copied' ); | |
| 115 | - setTimeout( function () { | |
| 116 | - $( el ).removeClass( 'viz-shortcode-copied' ); | |
| 117 | - }, 1200 ); | |
| 118 | - }; | |
| 119 | - | |
| 120 | - if ( navigator.clipboard && navigator.clipboard.writeText ) { | |
| 121 | - navigator.clipboard.writeText( text ).then( function () { | |
| 122 | - // Clipboard API succeeded. | |
| 123 | - showCopiedFeedback(); | |
| 124 | - } ).catch( function () { | |
| 125 | - // Clipboard API failed; fall back to textarea method. | |
| 126 | - if ( fallbackCopy( text ) ) { | |
| 127 | - showCopiedFeedback(); | |
| 128 | - } | |
| 129 | - } ); | |
| 130 | - } else { | |
| 131 | - // No Clipboard API; use fallback directly. | |
| 132 | - if ( fallbackCopy( text ) ) { | |
| 133 | - showCopiedFeedback(); | |
| 134 | - } | |
| 135 | - } | |
| 136 | - } ); | |
| 137 | - | |
| 138 | 88 | $('.visualizer-chart-shortcode').click(function (event) { |
| 139 | 89 | |
| 140 | 90 | if ( createPopupProBlocker( $, event ) ) { |
| 141 | 91 | event.preventDefault(); |
| @@ -167,9 +117,9 @@ | ||
| 167 | 117 | $('.visualizer-chart-edit').click(); |
| 168 | 118 | } |
| 169 | 119 | } ); |
| 170 | 120 | |
| 171 | - function openClassicBuilder() { | |
| 121 | + $('.add-new-chart').click(function () { | |
| 172 | 122 | var wnd = window, |
| 173 | 123 | view = new vmv.Chart({action: vu.create}); |
| 174 | 124 | vu.create = vu.create.replace(/[\?&]lang=[^&]+/, '').replace(/[\?&]parent_chart_id=[^&]+/, ''); |
| 175 | 125 | |
| @@ -187,84 +137,16 @@ | ||
| 187 | 137 | wnd.send_to_editor = function () { |
| 188 | 138 | wnd.location.href = vu.base.replace(/type=[a-zA-Z]*/, '').replace(/vaction/, ''); |
| 189 | 139 | }; |
| 190 | 140 | view.open(); |
| 191 | - } | |
| 192 | 141 | |
| 193 | - function closeAddNewMenus() { | |
| 194 | - $('.viz-add-new-group').removeClass('is-open'); | |
| 195 | - $('.viz-add-new-toggle').attr('aria-expanded', 'false'); | |
| 196 | - $('.viz-add-new-menu').attr('aria-hidden', 'true'); | |
| 197 | - } | |
| 198 | - | |
| 199 | - $(document).on('click', function() { | |
| 200 | - closeAddNewMenus(); | |
| 201 | - }); | |
| 202 | - | |
| 203 | - $(document).on('click', '.viz-add-new-toggle', function(event) { | |
| 204 | - event.preventDefault(); | |
| 205 | - event.stopPropagation(); | |
| 206 | - event.stopImmediatePropagation(); | |
| 207 | - var $group = $(this).closest('.viz-add-new-group'); | |
| 208 | - var isOpen = $group.hasClass('is-open'); | |
| 209 | - closeAddNewMenus(); | |
| 210 | - if ( ! isOpen ) { | |
| 211 | - $group.addClass('is-open'); | |
| 212 | - $(this).attr('aria-expanded', 'true'); | |
| 213 | - $group.find('.viz-add-new-menu').attr('aria-hidden', 'false'); | |
| 214 | - } | |
| 215 | 142 | return false; |
| 216 | 143 | }); |
| 217 | 144 | |
| 218 | - $(document).on('click', '.viz-add-new-item', function(event) { | |
| 219 | - event.preventDefault(); | |
| 220 | - event.stopPropagation(); | |
| 221 | - event.stopImmediatePropagation(); | |
| 222 | - var builder = $(this).data('viz-builder'); | |
| 223 | - closeAddNewMenus(); | |
| 224 | - | |
| 225 | - if ( builder === 'ai' ) { | |
| 226 | - if ( typeof window.vizOpenAIBuilderNew === 'function' ) { | |
| 227 | - window.vizOpenAIBuilderNew(); | |
| 228 | - return; | |
| 229 | - } | |
| 230 | - if ( typeof window.vizOpenChartChooser === 'function' ) { | |
| 231 | - var classicCallback = function() { | |
| 232 | - openClassicBuilder(); | |
| 233 | - }; | |
| 234 | - window.vizOpenChartChooser( classicCallback ); | |
| 235 | - return; | |
| 236 | - } | |
| 237 | - } | |
| 238 | - | |
| 239 | - openClassicBuilder(); | |
| 240 | - }); | |
| 241 | - | |
| 242 | - $('.add-new-chart').click(function () { | |
| 243 | - // Hook for the React chart builder chooser modal. | |
| 244 | - // If the React app is loaded it sets window.vizOpenChartChooser and handles routing. | |
| 245 | - // It will call the classicCallback if the user picks the Classic Builder. | |
| 246 | - if (typeof window.vizOpenChartChooser === 'function') { | |
| 247 | - var classicCallback = function() { | |
| 248 | - openClassicBuilder(); | |
| 249 | - }; | |
| 250 | - window.vizOpenChartChooser(classicCallback); | |
| 251 | - return false; | |
| 252 | - } | |
| 253 | - openClassicBuilder(); | |
| 254 | - return false; | |
| 255 | - }); | |
| 256 | - | |
| 257 | 145 | $('.visualizer-chart-edit').click(function (event) { |
| 258 | 146 | |
| 259 | 147 | if ( createPopupProBlocker( $, event ) ) { |
| 260 | 148 | return; |
| 261 | - } | |
| 262 | - | |
| 263 | - // D3/AI charts open in the AI Builder instead of the classic modal. | |
| 264 | - if ( $(this).data('library') === 'd3' && typeof window.vizOpenAIBuilderEdit === 'function' ) { | |
| 265 | - window.vizOpenAIBuilderEdit( $(this).attr('data-chart') ); | |
| 266 | - return false; | |
| 267 | 149 | } |
| 268 | 150 | |
| 269 | 151 | var wnd = window; |
| 270 | 152 | var view = new vmv.Chart( { |