Skip to content

Commit 744d467

Browse files
Chart source options #41
1 parent 02142f4 commit 744d467

File tree

6 files changed

+105
-105
lines changed

6 files changed

+105
-105
lines changed

classes/Visualizer/Module/Chart.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,6 @@ private function _handleDataPage() {
329329
wp_enqueue_script( 'visualizer-render' );
330330
wp_localize_script( 'visualizer-render', 'visualizer', array(
331331
'l10n' => array(
332-
'remotecsv_prompt' => esc_html__( 'Please, enter the URL of CSV file:', 'visualizer' ),
333332
'invalid_source' => esc_html__( 'You have entered invalid URL. Please, insert proper URL.', 'visualizer' ),
334333
),
335334
'charts' => array(
@@ -393,7 +392,6 @@ private function _handleDataAndSettingsPage() {
393392
wp_enqueue_script( 'visualizer-render' );
394393
wp_localize_script( 'visualizer-render', 'visualizer', array(
395394
'l10n' => array(
396-
'remotecsv_prompt' => esc_html__( 'Please, enter the URL of CSV file:', 'visualizer' ),
397395
'invalid_source' => esc_html__( 'You have entered invalid URL. Please, insert proper URL.', 'visualizer' ),
398396
),
399397
'charts' => array(

classes/Visualizer/Render/Page.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ protected function _renderContent() {}
6464
*/
6565
protected function _renderSidebar() {
6666
echo '<div id="sidebar">';
67-
echo '<ul class="group-wrapper">';
6867
$this->_renderSidebarContent();
69-
echo '</ul>';
7068

7169
echo '<div id="rate-the-plugin">';
7270
echo '<div><b>', esc_html__( 'Like the plugin? Show us your love!', 'visualizer' ), '</b></div>';

classes/Visualizer/Render/Page/Data.php

Lines changed: 60 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -63,64 +63,68 @@ protected function _renderSidebarContent() {
6363
'chart' => $this->chart->ID,
6464
), admin_url( 'admin-ajax.php' ) );
6565

66-
echo '<ul class="group-wrapper">';
67-
echo '<li class="group">';
68-
echo '<h2 class="group-title main-group">' . __( 'Chart Source', 'visualizer' ) . '</h2>';
69-
echo '<ul class="group-content">';
70-
echo '<iframe id="thehole" name="thehole"></iframe>';
71-
echo '<p class="group-description">';
72-
esc_html_e( 'Select and upload your data CSV file here. The first row of the CSV file should contain the column headings. The second one should contain series type (string, number, boolean, date, datetime, timeofday).', 'visualizer' );
73-
echo '</p>';
74-
75-
echo '<p class="group-description">';
76-
esc_html_e( 'If you are unsure about how to format your data CSV then please take a look at this sample:', 'visualizer' );
77-
echo ' <a href="', VISUALIZER_ABSURL, 'samples/', $this->type, '.csv" target="_blank">', $this->type, '.csv</a> ';
78-
printf( esc_html__( 'or read how you can add Google spreadsheet in following %1$sarticle%1$s.', 'visualizer' ), '<a href="https://github.com/madpixelslabs/visualizer/wiki/How-can-I-populate-data-from-Google-Spreadsheet%3F" target="_blank">', '</a>' );
79-
echo '</p>';
80-
81-
echo '<form id="csv-form" action="', $upload_link, '" method="post" target="thehole" enctype="multipart/form-data">';
82-
echo '<input type="hidden" id="remote-data" name="remote_data">';
83-
echo '<div class="form-inline">';
84-
echo '<div class="button button-primary file-wrapper computer-btn">';
85-
echo '<input type="file" id="csv-file" class="file" name="local_data">';
86-
esc_attr_e( 'From Computer', 'visualizer' );
87-
echo '</div>';
88-
89-
echo '<a id="remote-file" class="button from-web from-web-btn" href="javascript:;">', esc_html__( 'From Web', 'visualizer' ), '</a>';
90-
// Added by Ash/Upwork
91-
if ( defined( 'Visualizer_Pro' ) ) {
92-
global $Visualizer_Pro;
93-
$Visualizer_Pro->_addFormElements();
94-
} else {
95-
// Added by Ash/Upwork
96-
echo '<div class="just-on-pro"> </div>';
97-
}
98-
echo '</div>';
99-
echo '</form>';
100-
101-
// added by Ash/Upwork
102-
if ( defined( 'Visualizer_Pro' ) ) {
103-
global $Visualizer_Pro;
104-
$Visualizer_Pro->_addEditorElements();
105-
} else {
10666
?>
107-
<a href="<?php echo Visualizer_Plugin::PRO_TEASER_URL;?>" title="<?php echo Visualizer_Plugin::PRO_TEASER_TITLE;?>" class="check-pro-btn" target="_new">
108-
<input type="button" class="button preview preview-btn" id="existing-chart-free" value="<?php esc_attr_e( 'Check PRO Version ', 'visualizer' );?>">
109-
</a>
67+
<iframe id="thehole" name="thehole"></iframe>
68+
<ul class="group-wrapper">
69+
<li class="group">
70+
<h2 class="group-title main-group"><?php _e( 'Chart Source', 'visualizer' );?></h2>
71+
<ul class="group-content">
72+
<ul class="group-wrapper">
73+
<li class="group">
74+
<h2 class="group-title sub-group visualizer-src-tab"><?php _e( 'Create Chart From File', 'visualizer' );?></h2>
75+
<ul class="group-content">
76+
<p class="group-description"><?php esc_html_e( 'Select and upload your data CSV file here. The first row of the CSV file should contain the column headings. The second one should contain series type (string, number, boolean, date, datetime, timeofday).', 'visualizer' );?></p>
77+
<p class="group-description"><?php _e( sprintf( __( 'If you are unsure about how to format your data CSV then please take a look at this sample: %1$s or read how you can add Google spreadsheet in following %1$sarticle%1$s', 'visualizer' ), '<a href="' . VISUALIZER_ABSURL . 'samples/' . $this->type . '.csv" target="_blank">' . $this->type . '.csv</a>', '<a href="https://github.com/madpixelslabs/visualizer/wiki/How-can-I-populate-data-from-Google-Spreadsheet%3F" target="_blank">', '</a>' ) );?></p>
78+
<form id="csv-file-form" action="<?php echo $upload_link?>" method="post" target="thehole" enctype="multipart/form-data">
79+
<input type="hidden" id="remote-data" name="remote_data">
80+
<div class="">
81+
<input type="file" id="csv-file" name="local_data">
82+
<?php esc_attr_e( 'From Computer', 'visualizer' );?>
83+
</div>
84+
<input type="button" class="view-csv-file" value="<?php _e( 'View', 'visualizer' );?>">
85+
</form>
86+
</ul>
87+
</li>
88+
<li class="group">
89+
<h2 class="group-title sub-group visualizer-src-tab"><?php _e( 'Create Chart From URL', 'visualizer' );?></h2>
90+
<ul class="group-content">
91+
<form id="remote-file-form" action="<?php echo $upload_link?>" method="post" target="thehole" enctype="multipart/form-data">
92+
<div class="remote-file-section">
93+
<input type="url" id="remote-data" name="remote_data" placeholder="<?php esc_html_e( 'Please enter the URL of CSV file:', 'visualizer' );?>">
94+
<div class="<?php echo defined( 'Visualizer_Pro' ) ? '' : 'just-on-pro'?>"><?php _e( 'Synchronize each hour', 'visualizer' );?><input type="checkbox" id="remote-sync" name="remote-sync" value="1"></div>
95+
</div>
96+
<input type="button" class="view-remote-file" value="<?php _e( 'View', 'visualizer' );?>">
97+
</form>
98+
</ul>
99+
</li>
100+
<li class="group">
101+
<h2 class="group-title sub-group visualizer-editor-tab" data-current="chart"><?php _e( 'Add data from editor', 'visualizer' );?></h2>
102+
<ul class="group-content">
103+
<?php
104+
if ( defined( 'Visualizer_Pro' ) ) {
105+
global $Visualizer_Pro;
106+
$Visualizer_Pro->_addFormElements( $upload_link );
107+
} else {
108+
// Added by Ash/Upwork
109+
echo '<div class="just-on-pro"> </div>';
110+
}
111+
?>
112+
</ul>
113+
</li>
114+
</ul>
115+
</li>
116+
</ul>
117+
<ul class="group-wrapper">
118+
<li class="group">
119+
<h2 class="group-title main-group"><?php _e( 'Chart Settings', 'visualizer' );?></h2>
120+
<ul class="group-content">
121+
<form id="settings-form" action="<?php echo add_query_arg( 'nonce', wp_create_nonce() );?>" method="post">
122+
<?php echo $this->sidebar;?>
123+
</form>
124+
</ul>
125+
</li>
126+
</ul>
110127
<?php
111-
}
112-
113-
echo '</ul></li>';
114-
115-
echo '<ul class="group-wrapper">';
116-
echo '<li class="group">';
117-
echo '<h2 class="group-title main-group">' . __( 'Chart Settings', 'visualizer' ) . '</h2>';
118-
echo '<ul class="group-content">';
119-
echo '<form id="settings-form" action="', add_query_arg( 'nonce', wp_create_nonce() ), '" method="post">';
120-
echo $this->sidebar;
121-
echo '</form>';
122-
echo '</ul></li>';
123-
echo '</ul>';
124128
// changed by Ash/Upwork
125129
}
126130

css/frame.css

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
}
8888

8989
.group-title:hover,
90-
.group.open .group-title {
90+
.group.open > .group-title {
9191
color: white;
9292
background: gray;
9393
background-image: -webkit-gradient(linear, left bottom, left top, from(#6d6d6d), to(gray));
@@ -114,19 +114,19 @@
114114
}
115115

116116
.group-title:hover::after,
117-
.group.open .group-title::after {
117+
.group.open > .group-title::after {
118118
border-color: #eee transparent;
119119
}
120120

121121
.group:hover .group-title {
122122
border-top-color: gray;
123123
}
124124

125-
.group.open .group-title {
125+
.group.open > .group-title {
126126
border-top-color: #6d6d6d;
127127
}
128128

129-
.group.open .group-title::after {
129+
.group.open > .group-title::after {
130130
border-width: 0 6px 6px;
131131
}
132132

@@ -142,7 +142,7 @@ div.group-content {
142142
padding: 10px 20px 20px;
143143
}
144144

145-
.group.open .group-content {
145+
.group.open > .group-content {
146146
display: block;
147147
}
148148

js/frame.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,33 @@
1515
if (parent.hasClass('open')) {
1616
parent.removeClass('open');
1717
} else {
18-
$('.group.open').removeClass('open');
18+
parent.parent().find('.group.open').removeClass('open');
1919
parent.addClass('open');
2020
}
2121
});
2222

23-
$('#remote-file').click(function() {
24-
var url = $.trim(prompt(visualizer.l10n.remotecsv_prompt));
23+
$('.view-remote-file').click(function() {
24+
var url = $(this).parent().find('#remote-data').val();
2525

2626
if (url !== '') {
2727
if (/^([a-z]([a-z]|\d|\+|-|\.)*):(\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?((\[(|(v[\da-f]{1,}\.(([a-z]|\d|-|\.|_|~)|[!\$&'\(\)\*\+,;=]|:)+))\])|((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=])*)(:\d*)?)(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*|(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)){0})(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(url)) {
2828
if (url.substr(url.length - 8) === '/pubhtml') {
2929
url = url.substring(0, url.length - 8) + '/export?format=csv';
3030
}
3131

32-
$('#remote-data').val(url);
33-
$('#csv-file').val('');
3432
$('#canvas').lock();
35-
$('#csv-form').submit();
33+
$(this).parent().submit();
3634
} else {
3735
alert(visualizer.l10n.invalid_source);
3836
}
3937
}
4038
});
4139

42-
$('#csv-file').change(function() {
43-
if ($.trim($(this).val()) !== '') {
44-
$('#remote-data').val('');
40+
$('.view-csv-file').click(function(e) {
41+
e.preventDefault();
42+
if ($.trim($(this).parent().find("#csv-file").val()) !== '') {
4543
$('#canvas').lock();
46-
$('#csv-form').submit();
44+
$(this).parent().submit();
4745
}
4846
});
4947

languages/visualizer.pot

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ msgid ""
44
msgstr ""
55
"Project-Id-Version: Visualizer: Charts and Graphs Lite 1.7.6\n"
66
"Report-Msgid-Bugs-To: https://github.com/Codeinwp/visualizer/issues\n"
7-
"POT-Creation-Date: 2017-02-17 13:22:15+00:00\n"
7+
"POT-Creation-Date: 2017-02-23 12:58:23+00:00\n"
88
"MIME-Version: 1.0\n"
99
"Content-Type: text/plain; charset=utf-8\n"
1010
"Content-Transfer-Encoding: 8bit\n"
@@ -102,32 +102,27 @@ msgid "Pro Addon"
102102
msgstr ""
103103

104104
#: classes/Visualizer/Module/Chart.php:332
105-
#: classes/Visualizer/Module/Chart.php:396
106-
msgid "Please, enter the URL of CSV file:"
107-
msgstr ""
108-
109-
#: classes/Visualizer/Module/Chart.php:333
110-
#: classes/Visualizer/Module/Chart.php:397
105+
#: classes/Visualizer/Module/Chart.php:395
111106
msgid "You have entered invalid URL. Please, insert proper URL."
112107
msgstr ""
113108

114-
#: classes/Visualizer/Module/Chart.php:411
109+
#: classes/Visualizer/Module/Chart.php:409
115110
msgid "Save Chart"
116111
msgstr ""
117112

118-
#: classes/Visualizer/Module/Chart.php:412
113+
#: classes/Visualizer/Module/Chart.php:410
119114
msgid "Create Chart"
120115
msgstr ""
121116

122-
#: classes/Visualizer/Module/Chart.php:414
117+
#: classes/Visualizer/Module/Chart.php:412
123118
msgid "Insert Chart"
124119
msgstr ""
125120

126-
#: classes/Visualizer/Module/Chart.php:473
121+
#: classes/Visualizer/Module/Chart.php:471
127122
msgid "CSV file with chart data was not uploaded. Please, try again."
128123
msgstr ""
129124

130-
#: classes/Visualizer/Module/Chart.php:488
125+
#: classes/Visualizer/Module/Chart.php:486
131126
msgid "CSV file is broken or invalid. Please, try again."
132127
msgstr ""
133128

@@ -172,44 +167,51 @@ msgid ""
172167
"its value to 1. This option increases the speed of remote CSV uploading."
173168
msgstr ""
174169

175-
#: classes/Visualizer/Render/Page/Data.php:68
170+
#: classes/Visualizer/Render/Page/Data.php:70
176171
msgid "Chart Source"
177172
msgstr ""
178173

179-
#: classes/Visualizer/Render/Page/Data.php:72
174+
#: classes/Visualizer/Render/Page/Data.php:74
175+
msgid "Create Chart From File"
176+
msgstr ""
177+
178+
#: classes/Visualizer/Render/Page/Data.php:76
180179
msgid ""
181180
"Select and upload your data CSV file here. The first row of the CSV file "
182181
"should contain the column headings. The second one should contain series "
183182
"type (string, number, boolean, date, datetime, timeofday)."
184183
msgstr ""
185184

186-
#: classes/Visualizer/Render/Page/Data.php:76
187-
msgid ""
188-
"If you are unsure about how to format your data CSV then please take a look "
189-
"at this sample:"
185+
#: classes/Visualizer/Render/Page/Data.php:82
186+
msgid "From Computer"
190187
msgstr ""
191188

192-
#: classes/Visualizer/Render/Page/Data.php:78
193-
msgid "or read how you can add Google spreadsheet in following %1$sarticle%1$s."
189+
#: classes/Visualizer/Render/Page/Data.php:84
190+
#: classes/Visualizer/Render/Page/Data.php:96
191+
msgid "View"
194192
msgstr ""
195193

196-
#: classes/Visualizer/Render/Page/Data.php:86
197-
msgid "From Computer"
194+
#: classes/Visualizer/Render/Page/Data.php:89
195+
msgid "Create Chart From URL"
198196
msgstr ""
199197

200-
#: classes/Visualizer/Render/Page/Data.php:89
201-
msgid "From Web"
198+
#: classes/Visualizer/Render/Page/Data.php:93
199+
msgid "Please enter the URL of CSV file:"
200+
msgstr ""
201+
202+
#: classes/Visualizer/Render/Page/Data.php:94
203+
msgid "Synchronize each hour"
202204
msgstr ""
203205

204-
#: classes/Visualizer/Render/Page/Data.php:108
205-
msgid "Check PRO Version "
206+
#: classes/Visualizer/Render/Page/Data.php:101
207+
msgid "Add data from editor"
206208
msgstr ""
207209

208-
#: classes/Visualizer/Render/Page/Data.php:117
210+
#: classes/Visualizer/Render/Page/Data.php:119
209211
msgid "Chart Settings"
210212
msgstr ""
211213

212-
#: classes/Visualizer/Render/Page/Data.php:138
214+
#: classes/Visualizer/Render/Page/Data.php:142
213215
#: classes/Visualizer/Render/Page/Settings.php:55
214216
msgid "Back"
215217
msgstr ""
@@ -222,11 +224,11 @@ msgstr ""
222224
msgid "Next"
223225
msgstr ""
224226

225-
#: classes/Visualizer/Render/Page.php:72
227+
#: classes/Visualizer/Render/Page.php:70
226228
msgid "Like the plugin? Show us your love!"
227229
msgstr ""
228230

229-
#: classes/Visualizer/Render/Page.php:75
231+
#: classes/Visualizer/Render/Page.php:73
230232
msgid "Rate it on WordPress.org"
231233
msgstr ""
232234

0 commit comments

Comments
 (0)