summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorarv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-23 00:18:12 +0000
committerarv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-23 00:18:12 +0000
commitd74028f91ac301d74c684ca155ace697a74d56d0 (patch)
treeb89efe4c646c570cb34293a9b1f343dfb8fc4a66 /chrome
parent89a72ffa5d02af0c1fa66d31bf5f01c181f93c24 (diff)
downloadchromium_src-d74028f91ac301d74c684ca155ace697a74d56d0.zip
chromium_src-d74028f91ac301d74c684ca155ace697a74d56d0.tar.gz
chromium_src-d74028f91ac301d74c684ca155ace697a74d56d0.tar.bz2
Bookmark manager js lib: Some cleanup of the event class docs.
BUG=None TEST=None Review URL: http://codereview.chromium.org/1141007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42293 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/resources/bookmark_manager/js/cr/event.js25
-rw-r--r--chrome/browser/resources/bookmark_manager/js/cr/eventtarget.js14
2 files changed, 25 insertions, 14 deletions
diff --git a/chrome/browser/resources/bookmark_manager/js/cr/event.js b/chrome/browser/resources/bookmark_manager/js/cr/event.js
index 19fee7e..a02a1f3 100644
--- a/chrome/browser/resources/bookmark_manager/js/cr/event.js
+++ b/chrome/browser/resources/bookmark_manager/js/cr/event.js
@@ -3,15 +3,15 @@
// found in the LICENSE file.
/**
- * @fileoverview This is a simple pure JS event class that can be used with
- * {@code cr.ui.EventTarget}. It should not be used with DOM EventTargets.
+ * @fileoverview This provides a nicer way to create events than what DOM
+ * provides. These events can be used with DOM EventTarget interfaces as well
+ * as with {@code cr.EventTarget}.
*/
cr.define('cr', function() {
- // cr.Event is called CustomEvent in here to prevent naming conflicts. We
- // alse store the original Event in case someone does a global alias of
- // cr.Event.
+ // cr.Event is called CrEvent in here to prevent naming conflicts. We also
+ // store the original Event in case someone does a global alias of cr.Event.
const DomEvent = Event;
@@ -19,22 +19,25 @@ cr.define('cr', function() {
* Creates a new event to be used with cr.EventTarget or DOM EventTarget
* objects.
* @param {string} type The name of the event.
- * @param {boolean=}
+ * @param {boolean=} opt_bubbles Whether the event bubbles. Default is false.
+ * @param {boolean=} opt_preventable Whether the default action of the event
+ * can be prevented.
* @constructor
+ * @extends {DomEvent}
*/
- function CustomEvent(type, opt_bubbles, opt_capture) {
+ function CrEvent(type, opt_bubbles, opt_preventable) {
var e = cr.doc.createEvent('Event');
- e.initEvent(type, !!opt_bubbles, !!opt_capture);
- e.__proto__ = CustomEvent.prototype;
+ e.initEvent(type, !!opt_bubbles, !!opt_preventable);
+ e.__proto__ = CrEvent.prototype;
return e;
}
- CustomEvent.prototype = {
+ CrEvent.prototype = {
__proto__: DomEvent.prototype
};
// Export
return {
- Event: CustomEvent
+ Event: CrEvent
};
});
diff --git a/chrome/browser/resources/bookmark_manager/js/cr/eventtarget.js b/chrome/browser/resources/bookmark_manager/js/cr/eventtarget.js
index f2bc733..5bcb41d 100644
--- a/chrome/browser/resources/bookmark_manager/js/cr/eventtarget.js
+++ b/chrome/browser/resources/bookmark_manager/js/cr/eventtarget.js
@@ -2,10 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-cr.define('cr', function() {
+/**
+ * @fileoverview This contains an implementation of the EventTarget interface
+ * as defined by DOM Level 2 Events.
+ */
- // TODO(arv): object.handleEvent
+cr.define('cr', function() {
+ /**
+ * Creates a new EventTarget. This class implements the DOM level 2
+ * EventTarget interface and can be used wherever those are used.
+ * @constructor
+ */
function EventTarget() {
}
@@ -19,7 +27,7 @@ cr.define('cr', function() {
*/
addEventListener: function(type, handler) {
if (!this.listeners_)
- this.listeners_ = {__proto__: null};
+ this.listeners_ = Object.create(null);
if (!(type in this.listeners_)) {
this.listeners_[type] = [handler];
} else {