diff options
author | arv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-07 23:48:04 +0000 |
---|---|---|
committer | arv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-07 23:48:04 +0000 |
commit | 3d7a219946c1f718357d15cddb954cda5f2c92eb (patch) | |
tree | 5ca44768d03e0b83202cb9f310b1eb94f142e6a4 /chrome/browser/resources | |
parent | 6c2046560b8154ac140ec85465c60354bde17666 (diff) | |
download | chromium_src-3d7a219946c1f718357d15cddb954cda5f2c92eb.zip chromium_src-3d7a219946c1f718357d15cddb954cda5f2c92eb.tar.gz chromium_src-3d7a219946c1f718357d15cddb954cda5f2c92eb.tar.bz2 |
Move cr.Event into cr.js since that file should not depend on any other files.
BUG=None
TEST=Manually ran the js tests
Review URL: http://codereview.chromium.org/2014005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46759 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources')
6 files changed, 30 insertions, 53 deletions
diff --git a/chrome/browser/resources/bookmark_manager/main.html b/chrome/browser/resources/bookmark_manager/main.html index 140b2f6..6630aa9 100644 --- a/chrome/browser/resources/bookmark_manager/main.html +++ b/chrome/browser/resources/bookmark_manager/main.html @@ -19,7 +19,6 @@ found in the LICENSE file. <script src="css/bmm.css.js"></script> <script src="chrome://resources/js/cr.js"></script> -<script src="chrome://resources/js/cr/event.js"></script> <script src="chrome://resources/js/cr/event_target.js"></script> <script src="chrome://resources/js/cr/link_controller.js"></script> <script src="chrome://resources/js/cr/promise.js"></script> diff --git a/chrome/browser/resources/shared/js/cr.js b/chrome/browser/resources/shared/js/cr.js index 9de94da..1bd1b48 100644 --- a/chrome/browser/resources/shared/js/cr.js +++ b/chrome/browser/resources/shared/js/cr.js @@ -38,6 +38,31 @@ const cr = (function() { return cur; }; + // 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; + + /** + * Creates a new event to be used with cr.EventTarget or DOM EventTarget + * objects. + * @param {string} type The name of the event. + * @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 CrEvent(type, opt_bubbles, opt_preventable) { + var e = cr.doc.createEvent('Event'); + e.initEvent(type, !!opt_bubbles, !!opt_preventable); + e.__proto__ = CrEvent.prototype; + return e; + } + + CrEvent.prototype = { + __proto__: DomEvent.prototype + }; + /** * Fires a property change event on the target. * @param {EventTarget} target The target to dispatch the event on. @@ -46,8 +71,7 @@ const cr = (function() { * @param {*} oldValue The old value for the property. */ function dispatchPropertyChange(target, propertyName, newValue, oldValue) { - // TODO(arv): Depending on cr.Event here is a bit ugly. - var e = new cr.Event(propertyName + 'Change'); + var e = new CrEvent(propertyName + 'Change'); e.propertyName = propertyName; e.newValue = newValue; e.oldValue = oldValue; @@ -309,6 +333,7 @@ const cr = (function() { get doc() { return doc; }, - withDoc: withDoc + withDoc: withDoc, + Event: CrEvent }; })(); diff --git a/chrome/browser/resources/shared/js/cr/event.js b/chrome/browser/resources/shared/js/cr/event.js deleted file mode 100644 index a02a1f3..0000000 --- a/chrome/browser/resources/shared/js/cr/event.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -/** - * @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 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; - - /** - * Creates a new event to be used with cr.EventTarget or DOM EventTarget - * objects. - * @param {string} type The name of the event. - * @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 CrEvent(type, opt_bubbles, opt_preventable) { - var e = cr.doc.createEvent('Event'); - e.initEvent(type, !!opt_bubbles, !!opt_preventable); - e.__proto__ = CrEvent.prototype; - return e; - } - - CrEvent.prototype = { - __proto__: DomEvent.prototype - }; - - // Export - return { - Event: CrEvent - }; -}); diff --git a/chrome/browser/resources/shared/js/cr/event_target_test.html b/chrome/browser/resources/shared/js/cr/event_target_test.html index 998e7f1..ec5f2f6 100644 --- a/chrome/browser/resources/shared/js/cr/event_target_test.html +++ b/chrome/browser/resources/shared/js/cr/event_target_test.html @@ -5,8 +5,7 @@ tests --> <script src="http://closure-library.googlecode.com/svn/trunk/closure/goog/base.js"></script> <script src="../cr.js"></script> -<script src="event.js"></script> -<script src="eventtarget.js"></script> +<script src="event_target.js"></script> <script> goog.require('goog.testing.jsunit'); @@ -20,7 +19,6 @@ const EventTarget = cr.EventTarget; const Event = cr.Event; function testFunctionListener() { - debugger; var fi = 0; function f(e) { fi++; diff --git a/chrome/browser/resources/shared/js/cr/promise_test.html b/chrome/browser/resources/shared/js/cr/promise_test.html index 5c9ae1d..147d8ab 100644 --- a/chrome/browser/resources/shared/js/cr/promise_test.html +++ b/chrome/browser/resources/shared/js/cr/promise_test.html @@ -6,7 +6,6 @@ <script src="http://closure-library.googlecode.com/svn/trunk/closure/goog/base.js"></script> <script src="../cr.js"></script> <script src="promise.js"></script> -<script src="event.js"></script> <script> goog.require('goog.testing.jsunit'); diff --git a/chrome/browser/resources/shared/js/cr_test.html b/chrome/browser/resources/shared/js/cr_test.html index 5d6c16e..8514216 100644 --- a/chrome/browser/resources/shared/js/cr_test.html +++ b/chrome/browser/resources/shared/js/cr_test.html @@ -7,8 +7,7 @@ </style> <script src="http://closure-library.googlecode.com/svn/trunk/closure/goog/base.js"></script> <script src="cr.js"></script> -<script src="cr/event.js"></script> -<script src="cr/eventtarget.js"></script> +<script src="cr/event_target.js"></script> <script> goog.require('goog.testing.jsunit'); |