@@ -73,8 +73,30 @@ Sys.Extended.UI.ModalPopupBehavior.prototype = {
|
||||
this._dragHandleElement = $get(this._popupDragHandleControlID);
|
||||
|
||||
this._popupElement = $get(this._popupControlID);
|
||||
if(this._dropShadow) {
|
||||
this._foregroundElement = document.createElement('div');
|
||||
this._foregroundElement.id = this.get_id() + '_foregroundElement';
|
||||
this._popupElement.parentNode.appendChild(this._foregroundElement);
|
||||
this._foregroundElement.appendChild(this._popupElement);
|
||||
} else {
|
||||
this._foregroundElement = this._popupElement;
|
||||
}
|
||||
|
||||
this._createDomElements();
|
||||
this._backgroundElement = document.createElement('div');
|
||||
this._backgroundElement.id = this.get_id() + '_backgroundElement';
|
||||
this._backgroundElement.style.display = 'none';
|
||||
this._backgroundElement.style.position = 'fixed';
|
||||
this._backgroundElement.style.left = '0px';
|
||||
this._backgroundElement.style.top = '0px';
|
||||
|
||||
// Want zIndex to big enough that the background sits above everything else
|
||||
// CSS 2.1 defines no bounds for the <integer> type, so pick arbitrarily
|
||||
if(this._backgroundCssClass)
|
||||
this._backgroundElement.className = this._backgroundCssClass;
|
||||
|
||||
this._foregroundElement.parentNode.appendChild(this._backgroundElement);
|
||||
this._foregroundElement.style.display = 'none';
|
||||
this._foregroundElement.style.position = 'fixed';
|
||||
|
||||
this._showHandler = Function.createDelegate(this, this._onShow);
|
||||
$addHandler(this.get_element(), 'click', this._showHandler);
|
||||
@@ -162,55 +184,7 @@ Sys.Extended.UI.ModalPopupBehavior.prototype = {
|
||||
Sys.Extended.UI.ModalPopupBehavior.callBaseMethod(this, 'dispose');
|
||||
},
|
||||
|
||||
_createDomElements: function() {
|
||||
if(this._dropShadow) {
|
||||
this._foregroundElement = document.createElement('div');
|
||||
this._foregroundElement.id = this.get_id() + '_foregroundElement';
|
||||
this._popupElement.parentNode.appendChild(this._foregroundElement);
|
||||
this._foregroundElement.appendChild(this._popupElement);
|
||||
} else {
|
||||
this._foregroundElement = this._popupElement;
|
||||
}
|
||||
|
||||
this._backgroundElement = document.createElement('div');
|
||||
this._backgroundElement.setAttribute('data-act-control-type', 'modalPopupBackground');
|
||||
this._backgroundElement.id = this.get_id() + '_backgroundElement';
|
||||
this._backgroundElement.style.display = 'none';
|
||||
this._backgroundElement.style.position = 'fixed';
|
||||
this._backgroundElement.style.left = '0px';
|
||||
this._backgroundElement.style.top = '0px';
|
||||
|
||||
if(this._backgroundCssClass)
|
||||
this._backgroundElement.className = this._backgroundCssClass;
|
||||
|
||||
this._foregroundElement.parentNode.appendChild(this._backgroundElement);
|
||||
this._foregroundElement.style.display = 'none';
|
||||
this._foregroundElement.style.position = 'fixed';
|
||||
|
||||
this._setZIndex();
|
||||
},
|
||||
|
||||
_setZIndex: function() {
|
||||
var topModalPopupBackgroundZIndex = parseInt(this._findTopModalPopupBackgroundZIndex());
|
||||
// Want zIndex to big enough that the background sits above everything else
|
||||
// CSS 2.1 defines no bounds for the <integer> type, so pick arbitrarily
|
||||
this._backgroundElement.style.zIndex = topModalPopupBackgroundZIndex ? parseInt(topModalPopupBackgroundZIndex + 1) : parseInt(Sys.Extended.UI.zIndex.ModalPopupBackground);
|
||||
this._foregroundElement.style.zIndex = parseInt($common.getCurrentStyle(this._backgroundElement, 'zIndex', this._backgroundElement.style.zIndex)) + 1;
|
||||
},
|
||||
|
||||
_findTopModalPopupBackgroundZIndex: function () {
|
||||
var lastPopup = this._getLastPopup();
|
||||
return lastPopup ? lastPopup._backgroundElement.style.zIndex : undefined;
|
||||
},
|
||||
|
||||
_getLastPopup: function () {
|
||||
var popups = Sys.Extended.UI.ModalPopupBehavior.popups;
|
||||
return popups.length ? popups[popups.length - 1] : undefined;
|
||||
},
|
||||
|
||||
_attachPopup: function() {
|
||||
Sys.Extended.UI.ModalPopupBehavior.popups.push(this);
|
||||
|
||||
if(this._dropShadow && !this._dropShadowBehavior)
|
||||
this._dropShadowBehavior = $create(Sys.Extended.UI.DropShadowBehavior, {}, null, null, this._popupElement);
|
||||
|
||||
@@ -243,9 +217,6 @@ Sys.Extended.UI.ModalPopupBehavior.prototype = {
|
||||
this._dropShadowBehavior.dispose();
|
||||
this._dropShadowBehavior = null;
|
||||
}
|
||||
|
||||
if(this._getLastPopup() == this)
|
||||
Sys.Extended.UI.ModalPopupBehavior.popups.pop();
|
||||
},
|
||||
|
||||
_onShow: function(e) {
|
||||
@@ -325,11 +296,14 @@ Sys.Extended.UI.ModalPopupBehavior.prototype = {
|
||||
this._isAnimationJustEnded = false;
|
||||
}
|
||||
|
||||
var zindex = 10000 + (Sys.Extended.UI.ModalPopupBehavior._openCount++ * 1000);
|
||||
this._showing = true;
|
||||
this._backgroundElement.style.zIndex = zindex;
|
||||
this._foregroundElement.style.zIndex = zindex + 1;
|
||||
|
||||
this.populate();
|
||||
this._attachPopup();
|
||||
|
||||
this._setZIndex();
|
||||
|
||||
this._backgroundElement.style.display = '';
|
||||
this._foregroundElement.style.display = '';
|
||||
this._popupElement.style.display = '';
|
||||
@@ -350,6 +324,7 @@ Sys.Extended.UI.ModalPopupBehavior.prototype = {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Disable TAB
|
||||
this.disableTab();
|
||||
|
||||
@@ -479,6 +454,7 @@ Sys.Extended.UI.ModalPopupBehavior.prototype = {
|
||||
|
||||
_hideImplementation: function() {
|
||||
// Internal implementation to hide the modal dialog
|
||||
Sys.Extended.UI.ModalPopupBehavior._openCount--;
|
||||
this._backgroundElement.style.display = 'none';
|
||||
this._foregroundElement.style.display = 'none';
|
||||
|
||||
@@ -500,20 +476,14 @@ Sys.Extended.UI.ModalPopupBehavior.prototype = {
|
||||
var xCoord = 0;
|
||||
var yCoord = 0;
|
||||
if(this._xCoordinate < 0) {
|
||||
var foregroundelementwidth = this._getForegroundElementWidth();
|
||||
var foregroundelementwidth = this._foregroundElement.offsetWidth ? this._foregroundElement.offsetWidth : this._foregroundElement.scrollWidth;
|
||||
xCoord = ((clientWidth - foregroundelementwidth) / 2);
|
||||
|
||||
// workaround for drag behavior which calls setlocation which in turn
|
||||
// changes the position of the panel to be absolute and requiring us
|
||||
// to add the scrollLeft so that it is positioned correctly.
|
||||
if(this._foregroundElement.style.position == 'absolute') {
|
||||
var parentPopup = this._getParentPopup();
|
||||
|
||||
if(parentPopup)
|
||||
xCoord = (parentPopup._getForegroundElementWidth() - foregroundelementwidth) / 2;
|
||||
else
|
||||
xCoord += scrollLeft;
|
||||
}
|
||||
if(this._foregroundElement.style.position == 'absolute')
|
||||
xCoord += scrollLeft;
|
||||
|
||||
this._foregroundElement.style.left = xCoord + 'px';
|
||||
} else {
|
||||
@@ -527,20 +497,14 @@ Sys.Extended.UI.ModalPopupBehavior.prototype = {
|
||||
}
|
||||
|
||||
if(this._yCoordinate < 0) {
|
||||
var foregroundelementheight = this._getForegroundElementHeight();
|
||||
var foregroundelementheight = this._foregroundElement.offsetHeight ? this._foregroundElement.offsetHeight : this._foregroundElement.scrollHeight;
|
||||
yCoord = ((clientHeight - foregroundelementheight) / 2);
|
||||
|
||||
// workaround for drag behavior which calls setlocation which in turn
|
||||
// changes the position of the panel to be absolute and requiring us
|
||||
// to add the scrollLeft so that it is positioned correctly.
|
||||
if(this._foregroundElement.style.position == 'absolute') {
|
||||
var parentPopup = this._getParentPopup();
|
||||
|
||||
if(parentPopup)
|
||||
yCoord = (parentPopup._getForegroundElementHeight() - foregroundelementheight) / 2;
|
||||
else
|
||||
yCoord += scrollTop;
|
||||
}
|
||||
if(this._foregroundElement.style.position == 'absolute')
|
||||
yCoord += scrollTop;
|
||||
|
||||
this._foregroundElement.style.top = yCoord + 'px';
|
||||
} else {
|
||||
@@ -566,41 +530,6 @@ Sys.Extended.UI.ModalPopupBehavior.prototype = {
|
||||
this._layoutBackgroundElement();
|
||||
},
|
||||
|
||||
_getForegroundElementWidth: function (){
|
||||
return this._foregroundElement.offsetWidth ? this._foregroundElement.offsetWidth : this._foregroundElement.scrollWidth;
|
||||
},
|
||||
|
||||
_getForegroundElementHeight: function() {
|
||||
return this._foregroundElement.offsetHeight ? this._foregroundElement.offsetHeight : this._foregroundElement.scrollHeight;
|
||||
},
|
||||
|
||||
_getParentPopup: function () {
|
||||
var el = this._foregroundElement;
|
||||
var otherForegrounds = this._getOtherForegrounds();
|
||||
|
||||
while(el.parentNode) {
|
||||
el = el.parentNode;
|
||||
|
||||
var index = Array.indexOf(otherForegrounds, el)
|
||||
|
||||
if(index !== -1)
|
||||
return Sys.Extended.UI.ModalPopupBehavior.popups[index];
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
_getOtherForegrounds: function () {
|
||||
var foregrounds = [];
|
||||
var popups = Sys.Extended.UI.ModalPopupBehavior.popups;
|
||||
|
||||
for(var i = 0; i < popups.length; i++)
|
||||
foregrounds.push(popups[i]._foregroundElement);
|
||||
|
||||
return foregrounds;
|
||||
},
|
||||
|
||||
|
||||
_layoutForegroundElement: function(xCoord, yCoord) {
|
||||
// Set the correct location of the foreground element to ensure that it is absolutely
|
||||
// positioned with respect to the browser. This is just a workaround for IE 6 since
|
||||
@@ -958,7 +887,7 @@ Sys.Extended.UI.ModalPopupBehavior.prototype = {
|
||||
},
|
||||
set_OnOkScript: function(value) {
|
||||
Sys.Extended.Deprecated("set_OnOkScript(value)", "set_onOkScript(value)");
|
||||
this.set_onOkScript(value);
|
||||
this.set_onOkScript(value);
|
||||
},
|
||||
|
||||
/// <summary>
|
||||
@@ -1187,6 +1116,7 @@ Sys.Extended.UI.ModalPopupBehavior.prototype = {
|
||||
};
|
||||
|
||||
Sys.Extended.UI.ModalPopupBehavior.registerClass('Sys.Extended.UI.ModalPopupBehavior', Sys.Extended.UI.DynamicPopulateBehaviorBase);
|
||||
Sys.Extended.UI.ModalPopupBehavior._openCount = 0;
|
||||
|
||||
Sys.Extended.UI.ModalPopupBehavior.invokeViaServer = function(behaviorID, show) {
|
||||
// This static function (that is intended to be called from script emitted
|
||||
@@ -1202,5 +1132,3 @@ Sys.Extended.UI.ModalPopupBehavior.invokeViaServer = function(behaviorID, show)
|
||||
behavior.hide();
|
||||
}
|
||||
};
|
||||
|
||||
Sys.Extended.UI.ModalPopupBehavior.popups = [];
|
||||
|
||||
Reference in New Issue
Block a user