This commit is contained in:
贤心
2022-05-18 22:35:13 +08:00
parent ce805ee6b3
commit 902aea37d9
49 changed files with 861 additions and 613 deletions

View File

@@ -887,7 +887,7 @@ a cite{font-style: normal; *cursor:pointer;}
.layui-table[lay-data]{display: none;}
.layui-table-box{position: relative; overflow: hidden;}
.layui-table-view{margin: 10px 0;}
.layui-table-view .layui-table{position: relative; width: auto; margin: 0;}
.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;}
.layui-table-view .layui-table th,

View File

@@ -1,5 +1,4 @@
/*!
/**
* Layui
* Classic modular Front-End UI library
* MIT Licensed
@@ -16,7 +15,7 @@
}
,Layui = function(){
this.v = '2.6.8'; // layui 版本号
this.v = '2.6.9'; // layui 版本号
}
//识别预先可能定义的指定全局对象
@@ -371,7 +370,7 @@
};
// location.hash 路由解析
Layui.prototype.router = function(hash){
Layui.prototype.router = Layui.prototype.hash = function(hash){
var that = this
,hash = hash || location.hash
,data = {
@@ -541,7 +540,7 @@
};
//typeof 类型细分 -> string/number/boolean/undefined/null、object/array/function/…
Layui.prototype._typeof = function(operand){
Layui.prototype._typeof = Layui.prototype.type = function(operand){
if(operand === null) return String(operand);
//细分引用类型
@@ -559,10 +558,10 @@
};
//对象是否具备数组结构(此处为兼容 jQuery 对象)
Layui.prototype._isArray = function(obj){
Layui.prototype._isArray = Layui.prototype.isArray = function(obj){
var that = this
,len
,type = that._typeof(obj);
,type = that.type(obj);
if(!obj || (typeof obj !== 'object') || obj === win) return false;
@@ -584,7 +583,7 @@
obj = obj || [];
//优先处理数组结构
if(that._isArray(obj)){
if(that.isArray(obj)){
for(key = 0; key < obj.length; key++){
if(callFn(key, obj)) break;
}
@@ -597,25 +596,57 @@
return that;
};
//将数组中的对象按某个成员排序
Layui.prototype.sort = function(obj, key, desc){
var clone = JSON.parse(
JSON.stringify(obj || [])
// 将数组中的成员对象按某个 key 的 value 值进行排序
Layui.prototype.sort = function(arr, key, desc){
var that = this
,clone = JSON.parse(
JSON.stringify(arr || [])
);
if(!key) return clone;
// 若未传入 key则直接返回原对象
if(that.type(arr) === 'object' && !key){
return clone;
} else if(typeof arr !== 'object'){ //若 arr 非对象
return [clone];
}
//如果是数字,按大小排序;如果是非数字,则按字典序排序
// 开始排序
clone.sort(function(o1, o2){
var v1 = o1[key]
,v2 = o2[key]
,isNum = [
!isNaN(v1)
,!isNaN(v2)
];
,v2 = o2[key];
//若为数字比较
/*
* 特殊数据
* 若比较的成员均非对象
*/
// 若比较的成员均为数字
if(!isNaN(o1) && !isNaN(o2)) return o1 - o2;
// 若比较的成员只存在某一个非对象
if(!isNaN(o1) && isNaN(o2)){
if(key && typeof o2 === 'object'){
v1 = o1;
} else {
return -1;
}
} else if (isNaN(o1) && !isNaN(o2)){
if(key && typeof o1 === 'object'){
v2 = o2;
} else {
return 1;
}
}
/*
* 正常数据
* 即成员均为对象,也传入了对比依据: key
* 若 value 为数字,按「大小」排序;若 value 非数字,则按「字典序」排序
*/
// value 是否为数字
var isNum = [!isNaN(v1), !isNaN(v2)];
// 若为数字比较
if(isNum[0] && isNum[1]){
if(v1 && (!v2 && v2 !== 0)){ //数字 vs 空
return 1;
@@ -630,9 +661,9 @@
* 字典序排序
*/
//若为非数字比较
// 若为非数字比较
if(!isNum[0] && !isNum[1]){
//字典序比较
// 字典序比较
if(v1 > v2){
return 1;
} else if (v1 < v2) {
@@ -642,33 +673,16 @@
}
}
//若为混合比较
// 若为混合比较
if(isNum[0] || !isNum[1]){ //数字 vs 非数字
return -1;
} else if(!isNum[0] || isNum[1]) { //非数字 vs 数字
return 1;
}
/*
//老版本
if(v1 && !v2){
return 1;
} else if(!v1 && v2){
return -1;
}
if(v1 > v2){
return 1;
} else if (v1 < v2) {
return -1;
} else {
return 0;
}
*/
});
desc && clone.reverse(); //倒序
desc && clone.reverse(); // 倒序
return clone;
};

View File

@@ -1,5 +1,4 @@

/*!
/*!
* 用于加载所有内置模块
* MIT Licensed
*/

View File

@@ -1,5 +1,4 @@
/*!
/**
* carousel 轮播模块
* MIT Licensed
*/

View File

@@ -1,4 +1,3 @@
/**
* code 代码修饰器
* MIT Licensed

View File

@@ -1,5 +1,4 @@
/*!
/**
* colorpicker
* 颜色选择组件
*/

View File

@@ -1,5 +1,4 @@
/*!
/**
* MODULE_DEMO_NAME 模块组件通用结构
* MIT Licensed
*/
@@ -73,7 +72,7 @@ layui.define([''], function(exports){
//防止数组深度合并
layui.each(options, function(key, item){
if(layui._typeof(item) === 'array') delete that.config[key];
if(layui.type(item) === 'array') delete that.config[key];
});
that.config = $.extend(true, {}, that.config, options);

View File

@@ -1,8 +1,6 @@
/**
@Namedropdown 下拉菜单组件
@LicenseMIT
* dropdown
* 下拉菜单组件
*/
layui.define(['jquery', 'laytpl', 'lay'], function(exports){

View File

@@ -1,5 +1,4 @@
/*!
/**
* element 常用元素操作
* MIT Licensed
*/

View File

@@ -1,8 +1,5 @@
/**
@Name flow 流加载组件
@LicenseMIT
* flow 流加载组件
*/

View File

@@ -1,5 +1,4 @@
/*!
/**
* form 表单组件
* MIT Licensed
*/

View File

@@ -1,5 +1,5 @@
/*! lay 基础 DOM 操作 | MIT Licensed */
/** lay 基础 DOM 操作 | MIT Licensed */
;!function(window){ //gulp build: lay-header
"use strict";
@@ -33,9 +33,11 @@
//普通对象深度扩展
lay.extend = function(){
var ai = 1, args = arguments
var ai = 1
,length
,args = arguments
,clone = function(target, obj){
target = target || (layui._typeof(obj) === 'array' ? [] : {}); //目标对象
target = target || (layui.type(obj) === 'array' ? [] : {}); //目标对象
for(var i in obj){
//如果值为普通对象,则进入递归,继续深度合并
target[i] = (obj[i] && obj[i].constructor === Object)
@@ -46,8 +48,9 @@
}
args[0] = typeof args[0] === 'object' ? args[0] : {};
length = args.length
for(; ai < args.length; ai++){
for(; ai < length; ai++){
if(typeof args[ai] === 'object'){
clone(args[0], args[ai]);
}

View File

@@ -1,5 +1,5 @@
/*! layDate 日期与时间控件 | MIT Licensed */
/** layDate 日期与时间控件 | MIT Licensed */
;!function(window, document){
"use strict";
@@ -192,7 +192,7 @@
that.rangeStr = options.range ? (typeof options.range === 'string' ? options.range : '-') : '';
//若 range 参数为数组,则表示为开始日期和结束日期的 input 对象
if(layui._typeof(options.range) === 'array'){
if(layui.type(options.range) === 'array'){
that.rangeElem = [
lay(options.range[0]),
lay(options.range[1])
@@ -264,7 +264,6 @@
,'0-5-4': '青年'
,'0-6-1': '儿童'
,'0-9-10': '教师'
,'0-9-18': '国耻'
,'0-10-1': '国庆'
,'0-12-25': '圣诞'
} : {}, options.mark);
@@ -274,7 +273,15 @@
var ymd = [], hms = [];
if(typeof options[item] === 'number'){ //如果为数字
var day = options[item]
,time = new Date().getTime()
,tDate = new Date()
,time = that.newDate({ //今天的最大毫秒数
year: tDate.getFullYear()
,month: tDate.getMonth()
,date: tDate.getDate()
,hours: '23'
,minutes: '59'
,seconds: '59'
}).getTime()
,STAMP = 86400000 //代表一天的毫秒数
,thisDate = new Date(
day ? (
@@ -282,7 +289,7 @@
) : time
);
ymd = [thisDate.getFullYear(), thisDate.getMonth() + 1, thisDate.getDate()];
day < STAMP || (hms = [thisDate.getHours(), thisDate.getMinutes(), thisDate.getSeconds()]);
hms = [thisDate.getHours(), thisDate.getMinutes(), thisDate.getSeconds()];
} else {
ymd = (options[item].match(/\d+-\d+-\d+/) || [''])[0].split('-');
hms = (options[item].match(/\d+:\d+:\d+/) || [''])[0].split(':');
@@ -304,7 +311,7 @@
//默认赋值
if(options.value && options.isInitValue){
if(layui._typeof(options.value) === 'date'){
if(layui.type(options.value) === 'date'){
that.setValue(that.parse(0, that.systemDate(options.value)));
} else {
that.setValue(options.value);
@@ -696,7 +703,7 @@
) + lang.formatError[1]);
error = true;
}
} else if(value && layui._typeof(value) === 'date'){ //如果值为日期对象时
} else if(value && layui.type(value) === 'date'){ //如果值为日期对象时
options.dateTime = that.systemDate(value);
} else {
//重置开始日期
@@ -739,7 +746,9 @@
};
//校验主面板是否在可选日期区间
if(getDateTime(dateTime) > getDateTime(options.max) || getDateTime(dateTime) < getDateTime(options.min)){
if(getDateTime(dateTime) > getDateTime(options.max)){ //若超出最大日期
dateTime = options.dateTime = lay.extend({}, options.max);
} else if(getDateTime(dateTime) < getDateTime(options.min)){ //若少于最小日期
dateTime = options.dateTime = lay.extend({}, options.min);
}
@@ -1040,7 +1049,6 @@
lay(ul).find('li').on('click', function(){
var ym = lay(this).attr('lay-ym') | 0;
if(lay(this).hasClass(DISABLED)) return;
if(index === 0){
dateTime[type] = ym;
that.limit(lay(that.footer).find(ELEM_CONFIRM), null, 0);
@@ -1302,9 +1310,9 @@
//补充时分秒
lay.each(['startTime', 'endTime'], function(i, item){
that[item] = that[item] || {
hours: 0
,minutes: 0
,seconds: 0
hours: i ? 23: 0
,minutes: i ? 59: 0
,seconds: i ? 59: 0
};
});
that.calendar(null, index).done(null, 'change');
@@ -1377,8 +1385,9 @@
} else {
if(lay(btn).hasClass(DISABLED)) return that.hint(lang.invalidDate);
}
that.setValue(that.parse()).remove();
that.done();
that.setValue(that.parse()).remove()
}
};
active[type] && active[type]();

View File

@@ -1,8 +1,5 @@
/**
@Namelayedit 富文本编辑器
@LicenseMIT
* layedit 富文本编辑器
*/
layui.define(['layer', 'form'], function(exports){
@@ -28,7 +25,7 @@ layui.define(['layer', 'form'], function(exports){
,'|'
,'left', 'center', 'right'
,'|'
,'link', 'unlink', 'face', 'image'
,'link', 'unlink'
]
,hideTool: []
,height: 280 //默认高
@@ -372,38 +369,6 @@ layui.define(['layer', 'form'], function(exports){
,unlink: function(range){
iframeDOM.execCommand('unlink');
}
//表情
,face: function(range){
face.call(this, function(img){
insertInline.call(iframeWin, 'img', {
src: img.src
,alt: img.alt
}, range);
});
}
//图片
,image: function(range){
var that = this;
layui.use('upload', function(upload){
var uploadImage = set.uploadImage || {};
upload.render({
url: uploadImage.url
,method: uploadImage.type
,elem: $(that).find('input')[0]
,done: function(res){
if(res.code == 0){
res.data = res.data || {};
insertInline.call(iframeWin, 'img', {
src: res.data.src
,alt: res.data.title
}, range);
} else {
layer.msg(res.msg||'上传失败');
}
}
});
});
}
//插入代码
,code: function(range){
code.call(body, function(pre){
@@ -471,7 +436,6 @@ layui.define(['layer', 'form'], function(exports){
//触发内容区域
body.on('click', function(){
toolCheck.call(iframeWin, tools);
layer.close(face.index);
});
}
@@ -523,48 +487,6 @@ layui.define(['layer', 'form'], function(exports){
link.index = index;
}
//表情面板
,face = function(callback){
//表情库
var faces = function(){
var alt = ["[微笑]", "[嘻嘻]", "[哈哈]", "[可爱]", "[可怜]", "[挖鼻]", "[吃惊]", "[害羞]", "[挤眼]", "[闭嘴]", "[鄙视]", "[爱你]", "[泪]", "[偷笑]", "[亲亲]", "[生病]", "[太开心]", "[白眼]", "[右哼哼]", "[左哼哼]", "[嘘]", "[衰]", "[委屈]", "[吐]", "[哈欠]", "[抱抱]", "[怒]", "[疑问]", "[馋嘴]", "[拜拜]", "[思考]", "[汗]", "[困]", "[睡]", "[钱]", "[失望]", "[酷]", "[色]", "[哼]", "[鼓掌]", "[晕]", "[悲伤]", "[抓狂]", "[黑线]", "[阴险]", "[怒骂]", "[互粉]", "[心]", "[伤心]", "[猪头]", "[熊猫]", "[兔子]", "[ok]", "[耶]", "[good]", "[NO]", "[赞]", "[来]", "[弱]", "[草泥马]", "[神马]", "[囧]", "[浮云]", "[给力]", "[围观]", "[威武]", "[奥特曼]", "[礼物]", "[钟]", "[话筒]", "[蜡烛]", "[蛋糕]"], arr = {};
layui.each(alt, function(index, item){
arr[item] = layui.cache.dir + 'images/face/'+ index + '.gif';
});
return arr;
}();
face.hide = face.hide || function(e){
if($(e.target).attr('layedit-event') !== 'face'){
layer.close(face.index);
}
}
return face.index = layer.tips(function(){
var content = [];
layui.each(faces, function(key, item){
content.push('<li title="'+ key +'"><img src="'+ item +'" alt="'+ key +'"></li>');
});
return '<ul class="layui-clear">' + content.join('') + '</ul>';
}(), this, {
tips: 1
,time: 0
,skin: 'layui-box layui-util-face'
,maxWidth: 500
,success: function(layero, index){
layero.css({
marginTop: -4
,marginLeft: -10
}).find('.layui-clear>li').on('click', function(){
callback && callback({
src: faces[this.title]
,alt: this.title
});
layer.close(index);
});
$(document).off('click', face.hide).on('click', face.hide);
}
});
}
//插入代码面板
,code = function(callback){
var body = this, index = layer.open({

View File

@@ -1,5 +1,4 @@

/*!
/**
* layer - 通用 Web 弹出层组件
* MIT Licensed
*/

View File

@@ -1,8 +1,5 @@
/**
@Name : laypage 分页组件
@LicenseMIT
* laypage 分页组件
*/
layui.define(function(exports){

View File

@@ -1,8 +1,5 @@
/**
@Name : laytpl 模板引擎
@LicenseMIT
* laytpl 模板引擎
*/
layui.define(function(exports){
@@ -79,7 +76,7 @@ layui.define(function(exports){
str = str.replace(exp(config.open+'|'+config.close), '');
if(/^=/.test(str)){
str = str.replace(/^=/, '');
start = '"+_escape_(';
start = '"+laytpl.escape(';
}
return start + str.replace(/\\(.)/g, '$1') + ')+"';
});
@@ -87,8 +84,8 @@ layui.define(function(exports){
tpl = '"use strict";var view = "' + tpl + '";return view;';
try{
that.cache = tpl = new Function('d, _escape_', tpl);
return tpl(data, tool.escape);
that.cache = tpl = new Function('d, laytpl', tpl);
return tpl(data, tool);
} catch(e){
delete that.cache;
return tool.error(e, tplog);
@@ -98,7 +95,7 @@ layui.define(function(exports){
Tpl.pt.render = function(data, callback){
var that = this, tpl;
if(!data) return tool.error('no data');
tpl = that.cache ? that.cache(data, tool.escape) : that.parse(that.tpl, data);
tpl = that.cache ? that.cache(data, tool) : that.parse(that.tpl, data);
if(!callback) return tpl;
callback(tpl);
};

View File

@@ -1,5 +1,4 @@

/*!
/**
* 用于打包聚合版,该文件不会存在于构建后的目录
*/

View File

@@ -1,8 +1,6 @@
/**
@Namelayui 移动模块入口 | 构建后则为移动模块集合
@LicenseMIT
* layui 移动模块入口
* 构建后则为移动模块集合
*/

View File

@@ -1,8 +1,5 @@
/**
@Title: rate 评分评星组件
@LicenseMIT
* rate 评分评星组件
*/
layui.define('jquery',function(exports){

View File

@@ -1,8 +1,5 @@
/**
@Title: slider 滑块组件
@LicenseMIT
* slider 滑块组件
*/
layui.define('jquery', function(exports){

View File

@@ -1,5 +1,4 @@
/*!
/**
* layui.table
* 数据表格组件
*/
@@ -71,19 +70,28 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
}
//解析自定义模板数据
,parseTempData = function(item3, content, tplData, text){ //表头数据、原始内容、表体数据、是否只返回文本
var options = this.config || {};
,parseTempData = function(obj){
obj = obj || {};
var options = this.config || {}
,item3 = obj.item3 //表头数据
,content = obj.content; //原始内容
//是否防 xss
if(options.escape) content = util.escape(content);
//获取内容
var str = item3.templet ? function(){
return typeof item3.templet === 'function'
? item3.templet(tplData)
: laytpl($(item3.templet).html() || String(content)).render(tplData)
}() : content;
return text ? $('<div>'+ str +'</div>').text() : str;
//获取模板
var templet = obj.text && item3.exportTemplet || (item3.templet || item3.toolbar);
//获取模板内容
if(templet){
content = typeof templet === 'function'
? templet.call(item3, obj.tplData, obj.obj)
: laytpl($(templet).html() || String(content)).render(obj.tplData);
}
//是否只返回文本
return obj.text ? $('<div>'+ content +'</div>').text() : content;
}
//字符常量
@@ -650,7 +658,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
//防止数组深度合并
layui.each(options, function(key, item){
if(layui._typeof(item) === 'array') delete that.config[key];
if(layui.type(item) === 'array') delete that.config[key];
});
//对参数进行深度或浅扩展
@@ -744,7 +752,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
typeof options.error === 'function' && options.error(e, msg);
}
});
} else if(layui._typeof(options.data) === 'array'){ //已知数据
} else if(layui.type(options.data) === 'array'){ //已知数据
var res = {}
,startLimit = curr*options.limit - options.limit
@@ -790,7 +798,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
,numbers = i1 + options.limit*(curr - 1) + 1; //序号
//若数据项为空数组,则不往下执行(因为删除数据时,会将原有数据设置为 []
if(layui._typeof(item1) === 'array' && item1.length === 0) return;
if(layui.type(item1) === 'array' && item1.length === 0) return;
//记录下标索引,用于恢复排序
if(!sort){
@@ -810,7 +818,6 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
var td = ['<td data-field="'+ field +'" data-key="'+ key +'" '+ function(){ //追加各种属性
var attr = [];
if(item3.edit) attr.push('data-edit="'+ item3.edit +'"'); //是否允许单元格编辑
if(item3.align) attr.push('align="'+ item3.align +'"'); //对齐方式
if(item3.templet) attr.push('data-content="'+ content +'"'); //自定义模板
if(item3.toolbar) attr.push('data-off="true"'); //行工具列关闭单元格事件
if(item3.event) attr.push('lay-event="'+ item3.event +'"'); //自定义事件
@@ -826,7 +833,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
,'<div class="layui-table-cell laytable-cell-'+ function(){ //返回对应的CSS类标识
return item3.type === 'normal' ? key
: (key + ' laytable-cell-' + item3.type);
}() +'">' + function(){
}() +'"'+ (item3.align ? ' align="'+ item3.align +'"' : '') +'>' + function(){
var tplData = $.extend(true, {
LAY_INDEX: numbers
,LAY_COL: item3
@@ -861,7 +868,11 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
if(item3.toolbar){
return laytpl($(item3.toolbar).html()||'').render(tplData);
}
return parseTempData.call(that, item3, content, tplData);
return parseTempData.call(that, {
item3: item3
,content: content
,tplData: tplData
});
}()
,'</div></td>'].join('');
@@ -957,7 +968,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
layui.each(data, function(i1, item1){
//若数据项为空数组,则不往下执行(因为删除数据时,会将原有数据设置为 []
if(layui._typeof(item1) === 'array' && item1.length === 0) return;
if(layui.type(item1) === 'array' && item1.length === 0) return;
that.eachCols(function(i3, item3){
var field = item3.field || i3
@@ -985,7 +996,11 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
tplData[field] = thisTotalNum;
//获取自动计算的合并内容
getContent = item3.totalRow ? (parseTempData.call(that, item3, thisTotalNum, tplData) || text) : text;
getContent = item3.totalRow ? (parseTempData.call(that, {
item3: item3
,content: thisTotalNum
,tplData: tplData
}) || text) : text;
//如果直接传入了合计行数据,则不输出自动计算的结果
return totalRowData ? (totalRowData[item3.field] || getContent) : getContent;
@@ -1142,7 +1157,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
,options = that.config
,thisData = table.cache[that.key];
if(!thisData[index]) return;
if(layui._typeof(thisData[index]) === 'array') return;
if(layui.type(thisData[index]) === 'array') return;
thisData[index][options.checkName] = checked;
};
@@ -1194,7 +1209,8 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
Class.prototype.fullSize = function(){
var that = this
,options = that.config
,height = options.height, bodyHeight;
,height = options.height
,bodyHeight;
if(that.fullHeightGap){
height = _WIN.height() - that.fullHeightGap;
@@ -1209,17 +1225,17 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
//减去工具栏的高度
if(options.toolbar){
bodyHeight = bodyHeight - (that.layTool.outerHeight() || 50);
bodyHeight -= (that.layTool.outerHeight() || 50);
}
//减去统计朗的高度
if(options.totalRow){
bodyHeight = bodyHeight - (that.layTotal.outerHeight() || 40);
bodyHeight -= (that.layTotal.outerHeight() || 40);
}
//减去分页栏的高度
if(options.page){
bodyHeight = bodyHeight - (that.layPage.outerHeight() || 41);
bodyHeight -= (that.layPage.outerHeight() || 41);
}
that.layMain.css('height', bodyHeight - 2);
@@ -1503,7 +1519,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
});
//数据行中的事件返回的公共对象成员
var commonMember = function(sets){
var commonMember = that.commonMember = function(sets){
var othis = $(this)
,index = othis.parents('tr').eq(0).data('index')
,tr = that.layBody.find('tr[data-index="'+ index +'"]')
@@ -1523,19 +1539,34 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
,update: function(fields){ //修改行数据
fields = fields || {};
layui.each(fields, function(key, value){
if(key in data){
var templet, td = tr.children('td[data-field="'+ key +'"]');
data[key] = value;
that.eachCols(function(i, item2){
if(item2.field == key && item2.templet){
templet = item2.templet;
}
});
td.children(ELEM_CELL).html(parseTempData.call(that, {
templet: templet
}, value, data));
td.data('content', value);
}
var td = tr.children('td[data-field="'+ key +'"]')
,cell = td.children(ELEM_CELL); //获取当前修改的列
//更新缓存中的数据
if(key in data) data[key] = value;
that.eachCols(function(i, item3){
var templet = item3.templet || item3.toolbar;
//更新相应列视图
if(item3.field == key && item3.templet){
cell.html(parseTempData.call(that, {
item3: {templet: item3.templet}
,content: value
,tplData: data
}));
td.data('content', value);
} else if(templet){ //更新所有其他列的模板
var thisTd = tr.children('td[data-field="'+ (item3.field || i) +'"]')
,content = data[item3.field];
thisTd.children(ELEM_CELL).html(parseTempData.call(that, {
item3: {templet: templet}
,content: content
,tplData: data
}));
thisTd.data('content', content);
}
});
});
}
}, sets);
@@ -1645,8 +1676,10 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
});
othis.siblings(ELEM_CELL).html(function(value){
return parseTempData.call(that, {
templet: templet
}, value, data);
item3: {templet: templet}
,content: value
,tplData: data
});
}(thisElem.value));
othis.parent().data('content', thisElem.value);
othis.remove();
@@ -1904,7 +1937,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
,data = table.cache[id] || [];
//计算全选个数
layui.each(data, function(i, item){
if(layui._typeof(item) === 'array'){
if(layui.type(item) === 'array'){
invalidNum++; //无效数据,或已删除的
return;
}
@@ -1924,7 +1957,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
var arr = []
,data = table.cache[id] || [];
layui.each(data, function(i, item){
if(layui._typeof(item) === 'array'){
if(layui.type(item) === 'array'){
return;
};
arr.push(table.clearCacheKey(item));
@@ -1950,7 +1983,10 @@ layui.define(['laytpl', 'laypage', 'layer', '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 = [];
var dataTitle = []
,dataMain = []
,dataTotal = []
,fieldsIsHide = {};
//表头和表体
layui.each(data, function(i1, item1){
@@ -1964,12 +2000,30 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
});
} else {
table.eachCols(id, function(i3, item3){
if(item3.field && item3.type == 'normal' && !item3.hide){
var content = item1[item3.field];
if(item3.field && item3.type == 'normal'){
//不导出隐藏列
if(item3.hide){
if(i1 == 0) fieldsIsHide[item3.field] = true; //记录隐藏列
return;
}
var content = item1[item3.field]
,td = that.layBody.find('tr[data-index="'+ i1 +'"]>td');
if(content === undefined || content === null) content = '';
i1 == 0 && dataTitle.push(item3.title || '');
vals.push('"'+ parseTempData.call(thatTable, item3, content, item1, 'text') + '"');
vals.push('"'+ parseTempData.call(thatTable, {
item3: item3
,content: content
,tplData: item1
,text: 'text'
,obj: thatTable.commonMember.call(td.eq(0), {
td: function(field){
return td.filter('[data-field="'+ field +'"]');
}
})
}) + '"');
}
});
}
@@ -1978,7 +2032,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
//表合计
layui.each(that.dataTotal, function(key, value){
dataTotal.push(value);
fieldsIsHide[key] || dataTotal.push(value);
});
return dataTitle.join(',') + '\r\n' + dataMain.join('\r\n') + '\r\n' + dataTotal.join(',');

View File

@@ -1,8 +1,5 @@
/**
@Nametransfer 穿梭框组件
@LicenseMIT
* transfer 穿梭框组件
*/
layui.define(['laytpl', 'form'], function(exports){
@@ -171,7 +168,11 @@ layui.define(['laytpl', 'form'], function(exports){
});
that.layData.css({
height: function(){
return options.height - that.layHeader.outerHeight() - that.laySearch.outerHeight() - 2
var height = options.height - that.layHeader.outerHeight();
if(options.showSearch){
height -= that.laySearch.outerHeight();
}
return height - 2;
}()
});

View File

@@ -1,8 +1,5 @@
/**
@Nametree 树组件
@LicenseMIT
* tree 树组件
*/
layui.define('form', function(exports){
@@ -101,7 +98,7 @@ layui.define('form', function(exports){
var that = this;
layui.each(options, function(key, item){
if(layui._typeof(item) === 'array') delete that.config[key];
if(layui.type(item) === 'array') delete that.config[key];
});
that.config = $.extend(true, {}, that.config, options);

View File

@@ -1,7 +1,6 @@
/*!
* upload 文件上传组件
* MIT Licensed
/**
* upload
* 文件上传组件
*/
layui.define('layer' , function(exports){
@@ -63,6 +62,7 @@ layui.define('layer' , function(exports){
,auto: true //是否选完文件后自动上传
,bindAction: '' //手动上传触发的元素
,url: '' //上传地址
,force: '' //强制规定返回的数据格式,目前只支持是否强制 json
,field: 'file' //文件字段名
,acceptMime: '' //筛选出的文件类型,默认为所有文件
,method: 'post' //请求上传的 http 类型
@@ -218,9 +218,9 @@ layui.define('layer' , function(exports){
allDone();
}
//异常回调
,error: function(){
,error: function(e){
aborted++;
that.msg('请求上传接口出现异常');
that.msg('Request URL is abnormal: '+ (e.statusText || 'error'));
error(index);
allDone();
}
@@ -256,7 +256,7 @@ layui.define('layer' , function(exports){
try {
res = iframeBody.text();
} catch(e) {
that.msg('获取上传后的响应信息出现异常');
that.msg('Cross-domain requests are not supported');
clearInterval(Class.timer);
error();
}
@@ -272,14 +272,18 @@ layui.define('layer' , function(exports){
,done = function(index, res){
that.elemFile.next('.'+ ELEM_CHOOSE).remove();
elemFile.value = '';
if(typeof res !== 'object'){
try {
res = JSON.parse(res);
} catch(e){
res = {};
return that.msg('请对上传接口返回有效JSON');
if(options.force === 'json'){
if(typeof res !== 'object'){
try {
res = JSON.parse(res);
} catch(e){
res = {};
return that.msg('Please return JSON data format');
}
}
}
typeof options.done === 'function' && options.done(res, index || 0, function(files){
that.upload(files);
});
@@ -352,6 +356,14 @@ layui.define('layer' , function(exports){
ajaxSend();
}
//文件类型名称
,typeName = ({
file: '文件'
,images: '图片'
,video: '视频'
,audio: '音频'
})[options.accept] || '文件';
//校验文件格式
value = value.length === 0
@@ -359,39 +371,45 @@ layui.define('layer' , function(exports){
: value;
if(value.length === 0) return;
//根据文件类型校验
switch(options.accept){
case 'file': //一般文件
if(exts && !RegExp('\\w\\.('+ exts +')$', 'i').test(escape(value))){
that.msg('选择的文件中包含不支持的格式');
return elemFile.value = '';
}
layui.each(value, function(i, item){
if(exts && !RegExp('.\\.('+ exts +')$', 'i').test(escape(item))){
return check = true;
}
});
break;
case 'video': //视频文件
if(!RegExp('\\w\\.('+ (exts || 'avi|mp4|wma|rmvb|rm|flash|3gp|flv') +')$', 'i').test(escape(value))){
that.msg('选择的视频中包含不支持的格式');
return elemFile.value = '';
}
layui.each(value, function(i, item){
if(!RegExp('.\\.('+ (exts || 'avi|mp4|wma|rmvb|rm|flash|3gp|flv') +')$', 'i').test(escape(item))){
return check = true;
}
});
break;
case 'audio': //音频文件
if(!RegExp('\\w\\.('+ (exts || 'mp3|wav|mid') +')$', 'i').test(escape(value))){
that.msg('选择的音频中包含不支持的格式');
return elemFile.value = '';
}
layui.each(value, function(i, item){
if(!RegExp('.\\.('+ (exts || 'mp3|wav|mid') +')$', 'i').test(escape(item))){
return check = true;
}
});
break;
default: //图片文件
layui.each(value, function(i, item){
if(!RegExp('\\w\\.('+ (exts || 'jpg|png|gif|bmp|jpeg$') +')', 'i').test(escape(item))){
check = true;
if(!RegExp('.\\.('+ (exts || 'jpg|png|gif|bmp|jpeg') +')$', 'i').test(escape(item))){
return check = true;
}
});
if(check){
that.msg('选择的图片中包含不支持的格式');
return elemFile.value = '';
}
break;
}
//校验失败提示
if(check){
that.msg('选择的'+ typeName +'中包含不支持的格式');
return elemFile.value = '';
}
//检验文件数量
that.fileLength = function(){
var length = 0
@@ -401,8 +419,9 @@ layui.define('layer' , function(exports){
});
return length;
}();
if(options.number && that.fileLength > options.number){
return that.msg('同时最多只能上传的数量为:'+ options.number);
return that.msg('同时最多只能选择 '+ options.number + ' 个文件');
}
//检验文件大小
@@ -417,7 +436,7 @@ layui.define('layer' , function(exports){
limitSize = size;
}
});
if(limitSize) return that.msg('文件不能超过'+ limitSize);
if(limitSize) return that.msg('文件大小不能超过 '+ limitSize);
}
send();
};

View File

@@ -1,7 +1,6 @@
/*!
/**
* util 工具组件
*/
*/
layui.define('jquery', function(exports){
"use strict";
@@ -172,14 +171,18 @@ layui.define('jquery', function(exports){
//转义 html防 xss 攻击
,escape: function(html){
return String(html || '').replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&amp;')
if(html === undefined || html === null) html = '';
html += '';
return html.replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&amp;')
.replace(/</g, '&lt;').replace(/>/g, '&gt;')
.replace(/'/g, '&#39;').replace(/"/g, '&quot;');
}
//还原转义的 html
,unescape: function(str){
return String(str || '').replace(/\&amp;/g, '&')
if(html === undefined || html === null) html = '';
html += '';
return html.replace(/\&amp;/g, '&')
.replace(/\&lt;/g, '<').replace(/\&gt;/g, '>')
.replace(/\&#39;/, '\'').replace(/\&quot;/, '"');
}
@@ -237,6 +240,8 @@ layui.define('jquery', function(exports){
return obj;
}
};
util.on = util.event;
// DOM 尺寸变化该创意来自http://benalman.com/projects/jquery-resize-plugin/
/*