From 0e98598fde62c7d79910c44c03114e439f72829a Mon Sep 17 00:00:00 2001
From: sunxiaobin89 <470459819@qq.com>
Date: Wed, 10 Aug 2022 00:05:10 +0800
Subject: [PATCH 1/4] =?UTF-8?q?laydate=20=E6=96=B0=E5=A2=9E=E4=B8=80?=
=?UTF-8?q?=E4=BA=9B=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/css/modules/laydate/default/laydate.css | 20 ++-
src/layui.js | 2 +-
src/modules/laydate.js | 162 +++++++++++++++-----
3 files changed, 146 insertions(+), 38 deletions(-)
diff --git a/src/css/modules/laydate/default/laydate.css b/src/css/modules/laydate/default/laydate.css
index 1238c92c..44118799 100644
--- a/src/css/modules/laydate/default/laydate.css
+++ b/src/css/modules/laydate/default/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/layui.js b/src/layui.js
index d370be40..3b7036e7 100644
--- a/src/layui.js
+++ b/src/layui.js
@@ -54,7 +54,7 @@
,laydate: 'laydate' //日期
,laypage: 'laypage' //分页
,laytpl: 'laytpl' //模板引擎
- ,layedit: 'layedit' //富文本编辑器
+ // ,layedit: 'layedit' //富文本编辑器
,form: 'form' //表单集
,upload: 'upload' //上传
,dropdown: 'dropdown' //下拉菜单
diff --git a/src/modules/laydate.js b/src/modules/laydate.js
index bfa37af6..f964c02f 100644
--- a/src/modules/laydate.js
+++ b/src/modules/laydate.js
@@ -54,14 +54,15 @@
,id = options.id;
thisModule.that[id] = that; //记录当前实例对象
-
- return {
+
+ that.inst = {
//提示框
hint: function(content){
that.hint.call(that, content);
}
,config: that.config
- };
+ }
+ return that.inst;
}
//字符常量
@@ -78,8 +79,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
}));
});
@@ -197,9 +198,21 @@
};
options.elem = lay(options.elem);
- options.eventElem = lay(options.eventElem);
+ // options.eventElem = lay(options.eventElem); // 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.split(','));
+ // 设置了全面版模式
+ if (options.fullPanel) {
+ if (options.type !== 'datetime' || options.range) {
+ // 目前只支持datetime的全面版
+ delete options.fullPanel;
+ }
+ }
//日期范围分隔符
that.rangeStr = options.range ? (
@@ -272,10 +285,10 @@
}
//设置唯一KEY
- if(!options.elem.attr('lay-key')){
- options.elem.attr('lay-key', that.index);
- options.eventElem.attr('lay-key', that.index);
- }
+ // if(!options.elem.attr('lay-key')){
+ options.elem.attr('lay-key', that.index);
+ // options.eventElem.attr('lay-key', that.index);
+ // }
//记录重要日期
options.mark = lay.extend({}, (options.calendar && options.lang === 'cn') ? {
@@ -357,7 +370,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('')
})
@@ -465,7 +488,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('')
}
@@ -486,13 +509,37 @@
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);
-
+ // 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);
+ //
+ // if('styleSheet' in style){
+ // style.setAttribute('type', 'text/css');
+ // style.styleSheet.cssText = styleText;
+ // } else {
+ // style.innerHTML = styleText;
+ // }
+ //
+ // lay(elem).addClass('laydate-theme-molv');
+ // elem.appendChild(style);
+ // }
+ 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;
@@ -521,6 +568,7 @@
Class.thisElemDate = that.elemID;
+ that.renderAdditional()
typeof options.ready === 'function' && options.ready(lay.extend({}, options.dateTime, {
month: options.dateTime.month + 1
}));
@@ -821,7 +869,7 @@
mark = title || YMD[2];
}
});
- mark && td.html(''+ mark +'');
+ mark && td.find('div').html(''+ mark +'');
return that;
};
@@ -837,7 +885,7 @@
lay.each(options.holidays, function(idx, item) {
lay.each(item, function(i, dayStr) {
if(dayStr === td.attr('lay-ymd')){
- td.html('' + YMD[2] + '');
}
@@ -931,7 +979,7 @@
}
YMD[1]++;
YMD[2] = st + 1;
- item.attr('lay-ymd', YMD.join('-')).html(YMD[2]);
+ item.attr('lay-ymd', YMD.join('-')).html('
' + YMD[2] + '
');
that.mark(item, YMD).holidays(item, YMD).limit(item, {
year: YMD[0]
,month: YMD[1] - 1
@@ -1369,6 +1417,18 @@
});
}, 300);
};
+
+ // 附加的渲染处理,在ready和change的时候调用
+ Class.prototype.renderAdditional = function(){
+ var that = this;
+ var options = that.config;
+
+ // 处理全面板
+ if (options.fullPanel) {
+ that.list('time', 0);
+ }
+
+ };
//执行 done/change 回调
Class.prototype.done = function(param, type){
@@ -1387,6 +1447,7 @@
that.preview();
param = param || [that.parse(), start, end];
+ type === 'change' && that.renderAdditional();
typeof options[type || 'done'] === 'function' && options[type || 'done'].apply(options, param);
return that;
@@ -1663,24 +1724,40 @@
//绑定的元素事件处理
Class.prototype.events = function(){
var that = this
- ,options = that.config
+ var options = that.config
//绑定呼出控件事件
- ,showEvent = function(elem, bind){
- elem.on(options.trigger, function(){
- //已经打开的面板避免重新渲染
- if(laydate.thisId === options.id) return;
- bind && (that.bindElem = this);
- that.render();
- });
- };
+ // var showEvent = function(elem, bind){
+ // elem.on(options.trigger, function(){
+ // console.log('showEvent, ' + options.trigger, elem);
+ // //已经打开的面板避免重新渲染
+ // if(laydate.thisId === options.id) return;
+ // bind && (that.bindElem = this);
+ // that.render();
+ // });
+ // };
if(!options.elem[0] || options.elem[0].eventHandler) return;
-
- showEvent(options.elem, 'bind');
- showEvent(options.eventElem);
+
+ // showEvent(options.elem, 'bind');
+ // showEvent(options.eventElem);
+
+ var showFn = function(){
+ //已经打开的面板避免重新渲染
+ if(laydate.thisId === options.id) return;
+ that.bindElem = this;
+ that.render();
+ }
+ options.elem.on(options.trigger, showFn);
options.elem[0].eventHandler = true;
+
+ that.destroy = function () {
+ that.remove();
+ options.elem.off(options.trigger, showFn);
+ options.elem[0].eventHandler = false;
+ delete thisModule.that[options.id];
+ }
};
//记录所有实例
@@ -1705,7 +1782,7 @@
if(
e.target === options.elem[0] ||
- e.target === options.eventElem[0] ||
+ // e.target === options.eventElem[0] ||
e.target === lay(options.closeStop)[0]
) return;
@@ -1745,6 +1822,14 @@
var inst = new Class(options);
return thisModule.call(inst);
};
+
+ // 获取
+ laydate.getIns = function (key) {
+ var that = thisModule.getThis(key);
+ if (that) {
+ return that.inst;
+ }
+ }
//将指定对象转化为日期值
laydate.parse = function(dateTime, format, one){
@@ -1795,6 +1880,13 @@
if(!that) return;
return that.remove();
};
+
+ // 销毁实例
+ laydate.destroy = function(id){
+ var that = thisModule.getThis(id || laydate.thisId);
+ if(!that) return;
+ return that.destroy();
+ };
//加载方式
isLayui ? (
From afd5dbd6767a70a4fc5a7fc838cb70c5365aae44 Mon Sep 17 00:00:00 2001
From: sunxiaobin89 <470459819@qq.com>
Date: Mon, 22 Aug 2022 23:14:41 +0800
Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=BA=9B?=
=?UTF-8?q?=E9=97=AE=E9=A2=98=E5=92=8C=E5=8A=A0=E5=BC=BA=E4=B8=80=E4=BA=9B?=
=?UTF-8?q?=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/css/modules/laydate.css | 20 ++++++++++++++++++--
src/layui.js | 1 -
src/modules/carousel.js | 20 +++++++++++++-------
src/modules/laydate.js | 10 +++++-----
src/modules/table.js | 3 ++-
src/modules/util.js | 6 +++---
6 files changed, 41 insertions(+), 19 deletions(-)
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/layui.js b/src/layui.js
index 3b7036e7..fb180859 100644
--- a/src/layui.js
+++ b/src/layui.js
@@ -54,7 +54,6 @@
,laydate: 'laydate' //日期
,laypage: 'laypage' //分页
,laytpl: 'laytpl' //模板引擎
- // ,layedit: 'layedit' //富文本编辑器
,form: 'form' //表单集
,upload: 'upload' //上传
,dropdown: 'dropdown' //下拉菜单
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 f964c02f..b24321e2 100644
--- a/src/modules/laydate.js
+++ b/src/modules/laydate.js
@@ -909,8 +909,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){
@@ -1094,7 +1094,7 @@
}
*/
- that.limit(lay(li), ymd, index);
+ that.limit(lay(li), ymd, index, null, type);
yearNum++;
});
@@ -1126,7 +1126,7 @@
}
*/
- that.limit(lay(li), ymd, index);
+ that.limit(lay(li), ymd, index, null, type);
});
lay(elemYM[isCN ? 0 : 1]).attr('lay-ym', listYM[0] + '-' + listYM[1])
@@ -1729,7 +1729,6 @@
//绑定呼出控件事件
// var showEvent = function(elem, bind){
// elem.on(options.trigger, function(){
- // console.log('showEvent, ' + options.trigger, elem);
// //已经打开的面板避免重新渲染
// if(laydate.thisId === options.id) return;
// bind && (that.bindElem = this);
@@ -1756,6 +1755,7 @@
that.remove();
options.elem.off(options.trigger, showFn);
options.elem[0].eventHandler = false;
+ options.elem.removeAttr('lay-key');
delete thisModule.that[options.id];
}
};
diff --git a/src/modules/table.js b/src/modules/table.js
index 06aa8492..7f9d34a8 100644
--- a/src/modules/table.js
+++ b/src/modules/table.js
@@ -754,7 +754,8 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
// 给设定百分比的列分配列宽
else if(/\d+%$/.test(item3.width)){
that.getCssRule(options.index +'-'+ item3.key, function(item){
- item.style.width = Math.floor((parseFloat(item3.width) / 100) * cntrWidth) + 'px';
+ var width = Math.floor((parseFloat(item3.width) / 100) * cntrWidth);
+ item.style.width = (width < minWidth ? minWidth : width) + 'px';
});
}
diff --git a/src/modules/util.js b/src/modules/util.js
index dea710d7..b1e3e2bc 100644
--- a/src/modules/util.js
+++ b/src/modules/util.js
@@ -13,7 +13,7 @@ layui.define('jquery', function(exports){
//固定块
fixbar: function(options){
var ELEM = 'layui-fixbar', TOP_BAR = 'layui-fixbar-top'
- ,dom = $(document), body = $('body')
+ ,dom = $(options.elem || document), body = $(options.elem || 'body')
,is, timer;
options = $.extend({
@@ -39,7 +39,7 @@ layui.define('jquery', function(exports){
is && (topBar.hide(), is = 0);
}
};
- if($('.'+ ELEM)[0]) return;
+ if(body.find('.'+ ELEM)[0]) return;
typeof options.css === 'object' && elem.css(options.css);
body.append(elem), scroll();
@@ -48,7 +48,7 @@ layui.define('jquery', function(exports){
elem.find('li').on('click', function(){
var othis = $(this), type = othis.attr('lay-type');
if(type === 'top'){
- $('html,body').animate({
+ (options.elem ? $(options.elem) : $('html,body')).animate({
scrollTop : 0
}, 200);
}
From 218b133fbf73e1b8f0d4dbeb40593853bd87afc7 Mon Sep 17 00:00:00 2001
From: sunxiaobin89 <470459819@qq.com>
Date: Mon, 22 Aug 2022 23:54:02 +0800
Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=BA=9B?=
=?UTF-8?q?=E9=97=AE=E9=A2=98=E5=92=8C=E5=8A=A0=E5=BC=BA=E4=B8=80=E4=BA=9B?=
=?UTF-8?q?=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/modules/laydate.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/modules/laydate.js b/src/modules/laydate.js
index b24321e2..4205b341 100644
--- a/src/modules/laydate.js
+++ b/src/modules/laydate.js
@@ -41,7 +41,7 @@
//主体CSS等待事件
,ready: function(fn){
var cssname = 'laydate', ver = ''
- ,path = (isLayui ? 'modules/laydate/' : 'theme/') + 'default/laydate.css?v='+ laydate.v + ver;
+ ,path = (isLayui ? 'modules/' : '') + 'laydate.css?v='+ laydate.v + ver;
isLayui ? layui.addcss(path, fn, cssname) : ready.link(path, fn, cssname);
return this;
}
@@ -896,7 +896,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
@@ -1824,7 +1824,7 @@
};
// 获取
- laydate.getIns = function (key) {
+ laydate.getInst = function (key) {
var that = thisModule.getThis(key);
if (that) {
return that.inst;
From 1c10d93ed6a2bbd72da0cbd9d97743a4189ff5bf Mon Sep 17 00:00:00 2001
From: sunxiaobin89 <470459819@qq.com>
Date: Wed, 31 Aug 2022 12:48:10 +0800
Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=BA=9B?=
=?UTF-8?q?=E9=97=AE=E9=A2=98=E5=92=8C=E5=8A=A0=E5=BC=BA=E4=B8=80=E4=BA=9B?=
=?UTF-8?q?=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/modules/laydate.js | 54 +++++++++---------------------------------
src/modules/table.js | 8 ++++---
2 files changed, 16 insertions(+), 46 deletions(-)
diff --git a/src/modules/laydate.js b/src/modules/laydate.js
index ab2836fe..976b0e10 100644
--- a/src/modules/laydate.js
+++ b/src/modules/laydate.js
@@ -290,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.mark = lay.extend({}, (options.calendar && options.lang === 'cn') ? {
'0-1-1': '元旦'
@@ -514,23 +512,6 @@
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);
- //
- // if('styleSheet' in style){
- // style.setAttribute('type', 'text/css');
- // style.styleSheet.cssText = styleText;
- // } else {
- // style.innerHTML = styleText;
- // }
- //
- // lay(elem).addClass('laydate-theme-molv');
- // elem.appendChild(style);
- // }
var style;
var styleText = [];
lay.each(options.theme, function (index, theme) {
@@ -1730,39 +1711,26 @@
var that = this
var options = that.config
- //绑定呼出控件事件
- // var showEvent = function(elem, bind){
- // elem.on(options.trigger, function(){
- // //已经打开的面板避免重新渲染
- // if(laydate.thisId === options.id) return;
- // bind && (that.bindElem = this);
- // that.render();
- // });
- // };
-
if(!options.elem[0] || options.elem[0].eventHandler) return;
- // showEvent(options.elem, 'bind');
- // showEvent(options.eventElem);
-
- var showFn = function(){
- //已经打开的面板避免重新渲染
+ var showEvent = function(){
+ // 已经打开的面板避免重新渲染
if(laydate.thisId === options.id) return;
that.bindElem = this;
that.render();
}
- options.elem.on(options.trigger, showFn);
+ //绑定呼出控件事件
+ options.elem.on(options.trigger, showEvent);
options.elem[0].eventHandler = true;
- options.eventElem.on(options.trigger, showFn);
- options.eventElem[0].eventHandler = true;
+ options.eventElem.on(options.trigger, showEvent);
that.destroy = function () {
that.remove();
- layui.each(['elem', 'eventElem'], function (index, name) {
- options[name].off(options.trigger, showFn);
- options[name][0].eventHandler = false;
- options[name].removeAttr('lay-key');
- })
+ options.elem.off(options.trigger, showEvent);
+ options.elem.removeAttr('lay-key');
+ options.elem[0].eventHandler = false;
+ options.eventElem.off(options.trigger, showEvent);
+ options.eventElem.removeAttr('lay-key');
delete thisModule.that[options.id];
}
diff --git a/src/modules/table.js b/src/modules/table.js
index 5bc36b7e..ec62da14 100644
--- a/src/modules/table.js
+++ b/src/modules/table.js
@@ -786,9 +786,11 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
// 给设定百分比的列分配列宽
else if(/\d+%$/.test(item3.width)){
- that.getCssRule(options.index +'-'+ item3.key, function(item){
- var width = Math.floor((parseFloat(item3.width) / 100) * cntrWidth); // 计算结果有可能大于最大或者小于最小 todo
- item.style.width = (width < minWidth ? minWidth : width) + 'px';
+ that.getCssRule(item3.key, function(item){
+ var width = Math.floor((parseFloat(item3.width) / 100) * cntrWidth);
+ width < minWidth && (width = minWidth);
+ width > maxWidth && (width = maxWidth);
+ item.style.width = width + 'px';
});
}