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