From 5a21b4f148b5bfb92c6a339c8fa018475ed0b35d Mon Sep 17 00:00:00 2001 From: Brightcells Date: Thu, 27 Aug 2015 04:32:00 +0800 Subject: [PATCH] to make init/skin do its work in options --- laydate.dev.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) mode change 100644 => 100755 laydate.dev.js diff --git a/laydate.dev.js b/laydate.dev.js old mode 100644 new mode 100755 index 663caa2..cbb73ee --- a/laydate.dev.js +++ b/laydate.dev.js @@ -13,7 +13,7 @@ //全局配置,如果采用默认均不需要改动 var config = { path: '', //laydate所在路径 - defSkin: 'default', //初始化皮肤 + skin: 'default', //初始化皮肤 format: 'YYYY-MM-DD', //日期格式 min: '1900-01-01 00:00:00', //最小日期 max: '2099-12-31 23:59:59', //最大日期 @@ -169,7 +169,7 @@ Dates.run = function(options){ elem = options.elem ? S(options.elem) : target; as.elemv = /textarea|input/.test(elem.tagName.toLocaleLowerCase()) ? 'value' : 'innerHTML'; - if (config.init) elem[as.elemv] = laydate.now(null, options.format || config.format) + if ('init' in options ? options.init : config.init) elem[as.elemv] = laydate.now(null, options.format || config.format) if(even && target.tagName){ if(!elem || elem === Dates.elem){ @@ -192,6 +192,8 @@ Dates.run = function(options){ }); }); } + + chgSkin(options.skin || config.skin) }; Dates.scroll = function(type){ @@ -845,8 +847,6 @@ Dates.events = function(){ Dates.init = (function(){ Dates.use('need'); - Dates.use(as[4] + config.defSkin, as[3]); - Dates.skinLink = Dates.query('#'+as[3]); }()); //重置定位 @@ -867,8 +867,12 @@ laydate.now = function(timestamp, format){ }; //皮肤选择 -laydate.skin = function(lib){ - Dates.skinLink.href = Dates.getPath + as[4] + lib + as[5]; +laydate.skin = chgSkin; + +//内部函数 +function chgSkin(lib) { + Dates.use(as[4] + lib, as[3]); + Dates.skinLink = Dates.query('#'+as[3]); }; }(window);