diff --git a/src/css/modules/laydate.css b/src/css/modules/laydate.css index 1238c92c..44118799 100644 --- a/src/css/modules/laydate.css +++ b/src/css/modules/laydate.css @@ -55,7 +55,7 @@ html #layuicss-laydate{display: none; position: absolute; width: 1989px;} .layui-laydate-content{position: relative; padding: 10px; -moz-user-select: none; -webkit-user-select: none; -ms-user-select: none;} .layui-laydate-content table{border-collapse: collapse; border-spacing: 0;} .layui-laydate-content th, -.layui-laydate-content td{width: 36px; height: 30px; padding: 5px; text-align: center;} +.layui-laydate-content td{width: 36px; height: 30px; padding: 0; text-align: center;} .layui-laydate-content th{font-weight: 400;} .layui-laydate-content td{position: relative; cursor: pointer;} .laydate-day-mark{position: absolute; left: 0; top: 0; width: 100%; line-height: 30px; font-size: 12px; overflow: hidden;} @@ -107,7 +107,7 @@ html #layuicss-laydate{display: none; position: absolute; width: 1989px;} .layui-laydate-content td{color: #666;} .layui-laydate-content td.laydate-selected{background-color: #B5FFF8;} .laydate-selected:hover{background-color: #00F7DE !important;} -.layui-laydate-content td:hover, +.layui-laydate-content td>div:hover, .layui-laydate-list li:hover{background-color: #eee; color: #333;} .laydate-time-list li ol{margin: 0; padding: 0; border: 1px solid #e2e2e2; border-left-width: 0;} .laydate-time-list li:first-child ol{border-left-width: 1px;} @@ -124,6 +124,7 @@ html #layuicss-laydate{display: none; position: absolute; width: 1989px;} .layui-laydate .layui-this{background-color: #009688 !important; color: #fff !important;} .layui-laydate .laydate-disabled, .layui-laydate .laydate-disabled:hover{background:none !important; color: #d2d2d2 !important; cursor: not-allowed !important; -moz-user-select: none; -webkit-user-select: none; -ms-user-select: none;} +.layui-laydate-content td>div{padding: 7px 0;height: 100%;} /* 墨绿/自定义背景色主题 */ .laydate-theme-molv{border: none;} @@ -153,4 +154,19 @@ html #layuicss-laydate{display: none; position: absolute; width: 1989px;} .laydate-theme-grid .laydate-month-list>li{margin: 0 -1px -1px 0;} .laydate-theme-grid .laydate-year-list>li{height: 43px; line-height: 43px;} .laydate-theme-grid .laydate-month-list>li{height: 71px; line-height: 71px;} +.laydate-theme-grid .layui-laydate-content td>div{height: 29px;margin-top: -1px;} +/* 圆圈高亮主题 */ +.laydate-theme-circle .layui-laydate-content td>div, +.laydate-theme-circle .layui-laydate-content td.layui-this>div{width: 28px;height: 28px;line-height: 28px;border-radius: 14px;margin: 0 4px;padding: 0;} +.layui-laydate.laydate-theme-circle .layui-laydate-content table td.layui-this{background-color: transparent !important;} +.laydate-theme-grid.laydate-theme-circle .layui-laydate-content td>div{margin: 0 3.5px;} + +/* 全面板 */ +.laydate-theme-fullpanel .layui-laydate-main {width: 526px;} +.laydate-theme-fullpanel .layui-laydate-list {width: 252px;left: 272px;} +.laydate-theme-fullpanel .laydate-set-ym span {display: none;} +.laydate-theme-fullpanel .laydate-time-show .layui-laydate-header .layui-icon, +.laydate-theme-fullpanel .laydate-time-show .laydate-set-ym span[lay-type="year"], +.laydate-theme-fullpanel .laydate-time-show .laydate-set-ym span[lay-type="month"] {display: inline-block !important;} +.laydate-theme-fullpanel .laydate-btns-time{display: none;} \ No newline at end of file diff --git a/src/modules/carousel.js b/src/modules/carousel.js index 076a859b..116f51b8 100644 --- a/src/modules/carousel.js +++ b/src/modules/carousel.js @@ -194,6 +194,18 @@ layui.define('jquery', function(exports){ that.slide(type); }); }; + + // 跳转到特定下标 + Class.prototype.jump = function(index){ + var that = this; + var options = that.config; + + if(index > options.index){ + that.slide('add', index - options.index); + } else if(index < options.index){ + that.slide('sub', options.index - index); + } + } //指示器 Class.prototype.indicator = function(){ @@ -226,13 +238,7 @@ layui.define('jquery', function(exports){ //事件 tplInd.find('li').on(options.trigger === 'hover' ? 'mouseover' : options.trigger, function(){ - var othis = $(this) - ,index = othis.index(); - if(index > options.index){ - that.slide('add', index - options.index); - } else if(index < options.index){ - that.slide('sub', options.index - index); - } + that.jump($(this).index()); }); }; diff --git a/src/modules/laydate.js b/src/modules/laydate.js index 79de8ed5..ee1128d1 100644 --- a/src/modules/laydate.js +++ b/src/modules/laydate.js @@ -61,8 +61,8 @@ ,id = options.id; thisModule.that[id] = that; //记录当前实例对象 - - return { + + return that.inst = { //提示框 hint: function(content){ that.hint.call(that, content); @@ -85,8 +85,8 @@ // 若 elem 非唯一,则拆分为多个实例 var elem = lay(options.elem || that.config.elem); if(elem.length > 1){ - layui.each(elem, function(){ - laydate.render(lay.extend({}, that.config, { + lay.each(elem, function(){ + laydate.render(lay.extend({}, that.config, lay.options(this),{ elem: this })); }); @@ -207,7 +207,18 @@ options.eventElem = lay(options.eventElem); if(!options.elem[0]) return; - + var thatTemp = thisModule.that[options.elem.attr('lay-key')] + thatTemp && thatTemp.destroy && thatTemp.destroy(); // 销毁上一个实例以便重新渲染 + + layui.type(options.theme) !== 'array' && (options.theme = [options.theme]); + // 设置了全面版模式 + if (options.fullPanel) { + if (options.type !== 'datetime' || options.range) { + // 目前只支持datetime的全面版 + delete options.fullPanel; + } + } + //日期范围分隔符 that.rangeStr = options.range ? ( typeof options.range === 'string' ? options.range : '-' @@ -279,11 +290,9 @@ } //设置唯一KEY - if(!options.elem.attr('lay-key')){ - options.elem.attr('lay-key', that.index); - options.eventElem.attr('lay-key', that.index); - } - + options.elem.attr('lay-key', that.index); + options.eventElem.attr('lay-key', that.index); + //记录重要日期 options.mark = lay.extend({}, (options.calendar && options.lang === 'cn') ? { '0-1-1': '元旦' @@ -364,7 +373,17 @@ 'layui-laydate' ,options.range ? ' layui-laydate-range' : '' ,isStatic ? (' '+ ELEM_STATIC) : '' - ,options.theme && options.theme !== 'default' && !/^#/.test(options.theme) ? (' laydate-theme-' + options.theme) : '' + ,options.fullPanel ? ' laydate-theme-fullpanel' : '' // 全面版 + // ,options.theme && options.theme !== 'default' && !/^#/.test(options.theme) ? (' laydate-theme-' + options.theme) : '' + ,(function () { + var themeStr = ''; + lay.each(options.theme, function (index, theme) { + if (theme !== 'default' && !/^#/.test(theme)) { + themeStr += ' laydate-theme-' + theme; + } + }) + return themeStr; + })() ].join('') }) @@ -472,7 +491,7 @@ if(options.type === 'datetime'){ html.push(''+ lang.timeTips +''); } - if(!(!options.range && options.type === 'datetime')){ + if(!(!options.range && options.type === 'datetime') || options.fullPanel){ html.push('') } @@ -493,13 +512,20 @@ options.showBottom && elem.appendChild(divFooter); //生成自定义主题 - if(/^#/.test(options.theme)){ - var style = lay.elem('style') - ,styleText = [ - '#{{id}} .layui-laydate-header{background-color:{{theme}};}' - ,'#{{id}} .layui-this{background-color:{{theme}} !important;}' - ].join('').replace(/{{id}}/g, that.elemID).replace(/{{theme}}/g, options.theme); - + var style; + var styleText = []; + lay.each(options.theme, function (index, theme) { + if(/^#/.test(theme)){ + style = style || lay.elem('style'); + styleText.push([ + '#{{id}} .layui-laydate-header{background-color:{{theme}};}' + ,'#{{id}} li.layui-this,#{{id}} td.layui-this>div{background-color:{{theme}} !important;}' + ,options.theme.indexOf('circle') !== -1 ? '' : '#{{id}} .layui-this{background-color:{{theme}} !important;}' + ].join('').replace(/{{id}}/g, that.elemID).replace(/{{theme}}/g, theme)); + } + }); + if (style) { + styleText = styleText.join(''); if('styleSheet' in style){ style.setAttribute('type', 'text/css'); style.styleSheet.cssText = styleText; @@ -528,6 +554,7 @@ Class.thisElemDate = that.elemID; + that.renderAdditional() typeof options.ready === 'function' && options.ready(lay.extend({}, options.dateTime, { month: options.dateTime.month + 1 })); @@ -828,7 +855,7 @@ mark = title || YMD[2]; } }); - mark && td.html(''+ mark +''); + mark && td.find('div').html(''+ mark +''); return that; }; @@ -844,7 +871,7 @@ lay.each(options.holidays, function(idx, item) { lay.each(item, function(i, dayStr) { if(dayStr === td.attr('lay-ymd')){ - td.html('' + YMD[2] + ''); } @@ -855,7 +882,7 @@ }; //无效日期范围的标记 - Class.prototype.limit = function(elem, date, index, time){ + Class.prototype.limit = function(elem, date, index, time, type){ var that = this ,options = that.config, timestrap = {} ,dateTime = index > (time ? 0 : 41) ? that.endDate : options.dateTime @@ -868,8 +895,8 @@ }, function(key, item){ timestrap[key] = that.newDate(lay.extend({ year: item.year - ,month: item.month - ,date: item.date + ,month: type === 'year' ? 0 : item.month // 年份的时候只比较年 + ,date: (type === 'year' || type === 'month') ? 1 : item.date // 年月只比较年月不与最大最小比日期 }, function(){ var hms = {}; lay.each(time, function(i, keys){ @@ -938,7 +965,7 @@ } YMD[1]++; YMD[2] = st + 1; - item.attr('lay-ymd', YMD.join('-')).html(YMD[2]); + item.attr('lay-ymd', YMD.join('-')).html('