123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- goog.provide('goog.ui.Popup');
- goog.require('goog.math.Box');
- goog.require('goog.positioning.AbstractPosition');
- goog.require('goog.positioning.Corner');
- goog.require('goog.style');
- goog.require('goog.ui.PopupBase');
- goog.ui.Popup = function(opt_element, opt_position) {
-
- this.popupCorner_ = goog.positioning.Corner.TOP_START;
-
- this.position_ = opt_position || undefined;
- goog.ui.PopupBase.call(this, opt_element);
- };
- goog.inherits(goog.ui.Popup, goog.ui.PopupBase);
- goog.tagUnsealableClass(goog.ui.Popup);
- goog.ui.Popup.prototype.margin_;
- goog.ui.Popup.prototype.getPinnedCorner = function() {
- return this.popupCorner_;
- };
- goog.ui.Popup.prototype.setPinnedCorner = function(corner) {
- this.popupCorner_ = corner;
- if (this.isVisible()) {
- this.reposition();
- }
- };
- goog.ui.Popup.prototype.getPosition = function() {
- return this.position_ || null;
- };
- goog.ui.Popup.prototype.setPosition = function(position) {
- this.position_ = position || undefined;
- if (this.isVisible()) {
- this.reposition();
- }
- };
- goog.ui.Popup.prototype.getMargin = function() {
- return this.margin_ || null;
- };
- goog.ui.Popup.prototype.setMargin = function(
- arg1, opt_arg2, opt_arg3, opt_arg4) {
- if (arg1 == null || arg1 instanceof goog.math.Box) {
- this.margin_ = arg1;
- } else {
- this.margin_ = new goog.math.Box(
- arg1,
- (opt_arg2),
- (opt_arg3),
- (opt_arg4));
- }
- if (this.isVisible()) {
- this.reposition();
- }
- };
- goog.ui.Popup.prototype.reposition = function() {
- if (!this.position_) {
- return;
- }
- var hideForPositioning = !this.isVisible() &&
- this.getType() != goog.ui.PopupBase.Type.MOVE_OFFSCREEN;
- var el = this.getElement();
- if (hideForPositioning) {
- el.style.visibility = 'hidden';
- goog.style.setElementShown(el, true);
- }
- this.position_.reposition(el, this.popupCorner_, this.margin_);
- if (hideForPositioning) {
-
-
-
-
- goog.style.setElementShown(el, false);
- }
- };
|