| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * This file is part of Adblock Plus <http://adblockplus.org/>, | |
| 3 * Copyright (C) 2006-2013 Eyeo GmbH | |
| 4 * | |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | |
| 6 * it under the terms of the GNU General Public License version 3 as | |
| 7 * published by the Free Software Foundation. | |
| 8 * | |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 * GNU General Public License for more details. | |
| 13 * | |
| 14 * You should have received a copy of the GNU General Public License | |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | |
| 16 */ | |
| 17 | |
| 18 | |
| 19 (function() | |
| 20 { | |
| 21 window.ext = {}; | |
| 22 | |
| 23 var EventTarget = ext._EventTarget = function(cancelable) | |
| 24 { | |
| 25 this._listeners = []; | |
| 26 this._cancelable = cancelable; | |
| 27 }; | |
| 28 EventTarget.prototype = { | |
| 29 addListener: function(listener) | |
| 30 { | |
| 31 this._listeners.push(listener); | |
|
Wladimir Palant
2014/04/04 14:00:35
Please check first whether this listener is alread
Sebastian Noack
2014/04/07 13:15:25
Done.
| |
| 32 }, | |
| 33 removeListener: function(listener) | |
| 34 { | |
| 35 var idx = this._listeners.indexOf(listener); | |
| 36 if (idx != -1) | |
| 37 this._listeners.splice(idx, 1); | |
| 38 }, | |
| 39 _dispatch: function(cancelable, args) | |
| 40 { | |
| 41 for (var i = 0; i < this._listeners.length; i++) | |
| 42 { | |
| 43 var result = this._listeners[i].apply(null, arguments); | |
| 44 if (this._cancelable && result === false) | |
| 45 return false; | |
| 46 } | |
| 47 return true; | |
| 48 } | |
| 49 }; | |
| 50 })(); | |
| OLD | NEW |