feat(tree): 升级了tree

This commit is contained in:
smallwei 2018-07-15 21:53:25 +08:00
commit 546177d805
43 changed files with 673 additions and 399 deletions

View File

@ -1,5 +1,6 @@
# 更新日志
* [2.3.0](http://www.layui.com/doc/base/changelog.html#2-3-0)
* [2.2.6](http://www.layui.com/doc/base/changelog.html#2-2-6)
* [2.2.5](http://www.layui.com/doc/base/changelog.html#2-2-5)
* [2.2.45](http://www.layui.com/doc/base/changelog.html#2-2-45)

View File

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

4
dist/css/layui.css vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
/** layui-v2.3.0-rc1 MIT License By https://www.layui.com */
/** layui-v2.3.0 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}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

BIN
dist/font/iconfont.eot vendored

Binary file not shown.

View File

@ -297,6 +297,9 @@ t9.5 -10.5t21.5 -4h37h67h81h80h64h36q23 0 34 12t2 38q-5 13 -9.5 30.5t-9.5 34.5q-
<glyph glyph-name="fonts-html" unicode="&#58955;" d="M194.33 416.235h-101.295v101.28h-46.035v-267.03h46.035v119.7h101.28v-119.7h46.035v267.03h-46.035v-101.28zM277.205 480.69h73.665v-230.205h46.035v230.205h73.665v36.825h-193.365v-36.825zM627.815 335.58000000000004l-46.755 181.935h-73.665v-267.03h46.035v211.785l46.035-211.785h55.245l46.83 213.93-0.795-213.93h46.035v267.03h-73.665l-45.3-181.935zM848.09 287.30999999999995v230.205h-46.035v-267.03h174.945v36.825h-128.91z" horiz-adv-x="1024" />
<glyph glyph-name="screen-full" unicode="&#58914;" d="M641.750109 511.899972l205.227128 204.519-0.704035-115.89966c-0.282433-9.611915 7.489578-18.09103 17.101493-17.808598l12.297071 0c9.611915 0.283456 17.667382 5.936199 17.808598 15.689331l0.565888 172.57752c0 0.14224 0.282433 9.187243 0.282433 9.187243 0.14224 4.804423-0.99056 9.187243-4.100388 12.297071-3.109828 3.109828-7.347339 5.086855-12.297071 4.946662l-8.763594-0.14224c-0.141216 0-0.278339 0-0.420579-0.14224L697.581696 797.833213c-9.611915-0.283456-17.667382-8.200776-17.808598-17.950837l0-12.297071c1.416256-11.44875 10.458189-18.092054 20.070104-17.808598l112.789832-0.283456-204.66124-203.814965c-9.329483-9.329483-9.329483-24.449855 0-33.778314 9.329483-9.470699 24.452925-9.470699 33.782408 0L641.750109 511.899972zM383.095141 319.11010699999997L177.726797 115.29411900000002l0.707105 115.338888c0.283456 9.607822-7.492648 18.086937-17.104563 17.808598l-13.001105 0c-9.611915-0.283456-17.667382-5.937223-17.808598-15.690354l-0.565888-172.718737c0-0.14224-0.282433-9.187243-0.282433-9.187243-0.14224-4.808516 0.99056-9.187243 4.096295-12.297071 3.109828-3.109828 7.351432-5.086855 12.297071-4.946662l8.762571 0.14224c0.14224 0 0.283456 0 0.425695 0.14224l171.873486-0.708128c9.607822 0.283456 17.667382 8.196683 17.808598 17.950837L344.93503 63.42477399999996c-1.415232 11.44875-10.461259 18.092054-20.074198 17.808598L212.069977 81.51682800000003 416.59 285.32872299999997c9.329483 9.329483 9.329483 24.453948 0 33.782408C407.40685 328.58182999999997 392.424624 328.58182999999997 383.095141 319.11010699999997L383.095141 319.11010699999997zM894.047276 60.03251399999999l-0.424672 172.718737c-0.283456 9.612938-8.200776 15.406898-17.809621 15.690354l-12.296047 0c-9.612938 0.278339-17.243733-8.200776-17.105586-17.808598l0.708128-115.903753L641.750109 319.11010699999997c-9.329483 9.329483-24.452925 9.329483-33.782408 0-9.325389-9.328459-9.325389-24.452925 0-33.782408L812.490795 81.51682800000003l-112.789832-0.283456c-9.611915 0.283456-18.515702-6.502088-20.073174-17.808598l0-12.297071c0.282433-9.611915 8.200776-17.667382 17.808598-17.950837l171.166381 0.708128c0.141216 0 0.282433-0.14224 0.424672-0.14224l8.763594-0.14224c4.803399-0.141216 9.187243 1.694595 12.296047 4.946662 3.109828 3.109828 4.238534 7.488555 4.097318 12.297071 0 0-0.14224 9.046027-0.14224 9.187243L894.047276 60.03149099999996zM212.216309 749.493252l112.789832 0.283456c9.607822-0.283456 18.512632 6.502088 20.070104 17.808598L345.076246 779.883399c-0.283456 9.611915-8.196683 17.667382-17.808598 17.950837l-172.011632-0.708128c-0.14224 0-0.283456 0.14224-0.425695 0.14224l-8.761548 0.14224c-4.808516 0.141216-9.187243-1.694595-12.297071-4.946662-3.109828-3.109828-4.242627-7.488555-4.096295-12.297071 0 0 0.282433-9.046027 0.282433-9.187243l0.420579-172.718737c0.14224-9.608845 8.200776-15.406898 17.808598-15.686261l13.005198 0c9.611915-0.282433 17.242709 8.196683 17.10047 17.808598l-0.564865 115.334795 205.231221-203.958228c9.324366-9.329483 24.448832-9.329483 33.777291 0 9.329483 9.329483 9.329483 24.452925 0 33.782408L212.216309 749.493252 212.216309 749.493252zM212.216309 749.493252" horiz-adv-x="1024" />
<glyph glyph-name="form" unicode="&#58940;" d="M314.278111 437.019389l395.439892 0 0-30.297458-395.439892 0L314.278111 437.019389zM314.278111 315.83495200000004l395.439892 0 0-30.297458-395.439892 0L314.278111 315.83495200000004zM314.278111 194.62833l263.626661 0 0-30.297458L314.278111 164.330872 314.278111 194.62833zM609.376235 739.9931730000001c-7.849678 42.966669-48.394988 75.742447-97.378777 75.742447-48.961604 0-89.51311-32.775778-97.380776-75.742447L116.55177 739.9931730000001l0-787.725922 790.893774 0 0 787.725922L609.376235 739.9931730000001zM446.091342 670.440529l0 17.613058 0 36.791056c0 33.410348 29.57295 60.594317 65.906116 60.594317 36.352353 0 65.907115-27.183969 65.907115-60.594317l0-36.791056 0-17.621053 16.672696-8.712493c32.358061-16.929922 57.169039-42.663874 71.406386-73.213161L358.043239 588.50688c14.240345 30.555683 39.051523 56.281241 71.408385 73.213161L446.091342 670.440529zM874.489888-17.436289999999985L149.505227-17.436289999999985 149.505227 709.694715 413.138884 709.694715l0-21.641327c-51.44492-26.923746-88.727643-74.124144-98.86377-129.845165l395.44289 0c-10.102151 55.730615-47.40466 102.921419-98.859773 129.845165l0 21.641327 263.631658 0L874.489888-17.436289999999985z" horiz-adv-x="1024" />
@ -426,6 +429,9 @@ t9.5 -10.5t21.5 -4h37h67h81h80h64h36q23 0 34 12t2 38q-5 13 -9.5 30.5t-9.5 34.5q-
<glyph glyph-name="male" unicode="&#58978;" d="M889.6 800h-240s-35.2 0-38.4-41.6c0-19.2 16-38.4 38.4-38.4h140.8l-179.2-179.2C556.8 582.4 489.6 608 416 608 240 608 96 464 96 288s144-320 320-320 320 144 320 320c0 73.6-25.6 140.8-67.2 195.2l179.2 179.2v-140.8c0-22.4 19.2-38.4 38.4-38.4 22.4 0 38.4 19.2 38.4 41.6V764.8h3.2C924.8 800 889.6 800 889.6 800zM416 48c-131.2 0-236.8 105.6-236.8 236.8 0 131.2 105.6 236.8 236.8 236.8s236.8-105.6 236.8-236.8c0-131.2-105.6-236.8-236.8-236.8z" horiz-adv-x="1024" />
<glyph glyph-name="screen-restore" unicode="&#59224;" d="M582.6 454.6v320h50V540l274 274 35.4-35.4-274-274h234.6v-50h-320zM117.4-46l274 274v-234.6h50v320h-320v-50H356l-274-274 35.4-35.4zM132 764h302V814H82v-352h50V764z m760-760H590v-50h352V306h-50v-302z" horiz-adv-x="1024" />
<glyph glyph-name="password" unicode="&#58995;" d="M519.2 343.29999999999995c-41.1 0-74.4-33.3-74.4-74.4 0-29.7 17.5-55 42.5-67.1v-81.9c0-17.6 14.3-31.9 31.9-31.9 17.6 0 31.9 14.3 31.9 31.9v81.9c25.1 12 42.5 37.4 42.5 66.9 0 41.3-33.2 74.6-74.4 74.6zM827.6-62.10000000000002H189.4c-35.9 0-65.1 29.2-65.1 65.1V428.4c0 35.9 29.2 65.1 65.1 65.1h638.2c17.3 0 33.7-6.7 46-19.1 12.3-12.3 19.1-28.7 19.1-46V3c0-35.9-29.2-65.1-65.1-65.1zM231.9 427.2c-34.8 0-41.3-6.6-41.3-41.3v-340.4c0-34.8 6.6-41.3 41.3-41.3h553.2c34.8 0 41.3 6.6 41.3 41.3V385.9c0 34.8-6.6 41.3-41.3 41.3H231.9zM519.2 86.70000000000005c-18.3 0-33.2 14.8-33.2 33.2V201c-26.3 12.8-42.6 38.8-42.6 67.8 0 41.8 33.9 75.7 75.7 75.7s75.7-33.9 75.7-75.7c0-29-16.3-55-42.5-67.8v-81.1c0.1-18.2-14.9-33.2-33.1-33.2zM519.2 342c-40.4 0-73.2-32.9-73.2-73.2 0-28.3 16.1-53.6 41.9-65.8l0.7-0.4V120c0-17 13.7-30.7 30.7-30.7S550 103.10000000000002 550 120v82.6l0.7 0.4c25.8 12.3 41.9 37.5 41.9 65.8-0.2 40.4-33.1 73.2-73.4 73.2zM207 523.1c-9.1 0-17.6 3.5-23.9 10-6.4 6.4-10 15-10 23.9v2h-0.2l0.2 1.4c0.1 0.5 0.1 0.9 0.2 1.4l0.2 1c0.1 0.6 0.2 1.4 0.4 2 15.3 75.7 57 144.2 117.2 193 29.9 24.2 63.4 43 99.8 56 37.5 13.3 77 20.2 117.5 20.2 61 0 120.8-16.3 173-47.2 50.6-29.9 93-72.8 122.5-123.8 4-5.6 6.1-12.2 6.1-19.2 0-18.3-15-33.3-33.3-33.3-13.2 0-25.1 7.7-30.4 19.8-49.2 84.6-140.4 137.4-238 137.4-128.1 0-238.2-87.1-267.6-211.8v-0.2c-0.7-18.4-15.4-32.6-33.7-32.6z" horiz-adv-x="1024" />

Before

Width:  |  Height:  |  Size: 267 KiB

After

Width:  |  Height:  |  Size: 271 KiB

BIN
dist/font/iconfont.ttf vendored

Binary file not shown.

Binary file not shown.

View File

@ -1,2 +1,2 @@
/** layui-v2.3.0-rc1 MIT License By https://www.layui.com */
/** layui-v2.3.0 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&&(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)});

View File

@ -1,2 +1,2 @@
/** layui-v2.3.0-rc1 MIT License By https://www.layui.com */
/** layui-v2.3.0 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");

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
/** layui-v2.3.0-rc1 MIT License By https://www.layui.com */
/** layui-v2.3.0 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)});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
/** layui-v2.3.0-rc1 MIT License By https://www.layui.com */
/** layui-v2.3.0 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)});

View File

@ -1,2 +1,2 @@
/** layui-v2.3.0-rc1 MIT License By https://www.layui.com */
/** layui-v2.3.0 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)});

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
/** layui-v2.3.0-rc1 MIT License By https://www.layui.com */
/** layui-v2.3.0 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)});

File diff suppressed because one or more lines are too long

View File

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

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
/** layui-v2.3.0-rc1 MIT License By https://www.layui.com */
;layui.define("jquery",function(e){"use strict";var t=layui.$,i={fixbar:function(e){var i,o,a="layui-fixbar",r="layui-fixbar-top",n=t(document),l=t("body");e=t.extend({showHeight:200},e),e.bar1=e.bar1===!0?"&#xe606;":e.bar1,e.bar2=e.bar2===!0?"&#xe607;":e.bar2,e.bgcolor=e.bgcolor?"background-color:"+e.bgcolor:"";var c=[e.bar1,e.bar2,"&#xe604;"],g=t(['<ul class="'+a+'">',e.bar1?'<li class="layui-icon" lay-type="bar1" style="'+e.bgcolor+'">'+c[0]+"</li>":"",e.bar2?'<li class="layui-icon" lay-type="bar2" style="'+e.bgcolor+'">'+c[1]+"</li>":"",'<li class="layui-icon '+r+'" lay-type="top" style="'+e.bgcolor+'">'+c[2]+"</li>","</ul>"].join("")),s=g.find("."+r),u=function(){var t=n.scrollTop();t>=e.showHeight?i||(s.show(),i=1):i&&(s.hide(),i=0)};t("."+a)[0]||("object"==typeof e.css&&g.css(e.css),l.append(g),u(),g.find("li").on("click",function(){var i=t(this),o=i.attr("lay-type");"top"===o&&t("html,body").animate({scrollTop:0},200),e.click&&e.click.call(this,o)}),n.on("scroll",function(){clearTimeout(o),o=setTimeout(function(){u()},100)}))},countdown:function(e,t,i){var o=this,a="function"==typeof t,r=new Date(e).getTime(),n=new Date(!t||a?(new Date).getTime():t).getTime(),l=r-n,c=[Math.floor(l/864e5),Math.floor(l/36e5)%24,Math.floor(l/6e4)%60,Math.floor(l/1e3)%60];a&&(i=t);var g=setTimeout(function(){o.countdown(e,n+1e3,i)},1e3);return i&&i(l>0?c:[0,0,0,0],t,g),l<=0&&clearTimeout(g),g},timeAgo:function(e,t){var i=this,o=[[],[]],a=(new Date).getTime()-new Date(e).getTime();return a>6912e5?(a=new Date(e),o[0][0]=i.digit(a.getFullYear(),4),o[0][1]=i.digit(a.getMonth()+1),o[0][2]=i.digit(a.getDate()),t||(o[1][0]=i.digit(a.getHours()),o[1][1]=i.digit(a.getMinutes()),o[1][2]=i.digit(a.getSeconds())),o[0].join("-")+" "+o[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(e,t){var i="";e=String(e),t=t||2;for(var o=e.length;o<t;o++)i+="0";return e<Math.pow(10,t)?i+(0|e):e},toDateString:function(e,t){var i=this,o=new Date(e||new Date),a=[i.digit(o.getFullYear(),4),i.digit(o.getMonth()+1),i.digit(o.getDate())],r=[i.digit(o.getHours()),i.digit(o.getMinutes()),i.digit(o.getSeconds())];return t=t||"yyyy-MM-dd HH:mm:ss",t.replace(/yyyy/g,a[0]).replace(/MM/g,a[1]).replace(/dd/g,a[2]).replace(/HH/g,r[0]).replace(/mm/g,r[1]).replace(/ss/g,r[2])}};e("util",i)});
/** layui-v2.3.0 MIT License By https://www.layui.com */
;layui.define("jquery",function(e){"use strict";var t=layui.$,i={fixbar:function(e){var i,a,o="layui-fixbar",r="layui-fixbar-top",l=t(document),n=t("body");e=t.extend({showHeight:200},e),e.bar1=e.bar1===!0?"&#xe606;":e.bar1,e.bar2=e.bar2===!0?"&#xe607;":e.bar2,e.bgcolor=e.bgcolor?"background-color:"+e.bgcolor:"";var c=[e.bar1,e.bar2,"&#xe604;"],g=t(['<ul class="'+o+'">',e.bar1?'<li class="layui-icon" lay-type="bar1" style="'+e.bgcolor+'">'+c[0]+"</li>":"",e.bar2?'<li class="layui-icon" lay-type="bar2" style="'+e.bgcolor+'">'+c[1]+"</li>":"",'<li class="layui-icon '+r+'" lay-type="top" style="'+e.bgcolor+'">'+c[2]+"</li>","</ul>"].join("")),u=g.find("."+r),s=function(){var t=l.scrollTop();t>=e.showHeight?i||(u.show(),i=1):i&&(u.hide(),i=0)};t("."+o)[0]||("object"==typeof e.css&&g.css(e.css),n.append(g),s(),g.find("li").on("click",function(){var i=t(this),a=i.attr("lay-type");"top"===a&&t("html,body").animate({scrollTop:0},200),e.click&&e.click.call(this,a)}),l.on("scroll",function(){clearTimeout(a),a=setTimeout(function(){s()},100)}))},countdown:function(e,t,i){var a=this,o="function"==typeof t,r=new Date(e).getTime(),l=new Date(!t||o?(new Date).getTime():t).getTime(),n=r-l,c=[Math.floor(n/864e5),Math.floor(n/36e5)%24,Math.floor(n/6e4)%60,Math.floor(n/1e3)%60];o&&(i=t);var g=setTimeout(function(){a.countdown(e,l+1e3,i)},1e3);return i&&i(n>0?c:[0,0,0,0],t,g),n<=0&&clearTimeout(g),g},timeAgo:function(e,t){var i=this,a=[[],[]],o=(new Date).getTime()-new Date(e).getTime();return o>6912e5?(o=new Date(e),a[0][0]=i.digit(o.getFullYear(),4),a[0][1]=i.digit(o.getMonth()+1),a[0][2]=i.digit(o.getDate()),t||(a[1][0]=i.digit(o.getHours()),a[1][1]=i.digit(o.getMinutes()),a[1][2]=i.digit(o.getSeconds())),a[0].join("-")+" "+a[1].join(":")):o>=864e5?(o/1e3/60/60/24|0)+"天前":o>=36e5?(o/1e3/60/60|0)+"小时前":o>=12e4?(o/1e3/60|0)+"分钟前":o<0?"未来":"刚刚"},digit:function(e,t){var i="";e=String(e),t=t||2;for(var a=e.length;a<t;a++)i+="0";return e<Math.pow(10,t)?i+(0|e):e},toDateString:function(e,t){var i=this,a=new Date(e||new Date),o=[i.digit(a.getFullYear(),4),i.digit(a.getMonth()+1),i.digit(a.getDate())],r=[i.digit(a.getHours()),i.digit(a.getMinutes()),i.digit(a.getSeconds())];return t=t||"yyyy-MM-dd HH:mm:ss",t.replace(/yyyy/g,o[0]).replace(/MM/g,o[1]).replace(/dd/g,o[2]).replace(/HH/g,r[0]).replace(/mm/g,r[1]).replace(/ss/g,r[2])},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;")}};e("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

View File

@ -108,6 +108,14 @@ body{padding: 10px;}
<option value="音乐">音乐</option>
<option value="旅行">旅行</option>
<option value="读书">读书</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
</select>
</div>
</div>
@ -190,6 +198,10 @@ layui.use('form', function(){
}
}
,pass: [/(.+){6,12}$/, '密码必须6到12位']
,money: [
/^\d+\.\b\d{2}\b$/
,'金额必须为小数保留两位'
]
});
//初始赋值
@ -256,6 +268,27 @@ layui.use('form', function(){
<option disabled value="你工作的第一个城市">你工作的第一个城市</option>
<option value="你的工号">你的工号</option>
<option value="你最喜欢的老师">你最喜欢的老师</option>
<option value="你的工号">你的工号</option>
<option value="你的工号">你的工号</option>
<option value="你的工号">你的工号</option>
<option value="你的工号">你的工号</option>
<option value="你的工号">你的工号</option>
<option value="你的工号">你的工号</option>
<option value="你的工号">你的工号</option>
<option value="你的工号">你的工号</option>
<option value="你的工号">你的工号</option>
<option value="你的工号">你的工号</option>
<option value="你的工号">你的工号</option>
<option value="你的工号">你的工号</option>
<option value="你的工号">你的工号</option>
<option value="你的工号">你的工号</option>
<option value="你的工号">你的工号</option>
<option value="你的工号">你的工号</option>
<option value="你的工号">你的工号</option>
<option value="你的工号" selected>你的工号</option>
<option value="你的工号">你的工号</option>
<option value="你的工号">你的工号</option>
<option value="你的工号">你的工号</option>
</select>
<button>Go</button>
</form>

View File

@ -15,8 +15,6 @@ body{padding: 20px; /*overflow-y: scroll;*/}
</head>
<body>
<table id="test2" lay-filter="test2"></table>
<div class="layui-btn-group">
<button class="layui-btn" data-type="getCheckData">获取选中行数据</button>
<button class="layui-btn" data-type="getCheckLength">获取选中数目</button>
@ -46,6 +44,7 @@ body{padding: 20px; /*overflow-y: scroll;*/}
<span {{# if(!d.activate){ }}style="color:#999"{{# } }}>{{ d.email }}</span>
</script>
<table id="test2" lay-filter="test2"></table>
<table class="layui-table" lay-data="{width:800, height: 300, url:'json/table/demo2.json', page: true, limit: 6}">
<thead>
@ -180,6 +179,7 @@ layui.use('table', function(){
elem: '#test'
,height: 350
,url: 'json/table/demo1.json'
//,size: 'sm'
,page: {
}

View File

@ -1,147 +1,177 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>树模块 - layui</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>树模块 - layui</title>
<link rel="stylesheet" href="../src/css/layui.css">
<link rel="stylesheet" href="../src/css/layui.css">
<style>
body{padding: 50px 100px;}
</style>
<style>
body {
padding: 50px 100px;
}
</style>
</head>
<body>
<ul id="demo"></ul>
<ul id="demo"></ul>
<ul id="demo1" style="margin-top: 50px;"></ul>
<ul id="demo1" style="margin-top: 50px;"></ul>
<script src="../src/layui.js"></script>
<script>
layui.use('tree', function(){
var tree = layui.tree({
elem: '#demo' //指定元素
//,check: 'checkbox' //勾选风格
,skin: 'as' //设定皮肤
//,target: '_blank' //是否新选项卡打开比如节点返回href才有效
,drag: true
,click: function(item){ //点击节点回调
console.log(item)
}
,nodes: [ //节点
{
name: '常用文件夹'
,id: 1
,alias: 'changyong'
,children: [
{
name: '所有未读'
,id: 11
//,href: 'http://www.layui.com/'
,alias: 'weidu'
}, {
name: '置顶邮件'
,id: 12
}, {
name: '标签邮件'
,id: 13
}
]
}, {
name: '我的邮箱'
,id: 2
,spread: true
,children: [
{
name: 'QQ邮箱'
,id: 21
,spread: true
,children: [
{
name: '收件箱'
,id: 211
,children: [
{
name: '所有未读'
,id: 2111
}, {
name: '置顶邮件'
,id: 2112
}, {
name: '标签邮件'
,id: 2113
}
<script src="../src/layui.js"></script>
<script>
layui.use('tree', function() {
var tree = layui.tree({
elem: '#demo' //指定元素
,
check: 'checkbox' //勾选风格
,
skin: 'as' //设定皮肤
//,target: '_blank' //是否新选项卡打开比如节点返回href才有效
,
drag: true,
change:function(val){
console.group('change event')
console.log('Array')
console.log(val);
console.groupEnd()
},
click: function(item) { //点击节点回调
console.group('click event')
console.log('Object')
console.log(item);
console.groupEnd()
},
addClick:function(item,elem,add){
console.group('append event')
console.log('Object')
console.log(item);
console.log('dom')
console.log(elem);
console.log('dom add event')
var item ={
name: '测试节点',
id:-1
}
add(item)
console.groupEnd()
},
deleteClick:function(item,elem,done){
console.group('delete event')
console.log('Object')
console.log(item);
console.log('dom')
console.log(elem);
console.log('dom delete event')
done();
console.groupEnd()
},
nodes: [ //节点
{
name: '常用文件夹',
id: 1,
alias: 'changyong',
children: [{
name: '所有未读',
id: 11
//,href: 'http://www.layui.com/'
,
alias: 'weidu'
}, {
name: '置顶邮件',
id: 12
}, {
name: '标签邮件',
id: 13
}]
}, {
name: '我的邮箱',
id: 2,
spread: true,
children: [{
name: 'QQ邮箱',
id: 21,
spread: true,
children: [{
name: '收件箱',
id: 211,
children: [{
name: '所有未读',
id: 2111
}, {
name: '置顶邮件',
id: 2112
}, {
name: '标签邮件',
id: 2113
}]
}, {
name: '已发出的邮件',
id: 212
}, {
name: '垃圾邮件',
id: 213
}]
}, {
name: '阿里云邮',
id: 22,
children: [{
name: '收件箱',
id: 221
}, {
name: '已发出的邮件',
id: 222
}, {
name: '垃圾邮件',
id: 223
}]
}]
}
]
}, {
name: '已发出的邮件'
,id: 212
}, {
name: '垃圾邮件'
,id: 213
}
]
}, {
name: '阿里云邮'
,id: 22
,children: [
{
name: '收件箱'
,id: 221
}, {
name: '已发出的邮件'
,id: 222
}, {
name: '垃圾邮件'
,id: 223
}
]
}
]
}
]
});
//生成一个模拟树
var createTree = function(node, start){
node = node || function(){
var arr = [];
for(var i = 1; i < 10; i++){
arr.push({
name: i.toString().replace(/(\d)/, '$1$1$1$1$1$1$1$1$1')
});
//生成一个模拟树
var createTree = function(node, start) {
node = node || function() {
var arr = [];
for (var i = 1; i < 10; i++) {
arr.push({
name: i.toString().replace(/(\d)/, '$1$1$1$1$1$1$1$1$1')
});
}
return arr;
}();
start = start || 1;
layui.each(node, function(index, item) {
if (start < 10 && index < 9) {
var child = [{
name: (1 + index + start).toString().replace(/(\d)/, '$1$1$1$1$1$1$1$1$1')
}];
node[index].children = child;
createTree(child, index + start + 1);
}
});
return node;
};
layui.tree({
elem: '#demo1' //指定元素
,
nodes: createTree()
});
});
}
return arr;
}();
start = start || 1;
layui.each(node, function(index, item){
if(start < 10 && index < 9){
var child = [
{
name: (1 + index + start).toString().replace(/(\d)/, '$1$1$1$1$1$1$1$1$1')
}
];
node[index].children = child;
createTree(child, index + start + 1);
}
});
return node;
};
</script>
layui.tree({
elem: '#demo1' //指定元素
,nodes: createTree()
});
});
</script>
<pre class="layui-code">
# layui.tree-v2 备忘
* check参数 - checkbox、radio的支持
* 拖拽的支持
</pre>
<!--<pre class="layui-code">
# layui.tree-v2 备忘
* check参数 - checkbox、radio的支持
* 拖拽的支持
</pre>-->
</body>
</html>
</html>

View File

@ -93,6 +93,15 @@ layui.use('upload', function(){
,accept: 'file'
,fileAccept: 'image/*'
,exts: "jpg|png|gif|bmp|jpeg|pdf"
,data: { //额外参数
a: 1
,b: function(){
return 2
}
}
,choose: function(){
console.log(1)
}
,before: function(obj){
//预读本地文件示例不支持ie8
obj.preview(function(index, file, result){
@ -248,14 +257,24 @@ layui.use('upload', function(){
});
//手动上传
upload.render({
elem: '#test6'
,url: ''
,auto: false
//,multiple: true
,bindAction: '#test7'
,choose: function(obj){
var that = this;
obj.preview(function(index, file){
obj.resetFile(index, file, '123.jpg');
});
}
,before: function(){
console.log(345);
}
,done: function(res){
console.log(res)
console.log(res);
}
});
@ -263,7 +282,7 @@ layui.use('upload', function(){
elem: '#test8'
,url: ''
,done: function(res){
console.log(res)
console.log(res);
}
});
@ -271,7 +290,7 @@ layui.use('upload', function(){
elem: '#test9'
,url: ''
,done: function(res){
console.log(res)
console.log(res);
}
});

View File

@ -30,7 +30,7 @@ var argv = require('minimist')(process.argv.slice(2), {
]
//模块
,mods = 'laytpl,laypage,laydate,jquery,layer,element,upload,form,tree,table,carousel,util,flow,layedit,code'
,mods = 'laytpl,laypage,laydate,jquery,layer,element,upload,form,tree,table,carousel,rate,util,flow,layedit,code'
//发行版本目录
,releaseDir = './release/zip/layui-v' + pkg.version

View File

@ -1,9 +1,9 @@
{
"name": "layui-src",
"realname": "layui",
"version": "2.3.0-rc1",
"version": "2.3.0",
"independents": {
"layim": "3.7.6"
"layim": "3.7.7"
},
"description": "Classic modular front-end component library",
"main": "layui.js",

View File

@ -46,11 +46,11 @@ a cite{font-style: normal; *cursor:pointer;}
/** 图标字体 **/
@font-face {font-family: 'layui-icon';
src: url('../font/iconfont.eot?v=230-rc1');
src: url('../font/iconfont.eot?v=230-rc1#iefix') format('embedded-opentype'),
url('../font/iconfont.svg?v=230-rc1#iconfont') format('svg'),
url('../font/iconfont.woff?v=230-rc1') format('woff'),
url('../font/iconfont.ttf?v=230-rc1') format('truetype');
src: url('../font/iconfont.eot?v=230');
src: url('../font/iconfont.eot?v=230#iefix') format('embedded-opentype'),
url('../font/iconfont.svg?v=230#iconfont') format('svg'),
url('../font/iconfont.woff?v=230') format('woff'),
url('../font/iconfont.ttf?v=230') format('truetype');
}
.layui-icon{
@ -205,11 +205,12 @@ a cite{font-style: normal; *cursor:pointer;}
.layui-icon-template-1:before{content:"\e656"}
.layui-icon-vercode:before{content:"\e679"}
.layui-icon-cellphone:before{content:"\e678"}
.layui-icon-screen-full:before{content:"\e622";}
.layui-icon-screen-restore:before{content:"\e758";}
.layui-icon-checkbox:before{content:"\e624"}
.layui-icon-uncheckbox:before{content:"\e68c"}
/* 基本布局 */
.layui-main{position: relative; width: 1140px; margin: 0 auto;}
.layui-header{position: relative; z-index: 1000; height: 60px;}
@ -899,7 +900,7 @@ body .layui-table-tips .layui-layer-content{background: none; padding: 0; box-sh
/** 树组件(重写中) **/
.layui-tree{line-height: 26px;}
.layui-tree li{text-overflow: ellipsis; overflow:hidden; white-space: nowrap;}
.layui-tree li{position:relative;text-overflow: ellipsis; overflow:hidden; white-space: nowrap;}
.layui-tree li a,
.layui-tree li .layui-tree-spread{display: inline-block; vertical-align: top; height: 26px; *display: inline; *zoom:1; cursor: pointer;}
.layui-tree li a{font-size: 0;}
@ -908,11 +909,12 @@ body .layui-table-tips .layui-layer-content{background: none; padding: 0; box-sh
.layui-tree li i{padding-left: 6px; color: #333; -moz-user-select: none;}
.layui-tree li .layui-tree-check{font-size: 13px;}
.layui-tree li .layui-tree-check:hover{color: #009E94;}
.layui-tree li ul{display: none; margin-left: 20px;}
.layui-tree li ul{display: none; margin-left: 40px;}
.layui-tree li .layui-tree-enter{line-height: 24px; border: 1px dotted #000;}
.layui-tree-drag{display: none; position: absolute; left: -666px; top: -666px; background-color: #f2f2f2; padding: 5px 10px; border: 1px dotted #000; white-space: nowrap}
.layui-tree-drag i{padding-right: 5px;}
.layui-tree-menu{position: absolute;top:0;right: 0;z-index:1024;}
.layui-tree-menu span{margin-left: 10px;}
/** 导航菜单 **/
.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;}

View File

@ -144,6 +144,7 @@ layui.define('layer', function(exports){
index = select[0].selectedIndex; //获取最新的 selectedIndex
reElem.addClass(CLASS+'ed');
dds.removeClass(HIDE);
nearElem = null;
//初始选中样式
dds.eq(index).addClass(THIS).siblings().removeClass(THIS);
@ -231,6 +232,22 @@ layui.define('layer', function(exports){
//标注样式
nearDd.addClass(THIS).siblings().removeClass(THIS);
//定位滚动条
var ddThis = dl.children('dd.layui-this')
,posTop = ddThis.position().top
,dlHeight = dl.height()
,ddHeight = ddThis.height();
//若选中元素在滚动条不可见底部
if(posTop > dlHeight){
dl.scrollTop(posTop + dl.scrollTop() - dlHeight + ddHeight - 5);
}
//若选择玄素在滚动条不可见顶部
if(posTop < 0){
dl.scrollTop(posTop + dl.scrollTop());
}
};

View File

@ -377,7 +377,7 @@
,range: false //是否开启范围选择,即双控件
,format: 'yyyy-MM-dd' //默认日期格式
,value: null //默认日期支持传入new Date()或者符合format参数设定的日期格式字符
,isInitValue: false //用于控制是否自动向元素填充初始值(需配合 value 参数使用)
,isInitValue: true //用于控制是否自动向元素填充初始值(需配合 value 参数使用)
,min: '1900-1-1' //有效最小日期,年月日必须用“-”分割,时分秒必须用“:”分割。注意:它并不是遵循 format 设定的格式。
,max: '2099-12-31' //有效最大日期,同上
,trigger: 'focus' //呼出控件的事件

View File

@ -1,215 +1,348 @@
/**
@Namelayui.tree 树组件
@Author贤心
@Namelayui.tree2.0 树组件
@Authorsmallwei
@LicenseMIT
*/
layui.define('jquery', function(exports){
"use strict";
var $ = layui.$
,hint = layui.hint();
var enterSkin = 'layui-tree-enter', Tree = function(options){
this.options = options;
};
//图标
var icon = {
arrow: ['&#xe623;', '&#xe625;'] //箭头
,checkbox: ['&#xe626;', '&#xe627;'] //复选框
,radio: ['&#xe62b;', '&#xe62a;'] //单选框
,branch: ['&#xe622;', '&#xe624;'] //父节点
,leaf: '&#xe621;' //叶节点
};
//初始化
Tree.prototype.init = function(elem){
var that = this;
elem.addClass('layui-box layui-tree'); //添加tree样式
if(that.options.skin){
elem.addClass('layui-tree-skin-'+ that.options.skin);
}
that.tree(elem);
that.on(elem);
};
//树节点解析
Tree.prototype.tree = function(elem, children){
var that = this, options = that.options
var nodes = children || options.nodes;
layui.each(nodes, function(index, item){
var hasChild = item.children && item.children.length > 0;
var ul = $('<ul class="'+ (item.spread ? "layui-show" : "") +'"></ul>');
var li = $(['<li '+ (item.spread ? 'data-spread="'+ item.spread +'"' : '') +'>'
//展开箭头
,function(){
return hasChild ? '<i class="layui-icon layui-tree-spread">'+ (
item.spread ? icon.arrow[1] : icon.arrow[0]
) +'</i>' : '';
}()
//复选框/单选框
,function(){
return options.check ? (
'<i class="layui-icon layui-tree-check">'+ (
options.check === 'checkbox' ? icon.checkbox[0] : (
options.check === 'radio' ? icon.radio[0] : ''
)
) +'</i>'
) : '';
}()
//节点
,function(){
return '<a href="'+ (item.href || 'javascript:;') +'" '+ (
options.target && item.href ? 'target=\"'+ options.target +'\"' : ''
) +'>'
+ ('<i class="layui-icon layui-tree-'+ (hasChild ? "branch" : "leaf") +'">'+ (
hasChild ? (
item.spread ? icon.branch[1] : icon.branch[0]
) : icon.leaf
) +'</i>') //节点图标
+ ('<cite>'+ (item.name||'未命名') +'</cite></a>');
}()
,'</li>'].join(''));
//如果有子节点,则递归继续生成树
if(hasChild){
li.append(ul);
that.tree(ul, item.children);
}
elem.append(li);
//触发点击节点回调
typeof options.click === 'function' && that.click(li, item);
//伸展节点
that.spread(li, item);
//拖拽节点
options.drag && that.drag(li, item);
});
};
//点击节点回调
Tree.prototype.click = function(elem, item){
var that = this, options = that.options;
elem.children('a').on('click', function(e){
layui.stope(e);
options.click(item)
});
};
//伸展节点
Tree.prototype.spread = function(elem, item){
var that = this, options = that.options;
var arrow = elem.children('.layui-tree-spread')
var ul = elem.children('ul'), a = elem.children('a');
//执行伸展
var open = function(){
if(elem.data('spread')){
elem.data('spread', null)
ul.removeClass('layui-show');
arrow.html(icon.arrow[0]);
a.find('.layui-icon').html(icon.branch[0]);
} else {
elem.data('spread', true);
ul.addClass('layui-show');
arrow.html(icon.arrow[1]);
a.find('.layui-icon').html(icon.branch[1]);
}
};
//如果没有子节点,则不执行
if(!ul[0]) return;
arrow.on('click', open);
a.on('dblclick', open);
}
//通用事件
Tree.prototype.on = function(elem){
var that = this, options = that.options;
var dragStr = 'layui-tree-drag';
//屏蔽选中文字
elem.find('i').on('selectstart', function(e){
return false
});
//拖拽
if(options.drag){
$(document).on('mousemove', function(e){
var move = that.move;
if(move.from){
var to = move.to, treeMove = $('<div class="layui-box '+ dragStr +'"></div>');
e.preventDefault();
$('.' + dragStr)[0] || $('body').append(treeMove);
var dragElem = $('.' + dragStr)[0] ? $('.' + dragStr) : treeMove;
(dragElem).addClass('layui-show').html(move.from.elem.children('a').html());
dragElem.css({
left: e.pageX + 10
,top: e.pageY + 10
})
}
}).on('mouseup', function(){
var move = that.move;
if(move.from){
move.from.elem.children('a').removeClass(enterSkin);
move.to && move.to.elem.children('a').removeClass(enterSkin);
that.move = {};
$('.' + dragStr).remove();
}
});
}
};
//拖拽节点
Tree.prototype.move = {};
Tree.prototype.drag = function(elem, item){
var that = this, options = that.options;
var a = elem.children('a'), mouseenter = function(){
var othis = $(this), move = that.move;
if(move.from){
move.to = {
item: item
,elem: elem
};
othis.addClass(enterSkin);
}
};
a.on('mousedown', function(){
var move = that.move
move.from = {
item: item
,elem: elem
};
});
a.on('mouseenter', mouseenter).on('mousemove', mouseenter)
.on('mouseleave', function(){
var othis = $(this), move = that.move;
if(move.from){
delete move.to;
othis.removeClass(enterSkin);
}
});
};
//暴露接口
exports('tree', function(options){
var tree = new Tree(options = options || {});
var elem = $(options.elem);
if(!elem[0]){
return hint.error('layui.tree 没有找到'+ options.elem +'元素');
}
tree.init(elem);
});
});
layui.define('jquery', function(exports) {
"use strict";
var $ = layui.$,
hint = layui.hint();
var enterSkin = 'layui-tree-enter',
Tree = function(options) {
this.options = options;
};
//勾选集合
var changeList = [];
//图标
var icon = {
arrow: ['&#xe623;', '&#xe625;'] //箭头
,
checkbox: ['&#xe68c;', '&#xe624;'] //复选框
,
leaf: '&#xe621;' //叶节点
};
//初始化
Tree.prototype.init = function(elem) {
var that = this;
elem.addClass('layui-box layui-tree'); //添加tree样式
if(that.options.skin) {
elem.addClass('layui-tree-skin-' + that.options.skin);
}
that.tree(elem);
that.on(elem);
};
//树节点解析
Tree.prototype.tree = function(elem, children) {
var that = this,
options = that.options
var nodes = children || options.nodes;
layui.each(nodes, function(index, item) {
var hasChild = item.children && item.children.length > 0;
var ul = $('<ul class="' + (item.spread ? "layui-show" : "") + '"></ul>');
var li = that.getNode(item, hasChild);
//如果有子节点,则递归继续生成树
if(hasChild) {
li.append(ul);
that.tree(ul, item.children);
}
//伸展节点
that.spread(li, item);
that.bindUlEvent(li, item);
elem.append(li);
});
};
Tree.prototype.getDom = function() {
var that = this,
options = that.options
return {
spread: function(item, hasChild) {
return hasChild ? '<i class="layui-icon layui-tree-spread">' + (
item.spread ? icon.arrow[1] : icon.arrow[0]
) + '</i>' : '';
},
checkbox: function(item) {
return options.check ? (
'<i class="layui-icon layui-tree-check">' + (
options.check === 'checkbox' ? icon.checkbox[0] : (
options.check === 'radio' ? icon.radio[0] : ''
)
) + '</i>'
) : '';
},
node: function(item) {
return '<a href="' + (item.href || 'javascript:;') + '" ' + (
options.target && item.href ? 'target=\"' + options.target + '\"' : ''
) + '>' +
('<cite>' + (item.name || '未命名') + '</cite></a>')
},
menu: function(item) {
return '<div class="layui-tree-menu">' +
'<span class="layui-tree-add">Add</span>' +
'<span class="layui-tree-delete">Delete</span>' +
'</div>'
}
}
}
//获取树节点
Tree.prototype.getNode = function(item, hasChild) {
var that = this,
options = that.options
var dom = that.getDom();
var li = $(['<li ' + (item.spread ? 'data-spread="' + item.spread + '"' : '') + '>'
//展开箭头
,
dom.spread(item, hasChild)
//复选框/单选框
,
dom.checkbox(item)
//节点
,
dom.node(item)
//菜单
,
dom.menu()
,
'</li>'
].join(''));
return li;
}
//父绑定事件
Tree.prototype.bindUlEvent = function(li, item) {
var that = this,
options = that.options
//触发点击节点回调
typeof options.click === 'function' && that.click(li, item);
//节点选择
typeof options.change === 'function' && options.check === 'checkbox' && that.checkbox(li, item);
//新增方法
typeof options.addClick === 'function' && that.add(li, item);
//删除方法
typeof options.deleteClick === 'function' && that.delete(li, item);
//拖拽节点
options.drag && that.drag(li, item);
}
//选中回调函数
Tree.prototype.change = function() {
var that = this,
options = that.options;
options.change(changeList);
},
//新增方法回调
Tree.prototype.add = function(elem, item) {
var that = this,
options = that.options;
var addBtn = elem.children('.layui-tree-menu').children('.layui-tree-add')
var arrow = elem.children('.layui-tree-spread')
var ul = elem.children('ul'),
a = elem.children('a');
var addEvent = function(e) {
layui.stope(e);
var _addEvent = {
add: function(itemAddObj) {
if(!ul[0]) {
ul = $('<ul class="layui-show"></ul>');
elem.append(ul);
}
if(!arrow[0]) {
arrow = $('<i class="layui-icon layui-tree-spread">' + icon.arrow[1] + '</i>');
elem.prepend(arrow);
that.spread(elem, item);
}
if(!elem.data('spread')) {
that.open(elem, ul, arrow)
}
var li = that.getNode(itemAddObj, false);
that.bindUlEvent(li, itemAddObj);
ul.append(li);
}
}
options.addClick(item, elem, _addEvent.add)
}
addBtn.on('click', addEvent);
}
//删除方法回调
Tree.prototype.delete = function(elem, item) {
var that = this,
options = that.options;
var deleteBtn = elem.children('.layui-tree-menu').children('.layui-tree-delete')
var ul = elem.children('ul'),
a = elem.children('a');
var deleteEvent = function(e) {
layui.stope(e);
var _deleteEvent = {
done: function() {
elem.html('');
}
}
options.deleteClick(item, elem, _deleteEvent.done)
}
deleteBtn.on('click', deleteEvent);
}
//点击节点回调
Tree.prototype.click = function(elem, item) {
var that = this,
options = that.options;
elem.children('a').on('click', function(e) {
layui.stope(e);
options.click(item)
});
};
//节点选择
Tree.prototype.checkbox = function(elem, item) {
var that = this,
options = that.options;
var checkbox = elem.children('.layui-tree-check')
var ul = elem.children('ul'),
a = elem.children('a');
var check = function() {
var index = layui.findObj(changeList, item);
if(elem.data('check')) {
elem.data('check', null)
checkbox.html(icon.checkbox[0]);
} else {
elem.data('check', true);
checkbox.html(icon.checkbox[1]);
}
if(index === -1) {
changeList.push(item);
} else {
changeList.splice(index, 1);
}
that.change();
}
checkbox.on('click', check);
};
//伸展节点
Tree.prototype.spread = function(elem, item) {
var that = this,
options = that.options;
var arrow = elem.children('.layui-tree-spread')
var ul = elem.children('ul'),
a = elem.children('a');
//如果没有子节点,则不执行
if(!ul[0]) return;
arrow.on('click', function() {
that.open(elem, ul, arrow)
});
}
//打开节点
Tree.prototype.open = function(elem, ul, arrow) {
if(elem.data('spread')) {
elem.data('spread', null)
ul.removeClass('layui-show');
arrow.html(icon.arrow[0]);
} else {
elem.data('spread', true);
ul.addClass('layui-show');
arrow.html(icon.arrow[1]);
}
};
//通用事件
Tree.prototype.on = function(elem) {
var that = this,
options = that.options;
var dragStr = 'layui-tree-drag';
//屏蔽选中文字
elem.find('i').on('selectstart', function(e) {
return false
});
//拖拽
if(options.drag) {
$(document).on('mousemove', function(e) {
var move = that.move;
if(move.from) {
var to = move.to,
treeMove = $('<div class="layui-box ' + dragStr + '"></div>');
e.preventDefault();
$('.' + dragStr)[0] || $('body').append(treeMove);
var dragElem = $('.' + dragStr)[0] ? $('.' + dragStr) : treeMove;
(dragElem).addClass('layui-show').html(move.from.elem.children('a').html());
dragElem.css({
left: e.pageX + 10,
top: e.pageY + 10
})
}
}).on('mouseup', function() {
var move = that.move;
if(move.from) {
move.from.elem.children('a').removeClass(enterSkin);
move.to && move.to.elem.children('a').removeClass(enterSkin);
that.move = {};
$('.' + dragStr).remove();
}
});
}
};
//拖拽节点
Tree.prototype.move = {};
Tree.prototype.drag = function(elem, item) {
var that = this,
options = that.options;
var a = elem.children('a'),
mouseenter = function() {
var othis = $(this),
move = that.move;
if(move.from) {
move.to = {
item: item,
elem: elem
};
othis.addClass(enterSkin);
}
};
a.on('mousedown', function() {
var move = that.move
move.from = {
item: item,
elem: elem
};
});
a.on('mouseenter', mouseenter).on('mousemove', mouseenter)
.on('mouseleave', function() {
var othis = $(this),
move = that.move;
if(move.from) {
delete move.to;
othis.removeClass(enterSkin);
}
});
};
//暴露接口
exports('tree', function(options) {
var tree = new Tree(options = options || {});
var elem = $(options.elem);
if(!elem[0]) {
return hint.error('layui.tree 没有找到' + options.elem + '元素');
}
tree.init(elem);
});
});

View File

@ -127,11 +127,11 @@ layui.define('layer' , function(exports){
$('#'+ ELEM_IFRAME)[0] || $('body').append(iframe);
//包裹文件域
if(!options.elem.next().hasClass(ELEM_IFRAME)){
if(!options.elem.next().hasClass(ELEM_FORM)){
that.elemFile.wrap(elemForm);
//追加额外的参数
options.elem.next('.'+ ELEM_IFRAME).append(function(){
options.elem.next('.'+ ELEM_FORM).append(function(){
var arr = [];
layui.each(options.data, function(key, value){
value = typeof value === 'function' ? value() : value;
@ -288,14 +288,17 @@ layui.define('layer' , function(exports){
//回调返回的参数
,args = {
//预览
preview: function(callback){
that.preview(callback);
}
//上传
,upload: function(index, file){
var thisFile = {};
thisFile[index] = file;
that.upload(thisFile);
}
//追加文件到队列
,pushFile: function(){
that.files = that.files || {};
layui.each(that.chooseFiles, function(index, item){
@ -303,12 +306,22 @@ layui.define('layer' , function(exports){
});
return that.files;
}
//重置文件
,resetFile: function(index, file, filename){
var newFile = new File([file], filename);
that.files = that.files || {};
that.files[index] = newFile;
}
}
//提交上传
,send = function(){
if(type === 'choose'){
return options.choose && options.choose(args);
,send = function(){
//选择文件的回调
if(type === 'choose' || options.auto){
options.choose && options.choose(args);
if(type === 'choose'){
return;
}
}
//上传前的回调

View File

@ -164,6 +164,13 @@ layui.define('jquery', function(exports){
.replace(/mm/g, hms[1])
.replace(/ss/g, hms[2]);
}
//防 xss 攻击
,escape: function(html){
return String(html || '').replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&amp;')
.replace(/</g, '&lt;').replace(/>/g, '&gt;')
.replace(/'/g, '&#39;').replace(/"/g, '&quot;');
}
};
exports('util', util);

View File

@ -19,7 +19,7 @@
}
,Layui = function(){
this.v = '2.3.0-rc1'; //版本号
this.v = '2.3.0'; //版本号
}
//获取layui所在目录
@ -430,7 +430,20 @@
error: error
}
};
//判断对象是否相等
Layui.prototype.isEqualObj = function(obj1,obj2){
return JSON.stringify(obj1)===JSON.stringify(obj2)
}
//寻找对象是否存在数组中
Layui.prototype.findObj = function(list,obj) {
var that = this,
result = -1;
that.each(list, function(index, item) {
if(that.isEqualObj(obj,item))result = index;
})
return result;
}
//遍历
Layui.prototype.each = function(obj, fn){
var key