commit
0991560df5
2
dist/layui.js
vendored
2
dist/layui.js
vendored
File diff suppressed because one or more lines are too long
@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
@ -18,12 +16,31 @@ body{padding: 50px 100px;}
|
||||
</head>
|
||||
<body>
|
||||
|
||||
日期时间范围选择:
|
||||
范围选择1:
|
||||
<div class="layui-inline">
|
||||
<input type="text" class="layui-input" id="test1">
|
||||
</div>
|
||||
|
||||
<br><br><hr><br>
|
||||
<br><hr>
|
||||
|
||||
<div class="layui-form">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">范围选择2</label>
|
||||
<div class="layui-inline" id="test1-2">
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" autocomplete="off" id="test-startDate-1" class="layui-input" placeholder="开始日期">
|
||||
</div>
|
||||
<div class="layui-form-mid">-</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" autocomplete="off" id="test-endDate-1" class="layui-input" placeholder="结束日期">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br><hr>
|
||||
|
||||
日期选择器:
|
||||
<div class="layui-inline">
|
||||
@ -118,7 +135,7 @@ layui.use('laydate', function(laydate){
|
||||
//trigger: 'focus'
|
||||
})
|
||||
|
||||
//双控件
|
||||
//范围选择1
|
||||
laydate.render({
|
||||
elem: '#test1' //指定元素
|
||||
,type: 'datetime'
|
||||
@ -141,6 +158,16 @@ layui.use('laydate', function(laydate){
|
||||
});
|
||||
|
||||
//return;
|
||||
|
||||
//范围选择2
|
||||
laydate.render({
|
||||
elem: '#test1-2'
|
||||
,type: 'date'
|
||||
,range: ['#test-startDate-1', '#test-endDate-1']
|
||||
//,value: ['2022-05-01', '2022-06-01']
|
||||
//,value: '2022-05-01 - 2022-06-01'
|
||||
});
|
||||
|
||||
|
||||
//单控件
|
||||
laydate.render({
|
||||
|
@ -23,7 +23,7 @@ var config = {
|
||||
,{pkg: pkg, js: ';'}
|
||||
]
|
||||
//模块
|
||||
,modules: 'lay,laytpl,laypage,laydate,jquery,layer,util,dropdown,slider,colorpicker,element,upload,form,table,tree,transfer,carousel,rate,flow,code'
|
||||
,modules: 'lay,laytpl,laypage,laydate,jquery,layer,util,dropdown,slider,colorpicker,element,upload,form,table,tree,transfer,carousel,rate,flow,layedit,code'
|
||||
};
|
||||
|
||||
//获取参数
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "layui",
|
||||
"realname": "layui",
|
||||
"version": "2.6.9",
|
||||
"version": "2.6.10",
|
||||
"description": "Classic modular Front-End UI library",
|
||||
"main": "dist/layui.js",
|
||||
"license": "MIT",
|
||||
|
@ -15,7 +15,7 @@
|
||||
}
|
||||
|
||||
,Layui = function(){
|
||||
this.v = '2.6.9'; // layui 版本号
|
||||
this.v = '2.6.10'; // layui 版本号
|
||||
}
|
||||
|
||||
//识别预先可能定义的指定全局对象
|
||||
|
@ -91,14 +91,16 @@
|
||||
|
||||
|
||||
//数字前置补零
|
||||
lay.digit = function(num, length, end){
|
||||
lay.digit = function(num, length){
|
||||
if(!(typeof num === 'string' || typeof num === 'number')) return '';
|
||||
|
||||
var str = '';
|
||||
num = String(num);
|
||||
length = length || 2;
|
||||
for(var i = num.length; i < length; i++){
|
||||
str += '0';
|
||||
}
|
||||
return num < Math.pow(10, length) ? str + (num|0) : num;
|
||||
return num < Math.pow(10, length) ? str + num : num;
|
||||
};
|
||||
|
||||
//创建元素
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
/** layDate 日期与时间控件 | MIT Licensed */
|
||||
|
||||
;!function(window, document){
|
||||
@ -189,7 +188,9 @@
|
||||
if(!options.elem[0]) return;
|
||||
|
||||
//日期范围分隔符
|
||||
that.rangeStr = options.range ? (typeof options.range === 'string' ? options.range : '-') : '';
|
||||
that.rangeStr = options.range ? (
|
||||
typeof options.range === 'string' ? options.range : '-'
|
||||
) : '';
|
||||
|
||||
//若 range 参数为数组,则表示为开始日期和结束日期的 input 对象
|
||||
if(layui.type(options.range) === 'array'){
|
||||
@ -240,7 +241,7 @@
|
||||
) +'$');
|
||||
that.EXP_SPLIT = new RegExp('^'+ that.EXP_SPLIT +'$', '');
|
||||
|
||||
//如果不是input|textarea元素,则默认采用click事件
|
||||
//如果不是 input|textarea 元素,则默认采用 click 事件
|
||||
if(!that.isInput(options.elem[0])){
|
||||
if(options.trigger === 'focus'){
|
||||
options.trigger = 'click';
|
||||
@ -593,11 +594,14 @@
|
||||
//如果传入了开始和结束日期的 input 对象,则将其拼接为日期范围字符
|
||||
if(that.rangeElem){
|
||||
var vals = [that.rangeElem[0].val(), that.rangeElem[1].val()];
|
||||
|
||||
if(vals[0] && vals[1]){
|
||||
return vals.join(' ' + that.rangeStr + ' ');
|
||||
}
|
||||
}
|
||||
return that.isInput(elem) ? elem.value : (options.position === 'static' ? '' : lay(elem).attr('lay-date'));
|
||||
return that.isInput(elem)
|
||||
? elem.value
|
||||
: (options.position === 'static' ? '' : lay(elem).attr('lay-date'));
|
||||
}()
|
||||
|
||||
//校验日期有效数字
|
||||
@ -703,7 +707,7 @@
|
||||
) + lang.formatError[1]);
|
||||
error = true;
|
||||
}
|
||||
} else if(value && layui.type(value) === 'date'){ //如果值为日期对象时
|
||||
} else if(value && layui.type(value) === 'date'){ //若值为日期对象
|
||||
options.dateTime = that.systemDate(value);
|
||||
} else {
|
||||
//重置开始日期
|
||||
@ -1189,14 +1193,18 @@
|
||||
,options = that.config
|
||||
,dateTime = date || (state == 'end'
|
||||
? lay.extend({}, that.endDate, that.endTime)
|
||||
: (options.range ? lay.extend({}, options.dateTime, that.startTime) : options.dateTime))
|
||||
: (
|
||||
options.range
|
||||
? lay.extend({}, options.dateTime, that.startTime)
|
||||
: options.dateTime)
|
||||
)
|
||||
,format = laydate.parse(dateTime, that.format, 1);
|
||||
|
||||
//返回日期范围字符
|
||||
if(options.range && state === undefined){
|
||||
return format + ' '+ that.rangeStr +' ' + that.parse('end');
|
||||
}
|
||||
|
||||
|
||||
return format;
|
||||
};
|
||||
|
||||
@ -1229,9 +1237,13 @@
|
||||
lay(elem).val(value);
|
||||
} else {
|
||||
//如果 range 传入了开始和结束的 input 对象,则分别对其赋值
|
||||
if(that.rangeElem){
|
||||
that.rangeElem[0].val(value ? that.parse('start') : '');
|
||||
that.rangeElem[1].val(value ? that.parse('end') : '');
|
||||
var rangeElem = that.rangeElem;
|
||||
if(rangeElem){
|
||||
if(layui.type(value) !== 'array'){
|
||||
value = value.split(' '+ that.rangeStr +' ');
|
||||
}
|
||||
rangeElem[0].val(value[0] || '');
|
||||
rangeElem[1].val(value[1] || '');
|
||||
} else {
|
||||
if(lay(elem).find('*').length === 0){
|
||||
lay(elem).html(value);
|
||||
|
@ -179,7 +179,7 @@ layui.define('jquery', function(exports){
|
||||
}
|
||||
|
||||
//还原转义的 html
|
||||
,unescape: function(str){
|
||||
,unescape: function(html){
|
||||
if(html === undefined || html === null) html = '';
|
||||
html += '';
|
||||
return html.replace(/\&/g, '&')
|
||||
|
Loading…
Reference in New Issue
Block a user