57 lines
13 KiB
JavaScript
Raw Normal View History

2025-06-11 17:46:57 +08:00
/*
* 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;i<arr.length;i++){if(arr[i].name==this.lang){return arr[i]}}return arr[0]}};WdatePicker=main;var w=window,emptyEl={innerHTML:''},d='document',de='documentElement',tag='getElementsByTagName',dptop,jsPath,$IE,$FF,$OPERA;var ua=navigator.userAgent,isTablet=/(?:iPad|PlayBook)/.test(ua)||(/(?:Android)/.test(ua)&&!/(?:Mobile)/.test(ua)),isPhone=/(?:iPhone)/.test(ua)||/(?:Android)/.test(ua)&&/(?:Mobile)/.test(ua);var appName=navigator.appName;if(appName=='Microsoft Internet Explorer')$IE=true;else if(appName=='Opera')$OPERA=true;else $FF=true;jsPath=Config.$dpPath||getJsPath();if(Config.$wdate){loadCSS(jsPath+'skin/WdatePicker.css')}dptop=w;if(Config.$crossFrame){try{while(dptop.parent!=dptop&&dptop.parent[d][tag]('frameset').length==0){dptop=dptop.parent}}catch(e){}}if(!dptop.$dp){dptop.$dp={ff:$FF,ie:$IE,opera:$OPERA,status:0,defMinDate:Config.minDate,defMaxDate:Config.maxDate,isTablet:isTablet,isPhone:isPhone,isTouch:isTablet||isPhone}}initTopDP();if(Config.$preLoad&&$dp.status==0){dpAttachEvent(w,'onload',function(){main(null,true)})}var docEventName=$dp.isTouch?'ontouchstart':'onmousedown';if(!w[d].docMD){dpAttachEvent(w[d],docEventName,disposeDP,true);w[d].docMD=true}if(!dptop[d].docMD){dpAttachEvent(dptop[d],docEventName,disposeDP,true);dptop[d].docMD=true}dpAttachEvent(w,'onunload',function(){if($dp.dd){display($dp.dd,"none")}});function initTopDP(){try{dptop[d],dptop.$dp=dptop.$dp||{}}catch(e){dptop=w;$dp=$dp||{}}var obj={win:w,$:function(el){return(typeof el=='string')?w[d].getElementById(el):el},$D:function(id,arg){return this.$DV(this.$(id).value,arg)},$DV:function(v,arg){if(v!=''){this.dt=$dp.cal.splitDate(v,$dp.cal.dateFmt);if(arg){for(var p in arg){if(this.dt[p]===undefined){this.errMsg='invalid property:'+p}else{this.dt[p]+=arg[p];if(p=='M'){var offset=arg['M']>0?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;i<divs.length;i++){var curZ=parseInt(divs[i].style.zIndex);if(curZ>maxZIndex){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;i<scripts.length;i++){path=scripts[i].getAttribute('src')||'';path=path.substr(0,path.toLowerCase().indexOf('wdatepicker.js'));var tmp=path.lastIndexOf("/");if(tmp