Permalink
Browse files

Change on 2010/06/16 by nicksantos

        officially deprecate goog.typedef.

        R=arv
        DELTA=21  (2 added, 0 deleted, 19 changed)

Change on 2010/06/16 by djlee

         Clean up a couple warnings in goog.proto2 by adding a typedef.

        R=jschorr
        DELTA=37  (28 added, 0 deleted, 9 changed)

Change on 2010/06/16 by marcosalmeida

        Fix compiler warning.

        R=nicksantos
        DELTA=2  (1 added, 0 deleted, 1 changed)

Change on 2010/06/17 by nicksantos

        Automated rollback.

        *** Reason for rollback ***

        Added Mohamed Mansour's fix from
        http://codereview.appspot.com/1676044/show
        and re-rolled the original popupcolorpicker improvement.

        R=pupius
        DELTA=43  (39 added, 1 deleted, 3 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=29014


git-svn-id: http://closure-library.googlecode.com/svn/trunk@152 0b95b8e8-c90f-11de-9d4f-f947ee5921c8
  • Loading branch information...
nicholas.j.santos
nicholas.j.santos committed Jun 17, 2010
1 parent a3d1bdb commit b170e1ceb86fc92e56933e6daf836afe32604f1d
View
@@ -4,3 +4,4 @@
# Name or Organization <email address>
Google Inc.
+Mohamed Mansour <hello@mohamedmansour.com>
@@ -28,9 +28,9 @@ goog.require('goog.asserts');
/**
- * @type {Array|NodeList|Arguments|{length: number}}
+ * @typedef {Array|NodeList|Arguments|{length: number}}
*/
-goog.array.ArrayLike = goog.typedef;
+goog.array.ArrayLike;
/**
View
@@ -1067,6 +1067,8 @@ goog.globalEval = function(script) {
* definitions with the union of Array and NodeList.
*
* Does nothing in uncompiled code.
+ *
+ * @deprecated Please use the {@code @typedef} annotation.
*/
goog.typedef = true;
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -251,9 +251,10 @@ goog.editor.plugins.TagOnEnterHandler.prototype.
// create two elements. FF just inserts a BR.
// -Hitting enter inside an empty list-item doesn't create a block
// tag. It just splits the list and puts your cursor in the middle.
+ var li = null;
if (wasCollapsed) {
// Only break out of lists for collapsed selections.
- var li = goog.dom.getAncestorByTagNameAndClass(
+ li = goog.dom.getAncestorByTagNameAndClass(
range && range.getContainerElement(), goog.dom.TagName.LI);
}
var isEmptyLi = (li &&
@@ -26,9 +26,9 @@ goog.require('goog.array');
/**
- * @type {goog.iter.Iterator|{length:number}|{__iterator__}}
+ * @typedef {goog.iter.Iterator|{length:number}|{__iterator__}}
*/
-goog.iter.Iterable = goog.typedef;
+goog.iter.Iterable;
// For script engines that already support iterators.
@@ -18,29 +18,57 @@
*/
goog.provide('goog.proto2.Descriptor');
+goog.provide('goog.proto2.Metadata');
goog.require('goog.array');
goog.require('goog.object');
goog.require('goog.proto2.Util');
+/**
+ * @type {{name: (string|undefined),
+ * fullName: (string|undefined),
+ * containingType: (goog.proto2.Message|undefined)}}
+ */
+goog.proto2.Metadata = goog.typedef;
+
/**
* A class which describes a Protocol Buffer 2 Message.
*
* @param {Function} messageType Constructor for the message class that
* this descriptor describes.
- * @param {!Object} metadata The metadata about the message that will be used
- * to construct this descriptor.
+ * @param {!goog.proto2.Metadata} metadata The metadata about the message that
+ * will be used to construct this descriptor.
* @param {Array.<goog.proto2.FieldDescriptor>} fields The fields of the
* message described by this descriptor.
*
* @constructor
*/
goog.proto2.Descriptor = function(messageType, metadata, fields) {
+
+ /**
+ * @type {Function}
+ * @private
+ */
this.messageType_ = messageType;
- this.name_ = metadata.name;
- this.fullName_ = metadata.fullName;
+
+ /**
+ * @type {?string}
+ * @private
+ */
+ this.name_ = metadata.name || null;
+
+ /**
+ * @type {?string}
+ * @private
+ */
+ this.fullName_ = metadata.fullName || null;
+
+ /**
+ * @type {goog.proto2.Message|undefined}
+ * @private
+ */
this.containingType_ = metadata.containingType;
/**
@@ -58,19 +86,19 @@ goog.proto2.Descriptor = function(messageType, metadata, fields) {
/**
- * Returns the name of the message.
+ * Returns the name of the message, if any.
*
- * @return {string} The name.
+ * @return {?string} The name.
*/
goog.proto2.Descriptor.prototype.getName = function() {
return this.name_;
};
/**
- * Returns the full name of the message.
+ * Returns the full name of the message, if any.
*
- * @return {string} The na,e.
+ * @return {?string} The name.
*/
goog.proto2.Descriptor.prototype.getFullName = function() {
return this.fullName_;
@@ -20,9 +20,9 @@ goog.require('goog.testing.stacktrace');
// reimplement the asserters.
/**
- * @type {Array|NodeList|Arguments|{length: number}}
+ * @typedef {Array|NodeList|Arguments|{length: number}}
*/
-goog.testing.asserts.ArrayLike = goog.typedef;
+goog.testing.asserts.ArrayLike;
var DOUBLE_EQUALITY_PREDICATE = function(var1, var2) {
return var1 == var2;
@@ -24,6 +24,6 @@ goog.provide('goog.ui.ControlContent');
/**
* Type declaration for text caption or DOM structure to be used as the content
* of {@link goog.ui.Control}s.
- * @type {string|Node|Array.<Node>|NodeList}
+ * @typedef {string|Node|Array.<Node>|NodeList}
*/
-goog.ui.ControlContent = goog.typedef;
+goog.ui.ControlContent;
@@ -826,13 +826,13 @@ goog.ui.editor.DefaultToolbar.buttons_ = {};
/**
- * @type {{command: string, tooltip: ?string,
+ * @typedef {{command: string, tooltip: ?string,
* caption: ?goog.ui.ControlContent, classes: ?string,
* factory: ?function(string, string, goog.ui.ControlContent, ?string,
* goog.ui.ButtonRenderer, goog.dom.DomHelper):goog.ui.Button,
* queryable:?boolean}}
*/
-goog.ui.editor.ButtonDescriptor = goog.typedef;
+goog.ui.editor.ButtonDescriptor;
/**
@@ -52,6 +52,14 @@ goog.ui.PopupColorPicker = function(opt_domHelper, opt_colorPicker) {
goog.inherits(goog.ui.PopupColorPicker, goog.ui.Component);
+/**
+ * Whether the color picker is initialized.
+ * @type {boolean}
+ * @private
+ */
+goog.ui.PopupColorPicker.prototype.initialized_ = false;
+
+
/**
* Instance of a color picker control.
* @type {goog.ui.ColorPicker}
@@ -138,6 +146,7 @@ goog.ui.PopupColorPicker.prototype.disposeInternal = function() {
goog.ui.PopupColorPicker.superClass_.disposeInternal.call(this);
this.colorPicker_ = null;
this.lastTarget_ = null;
+ this.initialized_ = false;
if (this.popup_) {
this.popup_.dispose();
this.popup_ = null;
@@ -383,14 +392,14 @@ goog.ui.PopupColorPicker.prototype.setPopupCorner = function(corner) {
* @private
*/
goog.ui.PopupColorPicker.prototype.show_ = function(e) {
- if (!this.colorPicker_) {
- this.colorPicker_ =
+ if (!this.initialized_) {
+ this.colorPicker_ = this.colorPicker_ ||
goog.ui.ColorPicker.createSimpleColorGrid(this.getDomHelper());
this.colorPicker_.setFocusable(this.focusable_);
- this.addChild(this.colorPicker_);
- this.colorPicker_.render(this.getElement());
+ this.addChild(this.colorPicker_, true);
this.getHandler().listen(this.colorPicker_,
goog.ui.ColorPicker.EventType.CHANGE, this.onColorPicked_);
+ this.initialized_ = true;
}
if (this.popup_.isOrWasRecentlyVisible() && this.toggleMode_ &&
@@ -11,12 +11,14 @@
<script src="../base.js"></script>
<script>
goog.require('goog.dom');
+ goog.require('goog.testing.events');
goog.require('goog.testing.jsunit');
goog.require('goog.ui.PopupColorPicker');
</script>
</head>
<body>
<div id="containingDiv">
+<a href="javascript:void(0)" id="button1">color picker</a>
<script>
// Unittest to ensure that the popup gets created in createDom().
@@ -36,6 +38,32 @@
assertEquals(containingDiv, picker.getAutoHideRegion());
}
+// Unittest to ensure the popup opens with a custom color picker.
+function testCustomColorPicker() {
+ var button1 = document.getElementById('button1');
+ var domHelper = goog.dom.getDomHelper();
+ var colorPicker = new goog.ui.ColorPicker();
+ colorPicker.setColors(["#ffffff", "#000000"]);
+ var picker = new goog.ui.PopupColorPicker(domHelper, colorPicker);
+ picker.render();
+ picker.attach(button1);
+ assertNotNull(picker.getColorPicker());
+ assertNotNull(picker.getPopup().getElement());
+ assertNull(picker.getSelectedColor());
+
+ var changeEvents = 0;
+ goog.events.listen(picker, goog.ui.ColorPicker.EventType.CHANGE, function(e) {
+ changeEvents++;
+ });
+
+ // Select the first color.
+ goog.testing.events.fireClickSequence(button1);
+ goog.testing.events.fireClickSequence(
+ document.getElementById('goog-palette-cell-0').firstChild);
+ assertEquals("#ffffff", picker.getSelectedColor());
+ assertEquals(1, changeEvents);
+}
+
</script>
</div>
</body>
@@ -485,9 +485,9 @@ goog.uri.utils.assertNoFragmentsOrQueries_ = function(uri) {
* to a string and URI encoded. Array values are expanded into multiple
* &key=value pairs, with each element stringized and URI-encoded.
*
- * @type {*}
+ * @typedef {*}
*/
-goog.uri.utils.QueryValue = goog.typedef;
+goog.uri.utils.QueryValue;
/**
@@ -509,9 +509,9 @@ goog.uri.utils.QueryValue = goog.typedef;
* ];
* </pre>
*
- * @type {!Array.<string|goog.uri.utils.QueryValue>}
+ * @typedef {!Array.<string|goog.uri.utils.QueryValue>}
*/
-goog.uri.utils.QueryArray = goog.typedef;
+goog.uri.utils.QueryArray;
/**

0 comments on commit b170e1c

Please sign in to comment.