发版
This commit is contained in:
parent
c20b875946
commit
2257341313
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "layui",
|
||||
"main": "src/layui.js",
|
||||
"version": "2.5.0",
|
||||
"main": "dist/layui.js",
|
||||
"version": "2.5.1",
|
||||
"homepage": "https://github.com/sentsin/layui",
|
||||
"authors": [
|
||||
"sentsin <xu@sentsin.com>"
|
||||
|
4
dist/css/layui.css
vendored
4
dist/css/layui.css
vendored
File diff suppressed because one or more lines are too long
2
dist/css/layui.mobile.css
vendored
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
2
dist/css/modules/code.css
vendored
@ -1,2 +1,2 @@
|
||||
/** layui-v2.5.0 MIT License By https://www.layui.com */
|
||||
/** layui-v2.5.1 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
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
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
2
dist/lay/modules/carousel.js
vendored
@ -1,2 +1,2 @@
|
||||
/** layui-v2.5.0 MIT License By https://www.layui.com */
|
||||
/** layui-v2.5.1 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?"":"")+"</button>",'<button class="layui-icon '+u+'" lay-type="add">'+("updown"===n.anim?"":"")+"</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
2
dist/lay/modules/code.js
vendored
@ -1,2 +1,2 @@
|
||||
/** layui-v2.5.0 MIT License By https://www.layui.com */
|
||||
/** layui-v2.5.1 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,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,""")),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
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
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
2
dist/lay/modules/flow.js
vendored
@ -1,2 +1,2 @@
|
||||
/** layui-v2.5.0 MIT License By https://www.layui.com */
|
||||
/** layui-v2.5.1 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 "></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
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
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
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
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
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
2
dist/lay/modules/laypage.js
vendored
@ -1,2 +1,2 @@
|
||||
/** layui-v2.5.0 MIT License By https://www.layui.com */
|
||||
/** layui-v2.5.1 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:"上一页",a.next="next"in a?a.next:"下一页";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="首页">'+(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">…</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">…</span>'),0!==t&&e.push('<a href="javascript:;" class="layui-laypage-last" title="尾页" 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">到第','<input type="text" min="1" value="'+a.curr+'" class="layui-input">','页<button type="button" class="layui-laypage-btn">确定</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
2
dist/lay/modules/laytpl.js
vendored
@ -1,2 +1,2 @@
|
||||
/** layui-v2.5.0 MIT License By https://www.layui.com */
|
||||
/** layui-v2.5.1 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,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,""")},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
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
2
dist/lay/modules/rate.js
vendored
@ -1,2 +1,2 @@
|
||||
/** layui-v2.5.0 MIT License By https://www.layui.com */
|
||||
/** layui-v2.5.1 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
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
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
4
dist/lay/modules/transfer.js
vendored
File diff suppressed because one or more lines are too long
4
dist/lay/modules/tree.js
vendored
4
dist/lay/modules/tree.js
vendored
File diff suppressed because one or more lines are too long
2
dist/lay/modules/upload.js
vendored
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
2
dist/lay/modules/util.js
vendored
@ -1,2 +1,2 @@
|
||||
/** layui-v2.5.0 MIT License By https://www.layui.com */
|
||||
/** layui-v2.5.1 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?"":t.bar1,t.bar2=t.bar2===!0?"":t.bar2,t.bgcolor=t.bgcolor?"background-color:"+t.bgcolor:"";var c=[t.bar1,t.bar2,""],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,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,""")},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
6
dist/layui.all.js
vendored
File diff suppressed because one or more lines are too long
4
dist/layui.js
vendored
4
dist/layui.js
vendored
File diff suppressed because one or more lines are too long
@ -193,6 +193,7 @@ layui.use('table', function(){
|
||||
,page: {
|
||||
|
||||
}
|
||||
|
||||
,autoSort: false
|
||||
//,loading: false
|
||||
,totalRow: true
|
||||
@ -203,8 +204,8 @@ layui.use('table', function(){
|
||||
{type: 'checkbox', fixed: 'left'}
|
||||
,{field:'id', title:'ID', width:80, fixed: 'left', unresize: true, sort: true, totalRowText: '合计:'}
|
||||
,{field:'username', title:'用户名', width:120, edit: 'text', templet: '#usernameTpl'}
|
||||
,{field:'email', title:'邮箱', hide: true, width:150, edit: 'text', templet: function(x){
|
||||
return '<em>'+ x.email +'</em>'
|
||||
,{field:'email', title:'邮箱', hide: 0, width:150, edit: 'text', templet: function(x){
|
||||
return '<em>123</em>'
|
||||
}}
|
||||
,{field:'sex', title:'性别', width:80, edit: 'text', sort: true}
|
||||
,{field:'city', title:'城市', width:120, templet: '#cityTpl1'}
|
||||
@ -259,6 +260,7 @@ layui.use('table', function(){
|
||||
table.reload('test', {
|
||||
page: {curr: 5}
|
||||
//,height: 300
|
||||
//,url: 'x'
|
||||
}, 'data');
|
||||
break;
|
||||
};
|
||||
|
@ -48,7 +48,7 @@
|
||||
});
|
||||
|
||||
$("#btn").on('click', function(){
|
||||
alert(JSON.stringify(ins1.getValue()))
|
||||
alert(JSON.stringify(ins1.getData()))
|
||||
});
|
||||
|
||||
var ins2 = transfer.render({
|
||||
|
@ -148,7 +148,7 @@
|
||||
,data: data1
|
||||
,click: function(obj){
|
||||
layer.msg(JSON.stringify(obj.data));
|
||||
|
||||
console.log(obj);
|
||||
|
||||
}
|
||||
,oncheck: function(obj){
|
||||
@ -162,7 +162,7 @@
|
||||
if(type == 'add'){
|
||||
//ajax操作,返回key值
|
||||
return index++;
|
||||
}else if(type == 'edit'){
|
||||
}else if(type == 'update'){
|
||||
console.log(obj.elem.find('.layui-tree-txt').html());
|
||||
}else if(type == 'del'){
|
||||
console.log(obj);
|
||||
@ -176,15 +176,17 @@
|
||||
,checked: [6, 7, 9] //选中节点(依赖于 showCheckbox 以及 key 参数)
|
||||
,spread: [2, 4, 5] //展开节点(依赖于 key 参数)
|
||||
,accordion: 0 //是否开启手风琴模式
|
||||
,expandClick: true //选择在点击节点(true)/箭头图标(false)的时候展开节点
|
||||
|
||||
,onlyIconControl: true //是否仅允许节点左侧图标控制展开收缩
|
||||
,isJump: 0 //点击文案跳转地址
|
||||
,renderContent: true //增删改
|
||||
,showSearch: true //是否打开节点过滤
|
||||
,draggable: true //是否开启节点拖拽
|
||||
,edit: true //操作节点图标
|
||||
//,defaultNodeName: 'newNode'
|
||||
//,showSearch: true //是否打开节点过滤
|
||||
//,drag: true //是否开启节点拖拽
|
||||
});
|
||||
|
||||
console.log(tree1.getCheck()); //返回当前勾选节点
|
||||
tree1.setCheck([2, 3]); //设置节点勾选
|
||||
console.log(tree1.getChecked()); //返回当前勾选节点
|
||||
//tree1.setChecked([2, 3]); //设置节点勾选
|
||||
|
||||
|
||||
|
||||
@ -195,7 +197,7 @@
|
||||
//,expandClick: false
|
||||
,showLine: false //关闭连接线
|
||||
,click: function(obj, state){
|
||||
console.log(obj[0]);
|
||||
console.log(obj);
|
||||
}
|
||||
,oncheck: function(obj, checked, child){
|
||||
if(checked){
|
||||
|
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "layui-src",
|
||||
"realname": "layui",
|
||||
"version": "2.5.0",
|
||||
"version": "2.5.1",
|
||||
"independents": {
|
||||
"layim": "3.9.0"
|
||||
},
|
||||
"description": "Classic modular front-end component library",
|
||||
"main": "layui.js",
|
||||
"main": "dist/layui.js",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "karma start karma.conf.unit.js",
|
||||
|
@ -864,7 +864,6 @@ hr, .layui-timeline-item:before{background-color: #e6e6e6;}
|
||||
.laytable-cell-numbers{padding: 0; text-align: center;}
|
||||
|
||||
.layui-table-body{position: relative; overflow: auto; margin-right: -1px; margin-bottom: -1px;}
|
||||
.layui-table-body .layui-none{line-height: 26px; padding: 15px; text-align: center; color: #999;}
|
||||
.layui-table-fixed{position: absolute; left: 0; top: 0; z-index: 101;}
|
||||
.layui-table-fixed .layui-table-body{overflow: hidden;}
|
||||
.layui-table-fixed-l{box-shadow: 0 -1px 8px rgba(0,0,0,.08);}
|
||||
@ -877,6 +876,12 @@ hr, .layui-timeline-item:before{background-color: #e6e6e6;}
|
||||
|
||||
.layui-table-total{margin-bottom: -1px; border-width: 0; border-top-width: 1px; overflow: hidden;}
|
||||
|
||||
.layui-table-box .layui-none{display: block; line-height: 26px; text-align: center; color: #999;}
|
||||
.layui-table-box tr.layui-none{transition: none; -webkit-transition: none;}
|
||||
.layui-table-box .layui-none:hover{background: none!important;}
|
||||
.layui-table-box .layui-none td{display: block; padding: 0; border: none;}
|
||||
.layui-table-none{padding: 15px;}
|
||||
|
||||
|
||||
.layui-table-page{position: relative; width: 100%; padding: 7px 7px 0; border-width: 0; border-top-width: 1px; height: 41px; margin-bottom: -1px; font-size: 12px; white-space: nowrap; overflow: hidden;}
|
||||
.layui-table-page>div{height: 26px;}
|
||||
@ -1218,25 +1223,23 @@ body .layui-util-face .layui-layer-content{padding:0; background-color:#fff; co
|
||||
}
|
||||
|
||||
/** 穿梭框 By star1029 **/
|
||||
.layui-transfer{display: inline-block; position: relative; width: 480px; height: 360px; 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 #DDD;}
|
||||
.layui-transfer-topTitle{padding-left: 12px; height: 36px; border-bottom: 1px solid #DDD; line-height: 36px;}
|
||||
.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: #DDD;}
|
||||
.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: 36px; line-height: 36px; border-bottom: 1px solid #DDD; text-align: center;}
|
||||
.layui-transfer-search .layui-input{display: inline-block; width: 88%; padding-left: 30px; height: 28px; line-height: 28px;}
|
||||
.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: 303px; overflow: auto;}
|
||||
.layui-transfer-data.short{height: 266px;}
|
||||
.layui-transfer-data li{position: relative; padding-left: 12px; height: 30px; line-height: 30px;}
|
||||
.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;}
|
||||
.layui-transfer-data::-webkit-scrollbar{width: 5px; background-color: #EEE;}
|
||||
.layui-transfer-data::-webkit-scrollbar-thumb{background-color: #DDD;}
|
||||
|
||||
/** 树组件 By star1029 **/
|
||||
.layui-tree{line-height: 22px;}
|
||||
|
@ -302,6 +302,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
}));
|
||||
|
||||
options.index = that.index;
|
||||
that.key = options.id || options.index;
|
||||
|
||||
//生成替代元素
|
||||
hasRender[0] && hasRender.remove(); //如果已经渲染,则Rerender
|
||||
@ -635,9 +636,10 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
that.setColsWidth(); //自适应列宽
|
||||
that.scrollPatch(); //滚动条补丁
|
||||
|
||||
that.layNone && that.layNone.width(that.elem.width() - 2);
|
||||
};
|
||||
|
||||
//表格完整重载
|
||||
//表格重载
|
||||
Class.prototype.reload = function(options, type){
|
||||
var that = this
|
||||
,optString = typeof options === 'string'
|
||||
@ -654,6 +656,38 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
typs === 'data' ? that.pullData(that.config.page.curr) : that.render();
|
||||
};
|
||||
|
||||
//调整视图
|
||||
Class.prototype.adjustView = function(type){
|
||||
var that = this
|
||||
,isHide = type === 'hide';
|
||||
|
||||
that.layFixed[isHide ? 'addClass' : 'removeClass'](HIDE);
|
||||
that.layTotal[isHide ? 'addClass' : 'removeClass'](HIDE);
|
||||
that.layPage[isHide ? 'addClass' : 'removeClass'](HIDE);
|
||||
};
|
||||
|
||||
//异常提示
|
||||
Class.prototype.errorView = function(html){
|
||||
var that = this
|
||||
,elemNone = that.layMain.find('.'+ NONE)
|
||||
,layNone = $(['<tr class="'+ NONE +'" data-off="1">'
|
||||
,'<td data-off="1"><div class="layui-table-none">'+ html +'</div></td>'
|
||||
,'</tr>'].join(''));
|
||||
|
||||
if(elemNone[0]){
|
||||
that.layNone.remove();
|
||||
elemNone.remove();
|
||||
}
|
||||
|
||||
if(!html) return;
|
||||
|
||||
layNone.width(that.elem.width() - 2);
|
||||
that.layMain.find('tbody').html(that.layNone = layNone);
|
||||
|
||||
table.cache[that.key] = []; //格式化缓存数据
|
||||
that.adjustView('hide'); //隐藏无关视图
|
||||
};
|
||||
|
||||
//页码
|
||||
Class.prototype.page = 1;
|
||||
|
||||
@ -681,6 +715,8 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
if(options.contentType && options.contentType.indexOf("application/json") == 0){ //提交 json 格式
|
||||
data = JSON.stringify(data);
|
||||
}
|
||||
|
||||
that.loading();
|
||||
|
||||
$.ajax({
|
||||
type: options.method || 'get'
|
||||
@ -697,10 +733,10 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
//检查数据格式是否符合规范
|
||||
if(res[response.statusName] != response.statusCode){
|
||||
that.renderForm();
|
||||
that.layMain.html('<div class="'+ NONE +'">'+ (
|
||||
that.errorView(
|
||||
res[response.msgName] ||
|
||||
('返回的数据不符合规范,正确的成功状态码 ('+ response.statusName +') 应为:'+ response.statusCode)
|
||||
) +'</div>');
|
||||
('返回的数据不符合规范,正确的成功状态码应为:"'+ response.statusName +'": '+ response.statusCode)
|
||||
);
|
||||
} else {
|
||||
that.renderData(res, curr, res[response.countName]), sort();
|
||||
options.time = (new Date().getTime() - that.startTime) + ' ms'; //耗时(接口请求+视图渲染)
|
||||
@ -709,7 +745,8 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
typeof options.done === 'function' && options.done(res, curr, res[response.countName]);
|
||||
}
|
||||
,error: function(e, m){
|
||||
that.layMain.html('<div class="'+ NONE +'">数据接口请求异常:'+ m +'</div>');
|
||||
that.errorView('数据接口请求异常:'+ m);
|
||||
|
||||
that.renderForm();
|
||||
that.setColsWidth();
|
||||
}
|
||||
@ -833,9 +870,10 @@ 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('.'+ NONE).remove();
|
||||
that.layMain.find('tbody').html(trs.join(''));
|
||||
that.layFixLeft.find('tbody').html(trs_fixed.join(''));
|
||||
that.layFixRight.find('tbody').html(trs_fixed_r.join(''));
|
||||
@ -857,7 +895,6 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
options.HAS_SET_COLS_PATCH = true;
|
||||
};
|
||||
|
||||
that.key = options.id || options.index;
|
||||
table.cache[that.key] = data; //记录数据
|
||||
|
||||
//显示隐藏分页栏
|
||||
@ -870,10 +907,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
|
||||
if(data.length === 0){
|
||||
that.renderForm();
|
||||
that.layFixed.remove();
|
||||
that.layMain.find('tbody').html('');
|
||||
that.layMain.find('.'+ NONE).remove();
|
||||
return that.layMain.append('<div class="'+ NONE +'">'+ options.text.none +'</div>');
|
||||
return that.errorView(options.text.none);
|
||||
}
|
||||
|
||||
render(); //渲染数据
|
||||
@ -896,8 +930,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
//而并非用的是 options.page 中的参数(以确保分页未开启的情况仍能正常使用)
|
||||
that.page = obj.curr; //更新页码
|
||||
options.limit = obj.limit; //更新每页条数
|
||||
|
||||
that.loading();
|
||||
|
||||
that.pullData(obj.curr);
|
||||
}
|
||||
}
|
||||
@ -1154,10 +1187,10 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
|
||||
//减去分页栏的高度
|
||||
if(options.page){
|
||||
bodyHeight = bodyHeight - (that.layPage.outerHeight() || 41) - 2;
|
||||
bodyHeight = bodyHeight - (that.layPage.outerHeight() || 41);
|
||||
}
|
||||
|
||||
that.layMain.css('height', bodyHeight);
|
||||
that.layMain.css('height', bodyHeight - 2);
|
||||
};
|
||||
|
||||
//获取滚动条宽度
|
||||
@ -1442,7 +1475,10 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
var othis = $(this)
|
||||
,index = othis.parents('tr').eq(0).data('index')
|
||||
,tr = that.layBody.find('tr[data-index="'+ index +'"]')
|
||||
,data = table.cache[that.key][index];
|
||||
,data = table.cache[that.key] || [];
|
||||
|
||||
|
||||
data = data[index] || {};
|
||||
|
||||
return $.extend({
|
||||
tr: tr //行元素
|
||||
@ -1530,10 +1566,12 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
that.layBody.on('mouseenter', 'tr', function(){ //鼠标移入行
|
||||
var othis = $(this)
|
||||
,index = othis.index();
|
||||
if(othis.data('off')) return; //不触发事件
|
||||
that.layBody.find('tr:eq('+ index +')').addClass(ELEM_HOVER)
|
||||
}).on('mouseleave', 'tr', function(){ //鼠标移出行
|
||||
var othis = $(this)
|
||||
,index = othis.index();
|
||||
if(othis.data('off')) return; //不触发事件
|
||||
that.layBody.find('tr:eq('+ index +')').removeClass(ELEM_HOVER)
|
||||
}).on('click', 'tr', function(){ //单击行
|
||||
setRowEvent.call(this, 'row');
|
||||
@ -1544,6 +1582,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
//创建行单击、双击事件监听
|
||||
var setRowEvent = function(eventType){
|
||||
var othis = $(this);
|
||||
if(othis.data('off')) return; //不触发事件
|
||||
layui.event.call(this,
|
||||
MOD_NAME, eventType + '('+ filter +')'
|
||||
,commonMember.call(othis.children('td')[0])
|
||||
@ -1617,6 +1656,8 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
var othis = $(this)
|
||||
,elemCell = othis.children(ELEM_CELL);
|
||||
|
||||
if(othis.data('off')) return; //不触发事件
|
||||
|
||||
if(hide){
|
||||
othis.find('.layui-table-grid-down').remove();
|
||||
} else if(elemCell.prop('scrollWidth') > elemCell.outerWidth()){
|
||||
|
@ -35,15 +35,15 @@ layui.define('form', function(exports){
|
||||
,options = that.config;
|
||||
|
||||
return {
|
||||
getValue: function(){
|
||||
return that.getValue();
|
||||
getData: function(){
|
||||
return that.getData();
|
||||
}
|
||||
,config: options
|
||||
}
|
||||
}
|
||||
|
||||
//字符常量
|
||||
,MOD_NAME = 'transfer', ELEM_VIEW = 'layui-transfer', TRAN_LEFT = 'layui-transfer-left', TRAN_RIGHT = 'layui-transfer-right', TRAN_LEFT_LIST = 'layui-transfer-dataLeft'
|
||||
,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'
|
||||
|
||||
//构造器
|
||||
@ -57,6 +57,8 @@ layui.define('form', function(exports){
|
||||
//默认配置
|
||||
Class.prototype.config = {
|
||||
title: ['列表一', '列表二']
|
||||
,width: 200
|
||||
,height: 340
|
||||
,data: [] //数据源
|
||||
,value: [] //选中的数据
|
||||
,showSearch: false //是否开启搜索
|
||||
@ -97,12 +99,12 @@ layui.define('form', function(exports){
|
||||
}
|
||||
});
|
||||
|
||||
var temp = ['<div class="layui-transfer layui-form" id="transfer-'+ options.id +'" lay-filter="LAY-Transfer-'+ that.index +'">'
|
||||
,'<div class="layui-transfer-left" data-total="'+ total1 +'">'
|
||||
,'<div class="layui-transfer-topTitle"><input lay-skin="primary" name="layTranLeftCheck" lay-filter="layTranLeftCheckAll" type="checkbox" class="layui-input" title="'+ options.title[0] +'"></div>'
|
||||
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 short">';
|
||||
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">';
|
||||
};
|
||||
@ -113,11 +115,11 @@ layui.define('form', function(exports){
|
||||
,'<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" data-arr="'+ arr +'" data-total="'+ total2 +'">'
|
||||
,'<div class="layui-transfer-topTitle"><input lay-skin="primary" name="layTranRightCheck" lay-filter="layTranRightCheckAll" type="checkbox" class="layui-input" title="'+ options.title[1] +'"></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 short">';
|
||||
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">';
|
||||
};
|
||||
@ -134,9 +136,27 @@ layui.define('form', function(exports){
|
||||
//生成替代元素
|
||||
hasRender[0] && hasRender.remove(); //如果已经渲染,则Rerender
|
||||
|
||||
that.elemTemp = $(temp);
|
||||
|
||||
othis.html(that.elemTemp);
|
||||
that.elem = $(temp);
|
||||
othis.html(that.elem);
|
||||
|
||||
that.layTop = that.elem.find('.'+ ELEM_TOP)
|
||||
that.layBox = that.elem.find('.'+ ELEM_BOX)
|
||||
that.laySearch = that.elem.find('.'+ ELEM_SEARCH)
|
||||
that.layData = that.elem.find('.'+ ELEM_DATA)
|
||||
|
||||
//初始化尺寸
|
||||
that.layBox.css({
|
||||
width: options.width
|
||||
,height: options.height
|
||||
});
|
||||
that.layData.css({
|
||||
height: function(){
|
||||
return options.height - that.layTop.outerHeight() - that.laySearch.outerHeight() - 2
|
||||
}()
|
||||
});
|
||||
|
||||
|
||||
|
||||
that.event();
|
||||
form.render('checkbox', 'LAY-Transfer-' + that.index);
|
||||
};
|
||||
@ -144,10 +164,10 @@ layui.define('form', function(exports){
|
||||
Class.prototype.event = function(){
|
||||
var that = this
|
||||
,options = that.config
|
||||
,elem = that.elemTemp
|
||||
,elem = that.elem
|
||||
,listLeft = '', listRight = ''
|
||||
,checkTopLeft = elem.find('.'+ TRAN_LEFT).find('.layui-transfer-topTitle').find('input[name="layTranLeftCheck"]')
|
||||
,checkTopRight = elem.find('.'+ TRAN_RIGHT).find('.layui-transfer-topTitle').find('input[name="layTranRightCheck"]')
|
||||
,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');
|
||||
|
||||
@ -350,7 +370,7 @@ layui.define('form', function(exports){
|
||||
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.getValue());
|
||||
options.onchange && options.onchange(that.getData());
|
||||
});
|
||||
|
||||
//添加到左边
|
||||
@ -389,7 +409,7 @@ layui.define('form', function(exports){
|
||||
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.getValue());
|
||||
options.onchange && options.onchange(that.getData());
|
||||
});
|
||||
|
||||
//搜索
|
||||
@ -400,10 +420,10 @@ layui.define('form', function(exports){
|
||||
};
|
||||
|
||||
//得到选中值
|
||||
Class.prototype.getValue = function(){
|
||||
Class.prototype.getData = function(){
|
||||
var that = this
|
||||
,options = that.config
|
||||
,arr = that.elemTemp.find('.' + TRAN_RIGHT).data('arr')
|
||||
,arr = that.elem.find('.' + TRAN_RIGHT).data('arr')
|
||||
,data = [];
|
||||
|
||||
function sortNum(a,b){ return a - b };
|
||||
|
@ -36,11 +36,11 @@ layui.define('form', function(exports){
|
||||
,options = that.config;
|
||||
|
||||
return {
|
||||
getCheck: function(){
|
||||
return that.getCheck();
|
||||
getChecked: function(){
|
||||
return that.getChecked();
|
||||
}
|
||||
,setCheck: function(key){//设置值
|
||||
return that.setCheck(key);
|
||||
,setChecked: function(key){//设置值
|
||||
return that.setChecked(key);
|
||||
}
|
||||
,config: options
|
||||
}
|
||||
@ -48,7 +48,7 @@ layui.define('form', function(exports){
|
||||
|
||||
//字符常量
|
||||
,MOD_NAME = 'tree', ELEM_VIEW = 'layui-tree', ELEM_SET = 'layui-tree-set', ICON_CLICK = 'layui-tree-iconClick'
|
||||
,ICON_ADD = 'layui-icon-addition', ICON_SUB = 'layui-icon-subtraction', ELEM_ENTRY = 'layui-tree-entry', ELEM_MAIN = 'layui-tree-main', ELEM_PACK = 'layui-tree-pack', ELEM_SPREAD = 'layui-tree-spread'
|
||||
,ICON_ADD = 'layui-icon-addition', ICON_SUB = 'layui-icon-subtraction', ELEM_ENTRY = 'layui-tree-entry', ELEM_MAIN = 'layui-tree-main', ELEM_TEXT = 'layui-tree-txt', ELEM_PACK = 'layui-tree-pack', ELEM_SPREAD = 'layui-tree-spread'
|
||||
,ELEM_LINE_SHORT = 'layui-tree-setLineShort', ELEM_SHOW = 'layui-tree-showLine', ELEM_EXTEND = 'layui-tree-lineExtend'
|
||||
|
||||
//构造器
|
||||
@ -68,13 +68,14 @@ layui.define('form', function(exports){
|
||||
,checked: [] //选中节点(依赖于 showCheckbox 以及 key 参数)
|
||||
,spread: [] //展开节点(依赖于 key 参数)
|
||||
,accordion: false //是否开启手风琴模式
|
||||
,expandClick: true //选择在点击节点(true)/箭头图标(false)的时候展开节点
|
||||
,onlyIconControl: false //是否仅允许节点左侧图标控制展开收缩
|
||||
,isJump: false //是否允许点击节点时弹出新窗口跳转
|
||||
,renderContent: false //是否开启内置的“增加/删除/修改”操作图标
|
||||
,edit: false //是否开启节点的操作图标
|
||||
|
||||
,showSearch: false //是否打开节点过滤
|
||||
,draggable: false //是否开启节点拖拽
|
||||
,drag: false //是否开启节点拖拽
|
||||
|
||||
,defaultNodeName: '未命名' //节点默认名称
|
||||
,emptyText: '暂无数据' //数据为空时的文本提示
|
||||
};
|
||||
|
||||
@ -83,7 +84,7 @@ layui.define('form', function(exports){
|
||||
var that = this
|
||||
,options = that.config;
|
||||
|
||||
var temp = $('<div class="layui-tree'+ (options.showCheckbox ? " layui-form" : "") + (options.showLine ? " layui-tree-line" : "") +'"></div>');
|
||||
var temp = $('<div class="layui-tree'+ (options.showCheckbox ? " layui-form" : "") + (options.showLine ? " layui-tree-line" : "") +'" lay-filter="LAY-tree-'+ that.index +'"></div>');
|
||||
that.tree(temp);
|
||||
|
||||
var othis = $(options.elem)
|
||||
@ -105,11 +106,11 @@ layui.define('form', function(exports){
|
||||
};
|
||||
|
||||
//拖拽事件
|
||||
options.draggable && that.drag();
|
||||
options.drag && that.drag();
|
||||
|
||||
//复选框渲染
|
||||
if(options.showCheckbox){
|
||||
form.render('checkbox');
|
||||
that.renderForm('checkbox');
|
||||
};
|
||||
|
||||
that.elem.find('.layui-tree-set').each(function(){
|
||||
@ -161,7 +162,7 @@ layui.define('form', function(exports){
|
||||
var hasChild = item.children && item.children.length > 0
|
||||
,packDiv = $('<div class="layui-tree-pack" style="'+ (isOpen(item[options.key]) ? "display: block;" : "") +'"></div>')
|
||||
,entryDiv = $(['<div '+ (options.key ? 'data-key="'+ (item[options.key] || '') +'"' : '') +' class="layui-tree-set'+ (isOpen(item[options.key]) ? " layui-tree-spread" : "") + (isCheck(item[options.key]) ? " layui-tree-checkedFirst" : "") +'">'
|
||||
,'<div '+ (options.draggable && !item.fixed ? 'draggable="true"' : '') +' class="layui-tree-entry">'
|
||||
,'<div '+ (options.drag && !item.fixed ? 'draggable="true"' : '') +' class="layui-tree-entry">'
|
||||
,'<div class="layui-tree-main layui-inline">'
|
||||
//箭头
|
||||
,function(){
|
||||
@ -184,20 +185,33 @@ layui.define('form', function(exports){
|
||||
//节点
|
||||
,function(){
|
||||
if(options.isJump && item.href){
|
||||
return '<a href="'+ item.href +'" target="_blank" class="layui-tree-txt">'+ (item.label || '未命名') +'</a>';
|
||||
return '<a href="'+ item.href +'" target="_blank" class="'+ ELEM_TEXT +'">'+ (item.label || options.defaultNodeName) +'</a>';
|
||||
}else{
|
||||
return '<span class="layui-tree-txt">'+ (item.label || '未命名') +'</span>';
|
||||
return '<span class="'+ ELEM_TEXT +'">'+ (item.label || options.defaultNodeName) +'</span>';
|
||||
}
|
||||
}()
|
||||
,'</div>'
|
||||
|
||||
//增删改按钮
|
||||
//节点操作图标
|
||||
,function(){
|
||||
return options.renderContent ? ['<div class="layui-btn-group layui-tree-btnGroup">'
|
||||
,'<i class="layui-icon layui-icon-add-1" data-type="add"></i>'
|
||||
,'<i class="layui-icon layui-icon-edit" data-type="edit"></i>'
|
||||
,'<i class="layui-icon layui-icon-delete" data-type="del"></i>'
|
||||
,'</div>'].join(''): '';
|
||||
if(!options.edit) return '';
|
||||
|
||||
var editIcon = {
|
||||
add: '<i class="layui-icon layui-icon-add-1" data-type="add"></i>'
|
||||
,update: '<i class="layui-icon layui-icon-edit" data-type="update"></i>'
|
||||
,del: '<i class="layui-icon layui-icon-delete" data-type="del"></i>'
|
||||
}, arr = ['<div class="layui-btn-group layui-tree-btnGroup">'];
|
||||
|
||||
if(options.edit === true){
|
||||
options.edit = ['update', 'del']
|
||||
}
|
||||
|
||||
if(typeof options.edit === 'object'){
|
||||
layui.each(options.edit, function(i, val){
|
||||
arr.push(editIcon[val] || '')
|
||||
});
|
||||
return arr.join('') + '</div>';
|
||||
}
|
||||
}()
|
||||
,'</div></div>'].join(''));
|
||||
|
||||
@ -223,8 +237,8 @@ layui.define('form', function(exports){
|
||||
//选择框
|
||||
options.showCheckbox && that.checkClick(entryDiv, item);
|
||||
|
||||
//增删改
|
||||
options.renderContent && that.operate(entryDiv, item);
|
||||
//操作节点
|
||||
options.edit && that.operate(entryDiv, item);
|
||||
|
||||
});
|
||||
};
|
||||
@ -234,14 +248,17 @@ layui.define('form', function(exports){
|
||||
var that = this
|
||||
,options = that.config
|
||||
,entry = elem.children('.'+ELEM_ENTRY)
|
||||
,touchOpen = options.expandClick ? entry.children('.'+ ELEM_MAIN) : entry.find('.'+ICON_CLICK); //判断展开通过节点还是箭头图标
|
||||
|
||||
touchOpen.on('click', function(){
|
||||
,elemMain = entry.children('.'+ ELEM_MAIN)
|
||||
,elemIcon = entry.find('.'+ ICON_CLICK)
|
||||
,elemText = entry.find('.'+ ELEM_TEXT)
|
||||
,touchOpen = options.onlyIconControl ? elemIcon : elemMain //判断展开通过节点还是箭头图标
|
||||
,state = '';
|
||||
|
||||
//展开收缩
|
||||
touchOpen.on('click', function(e){
|
||||
var packCont = elem.children('.'+ELEM_PACK)
|
||||
,iconClick = touchOpen.children('.layui-icon')[0] ? touchOpen.children('.layui-icon') : touchOpen.find('.layui-tree-icon').children('.layui-icon');
|
||||
|
||||
var state = '';
|
||||
|
||||
|
||||
//若没有子节点
|
||||
if(!packCont[0]){
|
||||
state = 'normal';
|
||||
@ -249,14 +266,12 @@ layui.define('form', function(exports){
|
||||
if(elem.hasClass(ELEM_SPREAD)){
|
||||
elem.removeClass(ELEM_SPREAD);
|
||||
packCont.slideUp(200);
|
||||
iconClick.removeClass(ICON_SUB).addClass(ICON_ADD);
|
||||
state = 'close';
|
||||
iconClick.removeClass(ICON_SUB).addClass(ICON_ADD);
|
||||
}else{
|
||||
elem.addClass(ELEM_SPREAD);
|
||||
packCont.slideDown(200);
|
||||
iconClick.addClass(ICON_SUB).removeClass(ICON_ADD);
|
||||
state = 'open';
|
||||
|
||||
|
||||
//是否手风琴
|
||||
if(options.accordion){
|
||||
var sibls = elem.siblings('.'+ELEM_SET);
|
||||
@ -266,6 +281,16 @@ layui.define('form', function(exports){
|
||||
};
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
//点击回调
|
||||
elemText.on('click', function(){
|
||||
if(elem.hasClass(ELEM_SPREAD)){
|
||||
state = options.onlyIconControl ? 'open' : 'close';
|
||||
} else {
|
||||
state = options.onlyIconControl ? 'close' : 'open';
|
||||
}
|
||||
|
||||
//点击产生的回调
|
||||
options.click && options.click({
|
||||
elem: elem
|
||||
@ -274,87 +299,88 @@ layui.define('form', function(exports){
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
//渲染表单
|
||||
Class.prototype.renderForm = function(type){
|
||||
form.render(type, 'LAY-tree-'+ this.index);
|
||||
};
|
||||
|
||||
//复选框选择
|
||||
Class.prototype.checkClick = function(elem, item){
|
||||
var that = this
|
||||
,options = that.config
|
||||
,entry = elem.children('.'+ELEM_ENTRY)
|
||||
,elemMain = entry.children('.'+ELEM_MAIN)
|
||||
,hasChild = false;
|
||||
,entry = elem.children('.'+ ELEM_ENTRY)
|
||||
,elemMain = entry.children('.'+ ELEM_MAIN);
|
||||
|
||||
elemMain.on('click', 'input[name="layuiTreeCheck"]+', function(e){
|
||||
layui.stope(e); //阻止点击节点事件
|
||||
|
||||
var checked = $(this).prev()[0].checked;
|
||||
|
||||
if($(this).prev()[0].disabled) return;
|
||||
//若有子节点,同步选项
|
||||
var elemCheckbox = $(this).prev()
|
||||
,checked = elemCheckbox.prop('checked');
|
||||
|
||||
if(elemCheckbox.prop('disabled')) return;
|
||||
|
||||
//同步子节点选中状态
|
||||
if(typeof item.children === 'object' || elem.find('.'+ELEM_PACK)[0]){
|
||||
var childs = elem.find('.'+ELEM_PACK).find('input[name="layuiTreeCheck"]');
|
||||
childs.each(function(i, item1){
|
||||
if(item1.disabled) return; //不可点击则跳过
|
||||
item1.checked = checked;
|
||||
var childs = elem.find('.'+ ELEM_PACK).find('input[name="layuiTreeCheck"]');
|
||||
childs.each(function(){
|
||||
if(this.disabled) return; //不可点击则跳过
|
||||
this.checked = checked;
|
||||
});
|
||||
hasChild = true;
|
||||
};
|
||||
|
||||
//父节点及祖先节点选中
|
||||
function checkState(elem){
|
||||
//若无上一级则停止
|
||||
if(!elem.parents('.'+ELEM_SET)[0]) return;
|
||||
var siblingTree = elem.siblings().children('.'+ELEM_ENTRY)
|
||||
,parentTree = elem.parent('.'+ELEM_PACK)
|
||||
,num = 1;
|
||||
//若有兄弟节点,判断兄弟节点状态
|
||||
if(siblingTree[0]){
|
||||
siblingTree.each(function(i, item1){
|
||||
var input = $(item1).find('input[name="layuiTreeCheck"]')[0]
|
||||
//若是节点未选择并且是可选择的属性
|
||||
if(input.checked == false && !input.disabled){
|
||||
num = 0;
|
||||
};
|
||||
//同步父选中状态
|
||||
var setParentsChecked = function(thisNodeElem){
|
||||
//若无父节点,则终止递归
|
||||
if(!thisNodeElem.parents('.'+ ELEM_SET)[0]) return;
|
||||
|
||||
var state
|
||||
,parentPack = thisNodeElem.parent('.'+ ELEM_PACK)
|
||||
,parentNodeElem = parentPack.parent()
|
||||
,parentCheckbox = parentPack.prev().find('input[name="layuiTreeCheck"]');
|
||||
|
||||
|
||||
//如果子节点有任意一条选中,则父节点为选中状态
|
||||
if(checked){
|
||||
parentCheckbox.prop('checked', checked);
|
||||
} else { //如果当前节点取消选中,则根据计算“兄弟和子孙”节点选中状态,来同步父节点选中状态
|
||||
parentPack.find('input[name="layuiTreeCheck"]').each(function(){
|
||||
if(this.checked){
|
||||
state = true;
|
||||
}
|
||||
});
|
||||
};
|
||||
//若兄弟节点都为选中状态,父节点状态改变
|
||||
if(num == 1){
|
||||
parentTree.prev().find('input[name="layuiTreeCheck"]')[0].checked = true;
|
||||
//向上一级父节点执行
|
||||
checkState(parentTree.parent('.'+ELEM_SET));
|
||||
};
|
||||
|
||||
//如果兄弟子孙节点全部未选中,则父节点也应为非选中状态
|
||||
state || parentCheckbox.prop('checked', false);
|
||||
}
|
||||
|
||||
//向父节点递归
|
||||
setParentsChecked(parentNodeElem);
|
||||
};
|
||||
//向上遍历,同步父节点状态
|
||||
if(checked){
|
||||
checkState(elem);
|
||||
}else{
|
||||
//父节点及祖先节点取消选择
|
||||
var parentTree = elem.parents('.'+ELEM_PACK).prev();
|
||||
parentTree.each(function(i, item1){
|
||||
$(item1).find('input[name="layuiTreeCheck"]')[0].checked = false;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
setParentsChecked(elem);
|
||||
|
||||
//复选框点击产生的回调
|
||||
options.oncheck && options.oncheck({
|
||||
elem: elem
|
||||
,checked: checked
|
||||
,data: item
|
||||
,hasChild: hasChild
|
||||
});
|
||||
|
||||
form.render('checkbox');
|
||||
|
||||
that.renderForm('checkbox');
|
||||
});
|
||||
};
|
||||
|
||||
//增删改
|
||||
//节点操作
|
||||
Class.prototype.operate = function(elem, item){
|
||||
var that = this
|
||||
,options = that.config
|
||||
,entry = elem.children('.'+ELEM_ENTRY)
|
||||
,elemMain = entry.children('.'+ELEM_MAIN);
|
||||
,entry = elem.children('.'+ ELEM_ENTRY)
|
||||
,elemMain = entry.children('.'+ ELEM_MAIN);
|
||||
|
||||
entry.children('.layui-tree-btnGroup').on('click', '.layui-icon', function(e){
|
||||
layui.stope(e); //阻止节点操作
|
||||
|
||||
var type = $(this).data("type")
|
||||
,packCont = elem.children('.'+ELEM_PACK)
|
||||
,returnObj = {
|
||||
@ -381,7 +407,7 @@ layui.define('form', function(exports){
|
||||
//新增节点
|
||||
var key = options.operate && options.operate(returnObj)
|
||||
,obj = {};
|
||||
obj.label = 'newElemTree';
|
||||
obj.label = options.defaultNodeName;
|
||||
obj[options.key] = key;
|
||||
that.tree(elem.children('.'+ELEM_PACK), [obj]);
|
||||
|
||||
@ -439,12 +465,12 @@ layui.define('form', function(exports){
|
||||
var packLast = elem.children('.'+ELEM_PACK).children('.'+ELEM_SET).last();
|
||||
packLast.find('input[name="layuiTreeCheck"]')[0].checked = true;
|
||||
};
|
||||
form.render('checkbox');
|
||||
that.renderForm('checkbox');
|
||||
|
||||
//修改
|
||||
}else if(type == 'edit'){
|
||||
var text = elemMain.children('.layui-tree-txt').html();
|
||||
elemMain.children('.layui-tree-txt').html('');
|
||||
}else if(type == 'update'){
|
||||
var text = elemMain.children('.'+ ELEM_TEXT).html();
|
||||
elemMain.children('.'+ ELEM_TEXT).html('');
|
||||
//添加输入框,覆盖在文字上方
|
||||
elemMain.append('<input type="text" class="layui-inline layui-tree-editInput">');
|
||||
//获取焦点
|
||||
@ -452,9 +478,9 @@ layui.define('form', function(exports){
|
||||
//嵌入文字移除输入框
|
||||
var getVal = function(input){
|
||||
var textNew = input.val().trim();
|
||||
textNew = textNew ? textNew : '未命名';
|
||||
textNew = textNew ? textNew : options.defaultNodeName;
|
||||
input.remove();
|
||||
elemMain.children('.layui-tree-txt').html(textNew);
|
||||
elemMain.children('.'+ ELEM_TEXT).html(textNew);
|
||||
|
||||
//同步数据
|
||||
returnObj.data.label = textNew;
|
||||
@ -514,7 +540,7 @@ layui.define('form', function(exports){
|
||||
if(state == 1 && num == 1){
|
||||
//勾选父节点
|
||||
checkState.checked = true;
|
||||
form.render('checkbox');
|
||||
that.renderForm('checkbox');
|
||||
//向上遍历祖先节点
|
||||
elemDel(parentTree.parent('.'+ELEM_SET));
|
||||
};
|
||||
@ -712,7 +738,7 @@ layui.define('form', function(exports){
|
||||
if(state == 1 && ndig == 1){
|
||||
//勾选父节点
|
||||
checkState.checked = true;
|
||||
form.render('checkbox');
|
||||
that.renderForm('checkbox');
|
||||
//向上遍历祖先节点
|
||||
elemRemove(parentTree.parent('.'+ELEM_SET) || parentSet);
|
||||
};
|
||||
@ -729,12 +755,12 @@ layui.define('form', function(exports){
|
||||
if($(this).height() != 0){
|
||||
//若在本身位置
|
||||
if((disY > setTop && disY < setTop + setHeight)){
|
||||
options.dragend && options.dragend('拖拽失败,拖拽在节点本身进行!');
|
||||
options.dragend && options.dragend('drag error');
|
||||
return;
|
||||
};
|
||||
//若仅有一个子元素
|
||||
if(num == 1 && disY > parentTop && disY < setTop + setHeight){
|
||||
options.dragend && options.dragend('拖拽失败,拖拽在节点本身进行!');
|
||||
options.dragend && options.dragend('drag error');
|
||||
return;
|
||||
};
|
||||
var thisTop = $(this).offset().top;
|
||||
@ -811,7 +837,7 @@ layui.define('form', function(exports){
|
||||
packLast.find('input[name="layuiTreeCheck"]+').click();
|
||||
};
|
||||
};
|
||||
options.dragend && options.dragend('拖拽成功,进入目标节点内', setParent, $(this));
|
||||
options.dragend && options.dragend('drag success', setParent, $(this));
|
||||
return false;
|
||||
|
||||
//若位于元素上方
|
||||
@ -918,7 +944,7 @@ layui.define('form', function(exports){
|
||||
,arr = [];
|
||||
|
||||
//遍历所有的值
|
||||
pack.find('.layui-tree-txt').each(function(){
|
||||
pack.find('.'+ ELEM_TEXT).each(function(){
|
||||
var entry = $(this).parents('.'+ELEM_ENTRY);
|
||||
//若值匹配,加一个类以作标识
|
||||
if($(this).html().indexOf(val) != -1){
|
||||
@ -963,7 +989,7 @@ layui.define('form', function(exports){
|
||||
};
|
||||
|
||||
//得到选中节点
|
||||
Class.prototype.getCheck = function(){
|
||||
Class.prototype.getChecked = function(){
|
||||
var that = this
|
||||
,options = that.config
|
||||
,arr = [];
|
||||
@ -981,7 +1007,7 @@ layui.define('form', function(exports){
|
||||
};
|
||||
|
||||
//设置选中节点
|
||||
Class.prototype.setCheck = function(key){
|
||||
Class.prototype.setChecked = function(key){
|
||||
var that = this
|
||||
,options = that.config;
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
}
|
||||
|
||||
,Layui = function(){
|
||||
this.v = '2.5.0'; //版本号
|
||||
this.v = '2.5.1'; //版本号
|
||||
}
|
||||
|
||||
//获取layui所在目录
|
||||
|
Loading…
Reference in New Issue
Block a user