From 9b5a6231c87328a80d15936bcde32f14aebcc9c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Fri, 16 Dec 2022 17:19:50 +0800 Subject: [PATCH 01/28] =?UTF-8?q?=E4=BC=98=E5=8C=96=20table=20=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E7=9A=84=E6=95=B0=E6=8D=AE=E9=87=8F=E5=BE=88=E5=A4=A7?= =?UTF-8?q?=E6=97=B6=E5=8F=AF=E8=83=BD=E5=AD=98=E5=9C=A8=E7=9A=84=E5=8D=A1?= =?UTF-8?q?=E9=A1=BF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/table.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/modules/table.js b/src/modules/table.js index a780d981..a8add74d 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -2498,9 +2498,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ return; } - var content = item1[item3.field] - ,td = thatTable.layBody.find('tr[data-index="'+ i1 +'"]>td'); - + var content = item1[item3.field]; if(content === undefined || content === null) content = ''; i1 == 0 && dataTitle.push(item3.fieldTitle || item3.title || item3.field || ''); @@ -2509,11 +2507,12 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ ,content: content ,tplData: item1 ,text: 'text' - ,obj: thatTable.commonMember.call(td.eq(0), { + ,obj: { td: function(field){ + var td = thatTable.layBody.find('tr[data-index="'+ i1 +'"]>td'); return td.filter('[data-field="'+ field +'"]'); } - }) + } }) + '"'); } }); From 1ff6cd423cb0168538b07592d41624459ec132f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Mon, 19 Dec 2022 23:00:20 +0800 Subject: [PATCH 02/28] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20font=20=E6=9B=B4?= =?UTF-8?q?=E5=A4=9A=E5=86=85=E7=BD=AE=E5=AD=97=E4=BD=93=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/css/layui.css | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/css/layui.css b/src/css/layui.css index 4f54683b..200269ab 100644 --- a/src/css/layui.css +++ b/src/css/layui.css @@ -633,11 +633,18 @@ a cite{font-style: normal; *cursor:pointer;} .layui-text pre:not(.layui-code){padding: 15px; font-family: Lucida Console,Consolas,Courier New; background-color: #FAFAFA;} /* 字体大小及颜色 */ -.layui-font-12{font-size: 12px !important;;} +.layui-font-12{font-size: 12px !important;} +.layui-font-13{font-size: 13px !important;} .layui-font-14{font-size: 14px !important;} .layui-font-16{font-size: 16px !important;} .layui-font-18{font-size: 18px !important;} .layui-font-20{font-size: 20px !important;} +.layui-font-22{font-size: 22px !important;} +.layui-font-24{font-size: 24px !important;} +.layui-font-26{font-size: 26px !important;} +.layui-font-28{font-size: 28px !important;} +.layui-font-30{font-size: 30px !important;} +.layui-font-32{font-size: 32px !important;} .layui-font-red{color: #FF5722 !important;} /*赤*/ .layui-font-orange{color: #FFB800!important;} /*橙*/ @@ -918,7 +925,6 @@ a cite{font-style: normal; *cursor:pointer;} .layui-table-total tr, .layui-table-patch, .layui-table-mend, -.layui-table tbody tr:hover, .layui-table-hover, .layui-table-click{background-color: #FAFAFA;} From 753dd49e87d26475a9f2cebdc6d0ad9122d4aa62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Tue, 3 Jan 2023 01:58:03 +0800 Subject: [PATCH 03/28] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20scollbar=20=E5=BC=BA?= =?UTF-8?q?=E5=88=B6=E9=9A=90=E8=97=8F=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/css/layui.css | 1 + 1 file changed, 1 insertion(+) diff --git a/src/css/layui.css b/src/css/layui.css index 200269ab..74c456a7 100644 --- a/src/css/layui.css +++ b/src/css/layui.css @@ -556,6 +556,7 @@ a cite{font-style: normal; *cursor:pointer;} /* 其它辅助 */ .layui-auxiliar-moving{position: fixed; left: 0; right: 0; top: 0; bottom: 0; width: 100%; height: 100%; background: none; z-index: 9999999999;} +.layui-scollbar-hide{overflow: hidden !important;} /* From 1d1ed086f1001c48be0b4196b377892af6ea0b5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Tue, 3 Jan 2023 01:58:43 +0800 Subject: [PATCH 04/28] =?UTF-8?q?=E4=BC=98=E5=8C=96=20table=20=E5=B1=80?= =?UTF-8?q?=E9=83=A8=20UI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/css/layui.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/css/layui.css b/src/css/layui.css index 74c456a7..82a79c6b 100644 --- a/src/css/layui.css +++ b/src/css/layui.css @@ -917,7 +917,7 @@ a cite{font-style: normal; *cursor:pointer;} /** 表格 **/ .layui-table{width: 100%; margin: 10px 0; background-color: #fff; color: #5F5F5F;} .layui-table tr{transition: all .3s; -webkit-transition: all .3s;} -.layui-table th{text-align: left; font-weight: 400;} +.layui-table th{text-align: left; font-weight: 600;} .layui-table thead tr, .layui-table-header, @@ -925,7 +925,7 @@ a cite{font-style: normal; *cursor:pointer;} .layui-table-total, .layui-table-total tr, .layui-table-patch, -.layui-table-mend, +.layui-table-mend{} .layui-table-hover, .layui-table-click{background-color: #FAFAFA;} From 493cd53e7c22fc451b2678b385e38ce44e5b24c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Tue, 3 Jan 2023 02:00:02 +0800 Subject: [PATCH 05/28] =?UTF-8?q?=E4=BC=98=E5=8C=96=20text=20=E6=96=87?= =?UTF-8?q?=E6=9C=AC=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/css/layui.css | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/css/layui.css b/src/css/layui.css index 82a79c6b..bf88136f 100644 --- a/src/css/layui.css +++ b/src/css/layui.css @@ -606,13 +606,13 @@ a cite{font-style: normal; *cursor:pointer;} .layui-timeline-item:before{background-color: #eee;} /* 文本区域 */ -.layui-text{line-height: 1.6; font-size: 14px; color: #5F5F5F;} +.layui-text{line-height: 1.8; font-size: 14px;} .layui-text h1, .layui-text h2, .layui-text h3, .layui-text h4, .layui-text h5, -.layui-text h6{font-weight: 500; color: #333;} +.layui-text h6{font-weight: 500; color: #3A3A3A;} .layui-text h1{font-size: 32px;} .layui-text h2{font-size: 24px;} .layui-text h3{font-size: 18px;} @@ -622,7 +622,7 @@ a cite{font-style: normal; *cursor:pointer;} .layui-text a:not(.layui-btn){color: #01AAED;} .layui-text a:not(.layui-btn):hover{text-decoration: underline;} .layui-text ul, -.layui-text ol{padding: 5px 0 5px 15px;} +.layui-text ol{padding-left: 15px;} .layui-text ul li{margin-top: 5px; list-style-type: disc;} .layui-text ol li{margin-top: 5px; list-style-type: decimal;} .layui-text em, @@ -631,7 +631,7 @@ a cite{font-style: normal; *cursor:pointer;} .layui-text p:first-child{margin-top: 0;} .layui-text p:last-child{margin-bottom: 0;} .layui-text blockquote:not(.layui-elem-quote){padding: 5px 15px; border-left: 5px solid #eee;} -.layui-text pre:not(.layui-code){padding: 15px; font-family: Lucida Console,Consolas,Courier New; background-color: #FAFAFA;} +.layui-text pre > code:not(.layui-code){padding: 15px; font-family: Lucida Console,Consolas,Courier New; background-color: #FAFAFA;} /* 字体大小及颜色 */ .layui-font-12{font-size: 12px !important;} From e4df5b86881e4b9c22493f5ed63c417d4d8e3510 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Tue, 3 Jan 2023 02:00:39 +0800 Subject: [PATCH 06/28] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20lay=20=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=E6=A0=87=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/lay.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/lay.js b/src/modules/lay.js index fceff512..aff58385 100644 --- a/src/modules/lay.js +++ b/src/modules/lay.js @@ -1,5 +1,5 @@ -/** lay 基础 DOM 操作 | MIT Licensed */ +/** lay 基础模块 | MIT Licensed */ ;!function(window){ //gulp build: lay-header "use strict"; From 6e6034f1009574ff8ebee38439df0606dd6cc226 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Sat, 7 Jan 2023 22:37:24 +0800 Subject: [PATCH 07/28] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20form=20=E4=B8=AD?= =?UTF-8?q?=E9=83=A8=E5=88=86=E5=B1=9E=E6=80=A7=E7=9A=84=E9=A9=BC=E5=B3=B0?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E4=B8=BA=E4=B8=80=E8=88=AC=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/form.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/form.js b/src/modules/form.js index ff5dbeb5..1d60d670 100644 --- a/src/modules/form.js +++ b/src/modules/form.js @@ -766,7 +766,7 @@ layui.define(['layer', 'util'], function(exports){ var othis = $(this); var verifyStr = othis.attr('lay-verify') || ''; var vers = verifyStr.split('|'); - var verType = othis.attr('lay-verType'); // 提示方式 + var verType = othis.attr('lay-vertype'); // 提示方式 var value = othis.val(); othis.removeClass(DANGER); // 移除警示样式 @@ -791,7 +791,7 @@ layui.define(['layer', 'util'], function(exports){ errorText = errorText || rule[1]; if(thisVer === 'required'){ - errorText = othis.attr('lay-reqText') || errorText; + errorText = othis.attr('lay-reqtext') || errorText; } // 若为必填项或者非空命中校验,则阻止提交,弹出提示 From 3a090f6c83d29e4b19b6bbb3c6641779e2e6a9b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Sat, 7 Jan 2023 22:38:06 +0800 Subject: [PATCH 08/28] =?UTF-8?q?=E5=BE=AE=E8=B0=83=20css=20=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/css/layui.css | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/css/layui.css b/src/css/layui.css index bf88136f..3f38834b 100644 --- a/src/css/layui.css +++ b/src/css/layui.css @@ -560,10 +560,8 @@ a cite{font-style: normal; *cursor:pointer;} /* - - 默认主题 - -*/ + * 默认主题 + */ /* 背景颜色 */ From fec0f1951575a5fa529840bba48a7815baa98e51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Fri, 13 Jan 2023 03:42:12 +0800 Subject: [PATCH 09/28] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20`util.openWin()`=20?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/util.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/modules/util.js b/src/modules/util.js index 33ce44f4..c8495f34 100644 --- a/src/modules/util.js +++ b/src/modules/util.js @@ -260,6 +260,17 @@ layui.define('jquery', function(exports){ .replace(/\</g, '<').replace(/\>/g, '>') .replace(/\'/g, '\'').replace(/\"/g, '"'); } + + // 打开新窗口 + ,openWin: function(options){ + var win; + options = options || {}; + win = options.window || window.open((options.url || ''), options.target, options.specs); + if(options.url) return; + win.document.open('text/html', 'replace'); + win.document.write(options.content || ''); + win.document.close(); + } //让指定的元素保持在可视区域 ,toVisibleArea: function(options){ From 54eab77bab8f1c94e3cd738cd0106da26b75027e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Fri, 13 Jan 2023 03:42:49 +0800 Subject: [PATCH 10/28] =?UTF-8?q?=E4=BC=98=E5=8C=96=20all=20=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/all.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/all.js b/src/modules/all.js index 3e077615..bcfa718a 100644 --- a/src/modules/all.js +++ b/src/modules/all.js @@ -1,4 +1,4 @@ -/*! +/** * 用于加载所有内置模块 * MIT Licensed */ From a9a2b24f49eb9fd6a0cbfbf730b67b8e12ff6789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Fri, 13 Jan 2023 03:44:43 +0800 Subject: [PATCH 11/28] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E6=A1=86=E5=8A=A8=E6=80=81=E7=82=B9=E7=BC=80=20=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/form.js | 123 ++++++++++++++++++++++++++++---------------- 1 file changed, 78 insertions(+), 45 deletions(-) diff --git a/src/modules/form.js b/src/modules/form.js index 1d60d670..bf288d99 100644 --- a/src/modules/form.js +++ b/src/modules/form.js @@ -158,73 +158,106 @@ layui.define(['layer', 'util'], function(exports){ // 初始化全局的 autocomplete options.autocomplete && inputs.attr('autocomplete', options.autocomplete); - // 初始化 input 套件 + // 初始化输入框动态点缀 elemForm.find('input[lay-affix],textarea[lay-affix]').each(function(){ var othis = $(this); var affix = othis.attr('lay-affix'); var CLASS_SUFFIX = 'layui-input-suffix'; - var elemNext = othis.next('.'+ CLASS_SUFFIX); + var CLASS_AFFIX = 'layui-input-affix'; var disabled = othis.is('[disabled]') || othis.is('[readonly]'); - var hideElem = function(elem, value){ - if(!elem) return; + + // 根据是否空值来显示或隐藏元素 + var showAffix = function(elem, value){ + elem = $(elem); + if(!elem[0]) return; elem[$.trim(value) ? 'removeClass' : 'addClass'](HIDE); }; - var renderSuffix = function(type, _disabled){ - elemNext.remove(); - elemNext = $(['
' - ,'' - ,'
'].join('')); + + // 渲染动态点缀内容 + var renderAffix = function(){ + var opts = affixOptions[affix] || { + value: affix + }; + var elemAffix = $('
'); + var elemIcon = $(''); - othis.after(elemNext); - hideElem(elemNext, othis.val()); + elemAffix.append(elemIcon); + + // 移除旧的元素 + var hasElemAffix = othis.next('.'+ CLASS_AFFIX); + if(hasElemAffix[0]) hasElemAffix.remove(); + + // 是否已经存在后缀元素 + var hasElemSuffix = othis.next('.'+ CLASS_SUFFIX); + if(hasElemSuffix[0]){ + hasElemAffix = hasElemSuffix.find('.'+ CLASS_AFFIX); + if(hasElemAffix[0]) hasElemAffix.remove(); + + hasElemSuffix.prepend(elemAffix); + + othis.css('padding-right', function(){ + var paddingRight = othis.closest('.layui-input-group')[0] + ? 0 + : hasElemSuffix.outerWidth(); + return paddingRight + elemAffix.outerWidth() + }); + } else { + elemAffix.addClass(CLASS_SUFFIX); + othis.after(elemAffix); + } + + opts.show === 'auto' && showAffix(elemAffix, othis.val()); // 输入事件 othis.on('input propertychange', function(){ var value = this.value; - hideElem(elemNext, value); + opts.show === 'auto' && showAffix(elemAffix, value); }); - // 点击后缀套件事件 - elemNext.on('click', function(){ - var filter = othis.attr('lay-filter'); - if($(this).is('[disabled]')) return; - obj[affix] && obj[affix][1].call(this); + // 点击动态后缀事件 + elemIcon.on('click', function(){ + var inputFilter = othis.attr('lay-filter'); + if($(this).hasClass(DISABLED)) return; + + typeof opts.click === 'function' && opts.click.call(this, othis, opts); // 对外事件 - layui.event.call(this, MOD_NAME, 'input-affix('+ filter +')', { - elem: othis[0] - ,affix: affix + layui.event.call(this, MOD_NAME, 'input-affix('+ inputFilter +')', { + elem: othis[0], + affix: affix, + options: opts }); }); }; - // 渲染内置套件 - var obj = { - // 清空 - clear: [function(){ // 渲染 - renderSuffix('clear', disabled); - }, function(){ // 事件 - othis.val('').focus(); - hideElem(elemNext, null); - }] - - // 密码显隐 - ,eye: [function(){ // 渲染 - renderSuffix('eye-invisible'); - }, function(){ // 事件 - var SHOW_NAME = 'LAY_FORM_INPUT_AFFIX_SHOW'; - var isShow = othis.data(SHOW_NAME); - - othis.attr('type', isShow ? 'password' : 'text').data(SHOW_NAME, !isShow); - renderSuffix(isShow ? 'eye-invisible' : 'eye'); - }] + // 动态点缀配置项 + var affixOptions = { + eye: { // 密码显隐 + value: 'eye-invisible', + click: function(elem, opts){ // 事件 + var SHOW_NAME = 'LAY_FORM_INPUT_AFFIX_SHOW'; + var isShow = elem.data(SHOW_NAME); + + elem.attr('type', isShow ? 'password' : 'text').data(SHOW_NAME, !isShow); + + opts.value = isShow ? 'eye-invisible' : 'eye'; + renderAffix(); + } + }, + clear: { // 内容清除 + value: 'clear', + click: function(elem){ + elem.val('').focus(); + showAffix($(this).parent(), null); + }, + show: 'auto', // 根据输入框值是否来显示或隐藏点缀图标 + disabled: disabled // 跟随输入框禁用状态 + } }; - obj[affix] && obj[affix][0](); + renderAffix(); }); } From a3154b66235272f9b39af3982af01295c2abe133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Fri, 13 Jan 2023 03:45:30 +0800 Subject: [PATCH 12/28] =?UTF-8?q?=E4=BC=98=E5=8C=96=20`form.render()`=20?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/form.js | 53 +++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/src/modules/form.js b/src/modules/form.js index bf288d99..090fbcbb 100644 --- a/src/modules/form.js +++ b/src/modules/form.js @@ -745,31 +745,42 @@ layui.define(['layer', 'util'], function(exports){ }); } }; - if (layui.type(type) === 'object') { - // jquery 对象 - type.each(function (index, item) { - var elem = $(item); - if (!elem.closest(ELEM).length) { - // 如果不是存在layui-form中的直接跳过 - return; - } - if (item.tagName === 'SELECT') { - items['select'](elem); - } else if (item.tagName === 'INPUT') { - var itemType = item.type; - if (itemType === 'checkbox' || itemType === 'radio') { - items[itemType](elem); - } else { - items['input'](elem); - } - } + + // 执行所有渲染项 + var renderItem = function(){ + layui.each(items, function(index, item){ + item(); }); + }; + + // jquery 对象 + if (layui.type(type) === 'object') { + // 若对象为表单域容器 + if($(type).is(ELEM)){ + elemForm = $(type); + renderItem(); + } else { // 对象为表单项 + type.each(function (index, item) { + var elem = $(item); + if (!elem.closest(ELEM).length) { + return; // 若不在 layui-form 容器中直接跳过 + } + if (item.tagName === 'SELECT') { + items['select'](elem); + } else if (item.tagName === 'INPUT') { + var itemType = item.type; + if (itemType === 'checkbox' || itemType === 'radio') { + items[itemType](elem); + } else { + items['input'](elem); + } + } + }); + } } else { type ? ( items[type] ? items[type]() : hint.error('不支持的 "'+ type + '" 表单渲染') - ) : layui.each(items, function(index, item){ - item(); - }); + ) : renderItem(); } return that; }; From 366968e2b100a66bac6dbc39ad1e45ab5a7f6daf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Fri, 13 Jan 2023 03:45:44 +0800 Subject: [PATCH 13/28] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20form=20=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/form.html | 127 ++++++++++++++++++++++++++------------------- 1 file changed, 73 insertions(+), 54 deletions(-) diff --git a/examples/form.html b/examples/form.html index 5935ec69..3b9ad76b 100644 --- a/examples/form.html +++ b/examples/form.html @@ -17,17 +17,19 @@
-
-
-
- 前置信息 -
- -
- 后置信息 +
+
+
+
+ 前置信息 +
+ +
+ 后置信息 +
-
+
@@ -35,75 +37,87 @@
-
- -
-
-
- +
+
+
+ +
+
-
-
-
- +
+
+
+ +
+
-
-
- -
-
-
- +
+
+
-
-
- +
+
+
+ +
+ +
-
- +
+
+ +
-
- -
-
-
+
+
+ +
+
+
+
- +
-
+
- +
-
-
- +
+
+
+ +
+
-
-
- -
- -
+
+
+ +
+
+
+ +
+

@@ -406,6 +420,11 @@ ,xxxxxxxxx: 123 }); + // 自定义动态点缀事件 + form.on('input-affix(set)', function(data){ + var elem = data.elem; + elem.value = '通过自定义事件设置的值'; + }); //事件 form.on('select(quiz111)', function(data){ From 61637f260cacc1a5bf88b2e81617a36cca0f4c0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Wed, 25 Jan 2023 19:05:49 +0800 Subject: [PATCH 14/28] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20table=20=E7=9A=84?= =?UTF-8?q?=E5=90=88=E8=AE=A1=E8=A1=8C=E6=A8=A1=E6=9D=BF=20`TOTAL=5FROW`?= =?UTF-8?q?=20=E7=89=B9=E5=AE=9A=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/table.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/table.js b/src/modules/table.js index a8add74d..43a9550f 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -1340,6 +1340,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ if(typeof totalRow === 'string'){ return laytpl(totalRow).render($.extend({ TOTAL_NUMS: TOTAL_NUMS || totalNums[field], + TOTAL_ROW: totalRowData || {}, LAY_COL: item3 }, item3)); } @@ -2275,7 +2276,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ }); })(); - //初始化 + // 初始化 table.init = function(filter, settings){ settings = settings || {}; var that = this; @@ -2347,7 +2348,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ tableIns.reloadData({ data: options.data - }) + }); } }); From 926522da296f9a6fa7880a83652d6e189b2bf20c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Wed, 25 Jan 2023 19:07:41 +0800 Subject: [PATCH 15/28] =?UTF-8?q?=E8=B0=83=E6=95=B4=20checkbox=20=E7=9A=84?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E9=A3=8E=E6=A0=BC=E4=B8=BA=20`primary`=20?= =?UTF-8?q?=E9=A3=8E=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/form.js | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/modules/form.js b/src/modules/form.js index 090fbcbb..f33927dc 100644 --- a/src/modules/form.js +++ b/src/modules/form.js @@ -2,7 +2,7 @@ * form 表单组件 */ -layui.define(['layer', 'util'], function(exports){ +layui.define(['lay', 'layer', 'util'], function(exports){ "use strict"; var $ = layui.$; @@ -174,16 +174,17 @@ layui.define(['layer', 'util'], function(exports){ }; // 渲染动态点缀内容 - var renderAffix = function(){ - var opts = affixOptions[affix] || { + var renderAffix = function(opts){ + opts = $.extend({}, (affixOptions[affix] || { value: affix - }; + }), opts, lay.options(othis[0])); var elemAffix = $('
'); var elemIcon = $(''); elemAffix.append(elemIcon); + if(opts.split) elemAffix.addClass('layui-input-split'); // 移除旧的元素 var hasElemAffix = othis.next('.'+ CLASS_AFFIX); @@ -242,8 +243,9 @@ layui.define(['layer', 'util'], function(exports){ elem.attr('type', isShow ? 'password' : 'text').data(SHOW_NAME, !isShow); - opts.value = isShow ? 'eye-invisible' : 'eye'; - renderAffix(); + renderAffix({ + value: isShow ? 'eye-invisible' : 'eye' + }); } }, clear: { // 内容清除 @@ -627,16 +629,16 @@ layui.define(['layer', 'util'], function(exports){ // 勾选 reElem.on('click', function(){ var filter = check.attr('lay-filter') // 获取过滤器 - ,text = (check.attr('lay-text')||'').split('|'); + var title = (check.attr('title')||'').split('|'); if(check[0].disabled) return; check[0].checked ? ( check[0].checked = false - ,reElem.removeClass(RE_CLASS[1]).find('em').text(text[1]) + ,reElem.removeClass(RE_CLASS[1]).find('em').text(title[1]) ) : ( check[0].checked = true - ,reElem.addClass(RE_CLASS[1]).find('em').text(text[0]) + ,reElem.addClass(RE_CLASS[1]).find('em').text(title[0]) ); layui.event.call(check[0], MOD_NAME, RE_CLASS[2]+'('+ filter +')', { @@ -648,9 +650,12 @@ layui.define(['layer', 'util'], function(exports){ } checks.each(function(index, check){ - var othis = $(this), skin = othis.attr('lay-skin') - ,text = (othis.attr('lay-text') || '').split('|'), disabled = this.disabled; - if(skin === 'switch') skin = '_'+skin; + var othis = $(this); + var skin = othis.attr('lay-skin') || 'primary'; + var title = (check.title.replace(/\s/g, '') || '').split('|'); + var disabled = this.disabled; + + if(skin === 'switch') skin = '_'+ skin; var RE_CLASS = CLASS[skin] || CLASS.checkbox; if(typeof othis.attr('lay-ignore') === 'string') return othis.show(); @@ -664,16 +669,15 @@ layui.define(['layer', 'util'], function(exports){ ,(skin ? ' lay-skin="'+ skin +'"' : '') // 风格 ,'>' ,function(){ // 不同风格的内容 - var title = check.title.replace(/\s/g, '') - ,type = { + var type = { // 复选框 checkbox: [ - (title ? (''+ util.escape(check.title) +'') : '') + (title[0] ? (''+ util.escape(title[0]) +'') : '') ,'' ].join('') // 开关 - ,_switch: ''+ ((check.checked ? text[0] : text[1]) || '') +'' + ,_switch: ''+ ((check.checked ? title[0] : title[1]) || '') +'' }; return type[skin] || type['checkbox']; }() From e68bb91b02dca7e4362def3f36e4ab3854908d0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Wed, 25 Jan 2023 19:08:27 +0800 Subject: [PATCH 16/28] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20form=20=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/form.html | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/form.html b/examples/form.html index 3b9ad76b..69d4f899 100644 --- a/examples/form.html +++ b/examples/form.html @@ -296,25 +296,25 @@
- +
- - - + + +
- +
- - + +
From ea5676265f9a982f33f42ed465654688f643831c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Sat, 28 Jan 2023 22:04:04 +0800 Subject: [PATCH 17/28] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20table=20=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E6=8E=92=E5=BA=8F=E5=90=8E=E5=AF=BC=E8=87=B4=20`scrol?= =?UTF-8?q?lPos:'fixed'`=20=E5=A4=B1=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/table.js | 131 +++++++++++++++++++++++++++++-------------- 1 file changed, 88 insertions(+), 43 deletions(-) diff --git a/src/modules/table.js b/src/modules/table.js index 43a9550f..8734438b 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -19,10 +19,10 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ // api var table = { config: { // 全局配置项 - checkName: 'LAY_CHECKED' // 是否选中状态的字段名 + checkName: 'LAY_CHECKED' // 是否选中状态的特定字段名 ,indexName: 'LAY_TABLE_INDEX' // 初始下标索引名,用于恢复当前页表格排序 ,numbersName: 'LAY_INDEX' // 序号 - ,disabledName: 'LAY_DISABLED' + ,disabledName: 'LAY_DISABLED' // 禁用状态的特定字段名 } ,cache: {} // 数据缓存 ,index: layui.table ? (layui.table.index + 10000) : 0 @@ -908,7 +908,11 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ var response = options.response; var sort = function(){ if(typeof options.initSort === 'object'){ - that.sort(options.initSort.field, options.initSort.type); + that.sort({ + field: options.initSort.field, + type: options.initSort.type, + reloadType: opts.type + }); } }; @@ -1048,7 +1052,12 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ var thisCheckedRowIndex; if(!sort && that.sortKey){ - return that.sort(that.sortKey.field, that.sortKey.sort, true); + return that.sort({ + field: that.sortKey.field, + type: that.sortKey.sort, + pull: true, + reloadType: opts.type + }); } layui.each(data, function(i1, item1){ var tds = [], tds_fixed = [], tds_fixed_r = [] @@ -1371,33 +1380,54 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ form.render(type, filter); }; - //标记当前行选中状态 - Class.prototype.setThisRowChecked = function(index){ - var that = this - ,options = that.config - ,ELEM_CLICK = 'layui-table-click' - ,tr = that.layBody.find('tr[data-index="'+ index +'"]'); + // 标记当前行选中状态 + Class.prototype.setThisRowChecked = function(index, dataChecked){ + var that = this; + var options = that.config; + var ELEM_CLICK = 'layui-table-click'; + var tr = that.layBody.find('tr[data-index="'+ index +'"]'); + + // 同步数据选中属性值 + if(dataChecked){ + var thisData = table.cache[that.key]; + + // 重置数据单选选中属性 + layui.each(thisData, function(i, item){ + if(index === i){ + item[options.checkName] = true; + } else { + delete item[options.checkName]; + } + }); + + // 若存在单选框,则标注单选框选中样式 + tr.find('input[lay-type="layTableRadio"]').prop('checked', true); + that.renderForm('radio'); + } + // 选中样式 tr.addClass(ELEM_CLICK).siblings('tr').removeClass(ELEM_CLICK); }; - //数据排序 - Class.prototype.sort = function(th, type, pull, formEvent){ - var that = this - ,field - ,res = {} - ,options = that.config - ,filter = options.elem.attr('lay-filter') - ,data = table.cache[that.key], thisData; + // 数据排序 + Class.prototype.sort = function(opts){ // field, type, pull, fromEvent + var that = this; + var field; + var res = {}; + var options = that.config; + var filter = options.elem.attr('lay-filter'); + var data = table.cache[that.key], thisData; + + opts = opts || {}; - //字段匹配 - if(typeof th === 'string'){ - field = th; + // 字段匹配 + if(typeof opts.field === 'string'){ + field = opts.field; that.layHeader.find('th').each(function(i, item){ var othis = $(this) ,_field = othis.data('field'); - if(_field === th){ - th = othis; + if(_field === opts.field){ + opts.field = othis; field = _field; return false; } @@ -1405,37 +1435,37 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ } try { - var field = field || th.data('field') - ,key = th.data('key'); + var field = field || opts.field.data('field') + ,key = opts.field.data('key'); - //如果欲执行的排序已在状态中,则不执行渲染 - if(that.sortKey && !pull){ - if(field === that.sortKey.field && type === that.sortKey.sort){ + // 如果欲执行的排序已在状态中,则不执行渲染 + if(that.sortKey && !opts.pull){ + if(field === that.sortKey.field && opts.type === that.sortKey.sort){ return; } } var elemSort = that.layHeader.find('th .laytable-cell-'+ key).find(ELEM_SORT); - that.layHeader.find('th').find(ELEM_SORT).removeAttr('lay-sort'); //清除其它标题排序状态 - elemSort.attr('lay-sort', type || null); + that.layHeader.find('th').find(ELEM_SORT).removeAttr('lay-sort'); // 清除其它标题排序状态 + elemSort.attr('lay-sort', opts.type || null); that.layFixed.find('th') } catch(e){ hint.error('Table modules: sort field \''+ field +'\' not matched'); } - //记录排序索引和类型 + // 记录排序索引和类型 that.sortKey = { field: field - ,sort: type + ,sort: opts.type }; - //默认为前端自动排序。如果否,则需自主排序(通常为服务端处理好排序) + // 默认为前端自动排序。如果否,则需自主排序(通常为服务端处理好排序) if(options.autoSort){ - if(type === 'asc'){ //升序 + if(opts.type === 'asc'){ //升序 thisData = layui.sort(data, field); - } else if(type === 'desc'){ //降序 + } else if(opts.type === 'desc'){ //降序 thisData = layui.sort(data, field, true); - } else { //清除排序 + } else { // 清除排序 thisData = layui.sort(data, table.config.indexName); delete that.sortKey; delete options.initSort; @@ -1444,19 +1474,22 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ res[options.response.dataName] = thisData || data; + // 重载数据 that.renderData({ res: res, curr: that.page, count: that.count, - sort: true + sort: true, + type: opts.reloadType }); - if(formEvent){ + // 排序是否来自于点击表头事件触发 + if(opts.fromEvent){ options.initSort = { field: field - ,type: type + ,type: opts.type }; - layui.event.call(th, MOD_NAME, 'sort('+ filter +')', $.extend({ + layui.event.call(opts.field, MOD_NAME, 'sort('+ filter +')', $.extend({ config: options }, options.initSort)); } @@ -1923,16 +1956,28 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ } else { type = 'asc'; } - that.sort(othis, type, null, true); + that.sort({ + field: othis, + type: type, + fromEvent: true + }); }).find(ELEM_SORT+' .layui-edge ').on('click', function(e){ var othis = $(this) ,index = othis.index() ,field = othis.parents('th').eq(0).data('field') layui.stope(e); if(index === 0){ - that.sort(field, 'asc', null, true); + that.sort({ + field: field, + type: 'asc', + fromEvent: true + }); } else { - that.sort(field, 'desc', null, true); + that.sort({ + field: field, + type: 'desc', + fromEvent: true + }); } }); From 62e6d682b438c8466c1493fbc0c14856443d926e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Sat, 28 Jan 2023 22:04:44 +0800 Subject: [PATCH 18/28] =?UTF-8?q?=E4=BC=98=E5=8C=96=20table=20=E7=9A=84?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=A0=BC=E7=BC=96=E8=BE=91=E6=A0=87=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/table.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/modules/table.js b/src/modules/table.js index 8734438b..dc0dd83a 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -1090,9 +1090,13 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ if(item3.colGroup) return; // td 内容 - var td = [' Date: Sat, 28 Jan 2023 22:06:07 +0800 Subject: [PATCH 19/28] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20table=20=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E8=BF=94=E5=9B=9E=E7=9A=84=20`obj.setRowChecked()`=20?= =?UTF-8?q?=E5=85=AC=E5=85=B1=E6=96=B9=E6=B3=95=EF=BC=8C=E7=94=A8=E4=BA=8E?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=BD=93=E5=89=8D=E9=80=89=E4=B8=AD=E8=A1=8C?= =?UTF-8?q?=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/table.js | 77 +++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/src/modules/table.js b/src/modules/table.js index dc0dd83a..73ab496e 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -1837,8 +1837,8 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ // 分页栏操作事件 that.layPagebar.on('click', '*[lay-event]', function(e){ - var othis = $(this) - ,events = othis.attr('lay-event'); + var othis = $(this); + var events = othis.attr('lay-event'); layui.event.call(this, MOD_NAME, 'pagebar('+ filter +')', $.extend({ event: events @@ -1993,24 +1993,26 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ var data = table.cache[that.key] || []; data = data[index] || {}; - - return $.extend({ + + // 事件返回的公共成员 + var obj = { tr: tr //行元素 ,config: options ,data: table.clearCacheKey(data) //当前行数据 + ,index: index ,del: function(){ //删除行数据 table.cache[that.key][index] = []; tr.remove(); that.scrollPatch(); } - ,update: function(fields, related){ //修改行数据 + ,update: function(fields, related){ // 修改行数据 fields = fields || {}; layui.each(fields, function(key, value){ var td = tr.children('td[data-field="'+ key +'"]'); var cell = td.children(ELEM_CELL); //获取当前修改的列 // 更新缓存中的数据 - if(key in data) data[key] = value; + if(key in data) data[key] = obj.data[key] = value; // 更新相应列视图 that.eachCols(function(i, item3){ @@ -2043,7 +2045,14 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ that.renderForm(); } - }, sets); + // 设置行选中状态 + ,setRowChecked: function(checked){ + that.setThisRowChecked(index, true); + } + // 获取当前列 + }; + + return $.extend(obj, sets); }; // 复选框选择(替代元素的 click 事件) @@ -2080,23 +2089,15 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ ); }); - //单选框选择 + // 单选框选择 that.elem.on('click', 'input[lay-type="layTableRadio"]+', function(){ - var radio = $(this).prev() - ,checked = radio[0].checked - ,thisData = table.cache[that.key] - ,index = radio.parents('tr').eq(0).data('index'); - - //重置数据单选属性 - layui.each(thisData, function(i, item){ - if(index === i){ - item[options.checkName] = true; - } else { - delete item[options.checkName]; - } - }); - that.setThisRowChecked(index); - + var radio = $(this).prev(); + var checked = radio[0].checked; + var index = radio.parents('tr').eq(0).data('index'); + + // 单选框选中状态 + that.setThisRowChecked(index, true); + // 事件 layui.event.call(this, MOD_NAME, 'radio('+ filter +')', commonMember.call(this, { checked: checked })); @@ -2104,13 +2105,13 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ // 行事件 that.layBody.on('mouseenter', 'tr', function(){ //鼠标移入行 - var othis = $(this) - ,index = othis.index(); + var othis = $(this); + var index = othis.index(); if(othis.data('off')) return; //不触发事件 that.layBody.find('tr:eq('+ index +')').addClass(ELEM_HOVER) }).on('mouseleave', 'tr', function(){ //鼠标移出行 - var othis = $(this) - ,index = othis.index(); + var othis = $(this); + var index = othis.index(); if(othis.data('off')) return; //不触发事件 that.layBody.find('tr:eq('+ index +')').removeClass(ELEM_HOVER) }).on('click', 'tr', function(){ //单击行 @@ -2124,8 +2125,8 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ var othis = $(this); if(othis.data('off')) return; //不触发事件 layui.event.call(this, - MOD_NAME, eventType + '('+ filter +')' - ,commonMember.call(othis.children('td')[0]) + MOD_NAME, eventType + '('+ filter +')', + commonMember.call(othis.children('td')[0]) ); }; @@ -2176,11 +2177,11 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ //事件回调的参数对象 var params = commonMember.call(td[0], { - value: value - ,field: field - ,oldValue: data[field] // 编辑前的值 - ,td: td - ,reedit: function(){ // 重新编辑 + value: value, + field: field, + oldValue: data[field], // 编辑前的值 + td: td, + reedit: function(){ // 重新编辑 setTimeout(function(){ // 重新渲染为编辑状态 renderGridEdit(params.td); @@ -2330,9 +2331,11 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ settings = settings || {}; var that = this; var inst = null; - var elemTable = filter - ? $('table[lay-filter="'+ filter +'"]') - : $(ELEM + '[lay-data], '+ ELEM + '[lay-options]'); + var elemTable = typeof filter === 'object' ? filter : ( + typeof filter === 'string' + ? $('table[lay-filter="'+ filter +'"]') + : $(ELEM + '[lay-data], '+ ELEM + '[lay-options]') + ); var errorTips = 'Table element property lay-data configuration item has a syntax error: '; //遍历数据表格 From 9c8a632b463325e9ff9d63d276c2ad62211a03fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Sat, 28 Jan 2023 22:06:38 +0800 Subject: [PATCH 20/28] =?UTF-8?q?=E4=BC=98=E5=8C=96=20table=20=E7=9A=84`ed?= =?UTF-8?q?it`=20=E4=BA=8B=E4=BB=B6=EF=BC=8C=E6=96=B0=E5=A2=9E=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=20`obj.getCol()`=20=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/table.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/modules/table.js b/src/modules/table.js index 73ab496e..fd27a8f6 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -2191,6 +2191,9 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ obj[field] = params.oldValue; params.update(obj); }); + }, + getCol: function(){ // 获取当前列的表头配置信息 + return that.col(td.data('key')); } }); From d37a36778b44c057fdc5f39ad9383f3f23c62612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Sat, 28 Jan 2023 22:07:13 +0800 Subject: [PATCH 21/28] =?UTF-8?q?=E4=BC=98=E5=8C=96=20form=20=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=B0=BE=E9=83=A8=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/form.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/modules/form.js b/src/modules/form.js index f33927dc..9fa7e87f 100644 --- a/src/modules/form.js +++ b/src/modules/form.js @@ -915,16 +915,17 @@ layui.define(['lay', 'layer', 'util'], function(exports){ // 事件 return layui.event.call(this, MOD_NAME, 'submit('+ layFilter +')', params); }; - - // 自动完成渲染 - var form = new Form() - ,$dom = $(document), $win = $(window); + var form = new Form(); + var $dom = $(document); + var $win = $(window); + + // 初始自动完成渲染 $(function(){ form.render(); }); - // 表单reset重置渲染 + // 表单 reset 重置渲染 $dom.on('reset', ELEM, function(){ var filter = $(this).attr('lay-filter'); setTimeout(function(){ From a23e7c67c5e70f23e8538e487707cad0cb43d934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Sat, 28 Jan 2023 22:08:22 +0800 Subject: [PATCH 22/28] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20dropdown=20=E5=9C=A8?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E8=AE=BE=E5=A4=87=E4=B8=8B=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E5=85=B6=E4=BB=96=E5=85=83=E7=B4=A0=E6=97=A0=E6=B3=95=E5=85=B3?= =?UTF-8?q?=E9=97=AD=E9=9D=A2=E6=9D=BF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/dropdown.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/dropdown.js b/src/modules/dropdown.js index 47460f56..c0ae6148 100644 --- a/src/modules/dropdown.js +++ b/src/modules/dropdown.js @@ -10,7 +10,7 @@ layui.define(['jquery', 'laytpl', 'lay'], function(exports){ ,laytpl = layui.laytpl ,hint = layui.hint() ,device = layui.device() - ,clickOrMousedown = (device.mobile ? 'click' : 'mousedown') + ,clickOrMousedown = (device.mobile ? 'touchstart' : 'mousedown') //模块名 ,MOD_NAME = 'dropdown' From 687768575415dd944e82113ac6a3ca1b034f548d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Sun, 29 Jan 2023 01:10:56 +0800 Subject: [PATCH 23/28] =?UTF-8?q?=E4=BC=98=E5=8C=96=20table=20=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=AF=BC=E5=87=BA=E5=8A=9F=E8=83=BD=EF=BC=8C=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E6=89=93=E5=BC=80=E6=96=87=E4=BB=B6=E5=90=8E=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E6=98=BE=E7=A4=BA=E7=9A=84=E8=8B=A5=E5=B9=B2=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/table.js | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/src/modules/table.js b/src/modules/table.js index fd27a8f6..cc8aa4d9 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -2530,15 +2530,15 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ if(device.ie) return hint.error('IE_NOT_SUPPORT_EXPORTS'); alink.href = 'data:'+ textType +';charset=utf-8,\ufeff'+ encodeURIComponent(function(){ - var dataTitle = [] - ,dataMain = [] - ,dataTotal = [] - ,fieldsIsHide = {}; + var dataTitle = []; + var dataMain = []; + var dataTotal = []; + var fieldsIsHide = {}; - //表头和表体 + // 表头和表体 layui.each(data, function(i1, item1){ var vals = []; - if(typeof id === 'object'){ //如果 id 参数直接为表头数据 + if(typeof id === 'object'){ // 若 id 参数直接为表头数据 layui.each(id, function(i, item){ i1 == 0 && dataTitle.push(item || ''); }); @@ -2548,9 +2548,9 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ } else { table.eachCols(id, function(i3, item3){ if(item3.field && item3.type == 'normal'){ - //不导出隐藏列 + // 不导出隐藏列 if(item3.hide){ - if(i1 == 0) fieldsIsHide[item3.field] = true; //记录隐藏列 + if(i1 == 0) fieldsIsHide[item3.field] = true; // 记录隐藏列 return; } @@ -2558,7 +2558,9 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ if(content === undefined || content === null) content = ''; i1 == 0 && dataTitle.push(item3.fieldTitle || item3.title || item3.field || ''); - vals.push('"'+ parseTempData.call(thatTable, { + + // 解析内容 + content = parseTempData.call(thatTable, { item3: item3 ,content: content ,tplData: item1 @@ -2569,7 +2571,15 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ return td.filter('[data-field="'+ field +'"]'); } } - }) + '"'); + }); + + // 异常处理 + content = content.replace(/"/g, '""'); // 避免内容存在「双引号」导致异常分隔 + content += '\t'; // 加「水平制表符」 避免内容被转换格式 + content = '"'+ content +'"'; // 避免内容存在「逗号」导致异常分隔 + + // 插入内容 + vals.push(content); } }); } @@ -2583,7 +2593,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ return dataTitle.join(',') + '\r\n' + dataMain.join('\r\n') + '\r\n' + dataTotal.join(','); }()); - + //return; alink.download = (options.title || config.title || 'table_'+ (config.index || '')) + '.' + type; document.body.appendChild(alink); alink.click(); @@ -2592,14 +2602,14 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ // 重置表格尺寸结构 table.resize = function(id){ - //如果指定表格唯一 id,则只执行该 id 对应的表格实例 + // 若指定表格唯一 id,则只执行该 id 对应的表格实例 if(id){ - var config = getThisTableConfig(id); //获取当前实例配置项 + var config = getThisTableConfig(id); // 获取当前实例配置项 if(!config) return; getThisTable(id).resize(); - } else { //否则重置所有表格实例尺寸 + } else { // 否则重置所有表格实例尺寸 layui.each(thisTable.that, function(){ this.resize(); }); From 7be36d05c60b326cbdfac331927376aa6ff55914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Sun, 29 Jan 2023 01:12:02 +0800 Subject: [PATCH 24/28] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20table=20=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/table-test.html | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/table-test.html b/examples/table-test.html index fe82c525..ceb448b3 100644 --- a/examples/table-test.html +++ b/examples/table-test.html @@ -156,12 +156,13 @@ layui.use(['table', 'dropdown'], function(){ ,{field:'username', title:'用户名', width:120, edit: function(d){ return !d.LAY_DISABLED; }, templet: '#usernameTpl'} - ,{field:'email', minWidth: 160, maxWidth: 320, title:'邮箱 ', hide: 0, edit: 'text', templet: function(d){ + ,{field:'email', minWidth: 160, maxWidth: 320, title:'邮箱 ', fieldTitle: '邮箱', hide: 0, edit: 'text', templet: function(d){ return ''+ layui.util.escape(d.email) +'' }} ,{field:'sex', title:'性别', width:80, edit: 'text', sort: true, escape: false} ,{field:'city', title:'城市', width:120, templet: '#cityTpl', exportTemplet: function(d, obj){ - //console.log(obj) + // return '=HYPERLINK("https://abc.com/a.jpg","截图")'; // 测试内容存在特殊符 + // console.log(obj) var td = obj.td(this.field); //获取当前 td return td.find('select').val(); }} @@ -450,11 +451,12 @@ layui.use(['table', 'dropdown'], function(){ var value = obj.value // 得到修改后的值 var oldValue = obj.oldValue // 得到修改前的值 -- v2.8.0 新增 var data = obj.data; // 得到当前编辑所在行的数据 + var col = obj.getCol(); // 得到当前列的表头配置属性 // 值的校验 if(field === 'email'){ if(!/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(obj.value)){ - layer.tips('输入的邮箱格式不正确,请重新编辑', this, {tips: 1}); + layer.tips('输入的'+ col.fieldTitle +'格式不正确,请重新编辑', this, {tips: 1}); return obj.reedit(); // 重新编辑 -- v2.8.0 新增 } } From 067a9a4c78e1e87a1fce79b691a1661034b27e1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Sun, 29 Jan 2023 01:12:39 +0800 Subject: [PATCH 25/28] =?UTF-8?q?=E5=8A=A0=E5=BC=BA=20code=20=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E9=A2=84=E8=A7=88=E7=BB=84=E4=BB=B6=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/css/modules/code.css | 34 +++++-- src/modules/code.js | 212 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 228 insertions(+), 18 deletions(-) diff --git a/src/css/modules/code.css b/src/css/modules/code.css index 56e8c6a6..a0188666 100644 --- a/src/css/modules/code.css +++ b/src/css/modules/code.css @@ -6,18 +6,18 @@ html #layuicss-skincodecss{display:none; position: absolute; width:1989px;} /* 默认风格 */ -.layui-code-view{display: block; position: relative; margin: 10px 0; padding: 0; border: 1px solid #eee; border-left-width: 6px; background-color: #FAFAFA; color: #333; font-family: Courier New; font-size: 13px;} +.layui-code-view{display: block; position: relative; margin: 11px 0; padding: 0; border: 1px solid #eee; border-left-width: 6px; background-color: #FAFAFA; color: #333; font-family: Courier New; font-size: 13px;} .layui-code-title{position: relative; padding: 0 10px; height: 40px; line-height: 40px; border-bottom: 1px solid #eee; font-size: 12px;} .layui-code-title > .layui-code-about{position: absolute; right: 10px; top: 0; color: #B7B7B7;} .layui-code-about > a{padding-left: 10px;} .layui-code-view > .layui-code-ol, -.layui-code-view > .layui-code-ul{position: relative; overflow: auto;} -.layui-code-view > .layui-code-ol > li{position: relative; margin-left: 45px; line-height: 20px; padding: 0 10px; border-left: 1px solid #e2e2e2; list-style-type: decimal-leading-zero; *list-style-type: decimal; background-color: #fff;} +.layui-code-view > .layui-code-ul{max-height: 100%; padding: 0 !important; position: relative; overflow: auto;} +.layui-code-view > .layui-code-ol > li{position: relative; margin-top: 0 !important; margin-left: 45px !important; line-height: 20px; padding: 0 10px !important; border-left: 1px solid #e2e2e2; list-style-type: decimal-leading-zero; *list-style-type: decimal; background-color: #fff;} .layui-code-view > .layui-code-ol > li:first-child, -.layui-code-view > .layui-code-ul > li:first-child{padding-top: 10px;} +.layui-code-view > .layui-code-ul > li:first-child{padding-top: 10px !important;} .layui-code-view > .layui-code-ol > li:last-child, -.layui-code-view > .layui-code-ul > li:last-child{padding-bottom: 10px;} -.layui-code-view > .layui-code-ul > li{position: relative; line-height: 20px; padding: 0 10px; list-style-type: none; *list-style-type: none; background-color: #fff;} +.layui-code-view > .layui-code-ul > li:last-child{padding-bottom: 10px !important;} +.layui-code-view > .layui-code-ul > li{position: relative; line-height: 20px; padding: 0 10px !important; list-style-type: none; *list-style-type: none; background-color: #fff;} .layui-code-view pre{margin: 0;} /* 深色风格 */ @@ -28,5 +28,23 @@ html #layuicss-skincodecss{display:none; position: absolute; width:1989px;} .layui-code-dark > .layui-code-ul > li{margin-left: 6px;} /* 代码预览 */ -.layui-code-demo .layui-code{visibility: visible !important; margin: -15px; border-top: none; border-right: none; border-bottom: none;} -.layui-code-demo .layui-tab-content{padding: 15px; border-top: none} \ No newline at end of file +.layui-code textarea{display: none;} +.layui-code-preview > .layui-code{margin: 0;} +.layui-code-preview > .layui-tab{position: relative; z-index: 1; margin-bottom: 0;} +.layui-code-preview > .layui-tab > .layui-tab-title{border-bottom: none;} +.layui-code-preview > .layui-code > .layui-code-title{display: none;} +.layui-code-preview .layui-code-item{display: none;} +.layui-code-preview .layui-code-view > .layui-code-ol > li{} +.layui-code-item-preview{position: relative; padding: 16px;} +.layui-code-item-preview > iframe{position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none;} + +/* 工具栏 */ +.layui-code-tools{position: absolute; right: 11px; top: 3px;} +.layui-code-tools > i{display: inline-block; margin-left: 6px; padding: 3px; cursor: pointer;} + +/* 全屏风格 */ +.layui-code-full{position: fixed; left: 0; top: 0; z-index: 1111111; width: 100%; height: 100%; background-color: #fff;} +.layui-code-full .layui-code-item{width: 100% !important; border-width: 0 !important; border-top-width: 1px !important;} +.layui-code-full .layui-code-item, +.layui-code-full .layui-code-ol, +.layui-code-full .layui-code-ul{height: calc(100vh - 51px) !important; box-sizing: border-box;} \ No newline at end of file diff --git a/src/modules/code.js b/src/modules/code.js index 47a1fc5d..68da0494 100644 --- a/src/modules/code.js +++ b/src/modules/code.js @@ -1,22 +1,38 @@ /** * code - * 代码块简易修饰 + * Code 预览组件 */ -layui.define(['lay', 'util'], function(exports){ +layui.define(['lay', 'util', 'element', 'form'], function(exports){ "use strict"; var $ = layui.$; var util = layui.util; + var element = layui.element; + var form = layui.form; - var ELEM_TITLE = 'layui-code-title'; + // 常量 + var CONST = { + ELEM_VIEW: 'layui-code-view', + ELEM_TITLE: 'layui-code-title', + ELEM_FULL: 'layui-code-full', + ELEM_PREVIEW: 'layui-code-preview', + ELEM_ITEM: 'layui-code-item', + ELEM_SHOW: 'layui-show' + }; // 默认参数项 var config = { elem: '.layui-code', // 元素选择器 title: '</>', // 标题 about: '', // 右上角信息 - ln: true // 是否显示行号 + ln: true, // 是否显示行号 + header: false, // 是否显示头部区域 + + text: { + code: util.escape(''), + preview: 'Preview' + } }; var trim = function(str){ @@ -25,7 +41,7 @@ layui.define(['lay', 'util'], function(exports){ // export api exports('code', function(options){ - var opts = options = $.extend({}, config, options); + var opts = options = $.extend(true, {}, config, options); // 目标元素是否存在 options.elem = $(options.elem); @@ -37,7 +53,7 @@ layui.define(['lay', 'util'], function(exports){ var html = trim(othis.html()); // 合并属性上的参数,并兼容旧版本属性写法 lay-* - var options = $.extend({}, opts, lay.options(item), function(obj){ + var options = $.extend(true, {}, opts, lay.options(item), function(obj){ var attrs = ['title', 'height', 'encode', 'skin', 'about']; layui.each(attrs, function(i, attr){ var value = othis.attr('lay-'+ attr); @@ -48,12 +64,181 @@ layui.define(['lay', 'util'], function(exports){ return obj; }({})); + // 获得代码 + var codes = function(){ + var arr = []; + var textarea = othis.children('textarea'); + + // 若内容放置在 textarea 中 + textarea.each(function(){ + arr.push(trim(this.value)); + }); + + if(textarea[0]){ + html = util.escape(arr.join('')); + } + + // 内容直接放置在元素外层 + if(arr.length === 0){ + arr.push(trim(othis.html())); + } + + return arr; + }(); + + // 是否开启预览 + if(options.preview){ + var FILTER_VALUE = 'LAY-CODE-DF-'+ index; + var layout = options.layout || ['code', 'preview']; + var isIframePreview = options.preview === 'iframe'; + + // 追加 Tab 组件 + var elemView = $('
'); + var elemTabView = $('
'); + var elemHeaderView = $('
'); + var elemPreviewView = $('
'); + var elemToolbar = $('
'); + var elemViewHas = othis.prev('.' + CONST.ELEM_PREVIEW); + var elemPreviewViewHas = othis.next('.' + CONST.ELEM_ITEM +'-preview'); + + if(options.id) elemView.attr('id', options.id); + elemTabView.attr('lay-filter', FILTER_VALUE); + + // 标签头 + layui.each(layout, function(i, v){ + var li = $('
  • '); + if(i === 0) li.addClass('layui-this'); + li.html(options.text[v]); + elemHeaderView.append(li); + }); + + // 工具栏 + var tools = { + 'full': { + className: 'screen-full', + title: ['最大化显示', '还原显示'], + event: function(el, type){ + var elemView = el.closest('.'+ CONST.ELEM_PREVIEW); + var classNameFull = 'layui-icon-'+ this.className; + var classNameRestore = 'layui-icon-screen-restore'; + var title = this.title; + var html = $('html,body'); + var ELEM_SCOLLBAR_HIDE = 'layui-scollbar-hide'; + + if(el.hasClass(classNameFull)){ + elemView.addClass(CONST.ELEM_FULL); + el.removeClass(classNameFull).addClass(classNameRestore); + el.attr('title', title[1]); + html.addClass(ELEM_SCOLLBAR_HIDE); + } else { + elemView.removeClass(CONST.ELEM_FULL); + el.removeClass(classNameRestore).addClass(classNameFull); + el.attr('title', title[0]); + html.removeClass(ELEM_SCOLLBAR_HIDE); + } + } + }, + 'window': { + className: 'release', + title: ['在新窗口预览'], + event: function(el, type){ + util.openWin({ + content: codes.join('') + }); + } + } + }; + elemToolbar.on('click', '>i', function(){ // 工具栏事件 + var oi = $(this); + var type = oi.data('type'); + typeof tools[type].event === 'function' && tools[type].event(oi, type); + typeof options.toolsEvent === 'function' && options.toolsEvent(oi, type); + }); + layui.each(options.tools, function(i, v){ + var className = (tools[v] && tools[v].className) || v; + var title = tools[v].title || ['']; + elemToolbar.append( + '' + ); + }); + + // 移除旧结构 + if(elemViewHas[0]) elemViewHas.remove(); + if(elemPreviewViewHas[0]) elemPreviewViewHas.remove(); + + elemTabView.append(elemHeaderView); // 追加标签头 + options.tools && elemTabView.append(elemToolbar); // 追加工具栏 + othis.wrap(elemView).addClass(CONST.ELEM_ITEM).before(elemTabView); // 追加标签结构 + + + // 追加预览 + if(isIframePreview){ + elemPreviewView.html(''); + } + + // 执行预览 + var run = function(thisItemBody){ + var iframe = thisItemBody.children('iframe')[0]; + if(isIframePreview && iframe){ + iframe.srcdoc = codes.join(''); + } else { + thisItemBody.html(codes.join('')); + } + // 回调的返回参数 + var params = { + container: thisItemBody, + render: function(){ + form.render(thisItemBody.find('.layui-form')); + element.render(); + } + }; + // 当前实例预览完毕后的回调 + setTimeout(function(){ + typeof options.done === 'function' && options.done(params); + },3); + }; + + if(layout[0] === 'preview'){ + elemPreviewView.addClass(CONST.ELEM_SHOW); + othis.before(elemPreviewView); + run(elemPreviewView); + } else { + othis.addClass(CONST.ELEM_SHOW).after(elemPreviewView); + } + + // 内容项初始化样式 + options.codeStyle = [options.style, options.codeStyle].join(''); + options.previewStyle = [options.style, options.previewStyle].join(''); + // othis.attr('style', options.codeStyle); + elemPreviewView.attr('style', options.previewStyle); + + // tab change + element.on('tab('+ FILTER_VALUE +')', function(data){ + var $this = $(this); + var thisElem = $(data.elem).closest('.'+ CONST.ELEM_PREVIEW); + var elemItemBody = thisElem.find('.'+ CONST.ELEM_ITEM); + var thisItemBody = elemItemBody.eq(data.index); + + elemItemBody.removeClass(CONST.ELEM_SHOW); + thisItemBody.addClass(CONST.ELEM_SHOW); + + if($this.attr('lay-id') === 'preview'){ + run(thisItemBody); + } + }); + }; + + // 有序或无序列表 var listTag = options.ln ? 'ol' : 'ul'; var listElem = $('<'+ listTag +' class="layui-code-'+ listTag +'">'); // header - var headerElem = $('
    '); + var headerElem = $('
    '); // 添加组件 clasName othis.addClass('layui-code-view layui-box'); @@ -72,7 +257,7 @@ layui.define(['lay', 'util'], function(exports){ othis.html(listElem.html('
  • ' + html + '
  • ')); // 创建 header - if(!othis.children('.'+ ELEM_TITLE)[0]){ + if(options.header && !othis.children('.'+ CONST.ELEM_TITLE)[0]){ headerElem.html(options.title + ( options.about ? '
    ' + options.about + '
    ' @@ -81,6 +266,11 @@ layui.define(['lay', 'util'], function(exports){ othis.prepend(headerElem); } + // 所有实例渲染完毕后的回调 + if(options.elem.length === index + 1){ + typeof options.allDone === 'function' && options.allDone(); + } + // 按行数适配左边距 (function(autoIncNums){ if(autoIncNums > 0){ @@ -88,10 +278,12 @@ layui.define(['lay', 'util'], function(exports){ } })(Math.floor(listElem.find('li').length/100)); - // 限制最大高度 - if(options.height){ + // 限制 Code 最大高度 + if(options.height){ // 兼容旧版本 listElem.css('max-height', options.height); } + // Code 内容区域样式 + listElem.attr('style', options.codeStyle); }); From dc5c9658943795767469dff2ad09c042b21a42d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Sun, 29 Jan 2023 01:13:11 +0800 Subject: [PATCH 26/28] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E8=8B=A5=E5=B9=B2?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/css/layui.css | 90 ++++++++++++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 37 deletions(-) diff --git a/src/css/layui.css b/src/css/layui.css index 3f38834b..8290e64e 100644 --- a/src/css/layui.css +++ b/src/css/layui.css @@ -505,7 +505,7 @@ a cite{font-style: normal; *cursor:pointer;} /** 页面元素 **/ .layui-btn, .layui-input, .layui-textarea, .layui-upload-button, .layui-select{outline: none; -webkit-appearance: none; transition: all .3s; -webkit-transition: all .3s; box-sizing: border-box;} -/* 引用 */.layui-elem-quote{margin-bottom: 10px; padding: 15px; line-height: 1.6; border-left: 5px solid #5FB878; border-radius: 0 2px 2px 0; background-color: #FAFAFA;} +/* 引用 */.layui-elem-quote{margin-bottom: 10px; padding: 15px; line-height: 1.8; border-left: 5px solid #5FB878; border-radius: 0 2px 2px 0; background-color: #FAFAFA;} .layui-quote-nm{border-style: solid; border-width: 1px; border-left-width: 5px; background: none;} /* 字段集合 */.layui-elem-field{margin-bottom: 10px; padding: 0; border-width: 1px; border-style: solid;} .layui-elem-field legend{margin-left: 20px; padding: 0 10px; font-size: 20px; font-weight: 300;} @@ -623,7 +623,7 @@ a cite{font-style: normal; *cursor:pointer;} .layui-text ol{padding-left: 15px;} .layui-text ul li{margin-top: 5px; list-style-type: disc;} .layui-text ol li{margin-top: 5px; list-style-type: decimal;} -.layui-text em, +.layui-text-em, .layui-word-aux{color: #999 !important; padding-left: 5px !important; padding-right: 5px !important;} .layui-text p{margin: 15px 0;} .layui-text p:first-child{margin-top: 0;} @@ -667,7 +667,7 @@ a cite{font-style: normal; *cursor:pointer;} .layui-btn+.layui-btn{margin-left: 10px;} /* 按钮容器 */ -.layui-btn-container{font-size: 0;} +.layui-btn-container{word-spacing: -5px;} .layui-btn-container .layui-btn{margin-right: 10px; margin-bottom: 10px;} .layui-btn-container .layui-btn+.layui-btn{margin-left: 0;} .layui-table .layui-btn-container .layui-btn{margin-bottom: 9px;} @@ -714,7 +714,7 @@ a cite{font-style: normal; *cursor:pointer;} .layui-form input[type=radio]{display: none;} .layui-form *[lay-ignore]{display: initial;} -.layui-form-item{margin-bottom: 15px; clear: both; *zoom: 1;} +.layui-form-item{position: relative; margin-bottom: 15px; clear: both; *zoom: 1;} .layui-form-item:after{content:'\20'; clear: both; *zoom: 1; display: block; height:0;} .layui-form-label{position: relative; float: left; display: block; padding: 9px 15px; width: 80px; font-weight: 400; line-height: 20px; text-align: right;} .layui-form-label-col{display: block; float: none; padding: 9px 0; line-height: 20px; text-align: left;} @@ -732,40 +732,51 @@ a cite{font-style: normal; *cursor:pointer;} .layui-form-danger:focus, .layui-form-danger+.layui-form-select .layui-input{border-color: #FF5722 !important;} -/* 输入框套件 */ -.layui-input-wrap{position: relative; height: 38px; line-height: 38px;} -.layui-input-wrap .layui-input{padding-right: 35px;;} -.layui-input-wrap .layui-input::-ms-clear, -.layui-input-wrap .layui-input::-ms-reveal{display: none;} -.layui-input-wrap-prefix .layui-input{padding-left:35px;} +/* 输入框点缀 */ .layui-input-prefix, .layui-input-suffix, -.layui-input-split{position: absolute; right: 0; top: 0; padding: 0 10px; width: 35px; height: 100%; text-align: center; transition: all .3s; cursor: pointer; pointer-events: none; box-sizing: border-box;} +.layui-input-split, +.layui-input-suffix .layui-input-affix{position: absolute; right: 0; top: 0; padding: 0 10px; width: 35px; height: 100%; text-align: center; transition: all .3s; box-sizing: border-box;} .layui-input-prefix{left: 0; border-radius: 2px 0 0 2px;} .layui-input-suffix{right: 0; border-radius: 0 2px 2px 0;} - -.layui-input-wrap .layui-input:focus + .layui-input-split{border-color: #d2d2d2;} +.layui-input-split{border-width: 1px; border-style: solid;} .layui-input-prefix .layui-icon, .layui-input-suffix .layui-icon, .layui-input-split .layui-icon{position: relative; font-size: 16px; color: #5F5F5F; transition: all .3s;} -.layui-input-wrap .layui-input-prefix.layui-input-split{border-width: 0; border-right-width: 1px;} -.layui-input-wrap-prefix .layui-form-select{position: static;} - -.layui-input-affix-event .layui-icon{color: rgba(0,0,0,.8);} -.layui-input-affix-event .layui-icon-clear{color: rgba(0,0,0,.3);} -.layui-input-affix-event .layui-icon:hover{color: rgba(0,0,0,.6);} - -.layui-input-split{border-width: 1px; border-style: solid;} -.layui-input-affix-event{pointer-events: auto;} - -/* 输入框组 */ -.layui-input-group{position: relative; display: inline-table;} +/* 输入框前后置容器 */ +.layui-input-group{position: relative; display: table; box-sizing: border-box;} .layui-input-group>*{display: table-cell; vertical-align: middle; position: relative;} .layui-input-group .layui-input{padding-right: 15px;} .layui-input-group .layui-input-prefix{width: auto; border-right: 0;} .layui-input-group .layui-input-suffix{width: auto; border-left: 0;} +.layui-input-group .layui-input-split{white-space: nowrap;} + +/* 输入框前后缀容器 */ +.layui-input-wrap{position: relative; line-height: 38px;} +.layui-input-wrap .layui-input{padding-right: 35px;;} +.layui-input-wrap .layui-input::-ms-clear, +.layui-input-wrap .layui-input::-ms-reveal{display: none;} +.layui-input-wrap .layui-input-prefix + .layui-input, +.layui-input-wrap .layui-input-prefix ~ * .layui-input{padding-left: 35px;} +.layui-input-wrap .layui-input-split + .layui-input, +.layui-input-wrap .layui-input-split ~ * .layui-input{padding-left: 45px;} +.layui-input-wrap .layui-input-prefix ~ .layui-form-select{position: static;} +.layui-input-wrap .layui-input-prefix, +.layui-input-wrap .layui-input-suffix, +.layui-input-wrap .layui-input-split{pointer-events: none;} +.layui-input-wrap .layui-input:focus + .layui-input-split{border-color: #d2d2d2;} +.layui-input-wrap .layui-input-prefix.layui-input-split{border-width: 0; border-right-width: 1px;} + +/* 输入框动态点缀 */ +.layui-input-affix{line-height: 38px;} +.layui-input-suffix .layui-input-affix{right: auto; left: -35px;} +.layui-input-affix .layui-icon{color: rgba(0,0,0,.8); pointer-events: auto!important; cursor: pointer;} +.layui-input-affix .layui-icon-clear{color: rgba(0,0,0,.3);} +.layui-input-affix .layui-icon:hover{color: rgba(0,0,0,.6);} + + /* 下拉选择 */ .layui-form-select{position: relative; color: #5F5F5F;} @@ -804,7 +815,7 @@ a cite{font-style: normal; *cursor:pointer;} .layui-form-checked i, .layui-form-checked:hover i{color: #5FB878;} .layui-form-item .layui-form-checkbox{margin-top: 4px;} -/* 复选框-原始风格 */.layui-form-checkbox[lay-skin="primary"]{height: auto!important; line-height: normal!important; min-width: 18px; min-height: 18px; border: none!important; margin-right: 0; padding-left: 28px; padding-right: 0; background: none;} +/* 复选框-默认风格 */.layui-form-checkbox[lay-skin="primary"]{height: auto!important; line-height: normal!important; min-width: 18px; min-height: 18px; border: none!important; margin-right: 0; padding-left: 28px; padding-right: 0; background: none;} .layui-form-checkbox[lay-skin="primary"] span{padding-left: 0; padding-right: 15px; line-height: 18px; background: none; color: #5F5F5F;} .layui-form-checkbox[lay-skin="primary"] i{right: auto; left: 0; width: 16px; height: 16px; line-height: 16px; border: 1px solid #d2d2d2; font-size: 12px; border-radius: 2px; background-color: #fff; -webkit-transition: .1s linear; transition: .1s linear;} .layui-form-checkbox[lay-skin="primary"]:hover i{border-color: #5FB878; color: #fff;} @@ -878,10 +889,10 @@ a cite{font-style: normal; *cursor:pointer;} .layui-laypage select{border: 1px solid #eee;} .layui-laypage a, .layui-laypage span{display: inline-block; *display: inline; *zoom: 1; vertical-align: middle; padding: 0 15px; height: 28px; line-height: 28px; margin: 0 -1px 5px 0; background-color: #fff; color: #333; font-size: 12px;} -.layui-laypage a:hover{color: #009688;} +.layui-laypage a{color: #333 !important; text-decoration: none !important;} +.layui-laypage a:hover{color: #009688 !important;} .layui-laypage em{font-style: normal;} .layui-laypage .layui-laypage-spr{color:#999; font-weight: 700;} -.layui-laypage a{ text-decoration: none;} .layui-laypage .layui-laypage-curr{position: relative;} .layui-laypage .layui-laypage-curr em{position: relative; color: #fff;} .layui-laypage .layui-laypage-curr .layui-laypage-em{position: absolute; left: -1px; top: -1px; padding: 1px; width: 100%; height: 100%; background-color: #009688; } @@ -922,11 +933,12 @@ a cite{font-style: normal; *cursor:pointer;} .layui-table-tool, .layui-table-total, .layui-table-total tr, -.layui-table-patch, -.layui-table-mend{} +.layui-table-patch{} +.layui-table-mend{background-color: #fff;} .layui-table-hover, .layui-table-click{background-color: #FAFAFA;} +.layui-table[lay-even] tr:nth-child(even){background-color: #f2f2f2;} .layui-table th, .layui-table td, @@ -939,6 +951,7 @@ a cite{font-style: normal; *cursor:pointer;} .layui-table-total, .layui-table-page, .layui-table-fixed-r, +.layui-table-mend, .layui-table-tips-main, .layui-table-grid-down{border-width: 1px; border-style: solid; border-color: #eee;} @@ -964,7 +977,7 @@ a cite{font-style: normal; *cursor:pointer;} .layui-table[lay-data], .layui-table[lay-options]{display: none;} .layui-table-box{position: relative; overflow: hidden;} -.layui-table-view{margin: 10px 0;} +.layui-table-view{clear: both;} .layui-table-view .layui-table{position: relative; width: auto; margin: 0; border: 0; border-collapse: separate;} .layui-table-view .layui-table[lay-skin="line"]{border-width: 0; border-right-width: 1px;} .layui-table-view .layui-table[lay-skin="row"]{border-width: 0; border-bottom-width: 1px;} @@ -972,7 +985,9 @@ a cite{font-style: normal; *cursor:pointer;} .layui-table-view .layui-table td{padding: 0; border-top: none; border-left: none;} .layui-table-view .layui-table th.layui-unselect .layui-table-cell span{cursor: pointer;} .layui-table-view .layui-table td{cursor: default;} -.layui-table-view .layui-table td[data-edit="text"]{cursor: text;} +.layui-table-view .layui-table td[data-edit]{cursor: text;} +.layui-table-view .layui-table td[data-edit]:hover:after{position: absolute; left: 0; top: 0; width: 100%; height: 100%; box-sizing: border-box; border: 1px solid #16B777; pointer-events: none; content: "";} + .layui-table-view .layui-form-checkbox[lay-skin="primary"] i{width: 18px; height: 18px;} .layui-table-view .layui-form-radio{line-height: 0; padding: 0;} .layui-table-view .layui-form-radio>i{margin: 0; font-size: 20px;} @@ -990,8 +1005,8 @@ a cite{font-style: normal; *cursor:pointer;} .layui-table-tool-temp{padding-right: 120px;} .layui-table-tool-self{position: absolute; right: 17px; top: 10px;} .layui-table-tool .layui-table-tool-self .layui-inline[lay-event]{margin: 0 0 0 10px;} -.layui-table-tool-panel{position: absolute; top: 29px; left: -1px; z-index: 399; padding: 5px 0; min-width: 150px; min-height: 40px; border: 1px solid #d2d2d2; text-align: left; overflow-y: auto; background-color: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.12);} -.layui-table-tool-panel li{padding: 0 10px; line-height: 30px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; -webkit-transition: .5s all; transition: .5s all;} +.layui-table-tool-panel{position: absolute; top: 29px; left: -1px; z-index: 399; padding: 5px 0 !important; min-width: 150px; min-height: 40px; border: 1px solid #d2d2d2; text-align: left; overflow-y: auto; background-color: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.12);} +.layui-table-tool-panel li{padding: 0 10px; margin: 0 !important; line-height: 30px; list-style-type: none !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; -webkit-transition: .5s all; transition: .5s all;} .layui-table-tool-panel li .layui-form-checkbox[lay-skin="primary"]{width: 100%;} .layui-table-tool-panel li:hover{background-color: #F6F6F6;} .layui-table-tool-panel li .layui-form-checkbox[lay-skin="primary"]{padding-left: 28px;} @@ -999,6 +1014,7 @@ a cite{font-style: normal; *cursor:pointer;} .layui-table-tool-panel li .layui-form-checkbox[lay-skin="primary"] span{padding: 0;} .layui-table-tool .layui-table-tool-self .layui-table-tool-panel{left: auto; right: -1px;} +.layui-table-col-special{word-spacing: -5px;} .layui-table-col-set{position: absolute; right: 0; top: 0; width: 20px; height: 100%; border-width: 0; border-left-width: 1px; background-color: #fff;} .layui-table-sort{width: 10px; height: 20px; margin-left: 5px; cursor: pointer!important;} @@ -1030,7 +1046,7 @@ a cite{font-style: normal; *cursor:pointer;} .layui-table-fixed-l{box-shadow: 1px 0 8px rgba(0,0,0,.08);} .layui-table-fixed-r{left: auto; right: -1px; border-width: 0; border-left-width: 1px; box-shadow: -1px 0 8px rgba(0,0,0,.08);} .layui-table-fixed-r .layui-table-header{position: relative; overflow: visible;} -.layui-table-mend{position: absolute; right: -49px; top: 0; height: 100%; width: 50px;} +.layui-table-mend{position: absolute; right: -49px; top: 0; height: 100%; width: 50px; border-width: 0; border-left-width: 1px;} .layui-table-tool{position: relative; width: 100%; min-height: 50px; line-height: 30px; padding: 10px 15px; border-width: 0; border-bottom-width: 1px; /*box-shadow: 0 1px 8px 0 rgb(0 0 0 / 8%);*/} .layui-table-tool .layui-btn-container{margin-bottom: -10px;} @@ -1100,7 +1116,7 @@ body .layui-table-tips .layui-layer-content{background: none; padding: 0; box-sh .layui-menu{position: relative; margin: 5px 0; background-color: #fff; box-sizing: border-box;} .layui-menu *{box-sizing: border-box;} .layui-menu li, -.layui-menu-body-title a{padding: 5px 15px;} +.layui-menu-body-title a{padding: 5px 15px; color: initial} .layui-menu li{position: relative; margin: 1px 0; width: calc(100% + 1px); line-height: 26px; color: rgba(0,0,0,.8); font-size: 14px; white-space: nowrap; cursor: pointer; transition: all .3s;} .layui-menu li:hover{background-color: #F6F6F6; } @@ -1362,7 +1378,7 @@ body .layui-table-tips .layui-layer-content{background: none; padding: 0; box-sh .layui-carousel[lay-anim="fade"]>*[carousel-item]>.layui-this.layui-carousel-right{opacity: 0} /** fixbar **/ -.layui-fixbar{position: fixed; right: 15px; bottom: 15px; z-index: 999999;} +.layui-fixbar{position: fixed; right: 16px; bottom: 16px; z-index: 999999;} .layui-fixbar li{width: 50px; height: 50px; line-height: 50px; margin-bottom: 1px; text-align:center; cursor: pointer; font-size:30px; background-color: #9F9F9F; color:#fff; border-radius: 2px; opacity: 0.95;} .layui-fixbar li:hover{opacity: 0.85;} .layui-fixbar li:active{opacity: 1;} From 81062fccf0294fac99b9a235cced47d3a19aa7c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Sun, 29 Jan 2023 01:14:57 +0800 Subject: [PATCH 27/28] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/layui.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3aeb4e32..308fd42d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "layui", - "version": "2.8.0-rc.5", + "version": "2.8.0-rc.6", "description": "Classic modular Front-End UI library", "main": "dist/layui.js", "license": "MIT", diff --git a/src/layui.js b/src/layui.js index c0de192c..f8f33f2f 100644 --- a/src/layui.js +++ b/src/layui.js @@ -15,7 +15,7 @@ } ,Layui = function(){ - this.v = '2.8.0-rc.5'; // Layui 版本号 + this.v = '2.8.0-rc.6'; // Layui 版本号 } //识别预先可能定义的指定全局对象 From 71ddfe2b57947fd6051d9ab9b29e81818b1bc679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Sun, 29 Jan 2023 01:30:21 +0800 Subject: [PATCH 28/28] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20introduce?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ad7663f9..477dcd03 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ --- -Layui 是一套开源的 Web UI 组件库,采用自身轻量级模块化规范,遵循原生态的 HTML/CSS/JavaScript 开发模式,极易上手,拿来即用。其风格简约,而内在丰盈,利于实现网页界面的快速构建。Layui 区别于一众主流的前端框架,却并非逆道而行,而是信奉返璞归真之道。确切地说,它更多是面向于追求简单的务实主义者,他们无需涉足各类构建工具,只需面向浏览器本身,即可轻松掌握页面所需的元素与交互,进而信手拈来。 +Layui 是一套开源的 Web UI 组件库,采用自身轻量级模块化规范,遵循原生态的 HTML/CSS/JavaScript 开发模式,极易上手,拿来即用。其风格简约轻盈,而内在雅致丰盈,甚至包括文档在内的每一处细节都经过精心雕琢,非常适合网页界面的快速构建。Layui 区别于一众主流的前端框架,却并非逆道而行,而是信奉返璞归真之道。确切地说,它更多是面向于追求简单的务实主义者,即无需涉足各类构建工具,只需面向浏览器本身,便可将页面所需呈现的元素与交互信手拈来。 ## 快速上手