|
|
@ -44,42 +44,89 @@ var css = csjs` |
|
|
|
position : relative; |
|
|
|
position : relative; |
|
|
|
width : 100vw; |
|
|
|
width : 100vw; |
|
|
|
height : 100vh; |
|
|
|
height : 100vh; |
|
|
|
|
|
|
|
overflow : hidden; |
|
|
|
} |
|
|
|
} |
|
|
|
.centerpanel { |
|
|
|
.centerpanel { |
|
|
|
display : flex; |
|
|
|
display : flex; |
|
|
|
flex-direction : column; |
|
|
|
flex-direction : column; |
|
|
|
position : absolute; |
|
|
|
position : absolute; |
|
|
|
top : 0; |
|
|
|
top : 0; |
|
|
|
left : 200px; |
|
|
|
|
|
|
|
right : 0; |
|
|
|
|
|
|
|
bottom : 0; |
|
|
|
bottom : 0; |
|
|
|
|
|
|
|
overflow : hidden; |
|
|
|
} |
|
|
|
} |
|
|
|
.leftpanel { |
|
|
|
.leftpanel { |
|
|
|
display : flex; |
|
|
|
display : flex; |
|
|
|
|
|
|
|
flex-direction : column; |
|
|
|
position : absolute; |
|
|
|
position : absolute; |
|
|
|
top : 0; |
|
|
|
top : 0; |
|
|
|
left : 0; |
|
|
|
|
|
|
|
right : 0; |
|
|
|
|
|
|
|
bottom : 0; |
|
|
|
bottom : 0; |
|
|
|
width : 200px; |
|
|
|
left : 0; |
|
|
|
|
|
|
|
overflow : hidden; |
|
|
|
} |
|
|
|
} |
|
|
|
.dragbar2 { |
|
|
|
.rightpanel { |
|
|
|
background-color : transparent; |
|
|
|
display : flex; |
|
|
|
|
|
|
|
flex-direction : column; |
|
|
|
position : absolute; |
|
|
|
position : absolute; |
|
|
|
width : 0.5em; |
|
|
|
top : 0; |
|
|
|
top : 3em; |
|
|
|
right : 0; |
|
|
|
bottom : 0; |
|
|
|
bottom : 0; |
|
|
|
cursor : col-resize; |
|
|
|
overflow : hidden; |
|
|
|
z-index : 999; |
|
|
|
|
|
|
|
border-right : 2px solid hsla(215, 81%, 79%, .3);
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
` |
|
|
|
` |
|
|
|
|
|
|
|
|
|
|
|
class App { |
|
|
|
class App { |
|
|
|
constructor (opts = {}) { |
|
|
|
constructor (opts = {}) { |
|
|
|
var self = this |
|
|
|
var self = this |
|
|
|
|
|
|
|
self._api = {} |
|
|
|
|
|
|
|
var fileStorage = new Storage('sol:') |
|
|
|
|
|
|
|
self._api.config = new Config(fileStorage) |
|
|
|
|
|
|
|
self._api.filesProviders = {} |
|
|
|
|
|
|
|
self._api.filesProviders['browser'] = new Browserfiles(fileStorage) |
|
|
|
|
|
|
|
self._api.filesProviders['localhost'] = new SharedFolder(new Remixd()) |
|
|
|
self._view = {} |
|
|
|
self._view = {} |
|
|
|
self._components = {} |
|
|
|
self._components = {} |
|
|
|
|
|
|
|
self.data = { |
|
|
|
|
|
|
|
_layout: { |
|
|
|
|
|
|
|
right: { |
|
|
|
|
|
|
|
offset: self._api.config.get('right-offset') || 200, |
|
|
|
|
|
|
|
show: true |
|
|
|
|
|
|
|
}, // @TODO: adapt sizes proportionally to browser window size
|
|
|
|
|
|
|
|
left: { |
|
|
|
|
|
|
|
offset: self._api.config.get('left-offset') || 200, |
|
|
|
|
|
|
|
show: true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// ----------------- editor ----------------------------
|
|
|
|
|
|
|
|
self._components.editor = new Editor({}) // @TODO: put into editorpanel
|
|
|
|
|
|
|
|
// ----------------- editor panel ----------------------
|
|
|
|
|
|
|
|
self._components.editorpanel = new EditorPanel({ |
|
|
|
|
|
|
|
api: { editor: self._components.editor }, |
|
|
|
|
|
|
|
data: { _layout: self.data._layout } |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
self._components.editorpanel.event.register('resize', direction => self._adjustLayout(direction)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
_adjustLayout (direction, delta) { |
|
|
|
|
|
|
|
var self = this |
|
|
|
|
|
|
|
var layout = self.data._layout[direction] |
|
|
|
|
|
|
|
if (layout) { |
|
|
|
|
|
|
|
if (delta === undefined) { |
|
|
|
|
|
|
|
layout.show = !layout.show |
|
|
|
|
|
|
|
if (layout.show) delta = layout.offset |
|
|
|
|
|
|
|
else delta = 0 |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
self._api.config.set(`${direction}-offset`, delta) |
|
|
|
|
|
|
|
layout.offset = delta |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (direction === 'left') { |
|
|
|
|
|
|
|
self._view.leftpanel.style.width = delta + 'px' |
|
|
|
|
|
|
|
self._view.centerpanel.style.left = delta + 'px' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (direction === 'right') { |
|
|
|
|
|
|
|
self._view.rightpanel.style.width = delta + 'px' |
|
|
|
|
|
|
|
self._view.centerpanel.style.right = delta + 'px' |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
init () { |
|
|
|
init () { |
|
|
|
var self = this |
|
|
|
var self = this |
|
|
@ -88,22 +135,6 @@ class App { |
|
|
|
render () { |
|
|
|
render () { |
|
|
|
var self = this |
|
|
|
var self = this |
|
|
|
if (self._view.el) return self._view.el |
|
|
|
if (self._view.el) return self._view.el |
|
|
|
/*************************************************************************/ |
|
|
|
|
|
|
|
// ----------------- editor ----------------------------
|
|
|
|
|
|
|
|
self._components.editor = new Editor({}) // @TODO: put into editorpanel
|
|
|
|
|
|
|
|
// ----------------- editor panel ----------------------
|
|
|
|
|
|
|
|
var opts = { api: { editor: self._components.editor } } |
|
|
|
|
|
|
|
self._components.editorpanel = new EditorPanel(opts) |
|
|
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
|
|
|
// self._api = opts.api
|
|
|
|
|
|
|
|
// self.data = {
|
|
|
|
|
|
|
|
// _layout: {
|
|
|
|
|
|
|
|
// seperator1: self._api.config.get('seperator1') || 200,
|
|
|
|
|
|
|
|
// seperator2: self._api.config.get('seperator2') || 200,
|
|
|
|
|
|
|
|
// editorsize: self._api.config.get('editorWindowSize') || 400
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
|
|
|
self._view.leftpanel = yo` |
|
|
|
self._view.leftpanel = yo` |
|
|
|
<div id="filepanel" class=${css.leftpanel}> |
|
|
|
<div id="filepanel" class=${css.leftpanel}> |
|
|
|
${''} |
|
|
|
${''} |
|
|
@ -115,8 +146,7 @@ class App { |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
` |
|
|
|
` |
|
|
|
self._view.rightpanel = yo` |
|
|
|
self._view.rightpanel = yo` |
|
|
|
<div> |
|
|
|
<div class=${css.rightpanel}> |
|
|
|
<div id="dragbar" class=${css.dragbar2}></div> |
|
|
|
|
|
|
|
${''} |
|
|
|
${''} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
` |
|
|
|
` |
|
|
@ -127,6 +157,9 @@ class App { |
|
|
|
${self._view.rightpanel} |
|
|
|
${self._view.rightpanel} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
` |
|
|
|
` |
|
|
|
|
|
|
|
// INIT
|
|
|
|
|
|
|
|
self._adjustLayout('left', self.data._layout.left.offset) |
|
|
|
|
|
|
|
self._adjustLayout('right', self.data._layout.right.offset) |
|
|
|
return self._view.el |
|
|
|
return self._view.el |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -152,12 +185,9 @@ function run () { |
|
|
|
}, false) |
|
|
|
}, false) |
|
|
|
|
|
|
|
|
|
|
|
this.event = new EventManager() |
|
|
|
this.event = new EventManager() |
|
|
|
var fileStorage = new Storage('sol:') |
|
|
|
|
|
|
|
var config = new Config(fileStorage) |
|
|
|
var config = self._api.config |
|
|
|
var remixd = new Remixd() |
|
|
|
var filesProviders = self._api.filesProviders |
|
|
|
var filesProviders = {} |
|
|
|
|
|
|
|
filesProviders['browser'] = new Browserfiles(fileStorage) |
|
|
|
|
|
|
|
filesProviders['localhost'] = new SharedFolder(remixd) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var tabbedFiles = {} // list of files displayed in the tabs bar
|
|
|
|
var tabbedFiles = {} // list of files displayed in the tabs bar
|
|
|
|
|
|
|
|
|
|
|
@ -301,10 +331,7 @@ function run () { |
|
|
|
var filepanelContainer = document.querySelector('#filepanel') |
|
|
|
var filepanelContainer = document.querySelector('#filepanel') |
|
|
|
filepanelContainer.appendChild(filePanel.render()) |
|
|
|
filepanelContainer.appendChild(filePanel.render()) |
|
|
|
|
|
|
|
|
|
|
|
filePanel.event.register('resize', function changeLayout (width) { |
|
|
|
filePanel.event.register('resize', delta => self._adjustLayout('left', delta)) |
|
|
|
self._view.leftpanel.style.width = width + 'px' |
|
|
|
|
|
|
|
self._view.centerpanel.style.left = width + 'px' |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function fileRenamedEvent (oldName, newName, isFolder) { |
|
|
|
function fileRenamedEvent (oldName, newName, isFolder) { |
|
|
|
// TODO please never use 'window' when it is possible to use a variable
|
|
|
|
// TODO please never use 'window' when it is possible to use a variable
|
|
|
@ -644,17 +671,9 @@ function run () { |
|
|
|
// ---------------- Righthand-panel --------------------
|
|
|
|
// ---------------- Righthand-panel --------------------
|
|
|
|
var rhpAPI = { |
|
|
|
var rhpAPI = { |
|
|
|
config: config, |
|
|
|
config: config, |
|
|
|
setEditorSize (delta) { |
|
|
|
|
|
|
|
$('#righthand-panel').css('width', delta) |
|
|
|
|
|
|
|
self._view.centerpanel.style.right = delta + 'px' |
|
|
|
|
|
|
|
document.querySelector(`.${css.dragbar2}`).style.right = delta + 'px' |
|
|
|
|
|
|
|
onResize() |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
warnCompilerLoading: (msg) => { |
|
|
|
warnCompilerLoading: (msg) => { |
|
|
|
renderer.clear() |
|
|
|
renderer.clear() |
|
|
|
if (msg) { |
|
|
|
if (msg) renderer.error(msg, $('#output'), {type: 'warning'}) |
|
|
|
renderer.error(msg, $('#output'), {type: 'warning'}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
executionContextChange: (context) => { |
|
|
|
executionContextChange: (context) => { |
|
|
|
return executionContext.executionContextChange(context) |
|
|
|
return executionContext.executionContextChange(context) |
|
|
@ -668,16 +687,17 @@ function run () { |
|
|
|
app: self.event, |
|
|
|
app: self.event, |
|
|
|
udapp: udapp.event |
|
|
|
udapp: udapp.event |
|
|
|
} |
|
|
|
} |
|
|
|
var righthandPanel = new RighthandPanel(rhpAPI, rhpEvents, {}) // eslint-disable-line
|
|
|
|
self._components.righthandpanel = new RighthandPanel(rhpAPI, rhpEvents, {}) |
|
|
|
self._view.rightpanel.appendChild(righthandPanel.render()) |
|
|
|
self._view.rightpanel.appendChild(self._components.righthandpanel.render()) |
|
|
|
righthandPanel.init() |
|
|
|
self._components.righthandpanel.init() |
|
|
|
|
|
|
|
self._components.righthandpanel.event.register('resize', delta => self._adjustLayout('right', delta)) |
|
|
|
|
|
|
|
|
|
|
|
// ----------------- editor resize ---------------
|
|
|
|
// ----------------- editor resize ---------------
|
|
|
|
|
|
|
|
|
|
|
|
function onResize () { |
|
|
|
function onResize () { |
|
|
|
editor.resize(document.querySelector('#editorWrap').checked) |
|
|
|
editor.resize(document.querySelector('#editorWrap').checked) |
|
|
|
} |
|
|
|
} |
|
|
|
window.onresize = onResize |
|
|
|
self._onResize = window.onresize = onResize |
|
|
|
onResize() |
|
|
|
onResize() |
|
|
|
|
|
|
|
|
|
|
|
self._view.el.addEventListener('change', onResize) |
|
|
|
self._view.el.addEventListener('change', onResize) |
|
|
|