Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
Make panel resizable
Browse files Browse the repository at this point in the history
  • Loading branch information
0mkara committed Feb 24, 2017
1 parent beeb333 commit 2f38b66
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 691 deletions.
65 changes: 0 additions & 65 deletions lib/etch-component.js

This file was deleted.

120 changes: 104 additions & 16 deletions lib/ethereum-interface-view.js
@@ -1,52 +1,125 @@
var AtomSolidityView;
var AtomSolidityView,
CompositeDisposable;

CompositeDisposable = require('atom').CompositeDisposable;

module.exports = AtomSolidityView = (function() {
function AtomSolidityView(serializedState) {
var accountsNode, att, buttonNode, compileButton, compilerNode, makeButton, message;
var mainNode,
resizeNode,
accountsNode,
att,
buttonNode,
compileButton,
compilerNode,
makeButton,
message;

this.handleMouseDown = function(e) {
if (this.subscriptions != null) {
this.subscriptions.dispose()
}

const mouseUpHandler = (e) => this.handleMouseUp(e)
const mouseMoveHandler = (e) => this.handleMouseMove(e)
window.addEventListener('mousemove', mouseMoveHandler)
window.addEventListener('mouseup', mouseUpHandler)

this.subscriptions = new CompositeDisposable({
dispose: () => {
window.removeEventListener('mousemove', mouseMoveHandler)
}
}, {
dispose: () => {
window.removeEventListener('mouseup', mouseUpHandler)
}
})
}

this.handleMouseMove = function(e) {
// Currently only vertical panel is working, may be later I should add horizontal panel
const width = this.element.getBoundingClientRect().right - e.pageX;
const vwidth = window.innerWidth;
const vw = (width / vwidth) * 100 + 'vw';
this.element.style.width = vw;
}

this.handleMouseUp = function(e) {
if (this.subscriptions) {
this.subscriptions.dispose()
}
}

this.dispose = function() {
this.destroy()
}

this.element = document.createElement;
this.element = document.createElement('div');
this.element.classList.add('atom-solidity');
this.element.classList.add('native-key-bindings');
this.element.setAttribute('tabindex', '-1');
this.element = document.createElement('atom-panel');
this.element.classList.add('etheratom-panel');

// empty div to handle resize
resizeNode = document.createElement('div');
resizeNode.onmousedown = this.handleMouseDown.bind(this);
resizeNode.classList.add('etheratom-panel-resize-handle');
resizeNode.setAttribute('ref', 'resizehandle');
this.element.appendChild(resizeNode);

mainNode = document.createElement('div');
mainNode.classList.add('atom-solidity');
mainNode.classList.add('native-key-bindings');
mainNode.setAttribute('tabindex', '-1');

message = document.createElement('div');
message.textContent = "Atom Ethereum Interface";
message.classList.add('compiler-info');
message.classList.add('inline-block');
message.classList.add('highlight-info');
this.element.appendChild(message);
mainNode.appendChild(message);

compilerNode = document.createElement('div');
att = document.createAttribute('id');
att.value = 'compiler-options';
compilerNode.setAttributeNode(att);
this.element.appendChild(compilerNode);
mainNode.appendChild(compilerNode);

accountsNode = document.createElement('div');
att = document.createAttribute('id');
att.value = 'accounts-list';
accountsNode.setAttributeNode(att);
this.element.appendChild(accountsNode);
this.compiledNode = document.createElement('div');
att = document.createAttribute('id');
att.value = 'compiled-code';
this.compiledNode.setAttributeNode(att);
this.compiledNode.classList.add('compiled-code');
mainNode.appendChild(accountsNode);

buttonNode = document.createElement('div');
att = document.createAttribute('id');
att.value = 'common-buttons';
buttonNode.setAttributeNode(att);
buttonNode.classList.add('block');

compileButton = document.createElement('div');
att = document.createAttribute('id');
att.value = 'compile_btn';
compileButton.setAttributeNode(att);
compileButton.classList.add('inline-block');

makeButton = document.createElement('div');
att = document.createAttribute('id');
att.value = 'make_btn';
makeButton.setAttributeNode(att);
makeButton.classList.add('inline-block');
buttonNode.appendChild(compileButton);
buttonNode.appendChild(makeButton);
this.element.appendChild(buttonNode);
mainNode.appendChild(buttonNode);

this.compiledNode = document.createElement('div');
att = document.createAttribute('id');
att.value = 'compiled-code';
this.compiledNode.setAttributeNode(att);
this.compiledNode.classList.add('compiled-code');
mainNode.appendChild(this.compiledNode);

// Finally append mainNode to element
this.element.appendChild(mainNode);

}

AtomSolidityView.prototype.serialize = function() {};
Expand Down Expand Up @@ -99,28 +172,36 @@ module.exports = AtomSolidityView = (function() {
contractName = this.name;
bytecode = JSON.stringify(this.bytecode);
contractABI = JSON.stringify(this.abiDef);

cNode = document.createElement('div');
att = document.createAttribute('id');
att.value = contractName;
cNode.classList.add('contract-display');
cNode.setAttributeNode(att);

cnameNode = document.createElement('span');
cnameNode.classList.add('contract-name');
cnameNode.classList.add('inline-block');
cnameNode.classList.add('highlight-success');

title = document.createTextNode(contractName);
cnameNode.appendChild(title);
cNode.appendChild(cnameNode);

bcNode = document.createElement('div');
bcNode.classList.add('byte-code');

textNode = this.createTextareaR(bytecode);
bcNode.appendChild(textNode);
cNode.appendChild(bcNode);

messageNode = document.createElement('div');
messageNode.classList.add('abi-definition');

textNode = this.createTextareaR(contractABI);
messageNode.appendChild(textNode);
cNode.appendChild(messageNode);

inputsNode = document.createElement('div');
att = document.createAttribute('id');
att.value = contractName + '_inputs';
Expand All @@ -144,12 +225,15 @@ module.exports = AtomSolidityView = (function() {
inputsNode.appendChild(lineBr);
}
cNode.appendChild(inputsNode);

buttonText = document.createElement('button');
buttonText.classList.add('input');
buttonText.classList.add('text-subtle');

varName = document.createTextNode("Estimated Gas");
buttonText.appendChild(varName);
inputsNode.appendChild(buttonText);

estimatedGasInput = document.createElement('input');
att = document.createAttribute('id');
att.value = contractName + '_gas';
Expand All @@ -158,16 +242,19 @@ module.exports = AtomSolidityView = (function() {
estimatedGasInput.classList.add('inputs');
estimatedGasInput.setAttribute('value', this.estimatedGas);
inputsNode.appendChild(estimatedGasInput);

createButton = document.createElement('div');
att = document.createAttribute('id');
att.value = contractName + '_create';
createButton.setAttributeNode(att);
inputsNode.appendChild(createButton);

createStat = document.createElement('div');
att = document.createAttribute('id');
att.value = contractName + '_stat';
createStat.setAttributeNode(att);
cNode.appendChild(createStat);

createAddr = document.createElement('div');
att = document.createAttribute('id');
att.value = contractName + '_address';
Expand All @@ -176,13 +263,14 @@ module.exports = AtomSolidityView = (function() {
att.value = contractName;
createAddr.setAttributeNode(att);
cNode.appendChild(createAddr);

callButton = document.createElement('div');
att = document.createAttribute('id');
att.value = contractName + '_call';
callButton.setAttributeNode(att);
cNode.appendChild(callButton);
this.compiledNode.appendChild(cNode);
return this.element.appendChild(this.compiledNode);
return;
};

return AtomSolidityView;
Expand Down
16 changes: 5 additions & 11 deletions lib/ethereum-interface.js
Expand Up @@ -30,12 +30,6 @@ Account = require('ethereumjs-account');

ethJSABI = require('ethereumjs-abi');

EtchComponent = require('./etch-component');

const {
PanelManager
} = require('./panel/panel-manager')

Compiler = 'solcjs';

Coinbase = '';
Expand Down Expand Up @@ -75,7 +69,7 @@ module.exports = AtomSolidity = {


activate: function(state) {
this.showPanel()
//this.showPanel()
this.atomSolidityView = new AtomSolidityView(state.atomSolidityViewState);
this.modalPanel = atom.workspace.addRightPanel({
item: this.atomSolidityView.getElement(),
Expand Down Expand Up @@ -649,9 +643,9 @@ module.exports = AtomSolidity = {
cycle.next();
return cycle;
},
constructFunctions: function(contractABI1, callback) {
constructFunctions: function(contractABI, callback) {
var contractFunction, k, len, results;
this.contractABI = contractABI1;
this.contractABI = contractABI;
results = [];
for (k = 0, len = contractABI.length; k < len; k++) {
contractFunction = contractABI[k];
Expand Down Expand Up @@ -733,13 +727,13 @@ module.exports = AtomSolidity = {
});
});
},
create: function(abi, code, constructVars1, contractName1, estimatedGas1) {
create: function(abi, code, constructVars1, contractName1, estimatedGas) {
var e, that;
this.abi = abi;
this.code = code;
this.constructVars = constructVars1;
this.contractName = contractName1;
this.estimatedGas = estimatedGas1;
this.estimatedGas = estimatedGas;
that = this;
if (Compiler === 'solcjs') {
return this.constructorsArray(this.abi, this.constructVars, function(error, typeArr) {
Expand Down
48 changes: 0 additions & 48 deletions lib/panel/empty-tab-view.js

This file was deleted.

0 comments on commit 2f38b66

Please sign in to comment.