diff options
| author | Tristan Zur <tzur@web.web.ccwn.org> | 2014-03-27 22:27:47 +0100 |
|---|---|---|
| committer | Tristan Zur <tzur@web.web.ccwn.org> | 2014-03-27 22:27:47 +0100 |
| commit | b62676ca5d3d6f6ba3f019ea3f99722e165a98d8 (patch) | |
| tree | 86722cb80f07d4569f90088eeaea2fc2f6e2ef94 /js/dojo-1.7.2/dojo/Evented.js | |
Diffstat (limited to 'js/dojo-1.7.2/dojo/Evented.js')
| -rw-r--r-- | js/dojo-1.7.2/dojo/Evented.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/js/dojo-1.7.2/dojo/Evented.js b/js/dojo-1.7.2/dojo/Evented.js new file mode 100644 index 0000000..6e65365 --- /dev/null +++ b/js/dojo-1.7.2/dojo/Evented.js @@ -0,0 +1,33 @@ +//>>built +define("dojo/Evented", ["./aspect", "./on"], function(aspect, on){ + // summary: + // The export of this module is a class that can be used as a mixin or base class, + // to add on() and emit() methods to a class + // for listening for events and emiting events: + // |define(["dojo/Evented"], function(Evented){ + // | var EventedWidget = dojo.declare([Evented, dijit._Widget], {...}); + // | widget = new EventedWidget(); + // | widget.on("open", function(event){ + // | ... do something with event + // | }); + // | + // | widget.emit("open", {name:"some event", ...}); + + "use strict"; + var after = aspect.after; + function Evented(){ + } + Evented.prototype = { + on: function(type, listener){ + return on.parse(this, type, listener, function(target, type){ + return after(target, 'on' + type, listener, true); + }); + }, + emit: function(type, event){ + var args = [this]; + args.push.apply(args, arguments); + return on.emit.apply(on, args); + } + }; + return Evented; +}); |
