Skip to content

Commit e379b63

Browse files
Fix javascript error in library page Codeinwp/visualizer-pro#51
1 parent 786d34f commit e379b63

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

classes/Visualizer/Render/Library.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,20 @@ private function _renderLibrary() {
233233
foreach ( $this->charts as $placeholder_id => $chart ) {
234234
// show the sidebar after the first 3 charts.
235235
$count++;
236+
$enable_controls = false;
237+
$settings = isset( $chart['settings'] ) ? $chart['settings'] : array();
238+
if ( ! empty( $settings['controls']['controlType'] ) ) {
239+
$column_index = $settings['controls']['filterColumnIndex'];
240+
$column_label = $settings['controls']['filterColumnLabel'];
241+
if ( 'false' !== $column_index || 'false' !== $column_label ) {
242+
$enable_controls = true;
243+
}
244+
}
236245
if ( 3 === $count ) {
237246
$this->_renderSidebar();
238-
$this->_renderChartBox( $placeholder_id, $chart['id'] );
247+
$this->_renderChartBox( $placeholder_id, $chart['id'], $enable_controls );
239248
} else {
240-
$this->_renderChartBox( $placeholder_id, $chart['id'] );
249+
$this->_renderChartBox( $placeholder_id, $chart['id'], $enable_controls );
241250
}
242251
}
243252
// show the sidebar if there are less than 3 charts.
@@ -282,7 +291,7 @@ private function _renderLibrary() {
282291
* @param string $placeholder_id The placeholder's id for the chart.
283292
* @param int $chart_id The id of the chart.
284293
*/
285-
private function _renderChartBox( $placeholder_id, $chart_id ) {
294+
private function _renderChartBox( $placeholder_id, $chart_id, $with_filter = false ) {
286295
$settings = get_post_meta( $chart_id, Visualizer_Plugin::CF_SETTINGS );
287296
$title = '#' . $chart_id;
288297
if ( ! empty( $settings[0]['title'] ) ) {
@@ -336,14 +345,14 @@ private function _renderChartBox( $placeholder_id, $chart_id ) {
336345
}
337346
$shortcode = sprintf( '[visualizer id="%s" lazy="no" class=""]', $chart_id );
338347
echo '<div class="items"><div class="visualizer-chart"><div class="visualizer-chart-title">', esc_html( $title ), '</div>';
339-
if ( Visualizer_Module::is_pro() ) {
348+
if ( Visualizer_Module::is_pro() && $with_filter ) {
340349
echo '<div id="chart_wrapper_' . $placeholder_id . '">';
341350
echo '<div id="control_wrapper_' . $placeholder_id . '" class="vz-library-chart-filter"></div>';
342351
}
343352
echo '<div id="', $placeholder_id, '" class="visualizer-chart-canvas">';
344353
echo '<img src="', VISUALIZER_ABSURL, 'images/ajax-loader.gif" class="loader">';
345354
echo '</div>';
346-
if ( Visualizer_Module::is_pro() ) {
355+
if ( Visualizer_Module::is_pro() && $with_filter ) {
347356
echo '</div>';
348357
}
349358
echo '<div class="visualizer-chart-footer visualizer-clearfix">';

css/library.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,8 @@ div#visualizer-types ul, div#visualizer-types form p {
432432
padding: 5px 0 5px 5px;
433433
border: 1px solid #ddd;
434434
}
435-
.google-visualization-controls-rangefilter-thumblabel {
436-
padding: 0 !important;
435+
.google-visualization-controls-rangefilter {
436+
white-space: inherit !important;
437437
}
438438
@media (-webkit-min-device-pixel-ratio: 2) and (min-width: 1000px) and (max-width: 1600px) {
439439
#visualizer-sidebar.one-columns .visualizer-sidebar-box ul li:nth-child(+n+7) {

js/render-google.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ var chartWrapperError = [];
7777

7878
var controlWrapperElement = document.getElementById( "control_wrapper_" + id ) || null;
7979
var withControlMode = typeof settings.controls !== 'undefined' && controlWrapperElement ? true : false;
80-
80+
console.log( settings.controls );
8181
if ( $( controlWrapperElement ).hasClass( 'no-filter' ) ) {
8282
withControlMode = false;
8383
}

0 commit comments

Comments
 (0)