Browse Source

发版

pull/485/head v2.5.2
贤心 6 years ago
parent
commit
aee36d31bd
  1. 2
      bower.json
  2. 4
      dist/css/layui.css
  3. 2
      dist/css/layui.mobile.css
  4. 2
      dist/css/modules/code.css
  5. 2
      dist/css/modules/laydate/default/laydate.css
  6. 2
      dist/css/modules/layer/default/layer.css
  7. 2
      dist/lay/modules/carousel.js
  8. 2
      dist/lay/modules/code.js
  9. 2
      dist/lay/modules/colorpicker.js
  10. 2
      dist/lay/modules/element.js
  11. 2
      dist/lay/modules/flow.js
  12. 2
      dist/lay/modules/form.js
  13. 2
      dist/lay/modules/jquery.js
  14. 2
      dist/lay/modules/laydate.js
  15. 2
      dist/lay/modules/layedit.js
  16. 2
      dist/lay/modules/layer.js
  17. 2
      dist/lay/modules/laypage.js
  18. 2
      dist/lay/modules/laytpl.js
  19. 2
      dist/lay/modules/mobile.js
  20. 2
      dist/lay/modules/rate.js
  21. 2
      dist/lay/modules/slider.js
  22. 4
      dist/lay/modules/table.js
  23. 4
      dist/lay/modules/transfer.js
  24. 2
      dist/lay/modules/tree.js
  25. 2
      dist/lay/modules/upload.js
  26. 2
      dist/lay/modules/util.js
  27. 6
      dist/layui.all.js
  28. 4
      dist/layui.js
  29. 143
      examples/extends/temp.js
  30. 2
      examples/table.html
  31. 80
      examples/transfer.html
  32. 2
      package.json
  33. 43
      src/css/layui.css
  34. 41
      src/lay/modules/table.js
  35. 690
      src/lay/modules/transfer.js
  36. 2
      src/layui.js

2
bower.json

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

4
dist/css/layui.css vendored

File diff suppressed because one or more lines are too long

2
dist/css/layui.mobile.css vendored

File diff suppressed because one or more lines are too long

2
dist/css/modules/code.css vendored

@ -1,2 +1,2 @@
/** layui-v2.5.1 MIT License By https://www.layui.com */
/** layui-v2.5.2 MIT License By https://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 #e2e2e2;border-left-width:6px;background-color:#F2F2F2;color:#333;font-family:Courier New}.layui-code-h3{padding:0 10px;height:32px;line-height:32px;border-bottom:1px solid #e2e2e2}.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 #e2e2e2;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}

2
dist/css/modules/laydate/default/laydate.css vendored

File diff suppressed because one or more lines are too long

2
dist/css/modules/layer/default/layer.css vendored

File diff suppressed because one or more lines are too long

2
dist/lay/modules/carousel.js vendored

@ -1,2 +1,2 @@
/** layui-v2.5.1 MIT License By https://www.layui.com */
/** layui-v2.5.2 MIT License By https://www.layui.com */
;layui.define("jquery",function(e){"use strict";var i=layui.$,n=(layui.hint(),layui.device(),{config:{},set:function(e){var n=this;return n.config=i.extend({},n.config,e),n},on:function(e,i){return layui.onevent.call(this,t,e,i)}}),t="carousel",a="layui-this",l=">*[carousel-item]>*",o="layui-carousel-left",r="layui-carousel-right",d="layui-carousel-prev",s="layui-carousel-next",u="layui-carousel-arrow",c="layui-carousel-ind",m=function(e){var t=this;t.config=i.extend({},t.config,n.config,e),t.render()};m.prototype.config={width:"600px",height:"280px",full:!1,arrow:"hover",indicator:"inside",autoplay:!0,interval:3e3,anim:"",trigger:"click",index:0},m.prototype.render=function(){var e=this,n=e.config;n.elem=i(n.elem),n.elem[0]&&(e.elemItem=n.elem.find(l),n.index<0&&(n.index=0),n.index>=e.elemItem.length&&(n.index=e.elemItem.length-1),n.interval<800&&(n.interval=800),n.full?n.elem.css({position:"fixed",width:"100%",height:"100%",zIndex:9999}):n.elem.css({width:n.width,height:n.height}),n.elem.attr("lay-anim",n.anim),e.elemItem.eq(n.index).addClass(a),e.elemItem.length<=1||(e.indicator(),e.arrow(),e.autoplay(),e.events()))},m.prototype.reload=function(e){var n=this;clearInterval(n.timer),n.config=i.extend({},n.config,e),n.render()},m.prototype.prevIndex=function(){var e=this,i=e.config,n=i.index-1;return n<0&&(n=e.elemItem.length-1),n},m.prototype.nextIndex=function(){var e=this,i=e.config,n=i.index+1;return n>=e.elemItem.length&&(n=0),n},m.prototype.addIndex=function(e){var i=this,n=i.config;e=e||1,n.index=n.index+e,n.index>=i.elemItem.length&&(n.index=0)},m.prototype.subIndex=function(e){var i=this,n=i.config;e=e||1,n.index=n.index-e,n.index<0&&(n.index=i.elemItem.length-1)},m.prototype.autoplay=function(){var e=this,i=e.config;i.autoplay&&(clearInterval(e.timer),e.timer=setInterval(function(){e.slide()},i.interval))},m.prototype.arrow=function(){var e=this,n=e.config,t=i(['<button class="layui-icon '+u+'" lay-type="sub">'+("updown"===n.anim?"&#xe619;":"&#xe603;")+"</button>",'<button class="layui-icon '+u+'" lay-type="add">'+("updown"===n.anim?"&#xe61a;":"&#xe602;")+"</button>"].join(""));n.elem.attr("lay-arrow",n.arrow),n.elem.find("."+u)[0]&&n.elem.find("."+u).remove(),n.elem.append(t),t.on("click",function(){var n=i(this),t=n.attr("lay-type");e.slide(t)})},m.prototype.indicator=function(){var e=this,n=e.config,t=e.elemInd=i(['<div class="'+c+'"><ul>',function(){var i=[];return layui.each(e.elemItem,function(e){i.push("<li"+(n.index===e?' class="layui-this"':"")+"></li>")}),i.join("")}(),"</ul></div>"].join(""));n.elem.attr("lay-indicator",n.indicator),n.elem.find("."+c)[0]&&n.elem.find("."+c).remove(),n.elem.append(t),"updown"===n.anim&&t.css("margin-top",-(t.height()/2)),t.find("li").on("hover"===n.trigger?"mouseover":n.trigger,function(){var t=i(this),a=t.index();a>n.index?e.slide("add",a-n.index):a<n.index&&e.slide("sub",n.index-a)})},m.prototype.slide=function(e,i){var n=this,l=n.elemItem,u=n.config,c=u.index,m=u.elem.attr("lay-filter");n.haveSlide||("sub"===e?(n.subIndex(i),l.eq(u.index).addClass(d),setTimeout(function(){l.eq(c).addClass(r),l.eq(u.index).addClass(r)},50)):(n.addIndex(i),l.eq(u.index).addClass(s),setTimeout(function(){l.eq(c).addClass(o),l.eq(u.index).addClass(o)},50)),setTimeout(function(){l.removeClass(a+" "+d+" "+s+" "+o+" "+r),l.eq(u.index).addClass(a),n.haveSlide=!1},300),n.elemInd.find("li").eq(u.index).addClass(a).siblings().removeClass(a),n.haveSlide=!0,layui.event.call(this,t,"change("+m+")",{index:u.index,prevIndex:c,item:l.eq(u.index)}))},m.prototype.events=function(){var e=this,i=e.config;i.elem.data("haveEvents")||(i.elem.on("mouseenter",function(){clearInterval(e.timer)}).on("mouseleave",function(){e.autoplay()}),i.elem.data("haveEvents",!0))},n.render=function(e){var i=new m(e);return i},e(t,n)});

2
dist/lay/modules/code.js vendored

@ -1,2 +1,2 @@
/** layui-v2.5.1 MIT License By https://www.layui.com */
/** layui-v2.5.2 MIT License By https://www.layui.com */
;layui.define("jquery",function(e){"use strict";var a=layui.$,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");

2
dist/lay/modules/colorpicker.js vendored

File diff suppressed because one or more lines are too long

2
dist/lay/modules/element.js vendored

File diff suppressed because one or more lines are too long

2
dist/lay/modules/flow.js vendored

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

2
dist/lay/modules/form.js vendored

File diff suppressed because one or more lines are too long

2
dist/lay/modules/jquery.js vendored

File diff suppressed because one or more lines are too long

2
dist/lay/modules/laydate.js vendored

File diff suppressed because one or more lines are too long

2
dist/lay/modules/layedit.js vendored

File diff suppressed because one or more lines are too long

2
dist/lay/modules/layer.js vendored

File diff suppressed because one or more lines are too long

2
dist/lay/modules/laypage.js vendored

@ -1,2 +1,2 @@
/** layui-v2.5.1 MIT License By https://www.layui.com */
/** layui-v2.5.2 MIT License By https://www.layui.com */
;layui.define(function(e){"use strict";var a=document,t="getElementById",n="getElementsByTagName",i="laypage",r="layui-disabled",u=function(e){var a=this;a.config=e||{},a.config.index=++s.index,a.render(!0)};u.prototype.type=function(){var e=this.config;if("object"==typeof e.elem)return void 0===e.elem.length?2:3},u.prototype.view=function(){var e=this,a=e.config,t=a.groups="groups"in a?0|a.groups:5;a.layout="object"==typeof a.layout?a.layout:["prev","page","next"],a.count=0|a.count,a.curr=0|a.curr||1,a.limits="object"==typeof a.limits?a.limits:[10,20,30,40,50],a.limit=0|a.limit||10,a.pages=Math.ceil(a.count/a.limit)||1,a.curr>a.pages&&(a.curr=a.pages),t<0?t=1:t>a.pages&&(t=a.pages),a.prev="prev"in a?a.prev:"&#x4E0A;&#x4E00;&#x9875;",a.next="next"in a?a.next:"&#x4E0B;&#x4E00;&#x9875;";var n=a.pages>t?Math.ceil((a.curr+(t>1?1:0))/(t>0?t:1)):1,i={prev:function(){return a.prev?'<a href="javascript:;" class="layui-laypage-prev'+(1==a.curr?" "+r:"")+'" data-page="'+(a.curr-1)+'">'+a.prev+"</a>":""}(),page:function(){var e=[];if(a.count<1)return"";n>1&&a.first!==!1&&0!==t&&e.push('<a href="javascript:;" class="layui-laypage-first" data-page="1" title="&#x9996;&#x9875;">'+(a.first||1)+"</a>");var i=Math.floor((t-1)/2),r=n>1?a.curr-i:1,u=n>1?function(){var e=a.curr+(t-i-1);return e>a.pages?a.pages:e}():t;for(u-r<t-1&&(r=u-t+1),a.first!==!1&&r>2&&e.push('<span class="layui-laypage-spr">&#x2026;</span>');r<=u;r++)r===a.curr?e.push('<span class="layui-laypage-curr"><em class="layui-laypage-em" '+(/^#/.test(a.theme)?'style="background-color:'+a.theme+';"':"")+"></em><em>"+r+"</em></span>"):e.push('<a href="javascript:;" data-page="'+r+'">'+r+"</a>");return a.pages>t&&a.pages>u&&a.last!==!1&&(u+1<a.pages&&e.push('<span class="layui-laypage-spr">&#x2026;</span>'),0!==t&&e.push('<a href="javascript:;" class="layui-laypage-last" title="&#x5C3E;&#x9875;" data-page="'+a.pages+'">'+(a.last||a.pages)+"</a>")),e.join("")}(),next:function(){return a.next?'<a href="javascript:;" class="layui-laypage-next'+(a.curr==a.pages?" "+r:"")+'" data-page="'+(a.curr+1)+'">'+a.next+"</a>":""}(),count:'<span class="layui-laypage-count">共 '+a.count+" 条</span>",limit:function(){var e=['<span class="layui-laypage-limits"><select lay-ignore>'];return layui.each(a.limits,function(t,n){e.push('<option value="'+n+'"'+(n===a.limit?"selected":"")+">"+n+" 条/页</option>")}),e.join("")+"</select></span>"}(),refresh:['<a href="javascript:;" data-page="'+a.curr+'" class="layui-laypage-refresh">','<i class="layui-icon layui-icon-refresh"></i>',"</a>"].join(""),skip:function(){return['<span class="layui-laypage-skip">&#x5230;&#x7B2C;','<input type="text" min="1" value="'+a.curr+'" class="layui-input">','&#x9875;<button type="button" class="layui-laypage-btn">&#x786e;&#x5b9a;</button>',"</span>"].join("")}()};return['<div class="layui-box layui-laypage layui-laypage-'+(a.theme?/^#/.test(a.theme)?"molv":a.theme:"default")+'" id="layui-laypage-'+a.index+'">',function(){var e=[];return layui.each(a.layout,function(a,t){i[t]&&e.push(i[t])}),e.join("")}(),"</div>"].join("")},u.prototype.jump=function(e,a){if(e){var t=this,i=t.config,r=e.children,u=e[n]("button")[0],l=e[n]("input")[0],p=e[n]("select")[0],c=function(){var e=0|l.value.replace(/\s|\D/g,"");e&&(i.curr=e,t.render())};if(a)return c();for(var o=0,y=r.length;o<y;o++)"a"===r[o].nodeName.toLowerCase()&&s.on(r[o],"click",function(){var e=0|this.getAttribute("data-page");e<1||e>i.pages||(i.curr=e,t.render())});p&&s.on(p,"change",function(){var e=this.value;i.curr*e>i.count&&(i.curr=Math.ceil(i.count/e)),i.limit=e,t.render()}),u&&s.on(u,"click",function(){c()})}},u.prototype.skip=function(e){if(e){var a=this,t=e[n]("input")[0];t&&s.on(t,"keyup",function(t){var n=this.value,i=t.keyCode;/^(37|38|39|40)$/.test(i)||(/\D/.test(n)&&(this.value=n.replace(/\D/,"")),13===i&&a.jump(e,!0))})}},u.prototype.render=function(e){var n=this,i=n.config,r=n.type(),u=n.view();2===r?i.elem&&(i.elem.innerHTML=u):3===r?i.elem.html(u):a[t](i.elem)&&(a[t](i.elem).innerHTML=u),i.jump&&i.jump(i,e);var s=a[t]("layui-laypage-"+i.index);n.jump(s),i.hash&&!e&&(location.hash="!"+i.hash+"="+i.curr),n.skip(s)};var s={render:function(e){var a=new u(e);return a.index},index:layui.laypage?layui.laypage.index+1e4:0,on:function(e,a,t){return e.attachEvent?e.attachEvent("on"+a,function(a){a.target=a.srcElement,t.call(e,a)}):e.addEventListener(a,t,!1),this}};e(i,s)});

2
dist/lay/modules/laytpl.js vendored

@ -1,2 +1,2 @@
/** layui-v2.5.1 MIT License By https://www.layui.com */
/** layui-v2.5.2 MIT License By https://www.layui.com */
;layui.define(function(e){"use strict";var r={open:"{{",close:"}}"},c={exp:function(e){return new RegExp(e,"g")},query:function(e,c,t){var o=["#([\\s\\S])+?","([^{#}])*?"][e||0];return n((c||"")+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 c="Laytpl Error:";return"object"==typeof console&&console.error(c+e+"\n"+(r||"")),c+e}},n=c.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=n("^"+r.open+"#",""),l=n(r.close+"$","");e=e.replace(/\s+|\r|\t|\n/g," ").replace(n(r.open+"#"),r.open+"# ").replace(n(r.close+"}"),"} "+r.close).replace(/\\/g,"\\\\").replace(n(r.open+"!(.+?)!"+r.close),function(e){return e=e.replace(n("^"+r.open+"!"),"").replace(n("!"+r.close),"").replace(n(r.open+"|"+r.close),function(e){return e.replace(/(.)/g,"\\$1")})}).replace(/(?="|')/g,"\\").replace(c.query(),function(e){return e=e.replace(a,"").replace(l,""),'";'+e.replace(/\\/g,"")+';view+="'}).replace(c.query(1),function(e){var c='"+(';return e.replace(/\s/g,"")===r.open+r.close?"":(e=e.replace(n(r.open+"|"+r.close),""),/^=/.test(e)&&(e=e.replace(/^=/,""),c='"+_escape_('),c+e.replace(/\\/g,"")+')+"')}),e='"use strict";var view = "'+e+'";return view;';try{return o.cache=e=new Function("d, _escape_",e),e(t,c.escape)}catch(u){return delete o.cache,c.error(u,p)}},t.pt.render=function(e,r){var n,t=this;return e?(n=t.cache?t.cache(e,c.escape):t.parse(t.tpl,e),r?void r(n):n):c.error("no data")};var o=function(e){return"string"!=typeof e?c.error("Template not found"):new t(e)};o.config=function(e){e=e||{};for(var c in e)r[c]=e[c]},o.v="1.2.0",e("laytpl",o)});

2
dist/lay/modules/mobile.js vendored

File diff suppressed because one or more lines are too long

2
dist/lay/modules/rate.js vendored

@ -1,2 +1,2 @@
/** layui-v2.5.1 MIT License By https://www.layui.com */
/** layui-v2.5.2 MIT License By https://www.layui.com */
;layui.define("jquery",function(e){"use strict";var a=layui.jquery,i={config:{},index:layui.rate?layui.rate.index+1e4:0,set:function(e){var i=this;return i.config=a.extend({},i.config,e),i},on:function(e,a){return layui.onevent.call(this,n,e,a)}},l=function(){var e=this,a=e.config;return{setvalue:function(a){e.setvalue.call(e,a)},config:a}},n="rate",t="layui-rate",o="layui-icon-rate",s="layui-icon-rate-solid",u="layui-icon-rate-half",r="layui-icon-rate-solid layui-icon-rate-half",c="layui-icon-rate-solid layui-icon-rate",f="layui-icon-rate layui-icon-rate-half",v=function(e){var l=this;l.index=++i.index,l.config=a.extend({},l.config,i.config,e),l.render()};v.prototype.config={length:5,text:!1,readonly:!1,half:!1,value:0,theme:""},v.prototype.render=function(){var e=this,i=e.config,l=i.theme?'style="color: '+i.theme+';"':"";i.elem=a(i.elem),parseInt(i.value)!==i.value&&(i.half||(i.value=Math.ceil(i.value)-i.value<.5?Math.ceil(i.value):Math.floor(i.value)));for(var n='<ul class="layui-rate" '+(i.readonly?"readonly":"")+">",u=1;u<=i.length;u++){var r='<li class="layui-inline"><i class="layui-icon '+(u>Math.floor(i.value)?o:s)+'" '+l+"></i></li>";i.half&&parseInt(i.value)!==i.value&&u==Math.ceil(i.value)?n=n+'<li><i class="layui-icon layui-icon-rate-half" '+l+"></i></li>":n+=r}n+="</ul>"+(i.text?'<span class="layui-inline">'+i.value+"星":"")+"</span>";var c=i.elem,f=c.next("."+t);f[0]&&f.remove(),e.elemTemp=a(n),i.span=e.elemTemp.next("span"),i.setText&&i.setText(i.value),c.html(e.elemTemp),c.addClass("layui-inline"),i.readonly||e.action()},v.prototype.setvalue=function(e){var a=this,i=a.config;i.value=e,a.render()},v.prototype.action=function(){var e=this,i=e.config,l=e.elemTemp,n=l.find("i").width();l.children("li").each(function(e){var t=e+1,v=a(this);v.on("click",function(e){if(i.value=t,i.half){var o=e.pageX-a(this).offset().left;o<=n/2&&(i.value=i.value-.5)}i.text&&l.next("span").text(i.value+"星"),i.choose&&i.choose(i.value),i.setText&&i.setText(i.value)}),v.on("mousemove",function(e){if(l.find("i").each(function(){a(this).addClass(o).removeClass(r)}),l.find("i:lt("+t+")").each(function(){a(this).addClass(s).removeClass(f)}),i.half){var c=e.pageX-a(this).offset().left;c<=n/2&&v.children("i").addClass(u).removeClass(s)}}),v.on("mouseleave",function(){l.find("i").each(function(){a(this).addClass(o).removeClass(r)}),l.find("i:lt("+Math.floor(i.value)+")").each(function(){a(this).addClass(s).removeClass(f)}),i.half&&parseInt(i.value)!==i.value&&l.children("li:eq("+Math.floor(i.value)+")").children("i").addClass(u).removeClass(c)})})},v.prototype.events=function(){var e=this;e.config},i.render=function(e){var a=new v(e);return l.call(a)},e(n,i)});

2
dist/lay/modules/slider.js vendored

File diff suppressed because one or more lines are too long

4
dist/lay/modules/table.js vendored

File diff suppressed because one or more lines are too long

4
dist/lay/modules/transfer.js vendored

File diff suppressed because one or more lines are too long

2
dist/lay/modules/tree.js vendored

File diff suppressed because one or more lines are too long

2
dist/lay/modules/upload.js vendored

File diff suppressed because one or more lines are too long

2
dist/lay/modules/util.js vendored

@ -1,2 +1,2 @@
/** layui-v2.5.1 MIT License By https://www.layui.com */
/** layui-v2.5.2 MIT License By https://www.layui.com */
;layui.define("jquery",function(t){"use strict";var e=layui.$,i={fixbar:function(t){var i,n,a="layui-fixbar",o="layui-fixbar-top",r=e(document),l=e("body");t=e.extend({showHeight:200},t),t.bar1=t.bar1===!0?"&#xe606;":t.bar1,t.bar2=t.bar2===!0?"&#xe607;":t.bar2,t.bgcolor=t.bgcolor?"background-color:"+t.bgcolor:"";var c=[t.bar1,t.bar2,"&#xe604;"],g=e(['<ul class="'+a+'">',t.bar1?'<li class="layui-icon" lay-type="bar1" style="'+t.bgcolor+'">'+c[0]+"</li>":"",t.bar2?'<li class="layui-icon" lay-type="bar2" style="'+t.bgcolor+'">'+c[1]+"</li>":"",'<li class="layui-icon '+o+'" lay-type="top" style="'+t.bgcolor+'">'+c[2]+"</li>","</ul>"].join("")),s=g.find("."+o),u=function(){var e=r.scrollTop();e>=t.showHeight?i||(s.show(),i=1):i&&(s.hide(),i=0)};e("."+a)[0]||("object"==typeof t.css&&g.css(t.css),l.append(g),u(),g.find("li").on("click",function(){var i=e(this),n=i.attr("lay-type");"top"===n&&e("html,body").animate({scrollTop:0},200),t.click&&t.click.call(this,n)}),r.on("scroll",function(){clearTimeout(n),n=setTimeout(function(){u()},100)}))},countdown:function(t,e,i){var n=this,a="function"==typeof e,o=new Date(t).getTime(),r=new Date(!e||a?(new Date).getTime():e).getTime(),l=o-r,c=[Math.floor(l/864e5),Math.floor(l/36e5)%24,Math.floor(l/6e4)%60,Math.floor(l/1e3)%60];a&&(i=e);var g=setTimeout(function(){n.countdown(t,r+1e3,i)},1e3);return i&&i(l>0?c:[0,0,0,0],e,g),l<=0&&clearTimeout(g),g},timeAgo:function(t,e){var i=this,n=[[],[]],a=(new Date).getTime()-new Date(t).getTime();return a>6912e5?(a=new Date(t),n[0][0]=i.digit(a.getFullYear(),4),n[0][1]=i.digit(a.getMonth()+1),n[0][2]=i.digit(a.getDate()),e||(n[1][0]=i.digit(a.getHours()),n[1][1]=i.digit(a.getMinutes()),n[1][2]=i.digit(a.getSeconds())),n[0].join("-")+" "+n[1].join(":")):a>=864e5?(a/1e3/60/60/24|0)+"天前":a>=36e5?(a/1e3/60/60|0)+"小时前":a>=12e4?(a/1e3/60|0)+"分钟前":a<0?"未来":"刚刚"},digit:function(t,e){var i="";t=String(t),e=e||2;for(var n=t.length;n<e;n++)i+="0";return t<Math.pow(10,e)?i+(0|t):t},toDateString:function(t,e){var i=this,n=new Date(t||new Date),a=[i.digit(n.getFullYear(),4),i.digit(n.getMonth()+1),i.digit(n.getDate())],o=[i.digit(n.getHours()),i.digit(n.getMinutes()),i.digit(n.getSeconds())];return e=e||"yyyy-MM-dd HH:mm:ss",e.replace(/yyyy/g,a[0]).replace(/MM/g,a[1]).replace(/dd/g,a[2]).replace(/HH/g,o[0]).replace(/mm/g,o[1]).replace(/ss/g,o[2])},escape:function(t){return String(t||"").replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&#39;").replace(/"/g,"&quot;")},event:function(t,n,a){n=i.event[t]=e.extend(!0,i.event[t],n)||{},e("body").on(a||"click","*["+t+"]",function(){var i=e(this),a=i.attr(t);n[a]&&n[a].call(this,i)})}};!function(t,e,i){"$:nomunge";function n(){a=e[l](function(){o.each(function(){var e=t(this),i=e.width(),n=e.height(),a=t.data(this,g);(i!==a.w||n!==a.h)&&e.trigger(c,[a.w=i,a.h=n])}),n()},r[s])}var a,o=t([]),r=t.resize=t.extend(t.resize,{}),l="setTimeout",c="resize",g=c+"-special-event",s="delay",u="throttleWindow";r[s]=250,r[u]=!0,t.event.special[c]={setup:function(){if(!r[u]&&this[l])return!1;var e=t(this);o=o.add(e),t.data(this,g,{w:e.width(),h:e.height()}),1===o.length&&n()},teardown:function(){if(!r[u]&&this[l])return!1;var e=t(this);o=o.not(e),e.removeData(g),o.length||clearTimeout(a)},add:function(e){function n(e,n,o){var r=t(this),l=t.data(this,g)||{};l.w=n!==i?n:r.width(),l.h=o!==i?o:r.height(),a.apply(this,arguments)}if(!r[u]&&this[l])return!1;var a;return t.isFunction(e)?(a=e,n):(a=e.handler,void(e.handler=n))}}}(e,window),t("util",i)});

6
dist/layui.all.js vendored

File diff suppressed because one or more lines are too long

4
dist/layui.js vendored

File diff suppressed because one or more lines are too long

143
examples/extends/temp.js

@ -0,0 +1,143 @@
/**
@Namelayui.modDemo XX组件
@Author贤心
@LicenseMIT
*/
layui.define(['laytpl'], function(exports){
"use strict";
var $ = layui.$
,laytpl = layui.laytpl
//模块名
,MOD_NAME = 'modDemo'
//外部接口
,modeDemo = {
config: {}
,index: layui[MOD_NAME] ? (layui[MOD_NAME].index + 10000) : 0
//设置全局项
,set: function(options){
var that = this;
that.config = $.extend({}, that.config, options);
return that;
}
//事件监听
,on: function(events, callback){
return layui.onevent.call(this, MOD_NAME, events, callback);
}
}
//操作当前实例
,thisModule = function(){
var that = this
,options = that.config
,id = options.id || that.index;
thisModule.that[id] = that; //记录当前实例对象
thisModule.config[id] = options; //记录当前实例配置项
return {
config: options
//重置实例
,reload: function(options){
that.reload.call(that, options);
}
}
}
//获取当前实例配置项
,getThisModuleConfig = function(id){
var config = thisModule.config[id];
if(!config) hint.error('The ID option was not found in the '+ MOD_NAME +' instance');
return config || null;
}
//字符常量
,ELEM = 'layui-modeDemo'
//主模板
,TPL_MAIN = ['<div class="ayui-border-box">'
,'</div>'].join('')
//构造器
,Class = function(options){
var that = this;
that.index = ++transfer.index;
that.config = $.extend({}, that.config, transfer.config, options);
that.render();
};
//默认配置
Class.prototype.config = {
};
//重载实例
Class.prototype.reload = function(options){
var that = this;
layui.each(options, function(key, item){
if(item.constructor === Array) delete that.config[key];
});
that.config = $.extend(true, {}, that.config, options);
that.render();
};
//渲染
Class.prototype.render = function(){
var that = this
,options = that.config;
//解析模板
that.elem = $(TPL_MAIN);
var othis = options.elem = $(options.elem);
if(!othis[0]) return;
//索引
that.key = options.id || that.index;
//插入组件结构
othis.html(that.elem);
that.events(); //事件
};
//事件
Class.prototype.events = function(){
var that = this;
};
//记录所有实例
thisModule.that = {}; //记录所有实例对象
thisModule.config = {}; //记录所有实例配置项
//重载实例
modeDemo.reload = function(id, options){
var that = thisModule.that[id];
that.reload(options);
return thisModule.call(that);
};
//核心入口
modeDemo.render = function(options){
var inst = new Class(options);
return thisTransfer.call(inst);
};
exports(MOD_NAME, modeDemo);
});

2
examples/table.html

@ -20,7 +20,7 @@ body{padding: 20px; /*overflow-y: scroll;*/}
<button class="layui-btn layui-btn-sm" lay-event="getCheckData">获取选中行数据</button>
<button class="layui-btn layui-btn-sm" lay-event="getCheckLength">获取选中数目</button>
<button class="layui-btn layui-btn-sm" lay-event="isAll">验证是否全选</button>
<button class="layui-btn layui-btn-sm" lay-event="reload">无抖重载</button>
<button class="layui-btn layui-btn-sm" lay-event="reload">重载</button>
</div>
</script>

80
examples/transfer.html

@ -7,13 +7,16 @@
<link rel="stylesheet" href="../src/css/layui.css">
<style>
body{padding-left: 200px; padding-top: 30px;}
#text1,#text2{padding-top: 80px;}
body{padding: 100px;}
#text1,#text2{padding-top: 60px;}
</style>
</head>
<body>
<button id="btn" class="layui-btn">获取右侧值</button>
<div class="layui-btn-container">
<button type="button" class="layui-btn" lay-demo="getData">获取右侧数据</button>
<button type="button" class="layui-btn" lay-demo="reload">重载实例</button>
</div>
<div id="text1"></div>
@ -24,31 +27,31 @@
<script src="../src/layui.js"></script>
<script>
layui.use('transfer', function(){
var transfer = layui.transfer
,$ = layui.$;
layui.use(['transfer', 'util'], function(){
var $ = layui.$
,transfer = layui.transfer
,util = layui.util;
var ins1 = transfer.render({
elem: '#text1'
,parseData: function(res){
return {
"value": res.status
,"title": res.label
,"disabled": res.check
}
}
,data: [{"status": "1", "label": "瓦罐汤", "check": false}
,{"status": "2", "label": "油酥饼", "check": false}
,{"status": "3", "label": "炸酱面", "check": false}
,{"status": "4", "label": "串串香", "check": true}
,{"status": "5", "label": "豆腐脑", "check": false}
,{"status": "6", "label": "驴打滚", "check": false}]
,value: ["1", "5"]
,title: ['候选文人', '获奖文人']
,data: [
{"value": "1", "title": "李白"}
,{"value": "2", "title": "杜甫"}
,{"value": "3", "title": "贤心"}
,{"value": "4", "title": "鲁迅", "disabled": true}
,{"value": "5", "title": "巴金"}
,{"value": "6", "title": "冰心"}
]
,value: ["2", "3"]
,showSearch: true
});
$("#btn").on('click', function(){
alert(JSON.stringify(ins1.getData()))
//按钮事件
util.event('lay-demo', {
getData: function(othis){
alert(JSON.stringify(ins1.getData()))
}
});
var ins2 = transfer.render({
@ -56,22 +59,23 @@
,onchange: function(obj){
console.log(obj)
}
,data: [{"value": "1", "title": "瓦罐汤", "disabled": false}
,{"value": "2", "title": "油酥饼", "disabled": false}
,{"value": "3", "title": "炸酱面", "disabled": false}
,{"value": "4", "title": "串串香", "disabled": true}
,{"value": "5", "title": "豆腐脑", "disabled": false}
,{"value": "6", "title": "驴打滚", "disabled": false}
,{"value": "7", "title": "北京烤鸭", "disabled": false}
,{"value": "8", "title": "烤冷面", "disabled": false}
,{"value": "9", "title": "毛血旺", "disabled": true}
,{"value": "10", "title": "肉夹馍", "disabled": false}
,{"value": "11", "title": "臊子面", "disabled": false}
,{"value": "12", "title": "凉皮", "disabled": false}
,{"value": "13", "title": "羊肉泡馍", "disabled": false}
,{"value": "14", "title": "冰糖葫芦", "disabled": true}
,{"value": "15", "title": "狼牙土豆", "disabled": false}]
,value: ["1", "3", "5", "7", "9", "11"]
,parseData: function(res){
return {
"value": res.id
,"title": res.label
,"disabled": res.disabled
,"checked": res.checked
}
}
,data: [
{"id": "1", "label": "瓦罐汤"}
,{"id": "2", "label": "油酥饼"}
,{"id": "3", "label": "炸酱面"}
,{"id": "4", "label": "串串香", "disabled": true}
,{"id": "5", "label": "豆腐脑"}
,{"id": "6", "label": "驴打滚"}
]
,value: ["1", "5"]
});
});
</script>

2
package.json

@ -1,7 +1,7 @@
{
"name": "layui-src",
"realname": "layui",
"version": "2.5.1",
"version": "2.5.2",
"independents": {
"layim": "3.9.0"
},

43
src/css/layui.css

@ -503,7 +503,7 @@ a cite{font-style: normal; *cursor:pointer;}
.layui-input, .layui-textarea, .layui-select,
.layui-form-pane .layui-form-label,
.layui-form-pane .layui-form-item[pane],
.layui-layedit, .layui-layedit-tool{border-color: #e6e6e6}
.layui-layedit, .layui-layedit-tool{border-color: #e6e6e6}
/* 背景边框 */
hr, .layui-timeline-item:before{background-color: #e6e6e6;}
@ -549,6 +549,7 @@ hr, .layui-timeline-item:before{background-color: #e6e6e6;}
/* 百搭 */.layui-btn-normal{background-color: #1E9FFF;}
/* 暖色 */.layui-btn-warm{background-color: #FFB800;}
/* 警告 */.layui-btn-danger{background-color: #FF5722;}
/* 选中 */.layui-btn-checked{background-color: #5FB878;}
/* 禁用 */.layui-btn-disabled,.layui-btn-disabled:hover,.layui-btn-disabled:active{border: 1px solid #e6e6e6; background-color: #FBFBFB; color: #C9C9C9; cursor: not-allowed; opacity: 1;}
/* 大型 */.layui-btn-lg{height: 44px; line-height: 44px; padding: 0 25px; font-size: 16px;}
@ -935,6 +936,27 @@ body .layui-table-tips .layui-layer-content{background: none; padding: 0; box-sh
.layui-upload-wrap{position: relative; display: inline-block; vertical-align: middle;}
.layui-upload-wrap .layui-upload-file{display: block!important; position: absolute; left: 0; top: 0; z-index: 10; font-size: 100px; width: 100%; height: 100%; opacity: .01; filter: Alpha(opacity=1); cursor: pointer;}
/** 穿梭框 **/
.layui-transfer-box,
.layui-transfer-header,
.layui-transfer-search{border-width: 0; border-style: solid; border-color: #e6e6e6}
.layui-transfer-box{position: relative; border-width: 1px; width: 200px; height: 360px; border-radius: 2px; background-color:#fff;}
.layui-transfer-box .layui-form-checkbox{width: 100%;}
.layui-transfer-header{height: 38px; line-height: 38px; padding: 0 10px; border-bottom-width: 1px;}
.layui-transfer-search{position:relative; padding: 10px; border-bottom-width: 1px;}
.layui-transfer-search .layui-input{height: 32px; padding-left: 30px; font-size: 12px;}
.layui-transfer-search .layui-icon-search{position: absolute; left: 20px; top: 50%; margin-top: -8px; color: #666;}
.layui-transfer-active{margin: 0 15px;}
.layui-transfer-active .layui-btn{display: block; margin: 0; padding: 0 15px; background-color: #5FB878; border-color: #5FB878; color: #fff;}
.layui-transfer-active .layui-btn-disabled{background-color: #FBFBFB; border-color: #e6e6e6; color: #C9C9C9;}
.layui-transfer-active .layui-btn:first-child{margin-bottom: 15px;}
.layui-transfer-active .layui-btn .layui-icon{margin: 0; font-size: 14px !important;}
.layui-transfer-data{padding: 5px 0; overflow: auto;}
.layui-transfer-data li{height: 32px; line-height: 32px; padding: 0 10px;}
.layui-transfer-data li:hover{background-color: #f2f2f2; transition: .5s all;}
.layui-transfer-data .layui-none{padding: 15px 10px; text-align: center; color: #999;}
/** 导航菜单 **/
.layui-nav{position: relative; padding: 0 20px; background-color: #393D49; color: #fff; border-radius: 2px; font-size: 0; box-sizing: border-box;}
.layui-nav *{font-size: 14px;}
@ -1222,25 +1244,6 @@ body .layui-util-face .layui-layer-content{padding:0; background-color:#fff; co
.layui-slider > span{margin-left: 8px;}
}
/** 穿梭框 By star1029 **/
.layui-transfer{display: inline-block; position: relative; width: 480px; background-color: #FFF; text-align: left;}
.layui-transfer-left,.layui-transfer-right{display: inline-block; vertical-align: middle; position: relative; width: 200px; height: 340px; border: 1px solid #e6e6e6;}
.layui-transfer-topTitle{padding-left: 10px; height: 38px; line-height: 38px; border-bottom: 1px solid #e6e6e6;}
.layui-transfer-btn{display: inline-block; vertical-align: middle; width: 70px; height: 90px; text-align: center;}
.layui-transfer-btn .layui-btn{margin-left: 0; padding: 0 10px; height: 30px; line-height: 30px; background-color: #5FB878; border-color: #5FB878;}
.layui-transfer-btn .layui-btn i{margin-left: 4px; font-size: 14px; color: #FFF;}
.layui-transfer-btn .layui-btn.layui-btn-disabled{background-color: #FBFBFB; border-color: #e6e6e6;}
.layui-transfer-btn .layui-btn.layui-btn-disabled i{color: #CCC;}
.layui-transfer-btnRight{margin-bottom: 30px;}
.layui-transfer-search{position: relative; height: 46px; line-height: 36px; padding: 5px 10px; border-bottom: 1px solid #e6e6e6; text-align: center;}
.layui-transfer-search .layui-input{display: inline-block; width: 100%; padding-left: 30px; height: 28px; line-height: 28px;}
.layui-transfer-searchI{position: absolute; left: 20px;}
.layui-transfer-data{height: 300px; overflow: auto;}
.layui-transfer-short{height: 216px;}
.layui-transfer-data li{position: relative; padding-left: 10px; height: 30px; line-height: 30px;}
.layui-transfer-data .layui-form-checkbox[lay-skin="primary"]{width: 100%;}
.layui-transfer-data li:hover{background-color: #EEE;}
/** 树组件 By star1029 **/
.layui-tree{line-height: 22px;}
.layui-tree-set{width: 100%; position: relative;}

41
src/lay/modules/table.js

@ -52,8 +52,9 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
}
return {
reload: function(options, type){
that.reload.call(that, options, type);
config: options
,reload: function(options){
that.reload.call(that, options);
}
,setColsWidth: function(){
that.setColsWidth.call(that);
@ -61,7 +62,6 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
,resize: function(){ //重置表格尺寸/结构
that.resize.call(that);
}
,config: options
}
}
@ -639,30 +639,13 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
};
//表格重载
Class.prototype.reload = function(options, type){
var that = this
,optString = typeof options === 'string'
,opts, typs;
opts = optString ? type : options;
typs = optString ? options : type
opts = opts || {};
if(opts.data && opts.data.constructor === Array) delete that.config.data;
that.config = $.extend(true, {}, that.config, opts);
Class.prototype.reload = function(options){
var that = this;
typs === 'data' ? that.pullData(that.config.page.curr) : that.render();
};
//调整视图
Class.prototype.adjustView = function(type){
var that = this
,isHide = type === 'hide';
if(options.data && options.data.constructor === Array) delete that.config.data;
that.config = $.extend(true, {}, that.config, options);
that.layFixed[isHide ? 'addClass' : 'removeClass'](HIDE);
that.layTotal[isHide ? 'addClass' : 'removeClass'](HIDE);
that.layPage[isHide ? 'addClass' : 'removeClass'](HIDE);
that.render();
};
//异常提示
@ -684,7 +667,6 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
that.layMain.find('tbody').html(that.layNone = layNone);
table.cache[that.key] = []; //格式化缓存数据
that.adjustView('hide'); //隐藏无关视图
};
//页码
@ -869,8 +851,6 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
trs_fixed.push('<tr data-index="'+ i1 +'">'+ tds_fixed.join('') + '</tr>');
trs_fixed_r.push('<tr data-index="'+ i1 +'">'+ tds_fixed_r.join('') + '</tr>');
});
that.adjustView();
that.layBody.scrollTop(0);
that.layMain.find('tbody').html(trs.join(''));
@ -914,7 +894,6 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
//同步分页状态
if(options.page){
console.log(count);
options.page = $.extend({
elem: 'layui-table-page' + options.index
,count: count
@ -1949,12 +1928,12 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
};
//表格重载
table.reload = function(id, options, type){
table.reload = function(id, options){
var config = getThisTableConfig(id); //获取当前实例配置项
if(!config) return;
var that = thisTable.that[id];
that.reload(options, type);
that.reload(options);
return thisTable.call(that);
};

690
src/lay/modules/transfer.js

@ -1,20 +1,25 @@
/**
@Namelayui.transfer 穿梭框
@Authorstar1029
@Author贤心
@LicenseMIT
*/
layui.define('form', function(exports){
layui.define(['laytpl', 'form'], function(exports){
"use strict";
var form = layui.form
,$ = layui.$
var $ = layui.$
,laytpl = layui.laytpl
,form = layui.form
//模块名
,MOD_NAME = 'transfer'
//外部接口
,transfer = {
config: {}
,index: layui.transfer ? (layui.transfer.index + 10000) : 0
,index: layui[MOD_NAME] ? (layui[MOD_NAME].index + 10000) : 0
//设置全局项
,set: function(options){
@ -30,21 +35,74 @@ layui.define('form', function(exports){
}
//操作当前实例
,thisTran = function(){
,thisModule = function(){
var that = this
,options = that.config;
,options = that.config
,id = options.id || that.index;
thisModule.that[id] = that; //记录当前实例对象
thisModule.config[id] = options; //记录当前实例配置项
return {
getData: function(){
return that.getData();
config: options
//重置实例
,reload: function(options){
that.reload.call(that, options);
}
//获取右侧数据
,getData: function(){
return that.getData.call(that);
}
,config: options
}
}
//获取当前实例配置项
,getThisModuleConfig = function(id){
var config = thisModule.config[id];
if(!config) hint.error('The ID option was not found in the '+ MOD_NAME +' instance');
return config || null;
}
//字符常量
,MOD_NAME = 'transfer', ELEM_VIEW = 'layui-transfer', ELEM_TOP = 'layui-transfer-topTitle',ELEM_SEARCH = 'layui-transfer-search', ELEM_BOX = 'layui-transfer-box', ELEM_DATA = 'layui-transfer-data', TRAN_LEFT = 'layui-transfer-left', TRAN_RIGHT = 'layui-transfer-right', TRAN_LEFT_LIST = 'layui-transfer-dataLeft'
,TRAN_RIGHT_LIST = 'layui-transfer-dataRight' ,TRAN_BTN_LEFT = 'layui-transfer-btnLeft', TRAN_BTN_RIGHT = 'layui-transfer-btnRight', TRAN_BTN_DIS = 'layui-btn-disabled'
,ELEM = 'layui-transfer', HIDE = 'layui-hide', DISABLED = 'layui-btn-disabled', NONE = 'layui-none'
,ELEM_BOX = 'layui-transfer-box', ELEM_HEADER = 'layui-transfer-header', ELEM_SEARCH = 'layui-transfer-search', ELEM_ACTIVE = 'layui-transfer-active', ELEM_DATA = 'layui-transfer-data'
//穿梭框模板
,TPL_BOX = function(obj){
obj = obj || {};
return ['<div class="layui-transfer-box layui-inline" data-index="'+ obj.index +'">'
,'<div class="layui-transfer-header">'
,'<input type="checkbox" name="'+ obj.checkAllName +'" lay-filter="layTransferCheckbox" lay-type="all" lay-skin="primary" title="{{ d.data.title['+ obj.index +'] || \'list'+ (obj.index + 1) +'\' }}">'
,'</div>'
,'{{# if(d.data.showSearch){ }}'
,'<div class="layui-transfer-search">'
,'<i class="layui-icon layui-icon-search"></i>'
,'<input type="input" class="layui-input" placeholder="关键词搜索">'
,'</div>'
,'{{# } }}'
,'<ul class="layui-transfer-data"></ul>'
,'</div>'].join('');
}
//主模板
,TPL_MAIN = ['<div class="layui-transfer layui-form layui-border-box" lay-filter="LAY-transfer-{{ d.index }}">'
,TPL_BOX({
index: 0
,checkAllName: 'layTransferLeftCheckAll'
})
,'<div class="layui-transfer-active layui-inline">'
,'<button type="button" class="layui-btn layui-btn-sm layui-btn-primary layui-btn-disabled" data-index="0">'
,'<i class="layui-icon layui-icon-next"></i>'
,'</button>'
,'<button type="button" class="layui-btn layui-btn-sm layui-btn-primary layui-btn-disabled" data-index="1">'
,'<i class="layui-icon layui-icon-prev"></i>'
,'</button>'
,'</div>'
,TPL_BOX({
index: 1
,checkAllName: 'layTransferRightCheckAll'
})
,'</div>'].join('')
//构造器
,Class = function(options){
@ -58,91 +116,59 @@ layui.define('form', function(exports){
Class.prototype.config = {
title: ['列表一', '列表二']
,width: 200
,height: 340
,height: 360
,data: [] //数据源
,value: [] //选中的数据
,showSearch: false //是否开启搜索
,id: '' //唯一 ID 标识
,id: '' //唯一索引,默认自增 index
,text: {
none: '无数据'
,searchNone: '无匹配数据'
}
};
//重载实例
Class.prototype.reload = function(options){
var that = this;
layui.each(options, function(key, item){
if(item.constructor === Array) delete that.config[key];
});
that.config = $.extend(true, {}, that.config, options);
that.render();
};
//穿梭框渲染
//渲染
Class.prototype.render = function(){
var that = this
,options = that.config
,listLeft = '' ,listRight = '' , arr = [];
//格式转化
if(typeof options.parseData == 'function'){
layui.each(options.data, function(index, item){
options.data[index] = options.parseData(item) || item;
});
};
//循环列表
var num = 0 ,li = '',total1 = 0, total2 = 0;
layui.each(options.data, function(index1, item1){
num = 0;
layui.each(options.value, function(index2, item2){
if(item1.value == item2){
num = 1;
return true;
};
});
li = '<li data-title="'+ item1.title +'"><input lay-skin="primary" type="checkbox" data-index="'+ index1 +'" name="'+ (num == 0 ? 'layTranLeftCheck' : 'layTranRightCheck') +'" title="'+ item1.title +'" value="'+ item1.value +'" class="layui-input" '+ (item1.disabled ? 'disabled' : '') +'></li>';
if(num == 0){
listLeft += li;
total1 += item1.disabled ? 0 : 1;
}else{
listRight += li;
total2 += item1.disabled ? 0 : 1;
arr.push(index1);
}
});
var temp = ['<div class="layui-transfer layui-form layui-border-box" id="transfer-'+ options.id +'" lay-filter="LAY-Transfer-'+ that.index +'">'
,'<div class="layui-transfer-left layui-transfer-box" data-total="'+ total1 +'">'
,'<div class="'+ ELEM_TOP +'"><input lay-skin="primary" name="layTranLeftCheck" lay-filter="layTranLeftCheckAll" type="checkbox" class="layui-input" title="'+ options.title[0] +'"></div>'
,function(){
if(options.showSearch){
return '<div class="layui-transfer-search"><input class="layui-input" placeholder="关键字搜索"><i class="layui-icon layui-icon-search layui-transfer-searchI"></i></div><ul class="layui-transfer-data layui-transfer-dataLeft layui-transfer-short">';
}else{
return '<ul class="layui-transfer-data layui-transfer-dataLeft">';
};
return '';
}()
,listLeft + '</ul>'
,'</div>'
,'<div class="layui-transfer-btn">'
,'<button type="button" class="layui-btn layui-btn-primary layui-transfer-btnRight layui-btn-disabled"><i class="layui-icon layui-icon-next"></i></button>'
,'<button type="button" class="layui-btn layui-btn-primary layui-transfer-btnLeft layui-btn-disabled"><i class="layui-icon layui-icon-prev"></i></button></div>'
,'<div class="layui-transfer-right layui-transfer-box" data-arr="'+ arr +'" data-total="'+ total2 +'">'
,'<div class="'+ ELEM_TOP +'"><input lay-skin="primary" name="layTranRightCheck" lay-filter="layTranRightCheckAll" type="checkbox" class="layui-input" title="'+ options.title[1] +'"></div>'
,function(){
if(options.showSearch){
return '<div class="layui-transfer-search"><input class="layui-input" placeholder="关键字搜索"><i class="layui-icon layui-icon-search layui-transfer-searchI"></i></div><ul class="layui-transfer-data layui-transfer-dataRight layui-transfer-short">';
}else{
return '<ul class="layui-transfer-data layui-transfer-dataRight">';
};
return '';
}()
,listRight + '</ul>'
,'</div>'
,'</div>'].join('');
//开始插入替代元素
var othis = $(options.elem)
,hasRender = othis.next('.' + ELEM_VIEW);
,options = that.config;
//生成替代元素
hasRender[0] && hasRender.remove(); //如果已经渲染,则Rerender
that.elem = $(temp);
//解析模板
var thisElem = that.elem = $(laytpl(TPL_MAIN).render({
data: options
,index: that.index //索引
}));
var othis = options.elem = $(options.elem);
if(!othis[0]) return;
//初始化属性
options.data = options.data || [];
options.value = options.value || [];
//索引
that.key = options.id || that.index;
//插入组件结构
othis.html(that.elem);
that.layTop = that.elem.find('.'+ ELEM_TOP)
//各级容器
that.layBox = that.elem.find('.'+ ELEM_BOX)
that.layHeader = that.elem.find('.'+ ELEM_HEADER)
that.laySearch = that.elem.find('.'+ ELEM_SEARCH)
that.layData = that.elem.find('.'+ ELEM_DATA)
that.layData = thisElem.find('.'+ ELEM_DATA);
that.layBtn = thisElem.find('.'+ ELEM_ACTIVE + ' .layui-btn');
//初始化尺寸
that.layBox.css({
@ -151,294 +177,264 @@ layui.define('form', function(exports){
});
that.layData.css({
height: function(){
return options.height - that.layTop.outerHeight() - that.laySearch.outerHeight() - 2
return options.height - that.layHeader.outerHeight() - that.laySearch.outerHeight() - 2
}()
});
that.renderData(); //渲染数据
that.events(); //事件
};
//渲染数据
Class.prototype.renderData = function(){
var that = this
,options = that.config;
//左右穿梭框差异数据
var arr = [{
checkName: 'layTransferLeftCheck'
,views: []
}, {
checkName: 'layTransferRightCheck'
,views: []
}];
//解析格式
that.parseData(function(item){
//标注为 selected 的为右边的数据
var _index = item.selected ? 1 : 0
,listElem = ['<li>'
,'<input type="checkbox" name="'+ arr[_index].checkName +'" lay-skin="primary" lay-filter="layTransferCheckbox" title="'+ item.title +'"'+ (item.disabled ? ' disabled' : '') + (item.checked ? ' checked' : '') +' value="'+ item.value +'">'
,'</li>'].join('');
arr[_index].views.push(listElem);
delete item.selected;
});
that.layData.eq(0).html(arr[0].views.join(''));
that.layData.eq(1).html(arr[1].views.join(''));
that.event();
form.render('checkbox', 'LAY-Transfer-' + that.index);
that.renderCheckBtn();
}
//渲染表单
Class.prototype.renderForm = function(type){
form.render(type, 'LAY-transfer-'+ this.index);
};
Class.prototype.event = function(){
//同步复选框和按钮状态
Class.prototype.renderCheckBtn = function(obj){
var that = this
,options = that.config
,elem = that.elem
,listLeft = '', listRight = ''
,checkTopLeft = elem.find('.'+ TRAN_LEFT).find('.'+ ELEM_TOP).find('input[name="layTranLeftCheck"]')
,checkTopRight = elem.find('.'+ TRAN_RIGHT).find('.'+ ELEM_TOP).find('input[name="layTranRightCheck"]')
,totalLeft = elem.find('.' + TRAN_LEFT).data('total')
,totalRight = elem.find('.' + TRAN_RIGHT).data('total');
//左选项
elem.on('click', 'input[name="layTranLeftCheck"]+', function(){
var checkbox = $(this).prev()
,checked = checkbox[0].checked
,childs = elem.find('.'+ TRAN_LEFT_LIST).find('input[name="layTranLeftCheck"]')
,isAll = checkbox.attr('lay-filter') == 'layTranLeftCheckAll';
if(checkbox[0].disabled) return;
//如果是全选/全不选
if(isAll){
listLeft = '';
//如果数据为零,不进行其他操作
if(totalLeft == 0){
checkbox[0].checked = false;
}else{
//同步子选项
childs.each(function(i, item){
if(!item.disabled){
item.checked = checked;
if(checked){
listLeft += ($(childs[i]).data("index")) + ',';
$(childs[i]).parent("li").addClass("selected");
}else{
$(childs[i]).parent("li").removeClass("selected");
}
};
});
//同步按钮状态
if(checked){
elem.find('.' + TRAN_BTN_RIGHT).removeClass(TRAN_BTN_DIS);
}else{
elem.find('.' + TRAN_BTN_RIGHT).addClass(TRAN_BTN_DIS);
};
}
}else{
var num = 1;
//单个勾选
if(checked){
//判断是否全选
childs.each(function(i, item){
if(!item.disabled && !item.checked){
num = 0;
}
});
//如果全选,勾选全选按钮
if(num == 1){
checkTopLeft[0].checked = checked;
};
//加入列表
listLeft += checkbox.data("index") + ',';
checkbox.parent("li").addClass("selected");
elem.find('.' + TRAN_BTN_RIGHT).removeClass(TRAN_BTN_DIS);
}else{
//如果全选状态,更改全选按钮
if(checkTopLeft[0].checked){
checkTopLeft[0].checked = false;
};
//移除
checkbox.parent("li").removeClass("selected");
listLeft = listLeft.replace(checkbox.data('index'),'');
childs.each(function(i, item){
if(item.checked){
num = 0;
}
});
//如果勾选项,更改按钮状态
if(num == 1){
elem.find('.' + TRAN_BTN_RIGHT).addClass(TRAN_BTN_DIS);
};
}
};
form.render('checkbox', 'LAY-Transfer-' + that.index);
});
//右选项
elem.on('click', 'input[name="layTranRightCheck"]+', function(){
var checkbox = $(this).prev()
,checked = checkbox[0].checked
,childs = elem.find('.'+ TRAN_RIGHT_LIST).find('input[name="layTranRightCheck"]')
,isAll = checkbox.attr('lay-filter') === 'layTranRightCheckAll';
if(checkbox[0].disabled) return;
//如果是全选/全不选
if(isAll){
listRight = '';
//如果数据为零,不进行其他操作
if(totalRight == 0){
checkbox[0].checked = false;
}else{
childs.each(function(i, item){
if(!item.disabled){
item.checked = checked;
if(checked){
listRight += ($(childs[i]).data("index")) + ',';
$(childs[i]).parent("li").addClass("selected");
}else{
$(childs[i]).parent("li").removeClass("selected");
}
}
});
if(checked){
elem.find('.' + TRAN_BTN_LEFT).removeClass(TRAN_BTN_DIS);
}else{
elem.find('.' + TRAN_BTN_LEFT).addClass(TRAN_BTN_DIS);
}
};
form.render('checkbox', 'LAY-Transfer-' + that.index);
}else{
var num = 1;
//单个勾选
if(checked){
//判断是否全选
childs.each(function(i, item){
if(!item.disabled && !item.checked){
num = 0;
}
});
//如果全选,勾选全选按钮
if(num == 1){
checkTopRight[0].checked = checked;
};
//加入列表
listRight += checkbox.data("index") + ',';
checkbox.parent("li").addClass("selected");
elem.find('.' + TRAN_BTN_LEFT).removeClass(TRAN_BTN_DIS);
}else{
//如果全选状态,更改全选按钮
if(checkTopRight[0].checked){
checkTopRight[0].checked = false;
};
//移除
checkbox.parent("li").removeClass("selected");
listRight = listRight.replace(checkbox.data('index'),'');
childs.each(function(i, item){
if(item.checked){
num = 0;
}
});
//如果勾选项,更改按钮状态
if(num == 1){
elem.find('.' + TRAN_BTN_LEFT).addClass(TRAN_BTN_DIS);
};
,options = that.config;
obj = obj || {};
that.layBox.each(function(_index){
var othis = $(this)
,thisDataElem = othis.find('.'+ ELEM_DATA)
,allElemCheckbox = othis.find('.'+ ELEM_HEADER).find('input[type="checkbox"]')
,listElemCheckbox = thisDataElem.find('input[type="checkbox"]');
//同步复选框和按钮状态
var nums = 0
,haveChecked = false;
listElemCheckbox.each(function(){
var isHide = $(this).data('hide');
if(this.checked || this.disabled || isHide){
nums++;
}
};
form.render('checkbox', 'LAY-Transfer-' + that.index);
});
//查找
function searchVal(tran){
var input = elem.find(tran).find('.layui-transfer-search')
,val = input.children('input').val()
,warp = input.next();
warp.children("li").each(function(){
if($(this).data("title").indexOf(val) == -1){
$(this).hide();
}else{
$(this).show();
if(this.checked && !isHide){
haveChecked = true;
}
});
};
allElemCheckbox.prop('checked', haveChecked && nums === listElemCheckbox.length); //全选复选框状态
that.layBtn.eq(_index)[haveChecked ? 'removeClass' : 'addClass'](DISABLED); //对应的按钮状态
//无数据视图
if(!obj.stopNone){
var isNone = thisDataElem.children('li:not(.'+ HIDE +')').length
that.noneView(thisDataElem, isNone ? '' : options.text.none);
}
});
that.renderForm('checkbox');
};
//无数据视图
Class.prototype.noneView = function(thisDataElem, text){
var createNoneElem = $('<p class="layui-none">'+ (text || '') +'</p>');
if(thisDataElem.find('.'+ NONE)[0]){
thisDataElem.find('.'+ NONE).remove();
}
text.replace(/\s/g, '') && thisDataElem.append(createNoneElem);
};
//同步 value 属性值
Class.prototype.setValue = function(){
var that = this
,options = that.config
,arr = [];
that.layBox.eq(1).find('.'+ ELEM_DATA +' input[type="checkbox"]').each(function(){
var isHide = $(this).data('hide');
isHide || arr.push(this.value);
});
options.value = arr;
return that;
};
//添加到右边
elem.on('click', '.'+TRAN_BTN_RIGHT, function(){
var preList = '';
//未选中则不操作
if($(this).hasClass(TRAN_BTN_DIS)){
return ;
};
//选项移除
elem.find("."+ TRAN_LEFT_LIST).find("li").each(function(){
if($(this).hasClass("selected")){
$(this).remove();
//解析数据
Class.prototype.parseData = function(callback){
var that = this
,options = that.config
,newData = [];
layui.each(options.data, function(index, item){
//解析格式
item = (typeof options.parseData === 'function'
? options.parseData(item)
: item) || item;
newData.push(item = $.extend({}, item))
layui.each(options.value, function(index2, item2){
if(item2 == item.value){
item.selected = true;
}
});
//选项插入
var arr = elem.find('.' + TRAN_RIGHT).data('arr')
,add = 0;
layui.each(listLeft.split(','), function(index, num){
if(!num) return;
var data = options.data[num];
preList += '<li data-title="'+ data.title +'"><input lay-skin="primary" type="checkbox" data-index="'+ num +'" name="layTranRightCheck" title="'+ data.title +'" value="'+ data.value +'" class="layui-input" '+ (data.disabled ? 'disabled' : '') +'></li>'
arr += ',' + num;
add++;
});
elem.find("."+ TRAN_RIGHT_LIST).append(preList);
searchVal('.'+TRAN_RIGHT);
//更新状态
checkTopLeft[0].checked = false;
checkTopRight[0].checked = false;
$(this).addClass(TRAN_BTN_DIS);
listLeft = '';
//更改缓存数据
totalRight = totalRight + add;
totalLeft = totalLeft - add;
elem.find('.' + TRAN_RIGHT).data('total', totalRight);
elem.find('.' + TRAN_RIGHT).data('total', totalLeft);
elem.find('.' + TRAN_RIGHT).data('arr', arr);
form.render('checkbox', 'LAY-Transfer-' + that.index);
options.onchange && options.onchange(that.getData());
callback && callback(item);
});
//添加到左边
elem.on('click', '.'+TRAN_BTN_LEFT, function(){
var preList = '';
if($(this).hasClass(TRAN_BTN_DIS)){
return ;
};
//选项移除
elem.find("."+ TRAN_RIGHT_LIST).find("li").each(function(){
if($(this).hasClass("selected")){
$(this).remove();
}
options.data = newData;
return that;
};
//获得右侧面板数据
Class.prototype.getData = function(value){
var that = this
,options = that.config
,selectedData = [];
layui.each(value || options.value, function(index, item){
layui.each(options.data, function(index2, item2){
delete item2.selected;
if(item == item2.value){
selectedData.push(item2);
};
});
//选项插入
var arr = elem.find('.' + TRAN_RIGHT).data('arr')
,add = 0;
layui.each(listRight.split(','), function(index, num){
if(!num) return;
var data = options.data[num];
preList += '<li data-title="'+ data.title +'"><input lay-skin="primary" type="checkbox" data-index="'+ num +'" name="layTranLeftCheck" title="'+ data.title +'" value="'+ data.value +'" class="layui-input" '+ (data.disabled ? 'disabled' : '') +'></li>'
arr = arr.replace(num, '').replace(/(,)+/g,',');
add++;
});
return selectedData;
};
//事件
Class.prototype.events = function(){
var that = this
,options = that.config;
//左右复选框
that.elem.on('click', 'input[lay-filter="layTransferCheckbox"]+', function(){
var thisElemCheckbox = $(this).prev()
,checked = thisElemCheckbox[0].checked
,thisDataElem = thisElemCheckbox.parents('.'+ ELEM_BOX).eq(0).find('.'+ ELEM_DATA);
if(thisElemCheckbox[0].disabled) return;
//判断是否全选
if(thisElemCheckbox.attr('lay-type') === 'all'){
thisDataElem.find('input[type="checkbox"]').each(function(){
if(this.disabled) return;
this.checked = checked;
});
}
that.renderCheckBtn({stopNone: true});
});
//按钮事件
that.layBtn.on('click', function(){
var othis = $(this)
,_index = othis.data('index')
,thisBoxElem = that.layBox.eq(_index)
,arr = [];
if(othis.hasClass(DISABLED)) return;
that.layBox.eq(_index).each(function(_index){
var othis = $(this)
,thisDataElem = othis.find('.'+ ELEM_DATA);
thisDataElem.children('li').each(function(){
var thisList = $(this)
,thisElemCheckbox = thisList.find('input[type="checkbox"]')
,isHide = thisElemCheckbox.data('hide');
if(thisElemCheckbox[0].checked && !isHide){
thisElemCheckbox[0].checked = false;
thisBoxElem.siblings('.'+ ELEM_BOX).find('.'+ ELEM_DATA).append(thisList.clone());
thisList.remove();
//记录当前穿梭的数据
arr.push(thisElemCheckbox[0].value);
}
that.setValue();
});
});
elem.find("."+ TRAN_LEFT_LIST).append(preList);
searchVal('.'+TRAN_LEFT);
//更新状态
checkTopLeft[0].checked = false;
checkTopRight[0].checked = false;
$(this).addClass(TRAN_BTN_DIS);
listRight = '';
//更改缓存数据
totalRight = totalRight - add;
totalLeft = totalLeft + add;
elem.find('.' + TRAN_RIGHT).data('total', totalRight);
elem.find('.' + TRAN_RIGHT).data('total', totalLeft);
elem.find('.' + TRAN_RIGHT).data('arr', arr);
form.render('checkbox', 'LAY-Transfer-' + that.index);
options.onchange && options.onchange(that.getData());
that.renderCheckBtn();
//穿梭时,如果另外一个框正在搜索,则触发匹配
var siblingInput = thisBoxElem.siblings('.'+ ELEM_BOX).find('.'+ ELEM_SEARCH +' input')
siblingInput.val() === '' || siblingInput.trigger('keyup');
//穿梭时的回调
options.onchange && options.onchange(that.getData(arr), _index);
});
//搜索
elem.find('.layui-transfer-search').on('keyup', 'input', function(){
var outer = $(this).parent("div").parent("div");
searchVal(outer);
});
};
that.laySearch.find('input').on('keyup', function(){
var value = this.value
,thisDataElem = $(this).parents('.'+ ELEM_SEARCH).eq(0).siblings('.'+ ELEM_DATA)
,thisListElem = thisDataElem.children('li');
//得到选中值
Class.prototype.getData = function(){
var that = this
,options = that.config
,arr = that.elem.find('.' + TRAN_RIGHT).data('arr')
,data = [];
thisListElem.each(function(){
var thisList = $(this)
,thisElemCheckbox = thisList.find('input[type="checkbox"]')
,isMatch = thisElemCheckbox[0].title.indexOf(value) !== -1;
thisList[isMatch ? 'removeClass': 'addClass'](HIDE);
thisElemCheckbox.data('hide', isMatch ? false : true);
});
function sortNum(a,b){ return a - b };
layui.each(arr.split(',').sort(sortNum), function(index, num){
if(!num) return;
data.push(options.data[num]);
that.renderCheckBtn();
//无匹配数据视图
var isNone = thisListElem.length === thisDataElem.children('li.'+ HIDE).length;
that.noneView(thisDataElem, isNone ? options.text.searchNone : '');
});
return data;
};
//记录所有实例
thisModule.that = {}; //记录所有实例对象
thisModule.config = {}; //记录所有实例配置项
//重载实例
transfer.reload = function(id, options){
var that = thisModule.that[id];
that.reload(options);
return thisModule.call(that);
};
//获得选中的数据(右侧面板)
transfer.getData = function(id){
var that = thisModule.that[id];
return that.getData();
};
//核心入口
transfer.render = function(options){
var inst = new Class(options);
return thisTran.call(inst);
return thisModule.call(inst);
};
exports(MOD_NAME, transfer);
})
});

2
src/layui.js vendored

@ -19,7 +19,7 @@
}
,Layui = function(){
this.v = '2.5.1'; //版本号
this.v = '2.5.2'; //版本号
}
//获取layui所在目录

Loading…
Cancel
Save