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