|
|
@ -1,89 +1,94 @@ |
|
|
|
var yo = require('yo-yo') |
|
|
|
const yo = require('yo-yo') |
|
|
|
var remixLib = require('remix-lib') |
|
|
|
const csjs = require('csjs-inject') |
|
|
|
var EventManager = remixLib.EventManager |
|
|
|
const remixLib = require('remix-lib') |
|
|
|
var TabbedMenu = require('../tabs/tabbed-menu') |
|
|
|
|
|
|
|
var CompileTab = require('../tabs/compile-tab') |
|
|
|
|
|
|
|
var RunTab = require('../tabs/run-tab') |
|
|
|
|
|
|
|
var SettingsTab = require('../tabs/settings-tab') |
|
|
|
|
|
|
|
var AnalysisTab = require('../tabs/analysis-tab') |
|
|
|
|
|
|
|
var DebuggerTab = require('../tabs/debugger-tab') |
|
|
|
|
|
|
|
var SupportTab = require('../tabs/support-tab') |
|
|
|
|
|
|
|
var PluginTab = require('../tabs/plugin-tab') |
|
|
|
|
|
|
|
var TestTab = require('../tabs/test-tab') |
|
|
|
|
|
|
|
var PluginManager = require('../plugin/pluginManager') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var css = require('./styles/righthand-panel-styles') |
|
|
|
const styleguide = require('../ui/styles-guide/theme-chooser') |
|
|
|
|
|
|
|
const PluginManager = require('../plugin/pluginManager') |
|
|
|
|
|
|
|
const TabbedMenu = require('../tabs/tabbed-menu') |
|
|
|
|
|
|
|
const CompileTab = require('../tabs/compile-tab') |
|
|
|
|
|
|
|
const SettingsTab = require('../tabs/settings-tab') |
|
|
|
|
|
|
|
const AnalysisTab = require('../tabs/analysis-tab') |
|
|
|
|
|
|
|
const DebuggerTab = require('../tabs/debugger-tab') |
|
|
|
|
|
|
|
const SupportTab = require('../tabs/support-tab') |
|
|
|
|
|
|
|
const PluginTab = require('../tabs/plugin-tab') |
|
|
|
|
|
|
|
const TestTab = require('../tabs/test-tab') |
|
|
|
|
|
|
|
const RunTab = require('../tabs/run-tab') |
|
|
|
|
|
|
|
|
|
|
|
function RighthandPanel (appAPI = {}, events = {}, opts = {}) { |
|
|
|
const EventManager = remixLib.EventManager |
|
|
|
var self = this |
|
|
|
const styles = styleguide.chooser() |
|
|
|
self._api = appAPI |
|
|
|
|
|
|
|
|
|
|
|
module.exports = class RighthandPanel { |
|
|
|
|
|
|
|
constructor (api = {}, events = {}, opts = {}) { |
|
|
|
|
|
|
|
const self = this |
|
|
|
self.event = new EventManager() |
|
|
|
self.event = new EventManager() |
|
|
|
self._view = {} |
|
|
|
self._api = api |
|
|
|
|
|
|
|
self._api.switchTab = x => { // @TODO: refactor
|
|
|
|
|
|
|
|
if (self._components.tabbedMenu) self._components.tabbedMenu.selectTabByClassName(x) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
self._events = events |
|
|
|
|
|
|
|
self._events.rhp = self.event // @TODO: refactor
|
|
|
|
|
|
|
|
self._opts = opts |
|
|
|
|
|
|
|
self._view = { |
|
|
|
|
|
|
|
element: null, |
|
|
|
|
|
|
|
tabbedMenu: null, |
|
|
|
|
|
|
|
tabbedMenuViewport: null, |
|
|
|
|
|
|
|
dragbar: null |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
self._components = { |
|
|
|
|
|
|
|
pluginManager: new PluginManager(self._opts.pluginAPI, self._events), |
|
|
|
|
|
|
|
tabbedMenu: new TabbedMenu(self._api, self._events), |
|
|
|
|
|
|
|
compile: new CompileTab(self._api, self._events, self._opts), |
|
|
|
|
|
|
|
run: new RunTab(self._api, self._events, self._opts), |
|
|
|
|
|
|
|
settings: new SettingsTab(self._api, self._events, self._opts), |
|
|
|
|
|
|
|
analysis: new AnalysisTab(self._api, self._events, self._opts), |
|
|
|
|
|
|
|
debug: new DebuggerTab(self._api, self._events, self._opts), |
|
|
|
|
|
|
|
support: new SupportTab(self._api, self._events, self._opts), |
|
|
|
|
|
|
|
test: new TestTab(self._api, self._events, self._opts) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.event.register('plugin-loadRequest', json => { |
|
|
|
|
|
|
|
const tab = new PluginTab({}, self._events, json) |
|
|
|
|
|
|
|
const content = tab.render() |
|
|
|
|
|
|
|
self._components.tabbedMenu.addTab(json.title, 'plugin', content) |
|
|
|
|
|
|
|
self._components.pluginManager.register(json, content) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
var optionViews = yo`<div id="optionViews"></div>` |
|
|
|
|
|
|
|
self._view.dragbar = yo`<div id="dragbar" class=${css.dragbar}></div>` |
|
|
|
self._view.dragbar = yo`<div id="dragbar" class=${css.dragbar}></div>` |
|
|
|
// load tabbed menu component
|
|
|
|
|
|
|
|
var tabEvents = {compiler: events.compiler, app: events.app, rhp: self.event} |
|
|
|
|
|
|
|
self._view.tabbedMenu = new TabbedMenu(appAPI, tabEvents) |
|
|
|
|
|
|
|
var options = self._view.tabbedMenu.render() |
|
|
|
|
|
|
|
options.classList.add(css.opts) |
|
|
|
|
|
|
|
self._view.element = yo` |
|
|
|
self._view.element = yo` |
|
|
|
<div id="righthand-panel" class=${css.panel}> |
|
|
|
<div id="righthand-panel" class=${css.righthandpanel}> |
|
|
|
${self._view.dragbar} |
|
|
|
${self._view.dragbar} |
|
|
|
<div id="header" class=${css.header}> |
|
|
|
<div id="header" class=${css.header}> |
|
|
|
<div class=${css.menu}> |
|
|
|
${self._components.tabbedMenu.render()} |
|
|
|
${options} |
|
|
|
${self._components.tabbedMenu.renderViewport()} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
${optionViews} |
|
|
|
</div>` |
|
|
|
</div> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
` |
|
|
|
|
|
|
|
// selectTabByClassName
|
|
|
|
|
|
|
|
appAPI.switchTab = tabClass => self._view.tabbedMenu.selectTabByClassName(tabClass) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
events.rhp = self.event |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var compileTab = new CompileTab(appAPI, events, opts) |
|
|
|
|
|
|
|
optionViews.appendChild(compileTab.render()) |
|
|
|
|
|
|
|
var runTab = new RunTab(appAPI, events, opts) |
|
|
|
|
|
|
|
optionViews.appendChild(runTab.render()) |
|
|
|
|
|
|
|
var settingsTab = new SettingsTab(appAPI, events, opts) |
|
|
|
|
|
|
|
optionViews.appendChild(settingsTab.render()) |
|
|
|
|
|
|
|
var analysisTab = new AnalysisTab(appAPI, events, opts) |
|
|
|
|
|
|
|
optionViews.appendChild(analysisTab.render()) |
|
|
|
|
|
|
|
var debuggerTab = new DebuggerTab(appAPI, events, opts) |
|
|
|
|
|
|
|
optionViews.appendChild(debuggerTab.render()) |
|
|
|
|
|
|
|
var supportTab = new SupportTab(appAPI, events, opts) |
|
|
|
|
|
|
|
optionViews.appendChild(supportTab.render()) |
|
|
|
|
|
|
|
var testTab = new TestTab(appAPI, events, opts) |
|
|
|
|
|
|
|
optionViews.appendChild(testTab.render()) |
|
|
|
|
|
|
|
this._view.tabbedMenu.addTab('Compile', 'compileView', optionViews.querySelector('#compileTabView')) |
|
|
|
|
|
|
|
this._view.tabbedMenu.addTab('Run', 'runView', optionViews.querySelector('#runTabView')) |
|
|
|
|
|
|
|
this._view.tabbedMenu.addTab('Settings', 'settingsView', optionViews.querySelector('#settingsView')) |
|
|
|
|
|
|
|
this._view.tabbedMenu.addTab('Analysis', 'staticanalysisView', optionViews.querySelector('#staticanalysisView')) |
|
|
|
|
|
|
|
this._view.tabbedMenu.addTab('Debugger', 'debugView', optionViews.querySelector('#debugView')) |
|
|
|
|
|
|
|
this._view.tabbedMenu.addTab('Support', 'supportView', optionViews.querySelector('#supportView')) |
|
|
|
|
|
|
|
this._view.tabbedMenu.addTab('Test', 'testView', optionViews.querySelector('#testView')) |
|
|
|
|
|
|
|
this._view.tabbedMenu.selectTabByTitle('Compile') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.pluginManager = new PluginManager(opts.pluginAPI, events) |
|
|
|
const { compile, run, settings, analysis, debug, support, test } = self._components |
|
|
|
events.rhp.register('plugin-loadRequest', (json) => { |
|
|
|
self._components.tabbedMenu.addTab('Compile', 'compileView', compile.render()) |
|
|
|
var tab = new PluginTab({}, events, json) |
|
|
|
self._components.tabbedMenu.addTab('Run', 'runView', run.render()) |
|
|
|
var content = tab.render() |
|
|
|
self._components.tabbedMenu.addTab('Settings', 'settingsView', settings.render()) |
|
|
|
optionViews.appendChild(content) |
|
|
|
self._components.tabbedMenu.addTab('Analysis', 'staticanalysisView', analysis.render()) |
|
|
|
this._view.tabbedMenu.addTab(json.title, 'plugin', content) |
|
|
|
self._components.tabbedMenu.addTab('Debugger', 'debugView', debug.render()) |
|
|
|
self.pluginManager.register(json, content) |
|
|
|
self._components.tabbedMenu.addTab('Support', 'supportView', support.render()) |
|
|
|
}) |
|
|
|
self._components.tabbedMenu.addTab('Test', 'testView', test.render()) |
|
|
|
|
|
|
|
self._components.tabbedMenu.selectTabByTitle('Compile') |
|
|
|
self.render = function () { return self._view.element } |
|
|
|
} |
|
|
|
|
|
|
|
// showDebugger () {
|
|
|
|
self.init = function () { |
|
|
|
// const self = this
|
|
|
|
;[...options.children].forEach((el) => { el.classList.add(css.options) }) |
|
|
|
// if (!self._components.tabbedMenu) return
|
|
|
|
|
|
|
|
// self._components.tabbedMenu.selectTab(self._view.el.querySelector('li.debugView'))
|
|
|
|
// ----------------- resizeable ui ---------------
|
|
|
|
// }
|
|
|
|
var limit = 60 |
|
|
|
render () { |
|
|
|
|
|
|
|
const self = this |
|
|
|
|
|
|
|
if (self._view.element) return self._view.element |
|
|
|
|
|
|
|
return self._view.element |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
init () { |
|
|
|
|
|
|
|
// @TODO: init is for resizable drag bar only and should be refactored in the future
|
|
|
|
|
|
|
|
const self = this |
|
|
|
|
|
|
|
const limit = 60 |
|
|
|
self._view.dragbar.addEventListener('mousedown', mousedown) |
|
|
|
self._view.dragbar.addEventListener('mousedown', mousedown) |
|
|
|
var ghostbar = yo`<div class=${css.ghostbar}></div>` |
|
|
|
const ghostbar = yo`<div class=${css.ghostbar}></div>` |
|
|
|
function mousedown (event) { |
|
|
|
function mousedown (event) { |
|
|
|
event.preventDefault() |
|
|
|
event.preventDefault() |
|
|
|
if (event.which === 1) { |
|
|
|
if (event.which === 1) { |
|
|
@ -103,8 +108,8 @@ function RighthandPanel (appAPI = {}, events = {}, opts = {}) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
function getPosition (event) { |
|
|
|
function getPosition (event) { |
|
|
|
var lhp = window['filepanel'].offsetWidth |
|
|
|
const lhp = window['filepanel'].offsetWidth |
|
|
|
var max = document.body.offsetWidth - limit |
|
|
|
const max = document.body.offsetWidth - limit |
|
|
|
var newpos = (event.pageX > max) ? max : event.pageX |
|
|
|
var newpos = (event.pageX > max) ? max : event.pageX |
|
|
|
newpos = (newpos > (lhp + limit)) ? newpos : lhp + limit |
|
|
|
newpos = (newpos > (lhp + limit)) ? newpos : lhp + limit |
|
|
|
return newpos |
|
|
|
return newpos |
|
|
@ -122,4 +127,37 @@ function RighthandPanel (appAPI = {}, events = {}, opts = {}) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
module.exports = RighthandPanel |
|
|
|
const css = csjs` |
|
|
|
|
|
|
|
.righthandpanel { |
|
|
|
|
|
|
|
display : flex; |
|
|
|
|
|
|
|
flex-direction : column; |
|
|
|
|
|
|
|
top : 0; |
|
|
|
|
|
|
|
right : 0; |
|
|
|
|
|
|
|
bottom : 0; |
|
|
|
|
|
|
|
box-sizing : border-box; |
|
|
|
|
|
|
|
overflow : hidden; |
|
|
|
|
|
|
|
height : 100%; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.header { |
|
|
|
|
|
|
|
height : 100%; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.dragbar { |
|
|
|
|
|
|
|
position : absolute; |
|
|
|
|
|
|
|
width : 0.5em; |
|
|
|
|
|
|
|
top : 3em; |
|
|
|
|
|
|
|
bottom : 0; |
|
|
|
|
|
|
|
cursor : col-resize; |
|
|
|
|
|
|
|
z-index : 999; |
|
|
|
|
|
|
|
border-left : 2px solid ${styles.rightPanel.bar_Dragging}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.ghostbar { |
|
|
|
|
|
|
|
width : 3px; |
|
|
|
|
|
|
|
background-color : ${styles.rightPanel.bar_Ghost}; |
|
|
|
|
|
|
|
opacity : 0.5; |
|
|
|
|
|
|
|
position : absolute; |
|
|
|
|
|
|
|
cursor : col-resize; |
|
|
|
|
|
|
|
z-index : 9999; |
|
|
|
|
|
|
|
top : 0; |
|
|
|
|
|
|
|
bottom : 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
` |
|
|
|