Skip to content

Commit

Permalink
Merge pull request ethereum#452 from ethereum/editor-dom
Browse files Browse the repository at this point in the history
Remove DOM dependency of editor API
  • Loading branch information
yann300 authored Mar 9, 2017
2 parents 15b4cbe + 5beea7f commit a6ece05
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ var run = function () {

// ----------------- editor ----------------------

var editor = new Editor()
var editor = new Editor(document.getElementById('input'))

// ----------------- tabbed menu -------------------
$('#options li').click(function (ev) {
Expand Down Expand Up @@ -487,7 +487,7 @@ var run = function () {
// ----------------- editor resize ---------------

function onResize () {
editor.resize()
editor.resize(document.querySelector('#editorWrap').checked)
reAdjust()
}
window.onresize = onResize
Expand Down
10 changes: 5 additions & 5 deletions src/app/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ var ace = require('brace')
var Range = ace.acequire('ace/range').Range
require('../mode-solidity.js')

function Editor () {
var editor = ace.edit('input')
document.getElementById('input').editor = editor // required to access the editor during tests
function Editor (editorElement) {
var editor = ace.edit(editorElement)
editorElement.editor = editor // required to access the editor during tests
var event = new EventManager()
this.event = event
var sessions = {}
Expand Down Expand Up @@ -95,10 +95,10 @@ function Editor () {
}
}

this.resize = function () {
this.resize = function (useWrapMode) {
editor.resize()
var session = editor.getSession()
session.setUseWrapMode(document.querySelector('#editorWrap').checked)
session.setUseWrapMode(useWrapMode)
if (session.getUseWrapMode()) {
var characterWidth = editor.renderer.characterWidth
var contentWidth = editor.container.ownerDocument.getElementsByClassName('ace_scroller')[0].clientWidth
Expand Down

0 comments on commit a6ece05

Please sign in to comment.