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

Unified Diff: ui/webui/resources/js/cr/ui/position_util.js

Issue 454223004: Typecheck JS files for chrome://history (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@B_download
Patch Set: fixed issues Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: ui/webui/resources/js/cr/ui/position_util.js
diff --git a/ui/webui/resources/js/cr/ui/position_util.js b/ui/webui/resources/js/cr/ui/position_util.js
index c3e7f11ca62efcf77214abd5699011082ee98cdd..0a1c09e1e033b9ac0e769642866196c5a91f5090 100644
--- a/ui/webui/resources/js/cr/ui/position_util.js
+++ b/ui/webui/resources/js/cr/ui/position_util.js
@@ -6,55 +6,56 @@
* @fileoverview This file provides utility functions for position popups.
*/
-cr.define('cr.ui', function() {
+cr.exportPath('cr.ui');
+
+/**
+ * Type def for rects as returned by getBoundingClientRect.
+ * @typedef {{left: number, top: number, width: number, height: number,
+ * right: number, bottom: number}}
+ */
+cr.ui.Rect;
+/**
+ * Enum for defining how to anchor a popup to an anchor element.
+ * @enum {number}
+ */
+cr.ui.AnchorType = {
/**
- * Type def for rects as returned by getBoundingClientRect.
- * @typedef { {left: number, top: number, width: number, height: number,
- * right: number, bottom: number}}
+ * The popup's right edge is aligned with the left edge of the anchor.
+ * The popup's top edge is aligned with the top edge of the anchor.
*/
- var Rect;
+ BEFORE: 1, // p: right, a: left, p: top, a: top
/**
- * Enum for defining how to anchor a popup to an anchor element.
- * @enum {number}
+ * The popop's left edge is aligned with the right edge of the anchor.
+ * The popup's top edge is aligned with the top edge of the anchor.
*/
- var AnchorType = {
- /**
- * The popup's right edge is aligned with the left edge of the anchor.
- * The popup's top edge is aligned with the top edge of the anchor.
- */
- BEFORE: 1, // p: right, a: left, p: top, a: top
-
- /**
- * The popop's left edge is aligned with the right edge of the anchor.
- * The popup's top edge is aligned with the top edge of the anchor.
- */
- AFTER: 2, // p: left a: right, p: top, a: top
-
- /**
- * The popop's bottom edge is aligned with the top edge of the anchor.
- * The popup's left edge is aligned with the left edge of the anchor.
- */
- ABOVE: 3, // p: bottom, a: top, p: left, a: left
-
- /**
- * The popop's top edge is aligned with the bottom edge of the anchor.
- * The popup's left edge is aligned with the left edge of the anchor.
- */
- BELOW: 4 // p: top, a: bottom, p: left, a: left
- };
+ AFTER: 2, // p: left a: right, p: top, a: top
/**
+ * The popop's bottom edge is aligned with the top edge of the anchor.
+ * The popup's left edge is aligned with the left edge of the anchor.
+ */
+ ABOVE: 3, // p: bottom, a: top, p: left, a: left
+
+ /**
+ * The popop's top edge is aligned with the bottom edge of the anchor.
+ * The popup's left edge is aligned with the left edge of the anchor.
+ */
+ BELOW: 4 // p: top, a: bottom, p: left, a: left
+};
+
+cr.define('cr.ui', function() {
+ /**
* Helper function for positionPopupAroundElement and positionPopupAroundRect.
- * @param {!Rect} anchorRect The rect for the anchor.
+ * @param {!cr.ui.Rect} anchorRect The rect for the anchor.
* @param {!HTMLElement} popupElement The element used for the popup.
- * @param {AnchorType} type The type of anchoring to do.
- * @param {boolean} invertLeftRight Whether to invert the right/left
+ * @param {cr.ui.AnchorType} type The type of anchoring to do.
+ * @param {boolean=} opt_invertLeftRight Whether to invert the right/left
* alignment.
*/
function positionPopupAroundRect(anchorRect, popupElement, type,
- invertLeftRight) {
+ opt_invertLeftRight) {
var popupRect = popupElement.getBoundingClientRect();
var availRect;
var ownerDoc = popupElement.ownerDocument;
@@ -77,10 +78,10 @@ cr.define('cr.ui', function() {
}
if (cs.direction == 'rtl')
- invertLeftRight = !invertLeftRight;
+ opt_invertLeftRight = !opt_invertLeftRight;
// Flip BEFORE, AFTER based on alignment.
- if (invertLeftRight) {
+ if (opt_invertLeftRight) {
if (type == AnchorType.BEFORE)
type = AnchorType.AFTER;
else if (type == AnchorType.AFTER)
@@ -152,7 +153,7 @@ cr.define('cr.ui', function() {
switch (type) {
case AnchorType.BELOW:
case AnchorType.ABOVE:
- if (invertLeftRight) {
+ if (opt_invertLeftRight) {
// align right edges
if (anchorRect.right - popupRect.width >= 0) {
style.right = availRect.width - anchorRect.right + 'px';
@@ -206,7 +207,7 @@ cr.define('cr.ui', function() {
* @param {!HTMLElement} anchorElement The element that the popup is anchored
* to.
* @param {!HTMLElement} popupElement The popup element we are positioning.
- * @param {AnchorType} type The type of anchoring we want.
+ * @param {cr.ui.AnchorType} type The type of anchoring we want.
* @param {boolean} invertLeftRight Whether to invert the right/left
* alignment.
*/

Powered by Google App Engine
This is Rietveld 408576698