|
楼主 |
发表于 2019-9-17 16:21:44
|
显示全部楼层
源码中是在页面加载的时候执行了方法getHtml4Uploader : function(param){debugger; var uploaderDiv = param.uploaderDiv;
var docPath= param.docPath;
var onClickCallBack = param.clickCallBack;
var onSubmitCallBack = param.submitCallBack;
var onCompleteCallBack = param.completeCallBack;
var caller = param.caller;
var filter = param.filter ? param.filter : '*/*';
var button = $('#'+uploaderDiv), interval;
var dialog = document.createElement('div');
dialog.id = uploaderDiv+'-waiting';
dialog.style.position = "absolute";
dialog.style.zIndex = "2000";
dialog.style.background = "#fff";
dialog.style.border = "1px solid #C2D5DC";
dialog.style.width = "310px";
dialog.style.height = "80px";
AjaxUpload.prototype.setDocPath = function(docPath){
this._settings.action = justep.doc.InnerUtils.getdocServerAction(
docPath, "/repository/file/cache/upload", true);
};
AjaxUpload.prototype.getButton = function(){
return this._button;
};
debugger;
var uploader = new AjaxUpload(button, {
action : '',
name : 'myfile',
filter : filter,
onClick : function(){
if(onClickCallBack){
var success = onClickCallBack.call(caller,this);
if(success == false){
return false;
}
}
},
onSubmit : function(file, ext) {
var filter = this._settings.filter;
if (filter == '*/*' || ext && new RegExp('^('+filter+')$','\i').test(ext)){
this.setDocPath(docPath);
if(onSubmitCallBack){
var success = onSubmitCallBack.call(caller,file,this);
if(success == false){
return false;
}
}
var dialogHeight = 80;
var top = $(this._button).offset().top;
var topValue = (top > (50+dialogHeight) ? top -50 -dialogHeight :top);
var leftValue = ($(this._button).offset().left + 50);
if(topValue <= 0){
topValue = window.screen.height/2 -50 - dialogHeight;
}
if(leftValue <=0){
leftValue = window.screen.width/2 - 50;
}
dialog.style.top = topValue + "px";
dialog.style.left = leftValue + "px";
dialog.innerHTML = "<div id='uploadingDialog' style='position:relative;'>" +
"<img style='position:absolute;top:20px;left:20px;' src='"+justep.Request.convertURL("/UI/system/service/report/dialog/waiting1.gif")+"'/>" +
"<div style='position:absolute;top:32px;left:60px;font-size:13px;width:230px;overflow:hidden;height:30px;padding-left:10px;'>正在上传:"+file+",请稍等...</div>" +
"<div style='position:relative;top:32px;left:290px;float:left;width:20px;'></div></div>";
dialog.style.height = dialogHeight +"px";
document.body.appendChild(dialog);
} else {
alert(new justep.Message(justep.Message.JUSTEP232010).getMessage());
return false;
}
}
点击上传文件按钮的时候执行了new AjaxUpload();
我在我的按钮里这样写var button = $('#attachmentEditor21_uploaderButton'), interval;
var uploader = new AjaxUpload(button, {
action : '',
name : 'myfile',
filter : '*/*',
onClick : function(){
if(onClickCallBack){
var success = onClickCallBack.call(caller,this);
if(success == false){
return false;
}
}
},
onSubmit : function(file, ext) {
var filter = this._settings.filter;
if (filter == '*/*' || ext && new RegExp('^('+filter+')$','\i').test(ext)){
this.setDocPath(docPath);
if(onSubmitCallBack){
var success = onSubmitCallBack.call(caller,file,this);
if(success == false){
return false;
}
}
var dialogHeight = 80;
var top = $(this._button).offset().top;
var topValue = (top > (50+dialogHeight) ? top -50 -dialogHeight :top);
var leftValue = ($(this._button).offset().left + 50);
if(topValue <= 0){
topValue = window.screen.height/2 -50 - dialogHeight;
}
if(leftValue <=0){
leftValue = window.screen.width/2 - 50;
}
dialog.style.top = topValue + "px";
dialog.style.left = leftValue + "px";
dialog.innerHTML = "<div id='uploadingDialog' style='position:relative;'>" +
"<img style='position:absolute;top:20px;left:20px;' src='"+justep.Request.convertURL("/UI/system/service/report/dialog/waiting1.gif")+"'/>" +
"<div style='position:absolute;top:32px;left:60px;font-size:13px;width:230px;overflow:hidden;height:30px;padding-left:10px;'>正在上传:"+file+",请稍等...</div>" +
"<div style='position:relative;top:32px;left:290px;float:left;width:20px;'></div></div>";
dialog.style.height = dialogHeight +"px";
document.body.appendChild(dialog);
} else {
alert(new justep.Message(justep.Message.JUSTEP232010).getMessage());
return false;
}
},
onComplete : function(docName, response) {
var fileList = $(response).find("file");
$("#"+uploaderDiv+'-waiting').remove();
if(fileList.length == 0){
throw justep.Error.create(new justep.Message(justep.Message.JUSTEP232026,response).getMessage());
}else{
if(onCompleteCallBack){
onCompleteCallBack.call(caller,docName,this,response);
}
}
}
});
没有成功打开弹出框。我写的应该是错的。请教下正确的该怎么写
|
|