ganttTime_wev8.js 7.15 KB
var bShow = false;
var outObject;

/********鼠标点击别处时间控件消失*********/
document.onclick = function (){
  if (!bShow) closeLayer();
  bShow = false;
}
/*******时间控件消失函数*******/
function closeLayer(){
	document.getElementById("meizzDateLayer2").style.display="none";
}
/*********时间控件生成开始**********/
var strFrame2 = "";
var hourLabel = "Hour";
var closeLabel = "Close";
var clearLabel = "Clear";
try{
	hourLabel = SystemEnv.getHtmlNoteName(3706);
	closeLabel = SystemEnv.getHtmlNoteName(3787);
	clearLabel = SystemEnv.getHtmlNoteName(3704);
}catch(e){}
document.writeln('<iframe id=meizzDateLayer2 Author=wayx frameborder=0 style="position: absolute; width:200px; height:251px;z-index:9999;display:none;background:#fff;overflow:hidden;"></iframe>');
strFrame2+='<div style="position:absolute;left:0;top:3;text-align:center; border:1px solid #bbb;padding:2px background-color:#FFFFFF; width:180px;font-size:9pt;" onselectstart="return false">';
strFrame2+='<h1 Author="wayx" style="background-color:#A0EBF1;font-size:12px;font-weight:normal;height:22px;line-height:20px;margin:0px;">';
strFrame2+='<div id=hourid><span style=\"display:inline-block;width:50%;text-align:left;\">&nbsp;&nbsp;'+hourLabel+':</span><span style=\"display:inline-block;width:50%;text-align:right;\"><select id=hour name=hour>';
strFrame2+='<scr' + 'ipt>';
strFrame2+='document.body.overflow=\"hidden\";';
strFrame2+='var d = new Date();';
strFrame2+=' for (var i=0; i<24;  i++){';
strFrame2+='	i<10?j=0+i.toString():j=i;';
strFrame2+='		if (d.getHours().toString()==i)';
strFrame2+='		{';
strFrame2+='			document.writeln("<OPTION VALUE= " + j + " selected>" + j + "</option>");';
strFrame2+='		}else{';
strFrame2+='			document.writeln("<OPTION VALUE= " + j + ">" + j + "</option>");';
strFrame2+='		}';
strFrame2+='	 }';
strFrame2+='</scr' + 'ipt>';
strFrame2+='</select>&nbsp;&nbsp;</span></div></h1>';
strFrame2+='<span id="nowhour"></span>';
strFrame2+='</div>';
strFrame2+='<scr' + 'ipt>';
strFrame2+=' function getTime(id) {';
strFrame2+='    var sTime;';
strFrame2+='    var mTime = id.value;';
strFrame2+='    if(mTime<10){mTime = "0" + mTime;};';
strFrame2+='    sTime = document.all.hour.value + ":" +mTime;';
strFrame2+='	parent.meizzDayClick(sTime);';
strFrame2+=' }';
strFrame2+=' function clineTime() {';
strFrame2+='    var temptime;';
strFrame2+='    temptime = 0;';
strFrame2+='	parent.meizzDayClick(temptime);';
strFrame2+=' }';
strFrame2+='var timestr;';
strFrame2+='var m = new Date();';
strFrame2+='timestr = "<div style=\'border:#c5d9e8 1px solid;\' id=TimeLayer>";';
strFrame2+='	timestr+="<table><tr>";';
strFrame2+='	 for (var i=1; i<61; i++){';
strFrame2+='	 var j;';
strFrame2+='	   i<10?j=0+i.toString():j=i;';
strFrame2+='        var t =  i-1;';
strFrame2+='		if (i%6 == 0){';
strFrame2+='		  if(m.getMinutes().toString()==t){';
strFrame2+='		     timestr+="<td width=30 align=center bgcolor=\'#BEEBEE\' style=\'font-size:9pt;FONT-FAMILY: Verdana;cursor:pointer;\' onClick=getTime(minute"+t+")>" + t + "<input type=hidden id=minute"+t+" value="+t+"></td></tr><tr>";';
strFrame2+='		  }else{';
strFrame2+='		     timestr+="<td width=30 align=center  onmouseover=" + " style.backgroundColor=\'#BEEBEE\' " + " onmouseout=" + " style.backgroundColor=\'#fff\' " + " style=\'font-size:9pt;FONT-FAMILY: Verdana;cursor:pointer;\' onClick=getTime(minute"+t+")>" + t + "<input type=hidden id=minute"+t+" value="+t+"></td></tr><tr>";';
strFrame2+='		  }';
strFrame2+='		}else{';
strFrame2+='		  if(m.getMinutes().toString()==t){';
strFrame2+='		      timestr+="<td width=30 align=center bgcolor=\'#BEEBEE\' style=\'font-size:9pt;FONT-FAMILY: Verdana;cursor:pointer;\' onClick=getTime(minute"+t+")>" + t + "<input type=hidden id=minute"+t+" value="+t+"></td>";';
strFrame2+='		  }else{';
strFrame2+='		      timestr+="<td width=30 align=center onmouseover=" + " style.backgroundColor=\'#BEEBEE\' " + " onmouseout=" + " style.backgroundColor=\'#fff\' " + " style=\'font-size:9pt;FONT-FAMILY: Verdana;cursor:pointer;\' onClick=getTime(minute"+t+")>" + t + "<input type=hidden id=minute"+t+" value="+t+"></td>";';
strFrame2+='		  }';
strFrame2+='		}';
strFrame2+='	}';
strFrame2+='	timestr+="</tr><tr></table></div>";';
strFrame2+='	timestr+="<div style=\'text-align:right;margin-top:3px;\'><input type=\'button\' name=\'button\' value=\''+clearLabel+'\' onClick=clineTime() style=\'height:20px;width:45px;border:#ccc 1px solid;padding:2px;FONT-FAMILY: Verdana;\'>&nbsp;&nbsp;&nbsp;";';
strFrame2+='	timestr+="<input type=\'button\' name=\'button\' value=\''+closeLabel+'\' onClick=parent.closeLayer() style=\'height:20px;width:45px;border:#ccc 1px solid;padding:2px;FONT-FAMILY: Verdana;\'></div><div style=\'text-align:right;margin-top:3px;\'></div>";';
strFrame2+='	document.getElementById("nowhour").innerHTML = timestr;';
strFrame2+='</scr' + 'ipt>';

if(document.getElementById("meizzDateLayer2")&&document.getElementById("meizzDateLayer2").contentWindow){
	document.getElementById("meizzDateLayer2").contentWindow.document.writeln(strFrame2);
	document.getElementById("meizzDateLayer2").contentWindow.document.close(); 	
}
/*********时间控件生成结束**********/


function onShowStartTime(elementid){
	onProjTaskTime(elementid);  	
}

function onShowEndTime(elementid){
	onProjTaskTime(elementid);  
}

function onProjTaskTime(inputname){
	//alert(document.getElementById(inputname));
	var dads  = document.getElementById("meizzDateLayer2").style;
	setLastSelectTime(document.getElementById(inputname));
	var spanname = document.getElementById(inputname);
	var th = spanname;
	var ttop  = spanname.offsetTop; 
	var thei  = spanname.clientHeight;
	var tleft = spanname.offsetLeft; 
	var ttyp  = spanname.type;     
	while (spanname = spanname.offsetParent){
		ttop += spanname.offsetTop; 
		tleft += spanname.offsetLeft;
	}
	dads.top  = ((ttyp == "image") ? ttop + thei : ttop + thei + 0)+"px";
	dads.left = tleft+"px";
	outObject = th;	
	dads.display = '';
	bShow = true;
	
}

function setLastSelectTime(inputname)
{	
	if(inputname.value)
	{   //alert(inputname.value);
		var inputtime = inputname.value;
		var inputhour = inputtime.substring(0,2);
		var inputminute = inputtime.substring(3,5);
		if(inputminute!=-1)
		{
			inputminute = inputminute.valueOf()<10?inputminute.substring(1,2):inputminute;
			var inputminutetd = jQuery("#meizzDateLayer2")[0].contentWindow.document.getElementById('minute' + inputminute).parentNode;
			
			var inputhourselect = jQuery("#meizzDateLayer2")[0].contentWindow.document.getElementById('hour');
			for(var i=1;i<61;i++)
			{
				var t =  i-1;
				var otherminute = jQuery("#meizzDateLayer2")[0].contentWindow.document.getElementById('minute'+t).parentNode;
				otherminute.bgColor ="";
				otherminute.style.backgroundColor='#fff';
				//otherminute.fireEvent('onmouseout');
			}
			var hours = inputhourselect.options;
			
			for(key in hours)
			{
				if(hours[key]&&hours[key].value)
				{
					if(hours[key].value==inputhour)
					{
						hours[key].selected = true;
					}
				}
				
			}
			inputminutetd.bgColor='#BEEBEE';
			inputminutetd.style.backgroundColor='#BEEBEE';
		}
	}
}

function meizzDayClick(n){
	 //alert(n);
	 //alert(outObject.value);
     outObject.value=n;
	 closeLayer(); 
	 outObject.focus();
  }