Browse Source

on:bind:, off:unbind:

Herbert Vojčík 9 years ago
parent
commit
efee4cf3ac
2 changed files with 58 additions and 0 deletions
  1. 48 0
      src/DOMite.js
  2. 10 0
      src/DOMite.st

+ 48 - 0
src/DOMite.js

@@ -229,6 +229,54 @@ messageSends: ["isNil", "element"]
 }),
 $globals.Domite);
 
+$core.addMethod(
+$core.method({
+selector: "off:unbind:",
+protocol: 'events',
+fn: function (aString,aBlock){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+self._removeEventListener_block_useCapture_(aString,aBlock,false);
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"off:unbind:",{aString:aString,aBlock:aBlock},$globals.Domite)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aString", "aBlock"],
+source: "off: aString unbind: aBlock\x0a\x09self removeEventListener: aString block: aBlock useCapture: false",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["removeEventListener:block:useCapture:"]
+}),
+$globals.Domite);
+
+$core.addMethod(
+$core.method({
+selector: "on:bind:",
+protocol: 'events',
+fn: function (aString,aBlock){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+self._addEventListener_block_useCapture_(aString,aBlock,false);
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"on:bind:",{aString:aString,aBlock:aBlock},$globals.Domite)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aString", "aBlock"],
+source: "on: aString bind: aBlock\x0a\x09self addEventListener: aString block: aBlock useCapture: false",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["addEventListener:block:useCapture:"]
+}),
+$globals.Domite);
+
 $core.addMethod(
 $core.method({
 selector: "reference",

+ 10 - 0
src/DOMite.st

@@ -74,6 +74,16 @@ clearHere
 >
 ! !
 
+!Domite methodsFor: 'events'!
+
+off: aString unbind: aBlock
+	self removeEventListener: aString block: aBlock useCapture: false
+!
+
+on: aString bind: aBlock
+	self addEventListener: aString block: aBlock useCapture: false
+! !
+
 !Domite methodsFor: 'initialization'!
 
 initialize