diff --git a/bower.json b/bower.json index b1cfd00..5a49e81 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "layui", "main": "src/layui.js", - "version": "2.3.0-rc1", + "version": "2.3.0", "homepage": "https://github.com/sentsin/layui", "authors": [ "sentsin " diff --git a/examples/form.html b/examples/form.html index c639c28..6de1caf 100644 --- a/examples/form.html +++ b/examples/form.html @@ -108,6 +108,14 @@ body{padding: 10px;} + + + + + + + + @@ -190,6 +198,10 @@ layui.use('form', function(){ } } ,pass: [/(.+){6,12}$/, '密码必须6到12位'] + ,money: [ + /^\d+\.\b\d{2}\b$/ + ,'金额必须为小数保留两位' + ] }); //初始赋值 @@ -256,6 +268,27 @@ layui.use('form', function(){ + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/table.html b/examples/table.html index 43c2c3c..de1a86a 100644 --- a/examples/table.html +++ b/examples/table.html @@ -15,8 +15,6 @@ body{padding: 20px; /*overflow-y: scroll;*/} -
-
@@ -46,6 +44,7 @@ body{padding: 20px; /*overflow-y: scroll;*/} {{ d.email }} +
@@ -180,6 +179,7 @@ layui.use('table', function(){ elem: '#test' ,height: 350 ,url: 'json/table/demo1.json' + //,size: 'sm' ,page: { } diff --git a/examples/upload.html b/examples/upload.html index 673eba4..e895df6 100644 --- a/examples/upload.html +++ b/examples/upload.html @@ -93,6 +93,15 @@ layui.use('upload', function(){ ,accept: 'file' ,fileAccept: 'image/*' ,exts: "jpg|png|gif|bmp|jpeg|pdf" + ,data: { //额外参数 + a: 1 + ,b: function(){ + return 2 + } + } + ,choose: function(){ + console.log(1) + } ,before: function(obj){ //预读本地文件示例,不支持ie8 obj.preview(function(index, file, result){ @@ -248,14 +257,24 @@ layui.use('upload', function(){ }); + //手动上传 upload.render({ elem: '#test6' ,url: '' ,auto: false //,multiple: true ,bindAction: '#test7' + ,choose: function(obj){ + var that = this; + obj.preview(function(index, file){ + obj.resetFile(index, file, '123.jpg'); + }); + } + ,before: function(){ + console.log(345); + } ,done: function(res){ - console.log(res) + console.log(res); } }); @@ -263,7 +282,7 @@ layui.use('upload', function(){ elem: '#test8' ,url: '' ,done: function(res){ - console.log(res) + console.log(res); } }); @@ -271,7 +290,7 @@ layui.use('upload', function(){ elem: '#test9' ,url: '' ,done: function(res){ - console.log(res) + console.log(res); } }); diff --git a/package.json b/package.json index 3185a3a..843a0be 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "layui-src", "realname": "layui", - "version": "2.3.0-rc1", + "version": "2.3.0", "independents": { "layim": "3.7.6" }, diff --git a/src/css/layui.css b/src/css/layui.css index e2a1af5..c62c75e 100644 --- a/src/css/layui.css +++ b/src/css/layui.css @@ -46,11 +46,11 @@ a cite{font-style: normal; *cursor:pointer;} /** 图标字体 **/ @font-face {font-family: 'layui-icon'; - src: url('../font/iconfont.eot?v=230-rc1'); - src: url('../font/iconfont.eot?v=230-rc1#iefix') format('embedded-opentype'), - url('../font/iconfont.svg?v=230-rc1#iconfont') format('svg'), - url('../font/iconfont.woff?v=230-rc1') format('woff'), - url('../font/iconfont.ttf?v=230-rc1') format('truetype'); + src: url('../font/iconfont.eot?v=230'); + src: url('../font/iconfont.eot?v=230#iefix') format('embedded-opentype'), + url('../font/iconfont.svg?v=230#iconfont') format('svg'), + url('../font/iconfont.woff?v=230') format('woff'), + url('../font/iconfont.ttf?v=230') format('truetype'); } .layui-icon{ @@ -205,7 +205,8 @@ a cite{font-style: normal; *cursor:pointer;} .layui-icon-template-1:before{content:"\e656"} .layui-icon-vercode:before{content:"\e679"} .layui-icon-cellphone:before{content:"\e678"} - +.layui-icon-screen-full:before{content:"\e622";} +.layui-icon-screen-restore:before{content:"\e758";} /* 基本布局 */ diff --git a/src/font/iconfont.eot b/src/font/iconfont.eot index 961c051..51c4f89 100644 Binary files a/src/font/iconfont.eot and b/src/font/iconfont.eot differ diff --git a/src/font/iconfont.svg b/src/font/iconfont.svg index 401e773..e05b189 100644 --- a/src/font/iconfont.svg +++ b/src/font/iconfont.svg @@ -297,6 +297,9 @@ t9.5 -10.5t21.5 -4h37h67h81h80h64h36q23 0 34 12t2 38q-5 13 -9.5 30.5t-9.5 34.5q- + + + @@ -426,6 +429,9 @@ t9.5 -10.5t21.5 -4h37h67h81h80h64h36q23 0 34 12t2 38q-5 13 -9.5 30.5t-9.5 34.5q- + + + diff --git a/src/font/iconfont.ttf b/src/font/iconfont.ttf index 46a1267..43a3161 100644 Binary files a/src/font/iconfont.ttf and b/src/font/iconfont.ttf differ diff --git a/src/font/iconfont.woff b/src/font/iconfont.woff index 0cb6d7e..7fd98e3 100644 Binary files a/src/font/iconfont.woff and b/src/font/iconfont.woff differ diff --git a/src/lay/modules/form.js b/src/lay/modules/form.js index 72f0a27..7527020 100644 --- a/src/lay/modules/form.js +++ b/src/lay/modules/form.js @@ -144,6 +144,7 @@ layui.define('layer', function(exports){ index = select[0].selectedIndex; //获取最新的 selectedIndex reElem.addClass(CLASS+'ed'); dds.removeClass(HIDE); + nearElem = null; //初始选中样式 dds.eq(index).addClass(THIS).siblings().removeClass(THIS); @@ -231,6 +232,22 @@ layui.define('layer', function(exports){ //标注样式 nearDd.addClass(THIS).siblings().removeClass(THIS); + + //定位滚动条 + var ddThis = dl.children('dd.layui-this') + ,posTop = ddThis.position().top + ,dlHeight = dl.height() + ,ddHeight = ddThis.height(); + + //若选中元素在滚动条不可见底部 + if(posTop > dlHeight){ + dl.scrollTop(posTop + dl.scrollTop() - dlHeight + ddHeight - 5); + } + + //若选择玄素在滚动条不可见顶部 + if(posTop < 0){ + dl.scrollTop(posTop + dl.scrollTop()); + } }; diff --git a/src/lay/modules/laydate.js b/src/lay/modules/laydate.js index 5d3d5fd..42ccf05 100644 --- a/src/lay/modules/laydate.js +++ b/src/lay/modules/laydate.js @@ -377,7 +377,7 @@ ,range: false //是否开启范围选择,即双控件 ,format: 'yyyy-MM-dd' //默认日期格式 ,value: null //默认日期,支持传入new Date(),或者符合format参数设定的日期格式字符 - ,isInitValue: false //用于控制是否自动向元素填充初始值(需配合 value 参数使用) + ,isInitValue: true //用于控制是否自动向元素填充初始值(需配合 value 参数使用) ,min: '1900-1-1' //有效最小日期,年月日必须用“-”分割,时分秒必须用“:”分割。注意:它并不是遵循 format 设定的格式。 ,max: '2099-12-31' //有效最大日期,同上 ,trigger: 'focus' //呼出控件的事件 diff --git a/src/lay/modules/upload.js b/src/lay/modules/upload.js index b178ee8..f35b6c1 100644 --- a/src/lay/modules/upload.js +++ b/src/lay/modules/upload.js @@ -127,11 +127,11 @@ layui.define('layer' , function(exports){ $('#'+ ELEM_IFRAME)[0] || $('body').append(iframe); //包裹文件域 - if(!options.elem.next().hasClass(ELEM_IFRAME)){ + if(!options.elem.next().hasClass(ELEM_FORM)){ that.elemFile.wrap(elemForm); //追加额外的参数 - options.elem.next('.'+ ELEM_IFRAME).append(function(){ + options.elem.next('.'+ ELEM_FORM).append(function(){ var arr = []; layui.each(options.data, function(key, value){ value = typeof value === 'function' ? value() : value; @@ -288,14 +288,17 @@ layui.define('layer' , function(exports){ //回调返回的参数 ,args = { + //预览 preview: function(callback){ that.preview(callback); } + //上传 ,upload: function(index, file){ var thisFile = {}; thisFile[index] = file; that.upload(thisFile); } + //追加文件到队列 ,pushFile: function(){ that.files = that.files || {}; layui.each(that.chooseFiles, function(index, item){ @@ -303,12 +306,22 @@ layui.define('layer' , function(exports){ }); return that.files; } + //重置文件 + ,resetFile: function(index, file, filename){ + var newFile = new File([file], filename); + that.files = that.files || {}; + that.files[index] = newFile; + } } //提交上传 - ,send = function(){ - if(type === 'choose'){ - return options.choose && options.choose(args); + ,send = function(){ + //选择文件的回调 + if(type === 'choose' || options.auto){ + options.choose && options.choose(args); + if(type === 'choose'){ + return; + } } //上传前的回调 diff --git a/src/lay/modules/util.js b/src/lay/modules/util.js index a02386e..0da0d9b 100644 --- a/src/lay/modules/util.js +++ b/src/lay/modules/util.js @@ -164,6 +164,13 @@ layui.define('jquery', function(exports){ .replace(/mm/g, hms[1]) .replace(/ss/g, hms[2]); } + + //防 xss 攻击 + ,escape: function(html){ + return String(html || '').replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&') + .replace(//g, '>') + .replace(/'/g, ''').replace(/"/g, '"'); + } }; exports('util', util); diff --git a/src/layui.js b/src/layui.js index 2ad7898..351a697 100644 --- a/src/layui.js +++ b/src/layui.js @@ -19,7 +19,7 @@ } ,Layui = function(){ - this.v = '2.3.0-rc1'; //版本号 + this.v = '2.3.0'; //版本号 } //获取layui所在目录