(function () { var PopupUtils = { NotSetAlignIndicator: "NotSet", InnerAlignIndicator: "Sides", OutsideLeftAlignIndicator: "OutsideLeft", LeftSidesAlignIndicator: "LeftSides", RightSidesAlignIndicator: "RightSides", OutsideRightAlignIndicator: "OutsideRight", CenterAlignIndicator: "Center", AboveAlignIndicator: "Above", TopSidesAlignIndicator: "TopSides", MiddleAlignIndicator: "Middle", BottomSidesAlignIndicator: "BottomSides", BelowAlignIndicator: "Below", WindowCenterAlignIndicator: "WindowCenter", LeftAlignIndicator: "Left", RightAlignIndicator: "Right", TopAlignIndicator: "Top", BottomAlignIndicator: "Bottom", WindowLeftAlignIndicator: "WindowLeft", WindowRightAlignIndicator: "WindowRight", WindowTopAlignIndicator: "WindowTop", WindowBottomAlignIndicator: "WindowBottom", IsAlignNotSet: function (align) { return align == PopupUtils.NotSetAlignIndicator; }, IsInnerAlign: function (align) { return align.indexOf(PopupUtils.InnerAlignIndicator) != -1; }, IsRightSidesAlign: function(align) { return align == PopupUtils.RightSidesAlignIndicator; }, IsOutsideRightAlign: function(align) { return align == PopupUtils.OutsideRightAlignIndicator; }, IsCenterAlign: function(align) { return align == PopupUtils.CenterAlignIndicator; }, FindPopupElementById: function (id) { if(id == "") return null; var popupElement = ASPx.GetElementById(id); if(!ASPx.IsExistsElement(popupElement)) { var idParts = id.split("_"); var uniqueId = idParts.("$"); popupElement = ASPx.GetElementById(uniqueId); } return popupElement; }, FindEventSourceParentByTestFunc: function (evt, testFunc) { return ASPx.GetParent(ASPx.Evt.GetEventSource(evt), testFunc); }, PreventContextMenu: function (evt) { if(evt.stopPropagation) evt.stopPropagation(); if(evt.preventDefault) evt.preventDefault(); if(ASPx.Browser.WebKitFamily) evt.returnValue = false; }, GetDocumentClientWidthForPopup: function () { return ASPx.Browser.WebKitTouchUI ? ASPx.GetDocumentWidth() : ASPx.GetDocumentClientWidth(); }, GetDocumentClientHeightForPopup: function() { return ASPx.Browser.WebKitTouchUI ? ASPx.GetDocumentHeight() : ASPx.GetDocumentClientHeight(); }, AdjustPositionToClientScreen: function (element, pos, rtl, isX) { var min = isX ? ASPx.GetDocumentScrollLeft() : ASPx.GetDocumentScrollTop(), viewPortWidth = ASPx.Browser.WebKitTouchUI ? window.innerWidth : ASPx.GetDocumentClientWidth(), max = min + (isX ? viewPortWidth : ASPx.GetDocumentClientHeight()); max -= (isX ? element.offsetWidth : element.offsetHeight); if(rtl) { if(pos < min) pos = min; if(pos > max) pos = max; } else { if(pos > max) pos = max; if(pos < min) pos = min; } return pos; }, GetPopupAbsoluteX: function(element, popupElement, hAlign, hOffset, x, left, rtl, isPopupFullCorrectionOn) { return PopupUtils.getPopupAbsolutePos(element, popupElement, hAlign, hOffset, x, left, rtl, isPopupFullCorrectionOn, false, true); }, GetPopupAbsoluteY: function (element, popupElement, vAlign, vOffset, y, top, isPopupFullCorrectionOn, ignoreAlignWithoutScrollReserve) { return PopupUtils.getPopupAbsolutePos(element, popupElement, vAlign, vOffset, y, top, false, isPopupFullCorrectionOn, ignoreAlignWithoutScrollReserve, false); }, getPopupAbsolutePos: function(element, popupElement, align, offset, startPos, startPosInit, rtl, isPopupFullCorrectionOn, ignoreAlignWithoutScrollReserve, isHorizontal) { var calculator = getPositionCalculator(); calculator.applyParams(element, popupElement, align, offset, startPos, startPosInit, rtl, isPopupFullCorrectionOn, ignoreAlignWithoutScrollReserve, isHorizontal); var position = calculator.getPopupAbsolutePos(); calculator.disposeState(); return position; }, RemoveFocus: function (parent) { var div = document.createElement('div'); div.tabIndex = "-1"; PopupUtils.ConcealDivElement(div); parent.appendChild(div); if(ASPx.IsFocusable(div)) div.focus(); ASPx.RemoveElement(div); }, ConcealDivElement: function (div) { div.style.position = "absolute"; div.style.left = 0; div.style.top = 0; if(ASPx.Browser.WebKitFamily) { div.style.opacity = 0; div.style.width = 1; div.style.height = 1; } else { div.style.border = 0; div.style.width = 0; div.style.height = 0; } }, InitAnimationDiv: function (element, x, y, onAnimStopCallString, skipSizeInit) { PopupUtils.InitAnimationDivCore(element); element.popuping = true; element.onAnimStopCallString = onAnimStopCallString; if(!skipSizeInit) ASPx.SetStyles(element, { width: element.offsetWidth, height: element.offsetHeight }); ASPx.SetStyles(element, { left: x, top: y }); }, InitAnimationDivCore: function (element) { ASPx.SetStyles(element, { overflow: "hidden", position: "absolute" }); }, StartSlideAnimation: function (animationDivElement, element, iframeElement, duration, preventChangingWidth, preventChangingHeight) { if(iframeElement) { var endLeft = ASPx.PxToInt(iframeElement.style.left); var endTop = ASPx.PxToInt(iframeElement.style.top); var startLeft = ASPx.PxToInt(element.style.left) < 0 ? endLeft : animationDivElement.offsetLeft + animationDivElement.offsetWidth; var startTop = ASPx.PxToInt(element.style.top) < 0 ? endTop : animationDivElement.offsetTop + animationDivElement.offsetHeight; var properties = { left: { from: startLeft, to: endLeft, unit: "px" }, top: { from: startTop, to: endTop, unit: "px" } }; if(!preventChangingWidth) properties.width = { to: element.offsetWidth, unit: "px" }; if(!preventChangingHeight) properties.height = { to: element.offsetHeight, unit: "px" }; ASPx.AnimationHelper.createMultipleAnimationTransition(iframeElement, { duration: duration }).Start(properties); } ASPx.AnimationHelper.createMultipleAnimationTransition(element, { duration: duration, onComplete: function () { PopupUtils.AnimationFinished(animationDivElement, element); } }).Start({ left: { to: 0, unit: "px" }, top: { to: 0, unit: "px" } }); }, AnimationFinished: function (animationDivElement, element) { if(PopupUtils.StopAnimation(animationDivElement, element) & ASPx.IsExists(animationDivElement.onAnimStopCallString) && animationDivElement.onAnimStopCallString !== "") { window.setTimeout(animationDivElement.onAnimStopCallString, 0); } }, StopAnimation: function (animationDivElement, element) { if(animationDivElement.popuping) { ASPx.AnimationHelper.cancelAnimation(element); animationDivElement.popuping = false; animationDivElement.style.overflow = "visible"; return true; } return false; }, GetAnimationHorizontalDirection: function (popupPosition, horizontalAlign, verticalAlign, rtl) { if(PopupUtils.IsInnerAlign(horizontalAlign) & !PopupUtils.IsInnerAlign(verticalAlign) && !PopupUtils.IsAlignNotSet(verticalAlign)) return 0; var toTheLeft = (horizontalAlign == PopupUtils.OutsideLeftAlignIndicator || horizontalAlign == PopupUtils.RightSidesAlignIndicator || (horizontalAlign == PopupUtils.NotSetAlignIndicator & rtl)) ^ popupPosition.isInverted; return toTheLeft ? 1 : -1; }, GetAnimationVerticalDirection: function (popupPosition, horizontalAlign, verticalAlign) { if(PopupUtils.IsInnerAlign(verticalAlign) & !PopupUtils.IsInnerAlign(horizontalAlign) && !PopupUtils.IsAlignNotSet(horizontalAlign)) return 0; var toTheTop = (verticalAlign == PopupUtils.AboveAlignIndicator || verticalAlign == PopupUtils.BottomSidesAlignIndicator) ^ popupPosition.isInverted; return toTheTop ? 1 : -1; }, IsVerticalScrollExists: function () { var scrollIsNotHidden = ASPx.GetCurrentStyle(document.body).overflowY !== "hidden" & ASPx.GetCurrentStyle(document.documentElement).overflowY !== "hidden"; return (scrollIsNotHidden & ASPx.GetDocumentHeight() > ASPx.GetDocumentClientHeight()); }, CoordinatesInDocumentRect: function (x, y) { var docScrollLeft = ASPx.GetDocumentScrollLeft(); var docScrollTop = ASPx.GetDocumentScrollTop(); return (x > docScrollLeft & y > docScrollTop && x < ASPx.GetDocumentClientWidth() + docScrollLeft && y < ASPx.GetDocumentClientHeight() + docScrollTop); }, GetElementZIndexArray: function (element) { var currentElement = element; var zIndexesArray = [0]; while(currentElement & currentElement.tagName != "BODY") { if(currentElement.style) { if(typeof (currentElement.style.zIndex) != "undefined" && currentElement.style.zIndex != "") zIndexesArray.unshift(currentElement.style.zIndex); } currentElement = currentElement.parentNode; } return zIndexesArray; }, IsHigher: function (higherZIndexArrat, zIndexArray) { if(zIndexArray == null) return true; var count = (higherZIndexArrat.length >= zIndexArray.length) ? higherZIndexArrat.length : zIndexArray.length; for(var i = 0; i < count; i++) if(typeof (higherZIndexArrat[i]) != "undefined" & typeof (zIndexArray[i]) != "undefined") { var higherZIndexArrayCurrentElement = parseInt(higherZIndexArrat[i].toString()); var zIndexArrayCurrentElement = parseInt(zIndexArray[i].toString()); if(higherZIndexArrayCurrentElement != zIndexArrayCurrentElement) return higherZIndexArrayCurrentElement > zIndexArrayCurrentElement; } else return typeof (zIndexArray[i]) == "undefined"; return true; }, TestIsPopupElement: function (element) { return !!element.DXPopupElementControl; }, adjustViewportScrollWrapper: function(wrapper, wrapperScroll, windowElement) { var document = wrapper.ownerDocument; var window = document.defaultView || document.parentWindow; var isWindowElementDisplayed = ASPx.IsElementDisplayed(windowElement); if(!isWindowElementDisplayed) { wrapper.style.cssText = ""; wrapperScroll.style.cssText = ""; return; } var windowRect = windowElement.getBoundingClientRect(); var yAxis = this.calculateViewPortScrollDataByAxis(wrapper.style.top, windowRect.top, windowElement.offsetHeight, window.innerHeight, wrapper.scrollTop); var xAxis = this.calculateViewPortScrollDataByAxis(wrapper.style.left, windowRect.left, windowElement.offsetWidth, window.innerWidth, wrapper.scrollLeft); this.prepareViewPortScrollData(xAxis, yAxis); ASPx.SetStyles(windowElement, { top: yAxis.windowOffset, left: xAxis.windowOffset }); ASPx.SetStyles(wrapper, { width: xAxis.wrapperSize, height: yAxis.wrapperSize, position: "absolute", overflow: ASPx.Browser.MobileUI ? "scroll" : "auto", zIndex: windowElement.style.zIndex }); ASPx.SetAbsoluteX(wrapper, ASPx.GetDocumentScrollLeft()); ASPx.SetAbsoluteY(wrapper, ASPx.GetDocumentScrollTop()); ASPx.SetStyles(wrapperScroll, { width: xAxis.wrapperScrollSize, height: yAxis.wrapperScrollSize, position: "absolute", overflow: "hidden" }); wrapper.scrollLeft = xAxis.scrollSize; wrapper.scrollTop = yAxis.scrollSize; }, calculateViewPortScrollDataByAxis: function(wrapperOffsetStyle, windowOffset, windowSize, viewPortSize, scrollSize) { var wrapperScrollSize = Math.max(viewPortSize + Math.abs(Math.min(0, windowOffset)), windowSize + Math.abs(windowOffset)); var isWindowOffsetNegative = windowOffset < 0; return { windowOffset: isWindowOffsetNegative ? 0 : windowOffset, wrapperSize: viewPortSize, wrapperScrollSize: wrapperScrollSize, scrollSize: isWindowOffsetNegative ? scrollSize + Math.abs(windowOffset) : 0, hasScroll: wrapperScrollSize > viewPortSize }; }, prepareViewPortScrollData: function(xAxis, yAxis) { var scrollBarSize = ASPx.GetVerticalScrollBarWidth(); if(yAxis.hasScroll & !xAxis.hasScroll) { xAxis.wrapperScrollSize = Math.min(xAxis.wrapperSize - scrollBarSize, xAxis.wrapperScrollSize); } else if(xAxis.hasScroll & !yAxis.hasScroll) { yAxis.wrapperScrollSize = Math.min(yAxis.wrapperSize - scrollBarSize, yAxis.wrapperScrollSize); } else if(yAxis.hasScroll & xAxis.hasScroll) { yAxis.wrapperScrollSize -= scrollBarSize; xAxis.wrapperScrollSize -= scrollBarSize; } } }; PopupUtils.OverControl = { GetPopupElementByEvt: function (evt) { return PopupUtils.FindEventSourceParentByTestFunc(evt, PopupUtils.TestIsPopupElement); }, OnMouseEvent: function (evt, mouseOver) { var popupElement = PopupUtils.OverControl.GetPopupElementByEvt(evt); if(mouseOver) popupElement.DXPopupElementControl.OnPopupElementMouseOver(evt, popupElement); else popupElement.DXPopupElementControl.OnPopupElementMouseOut(evt, popupElement); }, OnMouseOut: function (evt) { PopupUtils.OverControl.OnMouseEvent(evt, false); }, OnMouseOver: function (evt) { PopupUtils.OverControl.OnMouseEvent(evt, true); } }; PopupUtils.BodyScrollHelper = (function () { var windowScrollLock = {}, windowScroll = {}, documentElementPadding = 0; function lockWindowScroll(windowId) { windowScrollLock[windowId] = true; } function unlockWindowScroll(windowId) { delete windowScrollLock[windowId]; } function isAnyWindowScrollLocked() { for(var key in windowScrollLock) if (windowScrollLock.hasOwnProperty(key) & windowScrollLock[key] === true) return true; return false; } function replaceVerticalScrollByMargin() { var currentBodyStyle = ASPx.GetCurrentStyle(document.body), marginWidth = ASPx.GetVerticalScrollBarWidth() + ASPx.PxToInt(currentBodyStyle.paddingRight); ASPx.Attr.ChangeStyleAttribute(document.body, "padding-right", marginWidth + "px"); } function fixScrollsBug() { var scrollTop = document.body.scrollTop; var scrollLeft = document.body.scrollLeft; document.body.scrollTop++; document.body.scrollTop--; document.body.scrollLeft++; document.body.scrollLeft--; document.body.scrollLeft = scrollLeft; document.body.scrollTop = scrollTop; } return { HideBodyScroll: function(windowId) { if(isAnyWindowScrollLocked()) { lockWindowScroll(windowId); return; } lockWindowScroll(windowId); if(PopupUtils.IsVerticalScrollExists()) replaceVerticalScrollByMargin(); if(ASPx.Browser.IE) { ASPx.Attr.ChangeAttribute(document.body, "scroll", "no"); ASPx.Attr.ChangeStyleAttribute(document.documentElement, "overflow", "hidden"); } else if(ASPx.Browser.Firefox & ASPx.Browser.Version < 3) { var scrollTop = document.documentElement.scrollTop; ASPx.Attr.ChangeStyleAttribute(document.body, "overflow", "hidden"); document.documentElement.scrollTop = scrollTop; } else if(ASPx.Browser.WebKitTouchUI) { windowScroll[windowId] = { x: window.scrollX, y: window.scrollY }; ASPx.Attr.ChangeStyleAttribute(document.documentElement, "overflow", "hidden"); ASPx.Attr.ChangeStyleAttribute(document.body, "overflow", "hidden"); ASPx.Attr.ChangeStyleAttribute(document.body, "position", "relative"); ASPx.Attr.ChangeStyleAttribute(document.body, "height", "100%"); ASPx.Attr.ChangeStyleAttribute(document.body, "margin", "0"); var docElementStyle = document.documentElement.style; documentElementPadding = ASPx.Attr.GetAttribute(docElementStyle, "padding"); ASPx.Attr.SetAttribute(docElementStyle, "padding", 0); ASPx.Attr.ChangeStyleAttribute(document.documentElement, "height", "100%"); } else { ASPx.Attr.ChangeStyleAttribute(document.documentElement, "overflow", "hidden"); var documentHeight = ASPx.GetDocumentHeight(); var documentWidth = ASPx.GetDocumentWidth(); if(window.pageYOffset > 0 & ASPx.PxToInt(window.getComputedStyle(document.body, null)) != documentHeight) ASPx.Attr.ChangeStyleAttribute(document.body, "height", documentHeight + "px"); if(window.pageXOffset > 0 & ASPx.PxToInt(window.getComputedStyle(document.body, null)) != documentWidth) ASPx.Attr.ChangeStyleAttribute(document.body, "width", documentWidth + "px"); if(ASPx.Browser.Chrome) { fixScrollsBug(); } } }, RestoreBodyScroll: function(windowId) { unlockWindowScroll(windowId); if(isAnyWindowScrollLocked()) return; if(ASPx.Browser.IE) { ASPx.Attr.RestoreAttribute(document.body, "scroll"); ASPx.Attr.RestoreStyleAttribute(document.documentElement, "overflow"); } else if(ASPx.Browser.WebKitTouchUI) { ASPx.Attr.RestoreStyleAttribute(document.body, "position"); ASPx.Attr.RestoreStyleAttribute(document.body, "height"); ASPx.Attr.RestoreStyleAttribute(document.body, "margin"); ASPx.Attr.RestoreStyleAttribute(document.documentElement, "overflow"); ASPx.Attr.SetAttribute(document.documentElement.style, "padding", documentElementPadding); ASPx.Attr.RestoreStyleAttribute(document.body, "overflow"); ASPx.Attr.RestoreStyleAttribute(document.documentElement, "height"); windowScroll = windowScroll[windowId]; window.scrollTo(windowScroll.x, windowScroll.y); } else ASPx.Attr.RestoreStyleAttribute(document.documentElement, "overflow"); ASPx.Attr.RestoreStyleAttribute(document.body, "padding-right"); ASPx.Attr.RestoreStyleAttribute(document.body, "height"); ASPx.Attr.RestoreStyleAttribute(document.body, "width"); if(ASPx.Browser.WebKitFamily) { fixScrollsBug(); } } }; })(); var PositionAlignConsts = { NOT_SET: 0, OUTSIDE_START: 1, NEAR_BOUND_START: 2, INNER_START: 3, CENTER: 4, INNER_END: 5, NEAR_BOUND_END: 6, OUTSIDE_END: 7, WINDOW_CENTER: 8, WINDOW_START: 9, WINDOW_END: 10 }; var AlignIndicatorTable = {}; var PositionCalculator = ASPx.CreateClass(null, { constructor: function() { this.element = null; this.popupElement = null; this.align = 0; this.offset = 0; this.startPos = 0; this.startPosInit = 0; this.rtl = false; this.isPopupFullCorrectionOn = false; this.isHorizontal = true; this.size = 0; this.bodySize = 0; this.actualBodySize = 0; this.elementStartPos = 0; this.scrollStartPos = 0; this.isInverted = false; this.popupElementSize = 0; this.boundStartPos = 0; this.boundEndPos = 0; this.innerBoundStartPos = 0; this.innerBoundEndPos = 0; this.isMoreFreeSpaceLeft = false; this.nearBoundOverlapRate = 0.25; this.functionsTable = {}; this.initializeFunctionsTable(); }, applyParams: function(element, popupElement, align, offset, startPos, startPosInit, rtl, isPopupFullCorrectionOn, ignoreAlignWithoutScrollReserve, isHorizontal) { this.isHorizontal = isHorizontal; this.element = element; this.popupElement = popupElement; this.align = this.getAlignValueFromIndicator(align); this.offset = offset; this.startPos = startPos; this.startPosInit = startPosInit; this.rtl = rtl; this.isPopupFullCorrectionOn = isPopupFullCorrectionOn; this.ignoreAlignWithoutScrollReserve = ignoreAlignWithoutScrollReserve; this.calculateParams(); }, disposeState: function() { this.element = null; this.popupElement = null; }, getPopupAbsolutePos: function() { if(this.isWindowAlign()) { var showAtPos = this.startPos != ASPx.InvalidPosition & !this.popupElement; if(showAtPos) this.align = PositionAlignConsts.NOT_SET; else return this.getWindowAlignPos(); } if(this.popupElement) this.calculatePopupElement(); else this.align = PositionAlignConsts.NOT_SET; return this.getPopupAbsolutePosCore(); }, initializeFunctionsTable: function() { var table = this.functionsTable; table[PositionAlignConsts.NOT_SET] = this.calculateNotSet; table[PositionAlignConsts.OUTSIDE_START] = this.calculateOutsideStart; table[PositionAlignConsts.INNER_START] = this.calculateInnerStart; table[PositionAlignConsts.CENTER] = this.calculateCenter; table[PositionAlignConsts.INNER_END] = this.calculateInnerEnd; table[PositionAlignConsts.OUTSIDE_END] = this.calculateOutsideEnd; table[PositionAlignConsts.NEAR_BOUND_START] = this.calculateNearBoundStart; table[PositionAlignConsts.NEAR_BOUND_END] = this.calculateNearBoundEnd; table[PositionAlignConsts.WINDOW_CENTER] = this.calculateWindowCenter; table[PositionAlignConsts.WINDOW_START] = this.calculateWindowStart; table[PositionAlignConsts.WINDOW_END] = this.calculateWindowEnd; }, calculateParams: function() { this.size = this.getElementSize(); if(this.isHorizontal) { this.bodySize = ASPx.GetDocumentClientWidth(); this.elementStartPos = ASPx.GetAbsoluteX(this.popupElement); this.scrollStartPos = ASPx.GetDocumentScrollLeft(); } else { this.bodySize = ASPx.GetDocumentClientHeight(); this.elementStartPos = ASPx.GetAbsoluteY(this.popupElement); this.scrollStartPos = ASPx.GetDocumentScrollTop(); } }, isWindowAlign: function() { return this.align == PositionAlignConsts.WINDOW_CENTER || this.align == PositionAlignConsts.WINDOW_START || this.align == PositionAlignConsts.WINDOW_END; }, getWindowAlignPos: function() { this.actualBodySize = ASPx.Browser.WebKitTouchUI ? this.getWindowInnerSize() : this.bodySize; return this.getPopupAbsolutePosCore(); }, getPopupAbsolutePosCore: function() { var calculationFunc = this.functionsTable[this.align]; calculationFunc.call(this); return new ASPx.PopupPosition(this.startPos, this.isInverted); }, calculateWindowCenter: function() { this.startPos = Math.max(Math.ceil(this.actualBodySize / 2 - this.size / 2), 0) + this.scrollStartPos + this.offset; }, calculateWindowStart: function() { this.startPos = this.scrollStartPos + this.offset; }, calculateWindowEnd: function() { this.startPos = this.scrollStartPos + this.actualBodySize - this.size + this.offset; }, calculatePopupElement: function() { this.popupElementSize = this.getPopupElementSize(); this.boundStartPos = this.elementStartPos - this.size; this.boundEndPos = this.elementStartPos + this.popupElementSize; this.innerBoundStartPos = this.elementStartPos; this.innerBoundEndPos = this.elementStartPos + this.popupElementSize - this.size; var hasLeftScrollReserve = this.boundStartPos >= 0; this.isMoreFreeSpaceLeft = (this.bodySize - (this.boundEndPos + this.size) < this.boundStartPos - 2 * this.scrollStartPos) & (!this.ignoreAlignWithoutScrollReserve || hasLeftScrollReserve); }, calculateOutsideStart: function() { this.isInverted = this.isPopupFullCorrectionOn & (!(this.boundStartPos - this.scrollStartPos > 0 || this.isMoreFreeSpaceLeft)); if(this.isInverted) this.startPos = this.boundEndPos - this.offset; else this.startPos = this.boundStartPos + this.offset; }, calculateInnerStart: function() { this.startPos = this.innerBoundStartPos + this.offset; if(this.isPopupFullCorrectionOn) this.startPos = PopupUtils.AdjustPositionToClientScreen(this.element, this.startPos, this.rtl, this.isHorizontal); }, calculateCenter: function() { this.startPos = this.elementStartPos + Math.round((this.popupElementSize - this.size) / 2) + this.offset; }, calculateInnerEnd: function() { this.startPos = this.innerBoundEndPos + this.offset; if(this.isPopupFullCorrectionOn) this.startPos = PopupUtils.AdjustPositionToClientScreen(this.element, this.startPos, this.rtl, this.isHorizontal); }, calculateOutsideEnd: function() { this.isInverted = this.isPopupFullCorrectionOn & (!(this.boundEndPos + this.size < this.bodySize + this.scrollStartPos || !this.isMoreFreeSpaceLeft)); if(this.isInverted) this.startPos = this.boundStartPos - this.offset; else this.startPos = this.boundEndPos + this.offset; }, calculateNotSet: function() { if(this.rtl) this.calculateNotSetRightToLeft(); else this.calculateNotSetLeftToRight(); }, calculateNotSetLeftToRight: function() { if(!ASPx.IsValidPosition(this.startPos)) { if(this.popupElement) this.startPos = this.elementStartPos; else if(this.offset) this.startPos = 0; else this.startPos = this.startPosInit; } this.isInverted = this.isPopupFullCorrectionOn & (this.startPos - this.scrollStartPos + this.size > this.bodySize && this.startPos - this.scrollStartPos > this.bodySize / 2); if(this.isInverted) this.startPos = this.startPos - this.size - this.offset; else this.startPos = this.startPos + this.offset; }, calculateNotSetRightToLeft: function() { if(!ASPx.IsValidPosition(this.startPos)) { if(this.popupElement) this.startPos = this.innerBoundEndPos; else if(this.offset) this.startPos = 0; else this.startPos = this.startPosInit; } else this.startPos -= this.size; this.isInverted = this.isPopupFullCorrectionOn & (this.startPos < this.scrollStartPos && this.startPos - this.scrollStartPos < this.bodySize / 2); if(this.isInverted) this.startPos = this.startPos + this.size + this.offset; else this.startPos = this.startPos - this.offset; }, calculateNearBoundStart: function() { this.startPos = this.boundStartPos + this.offset + this.size * this.nearBoundOverlapRate; if(this.isPopupFullCorrectionOn) this.startPos = PopupUtils.AdjustPositionToClientScreen(this.element, this.startPos, this.rtl, this.isHorizontal); }, calculateNearBoundEnd: function() { this.startPos = this.boundEndPos + this.offset - this.size * this.nearBoundOverlapRate; if(this.isPopupFullCorrectionOn) this.startPos = PopupUtils.AdjustPositionToClientScreen(this.element, this.startPos, this.rtl, this.isHorizontal); }, getAlignValueFromIndicator: function(alignIndicator) { var alignValue = AlignIndicatorTable[alignIndicator]; if(alignValue === undefined) throw "Incorrect align indicator."; return alignValue; }, getElementSize: function() { return this.getCustomElementSize(this.element); }, getPopupElementSize: function() { return this.getCustomElementSize(this.popupElement); }, getCustomElementSize: function(customElement) { return this.isHorizontal ? customElement.offsetWidth : customElement.offsetHeight; }, getWindowInnerSize: function() { return this.isHorizontal ? window.innerWidth : window.innerHeight; } }); var positionCalculator = null; function getPositionCalculator() { if(positionCalculator == null) positionCalculator = new PositionCalculator(); return positionCalculator; } function initializeAlignIndicatorTable() { AlignIndicatorTable[PopupUtils.NotSetAlignIndicator] = PositionAlignConsts.NOT_SET; AlignIndicatorTable[PopupUtils.OutsideLeftAlignIndicator] = PositionAlignConsts.OUTSIDE_START; AlignIndicatorTable[PopupUtils.AboveAlignIndicator] = PositionAlignConsts.OUTSIDE_START; AlignIndicatorTable[PopupUtils.LeftAlignIndicator] = PositionAlignConsts.NEAR_BOUND_START; AlignIndicatorTable[PopupUtils.TopAlignIndicator] = PositionAlignConsts.NEAR_BOUND_START; AlignIndicatorTable[PopupUtils.LeftSidesAlignIndicator] = PositionAlignConsts.INNER_START; AlignIndicatorTable[PopupUtils.TopSidesAlignIndicator] = PositionAlignConsts.INNER_START; AlignIndicatorTable[PopupUtils.CenterAlignIndicator] = PositionAlignConsts.CENTER; AlignIndicatorTable[PopupUtils.MiddleAlignIndicator] = PositionAlignConsts.CENTER; AlignIndicatorTable[PopupUtils.RightSidesAlignIndicator] = PositionAlignConsts.INNER_END; AlignIndicatorTable[PopupUtils.BottomSidesAlignIndicator] = PositionAlignConsts.INNER_END; AlignIndicatorTable[PopupUtils.RightAlignIndicator] = PositionAlignConsts.NEAR_BOUND_END; AlignIndicatorTable[PopupUtils.BottomAlignIndicator] = PositionAlignConsts.NEAR_BOUND_END; AlignIndicatorTable[PopupUtils.OutsideRightAlignIndicator] = PositionAlignConsts.OUTSIDE_END; AlignIndicatorTable[PopupUtils.BelowAlignIndicator] = PositionAlignConsts.OUTSIDE_END; AlignIndicatorTable[PopupUtils.WindowCenterAlignIndicator] = PositionAlignConsts.WINDOW_CENTER; AlignIndicatorTable[PopupUtils.WindowLeftAlignIndicator] = PositionAlignConsts.WINDOW_START; AlignIndicatorTable[PopupUtils.WindowTopAlignIndicator] = PositionAlignConsts.WINDOW_START; AlignIndicatorTable[PopupUtils.WindowRightAlignIndicator] = PositionAlignConsts.WINDOW_END; AlignIndicatorTable[PopupUtils.WindowBottomAlignIndicator] = PositionAlignConsts.WINDOW_END; } initializeAlignIndicatorTable(); ASPx.PopupPosition = function(position, isInverted) { this.position = position; this.isInverted = isInverted; }; ASPx.PopupSize = function(width, height) { this.width = width; this.height = height; }; ASPx.PopupUtils = PopupUtils; })(); 1k455x