Merge pull request #1104 from layui/2.x

为 v2.7.6: 修复若干问题和加强若干功能
pull/1109/head
贤心 2022-07-29 11:10:38 +08:00 committed by GitHub
commit 591bd70231
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 175 additions and 139 deletions

2
dist/layui.js vendored

File diff suppressed because one or more lines are too long

View File

@ -41,6 +41,12 @@ body{padding:20px;}
<div class="test-box"> <div class="test-box">
<div id="test6"></div> <div id="test6"></div>
</div> </div>
<div class="test-box">
<div class="test-more" lay-options="{color: '#FF0000'}"></div>
<div class="test-more" lay-options="{color: '#008000'}"></div>
<div class="test-more" lay-options="{color: '#0000FF'}"></div>
</div>
</div> </div>
<script src="../src/layui.js"></script> <script src="../src/layui.js"></script>
@ -101,6 +107,14 @@ body{padding:20px;}
,colors: ['#F00','#0F0','#00F','rgb(255, 69, 0)','rgba(255, 69, 0, 0.5)'] ,colors: ['#F00','#0F0','#00F','rgb(255, 69, 0)','rgba(255, 69, 0, 0.5)']
,size: 'xs' ,size: 'xs'
}); });
// 同时绑定多个
colorpicker.render({
elem: '.test-more',
done: function(color){
console.log(this.elem, color);
}
});
}) })
</script> </script>
</body> </body>

View File

@ -91,8 +91,8 @@
<label class="layui-form-label">行内表单</label> <label class="layui-form-label">行内表单</label>
<div class="layui-input-block"> <div class="layui-input-block">
<select name="quiz" lay-verify="required" lay-verType="tips" lay-filter="quiz111"> <select name="quiz" lay-verify="required" lay-verType="tips" lay-filter="quiz111">
<option value="">请选择问题</option> <option value="">"选择"问题</option>
<option value="0">你工作的 第一个城市</option> <option value="0">你工""的 第一个城市</option>
<option value="1" disabled>你的工号</option> <option value="1" disabled>你的工号</option>
<option value="2"> <option value="2">
你最喜欢的老师 你最喜欢的老师
@ -135,9 +135,9 @@
<div class="layui-inline"> <div class="layui-inline">
<label class="layui-form-label">搜索选择框</label> <label class="layui-form-label">搜索选择框</label>
<div class="layui-input-block"> <div class="layui-input-block">
<select name="interest-search" lay-filter="interest-search" lay-search> <select name="interest-search" lay-filter="interest-search" lay-search="">
<option value="">请搜索</option> <option value="">请搜索</option>
<option value="写作">写作</option> <option value="写作">""</option>
<option value="阅读" disabled>阅读</option> <option value="阅读" disabled>阅读</option>
<option value="游戏" disabled>游戏</option> <option value="游戏" disabled>游戏</option>
<option value="音乐">音乐</option> <option value="音乐">音乐</option>

View File

@ -50,11 +50,11 @@
,{"value": "3", "title": "贤心"} ,{"value": "3", "title": "贤心"}
,{"value": "4", "title": "鲁迅", "disabled": true} ,{"value": "4", "title": "鲁迅", "disabled": true}
,{"value": "5", "title": "巴金"} ,{"value": "5", "title": "巴金"}
,{"value": "6", "title": "冰心"},{"value": "6", "title": "冰心"},{"value": "6", "title": "冰心"},{"value": "6", "title": "冰心"},{"value": "6", "title": "冰心"},{"value": "6", "title": "冰心"},{"value": "6", "title": "冰心"},{"value": "6", "title": "冰心"},{"value": "6", "title": "冰心"},{"value": "6", "title": "冰心"} ,{"value": "6", "title": "冰心"},{"value": "6", "title": "冰心"},{"value": "6", "title": "冰心"},{"value": "6", "title": "冰心"},{"value": "6", "title": "冰心"},{"value": "6", "title": "冰心"},{"value": "6", "title": "Bbb"},{"value": "6", "title": "BB"},{"value": "6", "title": "Aa"},{"value": "6", "title": "aa"}
] ]
,id: 'demoId' ,id: 'demoId'
,value: ["2", "3"] ,value: ["2", "3"]
,showSearch: true ,showSearch: true // 若区分大小写,设置 'cs'
}); });
//按钮事件 //按钮事件

View File

@ -1,7 +1,7 @@
{ {
"name": "layui", "name": "layui",
"realname": "layui", "realname": "layui",
"version": "2.7.5", "version": "2.7.6",
"description": "Classic modular Front-End UI library", "description": "Classic modular Front-End UI library",
"main": "dist/layui.js", "main": "dist/layui.js",
"license": "MIT", "license": "MIT",

View File

@ -15,7 +15,7 @@
} }
,Layui = function(){ ,Layui = function(){
this.v = '2.7.5'; // layui 版本号 this.v = '2.7.6'; // layui 版本号
} }
//识别预先可能定义的指定全局对象 //识别预先可能定义的指定全局对象

View File

@ -162,11 +162,25 @@ layui.define(['jquery', 'lay'], function(exports){
//初始颜色选择框 //初始颜色选择框
Class.prototype.render = function(){ Class.prototype.render = function(){
var that = this var that = this;
,options = that.config var options = that.config;
// 若 elem 非唯一,则拆分为多个实例
var elem = $(options.elem);
if(elem.length > 1){
layui.each(elem, function(){
colorpicker.render($.extend({}, options, {
elem: this
}));
});
return that;
}
// 合并 lay-options 属性上的配置信息
that.config = $.extend(options, lay.options(elem[0]));
//颜色选择框对象 //颜色选择框对象
,elemColorBox = $(['<div class="layui-unselect layui-colorpicker">' var elemColorBox = $(['<div class="layui-unselect layui-colorpicker">'
,'<span '+ (options.format == 'rgb' && options.alpha ,'<span '+ (options.format == 'rgb' && options.alpha
? 'class="layui-colorpicker-trigger-bgcolor"' ? 'class="layui-colorpicker-trigger-bgcolor"'
: '') +'>' : '') +'>'
@ -196,7 +210,7 @@ layui.define(['jquery', 'lay'], function(exports){
,'</div>'].join('')) ,'</div>'].join(''))
//初始化颜色选择框 //初始化颜色选择框
var othis = $(options.elem); var othis = options.elem = $(options.elem);
options.size && elemColorBox.addClass('layui-colorpicker-'+ options.size); //初始化颜色选择框尺寸 options.size && elemColorBox.addClass('layui-colorpicker-'+ options.size); //初始化颜色选择框尺寸
//插入颜色选择框 //插入颜色选择框

View File

@ -1,20 +1,20 @@
/** /**
* form 表单组件 * form 表单组件
* MIT Licensed
*/ */
layui.define('layer', function(exports){ layui.define(['layer', 'util'], function(exports){
"use strict"; "use strict";
var $ = layui.$ var $ = layui.$;
,layer = layui.layer var layer = layui.layer;
,hint = layui.hint() var util = layui.util;
,device = layui.device() var hint = layui.hint();
var device = layui.device();
,MOD_NAME = 'form', ELEM = '.layui-form', THIS = 'layui-this' var MOD_NAME = 'form', ELEM = '.layui-form', THIS = 'layui-this';
,SHOW = 'layui-show', HIDE = 'layui-hide', DISABLED = 'layui-disabled' var SHOW = 'layui-show', HIDE = 'layui-hide', DISABLED = 'layui-disabled';
,Form = function(){ var Form = function(){
this.config = { this.config = {
verify: { verify: {
required: [ required: [
@ -357,7 +357,7 @@ layui.define('layer', function(exports){
var text = othis.text(); var text = othis.text();
// 是否区分大小写 // 是否区分大小写
if(laySearch !== 'exact'){ if(laySearch !== 'cs'){
text = text.toLowerCase(); text = text.toLowerCase();
value = value.toLowerCase(); value = value.toLowerCase();
} }
@ -477,8 +477,8 @@ layui.define('layer', function(exports){
var reElem = $(['<div class="'+ (isSearch ? '' : 'layui-unselect ') + CLASS var reElem = $(['<div class="'+ (isSearch ? '' : 'layui-unselect ') + CLASS
,(disabled ? ' layui-select-disabled' : '') +'">' ,(disabled ? ' layui-select-disabled' : '') +'">'
,'<div class="'+ TITLE +'">' ,'<div class="'+ TITLE +'">'
,('<input type="text" placeholder="'+ $.trim(placeholder) +'" ' ,('<input type="text" placeholder="'+ util.escape($.trim(placeholder)) +'" '
+('value="'+ $.trim(value ? selected.html() : '') +'"') //默认值 +('value="'+ util.escape($.trim(value ? selected.html() : '')) +'"') // 默认值
+((!disabled && isSearch) ? '' : ' readonly') // 是否开启搜索 +((!disabled && isSearch) ? '' : ' readonly') // 是否开启搜索
+' class="layui-input' +' class="layui-input'
+(isSearch ? '' : ' layui-unselect') +(isSearch ? '' : ' layui-unselect')
@ -493,7 +493,7 @@ layui.define('layer', function(exports){
} else if(item.tagName.toLowerCase() === 'optgroup'){ } else if(item.tagName.toLowerCase() === 'optgroup'){
arr.push('<dt>'+ item.label +'</dt>'); arr.push('<dt>'+ item.label +'</dt>');
} else { } else {
arr.push('<dd lay-value="'+ item.value +'" class="'+ (value === item.value ? THIS : '') + (item.disabled ? (' '+DISABLED) : '') +'">'+ $.trim(item.innerHTML) +'</dd>'); arr.push('<dd lay-value="'+ util.escape(item.value) +'" class="'+ (value === item.value ? THIS : '') + (item.disabled ? (' '+DISABLED) : '') +'">'+ $.trim(item.innerHTML) +'</dd>');
} }
}); });
arr.length === 0 && arr.push('<dd lay-value="" class="'+ DISABLED +'">没有选项</dd>'); arr.length === 0 && arr.push('<dd lay-value="" class="'+ DISABLED +'">没有选项</dd>');

View File

@ -427,14 +427,22 @@ layui.define(['laytpl', 'form'], function(exports){
//搜索 //搜索
that.laySearch.find('input').on('keyup', function(){ that.laySearch.find('input').on('keyup', function(){
var value = this.value var value = this.value;
,thisDataElem = $(this).parents('.'+ ELEM_SEARCH).eq(0).siblings('.'+ ELEM_DATA) var thisDataElem = $(this).parents('.'+ ELEM_SEARCH).eq(0).siblings('.'+ ELEM_DATA);
,thisListElem = thisDataElem.children('li'); var thisListElem = thisDataElem.children('li');
thisListElem.each(function(){ thisListElem.each(function(){
var thisList = $(this) var thisList = $(this);
,thisElemCheckbox = thisList.find('input[type="checkbox"]') var thisElemCheckbox = thisList.find('input[type="checkbox"]');
,isMatch = thisElemCheckbox[0].title.indexOf(value) !== -1; var title = thisElemCheckbox[0].title;
// 是否区分大小写
if(options.showSearch !== 'cs'){
title = title.toLowerCase();
value = value.toLowerCase();
}
var isMatch = title.indexOf(value) !== -1;
thisList[isMatch ? 'removeClass': 'addClass'](HIDE); thisList[isMatch ? 'removeClass': 'addClass'](HIDE);
thisElemCheckbox.data('hide', isMatch ? false : true); thisElemCheckbox.data('hide', isMatch ? false : true);