摘要: 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( ... 阅读全文
posted @ 2013-02-22 11:30 瓦尔登湖的秋天 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 1.本体var Publication = new Interface('Publication', ['getIsbn', 'setIsbn', 'getTitle', 'setTitle', 'getAuthor', 'setAuthor', 'display']);var Book = function(isbn, title, author) { ... } // implements Publication/* Library interface. */va 阅读全文
posted @ 2013-02-22 11:04 瓦尔登湖的秋天 阅读(163) 评论(0) 推荐(0) 编辑
摘要: 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... 阅读全文
posted @ 2013-02-22 10:45 瓦尔登湖的秋天 阅读(152) 评论(0) 推荐(0) 编辑