Skip to content

Add double click event to control the editor hide or show #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
theme: jekyll-theme-cayman
20 changes: 18 additions & 2 deletions assets/js/netscope.js
Original file line number Diff line number Diff line change
Expand Up @@ -2833,10 +2833,11 @@ var Editor;

module.exports = Editor = (function() {
function Editor(loader) {
var $editorBox, editorWidthPercentage;
var $editorBox, editorWidthPercentage, hasShow;
this.loader = loader;
editorWidthPercentage = 30;
$editorBox = $($.parseHTML('<div class="column"></div>'));
hasShow = true;
$editorBox = $($.parseHTML('<div id = "editor-column" class="column"></div>'));
$editorBox.width(editorWidthPercentage + '%');
$('#net-column').width((100 - editorWidthPercentage) + '%');
$('#master-container').prepend($editorBox);
Expand All @@ -2850,6 +2851,21 @@ module.exports = Editor = (function() {
return _this.onKeyDown(e);
};
})(this));
$('#net-column').on('dblclick', (function(_this) {
return function() {
if (hasShow === true) {
hasShow = false;
$("#editor-column").hide();
$('#editor-column').width(0 + '%');
return $('#net-column').width(100 + '%');
} else {
hasShow = true;
$("#editor-column").show();
$('#editor-column').width(30 + '%');
return $('#net-column').width(70 + '%');
}
};
})(this));
}

Editor.prototype.onKeyDown = function(e) {
Expand Down
16 changes: 14 additions & 2 deletions src/editor.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,27 @@ module.exports =
class Editor
constructor: (@loader) ->
editorWidthPercentage = 30;
$editorBox = $($.parseHTML '<div class="column"></div>')
hasShow = true
$editorBox = $($.parseHTML '<div id = "editor-column" class="column"></div>')
$editorBox.width(editorWidthPercentage+'%')
$('#net-column').width((100-editorWidthPercentage)+'%')
$('#master-container').prepend $editorBox
@editor = CodeMirror $editorBox[0],
value: '# Enter your network definition here.\n# Use Shift+Enter to update the visualization.'
value: '# Enter your network definition here.\n# Use Shift+Enter to update the visualization.\n# double click to control the editor hide or show'
lineNumbers : true
lineWrapping : true
@editor.on 'keydown', (cm, e) => @onKeyDown(e)
$('#net-column').on 'dblclick', () =>
if hasShow is true
hasShow = false
$("#editor-column").hide();
$('#editor-column').width(0+'%')
$('#net-column').width(100+'%')
else
hasShow = true
$("#editor-column").show();
$('#editor-column').width(30+'%')
$('#net-column').width(70+'%')

onKeyDown: (e) ->
if (e.shiftKey && e.keyCode==13)
Expand Down