Permalink
Browse files

* if(this.callback) and README

  • Loading branch information...
1 parent 757eeb4 commit 425925b0e7701842ceacbf084d4534f8358ed824 @termi termi committed Apr 14, 2012
Showing with 12 additions and 13 deletions.
  1. +10 −11 README.md
  2. +1 −1 __COMPILE/DelegateListener.js
  3. +1 −1 __SRC/DelegateListener.js
View
@@ -24,22 +24,21 @@ document.addEventListener("click", DelegateListener(
//Using filter instead of callback
var editorController = {
copy : function() {},
- past : function() {},
+ paste : function() {},
handler : function(node) {
- swicth(node.getAttrubute("data-menu-event")) {
- case "copy":
- this.copy();
- breal;
- case "past":
- this.copy();
- breal;
- return false;
- }
+ var operation = node.getAttrubute("data-menu-event"),//"copy" or "paste" or null
+ function = operation && this[operation];
+
+ if(function) {
+ function.call(this, node);
+ return true;
+ }
}
}
document.addEventListener("click", DelegateListener(
- editorController.handler.bind(editorController)
+ editorController.handler.bind(editorController),
+ function(){return false}
));
```

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -46,7 +46,7 @@ DelegateListener.prototype.handleEvent = function(event) {
}
- result = this.callback.call(this.context || stopElement, event);
+ if(this.callback)result = this.callback.call(this.context || stopElement, event);
} while(result !== false && elem != stopElement && (elem = elem.parentNode));
return result;

0 comments on commit 425925b

Please sign in to comment.