发版
This commit is contained in:
@@ -166,9 +166,10 @@ layui.define('layer', function(exports){
|
||||
if(choose) return;
|
||||
|
||||
notOption(input.val(), function(none){
|
||||
var selectedIndex = select[0].selectedIndex;
|
||||
if(none){
|
||||
initValue = dl.find('.'+THIS).html();
|
||||
input && input.val(initValue);
|
||||
initValue = $(select[0].options[selectedIndex]).html(); //重新获得初始选中值
|
||||
initValue || input.val(''); //none && !initValue
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -418,6 +419,7 @@ layui.define('layer', function(exports){
|
||||
events.call(this, reElem, disabled, isSearch);
|
||||
});
|
||||
}
|
||||
|
||||
//复选框/开关
|
||||
,checkbox: function(){
|
||||
var CLASS = {
|
||||
@@ -489,6 +491,7 @@ layui.define('layer', function(exports){
|
||||
events.call(this, reElem, RE_CLASS);
|
||||
});
|
||||
}
|
||||
|
||||
//单选框
|
||||
,radio: function(){
|
||||
var CLASS = 'layui-form-radio', ICON = ['', '']
|
||||
|
||||
@@ -72,9 +72,14 @@ layui.define('jquery', function(exports){
|
||||
Class.prototype.render = function(){
|
||||
var that = this
|
||||
,options = that.config;
|
||||
|
||||
//最小值为零
|
||||
options.min = options.min < 0 ? 0 : options.min;
|
||||
|
||||
//间隔值不能小于 1
|
||||
if(options.step < 1) options.step = 1;
|
||||
|
||||
//最大值不能小于最小值
|
||||
if(options.max < options.min) options.max = options.min + options.step;
|
||||
|
||||
|
||||
|
||||
//判断是否开启双滑块
|
||||
if(options.range){
|
||||
@@ -85,16 +90,25 @@ layui.define('jquery', function(exports){
|
||||
options.value[1] = maxValue > options.min ? maxValue : options.min;
|
||||
options.value[0] = options.value[0] > options.max ? options.max : options.value[0];
|
||||
options.value[1] = options.value[1] > options.max ? options.max : options.value[1];
|
||||
|
||||
var scaleFir = Math.floor((options.value[0] - options.min) / (options.max - options.min) * 100)
|
||||
,scaleSec = Math.floor((options.value[1] - options.min) / (options.max - options.min) * 100)
|
||||
,scale = scaleSec - scaleFir + '%';
|
||||
scaleFir = scaleFir + '%';
|
||||
scaleSec = scaleSec + '%';
|
||||
}else{
|
||||
options.value = typeof(options.value) == 'object' ? Math.min(options.value[0], options.value[1]) : options.value;
|
||||
options.value = options.value > options.min ? options.value : options.min;
|
||||
} else {
|
||||
//如果初始值是一个数组,则获取数组的最小值
|
||||
if(typeof options.value == 'object'){
|
||||
options.value = Math.min.apply(null, options.value);
|
||||
}
|
||||
|
||||
//初始值不能小于最小值且不能大于最大值
|
||||
if(options.value < options.min) options.value = options.min;
|
||||
if(options.value > options.max) options.value = options.max;
|
||||
|
||||
var scale = Math.floor((options.value - options.min) / (options.max - options.min) * 100) + '%';
|
||||
};
|
||||
|
||||
|
||||
//如果禁用,颜色为统一的灰色
|
||||
var theme = options.disabled ? '#c2c2c2' : options.theme;
|
||||
@@ -297,6 +311,7 @@ layui.define('jquery', function(exports){
|
||||
});
|
||||
});
|
||||
|
||||
//点击滑块
|
||||
sliderAct.on('click', function(e){
|
||||
var main = $('.' + SLIDER_WRAP_BTN);
|
||||
if(!main.is(event.target) && main.has(event.target).length === 0 && main.length){
|
||||
@@ -318,7 +333,7 @@ layui.define('jquery', function(exports){
|
||||
}
|
||||
});
|
||||
|
||||
//输入框
|
||||
//输入框移入事件
|
||||
sliderTxt.hover(function(){
|
||||
var othis = $(this);
|
||||
othis.children('.' + SLIDER_INPUT_BTN).fadeIn('fast');
|
||||
@@ -327,12 +342,17 @@ layui.define('jquery', function(exports){
|
||||
othis.children('.' + SLIDER_INPUT_BTN).fadeOut('fast');
|
||||
});
|
||||
|
||||
//点击加减输入框
|
||||
sliderTxt.children('.' + SLIDER_INPUT_BTN).children('i').each(function(index){
|
||||
$(this).on('click', function(){
|
||||
if(index == 1){
|
||||
inputValue = inputValue - step < options.min ? options.min : inputValue - step;
|
||||
inputValue = inputValue - options.step < options.min
|
||||
? options.min
|
||||
: Number(inputValue) - options.step;
|
||||
}else{
|
||||
inputValue = Number(inputValue) + step > options.max ? options.max : Number(inputValue) + step;
|
||||
inputValue = Number(inputValue) + options.step > options.max
|
||||
? options.max
|
||||
: Number(inputValue) + options.step;
|
||||
};
|
||||
var inputScale = (inputValue - options.min) / (options.max - options.min) * 100 / step;
|
||||
change(inputScale, 0);
|
||||
|
||||
@@ -420,7 +420,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
|
||||
if(options.toolbar === 'default'){
|
||||
elemToolTemp.html(leftDefaultTemp);
|
||||
} else if(options.toolbar){
|
||||
} else if(typeof options.toolbar === 'string'){
|
||||
var toolbarHtml = $(options.toolbar).html() || '';
|
||||
toolbarHtml && elemToolTemp.html(
|
||||
laytpl(toolbarHtml).render(options)
|
||||
@@ -621,8 +621,9 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
Class.prototype.resize = function(){
|
||||
var that = this;
|
||||
that.fullSize(); //让表格铺满
|
||||
that.scrollPatch(); //滚动条补丁
|
||||
that.setColsWidth(); //自适应列宽
|
||||
that.scrollPatch(); //滚动条补丁
|
||||
|
||||
};
|
||||
|
||||
//表格完整重载
|
||||
@@ -827,13 +828,11 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
typeof thisCheckedRowIndex === 'number' && that.setThisRowChecked(thisCheckedRowIndex);
|
||||
that.syncCheckAll();
|
||||
|
||||
that.scrollPatch();
|
||||
/*
|
||||
//滚动条补丁
|
||||
that.haveInit ? that.scrollPatch() : setTimeout(function(){
|
||||
that.scrollPatch();
|
||||
}, 50);
|
||||
that.haveInit = true;
|
||||
*/
|
||||
|
||||
layer.close(that.tipsIndex);
|
||||
|
||||
@@ -1194,7 +1193,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
//固定列区域高度
|
||||
var mainHeight = that.layMain.height()
|
||||
,fixHeight = mainHeight - scollHeight;
|
||||
that.layFixed.find(ELEM_BODY).css('height', layMainTable.height() > fixHeight ? fixHeight : 'auto');
|
||||
that.layFixed.find(ELEM_BODY).css('height', layMainTable.height() >= fixHeight ? fixHeight : 'auto');
|
||||
|
||||
//表格宽度小于容器宽度时,隐藏固定列
|
||||
that.layFixRight[outWidth > 0 ? 'removeClass' : 'addClass'](HIDE);
|
||||
@@ -1468,7 +1467,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
,index = checkbox.parents('tr').eq(0).data('index')
|
||||
,checked = checkbox[0].checked
|
||||
,isAll = checkbox.attr('lay-filter') === 'layTableAllChoose';
|
||||
|
||||
|
||||
//全选
|
||||
if(isAll){
|
||||
childs.each(function(i, item){
|
||||
@@ -1481,7 +1480,8 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
that.setCheckData(index, checked);
|
||||
that.syncCheckAll();
|
||||
}
|
||||
layui.event.call(this, MOD_NAME, 'checkbox('+ filter +')', commonMember.call(this, {
|
||||
|
||||
layui.event.call(checkbox[0], MOD_NAME, 'checkbox('+ filter +')', commonMember.call(checkbox[0], {
|
||||
checked: checked
|
||||
,type: isAll ? 'all' : 'one'
|
||||
}));
|
||||
@@ -1492,7 +1492,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
var radio = $(this).prev()
|
||||
,checked = radio[0].checked
|
||||
,thisData = table.cache[that.key]
|
||||
,index = radio.parents('tr').eq(0).data('index')
|
||||
,index = radio.parents('tr').eq(0).data('index');
|
||||
|
||||
//重置数据单选属性
|
||||
layui.each(thisData, function(i, item){
|
||||
@@ -1570,7 +1570,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
});
|
||||
|
||||
//单元格单击事件
|
||||
that.layBody.on('click', 'td', function(){
|
||||
that.layBody.on('click', 'td', function(e){
|
||||
var othis = $(this)
|
||||
,field = othis.data('field')
|
||||
,editType = othis.data('edit')
|
||||
@@ -1584,6 +1584,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
input[0].value = othis.data('content') || elemCell.text();
|
||||
othis.find('.'+ELEM_EDIT)[0] || othis.append(input);
|
||||
input.focus();
|
||||
layui.stope(e);
|
||||
return;
|
||||
}
|
||||
}).on('mouseenter', 'td', function(){
|
||||
@@ -1607,11 +1608,11 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
};
|
||||
|
||||
//单元格展开事件
|
||||
that.layBody.on('click', '.'+ ELEM_GRID_DOWN, function(){
|
||||
that.layBody.on('click', '.'+ ELEM_GRID_DOWN, function(e){
|
||||
var othis = $(this)
|
||||
,td = othis.parent()
|
||||
,elemCell = td.children(ELEM_CELL);
|
||||
|
||||
|
||||
that.tipsIndex = layer.tips([
|
||||
'<div class="layui-table-tips-main" style="margin-top: -'+ (elemCell.height() + 16) +'px;'+ function(){
|
||||
if(options.size === 'sm'){
|
||||
@@ -1638,6 +1639,8 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
layui.stope(e);
|
||||
});
|
||||
|
||||
//行工具条操作事件
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
}
|
||||
|
||||
,Layui = function(){
|
||||
this.v = '2.4.4'; //版本号
|
||||
this.v = '2.4.5'; //版本号
|
||||
}
|
||||
|
||||
//获取layui所在目录
|
||||
@@ -535,7 +535,7 @@
|
||||
|
||||
//执行指定事件
|
||||
key === '' && layui.each(item, callback);
|
||||
key === filterName && layui.each(item, callback);
|
||||
(filterName && key === filterName) && layui.each(item, callback);
|
||||
});
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user