Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
28 lines (27 sloc) 1.28 KB
An.object().named('Widget').plural('Widgets').from(Box).has('widgets', []).has('visible', true).has('moving',false).
does('draw', function() {}). // Override to draw
does('tick', function() {}). // Override to update based on time
does('click', function() {}).
does('init', function() { return this.clone().instance().here() }). // Override to change instancing
does('free', function() { return this.remove() }). // Override to custom cleanup
does('here', function() { return this.at(Mouse.x(),Mouse.y()) }).
does('remove',function() { Widget.has('widgets', Widget.widgets().except(this)); return this.hide() }).
does('instance', function() { Widget.has('widgets', Widget.widgets().concat(this)); return this }).
does('container', function() { return this.has('children',[]) }).
does('show', function () { return this.has('visible',true) }).
does('hide', function () { return this.has('visible', false) }).
does('down', function(E) {
if(!E.on(this)) return;
if(this.can('click')) this.click()
global['that'] = this
this.has('moving',E)
if(E.button() == 2) this.mirror()
}).
does('up', function(E) {
this.has('moving',false)
}).
does('move', function(E) {
if (!this.moving()) return;
this.to(E.x() - this.moving().x(),E.y() - this.moving().y())
this.has('moving',E)
})