| 1 |
// Copyright 2006 The Closure Library Authors. All Rights Reserved. |
| 2 |
// |
| 3 |
// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
// you may not use this file except in compliance with the License. |
| 5 |
// You may obtain a copy of the License at |
| 6 |
// |
| 7 |
// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
// |
| 9 |
// Unless required by applicable law or agreed to in writing, software |
| 10 |
// distributed under the License is distributed on an "AS-IS" BASIS, |
| 11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
// See the License for the specific language governing permissions and |
| 13 |
// limitations under the License. |
| 14 |
|
| 15 |
/** |
| 16 |
* @fileoverview Client viewport positioning class. |
| 17 |
* |
| 18 |
* @author [email protected] (Emil A Eklund) |
| 19 |
*/ |
| 20 |
|
| 21 |
goog.provide('goog.positioning.AbsolutePosition'); |
| 22 |
|
| 23 |
goog.require('goog.math.Coordinate'); |
| 24 |
goog.require('goog.positioning'); |
| 25 |
goog.require('goog.positioning.AbstractPosition'); |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
/** |
| 30 |
* Encapsulates a popup position where the popup absolutely positioned by |
| 31 |
* setting the left/top style elements directly to the specified values. |
| 32 |
* The position is generally relative to the element's offsetParent. Normally, |
| 33 |
* this is the document body, but can be another element if the popup element |
| 34 |
* is scoped by an element with relative position. |
| 35 |
* |
| 36 |
* @param {number|!goog.math.Coordinate} arg1 Left position or coordinate. |
| 37 |
* @param {number=} opt_arg2 Top position. |
| 38 |
* @constructor |
| 39 |
* @extends {goog.positioning.AbstractPosition} |
| 40 |
*/ |
| 41 |
goog.positioning.AbsolutePosition = function(arg1, opt_arg2) { |
| 42 |
/** |
| 43 |
* Coordinate to position popup at. |
| 44 |
* @type {goog.math.Coordinate} |
| 45 |
*/ |
| 46 |
this.coordinate = arg1 instanceof goog.math.Coordinate ? |
| 47 |
arg1 : |
| 48 |
new goog.math.Coordinate(/** @type {number} */ (arg1), opt_arg2); |
| 49 |
}; |
| 50 |
goog.inherits( |
| 51 |
goog.positioning.AbsolutePosition, goog.positioning.AbstractPosition); |
| 52 |
|
| 53 |
|
| 54 |
/** |
| 55 |
* Repositions the popup according to the current state. |
| 56 |
* |
| 57 |
* @param {Element} movableElement The DOM element to position. |
| 58 |
* @param {goog.positioning.Corner} movableCorner The corner of the movable |
| 59 |
* element that should be positioned at the specified position. |
| 60 |
* @param {goog.math.Box=} opt_margin A margin specified in pixels. |
| 61 |
* @param {goog.math.Size=} opt_preferredSize Preferred size of the |
| 62 |
* movableElement. |
| 63 |
* @override |
| 64 |
*/ |
| 65 |
goog.positioning.AbsolutePosition.prototype.reposition = function( |
| 66 |
movableElement, movableCorner, opt_margin, opt_preferredSize) { |
| 67 |
goog.positioning.positionAtCoordinate( |
| 68 |
this.coordinate, movableElement, movableCorner, opt_margin, null, null, |
| 69 |
opt_preferredSize); |
| 70 |
}; |