Skip to content

Commit 4ddd631

Browse files
Merge pull request #264 from contactashish13/issue-263
When Add New is used from within a selected chart type tab, that char…
2 parents ffb37c1 + 9f55283 commit 4ddd631

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

classes/Visualizer/Module/Admin.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,7 @@ public function renderLibraryPage() {
535535
array(
536536
'action' => Visualizer_Plugin::ACTION_CREATE_CHART,
537537
'library' => 'yes',
538+
'type' => isset( $_GET['type'] ) ? $_GET['type'] : '',
538539
), $ajaxurl
539540
),
540541
'edit' => add_query_arg(

classes/Visualizer/Module/Chart.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public function renderChartPages() {
209209
// check chart, if chart not exists, will create new one and redirects to the same page with proper chart id
210210
$chart_id = isset( $_GET['chart'] ) ? filter_var( $_GET['chart'], FILTER_VALIDATE_INT ) : '';
211211
if ( ! $chart_id || ! ( $chart = get_post( $chart_id ) ) || $chart->post_type != Visualizer_Plugin::CPT_VISUALIZER ) {
212-
$default_type = 'line';
212+
$default_type = isset( $_GET['type'] ) && ! empty( $_GET['type'] ) ? $_GET['type'] : 'line';
213213
$source = new Visualizer_Source_Csv( VISUALIZER_ABSPATH . DIRECTORY_SEPARATOR . 'samples' . DIRECTORY_SEPARATOR . $default_type . '.csv' );
214214
$source->fetch();
215215
$chart_id = wp_insert_post(

js/frame.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
/* global alert */
44

55
(function ($) {
6+
$(window).load(function(){
7+
// scroll to the selected chart type.
8+
if($('label.type-label.type-label-selected').length > 0) {
9+
$('label.type-label.type-label-selected')[0].scrollIntoView();
10+
}
11+
});
12+
613
$(document).ready(function () {
714
init_permissions();
815

0 commit comments

Comments
 (0)