Changeset 143576 in webkit
- Timestamp:
- Feb 21, 2013 2:16:32 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r143574 r143576 1 2013-02-21 Keishi Hattori <keishi@webkit.org> 2 3 Add event dispatch class for the new calendar picker 4 https://bugs.webkit.org/show_bug.cgi?id=110131 5 6 Reviewed by Kent Tamura. 7 8 Adding event dispatcher class as part of the new calendar picker patch at Bug 109439. 9 10 No new tests. Code is not yet used. 11 12 * Resources/pagepopups/calendarPicker.js: 13 (EventEmitter): 14 (EventEmitter.prototype.on): Adds a callback for an event. 15 (EventEmitter.prototype.hasListener): Returns true if more than one listeners exist for an event type. 16 (EventEmitter.prototype.removeListener): Removes an event listener. 17 (EventEmitter.prototype.dispatchEvent): Dispatches an event to all callbacks. Takes variable number of arguments. 18 1 19 2013-02-21 Ken Kania <kkania@chromium.org> 2 20 -
trunk/Source/WebCore/Resources/pagepopups/calendarPicker.js
r142572 r143576 649 649 closePicker(); 650 650 global.picker = new CalendarPicker($("main"), global.params); 651 }; 652 653 /** 654 * @constructor 655 */ 656 function EventEmitter() { 657 }; 658 659 /** 660 * @param {!string} type 661 * @param {!function({...*})} callback 662 */ 663 EventEmitter.prototype.on = function(type, callback) { 664 console.assert(callback instanceof Function); 665 if (!this._callbacks) 666 this._callbacks = {}; 667 if (!this._callbacks[type]) 668 this._callbacks[type] = []; 669 this._callbacks[type].push(callback); 670 }; 671 672 EventEmitter.prototype.hasListener = function(type) { 673 if (!this._callbacks) 674 return false; 675 var callbacksForType = this._callbacks[type]; 676 if (!callbacksForType) 677 return false; 678 return callbacksForType.length > 0; 679 }; 680 681 /** 682 * @param {!string} type 683 * @param {!function(Object)} callback 684 */ 685 EventEmitter.prototype.removeListener = function(type, callback) { 686 if (!this._callbacks) 687 return; 688 var callbacksForType = this._callbacks[type]; 689 if (!callbacksForType) 690 return; 691 callbacksForType.splice(callbacksForType.indexOf(callback), 1); 692 if (callbacksForType.length === 0) 693 delete this._callbacks[type]; 694 }; 695 696 /** 697 * @param {!string} type 698 * @param {...*} var_args 699 */ 700 EventEmitter.prototype.dispatchEvent = function(type) { 701 if (!this._callbacks) 702 return; 703 var callbacksForType = this._callbacks[type]; 704 if (!callbacksForType) 705 return; 706 for (var i = 0; i < callbacksForType.length; ++i) { 707 callbacksForType[i].apply(this, Array.prototype.slice.call(arguments, 1)); 708 } 651 709 }; 652 710
Note: See TracChangeset
for help on using the changeset viewer.