├── .gitignore ├── README.md ├── index.html └── layui ├── css ├── layui.css ├── layui.mobile.css └── modules │ ├── code.css │ ├── laydate │ └── default │ │ ├── font.css │ │ └── laydate.css │ └── layer │ └── default │ ├── icon-ext.png │ ├── icon.png │ ├── layer.css │ ├── loading-0.gif │ ├── loading-1.gif │ └── loading-2.gif ├── font ├── iconfont.eot ├── iconfont.svg ├── iconfont.ttf └── iconfont.woff ├── images └── face │ ├── 0.gif │ ├── 1.gif │ ├── 10.gif │ ├── 11.gif │ ├── 12.gif │ ├── 13.gif │ ├── 14.gif │ ├── 15.gif │ ├── 16.gif │ ├── 17.gif │ ├── 18.gif │ ├── 19.gif │ ├── 2.gif │ ├── 20.gif │ ├── 21.gif │ ├── 22.gif │ ├── 23.gif │ ├── 24.gif │ ├── 25.gif │ ├── 26.gif │ ├── 27.gif │ ├── 28.gif │ ├── 29.gif │ ├── 3.gif │ ├── 30.gif │ ├── 31.gif │ ├── 32.gif │ ├── 33.gif │ ├── 34.gif │ ├── 35.gif │ ├── 36.gif │ ├── 37.gif │ ├── 38.gif │ ├── 39.gif │ ├── 4.gif │ ├── 40.gif │ ├── 41.gif │ ├── 42.gif │ ├── 43.gif │ ├── 44.gif │ ├── 45.gif │ ├── 46.gif │ ├── 47.gif │ ├── 48.gif │ ├── 49.gif │ ├── 5.gif │ ├── 50.gif │ ├── 51.gif │ ├── 52.gif │ ├── 53.gif │ ├── 54.gif │ ├── 55.gif │ ├── 56.gif │ ├── 57.gif │ ├── 58.gif │ ├── 59.gif │ ├── 6.gif │ ├── 60.gif │ ├── 61.gif │ ├── 62.gif │ ├── 63.gif │ ├── 64.gif │ ├── 65.gif │ ├── 66.gif │ ├── 67.gif │ ├── 68.gif │ ├── 69.gif │ ├── 7.gif │ ├── 70.gif │ ├── 71.gif │ ├── 8.gif │ └── 9.gif ├── lay ├── all-mobile.js ├── all.js └── modules │ ├── carousel.js │ ├── code.js │ ├── colorpicker.js │ ├── element.js │ ├── flow.js │ ├── form.js │ ├── jquery.js │ ├── laydate.js │ ├── layedit.js │ ├── layer.js │ ├── laypage.js │ ├── laytpl.js │ ├── mobile.js │ ├── mobile │ ├── layer-mobile.js │ ├── layim-mobile-open.js │ ├── upload-mobile.js │ └── zepto.js │ ├── rate.js │ ├── slider.js │ ├── table.js │ ├── tree.js │ ├── upload.js │ └── util.js └── layui.js /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## 为 layui 扩展的 下拉多选select 2 | 当前layui版本:**2.4.5** (历史版本可在[release](https://github.com/yelog/layui-select-multiple/releases)中找到) 3 | 在线demo: [http://yelog.org/layui-select-multiple/](http://yelog.org/layui-select-multiple/) 4 | 5 | 这个在线 demo就是本项目的 `index.html`。 可将项目 `clone` 到本地查看效果。 6 | ## 效果图 7 | ![效果](http://oncj6b2vl.bkt.clouddn.com/FjNTC1ToZP0X0e7WbFZao4Cwc9B8.png) 8 | 9 | ## 参数 10 | | 属性名 | 属性值 | 备注 | 11 | |:-|:-|:-| 12 | | multiple | 无 | 开启多选 | 13 | | lay-search | 无 | 开启搜索 | 14 | | lay-case | 无 | 大小写敏感 | 15 | | lay-omit | 无 | 开启多选简写,显示勾选条数 | 16 | | lay-tools | 无 | 开启多选工具栏(多选、清空、反选)| 17 | ## 使用 18 | 1. 将项目中的 `form.js` 覆盖自己项目中的 `form.js`。 19 | 2. 引入下面css 20 | ```css 21 | select[multiple]+.layui-form-select>.layui-select-title>input.layui-input{ border-bottom: 0} 22 | select[multiple]+.layui-form-select dd{ padding:0;} 23 | select[multiple]+.layui-form-select .layui-form-checkbox[lay-skin=primary]{ margin:0 !important; display:block; line-height:36px !important; position:relative; padding-left:26px;} 24 | select[multiple]+.layui-form-select .layui-form-checkbox[lay-skin=primary] span{line-height:36px !important; float:none;} 25 | select[multiple]+.layui-form-select .layui-form-checkbox[lay-skin=primary] i{ position:absolute; left:10px; top:0; margin-top:9px;} 26 | .multiSelect{ line-height:normal; height:auto; padding:4px 10px; overflow:hidden;min-height:38px; margin-top:-38px; left:0; z-index:99;position:relative;background:none;} 27 | .multiSelect a{ padding:2px 5px; background:#908e8e; border-radius:2px; color:#fff; display:block; line-height:20px; height:20px; margin:2px 5px 2px 0; float:left;} 28 | .multiSelect a span{ float:left;} 29 | .multiSelect a i {float:left;display:block;margin:2px 0 0 2px;border-radius:2px;width:8px;height:8px;padding:4px;position:relative;-webkit-transition:all .3s;transition:all .3s} 30 | .multiSelect a i:before, .multiSelect a i:after {position:absolute;left:8px;top:2px;content:'';height:12px;width:1px;background-color:#fff} 31 | .multiSelect a i:before {-webkit-transform:rotate(45deg);transform:rotate(45deg)} 32 | .multiSelect a i:after {-webkit-transform:rotate(-45deg);transform:rotate(-45deg)} 33 | .multiSelect a i:hover{ background-color:#545556;} 34 | .multiOption{display: inline-block; padding: 0 5px;cursor: pointer; color: #999;} 35 | .multiOption:hover{color: #5FB878} 36 | 37 | @font-face {font-family: "iconfont"; src: url('data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAAaoAAsAAAAACfwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAADMAAABCsP6z7U9TLzIAAAE8AAAARAAAAFZW7kokY21hcAAAAYAAAABwAAABsgdU06BnbHlmAAAB8AAAAqEAAAOUTgbbS2hlYWQAAASUAAAALwAAADYR+R9jaGhlYQAABMQAAAAcAAAAJAfeA4ZobXR4AAAE4AAAABMAAAAUE+kAAGxvY2EAAAT0AAAADAAAAAwB/gLGbWF4cAAABQAAAAAfAAAAIAEVAGhuYW1lAAAFIAAAAUUAAAJtPlT+fXBvc3QAAAZoAAAAPQAAAFBD0CCqeJxjYGRgYOBikGPQYWB0cfMJYeBgYGGAAJAMY05meiJQDMoDyrGAaQ4gZoOIAgCKIwNPAHicY2Bk/s04gYGVgYOpk+kMAwNDP4RmfM1gxMjBwMDEwMrMgBUEpLmmMDgwVLwwZ27438AQw9zA0AAUZgTJAQAokgyoeJzFkTEOgCAQBOdAjTH+wtbezvggKyteTPyFLpyFvsC9DNnbHIEA0AJRzKIBOzCKdqVW88hQ84ZN/UBPUKU85fVcrkvZ27tMc17FR+0NMh2/yf47+quxrtvT6cVJD7pinpzyI3l1ysy5OIQbzBsVxHicZVM9aBRBFJ43c7szyeV2s/97m9zP3ppb5ZID72+9iJfDnyIiGImCMZWFXaKdaSyuESJYCFZpRZBUCpaJcCCKaexsRVHQytrC2/Pt5ZSIy+z3vvnemwfvY4ZIhAw/s33mEoMcJyfJebJCCMgVKCk0B37YqNIKWL5kOabCwiD0eVCqsjPglGTTrrUaZUfmsgoK5KHu11phlYbQbHToaajZOYDsjLeqz83q7BFMumH+fnyRPgGrEMyqnYV4eX7JrBUNsTWl61ldfyhkSRKUplQFNh17QpqYlOOnkupZ+4UTtABT2dC7tJYpzug3txu3c3POBECvB8ZMUXm2pHkarnuebehZPp0RrpcJjpmw9TXtGlO58heCXwpnfcVes7PExknPkVWctFxSIUxANgs4Q9RaglYjjIKwCqGvANfy4NQtBL8DkYaipAVVaGqNVuTnoQBYg8NzHzNaJ7HAdpjFXfF2DSEjxF2ui7T8ifP2CsBiZTCsLCbxCv4UDvlgp+kFgQcHXgAQP64s0gdQdOOKWwSM8CGJz4V4c11gQwc70hTlH4XLv12dbwO052OotGHMYYj8VrwDJQ/eeSXA2Ib24Me42XvX993ECxm96LM+6xKdBCRCNy6TdfSDoxmJFXYBaokV5RL7K/0nOHZ9rBl+chcCP7kVMML6SGHozx8Od3ZvCEvlm5KQ0nxPTJtiLHD7ny1jsnxYsAF7imkq8QVEOBgF5Yh0yNkpPIenN2QAsSdMNX6xu85VC/tiE3Mat6P8JqWM73NLhZ9mzjBy5uAlAlJYBiMRDPQleQ+9FEFfJJImGnHQHWIEmm/5UB8h8uaIIzrc4SEPozByel3oDvFcN+4D+dU/uou/L2xv/1mUQBdTCIN+jGUEgV47UkB+Aw7YpAMAAAB4nGNgZGBgAGLbQwYd8fw2Xxm4WRhA4HrO20sI+n8DCwOzE5DLwcAEEgUAPX4LPgB4nGNgZGBgbvjfwBDDwgACQJKRARWwAgBHCwJueJxjYWBgYH7JwMDCgMAADpsA/QAAAAAAAHYA/AGIAcp4nGNgZGBgYGWIYWBjAAEmIOYCQgaG/2A+AwASVwF+AHicZY9NTsMwEIVf+gekEqqoYIfkBWIBKP0Rq25YVGr3XXTfpk6bKokjx63UA3AejsAJOALcgDvwSCebNpbH37x5Y08A3OAHHo7fLfeRPVwyO3INF7gXrlN/EG6QX4SbaONVuEX9TdjHM6bCbXRheYPXuGL2hHdhDx18CNdwjU/hOvUv4Qb5W7iJO/wKt9Dx6sI+5l5XuI1HL/bHVi+cXqnlQcWhySKTOb+CmV7vkoWt0uqca1vEJlODoF9JU51pW91T7NdD5yIVWZOqCas6SYzKrdnq0AUb5/JRrxeJHoQm5Vhj/rbGAo5xBYUlDowxQhhkiMro6DtVZvSvsUPCXntWPc3ndFsU1P9zhQEC9M9cU7qy0nk6T4E9XxtSdXQrbsuelDSRXs1JErJCXta2VELqATZlV44RelzRiT8oZ0j/AAlabsgAAAB4nGNgYoAALgbsgJWRiZGZkYWRlZGNgbGCuzw1MykzMb8kU1eXs7A0Ma8CiA05CjPz0rPz89IZGADc3QvXAAAA') format('woff')} 38 | .iconfont {font-family:"iconfont" !important;font-size:16px;font-style:normal;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;} 39 | .icon-fanxuan:before { content: "\e837"; } 40 | .icon-quanxuan:before { content: "\e623"; } 41 | .icon-qingkong:before { content: "\e63e"; } 42 | ``` 43 | 44 | ## 使用实例 45 | 下面实例 开启了下拉多选(`multiple`), 并开启了检索功能(`lay-search`)。 46 | 效果可以参考 在线实例 的 `多选+搜索+大小写不敏感` 模块 47 | ```html 48 | 60 | ``` 61 | > **更多实例参考 在线实例、或 `index.html`。** 62 | 63 | ## 声明 64 | 此项目基于 https://gitee.com/layuicms/XiaLaDuoXuan 项目修改得来,修复了一些bug,扩展了 简化多选、多选搜索、大小写敏感控制等功能。 65 | -------------------------------------------------------------------------------- /layui/css/layui.mobile.css: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name: layui mobile 4 | @Author: 贤心 5 | @Site: http://www.layui.com/mobile/ 6 | 7 | */ 8 | 9 | /* reset */ 10 | body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,input,button,textarea,p,blockquote,th,td,form,legend{margin:0; padding:0; -webkit-tap-highlight-color:rgba(0,0,0,0)} 11 | html{font:12px 'Helvetica Neue','PingFang SC',STHeitiSC-Light,Helvetica,Arial,sans-serif; -ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;} 12 | a,button,input{-webkit-tap-highlight-color:rgba(255,0,0,0);} 13 | a{text-decoration: none; background:transparent} 14 | a:active,a:hover{outline:0} 15 | table{border-collapse:collapse;border-spacing:0} 16 | li{list-style:none;} 17 | b,strong{font-weight:700;} 18 | h1, h2, h3, h4, h5, h6{font-weight:500;} 19 | address,cite,dfn,em,var{font-style:normal;} 20 | dfn{font-style:italic} 21 | sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline} 22 | img{border:0; vertical-align: bottom} 23 | button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0; outline: 0;} 24 | button,select{text-transform:none} 25 | select{-webkit-appearance: none; border:none;} 26 | input{line-height:normal; } 27 | input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0} 28 | input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{height:auto} 29 | input[type=search]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box} 30 | input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none} 31 | label,input{vertical-align: middle;} 32 | 33 | 34 | /** 图标字体 **/ 35 | @font-face {font-family: 'layui-icon'; 36 | src: url('../font/iconfont.eot?v=1.0.7'); 37 | src: url('../font/iconfont.eot?v=1.0.7#iefix') format('embedded-opentype'), 38 | url('../font/iconfont.woff?v=1.0.7') format('woff'), 39 | url('../font/iconfont.ttf?v=1.0.7') format('truetype'), 40 | url('../font/iconfont.svg?v=1.0.7#iconfont') format('svg'); 41 | } 42 | 43 | .layui-icon{ 44 | font-family:"layui-icon" !important; 45 | font-size: 16px; 46 | font-style: normal; 47 | -webkit-font-smoothing: antialiased; 48 | -moz-osx-font-smoothing: grayscale; 49 | } 50 | 51 | 52 | /** 基础通用 **/ 53 | /* 消除第三方ui可能造成的冲突 */.layui-box, .layui-box *{-webkit-box-sizing: content-box !important; -moz-box-sizing: content-box !important; box-sizing: content-box !important;} 54 | .layui-border-box, .layui-border-box *{-webkit-box-sizing: border-box !important; -moz-box-sizing: border-box !important; box-sizing: border-box !important;} 55 | .layui-inline{position: relative; display: inline-block; *display:inline; *zoom:1; vertical-align: middle;} 56 | /* 三角形 */.layui-edge{position: absolute; width: 0; height: 0; border-style: dashed; border-color: transparent; overflow: hidden;} 57 | /* 单行溢出省略 */.layui-elip{text-overflow: ellipsis; overflow: hidden; white-space: nowrap;} 58 | /* 屏蔽选中 */.layui-unselect{-moz-user-select: none; -webkit-user-select: none; -ms-user-select: none;} 59 | .layui-disabled,.layui-disabled:active{background-color: #d2d2d2 !important; color: #fff !important; cursor: not-allowed !important;} 60 | /* 纯圆角 */.layui-circle{border-radius: 100%;} 61 | .layui-show{display: block !important;} 62 | .layui-hide{display: none !important;} 63 | 64 | 65 | .layui-upload-iframe{position: absolute; width: 0px; height: 0px; border: 0px; visibility: hidden;} 66 | .layui-upload-enter{border: 1px solid #009E94; background-color: #009E94; color: #fff; -webkit-transform: scale(1.1); transform: scale(1.1);} 67 | 68 | 69 | /* 弹出动画 */ 70 | @-webkit-keyframes layui-m-anim-scale { /* 默认 */ 71 | 0% {opacity: 0; -webkit-transform: scale(.5); transform: scale(.5)} 72 | 100% {opacity: 1; -webkit-transform: scale(1); transform: scale(1)} 73 | } 74 | @keyframes layui-m-anim-scale { /* 由小到大 */ 75 | 0% {opacity: 0; -webkit-transform: scale(.5); transform: scale(.5)} 76 | 100% {opacity: 1; -webkit-transform: scale(1); transform: scale(1)} 77 | } 78 | .layui-m-anim-scale{animation-name: layui-m-anim-scale; -webkit-animation-name: layui-m-anim-scale;} 79 | 80 | @-webkit-keyframes layui-m-anim-up{ /* 从下往上 */ 81 | 0%{opacity: 0; -webkit-transform: translateY(800px); transform: translateY(800px)} 82 | 100%{opacity: 1; -webkit-transform: translateY(0); transform: translateY(0)} 83 | } 84 | @keyframes layui-m-anim-up{ 85 | 0%{opacity: 0; -webkit-transform: translateY(800px); transform: translateY(800px)} 86 | 100%{opacity: 1; -webkit-transform: translateY(0); transform: translateY(0)} 87 | } 88 | .layui-m-anim-up{-webkit-animation-name: layui-m-anim-up; animation-name: layui-m-anim-up} 89 | 90 | @-webkit-keyframes layui-m-anim-left{ /* 从右往左 */ 91 | 0%{-webkit-transform: translateX(100%); transform: translateX(100%)} 92 | 100%{-webkit-transform: translateX(0); transform: translateX(0)} 93 | } 94 | @keyframes layui-m-anim-left{ 95 | 0%{-webkit-transform: translateX(100%); transform: translateX(100%)} 96 | 100%{-webkit-transform: translateX(0); transform: translateX(0)} 97 | } 98 | .layui-m-anim-left{-webkit-animation-name: layui-m-anim-left; animation-name: layui-m-anim-left} 99 | 100 | @-webkit-keyframes layui-m-anim-right{ /* 从左往右 */ 101 | 0%{-webkit-transform: translateX(-100%); transform: translateX(-100%)} 102 | 100%{-webkit-transform: translateX(0); transform: translateX(0)} 103 | } 104 | @keyframes layui-m-anim-right{ 105 | 0%{-webkit-transform: translateX(-100%); transform: translateX(-100%)} 106 | 100%{-webkit-transform: translateX(0); transform: translateX(0)} 107 | } 108 | .layui-m-anim-right{-webkit-animation-name: layui-m-anim-right; animation-name: layui-m-anim-right} 109 | 110 | @-webkit-keyframes layui-m-anim-lout{ /* 往左收缩 */ 111 | 0%{-webkit-transform: translateX(0); transform: translateX(0)} 112 | 100%{-webkit-transform: translateX(-100%); transform: translateX(-100%)} 113 | } 114 | @keyframes layui-m-anim-lout{ 115 | 0%{-webkit-transform: translateX(0); transform: translateX(0)} 116 | 100%{-webkit-transform: translateX(-100%); transform: translateX(-100%)} 117 | } 118 | .layui-m-anim-lout{-webkit-animation-name: layui-m-anim-lout; animation-name: layui-m-anim-lout} 119 | 120 | @-webkit-keyframes layui-m-anim-rout{ /* 往右收缩 */ 121 | 0%{-webkit-transform: translateX(0); transform: translateX(0)} 122 | 100%{-webkit-transform: translateX(100%); transform: translateX(100%)} 123 | } 124 | @keyframes layui-m-anim-rout{ 125 | 0%{-webkit-transform: translateX(0); transform: translateX(0)} 126 | 100%{-webkit-transform: translateX(100%); transform: translateX(100%)} 127 | } 128 | .layui-m-anim-rout{-webkit-animation-name: layui-m-anim-rout; animation-name: layui-m-anim-rout} 129 | 130 | 131 | /** layer mobile */ 132 | .layui-m-layer{position:relative; z-index: 19891014;} 133 | .layui-m-layer *{-webkit-box-sizing: content-box; -moz-box-sizing: content-box; box-sizing: content-box;} 134 | .layui-m-layershade, 135 | .layui-m-layermain{position:fixed; left:0; top:0; width:100%; height:100%;} 136 | .layui-m-layershade{background-color:rgba(0,0,0, .7); pointer-events:auto;} 137 | .layui-m-layermain{display:table; font-family: Helvetica, arial, sans-serif; pointer-events: none;} 138 | .layui-m-layermain .layui-m-layersection{display:table-cell; vertical-align:middle; text-align:center;} 139 | .layui-m-layerchild{position:relative; display:inline-block; text-align:left; background-color:#fff; font-size:14px; border-radius: 5px; box-shadow: 0 0 8px rgba(0, 0, 0, 0.1); pointer-events:auto; -webkit-overflow-scrolling: touch;} 140 | .layui-m-layerchild{-webkit-animation-fill-mode: both; animation-fill-mode: both; -webkit-animation-duration: .2s; animation-duration: .2s;} 141 | 142 | .layui-m-layer0 .layui-m-layerchild{width: 90%; max-width: 640px;} 143 | .layui-m-layer1 .layui-m-layerchild{border:none; border-radius:0;} 144 | .layui-m-layer2 .layui-m-layerchild{width:auto; max-width:260px; min-width:40px; border:none; background: none; box-shadow: none; color:#fff;} 145 | .layui-m-layerchild h3{padding: 0 10px; height: 60px; line-height: 60px; font-size:16px; font-weight: 400; border-radius: 5px 5px 0 0; text-align: center;} 146 | .layui-m-layerchild h3, 147 | .layui-m-layerbtn span{ text-overflow:ellipsis; overflow:hidden; white-space:nowrap;} 148 | .layui-m-layercont{padding: 50px 30px; line-height: 22px; text-align:center;} 149 | .layui-m-layer1 .layui-m-layercont{padding:0; text-align:left;} 150 | .layui-m-layer2 .layui-m-layercont{text-align:center; padding: 0; line-height: 0;} 151 | .layui-m-layer2 .layui-m-layercont i{width:25px; height:25px; margin-left:8px; display:inline-block; background-color:#fff; border-radius:100%;} 152 | .layui-m-layer2 .layui-m-layercont p{margin-top: 20px;} 153 | 154 | /* loading */ 155 | @-webkit-keyframes layui-m-anim-loading{ 156 | 0%,80%,100%{transform:scale(0); -webkit-transform:scale(0)} 157 | 40%{transform:scale(1); -webkit-transform:scale(1)} 158 | } 159 | @keyframes layui-m-anim-loading{ 160 | 0%,80%,100%{transform:scale(0); -webkit-transform:scale(0)} 161 | 40%{transform:scale(1); -webkit-transform:scale(1)} 162 | } 163 | .layui-m-layer2 .layui-m-layercont i{-webkit-animation: layui-m-anim-loading 1.4s infinite ease-in-out; animation: layui-m-anim-loading 1.4s infinite ease-in-out; -webkit-animation-fill-mode: both; animation-fill-mode: both;} 164 | 165 | .layui-m-layer2 .layui-m-layercont i:first-child{margin-left:0; -webkit-animation-delay: -.32s; animation-delay: -.32s;} 166 | .layui-m-layer2 .layui-m-layercont i.layui-m-layerload{-webkit-animation-delay: -.16s; animation-delay: -.16s;} 167 | .layui-m-layer2 .layui-m-layercont>div{line-height:22px; padding-top:7px; margin-bottom:20px; font-size: 14px;} 168 | .layui-m-layerbtn{display: box; display: -moz-box; display: -webkit-box; width: 100%; position:relative; height: 50px; line-height: 50px; font-size: 0; text-align:center; border-top:1px solid #D0D0D0; background-color: #F2F2F2; border-radius: 0 0 5px 5px;} 169 | .layui-m-layerbtn span{position:relative; display: block; -moz-box-flex: 1; box-flex: 1; -webkit-box-flex: 1; text-align:center; font-size:14px; border-radius: 0 0 5px 5px; cursor:pointer;} 170 | .layui-m-layerbtn span[yes]{color: #40AFFE;} 171 | .layui-m-layerbtn span[no]{border-right: 1px solid #D0D0D0; border-radius: 0 0 0 5px;} 172 | .layui-m-layerbtn span:active{background-color: #F6F6F6;} 173 | .layui-m-layerend{position:absolute; right:7px; top:10px; width:30px; height:30px; border: 0; font-weight:400; background: transparent; cursor: pointer; -webkit-appearance: none; font-size:30px;} 174 | .layui-m-layerend::before, .layui-m-layerend::after{position:absolute; left:5px; top:15px; content:''; width:18px; height:1px; background-color:#999; transform:rotate(45deg); -webkit-transform:rotate(45deg); border-radius: 3px;} 175 | .layui-m-layerend::after{transform:rotate(-45deg); -webkit-transform:rotate(-45deg);} 176 | 177 | /* 底部对话框风格 */ 178 | body .layui-m-layer .layui-m-layer-footer{position: fixed; width: 95%; max-width: 100%; margin: 0 auto; left:0; right: 0; bottom: 10px; background: none;} 179 | .layui-m-layer-footer .layui-m-layercont{padding: 20px; border-radius: 5px 5px 0 0; background-color: rgba(255,255,255,.8);} 180 | .layui-m-layer-footer .layui-m-layerbtn{display: block; height: auto; background: none; border-top: none;} 181 | .layui-m-layer-footer .layui-m-layerbtn span{background-color: rgba(255,255,255,.8);} 182 | .layui-m-layer-footer .layui-m-layerbtn span[no]{color: #FD482C; border-top: 1px solid #c2c2c2; border-radius: 0 0 5px 5px;} 183 | .layui-m-layer-footer .layui-m-layerbtn span[yes]{margin-top: 10px; border-radius: 5px;} 184 | 185 | /* 通用提示 */ 186 | body .layui-m-layer .layui-m-layer-msg{width: auto; max-width: 90%; margin: 0 auto; bottom: -150px; background-color: rgba(0,0,0,.7); color: #fff;} 187 | .layui-m-layer-msg .layui-m-layercont{padding: 10px 20px;} 188 | 189 | 190 | 191 | 192 | -------------------------------------------------------------------------------- /layui/css/modules/code.css: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name: layui.code 4 | @Author: 贤心 5 | @Site: http://www.layui.com 6 | 7 | */ 8 | 9 | /* 加载就绪标志 */ 10 | html #layuicss-skincodecss{display:none; position: absolute; width:1989px;} 11 | 12 | /* 默认风格 */ 13 | .layui-code-view{display: block; position: relative; margin: 10px 0; padding: 0; border: 1px solid #e2e2e2; border-left-width: 6px; background-color: #F2F2F2; color: #333; font-family: Courier New; font-size: 12px;} 14 | .layui-code-h3{position: relative; padding: 0 10px; height: 32px; line-height: 32px; border-bottom: 1px solid #e2e2e2; font-size: 12px;} 15 | .layui-code-h3 a{position: absolute; right: 10px; top: 0; color: #999;} 16 | .layui-code-view .layui-code-ol{position: relative; overflow: auto;} 17 | .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;} 18 | .layui-code-view pre{margin: 0;} 19 | 20 | /* notepadd++风格 */ 21 | .layui-code-notepad{border: 1px solid #0C0C0C; border-left-color: #3F3F3F; background-color: #0C0C0C; color: #C2BE9E} 22 | .layui-code-notepad .layui-code-h3{border-bottom: none;} 23 | .layui-code-notepad .layui-code-ol li{background-color: #3F3F3F; border-left: none;} -------------------------------------------------------------------------------- /layui/css/modules/laydate/default/font.css: -------------------------------------------------------------------------------- 1 | /** 图标字体 **/ 2 | @font-face {font-family: 'laydate-icon'; 3 | src: url('./font/iconfont.eot'); 4 | src: url('./font/iconfont.eot#iefix') format('embedded-opentype'), 5 | url('./font/iconfont.svg#iconfont') format('svg'), 6 | url('./font/iconfont.woff') format('woff'), 7 | url('./font/iconfont.ttf') format('truetype'); 8 | } 9 | 10 | .laydate-icon{ 11 | font-family:"laydate-icon" !important; 12 | font-size: 16px; 13 | font-style: normal; 14 | -webkit-font-smoothing: antialiased; 15 | -moz-osx-font-smoothing: grayscale; 16 | } -------------------------------------------------------------------------------- /layui/css/modules/laydate/default/laydate.css: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name: laydata 4 | @Author: 贤心 5 | 6 | **/ 7 | 8 | 9 | html #layuicss-laydate{display: none; position: absolute; width: 1989px;} 10 | 11 | /* 初始化 */ 12 | .layui-laydate *{margin: 0; padding: 0;} 13 | 14 | /* 主体结构 */ 15 | .layui-laydate, .layui-laydate *{box-sizing: border-box;} 16 | .layui-laydate{position: absolute; z-index: 66666666; margin: 5px 0; border-radius: 2px; font-size: 14px; -webkit-animation-duration: 0.3s; animation-duration: 0.3s; -webkit-animation-fill-mode: both; animation-fill-mode: both;} 17 | .layui-laydate-main{width: 272px;} 18 | .layui-laydate-header *, 19 | .layui-laydate-content td, 20 | .layui-laydate-list li{transition-duration: .3s; -webkit-transition-duration: .3s;} 21 | 22 | @-webkit-keyframes laydate-upbit{ /* 微微往上滑入 */ 23 | from {-webkit-transform: translate3d(0, 20px, 0); opacity: 0.3;} 24 | to {-webkit-transform: translate3d(0, 0, 0); opacity: 1;} 25 | } 26 | @keyframes laydate-upbit{ 27 | from {transform: translate3d(0, 20px, 0); opacity: 0.3;} 28 | to {transform: translate3d(0, 0, 0); opacity: 1;} 29 | } 30 | .layui-laydate{-webkit-animation-name: laydate-upbit; animation-name: laydate-upbit;} 31 | .layui-laydate-static{ position: relative; z-index: 0; display: inline-block; margin: 0; -webkit-animation: none; animation: none;} 32 | 33 | /* 展开年月列表时 */ 34 | .laydate-ym-show .laydate-prev-m, 35 | .laydate-ym-show .laydate-next-m{display: none !important;} 36 | .laydate-ym-show .laydate-prev-y, 37 | .laydate-ym-show .laydate-next-y{display: inline-block !important;} 38 | .laydate-ym-show .laydate-set-ym span[lay-type="month"]{display: none !important;} 39 | 40 | /* 展开时间列表时 */ 41 | .laydate-time-show .layui-laydate-header .layui-icon, 42 | .laydate-time-show .laydate-set-ym span[lay-type="year"], 43 | .laydate-time-show .laydate-set-ym span[lay-type="month"]{display: none !important;} 44 | 45 | /* 头部结构 */ 46 | .layui-laydate-header{position: relative; line-height:30px; padding: 10px 70px 5px;} 47 | .layui-laydate-header *{display: inline-block; vertical-align: bottom;} 48 | .layui-laydate-header i{position: absolute; top: 10px; padding: 0 5px; color: #999; font-size: 18px; cursor: pointer;} 49 | .layui-laydate-header i.laydate-prev-y{left: 15px;} 50 | .layui-laydate-header i.laydate-prev-m{left: 45px;} 51 | .layui-laydate-header i.laydate-next-y{right: 15px;} 52 | .layui-laydate-header i.laydate-next-m{right: 45px;} 53 | .laydate-set-ym{width: 100%; text-align: center; box-sizing: border-box; text-overflow: ellipsis; overflow: hidden; white-space: nowrap;} 54 | .laydate-set-ym span{padding: 0 5px; cursor: pointer;} 55 | .laydate-time-text{cursor: default !important;} 56 | 57 | /* 主体结构 */ 58 | .layui-laydate-content{position: relative; padding: 10px; -moz-user-select: none; -webkit-user-select: none; -ms-user-select: none;} 59 | .layui-laydate-content table{border-collapse: collapse; border-spacing: 0;} 60 | .layui-laydate-content th, 61 | .layui-laydate-content td{width: 36px; height: 30px; padding: 5px; text-align: center;} 62 | .layui-laydate-content th{font-weight: 400;} 63 | .layui-laydate-content td{position: relative; cursor: pointer;} 64 | .laydate-day-mark{position: absolute; left: 0; top: 0; width: 100%; height: 100%; line-height: 30px; font-size: 12px; overflow: hidden;} 65 | .laydate-day-mark::after{position: absolute; content:''; right: 2px; top: 2px; width: 5px; height: 5px; border-radius: 50%;} 66 | 67 | /* 底部结构 */ 68 | .layui-laydate-footer{position: relative; height: 46px; line-height: 26px; padding: 10px 20px;} 69 | .layui-laydate-footer span{margin-right: 15px; display: inline-block; cursor: pointer; font-size: 12px;} 70 | .layui-laydate-footer span:hover{color: #5FB878;} 71 | .laydate-footer-btns{position: absolute; right: 10px; top: 10px;} 72 | .laydate-footer-btns span{height: 26px; line-height: 26px; margin: 0 0 0 -1px; padding: 0 10px; border: 1px solid #C9C9C9; background-color: #fff; white-space: nowrap; vertical-align: top; border-radius: 2px;} 73 | 74 | /* 年月列表 */ 75 | .layui-laydate-list{position: absolute; left: 0; top: 0; width: 100%; height: 100%; padding: 10px; box-sizing: border-box; background-color: #fff;} 76 | .layui-laydate-list>li{position: relative; display: inline-block; width: 33.3%; height: 36px; line-height: 36px; margin: 3px 0; vertical-align: middle; text-align: center; cursor: pointer;} 77 | .laydate-month-list>li{width: 25%; margin: 17px 0;} 78 | .laydate-time-list{} 79 | .laydate-time-list>li{height: 100%; margin: 0; line-height: normal; cursor: default;} 80 | .laydate-time-list p{position: relative; top: -4px; line-height: 29px;} 81 | .laydate-time-list ol{height: 181px; overflow: hidden;} 82 | .laydate-time-list>li:hover ol{overflow-y: auto;} 83 | .laydate-time-list ol li{width: 130%; padding-left: 33px; line-height: 30px; text-align: left; cursor: pointer;} 84 | 85 | /* 提示 */ 86 | .layui-laydate-hint{position: absolute; top: 115px; left: 50%; width: 250px; margin-left: -125px; line-height: 20px; padding: 15px; text-align: center; font-size: 12px; color: #FF5722;} 87 | 88 | 89 | /* 双日历 */ 90 | .layui-laydate-range{width: 546px;} 91 | .layui-laydate-range .layui-laydate-main{display: inline-block; vertical-align: middle;} 92 | .layui-laydate-range .laydate-main-list-0 .laydate-next-m, 93 | .layui-laydate-range .laydate-main-list-0 .laydate-next-y, 94 | .layui-laydate-range .laydate-main-list-1 .laydate-prev-y, 95 | .layui-laydate-range .laydate-main-list-1 .laydate-prev-m{display: none;} 96 | .layui-laydate-range .laydate-main-list-1 .layui-laydate-content{border-left: 1px solid #e2e2e2;} 97 | 98 | 99 | /* 默认简约主题 */ 100 | .layui-laydate, .layui-laydate-hint{border: 1px solid #d2d2d2; box-shadow: 0 2px 4px rgba(0,0,0,.12); background-color: #fff; color: #666;} 101 | .layui-laydate-header{border-bottom: 1px solid #e2e2e2;} 102 | .layui-laydate-header i:hover, 103 | .layui-laydate-header span:hover{color: #5FB878;} 104 | .layui-laydate-content{border-top: none 0; border-bottom: none 0;} 105 | .layui-laydate-content th{color: #333;} 106 | .layui-laydate-content td{color: #666;} 107 | .layui-laydate-content td.laydate-selected{background-color: #00F7DE;} 108 | .laydate-selected:hover{background-color: #00F7DE !important;} 109 | .layui-laydate-content td:hover, 110 | .layui-laydate-list li:hover{background-color: #eaeaea; color: #333;} 111 | .laydate-time-list li ol{margin: 0; padding: 0; border: 1px solid #e2e2e2; border-left-width: 0;} 112 | .laydate-time-list li:first-child ol{border-left-width: 1px;} 113 | .laydate-time-list>li:hover{background: none;} 114 | .layui-laydate-content .laydate-day-prev, 115 | .layui-laydate-content .laydate-day-next{color: #d2d2d2;} 116 | .laydate-selected.laydate-day-prev, 117 | .laydate-selected.laydate-day-next{background-color: #f8f8f8 !important;} 118 | .layui-laydate-footer{border-top: 1px solid #e2e2e2;} 119 | .layui-laydate-hint{color: #FF5722;} 120 | .laydate-day-mark::after{background-color: #5FB878;} 121 | .layui-laydate-content td.layui-this .laydate-day-mark::after{display: none;} 122 | .layui-laydate-footer span[lay-type="date"]{color: #5FB878;} 123 | .layui-laydate .layui-this{background-color: #009688 !important; color: #fff !important;} 124 | .layui-laydate .laydate-disabled, 125 | .layui-laydate .laydate-disabled:hover{background:none !important; color: #d2d2d2 !important; cursor: not-allowed !important; -moz-user-select: none; -webkit-user-select: none; -ms-user-select: none;} 126 | 127 | /* 墨绿/自定义背景色主题 */ 128 | .laydate-theme-molv{border: none;} 129 | .laydate-theme-molv.layui-laydate-range{width: 548px} 130 | .laydate-theme-molv .layui-laydate-main{width: 274px;} 131 | .laydate-theme-molv .layui-laydate-header{border: none; background-color: #009688;} 132 | .laydate-theme-molv .layui-laydate-header i, 133 | .laydate-theme-molv .layui-laydate-header span{color: #f6f6f6;} 134 | .laydate-theme-molv .layui-laydate-header i:hover, 135 | .laydate-theme-molv .layui-laydate-header span:hover{color: #fff;} 136 | .laydate-theme-molv .layui-laydate-content{border: 1px solid #e2e2e2; border-top: none; border-bottom: none;} 137 | .laydate-theme-molv .laydate-main-list-1 .layui-laydate-content{border-left: none;} 138 | .laydate-theme-molv .layui-laydate-footer{border: 1px solid #e2e2e2;} 139 | 140 | /* 格子主题 */ 141 | .laydate-theme-grid .layui-laydate-content td, 142 | .laydate-theme-grid .layui-laydate-content thead, 143 | .laydate-theme-grid .laydate-year-list>li, 144 | .laydate-theme-grid .laydate-month-list>li{border: 1px solid #e2e2e2;} 145 | .laydate-theme-grid .laydate-selected, 146 | .laydate-theme-grid .laydate-selected:hover{background-color: #f2f2f2 !important; color: #009688 !important;} 147 | .laydate-theme-grid .laydate-selected.laydate-day-prev, 148 | .laydate-theme-grid .laydate-selected.laydate-day-next{color: #d2d2d2 !important;} 149 | .laydate-theme-grid .laydate-year-list, 150 | .laydate-theme-grid .laydate-month-list{margin: 1px 0 0 1px;} 151 | .laydate-theme-grid .laydate-year-list>li, 152 | .laydate-theme-grid .laydate-month-list>li{margin: 0 -1px -1px 0;} 153 | .laydate-theme-grid .laydate-year-list>li{height: 43px; line-height: 43px;} 154 | .laydate-theme-grid .laydate-month-list>li{height: 71px; line-height: 71px;} 155 | 156 | -------------------------------------------------------------------------------- /layui/css/modules/layer/default/icon-ext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/css/modules/layer/default/icon-ext.png -------------------------------------------------------------------------------- /layui/css/modules/layer/default/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/css/modules/layer/default/icon.png -------------------------------------------------------------------------------- /layui/css/modules/layer/default/layer.css: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name: layer 4 | @Author: 贤心 5 | 6 | **/ 7 | 8 | /* *html{background-image: url(about:blank); background-attachment: fixed;} */ 9 | html #layuicss-layer{display: none; position: absolute; width: 1989px;} 10 | 11 | /* common */ 12 | .layui-layer-shade, .layui-layer{position:fixed; _position:absolute; pointer-events: auto;} 13 | .layui-layer-shade{top:0; left:0; width:100%; height:100%; _height:expression(document.body.offsetHeight+"px");} 14 | .layui-layer{-webkit-overflow-scrolling: touch;} 15 | .layui-layer{top:150px; left: 0; margin:0; padding:0; background-color:#fff; -webkit-background-clip: content; border-radius: 2px; box-shadow: 1px 1px 50px rgba(0,0,0,.3);} 16 | .layui-layer-close{position:absolute;} 17 | .layui-layer-content{position:relative;} 18 | .layui-layer-border{border: 1px solid #B2B2B2; border: 1px solid rgba(0,0,0,.1); box-shadow: 1px 1px 5px rgba(0,0,0,.2);} 19 | .layui-layer-load{background:url(loading-1.gif) #eee center center no-repeat;} 20 | .layui-layer-ico{ background:url(icon.png) no-repeat;} 21 | .layui-layer-dialog .layui-layer-ico, 22 | .layui-layer-setwin a, 23 | .layui-layer-btn a{display:inline-block; *display:inline; *zoom:1; vertical-align:top;} 24 | 25 | .layui-layer-move{display: none; position: fixed; *position: absolute; left: 0px; top: 0px; width: 100%; height: 100%; cursor: move; opacity: 0; filter:alpha(opacity=0); background-color: #fff; z-index: 2147483647;} 26 | .layui-layer-resize{position: absolute; width: 15px; height: 15px; right: 0; bottom: 0; cursor: se-resize;} 27 | 28 | /* 动画 */ 29 | .layer-anim{-webkit-animation-fill-mode: both; animation-fill-mode: both; -webkit-animation-duration:.3s; animation-duration:.3s;} 30 | 31 | @-webkit-keyframes layer-bounceIn { /* 默认 */ 32 | 0% {opacity: 0; -webkit-transform: scale(.5); transform: scale(.5)} 33 | 100% {opacity: 1; -webkit-transform: scale(1); transform: scale(1)} 34 | } 35 | @keyframes layer-bounceIn { 36 | 0% {opacity: 0; -webkit-transform: scale(.5); -ms-transform: scale(.5); transform: scale(.5)} 37 | 100% {opacity: 1; -webkit-transform: scale(1); -ms-transform: scale(1); transform: scale(1)} 38 | } 39 | .layer-anim-00{-webkit-animation-name: layer-bounceIn;animation-name: layer-bounceIn} 40 | 41 | @-webkit-keyframes layer-zoomInDown{0%{opacity:0;-webkit-transform:scale(.1) translateY(-2000px);transform:scale(.1) translateY(-2000px);-webkit-animation-timing-function:ease-in-out;animation-timing-function:ease-in-out}60%{opacity:1;-webkit-transform:scale(.475) translateY(60px);transform:scale(.475) translateY(60px);-webkit-animation-timing-function:ease-out;animation-timing-function:ease-out}}@keyframes layer-zoomInDown{0%{opacity:0;-webkit-transform:scale(.1) translateY(-2000px);-ms-transform:scale(.1) translateY(-2000px);transform:scale(.1) translateY(-2000px);-webkit-animation-timing-function:ease-in-out;animation-timing-function:ease-in-out}60%{opacity:1;-webkit-transform:scale(.475) translateY(60px);-ms-transform:scale(.475) translateY(60px);transform:scale(.475) translateY(60px);-webkit-animation-timing-function:ease-out;animation-timing-function:ease-out}}.layer-anim-01{-webkit-animation-name:layer-zoomInDown;animation-name:layer-zoomInDown} 42 | 43 | @-webkit-keyframes layer-fadeInUpBig{0%{opacity:0;-webkit-transform:translateY(2000px);transform:translateY(2000px)}100%{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}}@keyframes layer-fadeInUpBig{0%{opacity:0;-webkit-transform:translateY(2000px);-ms-transform:translateY(2000px);transform:translateY(2000px)}100%{opacity:1;-webkit-transform:translateY(0);-ms-transform:translateY(0);transform:translateY(0)}}.layer-anim-02{-webkit-animation-name:layer-fadeInUpBig;animation-name:layer-fadeInUpBig} 44 | 45 | @-webkit-keyframes layer-zoomInLeft{0%{opacity:0;-webkit-transform:scale(.1) translateX(-2000px);transform:scale(.1) translateX(-2000px);-webkit-animation-timing-function:ease-in-out;animation-timing-function:ease-in-out}60%{opacity:1;-webkit-transform:scale(.475) translateX(48px);transform:scale(.475) translateX(48px);-webkit-animation-timing-function:ease-out;animation-timing-function:ease-out}}@keyframes layer-zoomInLeft{0%{opacity:0;-webkit-transform:scale(.1) translateX(-2000px);-ms-transform:scale(.1) translateX(-2000px);transform:scale(.1) translateX(-2000px);-webkit-animation-timing-function:ease-in-out;animation-timing-function:ease-in-out}60%{opacity:1;-webkit-transform:scale(.475) translateX(48px);-ms-transform:scale(.475) translateX(48px);transform:scale(.475) translateX(48px);-webkit-animation-timing-function:ease-out;animation-timing-function:ease-out}}.layer-anim-03{-webkit-animation-name:layer-zoomInLeft;animation-name:layer-zoomInLeft} 46 | 47 | @-webkit-keyframes layer-rollIn{0%{opacity:0;-webkit-transform:translateX(-100%) rotate(-120deg);transform:translateX(-100%) rotate(-120deg)}100%{opacity:1;-webkit-transform:translateX(0px) rotate(0deg);transform:translateX(0px) rotate(0deg)}}@keyframes layer-rollIn{0%{opacity:0;-webkit-transform:translateX(-100%) rotate(-120deg);-ms-transform:translateX(-100%) rotate(-120deg);transform:translateX(-100%) rotate(-120deg)}100%{opacity:1;-webkit-transform:translateX(0px) rotate(0deg);-ms-transform:translateX(0px) rotate(0deg);transform:translateX(0px) rotate(0deg)}}.layer-anim-04{-webkit-animation-name:layer-rollIn;animation-name:layer-rollIn} 48 | 49 | @keyframes layer-fadeIn{0%{opacity:0}100%{opacity:1}}.layer-anim-05{-webkit-animation-name:layer-fadeIn;animation-name:layer-fadeIn} 50 | 51 | @-webkit-keyframes layer-shake{0%,100%{-webkit-transform:translateX(0);transform:translateX(0)}10%,30%,50%,70%,90%{-webkit-transform:translateX(-10px);transform:translateX(-10px)}20%,40%,60%,80%{-webkit-transform:translateX(10px);transform:translateX(10px)}}@keyframes layer-shake{0%,100%{-webkit-transform:translateX(0);-ms-transform:translateX(0);transform:translateX(0)}10%,30%,50%,70%,90%{-webkit-transform:translateX(-10px);-ms-transform:translateX(-10px);transform:translateX(-10px)}20%,40%,60%,80%{-webkit-transform:translateX(10px);-ms-transform:translateX(10px);transform:translateX(10px)}}.layer-anim-06{-webkit-animation-name:layer-shake;animation-name:layer-shake}@-webkit-keyframes fadeIn{0%{opacity:0}100%{opacity:1}} 52 | 53 | /* 标题栏 */ 54 | .layui-layer-title{padding:0 80px 0 20px; height:42px; line-height:42px; border-bottom:1px solid #eee; font-size:14px; color:#333; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background-color: #F8F8F8; border-radius: 2px 2px 0 0;} 55 | .layui-layer-setwin{position:absolute; right:15px; *right:0; top:15px; font-size:0; line-height: initial;} 56 | .layui-layer-setwin a{position:relative; width: 16px; height:16px; margin-left:10px; font-size:12px; _overflow:hidden;} 57 | .layui-layer-setwin .layui-layer-min cite{position:absolute; width:14px; height:2px; left:0; top:50%; margin-top:-1px; background-color:#2E2D3C; cursor:pointer; _overflow:hidden;} 58 | .layui-layer-setwin .layui-layer-min:hover cite{background-color:#2D93CA; } 59 | .layui-layer-setwin .layui-layer-max{background-position:-32px -40px;} 60 | .layui-layer-setwin .layui-layer-max:hover{background-position:-16px -40px;} 61 | .layui-layer-setwin .layui-layer-maxmin{background-position:-65px -40px;} 62 | .layui-layer-setwin .layui-layer-maxmin:hover{background-position:-49px -40px;} 63 | .layui-layer-setwin .layui-layer-close1{background-position: 1px -40px; cursor: pointer;} 64 | .layui-layer-setwin .layui-layer-close1:hover{opacity:0.7;} 65 | .layui-layer-setwin .layui-layer-close2{position:absolute; right:-28px; top:-28px; width:30px; height:30px; margin-left:0; background-position:-149px -31px; *right:-18px; _display:none;} 66 | .layui-layer-setwin .layui-layer-close2:hover{ background-position:-180px -31px;} 67 | 68 | /* 按钮栏 */ 69 | .layui-layer-btn{text-align: right; padding: 0 15px 12px; pointer-events: auto; user-select: none; -webkit-user-select: none;} 70 | .layui-layer-btn a{height: 28px; line-height: 28px; margin: 5px 5px 0; padding: 0 15px; border: 1px solid #dedede; background-color:#fff; color: #333; border-radius: 2px; font-weight:400; cursor:pointer; text-decoration: none;} 71 | .layui-layer-btn a:hover{opacity: 0.9; text-decoration: none;} 72 | .layui-layer-btn a:active{opacity: 0.8;} 73 | .layui-layer-btn .layui-layer-btn0{border-color: #1E9FFF; background-color: #1E9FFF; color:#fff;} 74 | .layui-layer-btn-l{text-align: left;} 75 | .layui-layer-btn-c{text-align: center;} 76 | 77 | /* 定制化 */ 78 | .layui-layer-dialog{min-width:260px;} 79 | .layui-layer-dialog .layui-layer-content{position: relative; padding:20px; line-height:24px; word-break: break-all; overflow:hidden; font-size:14px; overflow-x: hidden; overflow-y:auto;} 80 | .layui-layer-dialog .layui-layer-content .layui-layer-ico{position:absolute; top:16px; left:15px; _left:-40px; width:30px; height:30px;} 81 | .layui-layer-ico1{background-position:-30px 0 } 82 | .layui-layer-ico2{background-position:-60px 0;} 83 | .layui-layer-ico3{background-position:-90px 0;} 84 | .layui-layer-ico4{background-position:-120px 0;} 85 | .layui-layer-ico5{background-position:-150px 0;} 86 | .layui-layer-ico6{background-position:-180px 0;} 87 | .layui-layer-rim{border:6px solid #8D8D8D; border:6px solid rgba(0,0,0,.3); border-radius:5px; box-shadow: none;} 88 | .layui-layer-msg{min-width:180px; border:1px solid #D3D4D3; box-shadow: none;} 89 | .layui-layer-hui{min-width:100px; background-color: #000; filter:alpha(opacity=60); background-color: rgba(0,0,0,0.6); color: #fff; border:none;} 90 | .layui-layer-hui .layui-layer-content{padding:12px 25px; text-align:center;} 91 | .layui-layer-dialog .layui-layer-padding{padding: 20px 20px 20px 55px; text-align: left;} 92 | .layui-layer-page .layui-layer-content{position:relative; overflow:auto;} 93 | .layui-layer-page .layui-layer-btn,.layui-layer-iframe .layui-layer-btn{padding-top:10px;} 94 | .layui-layer-nobg{background:none;} 95 | .layui-layer-iframe iframe{display: block; width: 100%;} 96 | 97 | .layui-layer-loading{border-radius:100%; background:none; box-shadow:none; border:none;} 98 | .layui-layer-loading .layui-layer-content{width:60px; height:24px; background:url(loading-0.gif) no-repeat;} 99 | .layui-layer-loading .layui-layer-loading1{width:37px; height:37px; background:url(loading-1.gif) no-repeat;} 100 | .layui-layer-loading .layui-layer-loading2, .layui-layer-ico16{width:32px; height:32px; background:url(loading-2.gif) no-repeat;} 101 | .layui-layer-tips{background: none; box-shadow:none; border:none;} 102 | .layui-layer-tips .layui-layer-content{position: relative; line-height: 22px; min-width: 12px; padding: 8px 15px; font-size: 12px; _float:left; border-radius: 2px; box-shadow: 1px 1px 3px rgba(0,0,0,.2); background-color: #000; color: #fff;} 103 | .layui-layer-tips .layui-layer-close{right:-2px; top:-1px;} 104 | .layui-layer-tips i.layui-layer-TipsG{ position:absolute; width:0; height:0; border-width:8px; border-color:transparent; border-style:dashed; *overflow:hidden;} 105 | .layui-layer-tips i.layui-layer-TipsT, .layui-layer-tips i.layui-layer-TipsB{left:5px; border-right-style:solid; border-right-color: #000;} 106 | .layui-layer-tips i.layui-layer-TipsT{bottom:-8px;} 107 | .layui-layer-tips i.layui-layer-TipsB{top:-8px;} 108 | .layui-layer-tips i.layui-layer-TipsR, .layui-layer-tips i.layui-layer-TipsL{top: 5px; border-bottom-style:solid; border-bottom-color: #000;} 109 | .layui-layer-tips i.layui-layer-TipsR{left:-8px;} 110 | .layui-layer-tips i.layui-layer-TipsL{right:-8px;} 111 | 112 | /* skin */ 113 | .layui-layer-lan[type="dialog"]{min-width:280px;} 114 | .layui-layer-lan .layui-layer-title{background:#4476A7; color:#fff; border: none;} 115 | .layui-layer-lan .layui-layer-btn{padding: 5px 10px 10px; text-align: right; border-top:1px solid #E9E7E7} 116 | .layui-layer-lan .layui-layer-btn a{background: #fff; border-color: #E9E7E7; color: #333;} 117 | .layui-layer-lan .layui-layer-btn .layui-layer-btn1{background:#C9C5C5;} 118 | .layui-layer-molv .layui-layer-title{background: #009f95; color:#fff; border: none;} 119 | .layui-layer-molv .layui-layer-btn a{background: #009f95; border-color: #009f95;} 120 | .layui-layer-molv .layui-layer-btn .layui-layer-btn1{background:#92B8B1;} 121 | 122 | 123 | /** 124 | 125 | @Name: layer拓展样式 126 | 127 | */ 128 | 129 | .layui-layer-iconext{background:url(icon-ext.png) no-repeat;} 130 | 131 | /* prompt模式 */ 132 | .layui-layer-prompt .layui-layer-input{display: block; width: 230px; height: 36px; margin: 0 auto; line-height: 30px; padding-left: 10px; border: 1px solid #e6e6e6; color: #333;} 133 | .layui-layer-prompt textarea.layui-layer-input{width: 300px; height: 100px; line-height: 20px; padding: 6px 10px;} 134 | .layui-layer-prompt .layui-layer-content{padding: 20px;} 135 | .layui-layer-prompt .layui-layer-btn{padding-top: 0;} 136 | 137 | /* tab模式 */ 138 | .layui-layer-tab{box-shadow:1px 1px 50px rgba(0,0,0,.4);} 139 | .layui-layer-tab .layui-layer-title{padding-left:0; overflow: visible;} 140 | .layui-layer-tab .layui-layer-title span{position:relative; float:left; min-width:80px; max-width:260px; padding:0 20px; text-align:center; cursor:default; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; cursor: pointer;} 141 | .layui-layer-tab .layui-layer-title span.layui-this{height: 43px; border-left: 1px solid #eee; border-right: 1px solid #eee; background-color: #fff; z-index: 10;} 142 | .layui-layer-tab .layui-layer-title span:first-child{border-left:none;} 143 | .layui-layer-tabmain{line-height:24px; clear:both;} 144 | .layui-layer-tabmain .layui-layer-tabli{display:none;} 145 | .layui-layer-tabmain .layui-layer-tabli.layui-this{display: block;} 146 | 147 | /* photo模式 */ 148 | .layui-layer-photos{-webkit-animation-duration: .8s; animation-duration: .8s;} 149 | .layui-layer-photos .layui-layer-content{overflow:hidden; text-align: center;} 150 | .layui-layer-photos .layui-layer-phimg img{position: relative; width:100%; display: inline-block; *display:inline; *zoom:1; vertical-align:top;} 151 | .layui-layer-imguide,.layui-layer-imgbar{display:none;} 152 | .layui-layer-imgprev, .layui-layer-imgnext{position:absolute; top:50%; width:27px; _width:44px; height:44px; margin-top:-22px; outline:none;blr:expression(this.onFocus=this.blur());} 153 | .layui-layer-imgprev{left:10px; background-position:-5px -5px; _background-position:-70px -5px;} 154 | .layui-layer-imgprev:hover{background-position:-33px -5px; _background-position:-120px -5px;} 155 | .layui-layer-imgnext{right:10px; _right:8px; background-position:-5px -50px; _background-position:-70px -50px;} 156 | .layui-layer-imgnext:hover{background-position:-33px -50px; _background-position:-120px -50px;} 157 | .layui-layer-imgbar{position:absolute; left:0; bottom:0; width:100%; height:32px; line-height:32px; background-color:rgba(0,0,0,.8); background-color:#000\9; filter:Alpha(opacity=80); color:#fff; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; font-size:0;} 158 | .layui-layer-imgtit{/*position:absolute; left:20px;*/} 159 | .layui-layer-imgtit *{display:inline-block; *display:inline; *zoom:1; vertical-align:top; font-size:12px;} 160 | .layui-layer-imgtit a{max-width:65%; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; color:#fff;} 161 | .layui-layer-imgtit a:hover{color:#fff; text-decoration:underline;} 162 | .layui-layer-imgtit em{padding-left:10px; font-style: normal;} 163 | 164 | /* 关闭动画 */ 165 | @-webkit-keyframes layer-bounceOut { 166 | 100% {opacity: 0; -webkit-transform: scale(.7); transform: scale(.7)} 167 | 30% {-webkit-transform: scale(1.05); transform: scale(1.05)} 168 | 0% {-webkit-transform: scale(1); transform: scale(1);} 169 | } 170 | @keyframes layer-bounceOut { 171 | 100% {opacity: 0; -webkit-transform: scale(.7); -ms-transform: scale(.7); transform: scale(.7);} 172 | 30% {-webkit-transform: scale(1.05); -ms-transform: scale(1.05); transform: scale(1.05);} 173 | 0% {-webkit-transform: scale(1); -ms-transform: scale(1);transform: scale(1);} 174 | } 175 | .layer-anim-close{-webkit-animation-name: layer-bounceOut; animation-name: layer-bounceOut; -webkit-animation-fill-mode: both; animation-fill-mode: both; -webkit-animation-duration:.2s; animation-duration:.2s;} 176 | 177 | @media screen and (max-width: 1100px) { 178 | .layui-layer-iframe{overflow-y: auto; -webkit-overflow-scrolling: touch;} 179 | } 180 | 181 | 182 | -------------------------------------------------------------------------------- /layui/css/modules/layer/default/loading-0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/css/modules/layer/default/loading-0.gif -------------------------------------------------------------------------------- /layui/css/modules/layer/default/loading-1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/css/modules/layer/default/loading-1.gif -------------------------------------------------------------------------------- /layui/css/modules/layer/default/loading-2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/css/modules/layer/default/loading-2.gif -------------------------------------------------------------------------------- /layui/font/iconfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/font/iconfont.eot -------------------------------------------------------------------------------- /layui/font/iconfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/font/iconfont.ttf -------------------------------------------------------------------------------- /layui/font/iconfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/font/iconfont.woff -------------------------------------------------------------------------------- /layui/images/face/0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/0.gif -------------------------------------------------------------------------------- /layui/images/face/1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/1.gif -------------------------------------------------------------------------------- /layui/images/face/10.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/10.gif -------------------------------------------------------------------------------- /layui/images/face/11.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/11.gif -------------------------------------------------------------------------------- /layui/images/face/12.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/12.gif -------------------------------------------------------------------------------- /layui/images/face/13.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/13.gif -------------------------------------------------------------------------------- /layui/images/face/14.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/14.gif -------------------------------------------------------------------------------- /layui/images/face/15.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/15.gif -------------------------------------------------------------------------------- /layui/images/face/16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/16.gif -------------------------------------------------------------------------------- /layui/images/face/17.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/17.gif -------------------------------------------------------------------------------- /layui/images/face/18.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/18.gif -------------------------------------------------------------------------------- /layui/images/face/19.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/19.gif -------------------------------------------------------------------------------- /layui/images/face/2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/2.gif -------------------------------------------------------------------------------- /layui/images/face/20.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/20.gif -------------------------------------------------------------------------------- /layui/images/face/21.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/21.gif -------------------------------------------------------------------------------- /layui/images/face/22.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/22.gif -------------------------------------------------------------------------------- /layui/images/face/23.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/23.gif -------------------------------------------------------------------------------- /layui/images/face/24.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/24.gif -------------------------------------------------------------------------------- /layui/images/face/25.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/25.gif -------------------------------------------------------------------------------- /layui/images/face/26.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/26.gif -------------------------------------------------------------------------------- /layui/images/face/27.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/27.gif -------------------------------------------------------------------------------- /layui/images/face/28.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/28.gif -------------------------------------------------------------------------------- /layui/images/face/29.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/29.gif -------------------------------------------------------------------------------- /layui/images/face/3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/3.gif -------------------------------------------------------------------------------- /layui/images/face/30.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/30.gif -------------------------------------------------------------------------------- /layui/images/face/31.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/31.gif -------------------------------------------------------------------------------- /layui/images/face/32.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/32.gif -------------------------------------------------------------------------------- /layui/images/face/33.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/33.gif -------------------------------------------------------------------------------- /layui/images/face/34.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/34.gif -------------------------------------------------------------------------------- /layui/images/face/35.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/35.gif -------------------------------------------------------------------------------- /layui/images/face/36.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/36.gif -------------------------------------------------------------------------------- /layui/images/face/37.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/37.gif -------------------------------------------------------------------------------- /layui/images/face/38.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/38.gif -------------------------------------------------------------------------------- /layui/images/face/39.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/39.gif -------------------------------------------------------------------------------- /layui/images/face/4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/4.gif -------------------------------------------------------------------------------- /layui/images/face/40.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/40.gif -------------------------------------------------------------------------------- /layui/images/face/41.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/41.gif -------------------------------------------------------------------------------- /layui/images/face/42.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/42.gif -------------------------------------------------------------------------------- /layui/images/face/43.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/43.gif -------------------------------------------------------------------------------- /layui/images/face/44.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/44.gif -------------------------------------------------------------------------------- /layui/images/face/45.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/45.gif -------------------------------------------------------------------------------- /layui/images/face/46.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/46.gif -------------------------------------------------------------------------------- /layui/images/face/47.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/47.gif -------------------------------------------------------------------------------- /layui/images/face/48.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/48.gif -------------------------------------------------------------------------------- /layui/images/face/49.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/49.gif -------------------------------------------------------------------------------- /layui/images/face/5.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/5.gif -------------------------------------------------------------------------------- /layui/images/face/50.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/50.gif -------------------------------------------------------------------------------- /layui/images/face/51.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/51.gif -------------------------------------------------------------------------------- /layui/images/face/52.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/52.gif -------------------------------------------------------------------------------- /layui/images/face/53.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/53.gif -------------------------------------------------------------------------------- /layui/images/face/54.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/54.gif -------------------------------------------------------------------------------- /layui/images/face/55.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/55.gif -------------------------------------------------------------------------------- /layui/images/face/56.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/56.gif -------------------------------------------------------------------------------- /layui/images/face/57.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/57.gif -------------------------------------------------------------------------------- /layui/images/face/58.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/58.gif -------------------------------------------------------------------------------- /layui/images/face/59.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/59.gif -------------------------------------------------------------------------------- /layui/images/face/6.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/6.gif -------------------------------------------------------------------------------- /layui/images/face/60.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/60.gif -------------------------------------------------------------------------------- /layui/images/face/61.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/61.gif -------------------------------------------------------------------------------- /layui/images/face/62.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/62.gif -------------------------------------------------------------------------------- /layui/images/face/63.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/63.gif -------------------------------------------------------------------------------- /layui/images/face/64.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/64.gif -------------------------------------------------------------------------------- /layui/images/face/65.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/65.gif -------------------------------------------------------------------------------- /layui/images/face/66.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/66.gif -------------------------------------------------------------------------------- /layui/images/face/67.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/67.gif -------------------------------------------------------------------------------- /layui/images/face/68.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/68.gif -------------------------------------------------------------------------------- /layui/images/face/69.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/69.gif -------------------------------------------------------------------------------- /layui/images/face/7.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/7.gif -------------------------------------------------------------------------------- /layui/images/face/70.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/70.gif -------------------------------------------------------------------------------- /layui/images/face/71.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/71.gif -------------------------------------------------------------------------------- /layui/images/face/8.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/8.gif -------------------------------------------------------------------------------- /layui/images/face/9.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yelog/layui-select-multiple/d15d7743676ed4901a74589d13a4e0e75834b76a/layui/images/face/9.gif -------------------------------------------------------------------------------- /layui/lay/all-mobile.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name:用于打包移动完整版 4 | @Author:贤心 5 | @License:LGPL 6 | 7 | */ 8 | 9 | layui.define(function(exports){ 10 | exports('layui.mobile', layui.v); 11 | }); 12 | -------------------------------------------------------------------------------- /layui/lay/all.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name:用于打包PC完整版,即包含layui.js和所有模块的完整合并(该文件不会存在于构建后的目录) 4 | @Author:贤心 5 | @License:LGPL 6 | 7 | */ 8 | 9 | layui.define(function(exports){ 10 | var cache = layui.cache; 11 | layui.config({ 12 | dir: cache.dir.replace(/lay\/dest\/$/, '') 13 | }); 14 | exports('layui.all', layui.v); 15 | }); 16 | -------------------------------------------------------------------------------- /layui/lay/modules/carousel.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name:layui.carousel 轮播模块 4 | @Author:贤心 5 | @License:MIT 6 | 7 | */ 8 | 9 | layui.define('jquery', function(exports){ 10 | "use strict"; 11 | 12 | var $ = layui.$ 13 | ,hint = layui.hint() 14 | ,device = layui.device() 15 | 16 | //外部接口 17 | ,carousel = { 18 | config: {} //全局配置项 19 | 20 | //设置全局项 21 | ,set: function(options){ 22 | var that = this; 23 | that.config = $.extend({}, that.config, options); 24 | return that; 25 | } 26 | 27 | //事件监听 28 | ,on: function(events, callback){ 29 | return layui.onevent.call(this, MOD_NAME, events, callback); 30 | } 31 | } 32 | 33 | //字符常量 34 | ,MOD_NAME = 'carousel', ELEM = '.layui-carousel', THIS = 'layui-this', SHOW = 'layui-show', HIDE = 'layui-hide', DISABLED = 'layui-disabled' 35 | 36 | ,ELEM_ITEM = '>*[carousel-item]>*', ELEM_LEFT = 'layui-carousel-left', ELEM_RIGHT = 'layui-carousel-right', ELEM_PREV = 'layui-carousel-prev', ELEM_NEXT = 'layui-carousel-next', ELEM_ARROW = 'layui-carousel-arrow', ELEM_IND = 'layui-carousel-ind' 37 | 38 | //构造器 39 | ,Class = function(options){ 40 | var that = this; 41 | that.config = $.extend({}, that.config, carousel.config, options); 42 | that.render(); 43 | }; 44 | 45 | //默认配置 46 | Class.prototype.config = { 47 | width: '600px' 48 | ,height: '280px' 49 | ,full: false //是否全屏 50 | ,arrow: 'hover' //切换箭头默认显示状态:hover/always/none 51 | ,indicator: 'inside' //指示器位置:inside/outside/none 52 | ,autoplay: true //是否自动切换 53 | ,interval: 3000 //自动切换的时间间隔,不能低于800ms 54 | ,anim: '' //动画类型:default/updown/fade 55 | ,trigger: 'click' //指示器的触发方式:click/hover 56 | ,index: 0 //初始开始的索引 57 | }; 58 | 59 | //轮播渲染 60 | Class.prototype.render = function(){ 61 | var that = this 62 | ,options = that.config; 63 | 64 | options.elem = $(options.elem); 65 | if(!options.elem[0]) return; 66 | that.elemItem = options.elem.find(ELEM_ITEM); 67 | 68 | if(options.index < 0) options.index = 0; 69 | if(options.index >= that.elemItem.length) options.index = that.elemItem.length - 1; 70 | if(options.interval < 800) options.interval = 800; 71 | 72 | //是否全屏模式 73 | if(options.full){ 74 | options.elem.css({ 75 | position: 'fixed' 76 | ,width: '100%' 77 | ,height: '100%' 78 | ,zIndex: 9999 79 | }); 80 | } else { 81 | options.elem.css({ 82 | width: options.width 83 | ,height: options.height 84 | }); 85 | } 86 | 87 | options.elem.attr('lay-anim', options.anim); 88 | 89 | //初始焦点状态 90 | that.elemItem.eq(options.index).addClass(THIS); 91 | 92 | //指示器等动作 93 | if(that.elemItem.length <= 1) return; 94 | that.indicator(); 95 | that.arrow(); 96 | that.autoplay(); 97 | that.events(); 98 | }; 99 | 100 | //重置轮播 101 | Class.prototype.reload = function(options){ 102 | var that = this; 103 | clearInterval(that.timer); 104 | that.config = $.extend({}, that.config, options); 105 | that.render(); 106 | }; 107 | 108 | //获取上一个等待条目的索引 109 | Class.prototype.prevIndex = function(){ 110 | var that = this 111 | ,options = that.config; 112 | 113 | var prevIndex = options.index - 1; 114 | if(prevIndex < 0){ 115 | prevIndex = that.elemItem.length - 1; 116 | } 117 | return prevIndex; 118 | }; 119 | 120 | //获取下一个等待条目的索引 121 | Class.prototype.nextIndex = function(){ 122 | var that = this 123 | ,options = that.config; 124 | 125 | var nextIndex = options.index + 1; 126 | if(nextIndex >= that.elemItem.length){ 127 | nextIndex = 0; 128 | } 129 | return nextIndex; 130 | }; 131 | 132 | //索引递增 133 | Class.prototype.addIndex = function(num){ 134 | var that = this 135 | ,options = that.config; 136 | 137 | num = num || 1; 138 | options.index = options.index + num; 139 | 140 | //index不能超过轮播总数量 141 | if(options.index >= that.elemItem.length){ 142 | options.index = 0; 143 | } 144 | }; 145 | 146 | //索引递减 147 | Class.prototype.subIndex = function(num){ 148 | var that = this 149 | ,options = that.config; 150 | 151 | num = num || 1; 152 | options.index = options.index - num; 153 | 154 | //index不能超过轮播总数量 155 | if(options.index < 0){ 156 | options.index = that.elemItem.length - 1; 157 | } 158 | }; 159 | 160 | //自动轮播 161 | Class.prototype.autoplay = function(){ 162 | var that = this 163 | ,options = that.config; 164 | 165 | if(!options.autoplay) return; 166 | 167 | that.timer = setInterval(function(){ 168 | that.slide(); 169 | }, options.interval); 170 | }; 171 | 172 | //箭头 173 | Class.prototype.arrow = function(){ 174 | var that = this 175 | ,options = that.config; 176 | 177 | //模板 178 | var tplArrow = $([ 179 | '' 180 | ,'' 181 | ].join('')); 182 | 183 | //预设基础属性 184 | options.elem.attr('lay-arrow', options.arrow); 185 | 186 | //避免重复插入 187 | if(options.elem.find('.'+ELEM_ARROW)[0]){ 188 | options.elem.find('.'+ELEM_ARROW).remove(); 189 | }; 190 | options.elem.append(tplArrow); 191 | 192 | //事件 193 | tplArrow.on('click', function(){ 194 | var othis = $(this) 195 | ,type = othis.attr('lay-type') 196 | that.slide(type); 197 | }); 198 | }; 199 | 200 | //指示器 201 | Class.prototype.indicator = function(){ 202 | var that = this 203 | ,options = that.config; 204 | 205 | //模板 206 | var tplInd = that.elemInd = $(['
'].join('')); 215 | 216 | //预设基础属性 217 | options.elem.attr('lay-indicator', options.indicator); 218 | 219 | //避免重复插入 220 | if(options.elem.find('.'+ELEM_IND)[0]){ 221 | options.elem.find('.'+ELEM_IND).remove(); 222 | }; 223 | options.elem.append(tplInd); 224 | 225 | if(options.anim === 'updown'){ 226 | tplInd.css('margin-top', -(tplInd.height()/2)); 227 | } 228 | 229 | //事件 230 | tplInd.find('li').on(options.trigger === 'hover' ? 'mouseover' : options.trigger, function(){ 231 | var othis = $(this) 232 | ,index = othis.index(); 233 | if(index > options.index){ 234 | that.slide('add', index - options.index); 235 | } else if(index < options.index){ 236 | that.slide('sub', options.index - index); 237 | } 238 | }); 239 | }; 240 | 241 | //滑动切换 242 | Class.prototype.slide = function(type, num){ 243 | var that = this 244 | ,elemItem = that.elemItem 245 | ,options = that.config 246 | ,thisIndex = options.index 247 | ,filter = options.elem.attr('lay-filter'); 248 | 249 | if(that.haveSlide) return; 250 | 251 | //滑动方向 252 | if(type === 'sub'){ 253 | that.subIndex(num); 254 | elemItem.eq(options.index).addClass(ELEM_PREV); 255 | setTimeout(function(){ 256 | elemItem.eq(thisIndex).addClass(ELEM_RIGHT); 257 | elemItem.eq(options.index).addClass(ELEM_RIGHT); 258 | }, 50); 259 | } else { //默认递增滑 260 | that.addIndex(num); 261 | elemItem.eq(options.index).addClass(ELEM_NEXT); 262 | setTimeout(function(){ 263 | elemItem.eq(thisIndex).addClass(ELEM_LEFT); 264 | elemItem.eq(options.index).addClass(ELEM_LEFT); 265 | }, 50); 266 | }; 267 | 268 | //移除过度类 269 | setTimeout(function(){ 270 | elemItem.removeClass(THIS + ' ' + ELEM_PREV + ' ' + ELEM_NEXT + ' ' + ELEM_LEFT + ' ' + ELEM_RIGHT); 271 | elemItem.eq(options.index).addClass(THIS); 272 | that.haveSlide = false; //解锁 273 | }, 300); 274 | 275 | //指示器焦点 276 | that.elemInd.find('li').eq(options.index).addClass(THIS) 277 | .siblings().removeClass(THIS); 278 | 279 | that.haveSlide = true; 280 | 281 | layui.event.call(this, MOD_NAME, 'change('+ filter +')', { 282 | index: options.index 283 | ,prevIndex: thisIndex 284 | ,item: elemItem.eq(options.index) 285 | }); 286 | }; 287 | 288 | //事件处理 289 | Class.prototype.events = function(){ 290 | var that = this 291 | ,options = that.config; 292 | 293 | if(options.elem.data('haveEvents')) return; 294 | 295 | //移入移出容器 296 | options.elem.on('mouseenter', function(){ 297 | clearInterval(that.timer); 298 | }).on('mouseleave', function(){ 299 | that.autoplay(); 300 | }); 301 | 302 | options.elem.data('haveEvents', true); 303 | }; 304 | 305 | //核心入口 306 | carousel.render = function(options){ 307 | var inst = new Class(options); 308 | return inst; 309 | }; 310 | 311 | exports(MOD_NAME, carousel); 312 | }); 313 | 314 | 315 | -------------------------------------------------------------------------------- /layui/lay/modules/code.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name:layui.code 代码修饰器 4 | @Author:贤心 5 | @License:MIT 6 | 7 | */ 8 | 9 | layui.define('jquery', function(exports){ 10 | "use strict"; 11 | 12 | var $ = layui.$; 13 | var about = 'http://www.layui.com/doc/modules/code.html'; //关于信息 14 | 15 | exports('code', function(options){ 16 | var elems = []; 17 | options = options || {}; 18 | options.elem = $(options.elem||'.layui-code'); 19 | options.about = 'about' in options ? options.about : true; 20 | 21 | options.elem.each(function(){ 22 | elems.push(this); 23 | }); 24 | 25 | layui.each(elems.reverse(), function(index, item){ 26 | var othis = $(item), html = othis.html(); 27 | 28 | //转义HTML标签 29 | if(othis.attr('lay-encode') || options.encode){ 30 | html = html.replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&') 31 | .replace(//g, '>').replace(/'/g, ''').replace(/"/g, '"') 32 | } 33 | 34 | othis.html('
  1. ' + html.replace(/[\r\t\n]+/g, '
  2. ') + '
') 35 | 36 | if(!othis.find('>.layui-code-h3')[0]){ 37 | othis.prepend('

'+ (othis.attr('lay-title')||options.title||'code') + (options.about ? 'layui.code' : '') + '

'); 38 | } 39 | 40 | var ol = othis.find('>.layui-code-ol'); 41 | othis.addClass('layui-box layui-code-view'); 42 | 43 | //识别皮肤 44 | if(othis.attr('lay-skin') || options.skin){ 45 | othis.addClass('layui-code-' +(othis.attr('lay-skin') || options.skin)); 46 | } 47 | 48 | //按行数适配左边距 49 | if((ol.find('li').length/100|0) > 0){ 50 | ol.css('margin-left', (ol.find('li').length/100|0) + 'px'); 51 | } 52 | 53 | //设置最大高度 54 | if(othis.attr('lay-height') || options.height){ 55 | ol.css('max-height', othis.attr('lay-height') || options.height); 56 | } 57 | 58 | }); 59 | 60 | }); 61 | }).addcss('modules/code.css', 'skincodecss'); -------------------------------------------------------------------------------- /layui/lay/modules/element.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name:layui.element 常用元素操作 4 | @Author:贤心 5 | @License:MIT 6 | 7 | */ 8 | 9 | layui.define('jquery', function(exports){ 10 | "use strict"; 11 | 12 | var $ = layui.$ 13 | ,hint = layui.hint() 14 | ,device = layui.device() 15 | 16 | ,MOD_NAME = 'element', THIS = 'layui-this', SHOW = 'layui-show' 17 | 18 | ,Element = function(){ 19 | this.config = {}; 20 | }; 21 | 22 | //全局设置 23 | Element.prototype.set = function(options){ 24 | var that = this; 25 | $.extend(true, that.config, options); 26 | return that; 27 | }; 28 | 29 | //表单事件监听 30 | Element.prototype.on = function(events, callback){ 31 | return layui.onevent.call(this, MOD_NAME, events, callback); 32 | }; 33 | 34 | //外部Tab新增 35 | Element.prototype.tabAdd = function(filter, options){ 36 | var TITLE = '.layui-tab-title' 37 | ,tabElem = $('.layui-tab[lay-filter='+ filter +']') 38 | ,titElem = tabElem.children(TITLE) 39 | ,barElem = titElem.children('.layui-tab-bar') 40 | ,contElem = tabElem.children('.layui-tab-content') 41 | ,li = '
  • '+ (options.title||'unnaming') +'
  • '; 43 | 44 | barElem[0] ? barElem.before(li) : titElem.append(li); 45 | contElem.append('
    '+ (options.content||'') +'
    '); 46 | call.hideTabMore(true); 47 | call.tabAuto(); 48 | return this; 49 | }; 50 | 51 | //外部Tab删除 52 | Element.prototype.tabDelete = function(filter, layid){ 53 | var TITLE = '.layui-tab-title' 54 | ,tabElem = $('.layui-tab[lay-filter='+ filter +']') 55 | ,titElem = tabElem.children(TITLE) 56 | ,liElem = titElem.find('>li[lay-id="'+ layid +'"]'); 57 | call.tabDelete(null, liElem); 58 | return this; 59 | }; 60 | 61 | //外部Tab切换 62 | Element.prototype.tabChange = function(filter, layid){ 63 | var TITLE = '.layui-tab-title' 64 | ,tabElem = $('.layui-tab[lay-filter='+ filter +']') 65 | ,titElem = tabElem.children(TITLE) 66 | ,liElem = titElem.find('>li[lay-id="'+ layid +'"]'); 67 | call.tabClick.call(liElem[0], null, null, liElem); 68 | return this; 69 | }; 70 | 71 | //自定义Tab选项卡 72 | Element.prototype.tab = function(options){ 73 | options = options || {}; 74 | dom.on('click', options.headerElem, function(e){ 75 | var index = $(this).index(); 76 | call.tabClick.call(this, e, index, null, options); 77 | }); 78 | }; 79 | 80 | 81 | //动态改变进度条 82 | Element.prototype.progress = function(filter, percent){ 83 | var ELEM = 'layui-progress' 84 | ,elem = $('.'+ ELEM +'[lay-filter='+ filter +']') 85 | ,elemBar = elem.find('.'+ ELEM +'-bar') 86 | ,text = elemBar.find('.'+ ELEM +'-text'); 87 | elemBar.css('width', percent); 88 | text.text(percent); 89 | return this; 90 | }; 91 | 92 | var NAV_ELEM = '.layui-nav', NAV_ITEM = 'layui-nav-item', NAV_BAR = 'layui-nav-bar' 93 | ,NAV_TREE = 'layui-nav-tree', NAV_CHILD = 'layui-nav-child', NAV_MORE = 'layui-nav-more' 94 | ,NAV_ANIM = 'layui-anim layui-anim-upbit' 95 | 96 | //基础事件体 97 | ,call = { 98 | //Tab点击 99 | tabClick: function(e, index, liElem, options){ 100 | options = options || {}; 101 | var othis = liElem || $(this) 102 | ,index = index || othis.parent().children('li').index(othis) 103 | ,parents = options.headerElem ? othis.parent() : othis.parents('.layui-tab').eq(0) 104 | ,item = options.bodyElem ? $(options.bodyElem) : parents.children('.layui-tab-content').children('.layui-tab-item') 105 | ,elemA = othis.find('a') 106 | ,filter = parents.attr('lay-filter'); 107 | 108 | if(!(elemA.attr('href') !== 'javascript:;' && elemA.attr('target') === '_blank')){ 109 | othis.addClass(THIS).siblings().removeClass(THIS); 110 | item.eq(index).addClass(SHOW).siblings().removeClass(SHOW); 111 | } 112 | 113 | layui.event.call(this, MOD_NAME, 'tab('+ filter +')', { 114 | elem: parents 115 | ,index: index 116 | }); 117 | } 118 | 119 | //Tab删除 120 | ,tabDelete: function(e, othis){ 121 | var li = othis || $(this).parent(), index = li.index() 122 | ,parents = li.parents('.layui-tab').eq(0) 123 | ,item = parents.children('.layui-tab-content').children('.layui-tab-item') 124 | ,filter = parents.attr('lay-filter'); 125 | 126 | if(li.hasClass(THIS)){ 127 | if(li.next()[0]){ 128 | call.tabClick.call(li.next()[0], null, index + 1); 129 | } else if(li.prev()[0]){ 130 | call.tabClick.call(li.prev()[0], null, index - 1); 131 | } 132 | } 133 | 134 | li.remove(); 135 | item.eq(index).remove(); 136 | setTimeout(function(){ 137 | call.tabAuto(); 138 | }, 50); 139 | 140 | layui.event.call(this, MOD_NAME, 'tabDelete('+ filter +')', { 141 | elem: parents 142 | ,index: index 143 | }); 144 | } 145 | 146 | //Tab自适应 147 | ,tabAuto: function(){ 148 | var SCROLL = 'layui-tab-scroll', MORE = 'layui-tab-more', BAR = 'layui-tab-bar' 149 | ,CLOSE = 'layui-tab-close', that = this; 150 | 151 | $('.layui-tab').each(function(){ 152 | var othis = $(this) 153 | ,title = othis.children('.layui-tab-title') 154 | ,item = othis.children('.layui-tab-content').children('.layui-tab-item') 155 | ,STOPE = 'lay-stope="tabmore"' 156 | ,span = $(''); 157 | 158 | if(that === window && device.ie != 8){ 159 | call.hideTabMore(true) 160 | } 161 | 162 | //允许关闭 163 | if(othis.attr('lay-allowClose')){ 164 | title.find('li').each(function(){ 165 | var li = $(this); 166 | if(!li.find('.'+CLOSE)[0]){ 167 | var close = $(''); 168 | close.on('click', call.tabDelete); 169 | li.append(close); 170 | } 171 | }); 172 | } 173 | 174 | if(typeof othis.attr('lay-unauto') === 'string') return; 175 | 176 | //响应式 177 | if(title.prop('scrollWidth') > title.outerWidth()+1){ 178 | if(title.find('.'+BAR)[0]) return; 179 | title.append(span); 180 | othis.attr('overflow', ''); 181 | span.on('click', function(e){ 182 | title[this.title ? 'removeClass' : 'addClass'](MORE); 183 | this.title = this.title ? '' : '收缩'; 184 | }); 185 | } else { 186 | title.find('.'+BAR).remove(); 187 | othis.removeAttr('overflow'); 188 | } 189 | }); 190 | } 191 | //隐藏更多Tab 192 | ,hideTabMore: function(e){ 193 | var tsbTitle = $('.layui-tab-title'); 194 | if(e === true || $(e.target).attr('lay-stope') !== 'tabmore'){ 195 | tsbTitle.removeClass('layui-tab-more'); 196 | tsbTitle.find('.layui-tab-bar').attr('title',''); 197 | } 198 | } 199 | 200 | //点击一级菜单 201 | /* 202 | ,clickThis: function(){ 203 | var othis = $(this), parents = othis.parents(NAV_ELEM) 204 | ,filter = parents.attr('lay-filter') 205 | ,elemA = othis.find('a') 206 | ,unselect = typeof othis.attr('lay-unselect') === 'string'; 207 | 208 | if(othis.find('.'+NAV_CHILD)[0]) return; 209 | 210 | if(!(elemA.attr('href') !== 'javascript:;' && elemA.attr('target') === '_blank') && !unselect){ 211 | parents.find('.'+THIS).removeClass(THIS); 212 | othis.addClass(THIS); 213 | } 214 | 215 | layui.event.call(this, MOD_NAME, 'nav('+ filter +')', othis); 216 | } 217 | ) 218 | */ 219 | 220 | //点击菜单 - a标签触发 221 | ,clickThis: function(){ 222 | var othis = $(this) 223 | ,parents = othis.parents(NAV_ELEM) 224 | ,filter = parents.attr('lay-filter') 225 | ,parent = othis.parent() 226 | ,child = othis.siblings('.'+NAV_CHILD) 227 | ,unselect = typeof parent.attr('lay-unselect') === 'string'; 228 | 229 | if(!(othis.attr('href') !== 'javascript:;' && othis.attr('target') === '_blank') && !unselect){ 230 | if(!child[0]){ 231 | parents.find('.'+THIS).removeClass(THIS); 232 | parent.addClass(THIS); 233 | } 234 | } 235 | 236 | //如果是垂直菜单 237 | if(parents.hasClass(NAV_TREE)){ 238 | child.removeClass(NAV_ANIM); 239 | 240 | //如果有子菜单,则展开 241 | if(child[0]){ 242 | parent[child.css('display') === 'none' ? 'addClass': 'removeClass'](NAV_ITEM+'ed'); 243 | if(parents.attr('lay-shrink') === 'all'){ 244 | parent.siblings().removeClass(NAV_ITEM + 'ed'); 245 | } 246 | } 247 | } 248 | 249 | layui.event.call(this, MOD_NAME, 'nav('+ filter +')', othis); 250 | } 251 | 252 | //点击子菜单选中 253 | /* 254 | ,clickChild: function(){ 255 | var othis = $(this), parents = othis.parents(NAV_ELEM) 256 | ,filter = parents.attr('lay-filter'); 257 | parents.find('.'+THIS).removeClass(THIS); 258 | othis.addClass(THIS); 259 | layui.event.call(this, MOD_NAME, 'nav('+ filter +')', othis); 260 | } 261 | */ 262 | 263 | //折叠面板 264 | ,collapse: function(){ 265 | var othis = $(this), icon = othis.find('.layui-colla-icon') 266 | ,elemCont = othis.siblings('.layui-colla-content') 267 | ,parents = othis.parents('.layui-collapse').eq(0) 268 | ,filter = parents.attr('lay-filter') 269 | ,isNone = elemCont.css('display') === 'none'; 270 | 271 | //是否手风琴 272 | if(typeof parents.attr('lay-accordion') === 'string'){ 273 | var show = parents.children('.layui-colla-item').children('.'+SHOW); 274 | show.siblings('.layui-colla-title').children('.layui-colla-icon').html(''); 275 | show.removeClass(SHOW); 276 | } 277 | 278 | elemCont[isNone ? 'addClass' : 'removeClass'](SHOW); 279 | icon.html(isNone ? '' : ''); 280 | 281 | layui.event.call(this, MOD_NAME, 'collapse('+ filter +')', { 282 | title: othis 283 | ,content: elemCont 284 | ,show: isNone 285 | }); 286 | } 287 | }; 288 | 289 | //初始化元素操作 290 | Element.prototype.init = function(type, filter){ 291 | var that = this, elemFilter = function(){ 292 | return filter ? ('[lay-filter="' + filter +'"]') : ''; 293 | }(), items = { 294 | 295 | //Tab选项卡 296 | tab: function(){ 297 | call.tabAuto.call({}); 298 | } 299 | 300 | //导航菜单 301 | ,nav: function(){ 302 | var TIME = 200, timer = {}, timerMore = {}, timeEnd = {}, follow = function(bar, nav, index){ 303 | var othis = $(this), child = othis.find('.'+NAV_CHILD); 304 | 305 | if(nav.hasClass(NAV_TREE)){ 306 | bar.css({ 307 | top: othis.position().top 308 | ,height: othis.children('a').outerHeight() 309 | ,opacity: 1 310 | }); 311 | } else { 312 | child.addClass(NAV_ANIM); 313 | bar.css({ 314 | left: othis.position().left + parseFloat(othis.css('marginLeft')) 315 | ,top: othis.position().top + othis.height() - bar.height() 316 | }); 317 | 318 | timer[index] = setTimeout(function(){ 319 | bar.css({ 320 | width: othis.width() 321 | ,opacity: 1 322 | }); 323 | }, device.ie && device.ie < 10 ? 0 : TIME); 324 | 325 | clearTimeout(timeEnd[index]); 326 | if(child.css('display') === 'block'){ 327 | clearTimeout(timerMore[index]); 328 | } 329 | timerMore[index] = setTimeout(function(){ 330 | child.addClass(SHOW) 331 | othis.find('.'+NAV_MORE).addClass(NAV_MORE+'d'); 332 | }, 300); 333 | } 334 | } 335 | 336 | $(NAV_ELEM + elemFilter).each(function(index){ 337 | var othis = $(this) 338 | ,bar = $('') 339 | ,itemElem = othis.find('.'+NAV_ITEM); 340 | 341 | //Hover滑动效果 342 | if(!othis.find('.'+NAV_BAR)[0]){ 343 | othis.append(bar); 344 | itemElem.on('mouseenter', function(){ 345 | follow.call(this, bar, othis, index); 346 | }).on('mouseleave', function(){ 347 | if(!othis.hasClass(NAV_TREE)){ 348 | clearTimeout(timerMore[index]); 349 | timerMore[index] = setTimeout(function(){ 350 | othis.find('.'+NAV_CHILD).removeClass(SHOW); 351 | othis.find('.'+NAV_MORE).removeClass(NAV_MORE+'d'); 352 | }, 300); 353 | } 354 | }); 355 | othis.on('mouseleave', function(){ 356 | clearTimeout(timer[index]) 357 | timeEnd[index] = setTimeout(function(){ 358 | if(othis.hasClass(NAV_TREE)){ 359 | bar.css({ 360 | height: 0 361 | ,top: bar.position().top + bar.height()/2 362 | ,opacity: 0 363 | }); 364 | } else { 365 | bar.css({ 366 | width: 0 367 | ,left: bar.position().left + bar.width()/2 368 | ,opacity: 0 369 | }); 370 | } 371 | }, TIME); 372 | }); 373 | } 374 | 375 | //展开子菜单 376 | itemElem.find('a').each(function(){ 377 | var thisA = $(this) 378 | ,parent = thisA.parent() 379 | ,child = thisA.siblings('.'+NAV_CHILD); 380 | 381 | //输出小箭头 382 | if(child[0] && !thisA.children('.'+NAV_MORE)[0]){ 383 | thisA.append(''); 384 | } 385 | 386 | thisA.off('click', call.clickThis).on('click', call.clickThis); //点击菜单 387 | }); 388 | }); 389 | } 390 | 391 | //面包屑 392 | ,breadcrumb: function(){ 393 | var ELEM = '.layui-breadcrumb'; 394 | 395 | $(ELEM + elemFilter).each(function(){ 396 | var othis = $(this) 397 | ,ATTE_SPR = 'lay-separator' 398 | ,separator = othis.attr(ATTE_SPR) || '/' 399 | ,aNode = othis.find('a'); 400 | if(aNode.next('span['+ ATTE_SPR +']')[0]) return; 401 | aNode.each(function(index){ 402 | if(index === aNode.length - 1) return; 403 | $(this).after(''+ separator +''); 404 | }); 405 | othis.css('visibility', 'visible'); 406 | }); 407 | } 408 | 409 | //进度条 410 | ,progress: function(){ 411 | var ELEM = 'layui-progress'; 412 | $('.' + ELEM + elemFilter).each(function(){ 413 | var othis = $(this) 414 | ,elemBar = othis.find('.layui-progress-bar') 415 | ,percent = elemBar.attr('lay-percent'); 416 | 417 | elemBar.css('width', function(){ 418 | return /^.+\/.+$/.test(percent) 419 | ? (new Function('return '+ percent)() * 100) + '%' 420 | : percent; 421 | }()); 422 | 423 | if(othis.attr('lay-showPercent')){ 424 | setTimeout(function(){ 425 | elemBar.html(''+ percent +''); 426 | },350); 427 | } 428 | }); 429 | } 430 | 431 | //折叠面板 432 | ,collapse: function(){ 433 | var ELEM = 'layui-collapse'; 434 | 435 | $('.' + ELEM + elemFilter).each(function(){ 436 | var elemItem = $(this).find('.layui-colla-item') 437 | elemItem.each(function(){ 438 | var othis = $(this) 439 | ,elemTitle = othis.find('.layui-colla-title') 440 | ,elemCont = othis.find('.layui-colla-content') 441 | ,isNone = elemCont.css('display') === 'none'; 442 | 443 | //初始状态 444 | elemTitle.find('.layui-colla-icon').remove(); 445 | elemTitle.append(''+ (isNone ? '' : '') +''); 446 | 447 | //点击标题 448 | elemTitle.off('click', call.collapse).on('click', call.collapse); 449 | }); 450 | 451 | }); 452 | } 453 | }; 454 | 455 | return items[type] ? items[type]() : layui.each(items, function(index, item){ 456 | item(); 457 | }); 458 | }; 459 | 460 | Element.prototype.render = Element.prototype.init; 461 | 462 | var element = new Element(), dom = $(document); 463 | element.render(); 464 | 465 | var TITLE = '.layui-tab-title li'; 466 | dom.on('click', TITLE, call.tabClick); //Tab切换 467 | dom.on('click', call.hideTabMore); //隐藏展开的Tab 468 | $(window).on('resize', call.tabAuto); //自适应 469 | 470 | exports(MOD_NAME, element); 471 | }); 472 | 473 | -------------------------------------------------------------------------------- /layui/lay/modules/flow.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name:layui.flow 流加载 4 | @Author:贤心 5 | @License:MIT 6 | 7 | */ 8 | 9 | 10 | layui.define('jquery', function(exports){ 11 | "use strict"; 12 | 13 | var $ = layui.$, Flow = function(options){} 14 | ,ELEM_MORE = 'layui-flow-more' 15 | ,ELEM_LOAD = ''; 16 | 17 | //主方法 18 | Flow.prototype.load = function(options){ 19 | var that = this, page = 0, lock, isOver, lazyimg, timer; 20 | options = options || {}; 21 | 22 | var elem = $(options.elem); if(!elem[0]) return; 23 | var scrollElem = $(options.scrollElem || document); //滚动条所在元素 24 | var mb = options.mb || 50; //与底部的临界距离 25 | var isAuto = 'isAuto' in options ? options.isAuto : true; //是否自动滚动加载 26 | var end = options.end || '没有更多了'; //“末页”显示文案 27 | 28 | //滚动条所在元素是否为document 29 | var notDocment = options.scrollElem && options.scrollElem !== document; 30 | 31 | //加载更多 32 | var ELEM_TEXT = '加载更多' 33 | ,more = $('
    '+ ELEM_TEXT +'
    '); 34 | 35 | if(!elem.find('.layui-flow-more')[0]){ 36 | elem.append(more); 37 | } 38 | 39 | //加载下一个元素 40 | var next = function(html, over){ 41 | html = $(html); 42 | more.before(html); 43 | over = over == 0 ? true : null; 44 | over ? more.html(end) : more.find('a').html(ELEM_TEXT); 45 | isOver = over; 46 | lock = null; 47 | lazyimg && lazyimg(); 48 | }; 49 | 50 | //触发请求 51 | var done = function(){ 52 | lock = true; 53 | more.find('a').html(ELEM_LOAD); 54 | typeof options.done === 'function' && options.done(++page, next); 55 | }; 56 | 57 | done(); 58 | 59 | //不自动滚动加载 60 | more.find('a').on('click', function(){ 61 | var othis = $(this); 62 | if(isOver) return; 63 | lock || done(); 64 | }); 65 | 66 | //如果允许图片懒加载 67 | if(options.isLazyimg){ 68 | var lazyimg = that.lazyimg({ 69 | elem: options.elem + ' img' 70 | ,scrollElem: options.scrollElem 71 | }); 72 | } 73 | 74 | if(!isAuto) return that; 75 | 76 | scrollElem.on('scroll', function(){ 77 | var othis = $(this), top = othis.scrollTop(); 78 | 79 | if(timer) clearTimeout(timer); 80 | if(isOver) return; 81 | 82 | timer = setTimeout(function(){ 83 | //计算滚动所在容器的可视高度 84 | var height = notDocment ? othis.height() : $(window).height(); 85 | 86 | //计算滚动所在容器的实际高度 87 | var scrollHeight = notDocment 88 | ? othis.prop('scrollHeight') 89 | : document.documentElement.scrollHeight; 90 | 91 | //临界点 92 | if(scrollHeight - top - height <= mb){ 93 | lock || done(); 94 | } 95 | }, 100); 96 | }); 97 | return that; 98 | }; 99 | 100 | //图片懒加载 101 | Flow.prototype.lazyimg = function(options){ 102 | var that = this, index = 0, haveScroll; 103 | options = options || {}; 104 | 105 | var scrollElem = $(options.scrollElem || document); //滚动条所在元素 106 | var elem = options.elem || 'img'; 107 | 108 | //滚动条所在元素是否为document 109 | var notDocment = options.scrollElem && options.scrollElem !== document; 110 | 111 | //显示图片 112 | var show = function(item, height){ 113 | var start = scrollElem.scrollTop(), end = start + height; 114 | var elemTop = notDocment ? function(){ 115 | return item.offset().top - scrollElem.offset().top + start; 116 | }() : item.offset().top; 117 | 118 | /* 始终只加载在当前屏范围内的图片 */ 119 | if(elemTop >= start && elemTop <= end){ 120 | if(!item.attr('src')){ 121 | var src = item.attr('lay-src'); 122 | layui.img(src, function(){ 123 | var next = that.lazyimg.elem.eq(index); 124 | item.attr('src', src).removeAttr('lay-src'); 125 | 126 | /* 当前图片加载就绪后,检测下一个图片是否在当前屏 */ 127 | next[0] && render(next); 128 | index++; 129 | }); 130 | } 131 | } 132 | }, render = function(othis, scroll){ 133 | 134 | //计算滚动所在容器的可视高度 135 | var height = notDocment ? (scroll||scrollElem).height() : $(window).height(); 136 | var start = scrollElem.scrollTop(), end = start + height; 137 | 138 | that.lazyimg.elem = $(elem); 139 | 140 | if(othis){ 141 | show(othis, height); 142 | } else { 143 | //计算未加载过的图片 144 | for(var i = 0; i < that.lazyimg.elem.length; i++){ 145 | var item = that.lazyimg.elem.eq(i), elemTop = notDocment ? function(){ 146 | return item.offset().top - scrollElem.offset().top + start; 147 | }() : item.offset().top; 148 | 149 | show(item, height); 150 | index = i; 151 | 152 | //如果图片的top坐标,超出了当前屏,则终止后续图片的遍历 153 | if(elemTop > end) break; 154 | } 155 | } 156 | }; 157 | 158 | render(); 159 | 160 | if(!haveScroll){ 161 | var timer; 162 | scrollElem.on('scroll', function(){ 163 | var othis = $(this); 164 | if(timer) clearTimeout(timer) 165 | timer = setTimeout(function(){ 166 | render(null, othis); 167 | }, 50); 168 | }); 169 | haveScroll = true; 170 | } 171 | return render; 172 | }; 173 | 174 | //暴露接口 175 | exports('flow', new Flow()); 176 | }); 177 | -------------------------------------------------------------------------------- /layui/lay/modules/layedit.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name:layui.layedit 富文本编辑器 4 | @Author:贤心 5 | @License:MIT 6 | 7 | */ 8 | 9 | layui.define(['layer', 'form'], function(exports){ 10 | "use strict"; 11 | 12 | var $ = layui.$ 13 | ,layer = layui.layer 14 | ,form = layui.form 15 | ,hint = layui.hint() 16 | ,device = layui.device() 17 | 18 | ,MOD_NAME = 'layedit', THIS = 'layui-this', SHOW = 'layui-show', ABLED = 'layui-disabled' 19 | 20 | ,Edit = function(){ 21 | var that = this; 22 | that.index = 0; 23 | 24 | //全局配置 25 | that.config = { 26 | //默认工具bar 27 | tool: [ 28 | 'strong', 'italic', 'underline', 'del' 29 | ,'|' 30 | ,'left', 'center', 'right' 31 | ,'|' 32 | ,'link', 'unlink', 'face', 'image' 33 | ] 34 | ,hideTool: [] 35 | ,height: 280 //默认高 36 | }; 37 | }; 38 | 39 | //全局设置 40 | Edit.prototype.set = function(options){ 41 | var that = this; 42 | $.extend(true, that.config, options); 43 | return that; 44 | }; 45 | 46 | //事件监听 47 | Edit.prototype.on = function(events, callback){ 48 | return layui.onevent(MOD_NAME, events, callback); 49 | }; 50 | 51 | //建立编辑器 52 | Edit.prototype.build = function(id, settings){ 53 | settings = settings || {}; 54 | 55 | var that = this 56 | ,config = that.config 57 | ,ELEM = 'layui-layedit', textArea = $(typeof(id)=='string'?'#'+id:id) 58 | ,name = 'LAY_layedit_'+ (++that.index) 59 | ,haveBuild = textArea.next('.'+ELEM) 60 | 61 | ,set = $.extend({}, config, settings) 62 | 63 | ,tool = function(){ 64 | var node = [], hideTools = {}; 65 | layui.each(set.hideTool, function(_, item){ 66 | hideTools[item] = true; 67 | }); 68 | layui.each(set.tool, function(_, item){ 69 | if(tools[item] && !hideTools[item]){ 70 | node.push(tools[item]); 71 | } 72 | }); 73 | return node.join(''); 74 | }() 75 | 76 | 77 | ,editor = $(['
    ' 78 | ,'
    '+ tool +'
    ' 79 | ,'
    ' 80 | ,'' 81 | ,'
    ' 82 | ,'
    '].join('')) 83 | 84 | //编辑器不兼容ie8以下 85 | if(device.ie && device.ie < 8){ 86 | return textArea.removeClass('layui-hide').addClass(SHOW); 87 | } 88 | 89 | haveBuild[0] && (haveBuild.remove()); 90 | 91 | setIframe.call(that, editor, textArea[0], set) 92 | textArea.addClass('layui-hide').after(editor); 93 | 94 | return that.index; 95 | }; 96 | 97 | //获得编辑器中内容 98 | Edit.prototype.getContent = function(index){ 99 | var iframeWin = getWin(index); 100 | if(!iframeWin[0]) return; 101 | return toLower(iframeWin[0].document.body.innerHTML); 102 | }; 103 | 104 | //获得编辑器中纯文本内容 105 | Edit.prototype.getText = function(index){ 106 | var iframeWin = getWin(index); 107 | if(!iframeWin[0]) return; 108 | return $(iframeWin[0].document.body).text(); 109 | }; 110 | /** 111 | * 设置编辑器内容 112 | * @param {[type]} index 编辑器索引 113 | * @param {[type]} content 要设置的内容 114 | * @param {[type]} flag 是否追加模式 115 | */ 116 | Edit.prototype.setContent = function(index, content, flag){ 117 | var iframeWin = getWin(index); 118 | if(!iframeWin[0]) return; 119 | if(flag){ 120 | $(iframeWin[0].document.body).append(content) 121 | }else{ 122 | $(iframeWin[0].document.body).html(content) 123 | }; 124 | layedit.sync(index) 125 | }; 126 | //将编辑器内容同步到textarea(一般用于异步提交时) 127 | Edit.prototype.sync = function(index){ 128 | var iframeWin = getWin(index); 129 | if(!iframeWin[0]) return; 130 | var textarea = $('#'+iframeWin[1].attr('textarea')); 131 | textarea.val(toLower(iframeWin[0].document.body.innerHTML)); 132 | }; 133 | 134 | //获取编辑器选中内容 135 | Edit.prototype.getSelection = function(index){ 136 | var iframeWin = getWin(index); 137 | if(!iframeWin[0]) return; 138 | var range = Range(iframeWin[0].document); 139 | return document.selection ? range.text : range.toString(); 140 | }; 141 | 142 | //iframe初始化 143 | var setIframe = function(editor, textArea, set){ 144 | var that = this, iframe = editor.find('iframe'); 145 | 146 | iframe.css({ 147 | height: set.height 148 | }).on('load', function(){ 149 | var conts = iframe.contents() 150 | ,iframeWin = iframe.prop('contentWindow') 151 | ,head = conts.find('head') 152 | ,style = $([''].join('')) 160 | ,body = conts.find('body'); 161 | 162 | head.append(style); 163 | body.attr('contenteditable', 'true').css({ 164 | 'min-height': set.height 165 | }).html(textArea.value||''); 166 | 167 | hotkey.apply(that, [iframeWin, iframe, textArea, set]); //快捷键处理 168 | toolActive.call(that, iframeWin, editor, set); //触发工具 169 | 170 | }); 171 | } 172 | 173 | //获得iframe窗口对象 174 | ,getWin = function(index){ 175 | var iframe = $('#LAY_layedit_'+ index) 176 | ,iframeWin = iframe.prop('contentWindow'); 177 | return [iframeWin, iframe]; 178 | } 179 | 180 | //IE8下将标签处理成小写 181 | ,toLower = function(html){ 182 | if(device.ie == 8){ 183 | html = html.replace(/<.+>/g, function(str){ 184 | return str.toLowerCase(); 185 | }); 186 | } 187 | return html; 188 | } 189 | 190 | //快捷键处理 191 | ,hotkey = function(iframeWin, iframe, textArea, set){ 192 | var iframeDOM = iframeWin.document, body = $(iframeDOM.body); 193 | body.on('keydown', function(e){ 194 | var keycode = e.keyCode; 195 | //处理回车 196 | if(keycode === 13){ 197 | var range = Range(iframeDOM); 198 | var container = getContainer(range) 199 | ,parentNode = container.parentNode; 200 | 201 | if(parentNode.tagName.toLowerCase() === 'pre'){ 202 | if(e.shiftKey) return 203 | layer.msg('请暂时用shift+enter'); 204 | return false; 205 | } 206 | iframeDOM.execCommand('formatBlock', false, '

    '); 207 | } 208 | }); 209 | 210 | //给textarea同步内容 211 | $(textArea).parents('form').on('submit', function(){ 212 | var html = body.html(); 213 | //IE8下将标签处理成小写 214 | if(device.ie == 8){ 215 | html = html.replace(/<.+>/g, function(str){ 216 | return str.toLowerCase(); 217 | }); 218 | } 219 | textArea.value = html; 220 | }); 221 | 222 | //处理粘贴 223 | body.on('paste', function(e){ 224 | iframeDOM.execCommand('formatBlock', false, '

    '); 225 | setTimeout(function(){ 226 | filter.call(iframeWin, body); 227 | textArea.value = body.html(); 228 | }, 100); 229 | }); 230 | } 231 | 232 | //标签过滤 233 | ,filter = function(body){ 234 | var iframeWin = this 235 | ,iframeDOM = iframeWin.document; 236 | 237 | //清除影响版面的css属性 238 | body.find('*[style]').each(function(){ 239 | var textAlign = this.style.textAlign; 240 | this.removeAttribute('style'); 241 | $(this).css({ 242 | 'text-align': textAlign || '' 243 | }) 244 | }); 245 | 246 | //修饰表格 247 | body.find('table').addClass('layui-table'); 248 | 249 | //移除不安全的标签 250 | body.find('script,link').remove(); 251 | } 252 | 253 | //Range对象兼容性处理 254 | ,Range = function(iframeDOM){ 255 | return iframeDOM.selection 256 | ? iframeDOM.selection.createRange() 257 | : iframeDOM.getSelection().getRangeAt(0); 258 | } 259 | 260 | //当前Range对象的endContainer兼容性处理 261 | ,getContainer = function(range){ 262 | return range.endContainer || range.parentElement().childNodes[0] 263 | } 264 | 265 | //在选区插入内联元素 266 | ,insertInline = function(tagName, attr, range){ 267 | var iframeDOM = this.document 268 | ,elem = document.createElement(tagName) 269 | for(var key in attr){ 270 | elem.setAttribute(key, attr[key]); 271 | } 272 | elem.removeAttribute('text'); 273 | 274 | if(iframeDOM.selection){ //IE 275 | var text = range.text || attr.text; 276 | if(tagName === 'a' && !text) return; 277 | if(text){ 278 | elem.innerHTML = text; 279 | } 280 | range.pasteHTML($(elem).prop('outerHTML')); 281 | range.select(); 282 | } else { //非IE 283 | var text = range.toString() || attr.text; 284 | if(tagName === 'a' && !text) return; 285 | if(text){ 286 | elem.innerHTML = text; 287 | } 288 | range.deleteContents(); 289 | range.insertNode(elem); 290 | } 291 | } 292 | 293 | //工具选中 294 | ,toolCheck = function(tools, othis){ 295 | var iframeDOM = this.document 296 | ,CHECK = 'layedit-tool-active' 297 | ,container = getContainer(Range(iframeDOM)) 298 | ,item = function(type){ 299 | return tools.find('.layedit-tool-'+type) 300 | } 301 | 302 | if(othis){ 303 | othis[othis.hasClass(CHECK) ? 'removeClass' : 'addClass'](CHECK); 304 | } 305 | 306 | tools.find('>i').removeClass(CHECK); 307 | item('unlink').addClass(ABLED); 308 | 309 | $(container).parents().each(function(){ 310 | var tagName = this.tagName.toLowerCase() 311 | ,textAlign = this.style.textAlign; 312 | 313 | //文字 314 | if(tagName === 'b' || tagName === 'strong'){ 315 | item('b').addClass(CHECK) 316 | } 317 | if(tagName === 'i' || tagName === 'em'){ 318 | item('i').addClass(CHECK) 319 | } 320 | if(tagName === 'u'){ 321 | item('u').addClass(CHECK) 322 | } 323 | if(tagName === 'strike'){ 324 | item('d').addClass(CHECK) 325 | } 326 | 327 | //对齐 328 | if(tagName === 'p'){ 329 | if(textAlign === 'center'){ 330 | item('center').addClass(CHECK); 331 | } else if(textAlign === 'right'){ 332 | item('right').addClass(CHECK); 333 | } else { 334 | item('left').addClass(CHECK); 335 | } 336 | } 337 | 338 | //超链接 339 | if(tagName === 'a'){ 340 | item('link').addClass(CHECK); 341 | item('unlink').removeClass(ABLED); 342 | } 343 | }); 344 | } 345 | 346 | //触发工具 347 | ,toolActive = function(iframeWin, editor, set){ 348 | var iframeDOM = iframeWin.document 349 | ,body = $(iframeDOM.body) 350 | ,toolEvent = { 351 | //超链接 352 | link: function(range){ 353 | var container = getContainer(range) 354 | ,parentNode = $(container).parent(); 355 | 356 | link.call(body, { 357 | href: parentNode.attr('href') 358 | ,target: parentNode.attr('target') 359 | }, function(field){ 360 | var parent = parentNode[0]; 361 | if(parent.tagName === 'A'){ 362 | parent.href = field.url; 363 | } else { 364 | insertInline.call(iframeWin, 'a', { 365 | target: field.target 366 | ,href: field.url 367 | ,text: field.url 368 | }, range); 369 | } 370 | }); 371 | } 372 | //清除超链接 373 | ,unlink: function(range){ 374 | iframeDOM.execCommand('unlink'); 375 | } 376 | //表情 377 | ,face: function(range){ 378 | face.call(this, function(img){ 379 | insertInline.call(iframeWin, 'img', { 380 | src: img.src 381 | ,alt: img.alt 382 | }, range); 383 | }); 384 | } 385 | //图片 386 | ,image: function(range){ 387 | var that = this; 388 | layui.use('upload', function(upload){ 389 | var uploadImage = set.uploadImage || {}; 390 | upload.render({ 391 | url: uploadImage.url 392 | ,method: uploadImage.type 393 | ,elem: $(that).find('input')[0] 394 | ,done: function(res){ 395 | if(res.code == 0){ 396 | res.data = res.data || {}; 397 | insertInline.call(iframeWin, 'img', { 398 | src: res.data.src 399 | ,alt: res.data.title 400 | }, range); 401 | } else { 402 | layer.msg(res.msg||'上传失败'); 403 | } 404 | } 405 | }); 406 | }); 407 | } 408 | //插入代码 409 | ,code: function(range){ 410 | code.call(body, function(pre){ 411 | insertInline.call(iframeWin, 'pre', { 412 | text: pre.code 413 | ,'lay-lang': pre.lang 414 | }, range); 415 | }); 416 | } 417 | //帮助 418 | ,help: function(){ 419 | layer.open({ 420 | type: 2 421 | ,title: '帮助' 422 | ,area: ['600px', '380px'] 423 | ,shadeClose: true 424 | ,shade: 0.1 425 | ,skin: 'layui-layer-msg' 426 | ,content: ['http://www.layui.com/about/layedit/help.html', 'no'] 427 | }); 428 | } 429 | } 430 | ,tools = editor.find('.layui-layedit-tool') 431 | 432 | ,click = function(){ 433 | var othis = $(this) 434 | ,events = othis.attr('layedit-event') 435 | ,command = othis.attr('lay-command'); 436 | 437 | if(othis.hasClass(ABLED)) return; 438 | 439 | body.focus(); 440 | 441 | var range = Range(iframeDOM) 442 | ,container = range.commonAncestorContainer 443 | 444 | if(command){ 445 | iframeDOM.execCommand(command); 446 | if(/justifyLeft|justifyCenter|justifyRight/.test(command)){ 447 | iframeDOM.execCommand('formatBlock', false, '

    '); 448 | } 449 | setTimeout(function(){ 450 | body.focus(); 451 | }, 10); 452 | } else { 453 | toolEvent[events] && toolEvent[events].call(this, range); 454 | } 455 | toolCheck.call(iframeWin, tools, othis); 456 | } 457 | 458 | ,isClick = /image/ 459 | 460 | tools.find('>i').on('mousedown', function(){ 461 | var othis = $(this) 462 | ,events = othis.attr('layedit-event'); 463 | if(isClick.test(events)) return; 464 | click.call(this) 465 | }).on('click', function(){ 466 | var othis = $(this) 467 | ,events = othis.attr('layedit-event'); 468 | if(!isClick.test(events)) return; 469 | click.call(this) 470 | }); 471 | 472 | //触发内容区域 473 | body.on('click', function(){ 474 | toolCheck.call(iframeWin, tools); 475 | layer.close(face.index); 476 | }); 477 | } 478 | 479 | //超链接面板 480 | ,link = function(options, callback){ 481 | var body = this, index = layer.open({ 482 | type: 1 483 | ,id: 'LAY_layedit_link' 484 | ,area: '350px' 485 | ,shade: 0.05 486 | ,shadeClose: true 487 | ,moveType: 1 488 | ,title: '超链接' 489 | ,skin: 'layui-layer-msg' 490 | ,content: ['

    '].join('') 511 | ,success: function(layero, index){ 512 | var eventFilter = 'submit(layedit-link-yes)'; 513 | form.render('radio'); 514 | layero.find('.layui-btn-primary').on('click', function(){ 515 | layer.close(index); 516 | body.focus(); 517 | }); 518 | form.on(eventFilter, function(data){ 519 | layer.close(link.index); 520 | callback && callback(data.field); 521 | }); 522 | } 523 | }); 524 | link.index = index; 525 | } 526 | 527 | //表情面板 528 | ,face = function(callback){ 529 | //表情库 530 | var faces = function(){ 531 | var alt = ["[微笑]", "[嘻嘻]", "[哈哈]", "[可爱]", "[可怜]", "[挖鼻]", "[吃惊]", "[害羞]", "[挤眼]", "[闭嘴]", "[鄙视]", "[爱你]", "[泪]", "[偷笑]", "[亲亲]", "[生病]", "[太开心]", "[白眼]", "[右哼哼]", "[左哼哼]", "[嘘]", "[衰]", "[委屈]", "[吐]", "[哈欠]", "[抱抱]", "[怒]", "[疑问]", "[馋嘴]", "[拜拜]", "[思考]", "[汗]", "[困]", "[睡]", "[钱]", "[失望]", "[酷]", "[色]", "[哼]", "[鼓掌]", "[晕]", "[悲伤]", "[抓狂]", "[黑线]", "[阴险]", "[怒骂]", "[互粉]", "[心]", "[伤心]", "[猪头]", "[熊猫]", "[兔子]", "[ok]", "[耶]", "[good]", "[NO]", "[赞]", "[来]", "[弱]", "[草泥马]", "[神马]", "[囧]", "[浮云]", "[给力]", "[围观]", "[威武]", "[奥特曼]", "[礼物]", "[钟]", "[话筒]", "[蜡烛]", "[蛋糕]"], arr = {}; 532 | layui.each(alt, function(index, item){ 533 | arr[item] = layui.cache.dir + 'images/face/'+ index + '.gif'; 534 | }); 535 | return arr; 536 | }(); 537 | face.hide = face.hide || function(e){ 538 | if($(e.target).attr('layedit-event') !== 'face'){ 539 | layer.close(face.index); 540 | } 541 | } 542 | return face.index = layer.tips(function(){ 543 | var content = []; 544 | layui.each(faces, function(key, item){ 545 | content.push('
  • '+ key +'
  • '); 546 | }); 547 | return ''; 548 | }(), this, { 549 | tips: 1 550 | ,time: 0 551 | ,skin: 'layui-box layui-util-face' 552 | ,maxWidth: 500 553 | ,success: function(layero, index){ 554 | layero.css({ 555 | marginTop: -4 556 | ,marginLeft: -10 557 | }).find('.layui-clear>li').on('click', function(){ 558 | callback && callback({ 559 | src: faces[this.title] 560 | ,alt: this.title 561 | }); 562 | layer.close(index); 563 | }); 564 | $(document).off('click', face.hide).on('click', face.hide); 565 | } 566 | }); 567 | } 568 | 569 | //插入代码面板 570 | ,code = function(callback){ 571 | var body = this, index = layer.open({ 572 | type: 1 573 | ,id: 'LAY_layedit_code' 574 | ,area: '550px' 575 | ,shade: 0.05 576 | ,shadeClose: true 577 | ,moveType: 1 578 | ,title: '插入代码' 579 | ,skin: 'layui-layer-msg' 580 | ,content: [''].join('') 608 | ,success: function(layero, index){ 609 | var eventFilter = 'submit(layedit-code-yes)'; 610 | form.render('select'); 611 | layero.find('.layui-btn-primary').on('click', function(){ 612 | layer.close(index); 613 | body.focus(); 614 | }); 615 | form.on(eventFilter, function(data){ 616 | layer.close(code.index); 617 | callback && callback(data.field); 618 | }); 619 | } 620 | }); 621 | code.index = index; 622 | } 623 | 624 | //全部工具 625 | ,tools = { 626 | html: '' 627 | ,strong: '' 628 | ,italic: '' 629 | ,underline: '' 630 | ,del: '' 631 | 632 | ,'|': '' 633 | 634 | ,left: '' 635 | ,center: '' 636 | ,right: '' 637 | ,link: '' 638 | ,unlink: '' 639 | ,face: '' 640 | ,image: '' 641 | ,code: '' 642 | 643 | ,help: '' 644 | } 645 | 646 | ,edit = new Edit(); 647 | 648 | exports(MOD_NAME, edit); 649 | }); 650 | -------------------------------------------------------------------------------- /layui/lay/modules/laypage.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name : layui.laypage 分页组件 4 | @Author:贤心 5 | @License:MIT 6 | 7 | */ 8 | 9 | layui.define(function(exports){ 10 | "use strict"; 11 | 12 | var doc = document 13 | ,id = 'getElementById' 14 | ,tag = 'getElementsByTagName' 15 | 16 | //字符常量 17 | ,MOD_NAME = 'laypage', DISABLED = 'layui-disabled' 18 | 19 | //构造器 20 | ,Class = function(options){ 21 | var that = this; 22 | that.config = options || {}; 23 | that.config.index = ++laypage.index; 24 | that.render(true); 25 | }; 26 | 27 | //判断传入的容器类型 28 | Class.prototype.type = function(){ 29 | var config = this.config; 30 | if(typeof config.elem === 'object'){ 31 | return config.elem.length === undefined ? 2 : 3; 32 | } 33 | }; 34 | 35 | //分页视图 36 | Class.prototype.view = function(){ 37 | var that = this 38 | ,config = that.config 39 | ,groups = config.groups = 'groups' in config ? (config.groups|0) : 5; //连续页码个数 40 | 41 | //排版 42 | config.layout = typeof config.layout === 'object' 43 | ? config.layout 44 | : ['prev', 'page', 'next']; 45 | 46 | config.count = config.count|0; //数据总数 47 | config.curr = (config.curr|0) || 1; //当前页 48 | 49 | //每页条数的选择项 50 | config.limits = typeof config.limits === 'object' 51 | ? config.limits 52 | : [10, 20, 30, 40, 50]; 53 | config.limit = (config.limit|0) || 10; //默认条数 54 | 55 | //总页数 56 | config.pages = Math.ceil(config.count/config.limit) || 1; 57 | 58 | //当前页不能超过总页数 59 | if(config.curr > config.pages){ 60 | config.curr = config.pages; 61 | } 62 | 63 | //连续分页个数不能低于0且不能大于总页数 64 | if(groups < 0){ 65 | groups = 1; 66 | } else if (groups > config.pages){ 67 | groups = config.pages; 68 | } 69 | 70 | config.prev = 'prev' in config ? config.prev : '上一页'; //上一页文本 71 | config.next = 'next' in config ? config.next : '下一页'; //下一页文本 72 | 73 | //计算当前组 74 | var index = config.pages > groups 75 | ? Math.ceil( (config.curr + (groups > 1 ? 1 : 0)) / (groups > 0 ? groups : 1) ) 76 | : 1 77 | 78 | //视图片段 79 | ,views = { 80 | //上一页 81 | prev: function(){ 82 | return config.prev 83 | ? ''+ config.prev +'' 84 | : ''; 85 | }() 86 | 87 | //页码 88 | ,page: function(){ 89 | var pager = []; 90 | 91 | //数据量为0时,不输出页码 92 | if(config.count < 1){ 93 | return ''; 94 | } 95 | 96 | //首页 97 | if(index > 1 && config.first !== false && groups !== 0){ 98 | pager.push(''+ (config.first || 1) +''); 99 | } 100 | 101 | //计算当前页码组的起始页 102 | var halve = Math.floor((groups-1)/2) //页码数等分 103 | ,start = index > 1 ? config.curr - halve : 1 104 | ,end = index > 1 ? (function(){ 105 | var max = config.curr + (groups - halve - 1); 106 | return max > config.pages ? config.pages : max; 107 | }()) : groups; 108 | 109 | //防止最后一组出现“不规定”的连续页码数 110 | if(end - start < groups - 1){ 111 | start = end - groups + 1; 112 | } 113 | 114 | //输出左分割符 115 | if(config.first !== false && start > 2){ 116 | pager.push('') 117 | } 118 | 119 | //输出连续页码 120 | for(; start <= end; start++){ 121 | if(start === config.curr){ 122 | //当前页 123 | pager.push(''+ start +''); 124 | } else { 125 | pager.push(''+ start +''); 126 | } 127 | } 128 | 129 | //输出输出右分隔符 & 末页 130 | if(config.pages > groups && config.pages > end && config.last !== false){ 131 | if(end + 1 < config.pages){ 132 | pager.push(''); 133 | } 134 | if(groups !== 0){ 135 | pager.push(''+ (config.last || config.pages) +''); 136 | } 137 | } 138 | 139 | return pager.join(''); 140 | }() 141 | 142 | //下一页 143 | ,next: function(){ 144 | return config.next 145 | ? ''+ config.next +'' 146 | : ''; 147 | }() 148 | 149 | //数据总数 150 | ,count: '共 '+ config.count +' 条' 151 | 152 | //每页条数 153 | ,limit: function(){ 154 | var options = [''; 163 | }() 164 | 165 | //刷新当前页 166 | ,refresh: ['' 167 | ,'' 168 | ,''].join('') 169 | 170 | //跳页区域 171 | ,skip: function(){ 172 | return ['到第' 173 | ,'' 174 | ,'页' 175 | ,''].join(''); 176 | }() 177 | }; 178 | 179 | return ['
    ' 182 | ,function(){ 183 | var plate = []; 184 | layui.each(config.layout, function(index, item){ 185 | if(views[item]){ 186 | plate.push(views[item]) 187 | } 188 | }); 189 | return plate.join(''); 190 | }() 191 | ,'
    '].join(''); 192 | }; 193 | 194 | //跳页的回调 195 | Class.prototype.jump = function(elem, isskip){ 196 | if(!elem) return; 197 | var that = this 198 | ,config = that.config 199 | ,childs = elem.children 200 | ,btn = elem[tag]('button')[0] 201 | ,input = elem[tag]('input')[0] 202 | ,select = elem[tag]('select')[0] 203 | ,skip = function(){ 204 | var curr = input.value.replace(/\s|\D/g, '')|0; 205 | if(curr){ 206 | config.curr = curr; 207 | that.render(); 208 | } 209 | }; 210 | 211 | if(isskip) return skip(); 212 | 213 | //页码 214 | for(var i = 0, len = childs.length; i < len; i++){ 215 | if(childs[i].nodeName.toLowerCase() === 'a'){ 216 | laypage.on(childs[i], 'click', function(){ 217 | var curr = this.getAttribute('data-page')|0; 218 | if(curr < 1 || curr > config.pages) return; 219 | config.curr = curr; 220 | that.render(); 221 | }); 222 | } 223 | } 224 | 225 | //条数 226 | if(select){ 227 | laypage.on(select, 'change', function(){ 228 | var value = this.value; 229 | if(config.curr*value > config.count){ 230 | config.curr = Math.ceil(config.count/value); 231 | } 232 | config.limit = value; 233 | that.render(); 234 | }); 235 | } 236 | 237 | //确定 238 | if(btn){ 239 | laypage.on(btn, 'click', function(){ 240 | skip(); 241 | }); 242 | } 243 | }; 244 | 245 | //输入页数字控制 246 | Class.prototype.skip = function(elem){ 247 | if(!elem) return; 248 | var that = this, input = elem[tag]('input')[0]; 249 | if(!input) return; 250 | laypage.on(input, 'keyup', function(e){ 251 | var value = this.value 252 | ,keyCode = e.keyCode; 253 | if(/^(37|38|39|40)$/.test(keyCode)) return; 254 | if(/\D/.test(value)){ 255 | this.value = value.replace(/\D/, ''); 256 | } 257 | if(keyCode === 13){ 258 | that.jump(elem, true) 259 | } 260 | }); 261 | }; 262 | 263 | //渲染分页 264 | Class.prototype.render = function(load){ 265 | var that = this 266 | ,config = that.config 267 | ,type = that.type() 268 | ,view = that.view(); 269 | 270 | if(type === 2){ 271 | config.elem && (config.elem.innerHTML = view); 272 | } else if(type === 3){ 273 | config.elem.html(view); 274 | } else { 275 | if(doc[id](config.elem)){ 276 | doc[id](config.elem).innerHTML = view; 277 | } 278 | } 279 | 280 | config.jump && config.jump(config, load); 281 | 282 | var elem = doc[id]('layui-laypage-' + config.index); 283 | that.jump(elem); 284 | 285 | if(config.hash && !load){ 286 | location.hash = '!'+ config.hash +'='+ config.curr; 287 | } 288 | 289 | that.skip(elem); 290 | }; 291 | 292 | //外部接口 293 | var laypage = { 294 | //分页渲染 295 | render: function(options){ 296 | var o = new Class(options); 297 | return o.index; 298 | } 299 | ,index: layui.laypage ? (layui.laypage.index + 10000) : 0 300 | ,on: function(elem, even, fn){ 301 | elem.attachEvent ? elem.attachEvent('on'+ even, function(e){ //for ie 302 | e.target = e.srcElement; 303 | fn.call(elem, e); 304 | }) : elem.addEventListener(even, fn, false); 305 | return this; 306 | } 307 | } 308 | 309 | exports(MOD_NAME, laypage); 310 | }); -------------------------------------------------------------------------------- /layui/lay/modules/laytpl.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name : layui.laytpl 模板引擎 4 | @Author:贤心 5 | @License:MIT 6 | 7 | */ 8 | 9 | layui.define(function(exports){ 10 | 11 | "use strict"; 12 | 13 | var config = { 14 | open: '{{', 15 | close: '}}' 16 | }; 17 | 18 | var tool = { 19 | exp: function(str){ 20 | return new RegExp(str, 'g'); 21 | }, 22 | //匹配满足规则内容 23 | query: function(type, _, __){ 24 | var types = [ 25 | '#([\\s\\S])+?', //js语句 26 | '([^{#}])*?' //普通字段 27 | ][type || 0]; 28 | return exp((_||'') + config.open + types + config.close + (__||'')); 29 | }, 30 | escape: function(html){ 31 | return String(html||'').replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&') 32 | .replace(//g, '>').replace(/'/g, ''').replace(/"/g, '"'); 33 | }, 34 | error: function(e, tplog){ 35 | var error = 'Laytpl Error:'; 36 | typeof console === 'object' && console.error(error + e + '\n'+ (tplog || '')); 37 | return error + e; 38 | } 39 | }; 40 | 41 | var exp = tool.exp, Tpl = function(tpl){ 42 | this.tpl = tpl; 43 | }; 44 | 45 | Tpl.pt = Tpl.prototype; 46 | 47 | window.errors = 0; 48 | 49 | //编译模版 50 | Tpl.pt.parse = function(tpl, data){ 51 | var that = this, tplog = tpl; 52 | var jss = exp('^'+config.open+'#', ''), jsse = exp(config.close+'$', ''); 53 | 54 | tpl = tpl.replace(/\s+|\r|\t|\n/g, ' ') 55 | .replace(exp(config.open+'#'), config.open+'# ') 56 | .replace(exp(config.close+'}'), '} '+config.close).replace(/\\/g, '\\\\') 57 | 58 | //不匹配指定区域的内容 59 | .replace(exp(config.open + '!(.+?)!' + config.close), function(str){ 60 | str = str.replace(exp('^'+ config.open + '!'), '') 61 | .replace(exp('!'+ config.close), '') 62 | .replace(exp(config.open + '|' + config.close), function(tag){ 63 | return tag.replace(/(.)/g, '\\$1') 64 | }); 65 | return str 66 | }) 67 | 68 | //匹配JS规则内容 69 | .replace(/(?="|')/g, '\\').replace(tool.query(), function(str){ 70 | str = str.replace(jss, '').replace(jsse, ''); 71 | return '";' + str.replace(/\\/g, '') + ';view+="'; 72 | }) 73 | 74 | //匹配普通字段 75 | .replace(tool.query(1), function(str){ 76 | var start = '"+('; 77 | if(str.replace(/\s/g, '') === config.open+config.close){ 78 | return ''; 79 | } 80 | str = str.replace(exp(config.open+'|'+config.close), ''); 81 | if(/^=/.test(str)){ 82 | str = str.replace(/^=/, ''); 83 | start = '"+_escape_('; 84 | } 85 | return start + str.replace(/\\/g, '') + ')+"'; 86 | }); 87 | 88 | tpl = '"use strict";var view = "' + tpl + '";return view;'; 89 | 90 | try{ 91 | that.cache = tpl = new Function('d, _escape_', tpl); 92 | return tpl(data, tool.escape); 93 | } catch(e){ 94 | delete that.cache; 95 | return tool.error(e, tplog); 96 | } 97 | }; 98 | 99 | Tpl.pt.render = function(data, callback){ 100 | var that = this, tpl; 101 | if(!data) return tool.error('no data'); 102 | tpl = that.cache ? that.cache(data, tool.escape) : that.parse(that.tpl, data); 103 | if(!callback) return tpl; 104 | callback(tpl); 105 | }; 106 | 107 | var laytpl = function(tpl){ 108 | if(typeof tpl !== 'string') return tool.error('Template not found'); 109 | return new Tpl(tpl); 110 | }; 111 | 112 | laytpl.config = function(options){ 113 | options = options || {}; 114 | for(var i in options){ 115 | config[i] = options[i]; 116 | } 117 | }; 118 | 119 | laytpl.v = '1.2.0'; 120 | 121 | exports('laytpl', laytpl); 122 | 123 | }); -------------------------------------------------------------------------------- /layui/lay/modules/mobile.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name:layui 移动模块入口 | 构建后则为移动模块集合 4 | @Author:贤心 5 | @License:MIT 6 | 7 | */ 8 | 9 | 10 | if(!layui['layui.mobile']){ 11 | layui.config({ 12 | base: layui.cache.dir + 'lay/modules/mobile/' 13 | }).extend({ 14 | 'layer-mobile': 'layer-mobile' 15 | ,'zepto': 'zepto' 16 | ,'upload-mobile': 'upload-mobile' 17 | ,'layim-mobile': 'layim-mobile' 18 | }); 19 | } 20 | 21 | layui.define([ 22 | 'layer-mobile' 23 | ,'zepto' 24 | ,'layim-mobile' 25 | ], function(exports){ 26 | exports('mobile', { 27 | layer: layui['layer-mobile'] //弹层 28 | ,layim: layui['layim-mobile'] //WebIM 29 | }); 30 | }); -------------------------------------------------------------------------------- /layui/lay/modules/mobile/layer-mobile.js: -------------------------------------------------------------------------------- 1 | /*! 2 | 3 | @Name:layer mobile v2.0.0 弹层组件移动版 4 | @Author:贤心 5 | @Site:http://layer.layui.com/mobie/ 6 | @License:MIT 7 | 8 | */ 9 | 10 | layui.define(function(exports){ 11 | 12 | "use strict"; 13 | 14 | var win = window, doc = document, query = 'querySelectorAll', claname = 'getElementsByClassName', S = function(s){ 15 | return doc[query](s); 16 | }; 17 | 18 | //默认配置 19 | var config = { 20 | type: 0 21 | ,shade: true 22 | ,shadeClose: true 23 | ,fixed: true 24 | ,anim: 'scale' //默认动画类型 25 | }; 26 | 27 | var ready = { 28 | extend: function(obj){ 29 | var newobj = JSON.parse(JSON.stringify(config)); 30 | for(var i in obj){ 31 | newobj[i] = obj[i]; 32 | } 33 | return newobj; 34 | }, 35 | timer: {}, end: {} 36 | }; 37 | 38 | //点触事件 39 | ready.touch = function(elem, fn){ 40 | elem.addEventListener('click', function(e){ 41 | fn.call(this, e); 42 | }, false); 43 | }; 44 | 45 | var index = 0, classs = ['layui-m-layer'], Layer = function(options){ 46 | var that = this; 47 | that.config = ready.extend(options); 48 | that.view(); 49 | }; 50 | 51 | Layer.prototype.view = function(){ 52 | var that = this, config = that.config, layerbox = doc.createElement('div'); 53 | 54 | that.id = layerbox.id = classs[0] + index; 55 | layerbox.setAttribute('class', classs[0] + ' ' + classs[0]+(config.type || 0)); 56 | layerbox.setAttribute('index', index); 57 | 58 | //标题区域 59 | var title = (function(){ 60 | var titype = typeof config.title === 'object'; 61 | return config.title 62 | ? '

    '+ (titype ? config.title[0] : config.title) +'

    ' 63 | : ''; 64 | }()); 65 | 66 | //按钮区域 67 | var button = (function(){ 68 | typeof config.btn === 'string' && (config.btn = [config.btn]); 69 | var btns = (config.btn || []).length, btndom; 70 | if(btns === 0 || !config.btn){ 71 | return ''; 72 | } 73 | btndom = ''+ config.btn[0] +'' 74 | if(btns === 2){ 75 | btndom = ''+ config.btn[1] +'' + btndom; 76 | } 77 | return '
    '+ btndom + '
    '; 78 | }()); 79 | 80 | if(!config.fixed){ 81 | config.top = config.hasOwnProperty('top') ? config.top : 100; 82 | config.style = config.style || ''; 83 | config.style += ' top:'+ ( doc.body.scrollTop + config.top) + 'px'; 84 | } 85 | 86 | if(config.type === 2){ 87 | config.content = '

    '+ (config.content||'') +'

    '; 88 | } 89 | 90 | if(config.skin) config.anim = 'up'; 91 | if(config.skin === 'msg') config.shade = false; 92 | 93 | layerbox.innerHTML = (config.shade ? '
    ' : '') 94 | +'
    ' 95 | +'
    ' 96 | +'
    ' 97 | + title 98 | +'
    '+ config.content +'
    ' 99 | + button 100 | +'
    ' 101 | +'
    ' 102 | +'
    '; 103 | 104 | if(!config.type || config.type === 2){ 105 | var dialogs = doc[claname](classs[0] + config.type), dialen = dialogs.length; 106 | if(dialen >= 1){ 107 | layer.close(dialogs[0].getAttribute('index')) 108 | } 109 | } 110 | 111 | document.body.appendChild(layerbox); 112 | var elem = that.elem = S('#'+that.id)[0]; 113 | config.success && config.success(elem); 114 | 115 | that.index = index++; 116 | that.action(config, elem); 117 | }; 118 | 119 | Layer.prototype.action = function(config, elem){ 120 | var that = this; 121 | 122 | //自动关闭 123 | if(config.time){ 124 | ready.timer[that.index] = setTimeout(function(){ 125 | layer.close(that.index); 126 | }, config.time*1000); 127 | } 128 | 129 | //确认取消 130 | var btn = function(){ 131 | var type = this.getAttribute('type'); 132 | if(type == 0){ 133 | config.no && config.no(); 134 | layer.close(that.index); 135 | } else { 136 | config.yes ? config.yes(that.index) : layer.close(that.index); 137 | } 138 | }; 139 | if(config.btn){ 140 | var btns = elem[claname]('layui-m-layerbtn')[0].children, btnlen = btns.length; 141 | for(var ii = 0; ii < btnlen; ii++){ 142 | ready.touch(btns[ii], btn); 143 | } 144 | } 145 | 146 | //点遮罩关闭 147 | if(config.shade && config.shadeClose){ 148 | var shade = elem[claname]('layui-m-layershade')[0]; 149 | ready.touch(shade, function(){ 150 | layer.close(that.index, config.end); 151 | }); 152 | } 153 | 154 | config.end && (ready.end[that.index] = config.end); 155 | }; 156 | 157 | var layer = { 158 | v: '2.0 m', 159 | index: index, 160 | 161 | //核心方法 162 | open: function(options){ 163 | var o = new Layer(options || {}); 164 | return o.index; 165 | }, 166 | 167 | close: function(index){ 168 | var ibox = S('#'+classs[0]+index)[0]; 169 | if(!ibox) return; 170 | ibox.innerHTML = ''; 171 | doc.body.removeChild(ibox); 172 | clearTimeout(ready.timer[index]); 173 | delete ready.timer[index]; 174 | typeof ready.end[index] === 'function' && ready.end[index](); 175 | delete ready.end[index]; 176 | }, 177 | 178 | //关闭所有layer层 179 | closeAll: function(){ 180 | var boxs = doc[claname](classs[0]); 181 | for(var i = 0, len = boxs.length; i < len; i++){ 182 | layer.close((boxs[0].getAttribute('index')|0)); 183 | } 184 | } 185 | }; 186 | 187 | exports('layer-mobile', layer); 188 | 189 | }); -------------------------------------------------------------------------------- /layui/lay/modules/mobile/layim-mobile-open.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name:layim mobile 开源包 4 | @Author:贤心 5 | @License:MIT 6 | 7 | */ 8 | 9 | layui.define(function(exports){ 10 | exports('layim-mobile', layui.v); 11 | }); -------------------------------------------------------------------------------- /layui/lay/modules/mobile/upload-mobile.js: -------------------------------------------------------------------------------- 1 | /*! 2 | 3 | @Title: layui.upload 单文件上传 - 全浏览器兼容版 4 | @Author: 贤心 5 | @License:MIT 6 | 7 | */ 8 | 9 | layui.define(['layer-mobile', 'zepto'] , function(exports){ 10 | "use strict"; 11 | 12 | var $ = layui.zepto; 13 | var layer = layui['layer-mobile']; 14 | var device = layui.device(); 15 | 16 | var elemDragEnter = 'layui-upload-enter'; 17 | var elemIframe = 'layui-upload-iframe'; 18 | 19 | var msgConf = { 20 | icon: 2 21 | ,shift: 6 22 | }, fileType = { 23 | file: '文件' 24 | ,video: '视频' 25 | ,audio: '音频' 26 | }; 27 | 28 | layer.msg = function(content){ 29 | return layer.open({ 30 | content: content || '' 31 | ,skin: 'msg' 32 | ,time: 2 //2秒后自动关闭 33 | }); 34 | }; 35 | 36 | var Upload = function(options){ 37 | this.options = options; 38 | }; 39 | 40 | //初始化渲染 41 | Upload.prototype.init = function(){ 42 | var that = this, options = that.options; 43 | var body = $('body'), elem = $(options.elem || '.layui-upload-file'); 44 | var iframe = $(''); 45 | 46 | //插入iframe 47 | $('#'+elemIframe)[0] || body.append(iframe); 48 | 49 | return elem.each(function(index, item){ 50 | item = $(item); 51 | var form = '
    '; 52 | 53 | var type = item.attr('lay-type') || options.type; //获取文件类型 54 | 55 | //包裹ui元素 56 | if(!options.unwrap){ 57 | form = '
    ' + form + ''+ ( 58 | item.attr('lay-title') || options.title|| ('上传'+ (fileType[type]||'图片') ) 59 | ) +'
    '; 60 | } 61 | 62 | form = $(form); 63 | 64 | //拖拽支持 65 | if(!options.unwrap){ 66 | form.on('dragover', function(e){ 67 | e.preventDefault(); 68 | $(this).addClass(elemDragEnter); 69 | }).on('dragleave', function(){ 70 | $(this).removeClass(elemDragEnter); 71 | }).on('drop', function(){ 72 | $(this).removeClass(elemDragEnter); 73 | }); 74 | } 75 | 76 | //如果已经实例化,则移除包裹元素 77 | if(item.parent('form').attr('target') === elemIframe){ 78 | if(options.unwrap){ 79 | item.unwrap(); 80 | } else { 81 | item.parent().next().remove(); 82 | item.unwrap().unwrap(); 83 | } 84 | }; 85 | 86 | //包裹元素 87 | item.wrap(form); 88 | 89 | //触发上传 90 | item.off('change').on('change', function(){ 91 | that.action(this, type); 92 | }); 93 | }); 94 | }; 95 | 96 | //提交上传 97 | Upload.prototype.action = function(input, type){ 98 | var that = this, options = that.options, val = input.value; 99 | var item = $(input), ext = item.attr('lay-ext') || options.ext || ''; //获取支持上传的文件扩展名; 100 | 101 | if(!val){ 102 | return; 103 | }; 104 | 105 | //校验文件 106 | switch(type){ 107 | case 'file': //一般文件 108 | if(ext && !RegExp('\\w\\.('+ ext +')$', 'i').test(escape(val))){ 109 | layer.msg('不支持该文件格式', msgConf); 110 | return input.value = ''; 111 | } 112 | break; 113 | case 'video': //视频文件 114 | if(!RegExp('\\w\\.('+ (ext||'avi|mp4|wma|rmvb|rm|flash|3gp|flv') +')$', 'i').test(escape(val))){ 115 | layer.msg('不支持该视频格式', msgConf); 116 | return input.value = ''; 117 | } 118 | break; 119 | case 'audio': //音频文件 120 | if(!RegExp('\\w\\.('+ (ext||'mp3|wav|mid') +')$', 'i').test(escape(val))){ 121 | layer.msg('不支持该音频格式', msgConf); 122 | return input.value = ''; 123 | } 124 | break; 125 | default: //图片文件 126 | if(!RegExp('\\w\\.('+ (ext||'jpg|png|gif|bmp|jpeg') +')$', 'i').test(escape(val))){ 127 | layer.msg('不支持该图片格式', msgConf); 128 | return input.value = ''; 129 | } 130 | break; 131 | } 132 | 133 | options.before && options.before(input); 134 | item.parent().submit(); 135 | 136 | var iframe = $('#'+elemIframe), timer = setInterval(function() { 137 | var res; 138 | try { 139 | res = iframe.contents().find('body').text(); 140 | } catch(e) { 141 | layer.msg('上传接口存在跨域', msgConf); 142 | clearInterval(timer); 143 | } 144 | if(res){ 145 | clearInterval(timer); 146 | iframe.contents().find('body').html(''); 147 | try { 148 | res = JSON.parse(res); 149 | } catch(e){ 150 | res = {}; 151 | return layer.msg('请对上传接口返回JSON字符', msgConf); 152 | } 153 | typeof options.success === 'function' && options.success(res, input); 154 | } 155 | }, 30); 156 | 157 | input.value = ''; 158 | }; 159 | 160 | //暴露接口 161 | exports('upload-mobile', function(options){ 162 | var upload = new Upload(options = options || {}); 163 | upload.init(); 164 | }); 165 | }); 166 | 167 | -------------------------------------------------------------------------------- /layui/lay/modules/rate.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Title: layui.rate 评分评星 4 | @Author: star1029 5 | @License:MIT 6 | 7 | */ 8 | 9 | layui.define('jquery',function(exports){ 10 | "use strict"; 11 | var $ = layui.jquery 12 | 13 | //外部接口 14 | ,rate = { 15 | config: {} 16 | ,index: layui.rate ? (layui.rate.index + 10000) : 0 17 | 18 | //设置全局项 19 | ,set: function(options){ 20 | var that = this; 21 | that.config = $.extend({}, that.config, options); 22 | return that; 23 | } 24 | 25 | //事件监听 26 | ,on: function(events, callback){ 27 | return layui.onevent.call(this, MOD_NAME, events, callback); 28 | } 29 | } 30 | 31 | //操作当前实例 32 | ,thisRate = function(){ 33 | var that = this 34 | ,options = that.config; 35 | 36 | return { 37 | setvalue: function(value){ 38 | that.setvalue.call(that, value); 39 | } 40 | ,config: options 41 | } 42 | } 43 | 44 | //字符常量 45 | ,MOD_NAME = 'rate',ELEM_VIEW = 'layui-rate', ICON_RATE = 'layui-icon-rate', ICON_RATE_SOLID = 'layui-icon-rate-solid', ICON_RATE_HALF = 'layui-icon-rate-half' 46 | 47 | ,ICON_SOLID_HALF = 'layui-icon-rate-solid layui-icon-rate-half', ICON_SOLID_RATE = 'layui-icon-rate-solid layui-icon-rate', ICON_HALF_RATE = 'layui-icon-rate layui-icon-rate-half' 48 | 49 | //构造器 50 | ,Class = function(options){ 51 | var that = this; 52 | that.index = ++rate.index; 53 | that.config = $.extend({}, that.config, rate.config, options); 54 | that.render(); 55 | }; 56 | 57 | //默认配置 58 | Class.prototype.config = { 59 | length: 5 //初始长度 60 | ,text: false //是否显示评分等级 61 | ,readonly: false //是否只读 62 | ,half: false //是否可以半星 63 | ,value: 0 //星星选中个数 64 | ,theme: '' 65 | }; 66 | 67 | //评分渲染 68 | Class.prototype.render = function(){ 69 | var that = this 70 | ,options = that.config 71 | ,style = options.theme ? ('style="color: '+ options.theme + ';"') : ''; 72 | 73 | options.elem = $(options.elem); 74 | 75 | //如果没有选择半星的属性,却给了小数的数值,统一向上或向下取整 76 | if(parseInt(options.value) !== options.value){ 77 | if(!options.half){ 78 | options.value = (Math.ceil(options.value) - options.value) < 0.5 ? Math.ceil(options.value): Math.floor(options.value) 79 | } 80 | } 81 | 82 | //组件模板 83 | var temp = '' + (options.text ? (''+ options.value + '星') : '') + ''; 104 | 105 | //开始插入替代元素 106 | var othis = options.elem 107 | ,hasRender = othis.next('.' + ELEM_VIEW); 108 | 109 | //生成替代元素 110 | hasRender[0] && hasRender.remove(); //如果已经渲染,则Rerender 111 | 112 | that.elemTemp = $(temp); 113 | 114 | options.span = that.elemTemp.next('span'); 115 | 116 | options.setText && options.setText(options.value); 117 | 118 | othis.html(that.elemTemp); 119 | 120 | othis.addClass("layui-inline"); 121 | 122 | //如果不是只读,那么进行触控事件 123 | if(!options.readonly) that.action(); 124 | 125 | }; 126 | 127 | //评分重置 128 | Class.prototype.setvalue = function(value){ 129 | var that = this 130 | ,options = that.config ; 131 | 132 | options.value = value ; 133 | that.render(); 134 | }; 135 | 136 | //li触控事件 137 | Class.prototype.action = function(){ 138 | var that = this 139 | ,options = that.config 140 | ,_ul = that.elemTemp 141 | ,wide = _ul.find("i").width(); 142 | 143 | _ul.children("li").each(function(index){ 144 | var ind = index + 1 145 | ,othis = $(this); 146 | 147 | //点击 148 | othis.on('click', function(e){ 149 | //将当前点击li的索引值赋给value 150 | options.value = ind; 151 | if(options.half){ 152 | //获取鼠标在li上的位置 153 | var x = e.pageX - $(this).offset().left; 154 | if(x <= wide / 2){ 155 | options.value = options.value - 0.5; 156 | } 157 | } 158 | 159 | if(options.text) _ul.next("span").text(options.value + "星"); 160 | 161 | options.choose && options.choose(options.value); 162 | options.setText && options.setText(options.value); 163 | }); 164 | 165 | //移入 166 | othis.on('mousemove', function(e){ 167 | _ul.find("i").each(function(){ 168 | $(this).addClass(ICON_RATE).removeClass(ICON_SOLID_HALF) 169 | }); 170 | _ul.find("i:lt(" + ind + ")").each(function(){ 171 | $(this).addClass(ICON_RATE_SOLID).removeClass(ICON_HALF_RATE) 172 | }); 173 | // 如果设置可选半星,那么判断鼠标相对li的位置 174 | if(options.half){ 175 | var x = e.pageX - $(this).offset().left; 176 | if(x <= wide / 2){ 177 | othis.children("i").addClass(ICON_RATE_HALF).removeClass(ICON_RATE_SOLID) 178 | } 179 | } 180 | }) 181 | 182 | //移出 183 | othis.on('mouseleave', function(){ 184 | _ul.find("i").each(function(){ 185 | $(this).addClass(ICON_RATE).removeClass(ICON_SOLID_HALF) 186 | }); 187 | _ul.find("i:lt(" + Math.floor(options.value) + ")").each(function(){ 188 | $(this).addClass(ICON_RATE_SOLID).removeClass(ICON_HALF_RATE) 189 | }); 190 | //如果设置可选半星,根据分数判断是否有半星 191 | if(options.half){ 192 | if(parseInt(options.value) !== options.value){ 193 | _ul.children("li:eq(" + Math.floor(options.value) + ")").children("i").addClass(ICON_RATE_HALF).removeClass(ICON_SOLID_RATE) 194 | } 195 | } 196 | }) 197 | 198 | }) 199 | }; 200 | 201 | //事件处理 202 | Class.prototype.events = function(){ 203 | var that = this 204 | ,options = that.config; 205 | }; 206 | 207 | //核心入口 208 | rate.render = function(options){ 209 | var inst = new Class(options); 210 | return thisRate.call(inst); 211 | }; 212 | 213 | exports(MOD_NAME, rate); 214 | }) -------------------------------------------------------------------------------- /layui/lay/modules/slider.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Title: layui.slider 滑块 4 | @Author: star1029 5 | @License:MIT 6 | 7 | */ 8 | 9 | layui.define('jquery', function(exports){ 10 | "use strict"; 11 | var $ = layui.jquery 12 | 13 | //外部接口 14 | ,slider = { 15 | config: {} 16 | ,index: layui.slider ? (layui.slider.index + 10000) : 0 17 | 18 | //设置全局项 19 | ,set: function(options){ 20 | var that = this; 21 | that.config = $.extend({}, that.config, options); 22 | return that; 23 | } 24 | 25 | //事件监听 26 | ,on: function(events, callback){ 27 | return layui.onevent.call(this, MOD_NAME, events, callback); 28 | } 29 | } 30 | 31 | //操作当前实例 32 | ,thisSlider = function(){ 33 | var that = this 34 | ,options = that.config; 35 | 36 | return { 37 | setValue: function(value, index){ //设置值 38 | return that.slide('set', value, index || 0); 39 | } 40 | ,config: options 41 | } 42 | } 43 | 44 | //字符常量 45 | ,MOD_NAME = 'slider', DISABLED = 'layui-disabled', ELEM_VIEW = 'layui-slider', SLIDER_BAR = 'layui-slider-bar', SLIDER_WRAP = 'layui-slider-wrap', SLIDER_WRAP_BTN = 'layui-slider-wrap-btn', SLIDER_TIPS = 'layui-slider-tips', SLIDER_INPUT = 'layui-slider-input', SLIDER_INPUT_TXT = 'layui-slider-input-txt', SLIDER_INPUT_BTN = 'layui-slider-input-btn', ELEM_HOVER = 'layui-slider-hover' 46 | 47 | //构造器 48 | ,Class = function(options){ 49 | var that = this; 50 | that.index = ++slider.index; 51 | that.config = $.extend({}, that.config, slider.config, options); 52 | that.render(); 53 | }; 54 | 55 | //默认配置 56 | Class.prototype.config = { 57 | type: 'default' //滑块类型,垂直:vertical 58 | ,min: 0 //最小值 59 | ,max: 100 //最大值,默认100 60 | ,value: 0 //初始值,默认为0 61 | ,step: 1 //间隔值 62 | ,showstep: false //间隔点开启 63 | ,tips: true //文字提示,开启 64 | ,input: false //输入框,关闭 65 | ,range: false //范围选择,与输入框不能同时开启,默认关闭 66 | ,height: 200 //配合 type:"vertical" 使用,默认200px 67 | ,disabled: false //滑块禁用,默认关闭 68 | ,theme: '#009688' //主题颜色 69 | }; 70 | 71 | //滑块渲染 72 | Class.prototype.render = function(){ 73 | var that = this 74 | ,options = that.config; 75 | 76 | //间隔值不能小于 1 77 | if(options.step < 1) options.step = 1; 78 | 79 | //最大值不能小于最小值 80 | if(options.max < options.min) options.max = options.min + options.step; 81 | 82 | 83 | 84 | //判断是否开启双滑块 85 | if(options.range){ 86 | options.value = typeof(options.value) == 'object' ? options.value : [options.min, options.value]; 87 | var minValue = Math.min(options.value[0], options.value[1]) 88 | ,maxValue = Math.max(options.value[0], options.value[1]); 89 | options.value[0] = minValue > options.min ? minValue : options.min; 90 | options.value[1] = maxValue > options.min ? maxValue : options.min; 91 | options.value[0] = options.value[0] > options.max ? options.max : options.value[0]; 92 | options.value[1] = options.value[1] > options.max ? options.max : options.value[1]; 93 | 94 | var scaleFir = Math.floor((options.value[0] - options.min) / (options.max - options.min) * 100) 95 | ,scaleSec = Math.floor((options.value[1] - options.min) / (options.max - options.min) * 100) 96 | ,scale = scaleSec - scaleFir + '%'; 97 | scaleFir = scaleFir + '%'; 98 | scaleSec = scaleSec + '%'; 99 | } else { 100 | //如果初始值是一个数组,则获取数组的最小值 101 | if(typeof options.value == 'object'){ 102 | options.value = Math.min.apply(null, options.value); 103 | } 104 | 105 | //初始值不能小于最小值且不能大于最大值 106 | if(options.value < options.min) options.value = options.min; 107 | if(options.value > options.max) options.value = options.max; 108 | 109 | var scale = Math.floor((options.value - options.min) / (options.max - options.min) * 100) + '%'; 110 | }; 111 | 112 | 113 | //如果禁用,颜色为统一的灰色 114 | var theme = options.disabled ? '#c2c2c2' : options.theme; 115 | 116 | //滑块 117 | var temp = '
    '+ (options.tips ? '
    ' : '') + 118 | '
    ' + 119 | '
    '+ (options.range ? '
    ' : '') +'
    '; 120 | 121 | var othis = $(options.elem) 122 | ,hasRender = othis.next('.' + ELEM_VIEW); 123 | //生成替代元素 124 | hasRender[0] && hasRender.remove(); //如果已经渲染,则Rerender 125 | that.elemTemp = $(temp); 126 | 127 | //把数据缓存到滑块上 128 | if(options.range){ 129 | that.elemTemp.find('.' + SLIDER_WRAP).eq(0).data('value', options.value[0]); 130 | that.elemTemp.find('.' + SLIDER_WRAP).eq(1).data('value', options.value[1]); 131 | }else{ 132 | that.elemTemp.find('.' + SLIDER_WRAP).data('value', options.value); 133 | }; 134 | 135 | //插入替代元素 136 | othis.html(that.elemTemp); 137 | 138 | //垂直滑块 139 | if(options.type === 'vertical'){ 140 | that.elemTemp.height(options.height + 'px'); 141 | }; 142 | 143 | //显示间断点 144 | if(options.showstep){ 145 | var number = (options.max - options.min) / options.step, item = ''; 146 | for(var i = 1; i < number + 1; i++) { 147 | var step = i * 100 / number; 148 | if(step < 100){ 149 | item += '
    ' 150 | } 151 | }; 152 | that.elemTemp.append(item); 153 | }; 154 | 155 | //插入输入框 156 | if(options.input && !options.range){ 157 | var elemInput = $('
    '); 158 | othis.css("position","relative"); 159 | othis.append(elemInput); 160 | othis.find('.' + SLIDER_INPUT_TXT).children('input').val(options.value); 161 | if(options.type === 'vertical'){ 162 | elemInput.css({ 163 | left: 0 164 | ,top: -48 165 | }); 166 | } else { 167 | that.elemTemp.css("margin-right", elemInput.outerWidth() + 15); 168 | } 169 | }; 170 | 171 | //给未禁止的滑块滑动事件 172 | if(!options.disabled){ 173 | that.slide(); 174 | }else{ 175 | that.elemTemp.addClass(DISABLED); 176 | that.elemTemp.find('.' + SLIDER_WRAP_BTN).addClass(DISABLED); 177 | }; 178 | 179 | //划过滑块显示数值 180 | that.elemTemp.find('.' + SLIDER_WRAP_BTN).on('mouseover', function(){ 181 | var sliderWidth = options.type === 'vertical' ? options.height : that.elemTemp[0].offsetWidth 182 | ,sliderWrap = that.elemTemp.find('.' + SLIDER_WRAP) 183 | ,tipsLeft = options.type === 'vertical' ? (sliderWidth - $(this).parent()[0].offsetTop - sliderWrap.height()) : $(this).parent()[0].offsetLeft 184 | ,left = tipsLeft / sliderWidth * 100 185 | ,value = $(this).parent().data('value') 186 | ,tipsTxt = options.setTips ? options.setTips(value) : value; 187 | that.elemTemp.find('.' + SLIDER_TIPS).html(tipsTxt); 188 | if(options.type === 'vertical'){ 189 | that.elemTemp.find('.' + SLIDER_TIPS).css({"bottom":left + '%', "margin-bottom":"20px", "display":"inline-block"}); 190 | }else{ 191 | that.elemTemp.find('.' + SLIDER_TIPS).css({"left":left + '%', "display":"inline-block"}); 192 | }; 193 | }).on('mouseout', function(){ 194 | that.elemTemp.find('.' + SLIDER_TIPS).css("display", "none"); 195 | }); 196 | }; 197 | 198 | //滑块滑动 199 | Class.prototype.slide = function(setValue, value, i){ 200 | var that = this 201 | ,options = that.config 202 | ,sliderAct = that.elemTemp 203 | ,sliderWidth = function(){ 204 | return options.type === 'vertical' ? options.height : sliderAct[0].offsetWidth 205 | } 206 | ,sliderWrap = sliderAct.find('.' + SLIDER_WRAP) 207 | ,sliderTxt = sliderAct.next('.' + SLIDER_INPUT) 208 | ,inputValue = sliderTxt.children('.' + SLIDER_INPUT_TXT).children('input').val() 209 | ,step = 100 / ((options.max - options.min) / Math.ceil(options.step)) 210 | ,change = function(offsetValue, index){ 211 | if(Math.ceil(offsetValue) * step > 100){ 212 | offsetValue = Math.ceil(offsetValue) * step 213 | }else{ 214 | offsetValue = Math.round(offsetValue) * step 215 | }; 216 | offsetValue = offsetValue > 100 ? 100: offsetValue; 217 | sliderWrap.eq(index).css((options.type === 'vertical' ?'bottom':'left'), offsetValue + '%'); 218 | var firLeft = valueTo(sliderWrap[0].offsetLeft) 219 | ,secLeft = options.range ? valueTo(sliderWrap[1].offsetLeft) : 0; 220 | if(options.type === 'vertical'){ 221 | sliderAct.find('.' + SLIDER_TIPS).css({"bottom":offsetValue + '%', "margin-bottom":"20px"}); 222 | firLeft = valueTo(sliderWidth() - sliderWrap[0].offsetTop - sliderWrap.height()); 223 | secLeft = options.range ? valueTo(sliderWidth() - sliderWrap[1].offsetTop - sliderWrap.height()) : 0; 224 | }else{ 225 | sliderAct.find('.' + SLIDER_TIPS).css("left",offsetValue + '%'); 226 | }; 227 | firLeft = firLeft > 100 ? 100: firLeft; 228 | secLeft = secLeft > 100 ? 100: secLeft; 229 | var minLeft = Math.min(firLeft, secLeft) 230 | ,wrapWidth = Math.abs(firLeft - secLeft); 231 | if(options.type === 'vertical'){ 232 | sliderAct.find('.' + SLIDER_BAR).css({"height":wrapWidth + '%', "bottom":minLeft + '%'}); 233 | }else{ 234 | sliderAct.find('.' + SLIDER_BAR).css({"width":wrapWidth + '%', "left":minLeft + '%'}); 235 | }; 236 | var selfValue = options.min + Math.round((options.max - options.min) * offsetValue / 100); 237 | 238 | inputValue = selfValue; 239 | sliderTxt.children('.' + SLIDER_INPUT_TXT).children('input').val(inputValue); 240 | sliderWrap.eq(index).data('value', selfValue); 241 | selfValue = options.setTips ? options.setTips(selfValue) : selfValue; 242 | sliderAct.find('.' + SLIDER_TIPS).html(selfValue); 243 | 244 | //如果开启范围选择,则返回数组值 245 | if(options.range){ 246 | var arrValue = [ 247 | sliderWrap.eq(0).data('value') 248 | ,sliderWrap.eq(1).data('value') 249 | ]; 250 | if(arrValue[0] > arrValue[1]) arrValue.reverse(); //如果前面的圆点超过了后面的圆点值,则调换顺序 251 | } 252 | 253 | //回调 254 | options.change && options.change(options.range ? arrValue : selfValue); 255 | } 256 | ,valueTo = function(value){ 257 | var oldLeft = value / sliderWidth() * 100 / step 258 | ,left = Math.round(oldLeft) * step; 259 | if(value == sliderWidth()){ 260 | left = Math.ceil(oldLeft) * step; 261 | }; 262 | return left; 263 | } 264 | 265 | //拖拽元素 266 | ,elemMove = $(['
    sliderWidth())left = sliderWidth(); 298 | var reaLeft = left / sliderWidth() * 100 / step; 299 | change(reaLeft, index); 300 | othis.addClass(ELEM_HOVER); 301 | sliderAct.find('.' + SLIDER_TIPS).show(); 302 | e.preventDefault(); 303 | }; 304 | 305 | var up = function(){ 306 | othis.removeClass(ELEM_HOVER); 307 | sliderAct.find('.' + SLIDER_TIPS).hide(); 308 | }; 309 | 310 | createMoveElem(move, up) 311 | }); 312 | }); 313 | 314 | //点击滑块 315 | sliderAct.on('click', function(e){ 316 | var main = $('.' + SLIDER_WRAP_BTN); 317 | if(!main.is(event.target) && main.has(event.target).length === 0 && main.length){ 318 | var left = options.type === 'vertical' ? (sliderWidth() - e.clientY + $(this).offset().top):(e.clientX - $(this).offset().left), index; 319 | if(left < 0)left = 0; 320 | if(left > sliderWidth())left = sliderWidth(); 321 | var reaLeft = left / sliderWidth() * 100 / step; 322 | if(options.range){ 323 | if(options.type === 'vertical'){ 324 | index = Math.abs(left - parseInt($(sliderWrap[0]).css('bottom'))) > Math.abs(left - parseInt($(sliderWrap[1]).css('bottom'))) ? 1 : 0; 325 | }else{ 326 | index = Math.abs(left - sliderWrap[0].offsetLeft) > Math.abs(left - sliderWrap[1].offsetLeft) ? 1 : 0; 327 | } 328 | }else{ 329 | index = 0; 330 | }; 331 | change(reaLeft, index); 332 | e.preventDefault(); 333 | } 334 | }); 335 | 336 | //输入框移入事件 337 | sliderTxt.hover(function(){ 338 | var othis = $(this); 339 | othis.children('.' + SLIDER_INPUT_BTN).fadeIn('fast'); 340 | }, function(){ 341 | var othis = $(this); 342 | othis.children('.' + SLIDER_INPUT_BTN).fadeOut('fast'); 343 | }); 344 | 345 | //点击加减输入框 346 | sliderTxt.children('.' + SLIDER_INPUT_BTN).children('i').each(function(index){ 347 | $(this).on('click', function(){ 348 | if(index == 1){ 349 | inputValue = inputValue - options.step < options.min 350 | ? options.min 351 | : Number(inputValue) - options.step; 352 | }else{ 353 | inputValue = Number(inputValue) + options.step > options.max 354 | ? options.max 355 | : Number(inputValue) + options.step; 356 | }; 357 | var inputScale = (inputValue - options.min) / (options.max - options.min) * 100 / step; 358 | change(inputScale, 0); 359 | }); 360 | }); 361 | 362 | //获取输入框值 363 | var getInputValue = function(){ 364 | var realValue = this.value; 365 | realValue = isNaN(realValue) ? 0 : realValue; 366 | realValue = realValue < options.min ? options.min : realValue; 367 | realValue = realValue > options.max ? options.max : realValue; 368 | this.value = realValue; 369 | var inputScale = (realValue - options.min) / (options.max - options.min) * 100 / step; 370 | change(inputScale, 0); 371 | }; 372 | sliderTxt.children('.' + SLIDER_INPUT_TXT).children('input').on('keydown', function(e){ 373 | if(e.keyCode === 13){ 374 | e.preventDefault(); 375 | getInputValue.call(this); 376 | } 377 | }).on('change', getInputValue); 378 | }; 379 | 380 | //事件处理 381 | Class.prototype.events = function(){ 382 | var that = this 383 | ,options = that.config; 384 | }; 385 | 386 | //核心入口 387 | slider.render = function(options){ 388 | var inst = new Class(options); 389 | return thisSlider.call(inst); 390 | }; 391 | 392 | exports(MOD_NAME, slider); 393 | }) -------------------------------------------------------------------------------- /layui/lay/modules/tree.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name:layui.tree 树组件 4 | @Author:贤心 5 | @License:MIT 6 | 7 | */ 8 | 9 | 10 | layui.define('jquery', function(exports){ 11 | "use strict"; 12 | 13 | var $ = layui.$ 14 | ,hint = layui.hint(); 15 | 16 | var enterSkin = 'layui-tree-enter', Tree = function(options){ 17 | this.options = options; 18 | }; 19 | 20 | //图标 21 | var icon = { 22 | arrow: ['', ''] //箭头 23 | ,checkbox: ['', ''] //复选框 24 | ,radio: ['', ''] //单选框 25 | ,branch: ['', ''] //父节点 26 | ,leaf: '' //叶节点 27 | }; 28 | 29 | //初始化 30 | Tree.prototype.init = function(elem){ 31 | var that = this; 32 | elem.addClass('layui-box layui-tree'); //添加tree样式 33 | if(that.options.skin){ 34 | elem.addClass('layui-tree-skin-'+ that.options.skin); 35 | } 36 | that.tree(elem); 37 | that.on(elem); 38 | }; 39 | 40 | //树节点解析 41 | Tree.prototype.tree = function(elem, children){ 42 | var that = this, options = that.options 43 | var nodes = children || options.nodes; 44 | 45 | layui.each(nodes, function(index, item){ 46 | var hasChild = item.children && item.children.length > 0; 47 | var ul = $(''); 48 | var li = $(['
  • ' 49 | //展开箭头 50 | ,function(){ 51 | return hasChild ? ''+ ( 52 | item.spread ? icon.arrow[1] : icon.arrow[0] 53 | ) +'' : ''; 54 | }() 55 | 56 | //复选框/单选框 57 | ,function(){ 58 | return options.check ? ( 59 | ''+ ( 60 | options.check === 'checkbox' ? icon.checkbox[0] : ( 61 | options.check === 'radio' ? icon.radio[0] : '' 62 | ) 63 | ) +'' 64 | ) : ''; 65 | }() 66 | 67 | //节点 68 | ,function(){ 69 | return '' 72 | + (''+ ( 73 | hasChild ? ( 74 | item.spread ? icon.branch[1] : icon.branch[0] 75 | ) : icon.leaf 76 | ) +'') //节点图标 77 | + (''+ (item.name||'未命名') +''); 78 | }() 79 | 80 | ,'
  • '].join('')); 81 | 82 | //如果有子节点,则递归继续生成树 83 | if(hasChild){ 84 | li.append(ul); 85 | that.tree(ul, item.children); 86 | } 87 | 88 | elem.append(li); 89 | 90 | //触发点击节点回调 91 | typeof options.click === 'function' && that.click(li, item); 92 | 93 | //伸展节点 94 | that.spread(li, item); 95 | 96 | //拖拽节点 97 | options.drag && that.drag(li, item); 98 | }); 99 | }; 100 | 101 | //点击节点回调 102 | Tree.prototype.click = function(elem, item){ 103 | var that = this, options = that.options; 104 | elem.children('a').on('click', function(e){ 105 | layui.stope(e); 106 | options.click(item) 107 | }); 108 | }; 109 | 110 | //伸展节点 111 | Tree.prototype.spread = function(elem, item){ 112 | var that = this, options = that.options; 113 | var arrow = elem.children('.layui-tree-spread') 114 | var ul = elem.children('ul'), a = elem.children('a'); 115 | 116 | //执行伸展 117 | var open = function(){ 118 | if(elem.data('spread')){ 119 | elem.data('spread', null) 120 | ul.removeClass('layui-show'); 121 | arrow.html(icon.arrow[0]); 122 | a.find('.layui-icon').html(icon.branch[0]); 123 | } else { 124 | elem.data('spread', true); 125 | ul.addClass('layui-show'); 126 | arrow.html(icon.arrow[1]); 127 | a.find('.layui-icon').html(icon.branch[1]); 128 | } 129 | }; 130 | 131 | //如果没有子节点,则不执行 132 | if(!ul[0]) return; 133 | 134 | arrow.on('click', open); 135 | a.on('dblclick', open); 136 | } 137 | 138 | //通用事件 139 | Tree.prototype.on = function(elem){ 140 | var that = this, options = that.options; 141 | var dragStr = 'layui-tree-drag'; 142 | 143 | //屏蔽选中文字 144 | elem.find('i').on('selectstart', function(e){ 145 | return false 146 | }); 147 | 148 | //拖拽 149 | if(options.drag){ 150 | $(document).on('mousemove', function(e){ 151 | var move = that.move; 152 | if(move.from){ 153 | var to = move.to, treeMove = $('
    '); 154 | e.preventDefault(); 155 | $('.' + dragStr)[0] || $('body').append(treeMove); 156 | var dragElem = $('.' + dragStr)[0] ? $('.' + dragStr) : treeMove; 157 | (dragElem).addClass('layui-show').html(move.from.elem.children('a').html()); 158 | dragElem.css({ 159 | left: e.pageX + 10 160 | ,top: e.pageY + 10 161 | }) 162 | } 163 | }).on('mouseup', function(){ 164 | var move = that.move; 165 | if(move.from){ 166 | move.from.elem.children('a').removeClass(enterSkin); 167 | move.to && move.to.elem.children('a').removeClass(enterSkin); 168 | that.move = {}; 169 | $('.' + dragStr).remove(); 170 | } 171 | }); 172 | } 173 | }; 174 | 175 | //拖拽节点 176 | Tree.prototype.move = {}; 177 | Tree.prototype.drag = function(elem, item){ 178 | var that = this, options = that.options; 179 | var a = elem.children('a'), mouseenter = function(){ 180 | var othis = $(this), move = that.move; 181 | if(move.from){ 182 | move.to = { 183 | item: item 184 | ,elem: elem 185 | }; 186 | othis.addClass(enterSkin); 187 | } 188 | }; 189 | a.on('mousedown', function(){ 190 | var move = that.move 191 | move.from = { 192 | item: item 193 | ,elem: elem 194 | }; 195 | }); 196 | a.on('mouseenter', mouseenter).on('mousemove', mouseenter) 197 | .on('mouseleave', function(){ 198 | var othis = $(this), move = that.move; 199 | if(move.from){ 200 | delete move.to; 201 | othis.removeClass(enterSkin); 202 | } 203 | }); 204 | }; 205 | 206 | //暴露接口 207 | exports('tree', function(options){ 208 | var tree = new Tree(options = options || {}); 209 | var elem = $(options.elem); 210 | if(!elem[0]){ 211 | return hint.error('layui.tree 没有找到'+ options.elem +'元素'); 212 | } 213 | tree.init(elem); 214 | }); 215 | }); 216 | -------------------------------------------------------------------------------- /layui/lay/modules/upload.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Title: layui.upload 文件上传 4 | @Author: 贤心 5 | @License:MIT 6 | 7 | */ 8 | 9 | layui.define('layer' , function(exports){ 10 | "use strict"; 11 | 12 | var $ = layui.$ 13 | ,layer = layui.layer 14 | ,hint = layui.hint() 15 | ,device = layui.device() 16 | 17 | //外部接口 18 | ,upload = { 19 | config: {} //全局配置项 20 | 21 | //设置全局项 22 | ,set: function(options){ 23 | var that = this; 24 | that.config = $.extend({}, that.config, options); 25 | return that; 26 | } 27 | 28 | //事件监听 29 | ,on: function(events, callback){ 30 | return layui.onevent.call(this, MOD_NAME, events, callback); 31 | } 32 | } 33 | 34 | //操作当前实例 35 | ,thisUpload = function(){ 36 | var that = this; 37 | return { 38 | upload: function(files){ 39 | that.upload.call(that, files); 40 | } 41 | ,config: that.config 42 | } 43 | } 44 | 45 | //字符常量 46 | ,MOD_NAME = 'upload', ELEM = '.layui-upload', THIS = 'layui-this', SHOW = 'layui-show', HIDE = 'layui-hide', DISABLED = 'layui-disabled' 47 | 48 | ,ELEM_FILE = 'layui-upload-file', ELEM_FORM = 'layui-upload-form', ELEM_IFRAME = 'layui-upload-iframe', ELEM_CHOOSE = 'layui-upload-choose', ELEM_DRAG = 'layui-upload-drag' 49 | 50 | 51 | //构造器 52 | ,Class = function(options){ 53 | var that = this; 54 | that.config = $.extend({}, that.config, upload.config, options); 55 | that.render(); 56 | }; 57 | 58 | //默认配置 59 | Class.prototype.config = { 60 | accept: 'images' //允许上传的文件类型:images/file/video/audio 61 | ,exts: '' //允许上传的文件后缀名 62 | ,auto: true //是否选完文件后自动上传 63 | ,bindAction: '' //手动上传触发的元素 64 | ,url: '' //上传地址 65 | ,field: 'file' //文件字段名 66 | ,method: 'post' //请求上传的 http 类型 67 | ,data: {} //请求上传的额外参数 68 | ,drag: true //是否允许拖拽上传 69 | ,size: 0 //文件限制大小,默认不限制 70 | ,number: 0 //允许同时上传的文件数,默认不限制 71 | ,multiple: false //是否允许多文件上传,不支持ie8-9 72 | }; 73 | 74 | //初始渲染 75 | Class.prototype.render = function(options){ 76 | var that = this 77 | ,options = that.config; 78 | 79 | options.elem = $(options.elem); 80 | options.bindAction = $(options.bindAction); 81 | 82 | that.file(); 83 | that.events(); 84 | }; 85 | 86 | //追加文件域 87 | Class.prototype.file = function(){ 88 | var that = this 89 | ,options = that.config 90 | ,elemFile = that.elemFile = $([ 91 | '' 94 | ].join('')) 95 | ,next = options.elem.next(); 96 | 97 | if(next.hasClass(ELEM_FILE) || next.hasClass(ELEM_FORM)){ 98 | next.remove(); 99 | } 100 | 101 | //包裹ie8/9容器 102 | if(device.ie && device.ie < 10){ 103 | options.elem.wrap('
    '); 104 | } 105 | 106 | that.isFile() ? ( 107 | that.elemFile = options.elem 108 | ,options.field = options.elem[0].name 109 | ) : options.elem.after(elemFile); 110 | 111 | //初始化ie8/9的Form域 112 | if(device.ie && device.ie < 10){ 113 | that.initIE(); 114 | } 115 | }; 116 | 117 | //ie8-9初始化 118 | Class.prototype.initIE = function(){ 119 | var that = this 120 | ,options = that.config 121 | ,iframe = $('') 122 | ,elemForm = $(['
    ' 123 | ,'
    '].join('')); 124 | 125 | //插入iframe 126 | $('#'+ ELEM_IFRAME)[0] || $('body').append(iframe); 127 | 128 | //包裹文件域 129 | if(!options.elem.next().hasClass(ELEM_FORM)){ 130 | that.elemFile.wrap(elemForm); 131 | 132 | //追加额外的参数 133 | options.elem.next('.'+ ELEM_FORM).append(function(){ 134 | var arr = []; 135 | layui.each(options.data, function(key, value){ 136 | value = typeof value === 'function' ? value() : value; 137 | arr.push('') 138 | }); 139 | return arr.join(''); 140 | }()); 141 | } 142 | }; 143 | 144 | //异常提示 145 | Class.prototype.msg = function(content){ 146 | return layer.msg(content, { 147 | icon: 2 148 | ,shift: 6 149 | }); 150 | }; 151 | 152 | //判断绑定元素是否为文件域本身 153 | Class.prototype.isFile = function(){ 154 | var elem = this.config.elem[0]; 155 | if(!elem) return; 156 | return elem.tagName.toLocaleLowerCase() === 'input' && elem.type === 'file' 157 | } 158 | 159 | //预读图片信息 160 | Class.prototype.preview = function(callback){ 161 | var that = this; 162 | if(window.FileReader){ 163 | layui.each(that.chooseFiles, function(index, file){ 164 | var reader = new FileReader(); 165 | reader.readAsDataURL(file); 166 | reader.onload = function(){ 167 | callback && callback(index, file, this.result); 168 | } 169 | }); 170 | } 171 | }; 172 | 173 | //执行上传 174 | Class.prototype.upload = function(files, type){ 175 | var that = this 176 | ,options = that.config 177 | ,elemFile = that.elemFile[0] 178 | 179 | //高级浏览器处理方式,支持跨域 180 | ,ajaxSend = function(){ 181 | var successful = 0, aborted = 0 182 | ,items = files || that.files || that.chooseFiles || elemFile.files 183 | ,allDone = function(){ //多文件全部上传完毕的回调 184 | if(options.multiple && successful + aborted === that.fileLength){ 185 | typeof options.allDone === 'function' && options.allDone({ 186 | total: that.fileLength 187 | ,successful: successful 188 | ,aborted: aborted 189 | }); 190 | } 191 | }; 192 | layui.each(items, function(index, file){ 193 | var formData = new FormData(); 194 | 195 | formData.append(options.field, file); 196 | 197 | //追加额外的参数 198 | layui.each(options.data, function(key, value){ 199 | value = typeof value === 'function' ? value() : value; 200 | formData.append(key, value); 201 | }); 202 | 203 | //提交文件 204 | $.ajax({ 205 | url: options.url 206 | ,type: 'post' 207 | ,data: formData 208 | ,contentType: false 209 | ,processData: false 210 | ,dataType: 'json' 211 | ,headers: options.headers || {} 212 | ,success: function(res){ 213 | successful++; 214 | done(index, res); 215 | allDone(); 216 | } 217 | ,error: function(){ 218 | aborted++; 219 | that.msg('请求上传接口出现异常'); 220 | error(index); 221 | allDone(); 222 | } 223 | }); 224 | }); 225 | } 226 | 227 | //低版本IE处理方式,不支持跨域 228 | ,iframeSend = function(){ 229 | var iframe = $('#'+ ELEM_IFRAME); 230 | 231 | that.elemFile.parent().submit(); 232 | 233 | //获取响应信息 234 | clearInterval(Class.timer); 235 | Class.timer = setInterval(function() { 236 | var res, iframeBody = iframe.contents().find('body'); 237 | try { 238 | res = iframeBody.text(); 239 | } catch(e) { 240 | that.msg('获取上传后的响应信息出现异常'); 241 | clearInterval(Class.timer); 242 | error(); 243 | } 244 | if(res){ 245 | clearInterval(Class.timer); 246 | iframeBody.html(''); 247 | done(0, res); 248 | } 249 | }, 30); 250 | } 251 | 252 | //统一回调 253 | ,done = function(index, res){ 254 | that.elemFile.next('.'+ ELEM_CHOOSE).remove(); 255 | elemFile.value = ''; 256 | if(typeof res !== 'object'){ 257 | try { 258 | res = JSON.parse(res); 259 | } catch(e){ 260 | res = {}; 261 | return that.msg('请对上传接口返回有效JSON'); 262 | } 263 | } 264 | typeof options.done === 'function' && options.done(res, index || 0, function(files){ 265 | that.upload(files); 266 | }); 267 | } 268 | 269 | //统一网络异常回调 270 | ,error = function(index){ 271 | if(options.auto){ 272 | elemFile.value = ''; 273 | } 274 | typeof options.error === 'function' && options.error(index || 0, function(files){ 275 | that.upload(files); 276 | }); 277 | } 278 | 279 | ,exts = options.exts 280 | ,check ,value = function(){ 281 | var arr = []; 282 | layui.each(files || that.chooseFiles, function(i, item){ 283 | arr.push(item.name); 284 | }); 285 | return arr; 286 | }() 287 | 288 | //回调返回的参数 289 | ,args = { 290 | //预览 291 | preview: function(callback){ 292 | that.preview(callback); 293 | } 294 | //上传 295 | ,upload: function(index, file){ 296 | var thisFile = {}; 297 | thisFile[index] = file; 298 | that.upload(thisFile); 299 | } 300 | //追加文件到队列 301 | ,pushFile: function(){ 302 | that.files = that.files || {}; 303 | layui.each(that.chooseFiles, function(index, item){ 304 | that.files[index] = item; 305 | }); 306 | return that.files; 307 | } 308 | //重置文件 309 | ,resetFile: function(index, file, filename){ 310 | var newFile = new File([file], filename); 311 | that.files = that.files || {}; 312 | that.files[index] = newFile; 313 | } 314 | } 315 | 316 | //提交上传 317 | ,send = function(){ 318 | //选择文件的回调 319 | if(type === 'choose' || options.auto){ 320 | options.choose && options.choose(args); 321 | if(type === 'choose'){ 322 | return; 323 | } 324 | } 325 | 326 | //上传前的回调 327 | options.before && options.before(args); 328 | 329 | //IE兼容处理 330 | if(device.ie){ 331 | return device.ie > 9 ? ajaxSend() : iframeSend(); 332 | } 333 | 334 | ajaxSend(); 335 | } 336 | 337 | //校验文件格式 338 | value = value.length === 0 339 | ? ((elemFile.value.match(/[^\/\\]+\..+/g)||[]) || '') 340 | : value; 341 | 342 | if(value.length === 0) return; 343 | 344 | switch(options.accept){ 345 | case 'file': //一般文件 346 | if(exts && !RegExp('\\w\\.('+ exts +')$', 'i').test(escape(value))){ 347 | that.msg('选择的文件中包含不支持的格式'); 348 | return elemFile.value = ''; 349 | } 350 | break; 351 | case 'video': //视频文件 352 | if(!RegExp('\\w\\.('+ (exts || 'avi|mp4|wma|rmvb|rm|flash|3gp|flv') +')$', 'i').test(escape(value))){ 353 | that.msg('选择的视频中包含不支持的格式'); 354 | return elemFile.value = ''; 355 | } 356 | break; 357 | case 'audio': //音频文件 358 | if(!RegExp('\\w\\.('+ (exts || 'mp3|wav|mid') +')$', 'i').test(escape(value))){ 359 | that.msg('选择的音频中包含不支持的格式'); 360 | return elemFile.value = ''; 361 | } 362 | break; 363 | default: //图片文件 364 | layui.each(value, function(i, item){ 365 | if(!RegExp('\\w\\.('+ (exts || 'jpg|png|gif|bmp|jpeg$') +')', 'i').test(escape(item))){ 366 | check = true; 367 | } 368 | }); 369 | if(check){ 370 | that.msg('选择的图片中包含不支持的格式'); 371 | return elemFile.value = ''; 372 | } 373 | break; 374 | } 375 | 376 | //检验文件数量 377 | that.fileLength = function(){ 378 | var length = 0 379 | ,items = files || that.files || that.chooseFiles || elemFile.files; 380 | layui.each(items, function(){ 381 | length++; 382 | }); 383 | return length; 384 | }(); 385 | if(options.number && that.fileLength > options.number){ 386 | return that.msg('同时最多只能上传的数量为:'+ options.number); 387 | } 388 | 389 | //检验文件大小 390 | if(options.size > 0 && !(device.ie && device.ie < 10)){ 391 | var limitSize; 392 | 393 | layui.each(that.chooseFiles, function(index, file){ 394 | if(file.size > 1024*options.size){ 395 | var size = options.size/1024; 396 | size = size >= 1 ? (size.toFixed(2) + 'MB') : options.size + 'KB' 397 | elemFile.value = ''; 398 | limitSize = size; 399 | } 400 | }); 401 | if(limitSize) return that.msg('文件不能超过'+ limitSize); 402 | } 403 | send(); 404 | }; 405 | 406 | //事件处理 407 | Class.prototype.events = function(){ 408 | var that = this 409 | ,options = that.config 410 | 411 | //设置当前选择的文件队列 412 | ,setChooseFile = function(files){ 413 | that.chooseFiles = {}; 414 | layui.each(files, function(i, item){ 415 | var time = new Date().getTime(); 416 | that.chooseFiles[time + '-' + i] = item; 417 | }); 418 | } 419 | 420 | //设置选择的文本 421 | ,setChooseText = function(files, filename){ 422 | var elemFile = that.elemFile 423 | ,value = files.length > 1 424 | ? files.length + '个文件' 425 | : ((files[0] || {}).name || (elemFile[0].value.match(/[^\/\\]+\..+/g)||[]) || ''); 426 | 427 | if(elemFile.next().hasClass(ELEM_CHOOSE)){ 428 | elemFile.next().remove(); 429 | } 430 | that.upload(null, 'choose'); 431 | if(that.isFile() || options.choose) return; 432 | elemFile.after(''+ value +''); 433 | }; 434 | 435 | //点击上传容器 436 | options.elem.off('upload.start').on('upload.start', function(){ 437 | var othis = $(this), data = othis.attr('lay-data'); 438 | 439 | if(data){ 440 | try{ 441 | data = new Function('return '+ data)(); 442 | that.config = $.extend({}, options, data); 443 | } catch(e){ 444 | hint.error('Upload element property lay-data configuration item has a syntax error: ' + data) 445 | } 446 | } 447 | 448 | that.config.item = othis; 449 | that.elemFile[0].click(); 450 | }); 451 | 452 | //拖拽上传 453 | if(!(device.ie && device.ie < 10)){ 454 | options.elem.off('upload.over').on('upload.over', function(){ 455 | var othis = $(this) 456 | othis.attr('lay-over', ''); 457 | }) 458 | .off('upload.leave').on('upload.leave', function(){ 459 | var othis = $(this) 460 | othis.removeAttr('lay-over'); 461 | }) 462 | .off('upload.drop').on('upload.drop', function(e, param){ 463 | var othis = $(this), files = param.originalEvent.dataTransfer.files || []; 464 | 465 | othis.removeAttr('lay-over'); 466 | setChooseFile(files); 467 | 468 | if(options.auto){ 469 | that.upload(files); 470 | } else { 471 | setChooseText(files); 472 | } 473 | }); 474 | } 475 | 476 | //文件选择 477 | that.elemFile.off('upload.change').on('upload.change', function(){ 478 | var files = this.files || []; 479 | setChooseFile(files); 480 | options.auto ? that.upload() : setChooseText(files); //是否自动触发上传 481 | }); 482 | 483 | //手动触发上传 484 | options.bindAction.off('upload.action').on('upload.action', function(){ 485 | that.upload(); 486 | }); 487 | 488 | //防止事件重复绑定 489 | if(options.elem.data('haveEvents')) return; 490 | 491 | that.elemFile.on('change', function(){ 492 | $(this).trigger('upload.change'); 493 | }); 494 | 495 | options.elem.on('click', function(){ 496 | if(that.isFile()) return; 497 | $(this).trigger('upload.start'); 498 | }); 499 | 500 | if(options.drag){ 501 | options.elem.on('dragover', function(e){ 502 | e.preventDefault(); 503 | $(this).trigger('upload.over'); 504 | }).on('dragleave', function(e){ 505 | $(this).trigger('upload.leave'); 506 | }).on('drop', function(e){ 507 | e.preventDefault(); 508 | $(this).trigger('upload.drop', e); 509 | }); 510 | } 511 | 512 | options.bindAction.on('click', function(){ 513 | $(this).trigger('upload.action'); 514 | }); 515 | 516 | options.elem.data('haveEvents', true); 517 | }; 518 | 519 | //核心入口 520 | upload.render = function(options){ 521 | var inst = new Class(options); 522 | return thisUpload.call(inst); 523 | }; 524 | 525 | exports(MOD_NAME, upload); 526 | }); 527 | 528 | -------------------------------------------------------------------------------- /layui/lay/modules/util.js: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @Name:layui.util 工具集 4 | @Author:贤心 5 | @License:MIT 6 | 7 | */ 8 | 9 | layui.define('jquery', function(exports){ 10 | "use strict"; 11 | 12 | var $ = layui.$ 13 | 14 | //外部接口 15 | ,util = { 16 | //固定块 17 | fixbar: function(options){ 18 | var ELEM = 'layui-fixbar', TOP_BAR = 'layui-fixbar-top' 19 | ,dom = $(document), body = $('body') 20 | ,is, timer; 21 | 22 | options = $.extend({ 23 | showHeight: 200 //出现TOP的滚动条高度临界值 24 | }, options); 25 | 26 | options.bar1 = options.bar1 === true ? '' : options.bar1; 27 | options.bar2 = options.bar2 === true ? '' : options.bar2; 28 | options.bgcolor = options.bgcolor ? ('background-color:' + options.bgcolor) : ''; 29 | 30 | var icon = [options.bar1, options.bar2, ''] //图标:信息、问号、TOP 31 | ,elem = $([''].join('')) 36 | ,topBar = elem.find('.'+TOP_BAR) 37 | ,scroll = function(){ 38 | var stop = dom.scrollTop(); 39 | if(stop >= (options.showHeight)){ 40 | is || (topBar.show(), is = 1); 41 | } else { 42 | is && (topBar.hide(), is = 0); 43 | } 44 | }; 45 | if($('.'+ ELEM)[0]) return; 46 | 47 | typeof options.css === 'object' && elem.css(options.css); 48 | body.append(elem), scroll(); 49 | 50 | //bar点击事件 51 | elem.find('li').on('click', function(){ 52 | var othis = $(this), type = othis.attr('lay-type'); 53 | if(type === 'top'){ 54 | $('html,body').animate({ 55 | scrollTop : 0 56 | }, 200); 57 | } 58 | options.click && options.click.call(this, type); 59 | }); 60 | 61 | //Top显示控制 62 | dom.on('scroll', function(){ 63 | clearTimeout(timer); 64 | timer = setTimeout(function(){ 65 | scroll(); 66 | }, 100); 67 | }); 68 | } 69 | 70 | //倒计时 71 | ,countdown: function(endTime, serverTime, callback){ 72 | var that = this 73 | ,type = typeof serverTime === 'function' 74 | ,end = new Date(endTime).getTime() 75 | ,now = new Date((!serverTime || type) ? new Date().getTime() : serverTime).getTime() 76 | ,count = end - now 77 | ,time = [ 78 | Math.floor(count/(1000*60*60*24)) //天 79 | ,Math.floor(count/(1000*60*60)) % 24 //时 80 | ,Math.floor(count/(1000*60)) % 60 //分 81 | ,Math.floor(count/1000) % 60 //秒 82 | ]; 83 | 84 | if(type) callback = serverTime; 85 | 86 | var timer = setTimeout(function(){ 87 | that.countdown(endTime, now + 1000, callback); 88 | }, 1000); 89 | 90 | callback && callback(count > 0 ? time : [0,0,0,0], serverTime, timer); 91 | 92 | if(count <= 0) clearTimeout(timer); 93 | return timer; 94 | } 95 | 96 | //某个时间在当前时间的多久前 97 | ,timeAgo: function(time, onlyDate){ 98 | var that = this 99 | ,arr = [[], []] 100 | ,stamp = new Date().getTime() - new Date(time).getTime(); 101 | 102 | //返回具体日期 103 | if(stamp > 1000*60*60*24*8){ 104 | stamp = new Date(time); 105 | arr[0][0] = that.digit(stamp.getFullYear(), 4); 106 | arr[0][1] = that.digit(stamp.getMonth() + 1); 107 | arr[0][2] = that.digit(stamp.getDate()); 108 | 109 | //是否输出时间 110 | if(!onlyDate){ 111 | arr[1][0] = that.digit(stamp.getHours()); 112 | arr[1][1] = that.digit(stamp.getMinutes()); 113 | arr[1][2] = that.digit(stamp.getSeconds()); 114 | } 115 | return arr[0].join('-') + ' ' + arr[1].join(':'); 116 | } 117 | 118 | //30天以内,返回“多久前” 119 | if(stamp >= 1000*60*60*24){ 120 | return ((stamp/1000/60/60/24)|0) + '天前'; 121 | } else if(stamp >= 1000*60*60){ 122 | return ((stamp/1000/60/60)|0) + '小时前'; 123 | } else if(stamp >= 1000*60*2){ //2分钟以内为:刚刚 124 | return ((stamp/1000/60)|0) + '分钟前'; 125 | } else if(stamp < 0){ 126 | return '未来'; 127 | } else { 128 | return '刚刚'; 129 | } 130 | } 131 | 132 | //数字前置补零 133 | ,digit: function(num, length){ 134 | var str = ''; 135 | num = String(num); 136 | length = length || 2; 137 | for(var i = num.length; i < length; i++){ 138 | str += '0'; 139 | } 140 | return num < Math.pow(10, length) ? str + (num|0) : num; 141 | } 142 | 143 | //转化为日期格式字符 144 | ,toDateString: function(time, format){ 145 | var that = this 146 | ,date = new Date(time || new Date()) 147 | ,ymd = [ 148 | that.digit(date.getFullYear(), 4) 149 | ,that.digit(date.getMonth() + 1) 150 | ,that.digit(date.getDate()) 151 | ] 152 | ,hms = [ 153 | that.digit(date.getHours()) 154 | ,that.digit(date.getMinutes()) 155 | ,that.digit(date.getSeconds()) 156 | ]; 157 | 158 | format = format || 'yyyy-MM-dd HH:mm:ss'; 159 | 160 | return format.replace(/yyyy/g, ymd[0]) 161 | .replace(/MM/g, ymd[1]) 162 | .replace(/dd/g, ymd[2]) 163 | .replace(/HH/g, hms[0]) 164 | .replace(/mm/g, hms[1]) 165 | .replace(/ss/g, hms[2]); 166 | } 167 | 168 | //防 xss 攻击 169 | ,escape: function(html){ 170 | return String(html || '').replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&') 171 | .replace(//g, '>') 172 | .replace(/'/g, ''').replace(/"/g, '"'); 173 | } 174 | }; 175 | 176 | //监听 DOM 尺寸变化,该创意来自:http://benalman.com/projects/jquery-resize-plugin/ 177 | !function(a,b,c){"$:nomunge";function l(){f=b[g](function(){d.each(function(){var b=a(this),c=b.width(),d=b.height(),e=a.data(this,i);(c!==e.w||d!==e.h)&&b.trigger(h,[e.w=c,e.h=d])}),l()},e[j])}var f,d=a([]),e=a.resize=a.extend(a.resize,{}),g="setTimeout",h="resize",i=h+"-special-event",j="delay",k="throttleWindow";e[j]=250,e[k]=!0,a.event.special[h]={setup:function(){if(!e[k]&&this[g])return!1;var b=a(this);d=d.add(b),a.data(this,i,{w:b.width(),h:b.height()}),1===d.length&&l()},teardown:function(){if(!e[k]&&this[g])return!1;var b=a(this);d=d.not(b),b.removeData(i),d.length||clearTimeout(f)},add:function(b){function f(b,e,f){var g=a(this),h=a.data(this,i)||{};h.w=e!==c?e:g.width(),h.h=f!==c?f:g.height(),d.apply(this,arguments)}if(!e[k]&&this[g])return!1;var d;return a.isFunction(b)?(d=b,f):(d=b.handler,b.handler=f,void 0)}}}($,window); 178 | 179 | //暴露接口 180 | exports('util', util); 181 | }); -------------------------------------------------------------------------------- /layui/layui.js: -------------------------------------------------------------------------------- 1 | /*! 2 | 3 | @Title: Layui 4 | @Description:经典模块化前端框架 5 | @Site: www.layui.com 6 | @Author: 贤心 7 | @License:MIT 8 | 9 | */ 10 | 11 | ;!function(win){ 12 | "use strict"; 13 | 14 | var doc = document, config = { 15 | modules: {} //记录模块物理路径 16 | ,status: {} //记录模块加载状态 17 | ,timeout: 10 //符合规范的模块请求最长等待秒数 18 | ,event: {} //记录模块自定义事件 19 | } 20 | 21 | ,Layui = function(){ 22 | this.v = '2.4.5'; //版本号 23 | } 24 | 25 | //获取layui所在目录 26 | ,getPath = function(){ 27 | var jsPath = doc.currentScript ? doc.currentScript.src : function(){ 28 | var js = doc.scripts 29 | ,last = js.length - 1 30 | ,src; 31 | for(var i = last; i > 0; i--){ 32 | if(js[i].readyState === 'interactive'){ 33 | src = js[i].src; 34 | break; 35 | } 36 | } 37 | return src || js[last].src; 38 | }(); 39 | return jsPath.substring(0, jsPath.lastIndexOf('/') + 1); 40 | }() 41 | 42 | //异常提示 43 | ,error = function(msg){ 44 | win.console && console.error && console.error('Layui hint: ' + msg); 45 | } 46 | 47 | ,isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]' 48 | 49 | //内置模块 50 | ,modules = { 51 | layer: 'modules/layer' //弹层 52 | ,laydate: 'modules/laydate' //日期 53 | ,laypage: 'modules/laypage' //分页 54 | ,laytpl: 'modules/laytpl' //模板引擎 55 | ,layim: 'modules/layim' //web通讯 56 | ,layedit: 'modules/layedit' //富文本编辑器 57 | ,form: 'modules/form' //表单集 58 | ,upload: 'modules/upload' //上传 59 | ,tree: 'modules/tree' //树结构 60 | ,table: 'modules/table' //表格 61 | ,element: 'modules/element' //常用元素操作 62 | ,rate: 'modules/rate' //评分组件 63 | ,colorpicker: 'modules/colorpicker' //颜色选择器 64 | ,slider: 'modules/slider' //滑块 65 | ,carousel: 'modules/carousel' //轮播 66 | ,flow: 'modules/flow' //流加载 67 | ,util: 'modules/util' //工具块 68 | ,code: 'modules/code' //代码修饰器 69 | ,jquery: 'modules/jquery' //DOM库(第三方) 70 | 71 | ,mobile: 'modules/mobile' //移动大模块 | 若当前为开发目录,则为移动模块入口,否则为移动模块集合 72 | ,'layui.all': '../layui.all' //PC模块合并版 73 | }; 74 | 75 | //记录基础数据 76 | Layui.prototype.cache = config; 77 | 78 | //定义模块 79 | Layui.prototype.define = function(deps, factory){ 80 | var that = this 81 | ,type = typeof deps === 'function' 82 | ,callback = function(){ 83 | var setApp = function(app, exports){ 84 | layui[app] = exports; 85 | config.status[app] = true; 86 | }; 87 | typeof factory === 'function' && factory(function(app, exports){ 88 | setApp(app, exports); 89 | config.callback[app] = function(){ 90 | factory(setApp); 91 | } 92 | }); 93 | return this; 94 | }; 95 | 96 | type && ( 97 | factory = deps, 98 | deps = [] 99 | ); 100 | 101 | if(layui['layui.all'] || (!layui['layui.all'] && layui['layui.mobile'])){ 102 | return callback.call(that); 103 | } 104 | 105 | that.use(deps, callback); 106 | return that; 107 | }; 108 | 109 | //使用特定模块 110 | Layui.prototype.use = function(apps, callback, exports){ 111 | var that = this 112 | ,dir = config.dir = config.dir ? config.dir : getPath 113 | ,head = doc.getElementsByTagName('head')[0]; 114 | 115 | apps = typeof apps === 'string' ? [apps] : apps; 116 | 117 | //如果页面已经存在jQuery1.7+库且所定义的模块依赖jQuery,则不加载内部jquery模块 118 | if(window.jQuery && jQuery.fn.on){ 119 | that.each(apps, function(index, item){ 120 | if(item === 'jquery'){ 121 | apps.splice(index, 1); 122 | } 123 | }); 124 | layui.jquery = layui.$ = jQuery; 125 | } 126 | 127 | var item = apps[0] 128 | ,timeout = 0; 129 | exports = exports || []; 130 | 131 | //静态资源host 132 | config.host = config.host || (dir.match(/\/\/([\s\S]+?)\//)||['//'+ location.host +'/'])[0]; 133 | 134 | //加载完毕 135 | function onScriptLoad(e, url){ 136 | var readyRegExp = navigator.platform === 'PLaySTATION 3' ? /^complete$/ : /^(complete|loaded)$/ 137 | if (e.type === 'load' || (readyRegExp.test((e.currentTarget || e.srcElement).readyState))) { 138 | config.modules[item] = url; 139 | head.removeChild(node); 140 | (function poll() { 141 | if(++timeout > config.timeout * 1000 / 4){ 142 | return error(item + ' is not a valid module'); 143 | }; 144 | config.status[item] ? onCallback() : setTimeout(poll, 4); 145 | }()); 146 | } 147 | } 148 | 149 | //回调 150 | function onCallback(){ 151 | exports.push(layui[item]); 152 | apps.length > 1 ? 153 | that.use(apps.slice(1), callback, exports) 154 | : ( typeof callback === 'function' && callback.apply(layui, exports) ); 155 | } 156 | 157 | //如果使用了 layui.all.js 158 | if(apps.length === 0 159 | || (layui['layui.all'] && modules[item]) 160 | || (!layui['layui.all'] && layui['layui.mobile'] && modules[item]) 161 | ){ 162 | return onCallback(), that; 163 | } 164 | 165 | //首次加载模块 166 | if(!config.modules[item]){ 167 | var node = doc.createElement('script') 168 | 169 | //如果是内置模块,则按照 dir 参数拼接模块路径 170 | //如果是扩展模块,则判断模块路径值是否为 {/} 开头, 171 | //如果路径值是 {/} 开头,则模块路径即为后面紧跟的字符。 172 | //否则,则按照 base 参数拼接模块路径 173 | ,url = ( modules[item] ? (dir + 'lay/') 174 | : (/^\{\/\}/.test(that.modules[item]) ? '' : (config.base || '')) 175 | ) + (that.modules[item] || item) + '.js'; 176 | 177 | url = url.replace(/^\{\/\}/, ''); 178 | 179 | node.async = true; 180 | node.charset = 'utf-8'; 181 | node.src = url + function(){ 182 | var version = config.version === true 183 | ? (config.v || (new Date()).getTime()) 184 | : (config.version||''); 185 | return version ? ('?v=' + version) : ''; 186 | }(); 187 | 188 | head.appendChild(node); 189 | 190 | if(node.attachEvent && !(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) && !isOpera){ 191 | node.attachEvent('onreadystatechange', function(e){ 192 | onScriptLoad(e, url); 193 | }); 194 | } else { 195 | node.addEventListener('load', function(e){ 196 | onScriptLoad(e, url); 197 | }, false); 198 | } 199 | 200 | config.modules[item] = url; 201 | } else { //缓存 202 | (function poll() { 203 | if(++timeout > config.timeout * 1000 / 4){ 204 | return error(item + ' is not a valid module'); 205 | }; 206 | (typeof config.modules[item] === 'string' && config.status[item]) 207 | ? onCallback() 208 | : setTimeout(poll, 4); 209 | }()); 210 | } 211 | 212 | return that; 213 | }; 214 | 215 | //获取节点的style属性值 216 | Layui.prototype.getStyle = function(node, name){ 217 | var style = node.currentStyle ? node.currentStyle : win.getComputedStyle(node, null); 218 | return style[style.getPropertyValue ? 'getPropertyValue' : 'getAttribute'](name); 219 | }; 220 | 221 | //css外部加载器 222 | Layui.prototype.link = function(href, fn, cssname){ 223 | var that = this 224 | ,link = doc.createElement('link') 225 | ,head = doc.getElementsByTagName('head')[0]; 226 | 227 | if(typeof fn === 'string') cssname = fn; 228 | 229 | var app = (cssname || href).replace(/\.|\//g, '') 230 | ,id = link.id = 'layuicss-'+app 231 | ,timeout = 0; 232 | 233 | link.rel = 'stylesheet'; 234 | link.href = href + (config.debug ? '?v='+new Date().getTime() : ''); 235 | link.media = 'all'; 236 | 237 | if(!doc.getElementById(id)){ 238 | head.appendChild(link); 239 | } 240 | 241 | if(typeof fn !== 'function') return that; 242 | 243 | //轮询css是否加载完毕 244 | (function poll() { 245 | if(++timeout > config.timeout * 1000 / 100){ 246 | return error(href + ' timeout'); 247 | }; 248 | parseInt(that.getStyle(doc.getElementById(id), 'width')) === 1989 ? function(){ 249 | fn(); 250 | }() : setTimeout(poll, 100); 251 | }()); 252 | 253 | return that; 254 | }; 255 | 256 | //存储模块的回调 257 | config.callback = {}; 258 | 259 | //重新执行模块的工厂函数 260 | Layui.prototype.factory = function(modName){ 261 | if(layui[modName]){ 262 | return typeof config.callback[modName] === 'function' 263 | ? config.callback[modName] 264 | : null; 265 | } 266 | }; 267 | 268 | //css内部加载器 269 | Layui.prototype.addcss = function(firename, fn, cssname){ 270 | return layui.link(config.dir + 'css/' + firename, fn, cssname); 271 | }; 272 | 273 | //图片预加载 274 | Layui.prototype.img = function(url, callback, error) { 275 | var img = new Image(); 276 | img.src = url; 277 | if(img.complete){ 278 | return callback(img); 279 | } 280 | img.onload = function(){ 281 | img.onload = null; 282 | typeof callback === 'function' && callback(img); 283 | }; 284 | img.onerror = function(e){ 285 | img.onerror = null; 286 | typeof error === 'function' && error(e); 287 | }; 288 | }; 289 | 290 | //全局配置 291 | Layui.prototype.config = function(options){ 292 | options = options || {}; 293 | for(var key in options){ 294 | config[key] = options[key]; 295 | } 296 | return this; 297 | }; 298 | 299 | //记录全部模块 300 | Layui.prototype.modules = function(){ 301 | var clone = {}; 302 | for(var o in modules){ 303 | clone[o] = modules[o]; 304 | } 305 | return clone; 306 | }(); 307 | 308 | //拓展模块 309 | Layui.prototype.extend = function(options){ 310 | var that = this; 311 | 312 | //验证模块是否被占用 313 | options = options || {}; 314 | for(var o in options){ 315 | if(that[o] || that.modules[o]){ 316 | error('\u6A21\u5757\u540D '+ o +' \u5DF2\u88AB\u5360\u7528'); 317 | } else { 318 | that.modules[o] = options[o]; 319 | } 320 | } 321 | 322 | return that; 323 | }; 324 | 325 | //路由解析 326 | Layui.prototype.router = function(hash){ 327 | var that = this 328 | ,hash = hash || location.hash 329 | ,data = { 330 | path: [] 331 | ,search: {} 332 | ,hash: (hash.match(/[^#](#.*$)/) || [])[1] || '' 333 | }; 334 | 335 | if(!/^#\//.test(hash)) return data; //禁止非路由规范 336 | hash = hash.replace(/^#\//, ''); 337 | data.href = '/' + hash; 338 | hash = hash.replace(/([^#])(#.*$)/, '$1').split('/') || []; 339 | 340 | //提取Hash结构 341 | that.each(hash, function(index, item){ 342 | /^\w+=/.test(item) ? function(){ 343 | item = item.split('='); 344 | data.search[item[0]] = item[1]; 345 | }() : data.path.push(item); 346 | }); 347 | 348 | return data; 349 | }; 350 | 351 | //本地持久性存储 352 | Layui.prototype.data = function(table, settings, storage){ 353 | table = table || 'layui'; 354 | storage = storage || localStorage; 355 | 356 | if(!win.JSON || !win.JSON.parse) return; 357 | 358 | //如果settings为null,则删除表 359 | if(settings === null){ 360 | return delete storage[table]; 361 | } 362 | 363 | settings = typeof settings === 'object' 364 | ? settings 365 | : {key: settings}; 366 | 367 | try{ 368 | var data = JSON.parse(storage[table]); 369 | } catch(e){ 370 | var data = {}; 371 | } 372 | 373 | if('value' in settings) data[settings.key] = settings.value; 374 | if(settings.remove) delete data[settings.key]; 375 | storage[table] = JSON.stringify(data); 376 | 377 | return settings.key ? data[settings.key] : data; 378 | }; 379 | 380 | //本地会话性存储 381 | Layui.prototype.sessionData = function(table, settings){ 382 | return this.data(table, settings, sessionStorage); 383 | } 384 | 385 | //设备信息 386 | Layui.prototype.device = function(key){ 387 | var agent = navigator.userAgent.toLowerCase() 388 | 389 | //获取版本号 390 | ,getVersion = function(label){ 391 | var exp = new RegExp(label + '/([^\\s\\_\\-]+)'); 392 | label = (agent.match(exp)||[])[1]; 393 | return label || false; 394 | } 395 | 396 | //返回结果集 397 | ,result = { 398 | os: function(){ //底层操作系统 399 | if(/windows/.test(agent)){ 400 | return 'windows'; 401 | } else if(/linux/.test(agent)){ 402 | return 'linux'; 403 | } else if(/iphone|ipod|ipad|ios/.test(agent)){ 404 | return 'ios'; 405 | } else if(/mac/.test(agent)){ 406 | return 'mac'; 407 | } 408 | }() 409 | ,ie: function(){ //ie版本 410 | return (!!win.ActiveXObject || "ActiveXObject" in win) ? ( 411 | (agent.match(/msie\s(\d+)/) || [])[1] || '11' //由于ie11并没有msie的标识 412 | ) : false; 413 | }() 414 | ,weixin: getVersion('micromessenger') //是否微信 415 | }; 416 | 417 | //任意的key 418 | if(key && !result[key]){ 419 | result[key] = getVersion(key); 420 | } 421 | 422 | //移动设备 423 | result.android = /android/.test(agent); 424 | result.ios = result.os === 'ios'; 425 | 426 | return result; 427 | }; 428 | 429 | //提示 430 | Layui.prototype.hint = function(){ 431 | return { 432 | error: error 433 | } 434 | }; 435 | 436 | //遍历 437 | Layui.prototype.each = function(obj, fn){ 438 | var key 439 | ,that = this; 440 | if(typeof fn !== 'function') return that; 441 | obj = obj || []; 442 | if(obj.constructor === Object){ 443 | for(key in obj){ 444 | if(fn.call(obj[key], key, obj[key])) break; 445 | } 446 | } else { 447 | for(key = 0; key < obj.length; key++){ 448 | if(fn.call(obj[key], key, obj[key])) break; 449 | } 450 | } 451 | return that; 452 | }; 453 | 454 | //将数组中的对象按其某个成员排序 455 | Layui.prototype.sort = function(obj, key, desc){ 456 | var clone = JSON.parse( 457 | JSON.stringify(obj || []) 458 | ); 459 | 460 | if(!key) return clone; 461 | 462 | //如果是数字,按大小排序,如果是非数字,按字典序排序 463 | clone.sort(function(o1, o2){ 464 | var isNum = /^-?\d+$/ 465 | ,v1 = o1[key] 466 | ,v2 = o2[key]; 467 | 468 | if(isNum.test(v1)) v1 = parseFloat(v1); 469 | if(isNum.test(v2)) v2 = parseFloat(v2); 470 | 471 | if(v1 && !v2){ 472 | return 1; 473 | } else if(!v1 && v2){ 474 | return -1; 475 | } 476 | 477 | if(v1 > v2){ 478 | return 1; 479 | } else if (v1 < v2) { 480 | return -1; 481 | } else { 482 | return 0; 483 | } 484 | }); 485 | 486 | desc && clone.reverse(); //倒序 487 | return clone; 488 | }; 489 | 490 | //阻止事件冒泡 491 | Layui.prototype.stope = function(thisEvent){ 492 | thisEvent = thisEvent || win.event; 493 | try { thisEvent.stopPropagation() } catch(e){ 494 | thisEvent.cancelBubble = true; 495 | } 496 | }; 497 | 498 | //自定义模块事件 499 | Layui.prototype.onevent = function(modName, events, callback){ 500 | if(typeof modName !== 'string' 501 | || typeof callback !== 'function') return this; 502 | 503 | return Layui.event(modName, events, null, callback); 504 | }; 505 | 506 | //执行自定义模块事件 507 | Layui.prototype.event = Layui.event = function(modName, events, params, fn){ 508 | var that = this 509 | ,result = null 510 | ,filter = events.match(/\((.*)\)$/)||[] //提取事件过滤器字符结构,如:select(xxx) 511 | ,eventName = (modName + '.'+ events).replace(filter[0], '') //获取事件名称,如:form.select 512 | ,filterName = filter[1] || '' //获取过滤器名称,,如:xxx 513 | ,callback = function(_, item){ 514 | var res = item && item.call(that, params); 515 | res === false && result === null && (result = false); 516 | }; 517 | 518 | //添加事件 519 | if(fn){ 520 | config.event[eventName] = config.event[eventName] || {}; 521 | 522 | //这里不再对多次事件监听做支持,避免更多麻烦 523 | //config.event[eventName][filterName] ? config.event[eventName][filterName].push(fn) : 524 | config.event[eventName][filterName] = [fn]; 525 | return this; 526 | } 527 | 528 | //执行事件回调 529 | layui.each(config.event[eventName], function(key, item){ 530 | //执行当前模块的全部事件 531 | if(filterName === '{*}'){ 532 | layui.each(item, callback); 533 | return; 534 | } 535 | 536 | //执行指定事件 537 | key === '' && layui.each(item, callback); 538 | (filterName && key === filterName) && layui.each(item, callback); 539 | }); 540 | 541 | return result; 542 | }; 543 | 544 | win.layui = new Layui(); 545 | 546 | }(window); 547 | 548 | --------------------------------------------------------------------------------