Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/third_party/closure/goog/positioning/menuanchoredposition.js
2868 views
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 Anchored viewport positioning class with both adjust and
17
* resize options for the popup.
18
*
19
* @author [email protected] (Emil A Eklund)
20
*/
21
22
goog.provide('goog.positioning.MenuAnchoredPosition');
23
24
goog.require('goog.positioning.AnchoredViewportPosition');
25
goog.require('goog.positioning.Overflow');
26
27
28
29
/**
30
* Encapsulates a popup position where the popup is anchored at a corner of
31
* an element. The positioning behavior changes based on the values of
32
* opt_adjust and opt_resize.
33
*
34
* When using this positioning object it's recommended that the movable element
35
* be absolutely positioned.
36
*
37
* @param {Element} anchorElement Element the movable element should be
38
* anchored against.
39
* @param {goog.positioning.Corner} corner Corner of anchored element the
40
* movable element should be positioned at.
41
* @param {boolean=} opt_adjust Whether the positioning should be adjusted until
42
* the element fits inside the viewport even if that means that the anchored
43
* corners are ignored.
44
* @param {boolean=} opt_resize Whether the positioning should be adjusted until
45
* the element fits inside the viewport on the X axis and its height is
46
* resized so if fits in the viewport. This take precedence over opt_adjust.
47
* @constructor
48
* @extends {goog.positioning.AnchoredViewportPosition}
49
*/
50
goog.positioning.MenuAnchoredPosition = function(
51
anchorElement, corner, opt_adjust, opt_resize) {
52
goog.positioning.AnchoredViewportPosition.call(
53
this, anchorElement, corner, opt_adjust || opt_resize);
54
55
if (opt_adjust || opt_resize) {
56
var overflowX = goog.positioning.Overflow.ADJUST_X_EXCEPT_OFFSCREEN;
57
var overflowY = opt_resize ?
58
goog.positioning.Overflow.RESIZE_HEIGHT :
59
goog.positioning.Overflow.ADJUST_Y_EXCEPT_OFFSCREEN;
60
this.setLastResortOverflow(overflowX | overflowY);
61
}
62
};
63
goog.inherits(
64
goog.positioning.MenuAnchoredPosition,
65
goog.positioning.AnchoredViewportPosition);
66
67