摘要:
1.function Publisher() { this.subscribers = [];}Publisher.prototype.deliver = function(data) { this.subscribers.forEach( function(fn) { fn(data); } ); return this;};Function.prototype.subscribe = function(publisher) { var that = this; var alreadyExists = publisher.subscribers.some( ... 阅读全文
摘要:
1.本体var Publication = new Interface('Publication', ['getIsbn', 'setIsbn', 'getTitle', 'setTitle', 'getAuthor', 'setAuthor', 'display']);var Book = function(isbn, title, author) { ... } // implements Publication/* Library interface. */va 阅读全文
摘要:
DED.util.Event = { getEvent: function(e) { return e || window.event; }, getTarget: function(e) { return e.target || e.srcElement; }, stopPropagation: function(e) { if (e.stopPropagation) { e.stopPropagation(); } else { e.cancelBubble = true; } }, preventDefault: f... 阅读全文