mirror of
https://github.com/liriliri/eruda.git
synced 2026-04-01 10:18:35 +08:00
Dev: Expose Tool class
This commit is contained in:
@@ -54,8 +54,11 @@ export default class DevTools extends util.Emitter
|
||||
}
|
||||
add(tool)
|
||||
{
|
||||
let {init, show, hide, destroy} = new Tool();
|
||||
util.defaults(tool, {init, show, hide, destroy});
|
||||
if (!(tool instanceof Tool))
|
||||
{
|
||||
let {init, show, hide, destroy} = new Tool();
|
||||
util.defaults(tool, {init, show, hide, destroy});
|
||||
}
|
||||
|
||||
let name = tool.name;
|
||||
if (!name) return logger.error('You must specify a name for a tool');
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
export default class Tool
|
||||
{
|
||||
import util from '../lib/util';
|
||||
|
||||
export default util.Class({
|
||||
init($el)
|
||||
{
|
||||
this._$el = $el;
|
||||
}
|
||||
},
|
||||
show()
|
||||
{
|
||||
this._$el.show();
|
||||
|
||||
return this;
|
||||
}
|
||||
},
|
||||
hide()
|
||||
{
|
||||
this._$el.hide();
|
||||
|
||||
return this;
|
||||
}
|
||||
},
|
||||
destroy()
|
||||
{
|
||||
this._$el.remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user