Dev: Expose Tool class

This commit is contained in:
surunzi
2017-11-19 16:02:16 +08:00
parent 53af31ced6
commit 3b6f7b8e0e
5 changed files with 24 additions and 16 deletions

View File

@@ -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');

View File

@@ -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();
}
}
});