coverController.js一些主要的方法入下:
var JSCoverCtrl = {
createCover :function(){
if (document.getElementById('JSCoverCtrlLoadinglookup') == null) {
document.write("<div id='JSCoverCtrlLoadinglookup' style='position:absolute; top:20; left:20; z-index:10; visibility:hidden'><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><TD bgcolor=6487DC><TABLE id='loadingTable' WIDTH=180 height=70 BORDER=0 CELLSPACING=2 CELLPADDING=0><TR><td bgcolor=E9F2FC align=center><font size=-1>正在查找数据, 请稍候...</font></td></tr></table></td></tr></table></div>");
}
if (document.getElementById('JSCoverCtrlLoadingTemplate') == null) {
document.write("<div id='JSCoverCtrlLoadingTemplate' style='position:absolute; top:20; left:20; z-index:10; visibility:hidden'><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><TD bgcolor=6487DC><TABLE WIDTH=180 height=70 BORDER=0 CELLSPACING=2 CELLPADDING=0><TR><td bgcolor=E9F2FC align=center><font size=-1><span id=JSCoverCtrlLoadingText contenteditable=true>正在查找数据, 请稍候...</span></font></td></tr></table></td></tr></table></div>");
}
if (document.getElementById('JSCoverCtrlCover') == null) {
document.write("<div id='JSCoverCtrlCover' style='position:absolute; top:0; left:0; z-index:11; visibility:hidden; height:100%; width:100%' ><TABLE id='JSCoverCtrlCovertable' WIDTH=100% height=100% BORDER=0 CELLSPACING=0 CELLPADDING=0 ><TR ><TD align=center> </td></tr></table></div>");
}
},
//根据页面重新调整Cover的大小
resizeByMain :function(){
JSCoverCtrlCovertable.width=document.all("elismaintemplatetable").offsetWidth;
JSCoverCtrlCovertable.height=document.all("elismaintemplatetable").offsetHeight;
},
//显示您所需要的提示---displapString
viewCover :function(viewObj,displayString){
viewObj.disabled=true;
JSCoverCtrl.viewWithString(displayString);
},
//显示您所需要的提示---displapString
viewWithString :function(displayString){
if(displayString != null)
{
JSCoverCtrlLoadingText.innerHTML=displayString;
JSCoverCtrlLoadingTemplate.style.top=document.all("JSCoverCtrlCovertable").offsetHeight/2-35;
JSCoverCtrlLoadingTemplate.style.left=document.all("JSCoverCtrlCovertable").offsetWidth/2-70;
JSCoverCtrlLoadingTemplate.style.visibility="visible";
}
else {
JSCoverCtrlLoadinglookup.style.top=document.all("JSCoverCtrlCover").offsetHeight/2-20;
JSCoverCtrlLoadinglookup.style.left=document.all("JSCoverCtrlCover").offsetWidth/2-20;
JSCoverCtrlLoadinglookup.style.visibility="visible";
}
JSCoverCtrlCover.style.visibility="visible";
JSCoverCtrl.buttonCanNotSubmit();
},
//显示您所需要的提示---displapString
hideAllCover :function(){
if (JSCoverCtrlCover.style.visibility=="visible") JSCoverCtrlCover.style.visibility="hidden";
if (JSCoverCtrlLoadingTemplate.style.visibility=="visible") JSCoverCtrlLoadingTemplate.style.visibility="hidden";
if (JSCoverCtrlLoadinglookup.style.visibility=="visible") JSCoverCtrlLoadinglookup.style.visibility="hidden";
JSCoverCtrl.buttonCanSubmit();
},
//如果有按钮,让按钮失效
buttonCanNotSubmit :function(){
var bt = document.getElementsByTagName('input');
for (i = 0; bt[i]; i++) {
type = bt[i].getAttribute('type');
if(type != null){
if (type == 'button' || type == 'reset' || type == 'submit') {
var l = bt[i].value.length;
bt[i].disabled = true;
bt[i].style.cursor = 'arrow';
bt[i].style.backgroundImage = "url(/layout/images/button_" + l +"gb2.gif)"
}
}
}
//控制有别的提交处理后,批文要重新生成
var selfFrame = self;
var posFlag = selfFrame.document.getElementById('posFlag');
if (posFlag == null) {
var parentFrame = self.parent;
var bottomFrame = parentFrame.bottomFrame;
if (bottomFrame != null) {
posFlag = bottomFrame.document.getElementById('posFlag');
if (posFlag != null) {
posFlag.value = 'N';
}
}
}
selfFrame = self.opener;
if (selfFrame != null) {
var posFlag = selfFrame.document.getElementById('posFlag');
if (posFlag == null) {
var parentFrame = selfFrame.parent;
var bottomFrame = parentFrame.bottomFrame;
if (bottomFrame != null) {
posFlag = bottomFrame.document.getElementById('posFlag');
if (posFlag != null) {
posFlag.value = 'N';
}
}
}
}
},
buttonCanSubmit :function(){
var bt = document.getElementsByTagName('input');
for (i = 0; bt[i]; i++){
type = bt[i].getAttribute('type');
if(type != null){
if (type == 'button' || type == 'reset' || type == 'submit'){
bt[i].disabled = false;
bt[i].style.cursor = 'arrow';
}
}
}
}
}
JSCoverCtrl.createCover();
使用方式:
JSCoverCtrl.viewWithString( "正在检查并提交数据…请稍候." );
JSCoverCtrl.hideAllCover();
alert('不能再点');
防止一些不能反复执行的操作被多次执行,在一次执行以后提示不可操作。