Commit bd9c4f48 authored by ThorbenQuast's avatar ThorbenQuast
Browse files

editor: preparation for submission functionalities:

- showOuput = boolean as parameter when creating an instance
- integrate submission menu in command line (functionality is to be
added yet)
parent 96a4d61d
......@@ -19,15 +19,29 @@
Abort
</button>
</span>
<!-- The submit button -->
<span class="input-group-btn">
<button class="btn btn-default dropdown-toggle" type="button2" data-toggle="dropdown">
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown" title="Submission menu">
<i class="glyphicon glyphicon-list"></i>
History
</button>
<ul class="dropdown-menu" role="menu">
<ul id="menu" class="dropdown-menu" role="menu">
<li>
<a id="submit"><i class="glyphicon glyphicon-time"></i> Submit </a>
</li>
<li>
<a id="quick-submit"><i class="glyphicon glyphicon-road"></i> Quick-submit </a>
</li>
</ul>
</span>
<input type="text" class="form-control" id="command-line" placeholder="Commandline" value="" data-toggle="tooltip" data-placement="bottom" style="height:35px" title="Execution command relative to the filepath. %file is a variable holding the filename.">
<!-- The history button -->
<span class="input-group-btn">
<button class="btn btn-default dropdown-toggle" type="button2" data-toggle="dropdown" title="Command history">
<i class="glyphicon glyphicon-chevron-down"></i>
</button>
<ul id="history" class="dropdown-menu dropdown-menu-right" role="menu">
</ul>
</span>
<input type="text" class="form-control" id="command-line" placeholder="Commandline" value="" data-toggle="tooltip" data-placement="bottom" title="Execution command relative to the filepath. %file is a variable holding the filename.">
</div>
<pre class="codeeditor-output">Execution Output</pre>
<div class="codeeditor-output-buttons">
......@@ -55,7 +69,7 @@
<i class="glyphicon glyphicon-folder-close"></i>
</button>
</span>
<input type="text" class="form-control" id="path-input" placeholder="Directory to inspect" />
<input type="text" class="form-control" id="path-input" style="height:35px" placeholder="Directory to inspect" />
</div>
<div class="well"></div>
</div>
......
......@@ -12,8 +12,9 @@ var CommandLine = Emitter.extend({
"g++ %file -o %file.out && ./%file.out": ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]
};
this.commandline = 0;
this.histNode = 0;
this.commandline = null;
this.histNode = null;
this.menuNode = null;
this.commands = [];
this.defaultCommand = null;
......@@ -36,14 +37,26 @@ var CommandLine = Emitter.extend({
}).tooltip({
trigger: "focus"
});
this.histNode = rightTopNode.find(".dropdown-menu");
this.histNode = rightTopNode.find("#history");
this.menuNode = rightTopNode.find("#menu");
//get the last command and afterwards set the default & render the history
this.cookieName = "commands-ws" + String(this.view.getWorkspaceId());
this.getCookie(function() {
self.setLastCommandFromCookie();
self.setDefault();
self.renderHistory();
});
this.setMenuFunctionality(); //sets up the buttons in the submit menu
},
setMenuFunctionality: function() {
this.menuNode.find("#submit").click(function(){
console.log("submit from editor not implemented yet");
});
this.menuNode.find("#quick-submit").click(function(){
console.log("quick-submit from editor not implemented yet");
});
},
getCookie: function(callback) {
......
......@@ -41,9 +41,11 @@ var CodeEditorExtension = vispa.Extension.extend({
var CodeEditorView = vispa.ExtensionView.Center.extend({
init: function(preferences, shortcuts, path, writable = null) {
init: function(preferences, shortcuts, path, writable = null, showOutput = true) {
//writable: force the editor to turn on/off read-only mode (writable -> read-only off)
//if file not writable but writable === true --> appropriate message when trying to save shows up
//showOutput: if set to false --> complete right side is hidden at first
//(loaded but not shown because css properties are simply set to appropriate values)
this._super(preferences, shortcuts);
var self = this;
......@@ -81,7 +83,7 @@ var CodeEditorView = vispa.ExtensionView.Center.extend({
this.editor = new CodeEditor(this, path, writable);
this.output = new CodeEditorOutput(this);
this.preview = new CodeEditorPreview(this);
this.ui = new CodeEditorUI(this);
this.ui = new CodeEditorUI(this, showOutput);
this.commandLine = new CommandLine(this);
this.forceClose = false;
......
var CodeEditorUI = Emitter.extend({
init: function(view) {
init: function(view, showOutput) {
this._super();
this.view = view;
......@@ -10,6 +10,8 @@ var CodeEditorUI = Emitter.extend({
this.yDragbar = null;
this.oldXDragPosition = null;
this.oldYDragPosition = null;
this.showOutput = showOutput;
},
setup: function() { //resize of divs per mouse drag
......@@ -42,6 +44,7 @@ var CodeEditorUI = Emitter.extend({
self.xDragbar.css("left", self.oldXDragPosition);
return;
}
self.showOutput = true; //reset it, whenever the user wants so
self.setInputOutputRatio(r);
self.view.setPreference("inputOutputRatio", r);
}
......@@ -72,14 +75,17 @@ var CodeEditorUI = Emitter.extend({
self.yDragbar.css("top", self.oldYDragPosition); //restore old position
return;
}
self.showOutput = true;
self.setTextPictureRatio(r);
self.view.setPreference("outputPreviewRatio", r);
}
});
},
setInputOutputRatio: function(r) { //r: ratio between left side width and total width
setInputOutputRatio: function(r) { //r: ratio between left side width and total widths
r = r == null ? this.view.getPreference("inputOutputRatio") : r;
if (!this.showOutput)
r = 99.9; //not 100% because we want to allow for the dragbar
$(".codeeditor-left", this.view._nodes.content).css("width", String(r) + "%");
$(".codeeditor-x-dragbar", this.view._nodes.content).css("left", String(r) + "%");
$(".codeeditor-right", this.view._nodes.content).css("width", String((100 - r)) + "%");
......@@ -93,6 +99,6 @@ var CodeEditorUI = Emitter.extend({
$(".codeeditor-y-dragbar", this.view._nodes.content).css("top", String(r) + "%");
$(".codeeditor-right-bottom", this.view._nodes.content).css("height", String(100 - r) + "%");
return this;
},
}
});
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment