Skip to content

Commit f553d28

Browse files
Remove error when updating other settings Codeinwp/visualizer-pro#51
1 parent dbbbe30 commit f553d28

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

js/preview.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,21 @@
2525
vizSettingsHaveChanged(false);
2626
};
2727

28+
// Update google chart filter control.
29+
window.vizUpdateFilterControl = function() {
30+
$( '#control_wrapper_canvas' ).removeClass( 'no-filter' );
31+
var controlsOpt = $( '.vz-controls-opt' ).map(
32+
function() {
33+
var val = $(this).val();
34+
return '' !== val && 'false' !== val ? val : false ;
35+
}
36+
).get();
37+
controlsOpt = controlsOpt.filter( function(el) { return el; } );
38+
if ( controlsOpt.length === 0 ) {
39+
$( '#control_wrapper_canvas' ).addClass( 'no-filter' ).html('');
40+
}
41+
}
42+
2843
$('#settings-button').click(function() {
2944
$('#settings-form').submit();
3045
});
@@ -42,6 +57,7 @@
4257
// this portion captures if the settings have changed so that tabs can handle that information.
4358

4459
function updateChart() {
60+
vizUpdateFilterControl();
4561
clearTimeout(timeout);
4662
timeout = setTimeout(function() {
4763
var settings = $('#settings-form').serializeObject();
@@ -72,19 +88,6 @@
7288
});
7389
$('textarea[name="manual"]').change(validateJSON).keyup(validateJSON);
7490

75-
$( document ).on( 'change', '.vz-controls-opt', function() {
76-
$( '#control_wrapper_canvas' ).removeClass( 'no-filter' );
77-
var controlsOpt = $( '.vz-controls-opt' ).map(
78-
function() {
79-
var val = $(this).val();
80-
return '' !== val && 'false' !== val ? val : false ;
81-
}
82-
).get();
83-
controlsOpt = controlsOpt.filter( function(el) { return el; } );
84-
if ( controlsOpt.length === 0 ) {
85-
$( '#control_wrapper_canvas' ).addClass( 'no-filter' ).html('');
86-
}
87-
} );
8891
});
8992
})(jQuery, visualizer);
9093

0 commit comments

Comments
 (0)