| @@ -26,9 +26,9 @@ | ||
| 26 | 26 | $( "#sidebar" ).unlock(); |
| 27 | 27 | }, |
| 28 | 28 | beforeActivate: function( event, ui ) { |
| 29 | 29 | // if settings have changed in tab #2 and tab #1 is being activated, warn the user. |
| 30 | - if(vizHaveSettingsChanged() && ui.newTab.find( 'a' ).attr( 'id' ).includes('viz-tab-basic')){ | |
| 30 | + if(vizHaveSettingsChanged() && $(ui.newTab.context).attr('id').includes('viz-tab-basic')){ | |
| 31 | 31 | return confirm(visualizer.l10n.save_settings); |
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | }); |
| @@ -127,11 +127,11 @@ | ||
| 127 | 127 | $(this).parent().submit(); |
| 128 | 128 | } |
| 129 | 129 | }); |
| 130 | 130 | |
| 131 | - $( window ).on( 'load', function() { | |
| 131 | + $('#thehole').load(function () { | |
| 132 | 132 | $('#canvas').unlock(); |
| 133 | - } ); | |
| 133 | + }); | |
| 134 | 134 | |
| 135 | 135 | $(document).on('click', '.viz-section-title', function () { |
| 136 | 136 | $(this).toggleClass('open').parent().find('.viz-section-items').toggle(); |
| 137 | 137 | }); |
| @@ -382,25 +382,19 @@ | ||
| 382 | 382 | $('.visualizer-json-subform').accordion( "option", "active", i ); |
| 383 | 383 | }); |
| 384 | 384 | |
| 385 | 385 | // toggle between chart and create/modify parameters |
| 386 | - $( '#json-chart-button, #woo-chart-button' ).on( 'click', function(){ | |
| 386 | + $( '#json-chart-button' ).on( 'click', function(){ | |
| 387 | 387 | |
| 388 | 388 | $('body').off('visualizer:change:action').on('visualizer:change:action', function(e){ |
| 389 | - var filter_button = $( '#json-chart-button, #woo-chart-button' ); | |
| 389 | + var filter_button = $( '#json-chart-button' ); | |
| 390 | 390 | $( '#visualizer-json-screen' ).css("z-index", "-1").hide(); |
| 391 | 391 | filter_button.val( filter_button.attr( 'data-t-chart' ) ); |
| 392 | 392 | filter_button.html( filter_button.attr( 'data-t-chart' ) ); |
| 393 | 393 | filter_button.attr( 'data-current', 'chart' ); |
| 394 | 394 | $( '#canvas' ).css("z-index", "1").show(); |
| 395 | - $( '#vz-import-woo-report' ).find( 'select, input' ).removeAttr( 'disabled' ); | |
| 396 | 395 | }); |
| 397 | 396 | |
| 398 | - if ( 'json-chart-button' === $( this ).attr( 'id' ) ) { | |
| 399 | - $( '#vz-import-woo-report' ).find( 'select, input' ).attr( 'disabled', true ); | |
| 400 | - } else { | |
| 401 | - $( '#vz-import-woo-report' ).find( 'select, input' ).removeAttr( 'disabled' ); | |
| 402 | - } | |
| 403 | 397 | $('#content').css('width', 'calc(100% - 100px)'); |
| 404 | 398 | if( $(this).attr( 'data-current' ) === 'chart'){ |
| 405 | 399 | // toggle from chart to LHS form |
| 406 | 400 | $(this).val( $(this).attr( 'data-t-filter' ) ); |
| @@ -407,17 +401,8 @@ | ||
| 407 | 401 | $(this).html( $(this).attr( 'data-t-filter' ) ); |
| 408 | 402 | $(this).attr( 'data-current', 'filter' ); |
| 409 | 403 | $( '.visualizer-editor-lhs' ).hide(); |
| 410 | 404 | $( '#visualizer-json-screen' ).css("z-index", "9999").show(); |
| 411 | - if ( 'woo-chart-button' === $( this ).attr( 'id' ) && '' !== $( '#vz-woo-source:visible' ).val() ) { | |
| 412 | - $( '#vz-import-json-url' ).val( visualizer.rest_base + $( '#vz-woo-source' ).val() ).attr( 'readonly', true ); | |
| 413 | - } else { | |
| 414 | - if ( 'undefined' !== $( '#vz-import-json-url' ).attr( 'readonly' ) ) { | |
| 415 | - $( '#vz-import-json-url' ).val( '' ).removeAttr( 'readonly' ).removeAttr( 'value' ); | |
| 416 | - $('#json-endpoint-form')[0].reset(); | |
| 417 | - $('.visualizer-json-form h3.viz-step:not(.step1)').addClass('ui-state-disabled'); | |
| 418 | - } | |
| 419 | - } | |
| 420 | 405 | $( '#canvas' ).hide(); |
| 421 | 406 | }else{ |
| 422 | 407 | // toggle from LHS form to chart |
| 423 | 408 | $( '#json-conclude-form' ).trigger('submit'); |
| @@ -424,9 +409,9 @@ | ||
| 424 | 409 | } |
| 425 | 410 | } ); |
| 426 | 411 | |
| 427 | 412 | $('body').on('visualizer:json:form:submit', function() { |
| 428 | - var filter_button = $( '#json-chart-button, #woo-chart-button' ); | |
| 413 | + var filter_button = $( '#json-chart-button' ); | |
| 429 | 414 | $( '#visualizer-json-screen' ).css("z-index", "-1").hide(); |
| 430 | 415 | $('#canvas').lock(); |
| 431 | 416 | filter_button.val( filter_button.attr( 'data-t-chart' ) ); |
| 432 | 417 | filter_button.html( filter_button.attr( 'data-t-chart' ) ); |
| @@ -431,9 +416,9 @@ | ||
| 431 | 416 | filter_button.val( filter_button.attr( 'data-t-chart' ) ); |
| 432 | 417 | filter_button.html( filter_button.attr( 'data-t-chart' ) ); |
| 433 | 418 | filter_button.attr( 'data-current', 'chart' ); |
| 434 | 419 | end_ajax( $( '#visualizer-json-screen' ) ); |
| 435 | - $( '#canvas' ).removeClass('visualizer-chart-loaded').css("z-index", "1").show(); | |
| 420 | + $( '#canvas' ).css("z-index", "1").show(); | |
| 436 | 421 | }); |
| 437 | 422 | |
| 438 | 423 | |
| 439 | 424 | // fetch the roots for the provided endpoint |
| @@ -526,9 +511,9 @@ | ||
| 526 | 511 | return false; |
| 527 | 512 | } |
| 528 | 513 | |
| 529 | 514 | // populate the form elements that are in the other tabs. |
| 530 | - $('#json-conclude-form-helper .json-form-element, #json-endpoint-form .json-form-element, #json-root-form .json-form-element, #vz-import-json .json-form-element, #vz-import-woo-report .json-form-element:not(:disabled)').each(function(x, y){ | |
| 515 | + $('#json-conclude-form-helper .json-form-element, #json-endpoint-form .json-form-element, #json-root-form .json-form-element, #vz-import-json .json-form-element').each(function(x, y){ | |
| 531 | 516 | $('#json-conclude-form').append('<input type="hidden" name="' + y.name + '" value="' + y.value + '">'); |
| 532 | 517 | }); |
| 533 | 518 | |
| 534 | 519 | $('body').trigger('visualizer:json:form:submit'); |
| @@ -534,12 +519,11 @@ | ||
| 534 | 519 | $('body').trigger('visualizer:json:form:submit'); |
| 535 | 520 | }); |
| 536 | 521 | |
| 537 | 522 | // update the schedule |
| 538 | - $('#json-chart-save-button, #woo-chart-save-button').on('click', function(e){ | |
| 523 | + $('#json-chart-save-button').on('click', function(e){ | |
| 539 | 524 | e.preventDefault(); |
| 540 | 525 | $('#canvas').lock(); |
| 541 | - var btnID = jQuery( this ).attr( 'id' ); | |
| 542 | 526 | $.ajax({ |
| 543 | 527 | url : ajaxurl, |
| 544 | 528 | method : 'post', |
| 545 | 529 | data : { |
| @@ -544,11 +528,10 @@ | ||
| 544 | 528 | method : 'post', |
| 545 | 529 | data : { |
| 546 | 530 | 'action' : visualizer.ajax['actions']['json_set_schedule'], |
| 547 | 531 | 'security' : visualizer.ajax['nonces']['json_set_schedule'], |
| 548 | - 'chart' : $('#vz-json-time, #vz-woo-time').attr('data-chart'), | |
| 549 | - 'time' : $('#vz-json-time, #vz-woo-time').val(), | |
| 550 | - 'is_woocommerce_report': 'woo-chart-save-button' === btnID, | |
| 532 | + 'chart' : $('#vz-json-time').attr('data-chart'), | |
| 533 | + 'time' : $('#vz-json-time').val() | |
| 551 | 534 | }, |
| 552 | 535 | success : function(data){ |
| 553 | 536 | // do nothing. |
| 554 | 537 | }, |
| @@ -556,20 +539,8 @@ | ||
| 556 | 539 | $('#canvas').unlock(); |
| 557 | 540 | } |
| 558 | 541 | }); |
| 559 | 542 | }); |
| 560 | - | |
| 561 | - // Select WooCommerce report endpoint. | |
| 562 | - $( '#vz-woo-source' ).on( 'click', function( e ) { | |
| 563 | - // Trigger change action. | |
| 564 | - $( 'body' ).trigger( 'visualizer:change:action' ); | |
| 565 | - | |
| 566 | - if ( '' !== $( this ).val() ) { | |
| 567 | - $( '#woo-chart-button, #woo-chart-save-button' ).removeAttr( 'disabled' ); | |
| 568 | - } else { | |
| 569 | - $( '#woo-chart-button, #woo-chart-save-button' ).attr( 'disabled', true ); | |
| 570 | - } | |
| 571 | - } ); | |
| 572 | 543 | |
| 573 | 544 | } |
| 574 | 545 | |
| 575 | 546 | function init_editor_table() { |