diff --git a/examples/dropdown.html b/examples/dropdown.html index 18203d6b..2af245ca 100644 --- a/examples/dropdown.html +++ b/examples/dropdown.html @@ -42,6 +42,7 @@ layui.use('dropdown', function(){ dropdown.render({ elem: '#demo1' + ,shade: [0.1, '#ddd'] //,align: 'right' ,data: [{ title: 'menu item 1' diff --git a/examples/laydate.html b/examples/laydate.html index 1190757d..b94d5a3f 100644 --- a/examples/laydate.html +++ b/examples/laydate.html @@ -152,6 +152,7 @@ layui.use('laydate', function(laydate){ laydate.render({ elem: '#test-first', min: 0, + shade: [0.1, '#ddd'] //max: '2016-12-30' }); diff --git a/src/css/layui.css b/src/css/layui.css index 40265bf3..9aee3908 100644 --- a/src/css/layui.css +++ b/src/css/layui.css @@ -1146,7 +1146,7 @@ body .layui-table-tips .layui-layer-content{background: none; padding: 0; box-sh /* 下拉菜单 */ .layui-dropdown{position: absolute; left: -999999px; top: -999999px; z-index: 77777777; margin: 5px 0; min-width: 100px;} .layui-dropdown:before{content:""; position: absolute; width: 100%; height: 6px; left: 0; top: -6px;} - +.layui-dropdown-shade{top: 0; left: 0; width: 100%; height: 100%; _height: expression(document.body.offsetHeight+"px"); position: fixed; _position: absolute; pointer-events: auto;} /** 导航菜单 **/ .layui-nav{position: relative; padding: 0 20px; background-color: #393D49; color: #fff; border-radius: 2px; font-size: 0; box-sizing: border-box;} diff --git a/src/css/modules/laydate.css b/src/css/modules/laydate.css index 022b063e..46cce051 100644 --- a/src/css/modules/laydate.css +++ b/src/css/modules/laydate.css @@ -17,6 +17,7 @@ html #layuicss-laydate{display: none; position: absolute; width: 1989px;} .layui-laydate-header *, .layui-laydate-content td, .layui-laydate-list li{transition-duration: .3s; -webkit-transition-duration: .3s;} +.layui-laydate-shade{top: 0; left: 0; width: 100%; height: 100%; _height: expression(document.body.offsetHeight+"px"); position: fixed; _position: absolute; pointer-events: auto;} /* 微微往下滑入 */ @keyframes laydate-downbit { diff --git a/src/modules/dropdown.js b/src/modules/dropdown.js index 617fa82a..47460f56 100644 --- a/src/modules/dropdown.js +++ b/src/modules/dropdown.js @@ -56,7 +56,7 @@ layui.define(['jquery', 'laytpl', 'lay'], function(exports){ //字符常量 ,STR_ELEM = 'layui-dropdown', STR_HIDE = 'layui-hide', STR_DISABLED = 'layui-disabled', STR_NONE = 'layui-none' - ,STR_ITEM_UP = 'layui-menu-item-up', STR_ITEM_DOWN = 'layui-menu-item-down', STR_MENU_TITLE = 'layui-menu-body-title', STR_ITEM_GROUP = 'layui-menu-item-group', STR_ITEM_PARENT = 'layui-menu-item-parent', STR_ITEM_DIV = 'layui-menu-item-divider', STR_ITEM_CHECKED = 'layui-menu-item-checked', STR_ITEM_CHECKED2 = 'layui-menu-item-checked2', STR_MENU_PANEL = 'layui-menu-body-panel', STR_MENU_PANEL_L = 'layui-menu-body-panel-left' + ,STR_ITEM_UP = 'layui-menu-item-up', STR_ITEM_DOWN = 'layui-menu-item-down', STR_MENU_TITLE = 'layui-menu-body-title', STR_ITEM_GROUP = 'layui-menu-item-group', STR_ITEM_PARENT = 'layui-menu-item-parent', STR_ITEM_DIV = 'layui-menu-item-divider', STR_ITEM_CHECKED = 'layui-menu-item-checked', STR_ITEM_CHECKED2 = 'layui-menu-item-checked2', STR_MENU_PANEL = 'layui-menu-body-panel', STR_MENU_PANEL_L = 'layui-menu-body-panel-left', STR_ELEM_SHADE = 'layui-dropdown-shade' ,STR_GROUP_TITLE = '.'+ STR_ITEM_GROUP + '>.'+ STR_MENU_TITLE @@ -79,6 +79,7 @@ layui.define(['jquery', 'laytpl', 'lay'], function(exports){ ,isSpreadItem: true //是否初始展开子菜单 ,data: [] //菜单数据结构 ,delay: 300 //延迟关闭的毫秒数,若 trigger 为 hover 时才生效 + ,shade: 0 // 遮罩 }; //重载实例 @@ -251,6 +252,10 @@ layui.define(['jquery', 'laytpl', 'lay'], function(exports){ that.remove(); //移除非当前绑定元素的面板 elemBody.append(that.elemView); options.elem.data(MOD_INDEX +'_opened', true); + + //遮罩 + var shade = options.shade ? ('
') : ''; + that.elemView.before(shade); //坐标定位 that.position(); @@ -324,6 +329,7 @@ layui.define(['jquery', 'laytpl', 'lay'], function(exports){ ); elemPrev.remove(); } + lay('.' + STR_ELEM_SHADE).remove(); }; //延迟删除视图 diff --git a/src/modules/laydate.js b/src/modules/laydate.js index fdf6f9ca..3cac3a65 100644 --- a/src/modules/laydate.js +++ b/src/modules/laydate.js @@ -94,6 +94,7 @@ var ELEM_TIME_BTN = 'laydate-btns-time'; var ELEM_PREVIEW = 'layui-laydate-preview'; var ELEM_MAIN = 'layui-laydate-main'; + var ELEM_SHADE = 'layui-laydate-shade'; // 组件构造器 var Class = function(options){ @@ -163,6 +164,7 @@ ,done: null //控件选择完毕后的回调,点击清空/现在/确定也均会触发 ,change: null //日期时间改变后的回调 ,autoConfirm: true //是否自动确认(日期|年份|月份选择器非range下是否自动确认) + ,shade: 0 }; //多语言 @@ -641,6 +643,9 @@ ,that.position() //定位 ); + var shade = options.shade ? ('
') : ''; + elem.insertAdjacentHTML('beforebegin', shade); + that.checkDate().calendar(null, 0, 'init'); //初始校验 that.changeEvent(); //日期切换 @@ -670,6 +675,7 @@ typeof options.close === 'function' && options.close(that); }); } + lay('.' + ELEM_SHADE).remove(); return that; }; @@ -1409,7 +1415,7 @@ setTimeStatus(); scroll(); - (that.endDate || options.type === 'time') && that.done(null, 'change'); + (that.endDate || options.type === 'time' || (options.type === 'datetime' && options.fullPanel)) && that.done(null, 'change'); //同步按钮可点状态 that.setBtnStatus(); diff --git a/src/modules/layer.js b/src/modules/layer.js index d900a733..f455483b 100644 --- a/src/modules/layer.js +++ b/src/modules/layer.js @@ -902,8 +902,8 @@ Class.pt.openLayer = function(){ //记录宽高坐标,用于还原 ready.record = function(layero){ var area = [ - layero.width(), - layero.height(), + layero[0].style.width || layero.width(), + layero[0].style.height || layero.height(), layero.position().top, layero.position().left + parseFloat(layero.css('margin-left')) ]; @@ -981,11 +981,11 @@ layer.style = function(index, options, limit){ if(type === ready.type[2]){ layero.find('iframe').css({ - height: parseFloat(options.height) - titHeight - btnHeight + height: (typeof options.height === 'number' ? options.height : layero.height()) - titHeight - btnHeight }); } else { contElem.css({ - height: parseFloat(options.height) - titHeight - btnHeight + height: (typeof options.height === 'number' ? options.height : layero.height()) - titHeight - btnHeight - parseFloat(contElem.css('padding-top')) - parseFloat(contElem.css('padding-bottom')) }) @@ -1058,9 +1058,9 @@ layer.restore = function(index){ //恢复原来尺寸 layer.style(index, { - width: parseFloat(area[0]), - height: parseFloat(area[1]), - top: parseFloat(area[2]), + width: area[0], // 数值或百分比 + height: area[1], + top: parseFloat(area[2]), left: parseFloat(area[3]), position: layero.attr('position'), overflow: 'visible' diff --git a/src/modules/table.js b/src/modules/table.js index f01df71b..74f15f33 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -1363,7 +1363,8 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ tds.push(td); }); - that.layTotal.find('tbody').html('' + tds.join('') + ''); + var patchElem = that.layTotal.find('.layui-table-patch'); // 可能存在滚动条补丁 + that.layTotal.find('tbody').html('' + tds.join('') + (patchElem.length ? patchElem.get(0).outerHTML : '') + ''); }; //找到对应的列元素 diff --git a/src/modules/upload.js b/src/modules/upload.js index 2f0cc614..0f106957 100644 --- a/src/modules/upload.js +++ b/src/modules/upload.js @@ -194,14 +194,15 @@ layui.define('layer' , function(exports){ layui.each(items, function(index, file){ var formData = new FormData(); - formData.append(options.field, file); - //追加额外的参数 layui.each(options.data, function(key, value){ value = typeof value === 'function' ? value() : value; formData.append(key, value); }); + //最后添加 file 到表单域 + formData.append(options.field, file); + //提交文件 var opts = { url: options.url