Path: blob/trunk/third_party/closure/goog/positioning/anchoredposition.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 positioning class.16*17* @author [email protected] (Emil A Eklund)18*/1920goog.provide('goog.positioning.AnchoredPosition');2122goog.require('goog.positioning');23goog.require('goog.positioning.AbstractPosition');24252627/**28* Encapsulates a popup position where the popup is anchored at a corner of29* an element.30*31* When using AnchoredPosition, it is recommended that the popup element32* specified in the Popup constructor or Popup.setElement be absolutely33* positioned.34*35* @param {Element} anchorElement Element the movable element should be36* anchored against.37* @param {goog.positioning.Corner} corner Corner of anchored element the38* movable element should be positioned at.39* @param {number=} opt_overflow Overflow handling mode. Defaults to IGNORE if40* not specified. Bitmap, {@see goog.positioning.Overflow}.41* @constructor42* @extends {goog.positioning.AbstractPosition}43*/44goog.positioning.AnchoredPosition = function(45anchorElement, corner, opt_overflow) {46/**47* Element the movable element should be anchored against.48* @type {Element}49*/50this.element = anchorElement;5152/**53* Corner of anchored element the movable element should be positioned at.54* @type {goog.positioning.Corner}55*/56this.corner = corner;5758/**59* Overflow handling mode. Defaults to IGNORE if not specified.60* Bitmap, {@see goog.positioning.Overflow}.61* @type {number|undefined}62* @private63*/64this.overflow_ = opt_overflow;65};66goog.inherits(67goog.positioning.AnchoredPosition, goog.positioning.AbstractPosition);686970/**71* Repositions the movable element.72*73* @param {Element} movableElement Element to position.74* @param {goog.positioning.Corner} movableCorner Corner of the movable element75* that should be positioned adjacent to the anchored element.76* @param {goog.math.Box=} opt_margin A margin specifin pixels.77* @param {goog.math.Size=} opt_preferredSize PreferredSize of the78* movableElement (unused in this class).79* @override80*/81goog.positioning.AnchoredPosition.prototype.reposition = function(82movableElement, movableCorner, opt_margin, opt_preferredSize) {83goog.positioning.positionAtAnchor(84this.element, this.corner, movableElement, movableCorner, undefined,85opt_margin, this.overflow_);86};878889