| @@ -7,107 +7,82 @@ | ||
| 7 | 7 | initTable(); |
| 8 | 8 | }); |
| 9 | 9 | |
| 10 | 10 | function onReady() { |
| 11 | - $( '#editor-button' ).on( 'click', function(e){ | |
| 12 | - switch($("#viz-editor-type").val()) { | |
| 13 | - case 'text': | |
| 14 | - showTextEditor($(this)); | |
| 15 | - break; | |
| 16 | - case 'table': | |
| 17 | - showTableEditor($(this)); | |
| 18 | - break; | |
| 19 | - default: | |
| 20 | - $('body').trigger('visualizer:chart:edit'); | |
| 11 | + $( '#editor-chart-button' ).on( 'click', function(){ | |
| 12 | + $('.viz-simple-editor-type').hide(); | |
| 13 | + if($("#simple-editor-type").is(':checked')){ | |
| 14 | + switch($("#simple-editor-type").val()) { | |
| 15 | + case 'textarea': | |
| 16 | + showText($(this)); | |
| 17 | + break; | |
| 18 | + } | |
| 19 | + } else { | |
| 20 | + showTable($(this)); | |
| 21 | 21 | } |
| 22 | 22 | }); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - function showTextEditor(button) { | |
| 25 | + function showText(button) { | |
| 26 | 26 | if( button.attr( 'data-current' ) === 'chart'){ |
| 27 | - | |
| 28 | - $('body').off('visualizer:change:action').on('visualizer:change:action', function(e){ | |
| 29 | - button.val( button.attr( 'data-t-chart' ) ); | |
| 30 | - button.html( button.attr( 'data-t-chart' ) ); | |
| 31 | - button.attr( 'data-current', 'chart' ); | |
| 32 | - $('p.viz-editor-selection').show(); | |
| 33 | - $('p.viz-info-msg').hide(); | |
| 34 | - $('.viz-text-editor').hide(); | |
| 35 | - $('.viz-simple-editor').hide(); | |
| 36 | - $( '#canvas' ).css('z-index', '1').show(); | |
| 37 | - }); | |
| 38 | - | |
| 39 | - // showing the editor | |
| 40 | 27 | button.val( button.attr( 'data-t-editor' ) ); |
| 41 | 28 | button.html( button.attr( 'data-t-editor' ) ); |
| 42 | 29 | button.attr( 'data-current', 'editor' ); |
| 43 | - $('p.viz-editor-selection').hide(); | |
| 44 | - $('p.viz-info-msg').show(); | |
| 45 | - $('.viz-text-editor').css('z-index', '9999').show(); | |
| 46 | - $('.viz-simple-editor').css('z-index', '9999').show(); | |
| 47 | - $( '#canvas' ).css('z-index', '-100').hide(); | |
| 30 | + $('p.simple-editor-type').hide(); | |
| 31 | + $( '.viz-text-editor' ).css("z-index", "9999").show(); | |
| 32 | + $( '#canvas' ).css("z-index", "-100").hide(); | |
| 33 | + $('.viz-simple-editor').css("z-index", "9999").show(); | |
| 48 | 34 | }else{ |
| 49 | - // showing the chart | |
| 50 | - $('#chart-data').val($('#edited_text').val()); | |
| 51 | - $('#canvas').lock(); | |
| 52 | - $('#editor-form').submit(); | |
| 53 | - | |
| 54 | 35 | button.val( button.attr( 'data-t-chart' ) ); |
| 55 | 36 | button.html( button.attr( 'data-t-chart' ) ); |
| 56 | 37 | button.attr( 'data-current', 'chart' ); |
| 57 | - $('p.viz-editor-selection').show(); | |
| 58 | - $('p.viz-info-msg').hide(); | |
| 59 | - $('.viz-text-editor').hide(); | |
| 38 | + $( '.viz-text-editor' ).hide(); | |
| 39 | + $('p.simple-editor-type').show(); | |
| 40 | + $( '#canvas' ).css("z-index", "1").show(); | |
| 60 | 41 | $('.viz-simple-editor').hide(); |
| 61 | - $( '#canvas' ).css('z-index', '1').show(); | |
| 62 | 42 | } |
| 43 | + | |
| 44 | + $( '#viz-text-editor-button').on('click', function(e){ | |
| 45 | + $( '#editor-chart-button' ).attr("disabled", "disabled"); | |
| 46 | + $('#chart-data').val($('#edited_text').val()); | |
| 47 | + $('#canvas').lock(); | |
| 48 | + $('#editor-form').submit(); | |
| 49 | + $( '#editor-chart-button' ).removeAttr("disabled"); | |
| 50 | + $( '#editor-chart-button' ).trigger('click'); | |
| 51 | + }); | |
| 63 | 52 | } |
| 64 | 53 | |
| 65 | 54 | function initTable() { |
| 66 | 55 | setTimeout(function(){ |
| 67 | - $('body').trigger('visualizer:db:editor:table:init', {config: { buttons: [] } }); | |
| 56 | + $('body').trigger('visualizer:db:editor:table:init', {}); | |
| 68 | 57 | $( '#canvas' ).unlock(); |
| 69 | 58 | }, 1000); |
| 59 | + | |
| 60 | + // when the data is set and the chart is updated, toggle the screen so that the chart is shown | |
| 61 | + $('#table-editor-form').on( 'submit', function(e){ | |
| 62 | + $( '#editor-chart-button' ).trigger('click'); | |
| 63 | + $('#canvas').lock(); | |
| 64 | + }); | |
| 70 | 65 | } |
| 71 | 66 | |
| 72 | - function showTableEditor(button) { | |
| 67 | + function showTable(button) { | |
| 73 | 68 | if( button.attr( 'data-current' ) === 'chart'){ |
| 74 | - | |
| 75 | - $('body').off('visualizer:change:action').on('visualizer:change:action', function(e){ | |
| 76 | - button.val( button.attr( 'data-t-chart' ) ); | |
| 77 | - button.html( button.attr( 'data-t-chart' ) ); | |
| 78 | - button.attr( 'data-current', 'chart' ); | |
| 79 | - $('p.viz-editor-selection').show(); | |
| 80 | - $('p.viz-info-msg').hide(); | |
| 81 | - $('.viz-table-editor').hide(); | |
| 82 | - $('.viz-simple-editor').hide(); | |
| 83 | - $( '#canvas' ).css('z-index', '1').show(); | |
| 84 | - }); | |
| 85 | - | |
| 86 | - // showing the editor | |
| 87 | 69 | button.val( button.attr( 'data-t-editor' ) ); |
| 88 | 70 | button.html( button.attr( 'data-t-editor' ) ); |
| 89 | 71 | button.attr( 'data-current', 'editor' ); |
| 90 | - $('p.viz-editor-selection').hide(); | |
| 91 | - $('p.viz-info-msg').show(); | |
| 92 | 72 | $( '.viz-table-editor' ).css("z-index", "9999").show(); |
| 93 | - $('.viz-simple-editor').css('z-index', '9999').show(); | |
| 94 | 73 | $('body').trigger('visualizer:db:editor:table:redraw', {}); |
| 95 | 74 | $( '#canvas' ).css("z-index", "-100").hide(); |
| 75 | + $('p.simple-editor-type').hide(); | |
| 76 | + $('.viz-simple-editor').css("z-index", "9999").show(); | |
| 96 | 77 | }else{ |
| 97 | - $('#canvas').lock(); | |
| 98 | - jQuery('.dataTables_scrollBody .sorting_disabled input').attr('disabled', true); | |
| 99 | - $('#table-editor-form').submit(); | |
| 100 | - | |
| 101 | - // showing the chart | |
| 102 | 78 | button.val( button.attr( 'data-t-chart' ) ); |
| 103 | 79 | button.html( button.attr( 'data-t-chart' ) ); |
| 104 | 80 | button.attr( 'data-current', 'chart' ); |
| 105 | - $('p.viz-editor-selection').show(); | |
| 106 | - $('p.viz-info-msg').hide(); | |
| 107 | - $('.viz-table-editor').hide(); | |
| 81 | + $( '.viz-table-editor' ).hide(); | |
| 82 | + $( '#canvas' ).css("z-index", "1").show(); | |
| 108 | 83 | $('.viz-simple-editor').hide(); |
| 109 | - $( '#canvas' ).css('z-index', '1').show(); | |
| 84 | + $('p.simple-editor-type').show(); | |
| 110 | 85 | } |
| 111 | 86 | } |
| 112 | 87 | |
| 113 | 88 | })(jQuery, visualizer1); |