Path: blob/trunk/third_party/closure/goog/positioning/menuanchoredposition.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 Anchored viewport positioning class with both adjust and16* resize options for the popup.17*18* @author [email protected] (Emil A Eklund)19*/2021goog.provide('goog.positioning.MenuAnchoredPosition');2223goog.require('goog.positioning.AnchoredViewportPosition');24goog.require('goog.positioning.Overflow');25262728/**29* Encapsulates a popup position where the popup is anchored at a corner of30* an element. The positioning behavior changes based on the values of31* opt_adjust and opt_resize.32*33* When using this positioning object it's recommended that the movable element34* be absolutely positioned.35*36* @param {Element} anchorElement Element the movable element should be37* anchored against.38* @param {goog.positioning.Corner} corner Corner of anchored element the39* movable element should be positioned at.40* @param {boolean=} opt_adjust Whether the positioning should be adjusted until41* the element fits inside the viewport even if that means that the anchored42* corners are ignored.43* @param {boolean=} opt_resize Whether the positioning should be adjusted until44* the element fits inside the viewport on the X axis and its height is45* resized so if fits in the viewport. This take precedence over opt_adjust.46* @constructor47* @extends {goog.positioning.AnchoredViewportPosition}48*/49goog.positioning.MenuAnchoredPosition = function(50anchorElement, corner, opt_adjust, opt_resize) {51goog.positioning.AnchoredViewportPosition.call(52this, anchorElement, corner, opt_adjust || opt_resize);5354if (opt_adjust || opt_resize) {55var overflowX = goog.positioning.Overflow.ADJUST_X_EXCEPT_OFFSCREEN;56var overflowY = opt_resize ?57goog.positioning.Overflow.RESIZE_HEIGHT :58goog.positioning.Overflow.ADJUST_Y_EXCEPT_OFFSCREEN;59this.setLastResortOverflow(overflowX | overflowY);60}61};62goog.inherits(63goog.positioning.MenuAnchoredPosition,64goog.positioning.AnchoredViewportPosition);656667