diff options
| -rw-r--r-- | js/tool.js | 43 | ||||
| -rw-r--r-- | js/util.js | 11 |
2 files changed, 34 insertions, 20 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({ +}) @@ -113,4 +113,13 @@ function weave(a){ aa[0].forEach(function(el){ b.push(el) }) reverse(aa[1]).forEach(function(el){ b.push(el) }) return b -}
\ No newline at end of file +} + +Model=function a(b,c,d,e){function f(){var a=this,f={};a.on=function(a,b){(f[a]|| +(f[a]=[])).push(b)},a.trigger=function(a,b){for(var c=f[a],d=0;c&&d<c.length;)c +[d++](b)},a.off=function(a,b){for(d=f[a]||[];b&&(c=d.indexOf(b))>-1;)d.splice(c +,1);f[a]=b?d:[]};for(c in b)d=b[c],a[c]=typeof d=="function"?function(){return( +d=this.apply(a,arguments))===e?a:d}.bind(d):d;a.init&&a.init.apply(a,arguments) +}return f.extend=function(f){d={};for(c in b)d[c]=b[c];for(c in f)d[c]=f[c],b[c +]!==e&&(d["__"+c]=b[c]);return a(d)},f},typeof module=="object"&&(module.exports +=Model); // c-{{{-< |
