Преглед изворни кода

修复dialog位置在可视区域内

huqi пре 5 година
родитељ
комит
f342152fbe
1 измењених фајлова са 14 додато и 0 уклоњено
  1. 14 0
      o2web/source/o2_core/o2/widget/Dialog.js

+ 14 - 0
o2web/source/o2_core/o2/widget/Dialog.js

@@ -453,6 +453,20 @@ o2.widget.Dialog = o2.DL = new Class({
             // //	this.content.setStyle("display", "block");
             // //	this.content.setStyle("display", "block");
             // //this.fireEvent("postShow");
             // //this.fireEvent("postShow");
 
 
+			var pn = this.node.getOffsetParent();
+			var p = pn.getPosition();
+
+			var h = this.css.to.height.toInt();
+			var y = this.css.to.top.toInt();
+			y = y+p.y;
+
+			var ih = window.innerHeight.toInt();
+			if (h+y> ih){
+				y = ih-p.y-h-20;
+				if (y<0) y=0;
+				this.css.to.top = ""+y+"px";
+			}
+
 			this.morph.start(this.css.to).chain(function(){
 			this.morph.start(this.css.to).chain(function(){
 				if (this.titleText) this.getTitle();
 				if (this.titleText) this.getTitle();
 				if (this.button) this.getButton();
 				if (this.button) this.getButton();