diff options
Diffstat (limited to 'js/tool.js')
| -rw-r--r-- | js/tool.js | 43 |
1 files changed, 24 insertions, 19 deletions
@@ -1,19 +1,24 @@ -function Tool (span) { - this.el = span - this.lex = new Lex (span) - this.name = span.innerHTML - this.span = span -} -Tool.prototype.use = function(){} -Tool.prototype.focus = function(){ - // focused && focused.blur() - current_tool && current_tool.blur() - current_tool = this - this.span.classList.add('focused') - this.use() - if (this.name != 'shader') { cursor_input.focus() } -} -Tool.prototype.blur = function(){ - current_tool = null - this.span.classList.remove('focused') -} +var Tool = Model({ + init: function (span) { + this.el = span + this.lex = new Lex (span) + this.name = span.innerHTML + this.span = span + }, + use: function(){}, + focus: function(){ + // focused && focused.blur() + current_tool && current_tool.blur() + current_tool = this + this.span.classList.add('focused') + this.use() + if (this.name != 'shader') { cursor_input.focus() } + }, + blur: function(){ + current_tool = null + this.span.classList.remove('focused') + } +}) + +var Checkbox = Tool({ +}) |
