pull/5/head^2
sentsin 2016-11-18 06:52:55 +08:00
parent 303fc4dcf4
commit bb6f99343f
29 changed files with 258 additions and 154 deletions

View File

@ -1,11 +1,54 @@
# v1.0.4 2016-11-18
* Tab选项卡新增用于添加Tab选项的接口element.tabAdd(filter, index);
* Tab选项卡新增用于外部删除Tab选项的接口element.tabDelete(filter, index);
* Tab选项卡新增用于动态切换的接口element.tabChange(filter, index);
* 表单组select、checkbox、radio等新增 disabled 属性的禁用支持
* 修复水平导航二级菜单在ie8下无法使用的bug
* 修复layPage分页在ie8的样式兼容问题
* 修复Form表单组radio框使用name="a[b]"、name="a.b"这种格式出现报错的bug
* 修复在使用了element.init()后Tab选项卡的相关事件出现多次执行的bug
* 修复在使用了element.init()后面包屑重复插入了分隔符的bug
* checkbox框样式调整勾选图标放在左侧
* 导航菜单在ie10以下浏览器开启了hover效果
---
# v1.0.3 2016-11-10
* 集成 layer 3.0
* 重点增加导航菜单的二级菜单支持(水平导航和树形导航都支持)
* 表单select增加optgroup的分组支持
* 富文本编辑器新增获取选中内容的方法layedit.getSelection(index)
* 修复layer模块无法使用layer.config的extend来加载拓展皮肤的bug
* 修复Tab选项卡与select的小冲突
* 修复Tab选项卡简洁模式与内容区域的导航的样式小冲突
* 修复Tab选项卡与内容区域的子Tab选项卡存在冲突的bug
* 修除表单组label标签、layDate与第三方框架如Bootstrap的样式冲突
* 修复flow流加载模块的的信息流在设置isLazyimg:true时下拉报错的bug
* 表单select内容若超出最大宽度则自适应宽度
* layui.js合并到layui.all.js中也就是说如果你不采用layui模块化规范只需引入layui.all.js即可。
---
# v1.0.2 2016-10-18
* 修复layui.data('table', null); 无法删除本地表的bug
* 修改自定义事件监听机制
* 新增“引用”的区块多套显示风格
* 新增“字段集”多套显示风格
* 新增“纯圆角”公共CSS类
* 新增hr全局初始化CSS类
* 新增<hr>全局初始化CSS类
* 富文本编辑器增加用于同步编辑器内容到textarea的sync方法一般用于异步提交
* 修复富文本编辑器点击编辑区域无法关闭表情的bug
@ -17,3 +60,4 @@
* 将表单下边距由20px调整为15px
* 完善表单响应式
* 处理layPage分页可能被第三方框架如Bootstrap引发的样式冲突

View File

@ -1,7 +1,7 @@
{
"name": "layui",
"main": "src/layui.js",
"version": "1.0.3",
"version": "1.0.4",
"homepage": "https://github.com/sentsin/layui",
"authors": [
"sentsin <xu@sentsin.com>"

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
/** layui-v1.0.3 LGPL license By www.layui.com */
/** layui-v1.0.4 LGPL license By www.layui.com */
html #layuicss-skincodecss{display:none;position:absolute;width:1989px}.layui-code-h3,.layui-code-view{position:relative;font-size:12px}.layui-code-view{display:block;margin:10px 0;padding:0;border:1px solid #ddd;border-left-width:6px;background-color:#F2F2F2;color:#333;font-family:Courier New}.layui-code-h3{padding:0 10px;height:30px;line-height:30px;border-bottom:1px solid #ddd}.layui-code-h3 a{position:absolute;right:10px;top:0;color:#999}.layui-code-view .layui-code-ol{position:relative;overflow:auto}.layui-code-view .layui-code-ol li{position:relative;margin-left:45px;line-height:20px;padding:0 5px;border-left:1px solid #ddd;list-style-type:decimal-leading-zero;*list-style-type:decimal;background-color:#fff}.layui-code-view pre{margin:0}.layui-code-notepad{border:1px solid #0C0C0C;border-left-color:#3F3F3F;background-color:#0C0C0C;color:#C2BE9E}.layui-code-notepad .layui-code-h3{border-bottom:none}.layui-code-notepad .layui-code-ol li{background-color:#3F3F3F;border-left:none}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
/** layui-v1.0.3 LGPL license By www.layui.com */
/** layui-v1.0.4 LGPL license By www.layui.com */
;layui.define("jquery",function(e){"use strict";var a=layui.jquery,l="http://www.layui.com/doc/modules/code.html";e("code",function(e){var t=[];e=e||{},e.elem=a(e.elem||".layui-code"),e.about=!("about"in e)||e.about,e.elem.each(function(){t.push(this)}),layui.each(t.reverse(),function(t,i){var c=a(i),o=c.html();(c.attr("lay-encode")||e.encode)&&(o=o.replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&#39;").replace(/"/g,"&quot;")),c.html('<ol class="layui-code-ol"><li>'+o.replace(/[\r\t\n]+/g,"</li><li>")+"</li></ol>"),c.find(">.layui-code-h3")[0]||c.prepend('<h3 class="layui-code-h3">'+(c.attr("lay-title")||e.title||"code")+(e.about?'<a href="'+l+'" target="_blank">layui.code</a>':"")+"</h3>");var d=c.find(">.layui-code-ol");c.addClass("layui-box layui-code-view"),(c.attr("lay-skin")||e.skin)&&c.addClass("layui-code-"+(c.attr("lay-skin")||e.skin)),(d.find("li").length/100|0)>0&&d.css("margin-left",(d.find("li").length/100|0)+"px"),(c.attr("lay-height")||e.height)&&d.css("max-height",c.attr("lay-height")||e.height)})})}).addcss("modules/code.css","skincodecss");

View File

@ -1,2 +1,2 @@
/** layui-v1.0.3 LGPL license By www.layui.com */
;layui.define("jquery",function(i){"use strict";var t=layui.jquery,a=(layui.hint(),layui.device()),e="element",n="layui-this",l="layui-show",s=function(){this.config={}};s.prototype.set=function(i){var a=this;return t.extend(!0,a.config,i),a},s.prototype.on=function(i,t){return layui.onevent(e,i,t)},s.prototype.init=function(i){var s={tabClick:function(i,a){var s=t(this),a=a||s.index(),o=s.parents(".layui-tab"),c=o.children(".layui-tab-content").children(".layui-tab-item"),u=o.attr("lay-filter");s.addClass(n).siblings().removeClass(n),c.eq(a).addClass(l).siblings().removeClass(l),layui.event.call(this,e,"tab("+u+")",{elem:o,index:a})},tabAuto:function(){var i="layui-tab-more",e="layui-tab-bar",l="layui-tab-close",o=this;t(".layui-tab").each(function(){var c=t(this),u=c.children(".layui-tab-title"),r=(c.children(".layui-tab-content").children(".layui-tab-item"),'lay-stope="tabmore"'),d=t('<span class="layui-unselect layui-tab-bar" '+r+"><i "+r+' class="layui-icon">&#xe61a;</i></span>');if(o===window&&8!=a.ie&&s.hideTabMore(!0),c.attr("lay-allowClose")&&!u.find("li").find("."+l)[0]){var h=t('<i class="layui-icon layui-unselect '+l+'">&#x1006;</i>');h.on("click",function(){var i=t(this).parent(),a=i.index(),e=i.parents(".layui-tab"),l=e.children(".layui-tab-content").children(".layui-tab-item");i.hasClass(n)&&(i.next()[0]?s.tabClick.call(i.next()[0],{},a+1):i.prev()[0]&&s.tabClick.call(i.prev()[0],{},a-1)),i.remove(),l.eq(a).remove()}),u.find("li").append(h)}if(u.prop("scrollWidth")>u.outerWidth()+1){if(u.find("."+e)[0])return;u.append(d),d.on("click",function(t){u[this.title?"removeClass":"addClass"](i),this.title=this.title?"":"收缩"})}else u.find("."+e).remove()})},hideTabMore:function(i){var a=t(".layui-tab-title");i!==!0&&"tabmore"===i.target.getAttribute("lay-stope")||(a.removeClass("layui-tab-more"),a.find(".layui-tab-bar").attr("title",""))}},o={tab:function(){var i=".layui-tab-title li";s.tabAuto.call({}),c.off("click",i,s.tabClick).on("click",i,s.tabClick),t(window).off("resize",s.tabAuto).on("resize",s.tabAuto),c.off("click",s.hideTabMore).on("click",s.hideTabMore)},nav:function(){var i,e,n,l=".layui-nav",s="layui-nav-item",o="layui-nav-bar",c="layui-nav-tree",u="layui-nav-child",r="layui-nav-more",d=200,h=function(a,l){var s=t(this),o=s.find("."+u);l.hasClass(c)?a.css({top:s.position().top,height:s.children("a").height(),opacity:1}):(o.addClass("layui-anim layui-anim-upbit"),a.css({left:s.position().left+parseFloat(s.css("marginLeft")),top:s.position().top+s.height()-5}),i=setTimeout(function(){a.css({width:s.width(),opacity:1})},d),clearTimeout(n),"block"===o.css("display")&&clearTimeout(e),e=setTimeout(function(){o.show(),s.find("."+r).addClass(r+"d")},300))};t(l).each(function(){var l=t(this),f=t('<span class="'+o+'"></span>'),y=l.find("."+s);l.find("."+o)[0]||a.ie&&a.ie<10||(l.append(f),y.on("mouseenter",function(){h.call(this,f,l)}).on("mouseleave",function(){l.hasClass(c)||(clearTimeout(e),e=setTimeout(function(){l.find("."+u).hide(),l.find("."+r).removeClass(r+"d")},300))}),l.on("mouseleave",function(){clearTimeout(i),n=setTimeout(function(){l.hasClass(c)?f.css({height:0,top:f.position().top+f.height()/2,opacity:0}):f.css({width:0,left:f.position().left+f.width()/2,opacity:0})},d)})),y.each(function(){var i=t(this),a=i.find("."+u);if(a[0]&&!i.find("."+r)[0]){if(i.children("a").append('<span class="'+r+'"></span>'),!l.hasClass(c))return;i.children("a").on("click",function(){t(this);"none"===a.css("display")?i.addClass(s+"ed"):i.removeClass(s+"ed")})}})})},breadcrumb:function(){var i=".layui-breadcrumb";t(i).each(function(){var i=t(this),a=i.attr("lay-separator")||">",e=i.find("a");e.each(function(i){i!==e.length-1&&t(this).append("<span>"+a+"</span>")}),i.css("visibility","visible")})}};return layui.each(o,function(i,t){t()})};var o=new s,c=t(document);o.init(),i(e,function(i){return o.set(i)})});
/** layui-v1.0.4 LGPL license By www.layui.com */
;layui.define("jquery",function(i){"use strict";var t=layui.jquery,a=(layui.hint(),layui.device()),e="element",n="layui-this",l="layui-show",s=function(){this.config={}};s.prototype.set=function(i){var a=this;return t.extend(!0,a.config,i),a},s.prototype.on=function(i,t){return layui.onevent(e,i,t)},s.prototype.tabAdd=function(i,a){var e=t(".layui-tab[lay-filter="+i+"]"),n=e.children(".layui-tab-title"),l=e.children(".layui-tab-content");return n.append("<li>"+(a.title||"unnaming")+"</li>"),l.append('<div class="layui-tab-item">'+(a.content||"")+"</div>"),this.init()},s.prototype.tabDelete=function(i,a){var e=t(".layui-tab[lay-filter="+i+"]"),n=e.children(".layui-tab-title").find(">li").eq(a);return o.tabDelete(null,n),this},s.prototype.tabChange=function(i,a){var e=t(".layui-tab[lay-filter="+i+"]"),n=e.children(".layui-tab-title").find(">li").eq(a);return o.tabClick(null,a,n),this};var o={tabClick:function(i,a,s){var o=s||t(this),a=a||o.index(),u=o.parents(".layui-tab"),c=u.children(".layui-tab-content").children(".layui-tab-item"),r=u.attr("lay-filter");o.addClass(n).siblings().removeClass(n),c.eq(a).addClass(l).siblings().removeClass(l),layui.event.call(this,e,"tab("+r+")",{elem:u,index:a})},tabDelete:function(i,a){var e=a||t(this).parent(),l=e.index(),s=e.parents(".layui-tab"),u=s.children(".layui-tab-content").children(".layui-tab-item");e.hasClass(n)&&(e.next()[0]?o.tabClick.call(e.next()[0],null,l+1):e.prev()[0]&&o.tabClick.call(e.prev()[0],null,l-1)),e.remove(),u.eq(l).remove()},tabAuto:function(){var i="layui-tab-more",e="layui-tab-bar",n="layui-tab-close",l=this;t(".layui-tab").each(function(){var s=t(this),u=s.children(".layui-tab-title"),c=(s.children(".layui-tab-content").children(".layui-tab-item"),'lay-stope="tabmore"'),r=t('<span class="layui-unselect layui-tab-bar" '+c+"><i "+c+' class="layui-icon">&#xe61a;</i></span>');if(l===window&&8!=a.ie&&o.hideTabMore(!0),s.attr("lay-allowClose")&&!u.find("li").find("."+n)[0]){var d=t('<i class="layui-icon layui-unselect '+n+'">&#x1006;</i>');d.on("click",o.tabDelete),u.find("li").append(d)}if(u.prop("scrollWidth")>u.outerWidth()+1){if(u.find("."+e)[0])return;u.append(r),r.on("click",function(t){u[this.title?"removeClass":"addClass"](i),this.title=this.title?"":"收缩"})}else u.find("."+e).remove()})},hideTabMore:function(i){var a=t(".layui-tab-title");i!==!0&&"tabmore"===t(i.target).attr("lay-stope")||(a.removeClass("layui-tab-more"),a.find(".layui-tab-bar").attr("title",""))}};s.prototype.init=function(i){var e={tab:function(){o.tabAuto.call({})},nav:function(){var i,e,n,l=".layui-nav",s="layui-nav-item",o="layui-nav-bar",u="layui-nav-tree",c="layui-nav-child",r="layui-nav-more",d=200,y=function(l,s){var o=t(this),y=o.find("."+c);s.hasClass(u)?l.css({top:o.position().top,height:o.children("a").height(),opacity:1}):(y.addClass("layui-anim layui-anim-upbit"),l.css({left:o.position().left+parseFloat(o.css("marginLeft")),top:o.position().top+o.height()-5}),i=setTimeout(function(){l.css({width:o.width(),opacity:1})},a.ie&&a.ie<10?0:d),clearTimeout(n),"block"===y.css("display")&&clearTimeout(e),e=setTimeout(function(){y.show(),o.find("."+r).addClass(r+"d")},300))};t(l).each(function(){var a=t(this),l=t('<span class="'+o+'"></span>'),h=a.find("."+s);a.find("."+o)[0]||(a.append(l),h.on("mouseenter",function(){y.call(this,l,a)}).on("mouseleave",function(){a.hasClass(u)||(clearTimeout(e),e=setTimeout(function(){a.find("."+c).hide(),a.find("."+r).removeClass(r+"d")},300))}),a.on("mouseleave",function(){clearTimeout(i),n=setTimeout(function(){a.hasClass(u)?l.css({height:0,top:l.position().top+l.height()/2,opacity:0}):l.css({width:0,left:l.position().left+l.width()/2,opacity:0})},d)})),h.each(function(){var i=t(this),e=i.find("."+c);if(e[0]&&!i.find("."+r)[0]){if(i.children("a").append('<span class="'+r+'"></span>'),!a.hasClass(u))return;i.children("a").on("click",function(){t(this);"none"===e.css("display")?i.addClass(s+"ed"):i.removeClass(s+"ed")})}})})},breadcrumb:function(){var i=".layui-breadcrumb";t(i).each(function(){var i=t(this),a=i.attr("lay-separator")||">",e=i.find("a");e.find(".layui-box")[0]||(e.each(function(i){i!==e.length-1&&t(this).append('<span class="layui-box">'+a+"</span>")}),i.css("visibility","visible"))})}};return layui.each(e,function(i,t){t()})};var u=new s,c=t(document);u.init();var r=".layui-tab-title li";c.on("click",r,o.tabClick),c.on("click",o.hideTabMore),t(window).on("resize",o.tabAuto),i(e,function(i){return u.set(i)})});

View File

@ -1,2 +1,2 @@
/** layui-v1.0.3 LGPL license By www.layui.com */
/** layui-v1.0.4 LGPL license By www.layui.com */
;layui.define("jquery",function(o){"use strict";var e=layui.jquery,l=function(o){},i='<i class="layui-anim layui-anim-rotate layui-anim-loop layui-icon ">&#xe63e;</i>';l.prototype.load=function(o){var l,t,n,r,a=this,c=1;o=o||{};var u=e(o.elem);if(u[0]){var f=e(o.scrollElem||document),m=o.mb||50,s=!("isAuto"in o)||o.isAuto,y=!("isShowEnd"in o)||o.isShowEnd,h=o.scrollElem&&o.scrollElem!==document,v="<cite>加载更多</cite>",d=e('<div class="layui-flow-more"><a href="javascript:;">'+v+"</a></div>");u.find(".layui-flow-more")[0]||u.append(d);var p=function(o,i){o=e(o),d.before(o),i=0==i||null,i?d.html(y?"没有更多了":""):d.find("a").html(v),t=i,l=null,n&&n()},g=function(){l=!0,d.find("a").html(i),"function"==typeof o.done&&o.done(++c,p)};if(d.find("a").on("click",function(){e(this);t||l||g()}),o.isLazyimg)var n=a.lazyimg({elem:o.elem+" img",scrollElem:o.scrollElem});return s?(f.on("scroll",function(){var o=e(this),i=o.scrollTop();r&&clearTimeout(r),t||(r=setTimeout(function(){var t=h?o.height():e(window).height(),n=h?o.prop("scrollHeight"):document.documentElement.scrollHeight;n-i-t<=m&&(l||g())},100))}),a):a}},l.prototype.lazyimg=function(o){var l,i=this,t=0;o=o||{};var n=e(o.scrollElem||document),r=o.elem||"img",a=o.scrollElem&&o.scrollElem!==document,c=function(o,e){var l=n.scrollTop(),r=l+e,c=a?function(){return o.offset().top-n.offset().top+l}():o.offset().top;if(c>=l&&c<=r&&!o.attr("src")){var f=o.attr("lay-src");layui.img(f,function(){var e=i.lazyimg.elem.eq(t);o.attr("src",f).removeAttr("lay-src"),e[0]&&u(e),t++})}},u=function(o,l){var u=a?(l||n).height():e(window).height(),f=n.scrollTop(),m=f+u;if(i.lazyimg.elem=e(r),o)c(o,u);else for(var s=0;s<i.lazyimg.elem.length;s++){var y=i.lazyimg.elem.eq(s),h=a?function(){return y.offset().top-n.offset().top+f}():y.offset().top;if(c(y,u),t=s,h>m)break}};if(u(),!l){var f;n.on("scroll",function(){var o=e(this);f&&clearTimeout(f),f=setTimeout(function(){u(null,o)},100)}),l=!0}return u},o("flow",new l)});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
/** layui-v1.0.3 LGPL license By www.layui.com */
/** layui-v1.0.4 LGPL license By www.layui.com */
;layui.define(function(a){"use strict";function t(a){new p(a)}var e=document,r="getElementById",n="getElementsByTagName",s=0,p=function(a){var t=this,e=t.config=a||{};e.item=s++,t.render(!0)};p.on=function(a,t,e){return a.attachEvent?a.attachEvent("on"+t,function(){e.call(a,window.even)}):a.addEventListener(t,e,!1),p},p.prototype.type=function(){var a=this.config;if("object"==typeof a.cont)return void 0===a.cont.length?2:3},p.prototype.view=function(){var a=this,t=a.config,e=[],r={};if(t.pages=0|t.pages,t.curr=0|t.curr||1,t.groups="groups"in t?0|t.groups:5,t.first="first"in t?t.first:"&#x9996;&#x9875;",t.last="last"in t?t.last:"&#x672B;&#x9875;",t.prev="prev"in t?t.prev:"&#x4E0A;&#x4E00;&#x9875;",t.next="next"in t?t.next:"&#x4E0B;&#x4E00;&#x9875;",t.pages<=1)return"";for(t.groups>t.pages&&(t.groups=t.pages),r.index=Math.ceil((t.curr+(t.groups>1&&t.groups!==t.pages?1:0))/(0===t.groups?1:t.groups)),t.curr>1&&t.prev&&e.push('<a href="javascript:;" class="layui-laypage-prev" data-page="'+(t.curr-1)+'">'+t.prev+"</a>"),r.index>1&&t.first&&0!==t.groups&&e.push('<a href="javascript:;" class="laypage_first" data-page="1" title="&#x9996;&#x9875;">'+t.first+"</a><span>&#x2026;</span>"),r.poor=Math.floor((t.groups-1)/2),r.start=r.index>1?t.curr-r.poor:1,r.end=r.index>1?function(){var a=t.curr+(t.groups-r.poor-1);return a>t.pages?t.pages:a}():t.groups,r.end-r.start<t.groups-1&&(r.start=r.end-t.groups+1);r.start<=r.end;r.start++)r.start===t.curr?e.push('<span class="layui-laypage-curr"><em class="layui-laypage-em" '+(/^#/.test(t.skin)?'style="background-color:'+t.skin+";":"")+'"></em><em>'+r.start+"</em></span>"):e.push('<a href="javascript:;" data-page="'+r.start+'">'+r.start+"</a>");return t.pages>t.groups&&r.end<t.pages&&t.last&&0!==t.groups&&e.push('<span>&#x2026;</span><a href="javascript:;" class="layui-laypage-last" title="&#x5C3E;&#x9875;" data-page="'+t.pages+'">'+t.last+"</a>"),r.flow=!t.prev&&0===t.groups,(t.curr!==t.pages&&t.next||r.flow)&&e.push(function(){return r.flow&&t.curr===t.pages?'<span class="layui-laypage-nomore" title="&#x5DF2;&#x6CA1;&#x6709;&#x66F4;&#x591A;">'+t.next+"</span>":'<a href="javascript:;" class="layui-laypage-next" data-page="'+(t.curr+1)+'">'+t.next+"</a>"}()),'<div class="layui-box layui-laypage layui-laypage-'+(t.skin?function(a){return/^#/.test(a)?"molv":a}(t.skin):"default")+'" id="layui-laypage-'+a.config.item+'">'+e.join("")+function(){return t.skip?'<span class="layui-laypage-total">&#x5230;&#x7B2C; <input type="number" min="1" onkeyup="this.value=this.value.replace(/\\D/, \'\');" value="'+t.curr+'" class="layui-laypage-skip"> &#x9875; <button type="button" class="layui-laypage-btn">&#x786e;&#x5b9a;</button></span>':""}()+"</div>"},p.prototype.jump=function(a){if(a){for(var t=this,e=t.config,r=a.children,s=a[n]("button")[0],i=a[n]("input")[0],u=0,o=r.length;u<o;u++)"a"===r[u].nodeName.toLowerCase()&&p.on(r[u],"click",function(){var a=0|this.getAttribute("data-page");e.curr=a,t.render()});s&&p.on(s,"click",function(){var a=0|i.value.replace(/\s|\D/g,"");a&&a<=e.pages&&(e.curr=a,t.render())})}},p.prototype.render=function(a){var t=this,n=t.config,s=t.type(),p=t.view();2===s?n.cont.innerHTML=p:3===s?n.cont.html(p):e[r](n.cont).innerHTML=p,n.jump&&n.jump(n,a),t.jump(e[r]("layui-laypage-"+n.item)),n.hash&&!a&&(location.hash="!"+n.hash+"="+n.curr)},a("laypage",t)});

View File

@ -1,2 +1,2 @@
/** layui-v1.0.3 LGPL license By www.layui.com */
/** layui-v1.0.4 LGPL license By www.layui.com */
;layui.define(function(e){"use strict";var r={open:"{{",close:"}}"},n={exp:function(e){return new RegExp(e,"g")},query:function(e,n,t){var o=["#([\\s\\S])+?","([^{#}])*?"][e||0];return c((n||"")+r.open+o+r.close+(t||""))},escape:function(e){return String(e||"").replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&#39;").replace(/"/g,"&quot;")},error:function(e,r){var n="Laytpl Error";return"object"==typeof console&&console.error(n+e+"\n"+(r||"")),n+e}},c=n.exp,t=function(e){this.tpl=e};t.pt=t.prototype,window.errors=0,t.pt.parse=function(e,t){var o=this,p=e,a=c("^"+r.open+"#",""),l=c(r.close+"$","");e=e.replace(/\s+|\r|\t|\n/g," ").replace(c(r.open+"#"),r.open+"# ").replace(c(r.close+"}"),"} "+r.close).replace(/\\/g,"\\\\").replace(/(?="|')/g,"\\").replace(n.query(),function(e){return e=e.replace(a,"").replace(l,""),'";'+e.replace(/\\/g,"")+';view+="'}).replace(n.query(1),function(e){var n='"+(';return e.replace(/\s/g,"")===r.open+r.close?"":(e=e.replace(c(r.open+"|"+r.close),""),/^=/.test(e)&&(e=e.replace(/^=/,""),n='"+_escape_('),n+e.replace(/\\/g,"")+')+"')}),e='"use strict";var view = "'+e+'";return view;';try{return o.cache=e=new Function("d, _escape_",e),e(t,n.escape)}catch(u){return delete o.cache,n.error(u,p)}},t.pt.render=function(e,r){var c,t=this;return e?(c=t.cache?t.cache(e,n.escape):t.parse(t.tpl,e),r?void r(c):c):n.error("no data")};var o=function(e){return"string"!=typeof e?n.error("Template not found"):new t(e)};o.config=function(e){e=e||{};for(var n in e)r[n]=e[n]},o.v="1.2.0",e("laytpl",o)});

View File

@ -1,2 +1,2 @@
/** layui-v1.0.3 LGPL license By www.layui.com */
/** layui-v1.0.4 LGPL license By www.layui.com */
;layui.define("jquery",function(e){"use strict";var o=layui.jquery,a=layui.hint(),r="layui-tree-enter",i=function(e){this.options=e},t={arrow:["&#xe623;","&#xe625;"],checkbox:["&#xe626;","&#xe627;"],radio:["&#xe62b;","&#xe62a;"],branch:["&#xe622;","&#xe624;"],leaf:"&#xe621;"};i.prototype.init=function(e){var o=this;e.addClass("layui-box layui-tree"),o.options.skin&&e.addClass("layui-tree-skin-"+o.options.skin),o.tree(e),o.on(e)},i.prototype.tree=function(e,a){var r=this,i=r.options,n=a||i.nodes;layui.each(n,function(a,n){var l=n.children&&n.children.length>0,c=o('<ul class="'+(n.spread?"layui-show":"")+'"></ul>'),s=o(["<li "+(n.spread?'data-spread="'+n.spread+'"':"")+">",function(){return l?'<i class="layui-icon layui-tree-spread">'+(n.spread?t.arrow[1]:t.arrow[0])+"</i>":""}(),function(){return i.check?'<i class="layui-icon layui-tree-check">'+("checkbox"===i.check?t.checkbox[0]:"radio"===i.check?t.radio[0]:"")+"</i>":""}(),function(){return'<a href="'+(n.href||"javascript:;")+'" '+(i.target&&n.href?'target="'+i.target+'"':"")+">"+('<i class="layui-icon layui-tree-'+(l?"branch":"leaf")+'">'+(l?n.spread?t.branch[1]:t.branch[0]:t.leaf)+"</i>")+("<cite>"+(n.name||"未命名")+"</cite></a>")}(),"</li>"].join(""));l&&(s.append(c),r.tree(c,n.children)),e.append(s),"function"==typeof i.click&&r.click(s,n),r.spread(s,n),i.drag&&r.drag(s,n)})},i.prototype.click=function(e,o){var a=this,r=a.options;e.children("a").on("click",function(e){layui.stope(e),r.click(o)})},i.prototype.spread=function(e,o){var a=this,r=(a.options,e.children(".layui-tree-spread")),i=e.children("ul"),n=e.children("a"),l=function(){e.data("spread")?(e.data("spread",null),i.removeClass("layui-show"),r.html(t.arrow[0]),n.find(".layui-icon").html(t.branch[0])):(e.data("spread",!0),i.addClass("layui-show"),r.html(t.arrow[1]),n.find(".layui-icon").html(t.branch[1]))};i[0]&&(r.on("click",l),n.on("dblclick",l))},i.prototype.on=function(e){var a=this,i=a.options,t="layui-tree-drag";e.find("i").on("selectstart",function(e){return!1}),i.drag&&o(document).on("mousemove",function(e){var r=a.move;if(r.from){var i=(r.to,o('<div class="layui-box '+t+'"></div>'));e.preventDefault(),o("."+t)[0]||o("body").append(i);var n=o("."+t)[0]?o("."+t):i;n.addClass("layui-show").html(r.from.elem.children("a").html()),n.css({left:e.pageX+10,top:e.pageY+10})}}).on("mouseup",function(){var e=a.move;e.from&&(e.from.elem.children("a").removeClass(r),e.to&&e.to.elem.children("a").removeClass(r),a.move={},o("."+t).remove())})},i.prototype.move={},i.prototype.drag=function(e,a){var i=this,t=(i.options,e.children("a")),n=function(){var t=o(this),n=i.move;n.from&&(n.to={item:a,elem:e},t.addClass(r))};t.on("mousedown",function(){var o=i.move;o.from={item:a,elem:e}}),t.on("mouseenter",n).on("mousemove",n).on("mouseleave",function(){var e=o(this),a=i.move;a.from&&(delete a.to,e.removeClass(r))})},e("tree",function(e){var r=new i(e=e||{}),t=o(e.elem);return t[0]?void r.init(t):a.error("layui.tree 没有找到"+e.elem+"元素")})});

View File

@ -1,2 +1,2 @@
/** layui-v1.0.3 LGPL license By www.layui.com */
/** layui-v1.0.4 LGPL license By www.layui.com */
;layui.define("layer",function(e){"use strict";var a=layui.jquery,t=layui.layer,i=(layui.device(),"layui-upload-enter"),n="layui-upload-iframe",r={icon:2,shift:6},o={file:"文件",video:"视频",audio:"音频"},s=function(e){this.options=e};s.prototype.init=function(){var e=this,t=e.options,r=a("body"),s=a(t.elem||".layui-upload-file"),u=a('<iframe id="'+n+'" class="'+n+'" name="'+n+'"></iframe>');return a("#"+n)[0]||r.append(u),s.each(function(r,s){s=a(s);var u='<form target="'+n+'" method="'+(t.method||"post")+'" key="set-mine" enctype="multipart/form-data" action="'+(t.url||"")+'"></form>',l=s.attr("lay-type")||t.type;t.unwrap||(u='<div class="layui-box layui-upload-button">'+u+'<span class="layui-upload-icon"><i class="layui-icon">&#xe608;</i>'+(s.attr("lay-title")||t.title||"上传"+(o[l]||"图片"))+"</span></div>"),u=a(u),t.unwrap||u.on("dragover",function(e){e.preventDefault(),a(this).addClass(i)}).on("dragleave",function(){a(this).removeClass(i)}).on("drop",function(){a(this).removeClass(i)}),s.parent("form").attr("target")===n&&(t.unwrap?s.unwrap():(s.parent().next().remove(),s.unwrap().unwrap())),s.wrap(u),s.off("change").on("change",function(){e.action(this,l)})})},s.prototype.action=function(e,i){var o=this,s=o.options,u=e.value,l=a(e),p=l.attr("lay-ext")||s.ext||"";if(u){switch(i){case"file":if(p&&!RegExp("\\w\\.("+p+")$","i").test(escape(u)))return t.msg("不支持该文件格式",r),e.value="";break;case"video":if(!RegExp("\\w\\.("+(p||"avi|mp4|wma|rmvb|rm|flash|3gp|flv")+")$","i").test(escape(u)))return t.msg("不支持该视频格式",r),e.value="";break;case"audio":if(!RegExp("\\w\\.("+(p||"mp3|wav|mid")+")$","i").test(escape(u)))return t.msg("不支持该音频格式",r),e.value="";break;default:if(!RegExp("\\w\\.("+(p||"jpg|png|gif|bmp|jpeg")+")$","i").test(escape(u)))return t.msg("不支持该图片格式",r),e.value=""}s.before&&s.before(e),l.parent().submit();var c=a("#"+n),f=setInterval(function(){var a;try{a=c.contents().find("body").text()}catch(i){t.msg("上传接口存在跨域",r),clearInterval(f)}if(a){clearInterval(f),c.contents().find("body").html("");try{a=JSON.parse(a)}catch(i){return a={},t.msg("请对上传接口返回JSON字符",r)}"function"==typeof s.success&&s.success(a,e)}},30);e.value=""}},e("upload",function(e){var a=new s(e=e||{});a.init()})});

View File

@ -1,2 +1,2 @@
/** layui-v1.0.3 LGPL license By www.layui.com */
/** layui-v1.0.4 LGPL license By www.layui.com */
;layui.define("jquery",function(l){"use strict";var o=layui.jquery,i={fixbar:function(l){l=l||{},l.bgcolor=l.bgcolor?"background-color:"+l.bgcolor:"";var i,a,c="layui-fixbar-top",t=[l.bar1===!0?"&#xe606;":l.bar1,l.bar2===!0?"&#xe607;":l.bar2,"&#xe604;"],r=o(['<ul class="layui-fixbar">',l.bar1?'<li class="layui-icon" lay-type="bar1" style="'+l.bgcolor+'">'+t[0]+"</li>":"",l.bar2?'<li class="layui-icon" lay-type="bar2" style="'+l.bgcolor+'">'+t[1]+"</li>":"",'<li class="layui-icon '+c+'" lay-type="top" style="'+l.bgcolor+'">'+t[2]+"</li>","</ul>"].join("")),e=r.find("."+c),s=function(){var i=o(document).scrollTop();i>=(l.showHeight||200)?a||(e.show(),a=1):a&&(e.hide(),a=0)};o(".layui-fixbar")[0]||("object"==typeof l.css&&r.css(l.css),o("body").append(r),s(),r.find("li").on("click",function(){var i=o(this),a=i.attr("lay-type");"top"===a&&o("html,body").animate({scrollTop:0},200),l.click&&l.click.call(this,a)}),o(document).on("scroll",function(){i&&clearTimeout(i),i=setTimeout(function(){s()},100)}))}};l("util",i)});

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "layui",
"version": "1.0.3",
"version": "1.0.4",
"description": "经典模块化前端框架",
"main": "layui.js",
"license": "LGPL",

View File

@ -74,8 +74,8 @@ a cite{font-style: normal; *cursor:pointer;}
.layui-side-scroll{width: 220px; height: 100%; overflow-x: hidden;}
.layui-body{position: absolute; left: 200px; right: 0; top: 0; bottom: 0; z-index: 998; width: auto; overflow: hidden; overflow-y: auto; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;}
/* 后台布局风格 */.layui-layout-admin .layui-header{border-bottom: 5px solid #5FB878;}
.layui-layout-admin .layui-side{top: 65px; width: 200px; overflow-x: hidden;}
/* 后台布局风格 */.layui-layout-admin .layui-header{border-bottom: 5px solid #1AA094;}
.layui-layout-admin .layui-side{top: 70px; width: 200px; overflow-x: hidden;}
.layui-layout-admin .layui-body{top: 70px; bottom: 44px;}
.layui-layout-admin .layui-main{width: auto; margin: 0 15px;}
.layui-layout-admin .layui-footer{position: fixed; left: 200px; right: 0; bottom: 0; height: 44px; background-color: #eee;}
@ -158,11 +158,15 @@ a cite{font-style: normal; *cursor:pointer;}
.layui-form-select dl dd:hover{background-color: #f2f2f2;}
.layui-form-select .layui-select-group dd{padding-left: 20px;}
.layui-form-select dl dd.layui-this{background-color: #5FB878; color: #fff;}
.layui-form-select dl dd.layui-disabled{background-color: #fff;}
.layui-form-selected dl{display: block;}
.layui-form-selected .layui-edge{margin-top: -9px; -webkit-transform:rotate(180deg); transform: rotate(180deg);}
.layui-form-selected .layui-edge{margin-top: -3px\0; }
:root .layui-form-selected .layui-edge{margin-top: -9px\0/IE9;}
.layui-select-disabled .layui-disabled{border-color: #eee !important;}
.layui-select-disabled .layui-edge{border-top-color: #d2d2d2}
/* 复选框 */.layui-form-checkbox{position: relative; display: inline-block; vertical-align: middle; height: 30px; line-height: 28px; margin: 4px 10px 0 0; padding-right: 30px; border: 1px solid #d2d2d2; background-color: #fff; cursor: pointer; font-size: 0; border-radius: 2px; -webkit-transition: .1s linear; transition: .1s linear; box-sizing: border-box !important;}
.layui-form-checkbox:hover{border: 1px solid #c2c2c2;}
.layui-form-checkbox *{display: inline-block; vertical-align: middle;}
@ -180,12 +184,17 @@ a cite{font-style: normal; *cursor:pointer;}
.layui-form-onswitch:before{content: 'ON'; color: #fff;}
.layui-form-onswitch i{left: 30px; background-color: #fff;}
.layui-checkbox-disbaled{border-color: #e2e2e2 !important;}
.layui-checkbox-disbaled span{background-color: #e2e2e2 !important;}
.layui-checkbox-disbaled:hover i{color: #fff !important;}
/* 单选框 */
.layui-form-radio{display: inline-block; vertical-align: middle; line-height: 28px; margin: 6px 10px 0 0; padding-right: 10px; cursor: pointer; font-size: 0;}
.layui-form-radio *{display: inline-block; vertical-align: middle;}
.layui-form-radio i{margin-right: 8px; font-size: 22px; color: #c2c2c2;}
.layui-form-radio span{font-size: 14px;}
.layui-form-radioed i,.layui-form-radio i:hover{color: #5FB878;}
.layui-radio-disbaled i{color: #e2e2e2 !important;}
/* 表单方框风格 */.layui-form-pane .layui-form-label{width: 80px; padding: 8px 15px; line-height: 20px; border: 1px solid #e6e6e6; border-radius: 2px 0 0 2px; text-align: center; background-color: #FBFBFB; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;}
.layui-form-pane .layui-input-inline{margin-left: -1px;}
@ -261,13 +270,13 @@ a cite{font-style: normal; *cursor:pointer;}
.layui-flow-more a i{font-size: 30px; color: #737383;}
/** 分页 **/
.layui-laypage{display: inline-block; vertical-align: middle; margin: 10px 0; background-color: #fff; font-size: 0;}
.layui-laypage{display: inline-block; *display: block; *zoom: 1; vertical-align: middle; margin: 10px 0; background-color: #fff; font-size: 0;}
.layui-laypage>*:first-child,
.layui-laypage>*:first-child em{border-radius: 2px 0 0 2px;}
.layui-laypage>*:last-child,
.layui-laypage>*:last-child em{border-radius: 0 2px 2px 0;}
.layui-laypage span,
.layui-laypage a{display: inline-block; vertical-align: middle; padding: 0 15px; border: 1px solid #e2e2e2; height: 28px; line-height: 28px; margin: 0 -1px -1px 0; color: #333; font-size: 12px;}
.layui-laypage a{display: inline-block; *display: block; *zoom: 1; vertical-align: middle; padding: 0 15px; border: 1px solid #e2e2e2; height: 28px; line-height: 28px; margin: 0 -1px 5px 0; color: #333; font-size: 12px;}
.layui-laypage em{font-style: normal;}
.layui-laypage span{color:#999; font-weight: 700;}
.layui-laypage a{ text-decoration: none;}

View File

@ -31,104 +31,124 @@ layui.define('jquery', function(exports){
return layui.onevent(MOD_NAME, events, callback);
};
//初始化元素操作
Element.prototype.init = function(type){
var that = this, call = {
//Tab点击
tabClick: function(e, index){
var othis = $(this)
,index = index || othis.index()
,parents = othis.parents('.layui-tab')
,item = parents.children('.layui-tab-content').children('.layui-tab-item')
,filter = parents.attr('lay-filter');
othis.addClass(THIS).siblings().removeClass(THIS);
item.eq(index).addClass(SHOW).siblings().removeClass(SHOW);
layui.event.call(this, MOD_NAME, 'tab('+ filter +')', {
elem: parents
,index: index
});
}
//Tab自适应
,tabAuto: function(){
var SCROLL = 'layui-tab-scroll', MORE = 'layui-tab-more', BAR = 'layui-tab-bar'
, CLOSE = 'layui-tab-close', that = this;
$('.layui-tab').each(function(){
var othis = $(this)
,title = othis.children('.layui-tab-title')
,item = othis.children('.layui-tab-content').children('.layui-tab-item')
,STOPE = 'lay-stope="tabmore"'
,span = $('<span class="layui-unselect layui-tab-bar" '+ STOPE +'><i '+ STOPE +' class="layui-icon">&#xe61a;</i></span>');
if(that === window && device.ie != 8){
call.hideTabMore(true)
}
//允许关闭
if(othis.attr('lay-allowClose')){
if(!title.find('li').find('.'+CLOSE)[0]){
var close = $('<i class="layui-icon layui-unselect '+ CLOSE +'">&#x1006;</i>');
close.on('click', function(){
var li = $(this).parent(), index = li.index();
var parents = li.parents('.layui-tab');
var item = parents.children('.layui-tab-content').children('.layui-tab-item')
if(li.hasClass(THIS)){
if(li.next()[0]){
call.tabClick.call(li.next()[0], {}, index + 1);
} else if(li.prev()[0]){
call.tabClick.call(li.prev()[0], {}, index - 1);
}
}
li.remove();
item.eq(index).remove();
});
title.find('li').append(close);
}
}
if(title.prop('scrollWidth') > title.outerWidth()+1){
if(title.find('.'+BAR)[0]) return;
title.append(span);
span.on('click', function(e){
title[this.title ? 'removeClass' : 'addClass'](MORE);
this.title = this.title ? '' : '收缩';
});
} else {
title.find('.'+BAR).remove();
}
});
}
//隐藏更多Tab
,hideTabMore: function(e){
var tsbTitle = $('.layui-tab-title');
if(e === true || e.target.getAttribute('lay-stope') !== 'tabmore'){
tsbTitle.removeClass('layui-tab-more');
tsbTitle.find('.layui-tab-bar').attr('title','');
//外部Tab新增
Element.prototype.tabAdd = function(filter, options){
var tabElem = $('.layui-tab[lay-filter='+ filter +']')
,titElem = tabElem.children('.layui-tab-title')
,contElem = tabElem.children('.layui-tab-content');
titElem.append('<li>'+ (options.title||'unnaming') +'</li>');
contElem.append('<div class="layui-tab-item">'+ (options.content||'') +'</div>');
return this.init();
};
//外部Tab删除
Element.prototype.tabDelete = function(filter, index){
var tabElem = $('.layui-tab[lay-filter='+ filter +']')
,liElem = tabElem.children('.layui-tab-title').find('>li').eq(index);
call.tabDelete(null, liElem);
return this;
};
//外部Tab切换
Element.prototype.tabChange = function(filter, index){
var tabElem = $('.layui-tab[lay-filter='+ filter +']')
,liElem = tabElem.children('.layui-tab-title').find('>li').eq(index);
call.tabClick(null, index, liElem);
return this;
};
//基础事件体
var call = {
//Tab点击
tabClick: function(e, index, liElem){
var othis = liElem || $(this)
,index = index || othis.index()
,parents = othis.parents('.layui-tab')
,item = parents.children('.layui-tab-content').children('.layui-tab-item')
,filter = parents.attr('lay-filter');
othis.addClass(THIS).siblings().removeClass(THIS);
item.eq(index).addClass(SHOW).siblings().removeClass(SHOW);
layui.event.call(this, MOD_NAME, 'tab('+ filter +')', {
elem: parents
,index: index
});
}
//Tab删除
,tabDelete: function(e, othis){
var li = othis || $(this).parent(), index = li.index();
var parents = li.parents('.layui-tab');
var item = parents.children('.layui-tab-content').children('.layui-tab-item')
if(li.hasClass(THIS)){
if(li.next()[0]){
call.tabClick.call(li.next()[0], null, index + 1);
} else if(li.prev()[0]){
call.tabClick.call(li.prev()[0], null, index - 1);
}
}
li.remove();
item.eq(index).remove();
}
,items = {
//Tab自适应
,tabAuto: function(){
var SCROLL = 'layui-tab-scroll', MORE = 'layui-tab-more', BAR = 'layui-tab-bar'
, CLOSE = 'layui-tab-close', that = this;
$('.layui-tab').each(function(){
var othis = $(this)
,title = othis.children('.layui-tab-title')
,item = othis.children('.layui-tab-content').children('.layui-tab-item')
,STOPE = 'lay-stope="tabmore"'
,span = $('<span class="layui-unselect layui-tab-bar" '+ STOPE +'><i '+ STOPE +' class="layui-icon">&#xe61a;</i></span>');
if(that === window && device.ie != 8){
call.hideTabMore(true)
}
//允许关闭
if(othis.attr('lay-allowClose')){
if(!title.find('li').find('.'+CLOSE)[0]){
var close = $('<i class="layui-icon layui-unselect '+ CLOSE +'">&#x1006;</i>');
close.on('click', call.tabDelete);
title.find('li').append(close);
}
}
if(title.prop('scrollWidth') > title.outerWidth()+1){
if(title.find('.'+BAR)[0]) return;
title.append(span);
span.on('click', function(e){
title[this.title ? 'removeClass' : 'addClass'](MORE);
this.title = this.title ? '' : '收缩';
});
} else {
title.find('.'+BAR).remove();
}
});
}
//隐藏更多Tab
,hideTabMore: function(e){
var tsbTitle = $('.layui-tab-title');
if(e === true || $(e.target).attr('lay-stope') !== 'tabmore'){
tsbTitle.removeClass('layui-tab-more');
tsbTitle.find('.layui-tab-bar').attr('title','');
}
}
};
//初始化元素操作
Element.prototype.init = function(type){
var that = this, items = {
//Tab选项卡
tab: function(){
var TITLE = '.layui-tab-title li';
call.tabAuto.call({});
//Tab切换
dom.off('click', TITLE, call.tabClick)
.on('click', TITLE, call.tabClick);
//自适应
$(window).off('resize', call.tabAuto)
.on('resize', call.tabAuto);
//隐藏展开的Tab
dom.off('click', call.hideTabMore)
.on('click', call.hideTabMore);
}
//导航菜单
,nav: function(){
var ELEM = '.layui-nav', ITEM = 'layui-nav-item', BAR = 'layui-nav-bar'
@ -154,7 +174,7 @@ layui.define('jquery', function(exports){
width: othis.width()
,opacity: 1
});
}, TIME);
}, device.ie && device.ie < 10 ? 0 : TIME);
clearTimeout(timeEnd);
if(child.css('display') === 'block'){
@ -173,7 +193,7 @@ layui.define('jquery', function(exports){
,itemElem = othis.find('.'+ITEM);
//Hover滑动效果
if(!othis.find('.'+BAR)[0] && !(device.ie && device.ie < 10)){
if(!othis.find('.'+BAR)[0]){
othis.append(bar);
itemElem.on('mouseenter', function(){
follow.call(this, bar, othis);
@ -233,9 +253,10 @@ layui.define('jquery', function(exports){
var othis = $(this)
,separator = othis.attr('lay-separator') || '>'
,aNode = othis.find('a');
if(aNode.find('.layui-box')[0]) return;
aNode.each(function(index){
if(index === aNode.length - 1) return;
$(this).append('<span>'+ separator +'</span>');
$(this).append('<span class="layui-box">'+ separator +'</span>');
});
othis.css('visibility', 'visible');
});
@ -247,10 +268,14 @@ layui.define('jquery', function(exports){
});
};
var element = new Element(), dom = $(document);
element.init();
var TITLE = '.layui-tab-title li';
dom.on('click', TITLE, call.tabClick); //Tab切换
dom.on('click', call.hideTabMore); //隐藏展开的Tab
$(window).on('resize', call.tabAuto); //自适应
exports(MOD_NAME, function(options){
return element.set(options);
});

View File

@ -14,7 +14,7 @@ layui.define('layer', function(exports){
,hint = layui.hint()
,device = layui.device()
,MOD_NAME = 'form', ELEM = '.layui-form', THIS = 'layui-this', SHOW = 'layui-show'
,MOD_NAME = 'form', ELEM = '.layui-form', THIS = 'layui-this', SHOW = 'layui-show', DISABLED = 'layui-disabled'
,Form = function(){
this.config = {
@ -83,9 +83,11 @@ layui.define('layer', function(exports){
}
}
,events = function(reElem){
,events = function(reElem, disabled){
var select = $(this), title = reElem.find('.' + TITLE);
if(disabled) return;
//展开下拉
title.on('click', function(e){
reElem.hasClass(CLASS+'ed') ? reElem.removeClass(CLASS+'ed') : (
@ -98,6 +100,8 @@ layui.define('layer', function(exports){
reElem.find('dl>dd').on('click', function(){
var othis = $(this), value = othis.attr('lay-value');
var filter = select.attr('lay-filter'); //获取过滤器
if(othis.hasClass(DISABLED)) return false;
select.val(value).removeClass('layui-form-danger'), title.find('input').val(othis.text());
othis.addClass(THIS).siblings().removeClass(THIS);
@ -108,7 +112,7 @@ layui.define('layer', function(exports){
});
reElem.find('dl>dt').on('click', function(e){
layui.stope(e);
return false;
});
//关闭下拉
@ -116,12 +120,12 @@ layui.define('layer', function(exports){
}
selects.each(function(index, select){
var othis = $(this), hasRender = othis.next('.'+CLASS);
var othis = $(this), hasRender = othis.next('.'+CLASS), disabled = this.disabled;
var value = select.value, selected = $(select.options[select.selectedIndex]); //获取当前选中项
//替代元素
var reElem = $(['<div class="layui-unselect '+ CLASS +'">'
,'<div class="'+ TITLE +'"><input type="text" placeholder="'+ (select.options[0].innerHTML ? select.options[0].innerHTML : TIPS) +'" value="'+ (value ? selected.html() : '') +'" readonly class="layui-input layui-unselect">'
var reElem = $(['<div class="layui-unselect '+ CLASS + (disabled ? ' layui-select-disabled' : '') +'">'
,'<div class="'+ TITLE +'"><input type="text" placeholder="'+ (select.options[0].innerHTML ? select.options[0].innerHTML : TIPS) +'" value="'+ (value ? selected.html() : '') +'" readonly class="layui-input layui-unselect'+ (disabled ? (' '+DISABLED) : '') +'">'
,'<i class="layui-edge"></i></div>'
,'<dl class="layui-anim layui-anim-upbit'+ (othis.find('optgroup')[0] ? ' layui-select-group' : '') +'">'+ function(options){
var arr = [];
@ -130,9 +134,7 @@ layui.define('layer', function(exports){
if(item.tagName.toLowerCase() === 'optgroup'){
arr.push('<dt>'+ item.label +'</dt>');
} else {
arr.push('<dd lay-value="'+ item.value +'" '+ (value === item.value
? 'class="'+ THIS +'"'
: '')+'>'+ item.innerHTML +'</dd>');
arr.push('<dd lay-value="'+ item.value +'" class="'+ (value === item.value ? THIS : '') + (item.disabled ? (' '+DISABLED) : '') +'">'+ item.innerHTML +'</dd>');
}
});
return arr.join('');
@ -141,7 +143,7 @@ layui.define('layer', function(exports){
hasRender[0] && hasRender.remove(); //如果已经渲染则Rerender
othis.after(reElem);
events.call(this, reElem);
events.call(this, reElem, disabled);
});
}
//复选框/开关
@ -158,6 +160,9 @@ layui.define('layer', function(exports){
//勾选
reElem.on('click', function(){
var filter = check.attr('lay-filter'); //获取过滤器
if(check[0].disabled) return;
check[0].checked ? (
check[0].checked = false
,reElem.removeClass(RE_CLASS[1])
@ -173,14 +178,14 @@ layui.define('layer', function(exports){
}
checks.each(function(index, check){
var othis = $(this), skin = othis.attr('lay-skin');
var othis = $(this), skin = othis.attr('lay-skin'), disabled = this.disabled;
if(skin === 'switch') skin = '_'+skin;
var RE_CLASS = CLASS[skin] || CLASS.checkbox;
//替代元素
var hasRender = othis.next('.' + RE_CLASS[0]);
var reElem = $(['<div class="layui-unselect '+ RE_CLASS[0] + (
check.checked ? (' '+RE_CLASS[1]) : '') +'">'
check.checked ? (' '+RE_CLASS[1]) : '') + (disabled ? ' layui-checkbox-disbaled '+DISABLED : '') +'">'
,{
_switch: '<i></i>'
}[skin] || ('<span>'+ (check.title || '勾选') +'</span><i class="layui-icon">&#xe618;</i>')
@ -202,7 +207,9 @@ layui.define('layer', function(exports){
reElem.on('click', function(){
var name = radio[0].name, forms = radio.parents(ELEM);
var filter = radio.attr('lay-filter'); //获取过滤器
var sameRadio = forms.find('input[name='+ name +']'); //找到相同name的兄弟
var sameRadio = forms.find('input[name='+ name.replace(/(\.|#|\[|\])/g, '\\$1') +']'); //找到相同name的兄弟
if(radio[0].disabled) return;
layui.each(sameRadio, function(){
var next = $(this).next('.'+CLASS);
@ -223,10 +230,10 @@ layui.define('layer', function(exports){
};
radios.each(function(index, radio){
var othis = $(this), hasRender = othis.next('.' + CLASS);
var othis = $(this), hasRender = othis.next('.' + CLASS), disabled = this.disabled;
//替代元素
var reElem = $(['<div class="layui-unselect '+ CLASS + (radio.checked ? (' '+CLASS+'ed') : '') +'">'
var reElem = $(['<div class="layui-unselect '+ CLASS + (radio.checked ? (' '+CLASS+'ed') : '') + (disabled ? ' layui-radio-disbaled '+DISABLED : '') +'">'
,'<i class="layui-anim layui-icon">'+ ICON[radio.checked ? 0 : 1] +'</i>'
,'<span>'+ (radio.title||'未命名') +'</span>'
,'</div>'].join(''));

View File

@ -13,7 +13,7 @@
"use strict";
var Lay = function(){
this.v = '1.0.3'; //版本号
this.v = '1.0.4'; //版本号
};
Lay.fn = Lay.prototype;

View File

@ -97,7 +97,7 @@ body{padding: 10px;}
<br><br>
<div class="layui-tab">
<div class="layui-tab" lay-filter="tabDemo">
<ul class="layui-tab-title">
<li class="layui-this">标题1</li>
<li>标题2</li>
@ -106,7 +106,12 @@ body{padding: 10px;}
<li>标题5</li>
</ul>
<div class="layui-tab-content">
<div class="layui-tab-item layui-show">1</div>
<div class="layui-tab-item layui-show">
1
<br><button class="layui-btn" onclick="layui.element().tabChange('tabDemo', 2)">手工切换到第三项</button>
<button class="layui-btn" onclick="layui.element().tabAdd('tabDemo', {title:'新标题', content:'新内容'})">添加Tab</button>
<button class="layui-btn" onclick="layui.element().tabDelete('tabDemo', 3)">删除第四项</button>
</div>
<div class="layui-tab-item">2</div>
<div class="layui-tab-item">3</div>
<div class="layui-tab-item">4</div>
@ -146,7 +151,7 @@ body{padding: 10px;}
</div>
</div>
<div class="layui-tab" lay-filter="test">
<div class="layui-tab" lay-filter="test" lay-allowClose="true">
<ul class="layui-tab-title">
<li class="layui-this">标题1</li>
<li>标题2</li>

View File

@ -56,7 +56,7 @@ body{padding: 10px;}
<select name="quiz">
<option value="">请选择问题</option>
<option value="你工作的第一个城市">你工作的第一个城市</option>
<option value="你的工号">你的工号</option>
<option value="你的工号" disabled>你的工号</option>
<option value="你最喜欢的老师">你最喜欢的老师</option>
</select>
</div>
@ -70,7 +70,7 @@ body{padding: 10px;}
<option value="你工作的第一个城市">你工作的第一个城市</option>
</optgroup>
<optgroup label="学生时代">
<option value="你的工号">你的工号</option>
<option value="你的工号" disabled>你的工号</option>
<option value="你最喜欢的老师">你最喜欢的老师</option>
</optgroup>
</select>
@ -95,13 +95,13 @@ body{padding: 10px;}
<div class="layui-input-block">
<input type="checkbox" name="like[write]" title="写作">
<input type="checkbox" name="like[read]" title="阅读">
<input type="checkbox" name="like[game]" title="游戏">
<input type="checkbox" name="like[game]" title="游戏" disabled>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">开关关</label>
<div class="layui-input-block">
<input type="checkbox" name="close" lay-skin="switch" title="开关">
<input type="checkbox" name="close" lay-skin="switch" title="开关" disabled>
</div>
</div>
<div class="layui-form-item">
@ -115,7 +115,15 @@ body{padding: 10px;}
<div class="layui-input-block">
<input type="radio" name="sex" value="男" title="男">
<input type="radio" name="sex" value="女" title="女" checked>
<input type="radio" name="sex" value="中型" title="中">
<input type="radio" name="sex" value="中型" title="中" disabled>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">单选框</label>
<div class="layui-input-block">
<input type="radio" name="sex.id" value="男" title="男">
<input type="radio" name="sex.id" value="女" title="女" checked>
<input type="radio" name="sex.id" value="中型" title="中">
</div>
</div>
<div class="layui-form-item layui-form-text">
@ -242,10 +250,16 @@ layui.use('form', function(){
<form id="test">
<input type="radio" value="girl">
<input type="radio" value="girl" disabled>
<input type="checkbox" name="love[a]">
<input type="checkbox" name="love[b]">
<input value="1">
<select name="quiz">
<option value="">请选择问题</option>
<option disabled value="你工作的第一个城市">你工作的第一个城市</option>
<option value="你的工号">你的工号</option>
<option value="你最喜欢的老师">你最喜欢的老师</option>
</select>
<button>go</button>
</form>
<script>