mirror of https://github.com/layui/layui
Merge branch 'layui:main' into main
commit
a4db9ea267
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "layui",
|
||||
"version": "2.8.0-rc.1",
|
||||
"version": "2.8.0-rc.2",
|
||||
"description": "Classic modular Front-End UI library",
|
||||
"main": "dist/layui.js",
|
||||
"license": "MIT",
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
}
|
||||
|
||||
,Layui = function(){
|
||||
this.v = '2.8.0-rc.1'; // Layui 版本号
|
||||
this.v = '2.8.0-rc.2'; // Layui 版本号
|
||||
}
|
||||
|
||||
//识别预先可能定义的指定全局对象
|
||||
|
|
|
@ -208,11 +208,15 @@
|
|||
|
||||
var othis = lay(elem);
|
||||
var attrName = opts.attr || 'lay-options';
|
||||
var attrValue = othis.attr(attrName);
|
||||
|
||||
try {
|
||||
return new Function('return '+ (othis.attr(attrName) || '{}'))();
|
||||
return new Function('return '+ (attrValue || '{}'))();
|
||||
} catch(ev) {
|
||||
hint.error(opts.errorText || 'parseerror: '+ ev, 'error');
|
||||
layui.hint().error(opts.errorText || [
|
||||
attrName + '="'+ attrValue + '"',
|
||||
'\n parseerror: '+ ev
|
||||
].join('\n'), 'error');
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
|
|
@ -48,7 +48,7 @@ var isLayui = window.layui && layui.define, $, win, ready = {
|
|||
|
||||
var app = (cssname || href).replace(/\.|\//g, '');
|
||||
var id = 'layuicss-'+ app
|
||||
,STAUTS_NAME = 'creating'
|
||||
,STATUS_NAME = 'creating'
|
||||
,timeout = 0;
|
||||
|
||||
link.rel = 'stylesheet';
|
||||
|
@ -74,13 +74,13 @@ var isLayui = window.layui && layui.define, $, win, ready = {
|
|||
//css 加载就绪
|
||||
if(parseInt(ready.getStyle(getLinkElem, 'width')) === 1989){
|
||||
//如果参数来自于初始轮询(即未加载就绪时的),则移除 link 标签状态
|
||||
if(status === STAUTS_NAME) getLinkElem.removeAttribute('lay-status');
|
||||
if(status === STATUS_NAME) getLinkElem.removeAttribute('lay-status');
|
||||
//如果 link 标签的状态仍为「创建中」,则继续进入轮询,直到状态改变,则执行回调
|
||||
getLinkElem.getAttribute('lay-status') === STAUTS_NAME ? setTimeout(poll, delay) : fn();
|
||||
getLinkElem.getAttribute('lay-status') === STATUS_NAME ? setTimeout(poll, delay) : fn();
|
||||
} else {
|
||||
getLinkElem.setAttribute('lay-status', STAUTS_NAME);
|
||||
getLinkElem.setAttribute('lay-status', STATUS_NAME);
|
||||
setTimeout(function(){
|
||||
poll(STAUTS_NAME);
|
||||
poll(STATUS_NAME);
|
||||
}, delay);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,12 +3,11 @@
|
|||
* 上传组件
|
||||
*/
|
||||
|
||||
layui.define('layer' , function(exports){
|
||||
layui.define(['lay','layer'], function(exports){
|
||||
"use strict";
|
||||
|
||||
var $ = layui.$
|
||||
,layer = layui.layer
|
||||
,hint = layui.hint()
|
||||
,device = layui.device()
|
||||
|
||||
//外部接口
|
||||
|
@ -466,20 +465,20 @@ layui.define('layer' , function(exports){
|
|||
|
||||
//事件处理
|
||||
Class.prototype.events = function(){
|
||||
var that = this
|
||||
,options = that.config
|
||||
var that = this;
|
||||
var options = that.config;
|
||||
|
||||
//设置当前选择的文件队列
|
||||
,setChooseFile = function(files){
|
||||
// 设置当前选择的文件队列
|
||||
var setChooseFile = function(files){
|
||||
that.chooseFiles = {};
|
||||
layui.each(files, function(i, item){
|
||||
var time = new Date().getTime();
|
||||
that.chooseFiles[time + '-' + i] = item;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
//设置选择的文本
|
||||
,setChooseText = function(files, filename){
|
||||
// 设置选择的文本
|
||||
var setChooseText = function(files, filename){
|
||||
var elemFile = that.elemFile
|
||||
,item = options.item ? options.item : options.elem
|
||||
,value = files.length > 1
|
||||
|
@ -494,19 +493,23 @@ layui.define('layer' , function(exports){
|
|||
elemFile.after('<span class="layui-inline '+ ELEM_CHOOSE +'">'+ value +'</span>');
|
||||
};
|
||||
|
||||
// 合并 lay-options/lay-data 属性配置项
|
||||
var extendAttrs = function(){
|
||||
var othis = $(this);
|
||||
var data = othis.attr('lay-data') || othis.attr('lay-options'); // 优先兼容旧版本
|
||||
|
||||
if(data){
|
||||
that.config = $.extend({}, options, lay.options(this, {
|
||||
attr: othis.attr('lay-data') ? 'lay-data' : null
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
//点击上传容器
|
||||
options.elem.off('upload.start').on('upload.start', function(){
|
||||
var othis = $(this), data = othis.attr('lay-data');
|
||||
|
||||
if(data){
|
||||
try{
|
||||
data = new Function('return '+ data)();
|
||||
that.config = $.extend({}, options, data);
|
||||
} catch(e){
|
||||
hint.error('Upload element property lay-data configuration item has a syntax error: ' + data)
|
||||
}
|
||||
}
|
||||
|
||||
var othis = $(this);
|
||||
|
||||
extendAttrs.call(this);
|
||||
that.config.item = othis;
|
||||
that.elemFile[0].click();
|
||||
});
|
||||
|
@ -522,9 +525,11 @@ layui.define('layer' , function(exports){
|
|||
othis.removeAttr('lay-over');
|
||||
})
|
||||
.off('upload.drop').on('upload.drop', function(e, param){
|
||||
var othis = $(this), files = param.originalEvent.dataTransfer.files || [];
|
||||
var othis = $(this);
|
||||
var files = param.originalEvent.dataTransfer.files || [];
|
||||
|
||||
othis.removeAttr('lay-over');
|
||||
extendAttrs.call(this);
|
||||
setChooseFile(files);
|
||||
|
||||
options.auto ? that.upload() : setChooseText(files); //是否自动触发上传
|
||||
|
@ -534,6 +539,8 @@ layui.define('layer' , function(exports){
|
|||
//文件选择
|
||||
that.elemFile.off('upload.change').on('upload.change', function(){
|
||||
var files = this.files || [];
|
||||
|
||||
extendAttrs.call(this);
|
||||
setChooseFile(files);
|
||||
options.auto ? that.upload() : setChooseText(files); //是否自动触发上传
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue