Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: ui/webui/resources/js/event_tracker.js

Issue 575333002: Compile print_preview, part 2: reduce down to 260 errors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@I_print_preview
Patch Set: node -> target Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/webui/resources/js/cr/event_target.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview EventTracker is a simple class that manages the addition and 6 * @fileoverview EventTracker is a simple class that manages the addition and
7 * removal of DOM event listeners. In particular, it keeps track of all 7 * removal of DOM event listeners. In particular, it keeps track of all
8 * listeners that have been added and makes it easy to remove some or all of 8 * listeners that have been added and makes it easy to remove some or all of
9 * them without requiring all the information again. This is particularly handy 9 * them without requiring all the information again. This is particularly handy
10 * when the listener is a generated function such as a lambda or the result of 10 * when the listener is a generated function such as a lambda or the result of
(...skipping 22 matching lines...) Expand all
33 /** 33 /**
34 * @type {Array.<EventTrackerEntry>} 34 * @type {Array.<EventTrackerEntry>}
35 * @private 35 * @private
36 */ 36 */
37 this.listeners_ = []; 37 this.listeners_ = [];
38 } 38 }
39 39
40 EventTracker.prototype = { 40 EventTracker.prototype = {
41 /** 41 /**
42 * Add an event listener - replacement for Node.addEventListener. 42 * Add an event listener - replacement for Node.addEventListener.
43 * @param {!Node} node The DOM node to add a listener to. 43 * @param {!EventTarget} target The DOM target to add a listener to.
44 * @param {string} eventType The type of event to subscribe to. 44 * @param {string} eventType The type of event to subscribe to.
45 * @param {EventListener|Function} listener The listener to add. 45 * @param {EventListener|Function} listener The listener to add.
46 * @param {boolean=} opt_capture Whether to invoke during the capture phase. 46 * @param {boolean=} opt_capture Whether to invoke during the capture phase.
47 */ 47 */
48 add: function(node, eventType, listener, opt_capture) { 48 add: function(target, eventType, listener, opt_capture) {
49 var capture = !!opt_capture; 49 var capture = !!opt_capture;
50 var h = { 50 var h = {
51 node: node, 51 node: target,
Dan Beam 2014/09/23 01:42:27 does this property make much sense to you?
Vitaly Pavlenko 2014/09/23 19:30:12 Done.
52 eventType: eventType, 52 eventType: eventType,
53 listener: listener, 53 listener: listener,
54 capture: capture, 54 capture: capture,
55 }; 55 };
56 this.listeners_.push(h); 56 this.listeners_.push(h);
57 node.addEventListener(eventType, listener, capture); 57 target.addEventListener(eventType, listener, capture);
58 }, 58 },
59 59
60 /** 60 /**
61 * Remove any specified event listeners added with this EventTracker. 61 * Remove any specified event listeners added with this EventTracker.
62 * @param {!Node} node The DOM node to remove a listener from. 62 * @param {!Node} node The DOM node to remove a listener from.
63 * @param {?string} eventType The type of event to remove. 63 * @param {?string} eventType The type of event to remove.
64 */ 64 */
65 remove: function(node, eventType) { 65 remove: function(node, eventType) {
66 this.listeners_ = this.listeners_.filter(function(h) { 66 this.listeners_ = this.listeners_.filter(function(h) {
67 if (h.node == node && (!eventType || (h.eventType == eventType))) { 67 if (h.node == node && (!eventType || (h.eventType == eventType))) {
(...skipping 15 matching lines...) Expand all
83 83
84 /** 84 /**
85 * Remove a single event listener given it's tracking entry. It's up to the 85 * Remove a single event listener given it's tracking entry. It's up to the
86 * caller to ensure the entry is removed from listeners_. 86 * caller to ensure the entry is removed from listeners_.
87 * @param {EventTrackerEntry} h The entry describing the listener to remove. 87 * @param {EventTrackerEntry} h The entry describing the listener to remove.
88 * @private 88 * @private
89 */ 89 */
90 EventTracker.removeEventListener_ = function(h) { 90 EventTracker.removeEventListener_ = function(h) {
91 h.node.removeEventListener(h.eventType, h.listener, h.capture); 91 h.node.removeEventListener(h.eventType, h.listener, h.capture);
92 }; 92 };
OLDNEW
« no previous file with comments | « ui/webui/resources/js/cr/event_target.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698