mirror of https://github.com/layui/layui
commit
591bd70231
File diff suppressed because one or more lines are too long
|
@ -41,6 +41,12 @@ body{padding:20px;}
|
|||
<div class="test-box">
|
||||
<div id="test6"></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>
|
||||
|
||||
<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)']
|
||||
,size: 'xs'
|
||||
});
|
||||
|
||||
// 同时绑定多个
|
||||
colorpicker.render({
|
||||
elem: '.test-more',
|
||||
done: function(color){
|
||||
console.log(this.elem, color);
|
||||
}
|
||||
});
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -91,8 +91,8 @@
|
|||
<label class="layui-form-label">行内表单</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="quiz" lay-verify="required" lay-verType="tips" lay-filter="quiz111">
|
||||
<option value="">请选择问题</option>
|
||||
<option value="0">你工作的 第一个城市</option>
|
||||
<option value="">请"选择"问题</option>
|
||||
<option value="0">你工"作"的 第一个城市</option>
|
||||
<option value="1" disabled>你的工号</option>
|
||||
<option value="2">
|
||||
你最喜欢的老师
|
||||
|
@ -135,9 +135,9 @@
|
|||
<div class="layui-inline">
|
||||
<label class="layui-form-label">搜索选择框</label>
|
||||
<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="阅读" disabled>阅读</option>
|
||||
<option value="游戏" disabled>游戏</option>
|
||||
<option value="音乐">音乐</option>
|
||||
|
|
|
@ -50,11 +50,11 @@
|
|||
,{"value": "3", "title": "贤心"}
|
||||
,{"value": "4", "title": "鲁迅", "disabled": true}
|
||||
,{"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'
|
||||
,value: ["2", "3"]
|
||||
,showSearch: true
|
||||
,showSearch: true // 若区分大小写,设置 'cs'
|
||||
});
|
||||
|
||||
//按钮事件
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "layui",
|
||||
"realname": "layui",
|
||||
"version": "2.7.5",
|
||||
"version": "2.7.6",
|
||||
"description": "Classic modular Front-End UI library",
|
||||
"main": "dist/layui.js",
|
||||
"license": "MIT",
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
}
|
||||
|
||||
,Layui = function(){
|
||||
this.v = '2.7.5'; // layui 版本号
|
||||
this.v = '2.7.6'; // layui 版本号
|
||||
}
|
||||
|
||||
//识别预先可能定义的指定全局对象
|
||||
|
|
|
@ -162,11 +162,25 @@ layui.define(['jquery', 'lay'], function(exports){
|
|||
|
||||
//初始颜色选择框
|
||||
Class.prototype.render = function(){
|
||||
var that = this
|
||||
,options = that.config
|
||||
var that = this;
|
||||
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
|
||||
? 'class="layui-colorpicker-trigger-bgcolor"'
|
||||
: '') +'>'
|
||||
|
@ -196,7 +210,7 @@ layui.define(['jquery', 'lay'], function(exports){
|
|||
,'</div>'].join(''))
|
||||
|
||||
//初始化颜色选择框
|
||||
var othis = $(options.elem);
|
||||
var othis = options.elem = $(options.elem);
|
||||
options.size && elemColorBox.addClass('layui-colorpicker-'+ options.size); //初始化颜色选择框尺寸
|
||||
|
||||
//插入颜色选择框
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
/**
|
||||
* form 表单组件
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
layui.define('layer', function(exports){
|
||||
layui.define(['layer', 'util'], function(exports){
|
||||
"use strict";
|
||||
|
||||
var $ = layui.$
|
||||
,layer = layui.layer
|
||||
,hint = layui.hint()
|
||||
,device = layui.device()
|
||||
var $ = layui.$;
|
||||
var layer = layui.layer;
|
||||
var util = layui.util;
|
||||
var hint = layui.hint();
|
||||
var device = layui.device();
|
||||
|
||||
,MOD_NAME = 'form', ELEM = '.layui-form', THIS = 'layui-this'
|
||||
,SHOW = 'layui-show', HIDE = 'layui-hide', DISABLED = 'layui-disabled'
|
||||
var MOD_NAME = 'form', ELEM = '.layui-form', THIS = 'layui-this';
|
||||
var SHOW = 'layui-show', HIDE = 'layui-hide', DISABLED = 'layui-disabled';
|
||||
|
||||
,Form = function(){
|
||||
var Form = function(){
|
||||
this.config = {
|
||||
verify: {
|
||||
required: [
|
||||
|
@ -357,7 +357,7 @@ layui.define('layer', function(exports){
|
|||
var text = othis.text();
|
||||
|
||||
// 是否区分大小写
|
||||
if(laySearch !== 'exact'){
|
||||
if(laySearch !== 'cs'){
|
||||
text = text.toLowerCase();
|
||||
value = value.toLowerCase();
|
||||
}
|
||||
|
@ -477,8 +477,8 @@ layui.define('layer', function(exports){
|
|||
var reElem = $(['<div class="'+ (isSearch ? '' : 'layui-unselect ') + CLASS
|
||||
,(disabled ? ' layui-select-disabled' : '') +'">'
|
||||
,'<div class="'+ TITLE +'">'
|
||||
,('<input type="text" placeholder="'+ $.trim(placeholder) +'" '
|
||||
+('value="'+ $.trim(value ? selected.html() : '') +'"') //默认值
|
||||
,('<input type="text" placeholder="'+ util.escape($.trim(placeholder)) +'" '
|
||||
+('value="'+ util.escape($.trim(value ? selected.html() : '')) +'"') // 默认值
|
||||
+((!disabled && isSearch) ? '' : ' readonly') // 是否开启搜索
|
||||
+' class="layui-input'
|
||||
+(isSearch ? '' : ' layui-unselect')
|
||||
|
@ -493,7 +493,7 @@ layui.define('layer', function(exports){
|
|||
} else if(item.tagName.toLowerCase() === 'optgroup'){
|
||||
arr.push('<dt>'+ item.label +'</dt>');
|
||||
} 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>');
|
||||
|
|
|
@ -427,14 +427,22 @@ layui.define(['laytpl', 'form'], function(exports){
|
|||
|
||||
//搜索
|
||||
that.laySearch.find('input').on('keyup', function(){
|
||||
var value = this.value
|
||||
,thisDataElem = $(this).parents('.'+ ELEM_SEARCH).eq(0).siblings('.'+ ELEM_DATA)
|
||||
,thisListElem = thisDataElem.children('li');
|
||||
var value = this.value;
|
||||
var thisDataElem = $(this).parents('.'+ ELEM_SEARCH).eq(0).siblings('.'+ ELEM_DATA);
|
||||
var thisListElem = thisDataElem.children('li');
|
||||
|
||||
thisListElem.each(function(){
|
||||
var thisList = $(this)
|
||||
,thisElemCheckbox = thisList.find('input[type="checkbox"]')
|
||||
,isMatch = thisElemCheckbox[0].title.indexOf(value) !== -1;
|
||||
var thisList = $(this);
|
||||
var thisElemCheckbox = thisList.find('input[type="checkbox"]');
|
||||
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);
|
||||
thisElemCheckbox.data('hide', isMatch ? false : true);
|
||||
|
|
Loading…
Reference in New Issue