diff --git a/package.json b/package.json index 1c705ba..0c21c6e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eruda", - "version": "0.0.6", + "version": "0.0.7", "description": "Console for mobile JavaScript", "main": "index.js", "scripts": { diff --git a/src/Console/Console.es6 b/src/Console/Console.es6 index 15a44f7..903559a 100644 --- a/src/Console/Console.es6 +++ b/src/Console/Console.es6 @@ -50,6 +50,7 @@ export default class Console extends Tool { var log = this._log; + this._origOnerror = window.onerror; window.onerror = (errMsg, url, lineNum, column, errObj) => { if (errObj) return log.error(errObj); @@ -58,6 +59,12 @@ export default class Console extends Tool return this; } + destroy() + { + super.destroy(); + + window.onerror = this._origOnerror; + } _appendTpl() { var $el = this._$el; @@ -89,8 +96,10 @@ export default class Console extends Tool log.input(jsInput); $jsInput.val(''); + $jsInput.get(0).blur(); } - }); + }).on('focusin', () => $jsInput.css({height: '100%'})) + .on('focusout', () => $jsInput.css({height: '40px'})) } } diff --git a/src/Console/Console.hbs b/src/Console/Console.hbs index 01eace6..b3aaca8 100644 --- a/src/Console/Console.hbs +++ b/src/Console/Console.hbs @@ -1,2 +1,2 @@
- + diff --git a/src/DevTools/DevTools.es6 b/src/DevTools/DevTools.es6 index 2232317..1cb5899 100644 --- a/src/DevTools/DevTools.es6 +++ b/src/DevTools/DevTools.es6 @@ -61,11 +61,11 @@ export default class DevTools remove(name) { var tool = this._tools[name]; - delete this._tools[name]; - this._$tools.find('.eruda-' + name); + delete this._tools[name]; this._navBar.remove(name); + tool.destroy(); if (tool.active) { var keys = util.keys(this._tools); @@ -80,6 +80,12 @@ export default class DevTools if (tool) return tool; } + destroy() + { + util.each(this._tools, (tool, key) => this.remove(key)); + this._navBar.destroy(); + this._$el.remove(); + } showTool(name) { var tools = this._tools; diff --git a/src/DevTools/NavBar.es6 b/src/DevTools/NavBar.es6 index 39e1947..73fc67d 100644 --- a/src/DevTools/NavBar.es6 +++ b/src/DevTools/NavBar.es6 @@ -24,6 +24,10 @@ export default class NavBar extends util.Emitter this._$el.find('li.' + name).remove(); this._$el.css({width: this._len * 69}); } + destroy() + { + this._$el.remove(); + } activeTool(name) { var $el = this._$el; diff --git a/src/DevTools/Tool.es6 b/src/DevTools/Tool.es6 index 8772983..e011588 100644 --- a/src/DevTools/Tool.es6 +++ b/src/DevTools/Tool.es6 @@ -16,4 +16,8 @@ export default class Tool return this; } + destroy() + { + this._$el.remove(); + } } \ No newline at end of file diff --git a/src/index.es6 b/src/index.es6 index 73dd67c..afbd564 100644 --- a/src/index.es6 +++ b/src/index.es6 @@ -49,7 +49,7 @@ settings.separator() function appendContainer() { - util.$('#eruda').remove(); + if (eruda) eruda.destroy(); util.$('body').append('
'); $container = util.$('#eruda'); } @@ -79,6 +79,12 @@ module.exports = { return this; }, + destroy() + { + devTools.destroy(); + $container.remove(); + window.eruda = undefined; + }, util }; diff --git a/test/index.html b/test/index.html index 905cf03..95adbbf 100644 --- a/test/index.html +++ b/test/index.html @@ -18,11 +18,5 @@ document.write(''); })(); - \ No newline at end of file