diff --git a/app/assets/javascripts/editor/editor.js.erb b/app/assets/javascripts/editor/editor.js.erb index ab673983..2a0a8b35 100644 --- a/app/assets/javascripts/editor/editor.js.erb +++ b/app/assets/javascripts/editor/editor.js.erb @@ -35,7 +35,7 @@ var CodeOceanEditor = { lastCopyText: null, autosaveTimer: null, - autosaveLabel: $("#autosave-label span"), + autosaveLabel: "#autosave-label span", ENTER_KEY_CODE: 13, @@ -100,7 +100,8 @@ var CodeOceanEditor = { showOutput: function(event) { event.preventDefault(); - this.showTab(1); + this.showTab(0); + this.showOutputBar(); $('#output').scrollTo($(this).attr('href')); }, @@ -144,10 +145,8 @@ var CodeOceanEditor = { handleKeyPress: function (event) { if (event.which === this.ALT_1_KEY_CODE) { this.showWorkspaceTab(event); - } else if (event.which === this.ALT_2_KEY_CODE) { - this.showTab(1); } else if (event.which === this.ALT_3_KEY_CODE) { - this.showTab(2); + this.showTab(1); } else if (event.which === this.ALT_R_KEY_CODE) { $('#run').trigger('click'); } else if (event.which === this.ALT_S_KEY_CODE) { @@ -190,9 +189,10 @@ var CodeOceanEditor = { autosave: function () { var date = new Date(); - this.autosaveLabel.parent().css("visibility", "visible"); - this.autosaveLabel.text(date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds()); - this.autosaveLabel.text(date.toLocaleTimeString()); + var autosaveLabel = $(this.autosaveLabel); + autosaveLabel.parent().css("visibility", "visible"); + autosaveLabel.text(date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds()); + autosaveLabel.text(date.toLocaleTimeString()); this.autosaveTimer = null; this.createSubmission($('#autosave'), null); }, @@ -270,16 +270,37 @@ var CodeOceanEditor = { var frame = $('[data-file-id="' + active_file.id + '"]').parent(); this.showFrame(frame); this.toggleButtonStates(); - }); + }.bind(this)); }, initializeFileTreeButtons: function () { $('#create-file').on('click', this.showFileDialog.bind(this)); + $('#create-file-collapsed').on('click', this.showFileDialog.bind(this)); $('#destroy-file').on('click', this.confirmDestroy.bind(this)); + $('#destroy-file-collapsed').on('click', this.confirmDestroy.bind(this)); $('#download').on('click', this.downloadCode.bind(this)); + $('#download-collapsed').on('click', this.downloadCode.bind(this)); $('#request-for-comments').on('click', this.requestComments.bind(this)); }, + initializeSideBarCollapse: function() { + $('#sidebar-collapsed').addClass('hidden'); + $('#sidebar-collapse-collapsed').on('click',this.handleSideBarToggle.bind(this)); + $('#sidebar-collapse').on('click',this.handleSideBarToggle.bind(this)) + }, + + handleSideBarToggle: function() { + $('#sidebar').toggleClass('sidebar-col').toggleClass('sidebar-col-collapsed');/** + $('#frames').toggleClass('editor-col') + if (main_area.hasClass('col-sm-10')) { + main_area.removeClass('col-sm-10').addClass('col-sm-11'); + } else if (main_area.hasClass('col-sm-11')) { + main_area.removeClass('col-sm-11').addClass('col-sm-10'); + }*/ + $('#sidebar-collapsed').toggleClass('hidden'); + $('#sidebar-uncollapsed').toggleClass('hidden'); + }, + initializeRegexes: function () { this.regex_for_language.set("ace/mode/python", /File "(.+?)", line (\d+)/g); this.regex_for_language.set("ace/mode/java", /(.*\.java):(\d+):/g); @@ -454,7 +475,8 @@ var CodeOceanEditor = { this.clearOutput(); $('#hint').fadeOut(); $('#flowrHint').fadeOut(); - this.showTab(1); + this.showTab(0); + this.showOutputBar(); }, isActiveFileBinary: function () { @@ -544,6 +566,26 @@ var CodeOceanEditor = { }); }, + initializeOutputBarToggle: function() { + $('#toggle-sidebar-output').on('click',this.hideOutputBar.bind(this)); + $('#toggle-sidebar-output-collapsed').on('click',this.showOutputBar.bind(this)); + }, + + showOutputBar: function() { + if ($('#sidebar').hasClass('sidebar-col')) { + this.handleSideBarToggle(); + } + $('#output_sidebar_collapsed').addClass('hidden'); + $('#output_sidebar_uncollapsed').removeClass('hidden'); + $('#output_sidebar').removeClass('output-col-collapsed').addClass('output-col'); + }, + + hideOutputBar: function() { + $('#output_sidebar_collapsed').removeClass('hidden'); + $('#output_sidebar_uncollapsed').addClass('hidden'); + $('#output_sidebar').removeClass('output-col').addClass('output-col-collapsed'); + }, + initializeEverything: function() { this.initializeRegexes(); this.initializeCodePilot(); @@ -552,6 +594,8 @@ var CodeOceanEditor = { this.initializeEditors(); this.initializeEventHandlers(); this.initializeFileTree(); + this.initializeSideBarCollapse(); + this.initializeOutputBarToggle(); this.initializeTooltips(); this.initPrompt(); this.renderScore();