Update wmts-hidpi, add nicer-api-docs

This commit is contained in:
Andreas Hocevar
2014-05-06 13:02:46 -05:00
parent b3ac1afd00
commit 1e25fc5585
2239 changed files with 3726515 additions and 37010 deletions

View File

@@ -0,0 +1,74 @@
// Copyright 2006 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* @fileoverview Client viewport positioning class.
*
*/
goog.provide('goog.positioning.AbsolutePosition');
goog.require('goog.math.Box');
goog.require('goog.math.Coordinate');
goog.require('goog.math.Size');
goog.require('goog.positioning');
goog.require('goog.positioning.AbstractPosition');
/**
* Encapsulates a popup position where the popup absolutely positioned by
* setting the left/top style elements directly to the specified values.
* The position is generally relative to the element's offsetParent. Normally,
* this is the document body, but can be another element if the popup element
* is scoped by an element with relative position.
*
* @param {number|!goog.math.Coordinate} arg1 Left position or coordinate.
* @param {number=} opt_arg2 Top position.
* @constructor
* @extends {goog.positioning.AbstractPosition}
*/
goog.positioning.AbsolutePosition = function(arg1, opt_arg2) {
/**
* Coordinate to position popup at.
* @type {goog.math.Coordinate}
*/
this.coordinate = arg1 instanceof goog.math.Coordinate ? arg1 :
new goog.math.Coordinate(/** @type {number} */ (arg1), opt_arg2);
};
goog.inherits(goog.positioning.AbsolutePosition,
goog.positioning.AbstractPosition);
/**
* Repositions the popup according to the current state.
*
* @param {Element} movableElement The DOM element to position.
* @param {goog.positioning.Corner} movableCorner The corner of the movable
* element that should be positioned at the specified position.
* @param {goog.math.Box=} opt_margin A margin specified in pixels.
* @param {goog.math.Size=} opt_preferredSize Prefered size of the
* movableElement.
* @override
*/
goog.positioning.AbsolutePosition.prototype.reposition = function(
movableElement, movableCorner, opt_margin, opt_preferredSize) {
goog.positioning.positionAtCoordinate(this.coordinate,
movableElement,
movableCorner,
opt_margin,
null,
null,
opt_preferredSize);
};

View File

@@ -0,0 +1,48 @@
// Copyright 2006 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* @fileoverview Abstract base class for positioning implementations.
*
* @author eae@google.com (Emil A Eklund)
*/
goog.provide('goog.positioning.AbstractPosition');
goog.require('goog.math.Box');
goog.require('goog.math.Size');
goog.require('goog.positioning.Corner');
/**
* Abstract position object. Encapsulates position and overflow handling.
*
* @constructor
*/
goog.positioning.AbstractPosition = function() {};
/**
* Repositions the element. Abstract method, should be overloaded.
*
* @param {Element} movableElement Element to position.
* @param {goog.positioning.Corner} corner Corner of the movable element that
* should be positioned adjacent to the anchored element.
* @param {goog.math.Box=} opt_margin A margin specified in pixels.
* @param {goog.math.Size=} opt_preferredSize PreferredSize of the
* movableElement.
*/
goog.positioning.AbstractPosition.prototype.reposition =
function(movableElement, corner, opt_margin, opt_preferredSize) { };

View File

@@ -0,0 +1,92 @@
// Copyright 2006 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* @fileoverview Client positioning class.
*
*/
goog.provide('goog.positioning.AnchoredPosition');
goog.require('goog.math.Box');
goog.require('goog.positioning');
goog.require('goog.positioning.AbstractPosition');
/**
* Encapsulates a popup position where the popup is anchored at a corner of
* an element.
*
* When using AnchoredPosition, it is recommended that the popup element
* specified in the Popup constructor or Popup.setElement be absolutely
* positioned.
*
* @param {Element} anchorElement Element the movable element should be
* anchored against.
* @param {goog.positioning.Corner} corner Corner of anchored element the
* movable element should be positioned at.
* @param {number=} opt_overflow Overflow handling mode. Defaults to IGNORE if
* not specified. Bitmap, {@see goog.positioning.Overflow}.
* @constructor
* @extends {goog.positioning.AbstractPosition}
*/
goog.positioning.AnchoredPosition = function(anchorElement,
corner,
opt_overflow) {
/**
* Element the movable element should be anchored against.
* @type {Element}
*/
this.element = anchorElement;
/**
* Corner of anchored element the movable element should be positioned at.
* @type {goog.positioning.Corner}
*/
this.corner = corner;
/**
* Overflow handling mode. Defaults to IGNORE if not specified.
* Bitmap, {@see goog.positioning.Overflow}.
* @type {number|undefined}
* @private
*/
this.overflow_ = opt_overflow;
};
goog.inherits(goog.positioning.AnchoredPosition,
goog.positioning.AbstractPosition);
/**
* Repositions the movable element.
*
* @param {Element} movableElement Element to position.
* @param {goog.positioning.Corner} movableCorner Corner of the movable element
* that should be positioned adjacent to the anchored element.
* @param {goog.math.Box=} opt_margin A margin specifin pixels.
* @param {goog.math.Size=} opt_preferredSize PreferredSize of the
* movableElement (unused in this class).
* @override
*/
goog.positioning.AnchoredPosition.prototype.reposition = function(
movableElement, movableCorner, opt_margin, opt_preferredSize) {
goog.positioning.positionAtAnchor(this.element,
this.corner,
movableElement,
movableCorner,
undefined,
opt_margin,
this.overflow_);
};

View File

@@ -0,0 +1,191 @@
// Copyright 2006 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* @fileoverview Anchored viewport positioning class.
*
* @author eae@google.com (Emil A Eklund)
*/
goog.provide('goog.positioning.AnchoredViewportPosition');
goog.require('goog.math.Box');
goog.require('goog.positioning');
goog.require('goog.positioning.AnchoredPosition');
goog.require('goog.positioning.Corner');
goog.require('goog.positioning.Overflow');
goog.require('goog.positioning.OverflowStatus');
/**
* Encapsulates a popup position where the popup is anchored at a corner of
* an element. The corners are swapped if dictated by the viewport. For instance
* if a popup is anchored with its top left corner to the bottom left corner of
* the anchor the popup is either displayed below the anchor (as specified) or
* above it if there's not enough room to display it below.
*
* When using this positioning object it's recommended that the movable element
* be absolutely positioned.
*
* @param {Element} anchorElement Element the movable element should be
* anchored against.
* @param {goog.positioning.Corner} corner Corner of anchored element the
* movable element should be positioned at.
* @param {boolean=} opt_adjust Whether the positioning should be adjusted until
* the element fits inside the viewport even if that means that the anchored
* corners are ignored.
* @param {goog.math.Box=} opt_overflowConstraint Box object describing the
* dimensions in which the movable element could be shown.
* @constructor
* @extends {goog.positioning.AnchoredPosition}
*/
goog.positioning.AnchoredViewportPosition = function(anchorElement,
corner,
opt_adjust,
opt_overflowConstraint) {
goog.positioning.AnchoredPosition.call(this, anchorElement, corner);
/**
* The last resort algorithm to use if the algorithm can't fit inside
* the viewport.
*
* IGNORE = do nothing, just display at the preferred position.
*
* ADJUST_X | ADJUST_Y = Adjust until the element fits, even if that means
* that the anchored corners are ignored.
*
* @type {number}
* @private
*/
this.lastResortOverflow_ = opt_adjust ?
(goog.positioning.Overflow.ADJUST_X |
goog.positioning.Overflow.ADJUST_Y) :
goog.positioning.Overflow.IGNORE;
/**
* The dimensions in which the movable element could be shown.
* @type {goog.math.Box|undefined}
* @private
*/
this.overflowConstraint_ = opt_overflowConstraint || undefined;
};
goog.inherits(goog.positioning.AnchoredViewportPosition,
goog.positioning.AnchoredPosition);
/**
* @return {goog.math.Box|undefined} The box object describing the
* dimensions in which the movable element will be shown.
*/
goog.positioning.AnchoredViewportPosition.prototype.getOverflowConstraint =
function() {
return this.overflowConstraint_;
};
/**
* @param {goog.math.Box|undefined} overflowConstraint Box object describing the
* dimensions in which the movable element could be shown.
*/
goog.positioning.AnchoredViewportPosition.prototype.setOverflowConstraint =
function(overflowConstraint) {
this.overflowConstraint_ = overflowConstraint;
};
/**
* @return {number} A bitmask for the "last resort" overflow.
*/
goog.positioning.AnchoredViewportPosition.prototype.getLastResortOverflow =
function() {
return this.lastResortOverflow_;
};
/**
* @param {number} lastResortOverflow A bitmask for the "last resort" overflow,
* if we fail to fit the element on-screen.
*/
goog.positioning.AnchoredViewportPosition.prototype.setLastResortOverflow =
function(lastResortOverflow) {
this.lastResortOverflow_ = lastResortOverflow;
};
/**
* Repositions the movable element.
*
* @param {Element} movableElement Element to position.
* @param {goog.positioning.Corner} movableCorner Corner of the movable element
* that should be positioned adjacent to the anchored element.
* @param {goog.math.Box=} opt_margin A margin specified in pixels.
* @param {goog.math.Size=} opt_preferredSize The preferred size of the
* movableElement.
* @override
*/
goog.positioning.AnchoredViewportPosition.prototype.reposition = function(
movableElement, movableCorner, opt_margin, opt_preferredSize) {
var status = goog.positioning.positionAtAnchor(this.element, this.corner,
movableElement, movableCorner, null, opt_margin,
goog.positioning.Overflow.FAIL_X | goog.positioning.Overflow.FAIL_Y,
opt_preferredSize, this.overflowConstraint_);
// If the desired position is outside the viewport try mirroring the corners
// horizontally or vertically.
if (status & goog.positioning.OverflowStatus.FAILED) {
var cornerFallback = this.adjustCorner(status, this.corner);
var movableCornerFallback = this.adjustCorner(status, movableCorner);
status = goog.positioning.positionAtAnchor(this.element, cornerFallback,
movableElement, movableCornerFallback, null, opt_margin,
goog.positioning.Overflow.FAIL_X | goog.positioning.Overflow.FAIL_Y,
opt_preferredSize, this.overflowConstraint_);
if (status & goog.positioning.OverflowStatus.FAILED) {
// If that also fails, pick the best corner from the two tries,
// and adjust the position until it fits.
cornerFallback = this.adjustCorner(status, cornerFallback);
movableCornerFallback = this.adjustCorner(
status, movableCornerFallback);
goog.positioning.positionAtAnchor(this.element, cornerFallback,
movableElement, movableCornerFallback, null, opt_margin,
this.getLastResortOverflow(), opt_preferredSize,
this.overflowConstraint_);
}
}
};
/**
* Adjusts the corner if X or Y positioning failed.
* @param {number} status The status of the last positionAtAnchor call.
* @param {goog.positioning.Corner} corner The corner to adjust.
* @return {goog.positioning.Corner} The adjusted corner.
* @protected
*/
goog.positioning.AnchoredViewportPosition.prototype.adjustCorner = function(
status, corner) {
if (status & goog.positioning.OverflowStatus.FAILED_HORIZONTAL) {
corner = goog.positioning.flipCornerHorizontal(corner);
}
if (status & goog.positioning.OverflowStatus.FAILED_VERTICAL) {
corner = goog.positioning.flipCornerVertical(corner);
}
return corner;
};

View File

@@ -0,0 +1,88 @@
// Copyright 2006 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* @fileoverview Client positioning class.
*
*/
goog.provide('goog.positioning.ClientPosition');
goog.require('goog.asserts');
goog.require('goog.math.Box');
goog.require('goog.math.Coordinate');
goog.require('goog.math.Size');
goog.require('goog.positioning');
goog.require('goog.positioning.AbstractPosition');
goog.require('goog.style');
/**
* Encapsulates a popup position where the popup is positioned relative to the
* window (client) coordinates. This calculates the correct position to
* use even if the element is relatively positioned to some other element. This
* is for trying to position an element at the spot of the mouse cursor in
* a MOUSEMOVE event. Just use the event.clientX and event.clientY as the
* parameters.
*
* @param {number|goog.math.Coordinate} arg1 Left position or coordinate.
* @param {number=} opt_arg2 Top position.
* @constructor
* @extends {goog.positioning.AbstractPosition}
*/
goog.positioning.ClientPosition = function(arg1, opt_arg2) {
/**
* Coordinate to position popup at.
* @type {goog.math.Coordinate}
*/
this.coordinate = arg1 instanceof goog.math.Coordinate ? arg1 :
new goog.math.Coordinate(/** @type {number} */ (arg1), opt_arg2);
};
goog.inherits(goog.positioning.ClientPosition,
goog.positioning.AbstractPosition);
/**
* Repositions the popup according to the current state
*
* @param {Element} movableElement The DOM element of the popup.
* @param {goog.positioning.Corner} movableElementCorner The corner of
* the popup element that that should be positioned adjacent to
* the anchorElement. One of the goog.positioning.Corner
* constants.
* @param {goog.math.Box=} opt_margin A margin specified in pixels.
* @param {goog.math.Size=} opt_preferredSize Preferred size of the element.
* @override
*/
goog.positioning.ClientPosition.prototype.reposition = function(
movableElement, movableElementCorner, opt_margin, opt_preferredSize) {
goog.asserts.assert(movableElement);
// Translates the coordinate to be relative to the page.
var viewportOffset = goog.style.getViewportPageOffset(
goog.dom.getOwnerDocument(movableElement));
var x = this.coordinate.x + viewportOffset.x;
var y = this.coordinate.y + viewportOffset.y;
// Translates the coordinate to be relative to the offset parent.
var movableParentTopLeft =
goog.positioning.getOffsetParentPageOffset(movableElement);
x -= movableParentTopLeft.x;
y -= movableParentTopLeft.y;
goog.positioning.positionAtCoordinate(
new goog.math.Coordinate(x, y), movableElement, movableElementCorner,
opt_margin, null, null, opt_preferredSize);
};

View File

@@ -0,0 +1,122 @@
// Copyright 2012 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* Tests for {@code goog.positioning.ClientPosition}
*/
goog.provide('goog.positioning.clientPositionTest');
goog.setTestOnly('goog.positioning.clientPositionTest');
goog.require('goog.dom');
goog.require('goog.positioning.ClientPosition');
goog.require('goog.style');
goog.require('goog.testing.jsunit');
/**
* Prefabricated popup element for convenient. This is created during
* setUp and is not attached to the document at the beginning of the
* test.
* @type {Element}
*/
var popupElement;
var testArea;
var POPUP_HEIGHT = 100;
var POPUP_WIDTH = 150;
function setUp() {
testArea = goog.dom.getElement('test-area');
// Enlarges the test area to 5000x5000px so that we can be confident
// that scrolling the document to some small (x,y) value would work.
goog.style.setSize(testArea, 5000, 5000);
window.scrollTo(0, 0);
popupElement = goog.dom.createDom('div');
goog.style.setSize(popupElement, POPUP_WIDTH, POPUP_HEIGHT);
popupElement.style.position = 'absolute';
// For ease of debugging.
popupElement.style.background = 'blue';
}
function tearDown() {
popupElement = null;
testArea.innerHTML = '';
testArea.setAttribute('style', '');
}
function testClientPositionWithZeroViewportOffset() {
goog.dom.appendChild(testArea, popupElement);
var x = 300;
var y = 200;
var pos = new goog.positioning.ClientPosition(x, y);
pos.reposition(popupElement, goog.positioning.Corner.TOP_LEFT);
assertPageOffset(x, y, popupElement);
pos.reposition(popupElement, goog.positioning.Corner.TOP_RIGHT);
assertPageOffset(x - POPUP_WIDTH, y, popupElement);
pos.reposition(popupElement, goog.positioning.Corner.BOTTOM_LEFT);
assertPageOffset(x, y - POPUP_HEIGHT, popupElement);
pos.reposition(popupElement, goog.positioning.Corner.BOTTOM_RIGHT);
assertPageOffset(x - POPUP_WIDTH, y - POPUP_HEIGHT, popupElement);
}
function testClientPositionWithSomeViewportOffset() {
goog.dom.appendChild(testArea, popupElement);
var x = 300;
var y = 200;
var scrollX = 135;
var scrollY = 270;
window.scrollTo(scrollX, scrollY);
var pos = new goog.positioning.ClientPosition(x, y);
pos.reposition(popupElement, goog.positioning.Corner.TOP_LEFT);
assertPageOffset(scrollX + x, scrollY + y, popupElement);
}
function testClientPositionWithPositionContext() {
var contextAbsoluteX = 90;
var contextAbsoluteY = 110;
var x = 300;
var y = 200;
var contextElement = goog.dom.createDom('div', undefined, popupElement);
goog.style.setPosition(contextElement, contextAbsoluteX, contextAbsoluteY);
contextElement.style.position = 'absolute';
goog.dom.appendChild(testArea, contextElement);
var pos = new goog.positioning.ClientPosition(x, y);
pos.reposition(popupElement, goog.positioning.Corner.TOP_LEFT);
assertPageOffset(x, y, popupElement);
}
function assertPageOffset(expectedX, expectedY, el) {
var offsetCoordinate = goog.style.getPageOffset(el);
assertEquals('x-coord page offset is wrong.', expectedX, offsetCoordinate.x);
assertEquals('y-coord page offset is wrong.', expectedY, offsetCoordinate.y);
}

View File

@@ -0,0 +1,71 @@
// Copyright 2006 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* @fileoverview Anchored viewport positioning class with both adjust and
* resize options for the popup.
*
* @author eae@google.com (Emil A Eklund)
* @author tildahl@google.com (Michael Tildahl)
*/
goog.provide('goog.positioning.MenuAnchoredPosition');
goog.require('goog.math.Box');
goog.require('goog.math.Size');
goog.require('goog.positioning');
goog.require('goog.positioning.AnchoredViewportPosition');
goog.require('goog.positioning.Corner');
goog.require('goog.positioning.Overflow');
/**
* Encapsulates a popup position where the popup is anchored at a corner of
* an element. The positioning behavior changes based on the values of
* opt_adjust and opt_resize.
*
* When using this positioning object it's recommended that the movable element
* be absolutely positioned.
*
* @param {Element} anchorElement Element the movable element should be
* anchored against.
* @param {goog.positioning.Corner} corner Corner of anchored element the
* movable element should be positioned at.
* @param {boolean=} opt_adjust Whether the positioning should be adjusted until
* the element fits inside the viewport even if that means that the anchored
* corners are ignored.
* @param {boolean=} opt_resize Whether the positioning should be adjusted until
* the element fits inside the viewport on the X axis and its height is
* resized so if fits in the viewport. This take precedence over opt_adjust.
* @constructor
* @extends {goog.positioning.AnchoredViewportPosition}
*/
goog.positioning.MenuAnchoredPosition = function(anchorElement,
corner,
opt_adjust,
opt_resize) {
goog.positioning.AnchoredViewportPosition.call(this, anchorElement, corner,
opt_adjust || opt_resize);
if (opt_adjust || opt_resize) {
var overflowX = goog.positioning.Overflow.ADJUST_X_EXCEPT_OFFSCREEN;
var overflowY = opt_resize ?
goog.positioning.Overflow.RESIZE_HEIGHT :
goog.positioning.Overflow.ADJUST_Y_EXCEPT_OFFSCREEN;
this.setLastResortOverflow(overflowX | overflowY);
}
};
goog.inherits(goog.positioning.MenuAnchoredPosition,
goog.positioning.AnchoredViewportPosition);

View File

@@ -0,0 +1,557 @@
// Copyright 2006 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* @fileoverview Common positioning code.
*
*/
goog.provide('goog.positioning');
goog.provide('goog.positioning.Corner');
goog.provide('goog.positioning.CornerBit');
goog.provide('goog.positioning.Overflow');
goog.provide('goog.positioning.OverflowStatus');
goog.require('goog.asserts');
goog.require('goog.dom');
goog.require('goog.dom.TagName');
goog.require('goog.math.Box');
goog.require('goog.math.Coordinate');
goog.require('goog.math.Size');
goog.require('goog.style');
goog.require('goog.style.bidi');
/**
* Enum for representing an element corner for positioning the popup.
*
* The START constants map to LEFT if element directionality is left
* to right and RIGHT if the directionality is right to left.
* Likewise END maps to RIGHT or LEFT depending on the directionality.
*
* @enum {number}
*/
goog.positioning.Corner = {
TOP_LEFT: 0,
TOP_RIGHT: 2,
BOTTOM_LEFT: 1,
BOTTOM_RIGHT: 3,
TOP_START: 4,
TOP_END: 6,
BOTTOM_START: 5,
BOTTOM_END: 7
};
/**
* Enum for bits in the {@see goog.positioning.Corner) bitmap.
*
* @enum {number}
*/
goog.positioning.CornerBit = {
BOTTOM: 1,
RIGHT: 2,
FLIP_RTL: 4
};
/**
* Enum for representing position handling in cases where the element would be
* positioned outside the viewport.
*
* @enum {number}
*/
goog.positioning.Overflow = {
/** Ignore overflow */
IGNORE: 0,
/** Try to fit horizontally in the viewport at all costs. */
ADJUST_X: 1,
/** If the element can't fit horizontally, report positioning failure. */
FAIL_X: 2,
/** Try to fit vertically in the viewport at all costs. */
ADJUST_Y: 4,
/** If the element can't fit vertically, report positioning failure. */
FAIL_Y: 8,
/** Resize the element's width to fit in the viewport. */
RESIZE_WIDTH: 16,
/** Resize the element's height to fit in the viewport. */
RESIZE_HEIGHT: 32,
/**
* If the anchor goes off-screen in the x-direction, position the movable
* element off-screen. Otherwise, try to fit horizontally in the viewport.
*/
ADJUST_X_EXCEPT_OFFSCREEN: 64 | 1,
/**
* If the anchor goes off-screen in the y-direction, position the movable
* element off-screen. Otherwise, try to fit vertically in the viewport.
*/
ADJUST_Y_EXCEPT_OFFSCREEN: 128 | 4
};
/**
* Enum for representing the outcome of a positioning call.
*
* @enum {number}
*/
goog.positioning.OverflowStatus = {
NONE: 0,
ADJUSTED_X: 1,
ADJUSTED_Y: 2,
WIDTH_ADJUSTED: 4,
HEIGHT_ADJUSTED: 8,
FAILED_LEFT: 16,
FAILED_RIGHT: 32,
FAILED_TOP: 64,
FAILED_BOTTOM: 128,
FAILED_OUTSIDE_VIEWPORT: 256
};
/**
* Shorthand to check if a status code contains any fail code.
* @type {number}
*/
goog.positioning.OverflowStatus.FAILED =
goog.positioning.OverflowStatus.FAILED_LEFT |
goog.positioning.OverflowStatus.FAILED_RIGHT |
goog.positioning.OverflowStatus.FAILED_TOP |
goog.positioning.OverflowStatus.FAILED_BOTTOM |
goog.positioning.OverflowStatus.FAILED_OUTSIDE_VIEWPORT;
/**
* Shorthand to check if horizontal positioning failed.
* @type {number}
*/
goog.positioning.OverflowStatus.FAILED_HORIZONTAL =
goog.positioning.OverflowStatus.FAILED_LEFT |
goog.positioning.OverflowStatus.FAILED_RIGHT;
/**
* Shorthand to check if vertical positioning failed.
* @type {number}
*/
goog.positioning.OverflowStatus.FAILED_VERTICAL =
goog.positioning.OverflowStatus.FAILED_TOP |
goog.positioning.OverflowStatus.FAILED_BOTTOM;
/**
* Positions a movable element relative to an anchor element. The caller
* specifies the corners that should touch. This functions then moves the
* movable element accordingly.
*
* @param {Element} anchorElement The element that is the anchor for where
* the movable element should position itself.
* @param {goog.positioning.Corner} anchorElementCorner The corner of the
* anchorElement for positioning the movable element.
* @param {Element} movableElement The element to move.
* @param {goog.positioning.Corner} movableElementCorner The corner of the
* movableElement that that should be positioned adjacent to the anchor
* element.
* @param {goog.math.Coordinate=} opt_offset An offset specified in pixels.
* After the normal positioning algorithm is applied, the offset is then
* applied. Positive coordinates move the popup closer to the center of the
* anchor element. Negative coordinates move the popup away from the center
* of the anchor element.
* @param {goog.math.Box=} opt_margin A margin specified in pixels.
* After the normal positioning algorithm is applied and any offset, the
* margin is then applied. Positive coordinates move the popup away from the
* spot it was positioned towards its center. Negative coordinates move it
* towards the spot it was positioned away from its center.
* @param {?number=} opt_overflow Overflow handling mode. Defaults to IGNORE if
* not specified. Bitmap, {@see goog.positioning.Overflow}.
* @param {goog.math.Size=} opt_preferredSize The preferred size of the
* movableElement.
* @param {goog.math.Box=} opt_viewport Box object describing the dimensions of
* the viewport. The viewport is specified relative to offsetParent of
* {@code movableElement}. In other words, the viewport can be thought of as
* describing a "position: absolute" element contained in the offsetParent.
* It defaults to visible area of nearest scrollable ancestor of
* {@code movableElement} (see {@code goog.style.getVisibleRectForElement}).
* @return {goog.positioning.OverflowStatus} Status bitmap,
* {@see goog.positioning.OverflowStatus}.
*/
goog.positioning.positionAtAnchor = function(anchorElement,
anchorElementCorner,
movableElement,
movableElementCorner,
opt_offset,
opt_margin,
opt_overflow,
opt_preferredSize,
opt_viewport) {
goog.asserts.assert(movableElement);
var movableParentTopLeft =
goog.positioning.getOffsetParentPageOffset(movableElement);
// Get the visible part of the anchor element. anchorRect is
// relative to anchorElement's page.
var anchorRect = goog.positioning.getVisiblePart_(anchorElement);
// Translate anchorRect to be relative to movableElement's page.
goog.style.translateRectForAnotherFrame(
anchorRect,
goog.dom.getDomHelper(anchorElement),
goog.dom.getDomHelper(movableElement));
// Offset based on which corner of the element we want to position against.
var corner = goog.positioning.getEffectiveCorner(anchorElement,
anchorElementCorner);
// absolutePos is a candidate position relative to the
// movableElement's window.
var absolutePos = new goog.math.Coordinate(
corner & goog.positioning.CornerBit.RIGHT ?
anchorRect.left + anchorRect.width : anchorRect.left,
corner & goog.positioning.CornerBit.BOTTOM ?
anchorRect.top + anchorRect.height : anchorRect.top);
// Translate absolutePos to be relative to the offsetParent.
absolutePos =
goog.math.Coordinate.difference(absolutePos, movableParentTopLeft);
// Apply offset, if specified
if (opt_offset) {
absolutePos.x += (corner & goog.positioning.CornerBit.RIGHT ? -1 : 1) *
opt_offset.x;
absolutePos.y += (corner & goog.positioning.CornerBit.BOTTOM ? -1 : 1) *
opt_offset.y;
}
// Determine dimension of viewport.
var viewport;
if (opt_overflow) {
if (opt_viewport) {
viewport = opt_viewport;
} else {
viewport = goog.style.getVisibleRectForElement(movableElement);
if (viewport) {
viewport.top -= movableParentTopLeft.y;
viewport.right -= movableParentTopLeft.x;
viewport.bottom -= movableParentTopLeft.y;
viewport.left -= movableParentTopLeft.x;
}
}
}
return goog.positioning.positionAtCoordinate(absolutePos,
movableElement,
movableElementCorner,
opt_margin,
viewport,
opt_overflow,
opt_preferredSize);
};
/**
* Calculates the page offset of the given element's
* offsetParent. This value can be used to translate any x- and
* y-offset relative to the page to an offset relative to the
* offsetParent, which can then be used directly with as position
* coordinate for {@code positionWithCoordinate}.
* @param {!Element} movableElement The element to calculate.
* @return {!goog.math.Coordinate} The page offset, may be (0, 0).
*/
goog.positioning.getOffsetParentPageOffset = function(movableElement) {
// Ignore offset for the BODY element unless its position is non-static.
// For cases where the offset parent is HTML rather than the BODY (such as in
// IE strict mode) there's no need to get the position of the BODY as it
// doesn't affect the page offset.
var movableParentTopLeft;
var parent = movableElement.offsetParent;
if (parent) {
var isBody = parent.tagName == goog.dom.TagName.HTML ||
parent.tagName == goog.dom.TagName.BODY;
if (!isBody ||
goog.style.getComputedPosition(parent) != 'static') {
// Get the top-left corner of the parent, in page coordinates.
movableParentTopLeft = goog.style.getPageOffset(parent);
if (!isBody) {
movableParentTopLeft = goog.math.Coordinate.difference(
movableParentTopLeft,
new goog.math.Coordinate(goog.style.bidi.getScrollLeft(parent),
parent.scrollTop));
}
}
}
return movableParentTopLeft || new goog.math.Coordinate();
};
/**
* Returns intersection of the specified element and
* goog.style.getVisibleRectForElement for it.
*
* @param {Element} el The target element.
* @return {goog.math.Rect} Intersection of getVisibleRectForElement
* and the current bounding rectangle of the element. If the
* intersection is empty, returns the bounding rectangle.
* @private
*/
goog.positioning.getVisiblePart_ = function(el) {
var rect = goog.style.getBounds(el);
var visibleBox = goog.style.getVisibleRectForElement(el);
if (visibleBox) {
rect.intersection(goog.math.Rect.createFromBox(visibleBox));
}
return rect;
};
/**
* Positions the specified corner of the movable element at the
* specified coordinate.
*
* @param {goog.math.Coordinate} absolutePos The coordinate to position the
* element at.
* @param {Element} movableElement The element to be positioned.
* @param {goog.positioning.Corner} movableElementCorner The corner of the
* movableElement that that should be positioned.
* @param {goog.math.Box=} opt_margin A margin specified in pixels.
* After the normal positioning algorithm is applied and any offset, the
* margin is then applied. Positive coordinates move the popup away from the
* spot it was positioned towards its center. Negative coordinates move it
* towards the spot it was positioned away from its center.
* @param {goog.math.Box=} opt_viewport Box object describing the dimensions of
* the viewport. Required if opt_overflow is specified.
* @param {?number=} opt_overflow Overflow handling mode. Defaults to IGNORE if
* not specified, {@see goog.positioning.Overflow}.
* @param {goog.math.Size=} opt_preferredSize The preferred size of the
* movableElement. Defaults to the current size.
* @return {goog.positioning.OverflowStatus} Status bitmap.
*/
goog.positioning.positionAtCoordinate = function(absolutePos,
movableElement,
movableElementCorner,
opt_margin,
opt_viewport,
opt_overflow,
opt_preferredSize) {
absolutePos = absolutePos.clone();
var status = goog.positioning.OverflowStatus.NONE;
// Offset based on attached corner and desired margin.
var corner = goog.positioning.getEffectiveCorner(movableElement,
movableElementCorner);
var elementSize = goog.style.getSize(movableElement);
var size = opt_preferredSize ? opt_preferredSize.clone() :
elementSize.clone();
if (opt_margin || corner != goog.positioning.Corner.TOP_LEFT) {
if (corner & goog.positioning.CornerBit.RIGHT) {
absolutePos.x -= size.width + (opt_margin ? opt_margin.right : 0);
} else if (opt_margin) {
absolutePos.x += opt_margin.left;
}
if (corner & goog.positioning.CornerBit.BOTTOM) {
absolutePos.y -= size.height + (opt_margin ? opt_margin.bottom : 0);
} else if (opt_margin) {
absolutePos.y += opt_margin.top;
}
}
// Adjust position to fit inside viewport.
if (opt_overflow) {
status = opt_viewport ?
goog.positioning.adjustForViewport_(
absolutePos, size, opt_viewport, opt_overflow) :
goog.positioning.OverflowStatus.FAILED_OUTSIDE_VIEWPORT;
if (status & goog.positioning.OverflowStatus.FAILED) {
return status;
}
}
goog.style.setPosition(movableElement, absolutePos);
if (!goog.math.Size.equals(elementSize, size)) {
goog.style.setBorderBoxSize(movableElement, size);
}
return status;
};
/**
* Adjusts the position and/or size of an element, identified by its position
* and size, to fit inside the viewport. If the position or size of the element
* is adjusted the pos or size objects, respectively, are modified.
*
* @param {goog.math.Coordinate} pos Position of element, updated if the
* position is adjusted.
* @param {goog.math.Size} size Size of element, updated if the size is
* adjusted.
* @param {goog.math.Box} viewport Bounding box describing the viewport.
* @param {number} overflow Overflow handling mode,
* {@see goog.positioning.Overflow}.
* @return {goog.positioning.OverflowStatus} Status bitmap,
* {@see goog.positioning.OverflowStatus}.
* @private
*/
goog.positioning.adjustForViewport_ = function(pos, size, viewport, overflow) {
var status = goog.positioning.OverflowStatus.NONE;
var ADJUST_X_EXCEPT_OFFSCREEN =
goog.positioning.Overflow.ADJUST_X_EXCEPT_OFFSCREEN;
var ADJUST_Y_EXCEPT_OFFSCREEN =
goog.positioning.Overflow.ADJUST_Y_EXCEPT_OFFSCREEN;
if ((overflow & ADJUST_X_EXCEPT_OFFSCREEN) == ADJUST_X_EXCEPT_OFFSCREEN &&
(pos.x < viewport.left || pos.x >= viewport.right)) {
overflow &= ~goog.positioning.Overflow.ADJUST_X;
}
if ((overflow & ADJUST_Y_EXCEPT_OFFSCREEN) == ADJUST_Y_EXCEPT_OFFSCREEN &&
(pos.y < viewport.top || pos.y >= viewport.bottom)) {
overflow &= ~goog.positioning.Overflow.ADJUST_Y;
}
// Left edge outside viewport, try to move it.
if (pos.x < viewport.left && overflow & goog.positioning.Overflow.ADJUST_X) {
pos.x = viewport.left;
status |= goog.positioning.OverflowStatus.ADJUSTED_X;
}
// Left edge inside and right edge outside viewport, try to resize it.
if (pos.x < viewport.left &&
pos.x + size.width > viewport.right &&
overflow & goog.positioning.Overflow.RESIZE_WIDTH) {
size.width = Math.max(
size.width - ((pos.x + size.width) - viewport.right), 0);
status |= goog.positioning.OverflowStatus.WIDTH_ADJUSTED;
}
// Right edge outside viewport, try to move it.
if (pos.x + size.width > viewport.right &&
overflow & goog.positioning.Overflow.ADJUST_X) {
pos.x = Math.max(viewport.right - size.width, viewport.left);
status |= goog.positioning.OverflowStatus.ADJUSTED_X;
}
// Left or right edge still outside viewport, fail if the FAIL_X option was
// specified, ignore it otherwise.
if (overflow & goog.positioning.Overflow.FAIL_X) {
status |= (pos.x < viewport.left ?
goog.positioning.OverflowStatus.FAILED_LEFT : 0) |
(pos.x + size.width > viewport.right ?
goog.positioning.OverflowStatus.FAILED_RIGHT : 0);
}
// Top edge outside viewport, try to move it.
if (pos.y < viewport.top && overflow & goog.positioning.Overflow.ADJUST_Y) {
pos.y = viewport.top;
status |= goog.positioning.OverflowStatus.ADJUSTED_Y;
}
// Bottom edge inside and top edge outside viewport, try to resize it.
if (pos.y <= viewport.top &&
pos.y + size.height < viewport.bottom &&
overflow & goog.positioning.Overflow.RESIZE_HEIGHT) {
size.height = Math.max(size.height - (viewport.top - pos.y), 0);
pos.y = viewport.top;
status |= goog.positioning.OverflowStatus.HEIGHT_ADJUSTED;
}
// Top edge inside and bottom edge outside viewport, try to resize it.
if (pos.y >= viewport.top &&
pos.y + size.height > viewport.bottom &&
overflow & goog.positioning.Overflow.RESIZE_HEIGHT) {
size.height = Math.max(
size.height - ((pos.y + size.height) - viewport.bottom), 0);
status |= goog.positioning.OverflowStatus.HEIGHT_ADJUSTED;
}
// Bottom edge outside viewport, try to move it.
if (pos.y + size.height > viewport.bottom &&
overflow & goog.positioning.Overflow.ADJUST_Y) {
pos.y = Math.max(viewport.bottom - size.height, viewport.top);
status |= goog.positioning.OverflowStatus.ADJUSTED_Y;
}
// Top or bottom edge still outside viewport, fail if the FAIL_Y option was
// specified, ignore it otherwise.
if (overflow & goog.positioning.Overflow.FAIL_Y) {
status |= (pos.y < viewport.top ?
goog.positioning.OverflowStatus.FAILED_TOP : 0) |
(pos.y + size.height > viewport.bottom ?
goog.positioning.OverflowStatus.FAILED_BOTTOM : 0);
}
return status;
};
/**
* Returns an absolute corner (top/bottom left/right) given an absolute
* or relative (top/bottom start/end) corner and the direction of an element.
* Absolute corners remain unchanged.
* @param {Element} element DOM element to test for RTL direction.
* @param {goog.positioning.Corner} corner The popup corner used for
* positioning.
* @return {goog.positioning.Corner} Effective corner.
*/
goog.positioning.getEffectiveCorner = function(element, corner) {
return /** @type {goog.positioning.Corner} */ (
(corner & goog.positioning.CornerBit.FLIP_RTL &&
goog.style.isRightToLeft(element) ?
corner ^ goog.positioning.CornerBit.RIGHT :
corner
) & ~goog.positioning.CornerBit.FLIP_RTL);
};
/**
* Returns the corner opposite the given one horizontally.
* @param {goog.positioning.Corner} corner The popup corner used to flip.
* @return {goog.positioning.Corner} The opposite corner horizontally.
*/
goog.positioning.flipCornerHorizontal = function(corner) {
return /** @type {goog.positioning.Corner} */ (corner ^
goog.positioning.CornerBit.RIGHT);
};
/**
* Returns the corner opposite the given one vertically.
* @param {goog.positioning.Corner} corner The popup corner used to flip.
* @return {goog.positioning.Corner} The opposite corner vertically.
*/
goog.positioning.flipCornerVertical = function(corner) {
return /** @type {goog.positioning.Corner} */ (corner ^
goog.positioning.CornerBit.BOTTOM);
};
/**
* Returns the corner opposite the given one horizontally and vertically.
* @param {goog.positioning.Corner} corner The popup corner used to flip.
* @return {goog.positioning.Corner} The opposite corner horizontally and
* vertically.
*/
goog.positioning.flipCorner = function(corner) {
return /** @type {goog.positioning.Corner} */ (corner ^
goog.positioning.CornerBit.BOTTOM ^
goog.positioning.CornerBit.RIGHT);
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,121 @@
// Copyright 2006 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* @fileoverview Client viewport positioning class.
*
* @author robbyw@google.com (Robert Walker)
* @author eae@google.com (Emil A Eklund)
*/
goog.provide('goog.positioning.ViewportClientPosition');
goog.require('goog.math.Box');
goog.require('goog.math.Coordinate');
goog.require('goog.math.Size');
goog.require('goog.positioning.ClientPosition');
/**
* Encapsulates a popup position where the popup is positioned relative to the
* window (client) coordinates, and made to stay within the viewport.
*
* @param {number|goog.math.Coordinate} arg1 Left position or coordinate.
* @param {number=} opt_arg2 Top position if arg1 is a number representing the
* left position, ignored otherwise.
* @constructor
* @extends {goog.positioning.ClientPosition}
*/
goog.positioning.ViewportClientPosition = function(arg1, opt_arg2) {
goog.positioning.ClientPosition.call(this, arg1, opt_arg2);
};
goog.inherits(goog.positioning.ViewportClientPosition,
goog.positioning.ClientPosition);
/**
* The last-resort overflow strategy, if the popup fails to fit.
* @type {number}
* @private
*/
goog.positioning.ViewportClientPosition.prototype.lastResortOverflow_ = 0;
/**
* Set the last-resort overflow strategy, if the popup fails to fit.
* @param {number} overflow A bitmask of goog.positioning.Overflow strategies.
*/
goog.positioning.ViewportClientPosition.prototype.setLastResortOverflow =
function(overflow) {
this.lastResortOverflow_ = overflow;
};
/**
* Repositions the popup according to the current state.
*
* @param {Element} element The DOM element of the popup.
* @param {goog.positioning.Corner} popupCorner The corner of the popup
* element that that should be positioned adjacent to the anchorElement.
* One of the goog.positioning.Corner constants.
* @param {goog.math.Box=} opt_margin A margin specified in pixels.
* @param {goog.math.Size=} opt_preferredSize Preferred size fo the element.
* @override
*/
goog.positioning.ViewportClientPosition.prototype.reposition = function(
element, popupCorner, opt_margin, opt_preferredSize) {
var viewportElt = goog.style.getClientViewportElement(element);
var viewport = goog.style.getVisibleRectForElement(viewportElt);
var scrollEl = goog.dom.getDomHelper(element).getDocumentScrollElement();
var clientPos = new goog.math.Coordinate(
this.coordinate.x + scrollEl.scrollLeft,
this.coordinate.y + scrollEl.scrollTop);
var failXY = goog.positioning.Overflow.FAIL_X |
goog.positioning.Overflow.FAIL_Y;
var corner = popupCorner;
// Try the requested position.
var status = goog.positioning.positionAtCoordinate(clientPos, element, corner,
opt_margin, viewport, failXY, opt_preferredSize);
if ((status & goog.positioning.OverflowStatus.FAILED) == 0) {
return;
}
// Outside left or right edge of viewport, try try to flip it horizontally.
if (status & goog.positioning.OverflowStatus.FAILED_LEFT ||
status & goog.positioning.OverflowStatus.FAILED_RIGHT) {
corner = goog.positioning.flipCornerHorizontal(corner);
}
// Outside top or bottom edge of viewport, try try to flip it vertically.
if (status & goog.positioning.OverflowStatus.FAILED_TOP ||
status & goog.positioning.OverflowStatus.FAILED_BOTTOM) {
corner = goog.positioning.flipCornerVertical(corner);
}
// Try flipped position.
status = goog.positioning.positionAtCoordinate(clientPos, element, corner,
opt_margin, viewport, failXY, opt_preferredSize);
if ((status & goog.positioning.OverflowStatus.FAILED) == 0) {
return;
}
// If that failed, the viewport is simply too small to contain the popup.
// Revert to the original position.
goog.positioning.positionAtCoordinate(
clientPos, element, popupCorner, opt_margin, viewport,
this.lastResortOverflow_, opt_preferredSize);
};

View File

@@ -0,0 +1,64 @@
// Copyright 2006 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* @fileoverview Client positioning class.
*
*/
goog.provide('goog.positioning.ViewportPosition');
goog.require('goog.math.Box');
goog.require('goog.math.Coordinate');
goog.require('goog.math.Size');
goog.require('goog.positioning.AbstractPosition');
/**
* Encapsulates a popup position where the popup is positioned according to
* coordinates relative to the element's viewport (page). This calculates the
* correct position to use even if the element is relatively positioned to some
* other element.
*
* @param {number|goog.math.Coordinate} arg1 Left position or coordinate.
* @param {number=} opt_arg2 Top position.
* @constructor
* @extends {goog.positioning.AbstractPosition}
*/
goog.positioning.ViewportPosition = function(arg1, opt_arg2) {
this.coordinate = arg1 instanceof goog.math.Coordinate ? arg1 :
new goog.math.Coordinate(/** @type {number} */ (arg1), opt_arg2);
};
goog.inherits(goog.positioning.ViewportPosition,
goog.positioning.AbstractPosition);
/**
* Repositions the popup according to the current state
*
* @param {Element} element The DOM element of the popup.
* @param {goog.positioning.Corner} popupCorner The corner of the popup
* element that that should be positioned adjacent to the anchorElement.
* @param {goog.math.Box=} opt_margin A margin specified in pixels.
* @param {goog.math.Size=} opt_preferredSize Preferred size of the element.
* @override
*/
goog.positioning.ViewportPosition.prototype.reposition = function(
element, popupCorner, opt_margin, opt_preferredSize) {
goog.positioning.positionAtAnchor(
goog.style.getClientViewportElement(element),
goog.positioning.Corner.TOP_LEFT, element, popupCorner,
this.coordinate, opt_margin, null, opt_preferredSize);
};