From 4384afdd03ae8db72dd38b6a0ab7c2c2fd126ab9 Mon Sep 17 00:00:00 2001 From: David Evans Date: Sun, 5 Nov 2017 14:59:18 +0000 Subject: [PATCH] Add GitHub link and tweak flags code suggestions --- scripts/interface/Interface.js | 31 ++++++++++++++++---- scripts/sequence/CodeMirrorMode.js | 46 ++++++++++++++++++------------ styles/main.css | 28 ++++++++++++++---- 3 files changed, 76 insertions(+), 29 deletions(-) diff --git a/scripts/interface/Interface.js b/scripts/interface/Interface.js index 18e39df..a77bc58 100644 --- a/scripts/interface/Interface.js +++ b/scripts/interface/Interface.js @@ -56,7 +56,20 @@ define([ this._downloadPNGFocus = this._downloadPNGFocus.bind(this); } - buildOptions() { + buildOptionsLinks() { + const githubLink = makeNode('a', { + 'class': 'github', + 'href': 'https://github.com/davidje13/SequenceDiagram', + 'target': '_blank', + }); + githubLink.appendChild(makeText('GitHub')); + + const options = makeNode('div', {'class': 'options links'}); + options.appendChild(githubLink); + return options; + } + + buildOptionsDownloads() { this.downloadPNG = makeNode('a', { 'href': '#', 'download': 'SequenceDiagram.png', @@ -76,7 +89,7 @@ define([ this.downloadSVG.appendChild(makeText('SVG')); on(this.downloadSVG, ['click'], this._downloadSVGClick); - const options = makeNode('div', {'class': 'options'}); + const options = makeNode('div', {'class': 'options downloads'}); options.appendChild(this.downloadPNG); options.appendChild(this.downloadSVG); return options; @@ -137,11 +150,17 @@ define([ this.errorPane = makeNode('div', {'class': 'pane-error'}); this.errorText = makeText(); this.errorPane.appendChild(this.errorText); - this.viewPaneInner = makeNode('div', {'class': 'pane-view-inner'}); + const viewPaneScroller = makeNode('div', { + 'class': 'pane-view-scroller', + }); + this.viewPaneInner = makeNode('div', { + 'class': 'pane-view-inner', + }); - const options = this.buildOptions(); - viewPane.appendChild(this.viewPaneInner); - viewPane.appendChild(options); + viewPane.appendChild(viewPaneScroller); + viewPaneScroller.appendChild(this.viewPaneInner); + viewPane.appendChild(this.buildOptionsLinks()); + viewPane.appendChild(this.buildOptionsDownloads()); container.appendChild(codePane); container.appendChild(this.errorPane); diff --git a/scripts/sequence/CodeMirrorMode.js b/scripts/sequence/CodeMirrorMode.js index 169af6b..1ed55d4 100644 --- a/scripts/sequence/CodeMirrorMode.js +++ b/scripts/sequence/CodeMirrorMode.js @@ -54,25 +54,35 @@ define(['core/ArrayUtilities'], (array) => { '!': CM_ERROR, '': exit, }}; - const pm = {type: 'operator', suggest: true, then: { - '+': CM_ERROR, - '-': CM_ERROR, - '*': op, - '!': op, - '': exit, - }}; - const se = {type: 'operator', suggest: true, then: { - '+': op, - '-': op, - '*': CM_ERROR, - '!': CM_ERROR, - '': exit, - }}; return { - '+': pm, - '-': pm, - '*': se, - '!': se, + '+': {type: 'operator', suggest: true, then: { + '+': CM_ERROR, + '-': CM_ERROR, + '*': op, + '!': CM_ERROR, + '': exit, + }}, + '-': {type: 'operator', suggest: true, then: { + '+': CM_ERROR, + '-': CM_ERROR, + '*': op, + '!': {type: 'operator', then: { + '+': CM_ERROR, + '-': CM_ERROR, + '*': CM_ERROR, + '!': CM_ERROR, + '': exit, + }}, + '': exit, + }}, + '*': {type: 'operator', suggest: true, then: { + '+': op, + '-': op, + '*': CM_ERROR, + '!': CM_ERROR, + '': exit, + }}, + '!': op, '': exit, }; } diff --git a/styles/main.css b/styles/main.css index d9acb02..36e38a0 100644 --- a/styles/main.css +++ b/styles/main.css @@ -44,6 +44,14 @@ html, body { top: 0; bottom: 0; right: 0; +} + +.pane-view-scroller { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; overflow: auto; } @@ -76,16 +84,26 @@ html, body { } .options { - display: inline-block; - position: fixed; + position: absolute; + background: #FFFFFF; + font-family: sans-serif; + overflow: hidden; +} + +.options.links { + top: 0; + right: 0; + border-bottom-left-radius: 5px; + border-bottom: 1px solid #EEEEEE; + border-left: 1px solid #EEEEEE; +} + +.options.downloads { bottom: 0; right: 0; - background: #FFFFFF; border-top-left-radius: 5px; border-top: 1px solid #EEEEEE; border-left: 1px solid #EEEEEE; - font-family: sans-serif; - overflow: hidden; } .options a {