-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathsimple-editor.js
More file actions
113 lines (100 loc) · 4.27 KB
/
Copy pathsimple-editor.js
File metadata and controls
113 lines (100 loc) · 4.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/* global visualizer1 */
(function($, v) {
$(document).ready(function(){
onReady();
initTable();
});
function onReady() {
$( '#editor-button' ).on( 'click', function(e){
switch($("#viz-editor-type").val()) {
case 'text':
showTextEditor($(this));
break;
case 'table':
showTableEditor($(this));
break;
default:
$('body').trigger('visualizer:chart:edit');
}
});
}
function showTextEditor(button) {
if( button.attr( 'data-current' ) === 'chart'){
$('body').off('visualizer:change:action').on('visualizer:change:action', function(e){
button.val( button.attr( 'data-t-chart' ) );
button.html( button.attr( 'data-t-chart' ) );
button.attr( 'data-current', 'chart' );
$('p.viz-editor-selection').show();
$('p.viz-info-msg').hide();
$('.viz-text-editor').hide();
$('.viz-simple-editor').hide();
$( '#canvas' ).css('z-index', '1').show();
});
// showing the editor
button.val( button.attr( 'data-t-editor' ) );
button.html( button.attr( 'data-t-editor' ) );
button.attr( 'data-current', 'editor' );
$('p.viz-editor-selection').hide();
$('p.viz-info-msg').show();
$('.viz-text-editor').css('z-index', '9999').show();
$('.viz-simple-editor').css('z-index', '9999').show();
$( '#canvas' ).css('z-index', '-100').hide();
}else{
// showing the chart
$('#chart-data').val($('#edited_text').val());
$('#canvas').lock();
$('#editor-form').submit();
button.val( button.attr( 'data-t-chart' ) );
button.html( button.attr( 'data-t-chart' ) );
button.attr( 'data-current', 'chart' );
$('p.viz-editor-selection').show();
$('p.viz-info-msg').hide();
$('.viz-text-editor').hide();
$('.viz-simple-editor').hide();
$( '#canvas' ).css('z-index', '1').show();
}
}
function initTable() {
setTimeout(function(){
$('body').trigger('visualizer:db:editor:table:init', {config: { buttons: [] } });
$( '#canvas' ).unlock();
}, 1000);
}
function showTableEditor(button) {
if( button.attr( 'data-current' ) === 'chart'){
$('body').off('visualizer:change:action').on('visualizer:change:action', function(e){
button.val( button.attr( 'data-t-chart' ) );
button.html( button.attr( 'data-t-chart' ) );
button.attr( 'data-current', 'chart' );
$('p.viz-editor-selection').show();
$('p.viz-info-msg').hide();
$('.viz-table-editor').hide();
$('.viz-simple-editor').hide();
$( '#canvas' ).css('z-index', '1').show();
});
// showing the editor
button.val( button.attr( 'data-t-editor' ) );
button.html( button.attr( 'data-t-editor' ) );
button.attr( 'data-current', 'editor' );
$('p.viz-editor-selection').hide();
$('p.viz-info-msg').show();
$( '.viz-table-editor' ).css("z-index", "9999").show();
$('.viz-simple-editor').css('z-index', '9999').show();
$('body').trigger('visualizer:db:editor:table:redraw', {});
$( '#canvas' ).css("z-index", "-100").hide();
}else{
$('#canvas').lock();
jQuery('.dataTables_scrollBody .sorting_disabled input').attr('disabled', true);
$('#table-editor-form').submit();
// showing the chart
button.val( button.attr( 'data-t-chart' ) );
button.html( button.attr( 'data-t-chart' ) );
button.attr( 'data-current', 'chart' );
$('p.viz-editor-selection').show();
$('p.viz-info-msg').hide();
$('.viz-table-editor').hide();
$('.viz-simple-editor').hide();
$( '#canvas' ).css('z-index', '1').show();
}
}
})(jQuery, visualizer1);