2.0.0
28
.gitignore
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
*.iml
|
||||
.idea/
|
||||
.ipr
|
||||
.iws
|
||||
*~
|
||||
~*
|
||||
*.diff
|
||||
*.patch
|
||||
*.bak
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
.svn/
|
||||
*.swp
|
||||
.nojekyll
|
||||
.project
|
||||
.settings/
|
||||
node_modules/
|
||||
_site/
|
||||
run.bat
|
||||
dir.txt
|
||||
/**/layim/
|
||||
/**/layim.js
|
||||
/**/layim-mobile.js
|
||||
/**/layim.html
|
||||
/**/layim.m.html
|
||||
release/
|
||||
build/
|
||||
|
3
CHANGELOG.md
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
# 更新日志
|
||||
* [2.0.0](http://www.layui.com/doc/base/changelog.html#2-0-0)
|
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2016 layui
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
111
README.md
Normal file
@ -0,0 +1,111 @@
|
||||
<p align=center>
|
||||
<a href="http://www.layui.com">
|
||||
<img src="http://cdn.layui.com/upload/2016_10/168_1476644144774_50450.png" alt="layui" width="520">
|
||||
</a>
|
||||
</p>
|
||||
<p align=center>
|
||||
经典模块化前端UI框架
|
||||
</p>
|
||||
|
||||
---
|
||||
|
||||
Layui 是一款采用自身模块规范编写的情怀型前端UI框架,遵循原生HTML/CSS/JS的书写与组织形式,门槛极低,拿来即用。其外在极简,却又不失饱满的内在,体积轻盈,组件丰盈,从核心代码到API的每一处细节都经过精心雕琢,非常适合界面的快速开发。Layui 首个版本发布于2016年金秋,她区别于那些基于MVVM底层的UI框架,却并非逆道而行,而是信奉返璞归真之道。准确地说,她更多是为服务端程序员量身定做,你无需涉足各种前端工具的复杂配置,只需面对浏览器本身,让一切你所需要的元素与交互,从这里信手拈来。
|
||||
|
||||
## 返璞归真
|
||||
|
||||
Layui 定义为“经典模块化”,并非是自吹她自身有多优秀,而是有意避开当下JS社区的主流方案,试图以最简单的方式去诠释高效!<em>她的所谓经典,是在于对返璞归真的执念</em>,她以当前浏览器普通认可的方式去组织模块!我们认为,这恰是符合当下国内绝大多数程序员从旧时代过渡到未来新标准的最佳指引。所以 Layui 本身也并不是完全遵循于AMD时代,准确地说,她试图建立自己的模式,所以你会看到:
|
||||
|
||||
```
|
||||
//layui模块的定义
|
||||
layui.define([mods], function(exports){
|
||||
|
||||
//……
|
||||
|
||||
exports('mod', api);
|
||||
});
|
||||
|
||||
//layui模块的使用
|
||||
layui.use(['mod1', 'mod2'], function(args){
|
||||
var mod = layui.mod1;
|
||||
|
||||
//……
|
||||
|
||||
});
|
||||
|
||||
```
|
||||
没错,她具备AMD的影子,又并非受限于commonjs的那些条条框框,Layui认为这种轻量的组织方式,比WebPack更符合绝大多数场景。所以她坚持采用经典模块化,也正是能让人避开工具的复杂配置,回归简单,安静高效地撸一会原生态的HTML、CSS、JavaScript。
|
||||
|
||||
但是 Layui 又并非是Requirejs那样的模块加载器,而是一款UI解决方案,她与Bootstrap最大的不同恰恰在于她糅合了自身对经典模块化的理解。
|
||||
|
||||
|
||||
## 快速上手
|
||||
|
||||
获得layui后,将其完整地部署到你的项目目录(或静态资源服务器),你只需要引入下述两个文件:
|
||||
|
||||
```
|
||||
./layui/css/layui.css
|
||||
./layui/layui.js //提示:如果是采用非模块化方式(最下面有讲解),此处可换成:./layui/layui.all.js
|
||||
```
|
||||
|
||||
不用去管其它任何文件。因为他们(比如各模块)都是在最终使用的时候才会自动加载。这是一个基本的入门页面:
|
||||
|
||||
```
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<title>开始使用Layui</title>
|
||||
<link rel="stylesheet" href="../layui/css/layui.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- 你的HTML代码 -->
|
||||
|
||||
<script src="../layui/layui.js"></script>
|
||||
<script>
|
||||
//一般直接写在一个js文件中
|
||||
layui.use(['layer', 'form'], function(){
|
||||
var layer = layui.layer
|
||||
,form = layui.form;
|
||||
|
||||
layer.msg('Hello World');
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
如果你想采用非模块化方式(即所有模块一次性加载,尽管我们并不推荐你这么做),你也可以按照下面的方式使用:
|
||||
|
||||
```
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<title>非模块化方式使用Layui</title>
|
||||
<link rel="stylesheet" href="../layui/css/layui.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- 你的HTML代码 -->
|
||||
|
||||
<script src="../layui/layui.all.js"></script>
|
||||
<script>
|
||||
//由于模块都一次性加载,因此不用执行 layui.use() 来加载对应模块,直接使用即可:
|
||||
;!function(){
|
||||
var layer = layui.layer
|
||||
,form = layui.form;
|
||||
|
||||
layer.msg('Hello World');
|
||||
}();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
## [阅读文档](http://www.layui.com/)
|
||||
从现在开始,尽情地拥抱 layui 吧!但愿她能成为你长远的开发伴侣,化作你方寸屏幕前的亿万字节!
|
||||
|
||||
## 相关
|
||||
[官网](http://www.layui.com/)、[更新日志](http://www.layui.com/doc/base/changelog.html)、[社区交流](http://fly.layui.com)
|
19
bower.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "layui",
|
||||
"main": "src/layui.js",
|
||||
"version": "2.0.0",
|
||||
"homepage": "https://github.com/sentsin/layui",
|
||||
"authors": [
|
||||
"sentsin <xu@sentsin.com>"
|
||||
],
|
||||
"description": "模块化前端UI框架",
|
||||
"moduleType": [
|
||||
"amd",
|
||||
"globals"
|
||||
],
|
||||
"keywords": [
|
||||
"layui",
|
||||
"ui"
|
||||
],
|
||||
"license": "MIT"
|
||||
}
|
2
dist/css/layui.css
vendored
Normal file
2
dist/css/layui.mobile.css
vendored
Normal file
2
dist/css/modules/code.css
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/** layui-v2.0.0 MIT License By http://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
Normal file
BIN
dist/css/modules/layer/default/icon-ext.png
vendored
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
dist/css/modules/layer/default/icon.png
vendored
Normal file
After Width: | Height: | Size: 11 KiB |
2
dist/css/modules/layer/default/layer.css
vendored
Normal file
BIN
dist/css/modules/layer/default/loading-0.gif
vendored
Normal file
After Width: | Height: | Size: 5.7 KiB |
BIN
dist/css/modules/layer/default/loading-1.gif
vendored
Normal file
After Width: | Height: | Size: 701 B |
BIN
dist/css/modules/layer/default/loading-2.gif
vendored
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
dist/font/iconfont.eot
vendored
Normal file
402
dist/font/iconfont.svg
vendored
Normal file
After Width: | Height: | Size: 200 KiB |
BIN
dist/font/iconfont.ttf
vendored
Normal file
BIN
dist/font/iconfont.woff
vendored
Normal file
BIN
dist/images/face/0.gif
vendored
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
dist/images/face/1.gif
vendored
Normal file
After Width: | Height: | Size: 5.4 KiB |
BIN
dist/images/face/10.gif
vendored
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
dist/images/face/11.gif
vendored
Normal file
After Width: | Height: | Size: 4.0 KiB |
BIN
dist/images/face/12.gif
vendored
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
dist/images/face/13.gif
vendored
Normal file
After Width: | Height: | Size: 7.3 KiB |
BIN
dist/images/face/14.gif
vendored
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
dist/images/face/15.gif
vendored
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
dist/images/face/16.gif
vendored
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
dist/images/face/17.gif
vendored
Normal file
After Width: | Height: | Size: 4.3 KiB |
BIN
dist/images/face/18.gif
vendored
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
dist/images/face/19.gif
vendored
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
dist/images/face/2.gif
vendored
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
dist/images/face/20.gif
vendored
Normal file
After Width: | Height: | Size: 5.0 KiB |
BIN
dist/images/face/21.gif
vendored
Normal file
After Width: | Height: | Size: 5.1 KiB |
BIN
dist/images/face/22.gif
vendored
Normal file
After Width: | Height: | Size: 9.6 KiB |
BIN
dist/images/face/23.gif
vendored
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
dist/images/face/24.gif
vendored
Normal file
After Width: | Height: | Size: 7.9 KiB |
BIN
dist/images/face/25.gif
vendored
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
dist/images/face/26.gif
vendored
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
dist/images/face/27.gif
vendored
Normal file
After Width: | Height: | Size: 4.3 KiB |
BIN
dist/images/face/28.gif
vendored
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
dist/images/face/29.gif
vendored
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
dist/images/face/3.gif
vendored
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
dist/images/face/30.gif
vendored
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
dist/images/face/31.gif
vendored
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
dist/images/face/32.gif
vendored
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
dist/images/face/33.gif
vendored
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
dist/images/face/34.gif
vendored
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
dist/images/face/35.gif
vendored
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
dist/images/face/36.gif
vendored
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
dist/images/face/37.gif
vendored
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
dist/images/face/38.gif
vendored
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
dist/images/face/39.gif
vendored
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
dist/images/face/4.gif
vendored
Normal file
After Width: | Height: | Size: 5.6 KiB |
BIN
dist/images/face/40.gif
vendored
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
dist/images/face/41.gif
vendored
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
dist/images/face/42.gif
vendored
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
dist/images/face/43.gif
vendored
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
dist/images/face/44.gif
vendored
Normal file
After Width: | Height: | Size: 4.0 KiB |
BIN
dist/images/face/45.gif
vendored
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
dist/images/face/46.gif
vendored
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
dist/images/face/47.gif
vendored
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
dist/images/face/48.gif
vendored
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
dist/images/face/49.gif
vendored
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
dist/images/face/5.gif
vendored
Normal file
After Width: | Height: | Size: 4.5 KiB |
BIN
dist/images/face/50.gif
vendored
Normal file
After Width: | Height: | Size: 5.7 KiB |
BIN
dist/images/face/51.gif
vendored
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
dist/images/face/52.gif
vendored
Normal file
After Width: | Height: | Size: 777 B |
BIN
dist/images/face/53.gif
vendored
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
dist/images/face/54.gif
vendored
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
dist/images/face/55.gif
vendored
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
dist/images/face/56.gif
vendored
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
dist/images/face/57.gif
vendored
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
dist/images/face/58.gif
vendored
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
dist/images/face/59.gif
vendored
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
dist/images/face/6.gif
vendored
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
dist/images/face/60.gif
vendored
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
dist/images/face/61.gif
vendored
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
dist/images/face/62.gif
vendored
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
dist/images/face/63.gif
vendored
Normal file
After Width: | Height: | Size: 5.7 KiB |
BIN
dist/images/face/64.gif
vendored
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
dist/images/face/65.gif
vendored
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
dist/images/face/66.gif
vendored
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
dist/images/face/67.gif
vendored
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
dist/images/face/68.gif
vendored
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
dist/images/face/69.gif
vendored
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
dist/images/face/7.gif
vendored
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
dist/images/face/70.gif
vendored
Normal file
After Width: | Height: | Size: 4.5 KiB |
BIN
dist/images/face/71.gif
vendored
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
dist/images/face/8.gif
vendored
Normal file
After Width: | Height: | Size: 4.0 KiB |
BIN
dist/images/face/9.gif
vendored
Normal file
After Width: | Height: | Size: 4.1 KiB |
2
dist/lay/modules/carousel.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/** layui-v2.0.0 MIT License By http://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",o=">*[carousel-item]>*",l="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(o),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.indicator(),e.elemItem.length<=1||(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?"":"")+"</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,o=n.elemItem,u=n.config,c=u.index,m=u.elem.attr("lay-filter");n.haveSlide||("sub"===e?(n.subIndex(i),setTimeout(function(){o.eq(u.index).addClass(d),setTimeout(function(){o.eq(c).addClass(r),o.eq(u.index).addClass(r)},50)},50)):(n.addIndex(i),setTimeout(function(){o.eq(u.index).addClass(s),setTimeout(function(){o.eq(c).addClass(l),o.eq(u.index).addClass(l)},50)},50)),setTimeout(function(){o.removeClass(a+" "+d+" "+s+" "+l+" "+r),o.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:o.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
Normal file
@ -0,0 +1,2 @@
|
||||
/** layui-v2.0.0 MIT License By http://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/element.js
vendored
Normal file
2
dist/lay/modules/flow.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/** layui-v2.0.0 MIT License By http://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)});
|