/* * My97 DatePicker 4.8.5 * License: http://www.my97.net/license.asp */ var $dp,WdatePicker;(function(){var Config={ $langList:[{name:'en',charset:'UTF-8'}, {name:'zh-cn',charset:'gb2312'}, {name:'zh-tw',charset:'GBK'}], $skinList:[ {name:'default',charset:'gb2312'}, {name:'whyGreen',charset:'gb2312'}, {name:'blue',charset:'gb2312'}, {name:'green',charset:'gb2312'}, {name:'simple',charset:'gb2312'}, {name:'ext',charset:'gb2312'}, {name:'blueFresh',charset:'gb2312'}, {name:'twoer',charset:'gb2312'}, {name:'YcloudRed',charset:'gb2312'}, {name:'thinkpap',charset:'gb2312'}], $wdate:false, $crossFrame:true, $preLoad:false, $dpPath:'', doubleCalendar:false, enableKeyboard:true, enableInputMask:true, autoUpdateOnChanged:null, weekMethod:'MSExcel', position:{}, lang:'auto', skin:'default', dateFmt:'yyyy-MM-dd', realDateFmt:'yyyy-MM-dd', realTimeFmt:'HH:mm:ss', realFullFmt:'%Date %Time', minDate:'0001-01-01 00:00:00', maxDate:'9999-12-31 23:59:59', minTime:'00:00:00', maxTime:'23:59:59', startDate:'', alwaysUseStartDate:false, yearOffset:1911, firstDayOfWeek:0, isShowWeek:false, highLineWeekDay:true, isShowClear:true, isShowToday:true, isShowOK:true, isShowOthers:true, readOnly:false, errDealMode:0, autoPickDate:null, qsEnabled:true, autoShowQS:false, hmsMenuCfg:{H:[1,6],m:[5,6],s:[15,4]}, opposite:false,specialDates:null,specialDays:null,disabledDates:null,disabledDays:null,onpicking:null,onpicked:null,onclearing:null,oncleared:null,ychanging:null,ychanged:null,Mchanging:null,Mchanged:null,dchanging:null,dchanged:null,Hchanging:null,Hchanged:null,mchanging:null,mchanged:null,schanging:null,schanged:null,eCont:null,vel:null,elProp:'',errMsg:'',quickSel:[],has:{},getRealLang:function(){var arr=Config.$langList;for(var i=0;i0?1:0;var tmpday=new Date(this.dt['y'],this.dt['M'],0).getDate();this.dt['d']=Math.min(tmpday+offset,this.dt['d'])}}}}if(this.dt.refresh()){return this.dt}}return''},show:function(){var divs=dptop[d].getElementsByTagName('div'),maxZIndex=1e5;for(var i=0;imaxZIndex){maxZIndex=curZ}}this.dd.style.zIndex=maxZIndex+2;display(this.dd,"block");display(this.dd.firstChild,"")},unbind:function(el){el=this.$(el);if(el.initcfg){dpDetachEvent(el,'onclick',function(){main(el.initcfg)});dpDetachEvent(el,'onfocus',function(){main(el.initcfg)})}},hide:function(){display(this.dd,"none")},attachEvent:dpAttachEvent};for(var p in obj){dptop.$dp[p]=obj[p];}$dp=dptop.$dp}function dpAttachEvent(o,sType,fHandler,useCapture){if(o.addEventListener){var shortTypeName=sType.replace(/on/,"");fHandler._ieEmuEventHandler=function(e){return fHandler(e)};o.addEventListener(shortTypeName,fHandler._ieEmuEventHandler,useCapture)}else{o.attachEvent(sType,fHandler)}}function dpDetachEvent(o,sType,fHandler){if(o.removeEventListener){var shortTypeName=sType.replace(/on/,"");fHandler._ieEmuEventHandler=function(e){return fHandler(e)};o.removeEventListener(shortTypeName,fHandler._ieEmuEventHandler,false)}else{o.detachEvent(sType,fHandler)}}function compareCfg(o1,o2,issub){if(typeof o1!=typeof o2)return false;if(typeof o1=='object'){if(!issub){for(var o in o1){if(typeof o2[o]=='undefined')return false;if(!compareCfg(o1[o],o2[o],true))return false}}return true}else if(typeof o1=='function'&&typeof o2=='function'){return o1.toString()==o2.toString()}else{return o1==o2}}function getJsPath(){var path,tmp,scripts=w[d][tag]("script");for(var i=0;i0)path=path.substring(0,tmp+1);if(path)break}return path}function loadCSS(path,title,charset){var head=w[d][tag]('HEAD').item(0),style=w[d].createElement('link');if(head){style.href=path;style.rel='stylesheet';style.type='text/css';if(title)style.title=title;if(charset)style.charset=charset;head.appendChild(style)}}function getAbsM(w){w=w||dptop;var lm=0,tm=0;while(w!=dptop){var ifs=w.parent[d][tag]('iframe');for(var i=0;idb.scrollTop||doce.scrollLeft>db.scrollLeft))?doce:db;return{'top':doc.scrollTop,'left':doc.scrollLeft}}function disposeDP(e){try{var src=e?(e.srcElement||e.target):null;if($dp.cal&&!$dp.eCont&&$dp.dd&&src!=$dp.el&&$dp.dd.style.display=='block'){$dp.cal.close()}}catch(e){}}function dpLoaded(){$dp.status=2}var isDptopReady,dptopInterval;function main(initcfg,preLoad){if(!$dp)return;initcfg.el=initcfg.el||w[d].activeElement;if($dp.isTouch){try{initcfg.el.readOnly=true;initcfg.el.blur()}catch(e){}}initTopDP();var cfg={};for(var p in initcfg){cfg[p]=initcfg[p]}for(var p in Config){if(p.substring(0,1)!='$'&&cfg[p]===undefined){cfg[p]=Config[p]}}if(preLoad){if(!dptopReady()){dptopInterval=dptopInterval||setInterval(function(){if(dptop[d].readyState=='complete'){clearInterval(dptopInterval);}main(null,true)},50);return}if($dp.status==0){$dp.status=1;cfg.el=emptyEl;showPicker(cfg,true)}else{return}}else if(cfg.eCont){cfg.eCont=$dp.$(cfg.eCont);cfg.el=emptyEl;cfg.autoPickDate=true;cfg.qsEnabled=false;showPicker(cfg)}else{if(Config.$preLoad&&$dp.status!=2)return;if(!cfg.el){var evt=SearchEvent();if(w.event===evt||evt){cfg.srcEl=evt.srcElement||evt.target;evt.cancelBubble=true}}cfg.el=cfg.el=$dp.$(cfg.el||cfg.srcEl);if(cfg.el==null){alert('WdatePicker:el is null!\nexample:onclick="WdatePicker({el:this})"');return}try{if(!cfg.el||cfg.el['My97Mark']===true||cfg.el.disabled||($dp.dd&&display($dp.dd)!='none'&&$dp.dd.style.left!='-970px')){if(cfg.el['My97Mark'])cfg.el['My97Mark']=false;return}}catch(e){}if(evt&&cfg.el.nodeType==1&&!compareCfg(cfg.el.initcfg,initcfg)){$dp.unbind(cfg.el);dpAttachEvent(cfg.el,evt.type=='focus'?'onclick':'onfocus',function(){main(initcfg)});cfg.el.initcfg=initcfg;}showPicker(cfg)}function dptopReady(){if($IE&&dptop!=w&&dptop[d].readyState!='complete')return false;return true}function SearchEvent(){if($FF){try{var count=0;func=SearchEvent.caller;while(func!=null){var arg0=func.arguments[0];if(arg0&&(arg0+'').indexOf('Event')>=0||(count++)>97){return arg0}func=func.caller}}catch(e){}return null}return event}}function getStyle(obj,attribute){return obj.currentStyle?obj.currentStyle[attribute]:document.defaultView.getComputedStyle(obj,false)[attribute]}function display(obj,value){if(obj){if(value!=null)obj.style.display=value;else return getStyle(obj,'display')}}function showPicker(cfg,preLoad){var nodeName=cfg.el?cfg.el.nodeName:'INPUT';if(preLoad||cfg.eCont||new RegExp(/input|textarea|div|span|p|a/ig).test(nodeName)){cfg.elProp=cfg.elProp||nodeName=='INPUT'?'value':'innerHTML'}else{return}if(cfg.lang=='auto'){cfg.lang=$IE?navigator.browserLanguage.toLowerCase():navigator.language.toLowerCase()}if(!cfg.eCont){for(var p in cfg){$dp[p]=cfg[p]}}if(!$dp.dd||cfg.eCont||($dp.dd&&(cfg.getRealLang().name!=$dp.dd.lang||cfg.skin!=$dp.dd.skin))){if(cfg.eCont){ddInit(cfg.eCont,cfg)}else{$dp.dd=dptop[d].createElement("DIV");$dp.dd.style.cssText='position:absolute';dptop[d].body.appendChild($dp.dd);ddInit($dp.dd,cfg);if(preLoad){$dp.dd.style.left=$dp.dd.style.top='-970px'}else{$dp.show();setPos($dp)}}}else if($dp.cal){$dp.show();$dp.cal.init();if(!$dp.eCont)setPos($dp)}function ddInit(cont,cfg){var dm=dptop[d].domain,isCross=false,defHtml='';cont.innerHTML=defHtml;var langList=Config.$langList,skinList=Config.$skinList,doc;try{doc=cont.lastChild.contentWindow[d]}catch(e){isCross=true;cont.removeChild(cont.lastChild);var ifr=dptop[d].createElement("iframe");ifr.hideFocus=true;ifr.frameBorder=0;ifr.scrolling='no';ifr.src="javascript:(function(){var d=document;d.open();d.domain='"+dm+"';})()";cont.appendChild(ifr);setTimeout(function(){doc=cont.lastChild.contentWindow[d];ddWrite()},97);return}ddWrite();function ddWrite(){var realLang=cfg.getRealLang(),ver='4.9.0b3';cont.lang=realLang.name;cont.skin=cfg.skin;var h=[''];if(isCross)h[1]='document.domain="'+dm+'";';for(var i=0;i')}}h.push('');h.push('');h.push('');cfg.setPos=setPos;cfg.onload=dpLoaded;doc.write('');doc.cfg=cfg;doc.write(h.join(''));doc.close()}}function setPos(dp){var l=dp.position.left,t=dp.position.top,el=dp.el;if(el==emptyEl)return;if(el!=dp.srcEl&&(display(el)=='none'||el.type=='hidden'))el=dp.srcEl;var objxy=getBound(el),mm=getAbsM(w),currWH=getWH(dptop),scr=getScroll(dptop),ddHeight=$dp.dd.offsetHeight,ddWidth=$dp.dd.offsetWidth;if(isNaN(t))t=0;if((mm.topM+objxy.bottom+ddHeight>currWH.height)&&(mm.topM+objxy.top-ddHeight>0)){t+=scr.top+mm.topM+objxy.top-ddHeight-2}else{t+=scr.top+mm.topM+objxy.bottom;var offsetT=t-scr.top+ddHeight-currWH.height;if(offsetT>0)t-=offsetT}if(isNaN(l))l=0;l+=scr.left+Math.min(mm.leftM+objxy.left,currWH.width-ddWidth-5)-($IE?2:0);dp.dd.style.top=(t+2)+'px';dp.dd.style.left=l+'px'}}})();