|
|
Q:弹出层的位置能不能设定
平台的obpm.dialog这个函数用来弹出层的时候,哪里传参数能够设定弹出层的坐标,也就是左边,顶部的位置 现在用户反映这个弹出层老是往右边了.
A:这是旧版本的一些问题,现在新版本不会出现这样的问题,请参考下列方法的优化:
设定弹出层的坐标和顶部的位置你可以优化以下文件:
1、/script/obpm/adapter/jquery-bridge.js
添加left和top参数,
/**
* 调整弹出框高度宽度, 小于等于-1表示不更改
*/
resize: function(width, height){
jQuery.FrameDialog.resize(width, height,left,top);
}
2、/script/jquery-ui/external/jquery-framedialog.js
$.FrameDialog.resize = function(width, height, left, top, uid) {
if (uid) {
var wrap = jQuery("#" + uid).parent(".ui-resizable");
//resize child
if (width > -1) {
wrap.css('width', width + 'px');
}
if (height > -1) {
wrap.css('height', height + 'px');
}
if(left>-1){
wrap.css('left', left + 'px');
}
if(left>-1){
wrap.css('top', top + 'px');
}
或是这样修改,请看:
修改文件1、/script/obpm/adapter/jquery-bridge.js
resize: function(width, height){
var cWidth=window.top.document.body.clientWidth;//取得宽度
var cHeight=window.top.document.body.clientHeight;//取得高度
if(width<=0 && width>(cWidth-20)){//判断条件
width=cWidth-20;
}
if(height<=0 || height>(cHeight-20)){
height=cHeight-20;
}
var left=parseInt(parseFloat(cWidth - width) / 2);
var top=parseInt(parseFloat(cHeight - height) / 2);
jQuery.FrameDialog.resize(width, height,left,top);
}
修改文件2、/script/jquery-ui/external/jquery-framedialog.js
$.FrameDialog.resize = function(width, height, left , top, uid) {
if (uid) {
var wrap = jQuery("#" + uid).parent(".ui-resizable");
//resize child
if (width > -1) {
wrap.css('width', width + 'px');
}
if (height > -1) {
wrap.css('height', height + 'px');
}
if(left>=0 && typeof left!="string"){
//var dleft=parseInt(parseFloat(cWidth - width) / 2);
wrap.css('left', left + 'px');
}
if(top>=0 && typeof top!="string"){
//var dheight=parseInt(parseFloat(cHeight - height) / 2);
wrap.css('top', top + 'px');
}
} else {
var uid = $.FrameDialog._getUid();
var opener = $.FrameDialog._getOpener();
if (uid != null && opener && opener.jQuery && opener.jQuery.FrameDialog) {
var wrap = opener.jQuery("#" + uid).parent(".ui-resizable");
//resize self
if (width > -1) {
wrap.css('width', width + 'px');
}
if (height > -1) {
wrap.css('height', height + 'px');
}
if(left>=0 && typeof left!="string"){
//var dleft=parseInt(parseFloat(cWidth - width) / 2);
wrap.css('left', left + 'px');
}
if(top>=0 && typeof top!="string"){
//var dheight=parseInt(parseFloat(cHeight - height) / 2);
wrap.css('top', top + 'px');
}
}
}
}
摘自BSI提问,原帖子链接:http://www.teemlink.com/bbs/view ... 26amp%3Btypeid%3D51 |
|