File tree Expand file tree Collapse file tree 4 files changed +68
-4
lines changed Expand file tree Collapse file tree 4 files changed +68
-4
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,34 @@ public function __construct( Visualizer_Plugin $plugin ) {
69
69
70
70
$ this ->_addAjaxAction ( Visualizer_Plugin::ACTION_SAVE_FILTER_QUERY , 'saveFilter ' );
71
71
72
+ $ this ->_addFilter ( 'visualizer_get_sidebar ' , 'getSidebar ' , 10 , 2 );
73
+
74
+ }
75
+
76
+ /**
77
+ * Generates the HTML of the sidebar for the chart.
78
+ *
79
+ * @since ?
80
+ *
81
+ * @access public
82
+ */
83
+ public function getSidebar ( $ sidebar , $ chart_id ) {
84
+ $ chart = get_post ( $ chart_id );
85
+ $ data = $ this ->_getChartArray ( $ chart );
86
+ $ sidebar = '' ;
87
+ $ sidebar_class = $ this ->load_chart_class_name ( $ chart_id );
88
+ if ( class_exists ( $ sidebar_class , true ) ) {
89
+ $ sidebar = new $ sidebar_class ( $ data ['settings ' ] );
90
+ $ sidebar ->__series = $ data ['series ' ];
91
+ $ sidebar ->__data = $ data ['data ' ];
92
+ } else {
93
+ $ sidebar = apply_filters ( 'visualizer_pro_chart_type_sidebar ' , '' , $ data );
94
+ if ( $ sidebar !== '' ) {
95
+ $ sidebar ->__series = $ data ['series ' ];
96
+ $ sidebar ->__data = $ data ['data ' ];
97
+ }
98
+ }
99
+ return str_replace ( "' " , '" ' , $ sidebar ->__toString () );
72
100
}
73
101
74
102
/**
Original file line number Diff line number Diff line change @@ -52,6 +52,9 @@ protected function _toHTML() {
52
52
echo 'win.visualizer.charts.canvas.settings = ' , $ this ->settings , '; ' ;
53
53
}
54
54
echo 'win.visualizer.update(); ' ;
55
+
56
+ echo $ this ->updateEditorAndSettings ();
57
+
55
58
echo '} ' ;
56
59
57
60
do_action ( 'visualizer_add_update_hook ' , $ this ->series , $ this ->data );
@@ -70,4 +73,21 @@ protected function _toHTML() {
70
73
echo '</html> ' ;
71
74
}
72
75
76
+
77
+ /**
78
+ * Update the hidden content in the LHS and the advanced settings
79
+ */
80
+ private function updateEditorAndSettings () {
81
+ $ editor = '' ;
82
+ if ( Visualizer_Module::can_show_feature ( 'simple-editor ' ) ) {
83
+ ob_start ();
84
+ Visualizer_Render_Layout::show ( 'simple-editor-screen ' , $ this ->id );
85
+ $ editor = ob_get_clean ();
86
+ }
87
+
88
+ $ sidebar = apply_filters ( 'visualizer_get_sidebar ' , '' , $ this ->id );
89
+
90
+ return 'win.updateHTML( \'' . json_encode ( $ editor ) . '\', \'' . json_encode ( $ sidebar ) . '\'); ' ;
91
+ }
92
+
73
93
}
Original file line number Diff line number Diff line change 69
69
} ) ;
70
70
71
71
// collapse other open sections of this group
72
- $ ( ' .viz-group-title') . click ( function ( ) {
72
+ $ ( document ) . on ( 'click' , ' .viz-group-title', function ( ) {
73
73
var parent = $ ( this ) . parent ( ) ;
74
74
75
75
if ( parent . hasClass ( 'open' ) ) {
89
89
} ) ;
90
90
91
91
// collapse other open subsections of this section
92
- $ ( ' .viz-section-title') . click ( function ( ) {
92
+ $ ( document ) . on ( 'click' , ' .viz-section-title', function ( ) {
93
93
var grandparent = $ ( this ) . parent ( ) . parent ( ) ;
94
94
grandparent . find ( '.viz-section-title.open ~ .viz-section-items' ) . hide ( ) ;
95
95
grandparent . find ( '.viz-section-title.open' ) . removeClass ( 'open' ) ;
124
124
$ ( '#canvas' ) . unlock ( ) ;
125
125
} ) ;
126
126
127
- $ ( ' .viz-section-title') . click ( function ( ) {
127
+ $ ( document ) . on ( 'click' , ' .viz-section-title', function ( ) {
128
128
$ ( this ) . toggleClass ( 'open' ) . parent ( ) . find ( '.viz-section-items' ) . toggle ( ) ;
129
129
} ) ;
130
130
131
- $ ( ' .more-info') . click ( function ( ) {
131
+ $ ( document ) . on ( 'click' , ' .more-info', function ( ) {
132
132
$ ( this ) . parent ( ) . find ( '.viz-section-description:first' ) . toggle ( ) ;
133
133
return false ;
134
134
} ) ;
Original file line number Diff line number Diff line change 4
4
var timeout ;
5
5
6
6
$ ( document ) . ready ( function ( ) {
7
+ // when data is impported using csv/url, update the hidden data and the advanced settings sidebar.
8
+ window . updateHTML = function ( editor , sidebar ) {
9
+ $ ( '.viz-simple-editor' ) . remove ( ) ;
10
+ $ ( '#content' ) . append ( editor ) ;
11
+ $ ( '#settings-form .viz-group' ) . remove ( ) ;
12
+ $ ( '#settings-form' ) . append ( sidebar ) ;
13
+
14
+ $ ( '#settings-form .control-text' ) . change ( updateChart ) . keyup ( updateChart ) ;
15
+ $ ( '#settings-form .control-select, #settings-form .control-checkbox, #settings-form .control-check' ) . change ( updateChart ) ;
16
+ $ ( '#settings-form .color-picker-hex' ) . wpColorPicker ( {
17
+ change : updateChart ,
18
+ clear : updateChart
19
+ } ) ;
20
+ $ ( '#settings-form textarea[name="manual"]' ) . change ( validateJSON ) . keyup ( validateJSON ) ;
21
+ } ;
22
+
7
23
$ ( '#settings-button' ) . click ( function ( ) {
8
24
$ ( '#settings-form' ) . submit ( ) ;
9
25
} ) ;
You can’t perform that action at this time.
0 commit comments