parent
200a8c9d0b
commit
b15ebfacfe
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,16 @@
|
||||
/** 图标字体 **/
|
||||
@font-face {font-family: 'laydate-icon';
|
||||
src: url('./font/iconfont.eot');
|
||||
src: url('./font/iconfont.eot#iefix') format('embedded-opentype'),
|
||||
url('./font/iconfont.svg#iconfont') format('svg'),
|
||||
url('./font/iconfont.woff') format('woff'),
|
||||
url('./font/iconfont.ttf') format('truetype');
|
||||
}
|
||||
|
||||
.laydate-icon{
|
||||
font-family:"laydate-icon" !important;
|
||||
font-size: 16px;
|
||||
font-style: normal;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
@ -0,0 +1,152 @@
|
||||
/**
|
||||
|
||||
@Name: laydata
|
||||
|
||||
**/
|
||||
|
||||
|
||||
html #layuicss-laydate{display: none; position: absolute; width: 1989px;}
|
||||
|
||||
/* 初始化 */
|
||||
.layui-laydate *{margin: 0; padding: 0;}
|
||||
|
||||
/* 主体结构 */
|
||||
.layui-laydate, .layui-laydate *{box-sizing: border-box;}
|
||||
.layui-laydate{position: absolute; z-index: 66666666; margin: 5px 0; border-radius: 2px; font-size: 14px; -webkit-animation-duration: 0.2s; animation-duration: 0.2s; -webkit-animation-fill-mode: both; animation-fill-mode: both;}
|
||||
.layui-laydate-main{width: 272px;}
|
||||
.layui-laydate-header *,
|
||||
.layui-laydate-content td,
|
||||
.layui-laydate-list li{transition-duration: .3s; -webkit-transition-duration: .3s;}
|
||||
|
||||
/* 微微往下滑入 */
|
||||
@keyframes laydate-downbit {
|
||||
0% {opacity: 0.3; transform: translate3d(0, -5px, 0);}
|
||||
100% {opacity: 1; transform: translate3d(0, 0, 0);}
|
||||
}
|
||||
|
||||
.layui-laydate{animation-name: laydate-downbit;}
|
||||
.layui-laydate-static{ position: relative; z-index: 0; display: inline-block; margin: 0; -webkit-animation: none; animation: none;}
|
||||
|
||||
/* 展开年月列表时 */
|
||||
.laydate-ym-show .laydate-prev-m,
|
||||
.laydate-ym-show .laydate-next-m{display: none !important;}
|
||||
.laydate-ym-show .laydate-prev-y,
|
||||
.laydate-ym-show .laydate-next-y{display: inline-block !important;}
|
||||
.laydate-ym-show .laydate-set-ym span[lay-type="month"]{display: none !important;}
|
||||
|
||||
/* 展开时间列表时 */
|
||||
.laydate-time-show .layui-laydate-header .layui-icon,
|
||||
.laydate-time-show .laydate-set-ym span[lay-type="year"],
|
||||
.laydate-time-show .laydate-set-ym span[lay-type="month"]{display: none !important;}
|
||||
|
||||
/* 头部结构 */
|
||||
.layui-laydate-header{position: relative; line-height:30px; padding: 10px 70px 5px;}
|
||||
.layui-laydate-header *{display: inline-block; vertical-align: bottom;}
|
||||
.layui-laydate-header i{position: absolute; top: 10px; padding: 0 5px; color: #999; font-size: 18px; cursor: pointer;}
|
||||
.layui-laydate-header i.laydate-prev-y{left: 15px;}
|
||||
.layui-laydate-header i.laydate-prev-m{left: 45px;}
|
||||
.layui-laydate-header i.laydate-next-y{right: 15px;}
|
||||
.layui-laydate-header i.laydate-next-m{right: 45px;}
|
||||
.laydate-set-ym{width: 100%; text-align: center; box-sizing: border-box; text-overflow: ellipsis; overflow: hidden; white-space: nowrap;}
|
||||
.laydate-set-ym span{padding: 0 10px; cursor: pointer;}
|
||||
.laydate-time-text{cursor: default !important;}
|
||||
|
||||
/* 主体结构 */
|
||||
.layui-laydate-content{position: relative; padding: 10px; -moz-user-select: none; -webkit-user-select: none; -ms-user-select: none;}
|
||||
.layui-laydate-content table{border-collapse: collapse; border-spacing: 0;}
|
||||
.layui-laydate-content th,
|
||||
.layui-laydate-content td{width: 36px; height: 30px; padding: 5px; text-align: center;}
|
||||
.layui-laydate-content th{font-weight: 400;}
|
||||
.layui-laydate-content td{position: relative; cursor: pointer;}
|
||||
.laydate-day-mark{position: absolute; left: 0; top: 0; width: 100%; line-height: 30px; font-size: 12px; overflow: hidden;}
|
||||
.laydate-day-mark::after{position: absolute; content:''; right: 2px; top: 2px; width: 5px; height: 5px; border-radius: 50%;}
|
||||
|
||||
/* 底部结构 */
|
||||
.layui-laydate-footer{position: relative; height: 46px; line-height: 26px; padding: 10px;}
|
||||
.layui-laydate-footer span{display: inline-block; vertical-align: top; height: 26px; line-height: 24px; padding: 0 10px; border: 1px solid #C9C9C9; border-radius: 2px; background-color: #fff; font-size: 12px; cursor: pointer; white-space: nowrap; transition: all .3s;}
|
||||
.layui-laydate-footer span:hover{color: #5FB878;}
|
||||
.layui-laydate-footer span.layui-laydate-preview{cursor: default; border-color: transparent !important;}
|
||||
.layui-laydate-footer span.layui-laydate-preview:hover{color: #666;}
|
||||
.layui-laydate-footer span:first-child.layui-laydate-preview{padding-left: 0;}
|
||||
.laydate-footer-btns{position: absolute; right: 10px; top: 10px;}
|
||||
.laydate-footer-btns span{margin: 0 0 0 -1px;}
|
||||
|
||||
/* 年月列表 */
|
||||
.layui-laydate-list{position: absolute; left: 0; top: 0; width: 100%; height: 100%; padding: 10px; box-sizing: border-box; background-color: #fff;}
|
||||
.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;}
|
||||
.laydate-month-list>li{width: 25%; margin: 17px 0;}
|
||||
.laydate-time-list{}
|
||||
.laydate-time-list>li{height: 100%; margin: 0; line-height: normal; cursor: default;}
|
||||
.laydate-time-list p{position: relative; top: -4px; line-height: 29px;}
|
||||
.laydate-time-list ol{height: 181px; overflow: hidden;}
|
||||
.laydate-time-list>li:hover ol{overflow-y: auto;}
|
||||
.laydate-time-list ol li{width: 130%; padding-left: 33px; height: 30px; line-height: 30px; text-align: left; cursor: pointer;}
|
||||
|
||||
/* 提示 */
|
||||
.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;}
|
||||
|
||||
|
||||
/* 双日历 */
|
||||
.layui-laydate-range{width: 546px;}
|
||||
.layui-laydate-range .layui-laydate-main{display: inline-block; vertical-align: middle;}
|
||||
.layui-laydate-range .laydate-main-list-1 .layui-laydate-header,
|
||||
.layui-laydate-range .laydate-main-list-1 .layui-laydate-content{border-left: 1px solid #e2e2e2;}
|
||||
|
||||
|
||||
/* 默认简约主题 */
|
||||
.layui-laydate, .layui-laydate-hint{border: 1px solid #d2d2d2; box-shadow: 0 2px 4px rgba(0,0,0,.12); background-color: #fff; color: #666;}
|
||||
.layui-laydate-header{border-bottom: 1px solid #e2e2e2;}
|
||||
.layui-laydate-header i:hover,
|
||||
.layui-laydate-header span:hover{color: #5FB878;}
|
||||
.layui-laydate-content{border-top: none 0; border-bottom: none 0;}
|
||||
.layui-laydate-content th{color: #333;}
|
||||
.layui-laydate-content td{color: #666;}
|
||||
.layui-laydate-content td.laydate-selected{background-color: #B5FFF8;}
|
||||
.laydate-selected:hover{background-color: #00F7DE !important;}
|
||||
.layui-laydate-content td:hover,
|
||||
.layui-laydate-list li:hover{background-color: #eee; color: #333;}
|
||||
.laydate-time-list li ol{margin: 0; padding: 0; border: 1px solid #e2e2e2; border-left-width: 0;}
|
||||
.laydate-time-list li:first-child ol{border-left-width: 1px;}
|
||||
.laydate-time-list>li:hover{background: none;}
|
||||
.layui-laydate-content .laydate-day-prev,
|
||||
.layui-laydate-content .laydate-day-next{color: #d2d2d2;}
|
||||
.laydate-selected.laydate-day-prev,
|
||||
.laydate-selected.laydate-day-next{background-color: #f8f8f8 !important;}
|
||||
.layui-laydate-footer{border-top: 1px solid #e2e2e2;}
|
||||
.layui-laydate-hint{color: #FF5722;}
|
||||
.laydate-day-mark::after{background-color: #5FB878;}
|
||||
.layui-laydate-content td.layui-this .laydate-day-mark::after{display: none;}
|
||||
.layui-laydate-footer span[lay-type="date"]{color: #5FB878;}
|
||||
.layui-laydate .layui-this{background-color: #009688 !important; color: #fff !important;}
|
||||
.layui-laydate .laydate-disabled,
|
||||
.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;}
|
||||
|
||||
/* 墨绿/自定义背景色主题 */
|
||||
.laydate-theme-molv{border: none;}
|
||||
.laydate-theme-molv.layui-laydate-range{width: 548px}
|
||||
.laydate-theme-molv .layui-laydate-main{width: 274px;}
|
||||
.laydate-theme-molv .layui-laydate-header{border: none; background-color: #009688;}
|
||||
.laydate-theme-molv .layui-laydate-header i,
|
||||
.laydate-theme-molv .layui-laydate-header span{color: #f6f6f6;}
|
||||
.laydate-theme-molv .layui-laydate-header i:hover,
|
||||
.laydate-theme-molv .layui-laydate-header span:hover{color: #fff;}
|
||||
.laydate-theme-molv .layui-laydate-content{border: 1px solid #e2e2e2; border-top: none; border-bottom: none;}
|
||||
.laydate-theme-molv .laydate-main-list-1 .layui-laydate-content{border-left: none;}
|
||||
.laydate-theme-molv .layui-laydate-footer{border: 1px solid #e2e2e2;}
|
||||
|
||||
/* 格子主题 */
|
||||
.laydate-theme-grid .layui-laydate-content td,
|
||||
.laydate-theme-grid .layui-laydate-content thead,
|
||||
.laydate-theme-grid .laydate-year-list>li,
|
||||
.laydate-theme-grid .laydate-month-list>li{border: 1px solid #e2e2e2;}
|
||||
.laydate-theme-grid .laydate-selected,
|
||||
.laydate-theme-grid .laydate-selected:hover{background-color: #f2f2f2 !important; color: #009688 !important;}
|
||||
.laydate-theme-grid .laydate-selected.laydate-day-prev,
|
||||
.laydate-theme-grid .laydate-selected.laydate-day-next{color: #d2d2d2 !important;}
|
||||
.laydate-theme-grid .laydate-year-list,
|
||||
.laydate-theme-grid .laydate-month-list{margin: 1px 0 0 1px;}
|
||||
.laydate-theme-grid .laydate-year-list>li,
|
||||
.laydate-theme-grid .laydate-month-list>li{margin: 0 -1px -1px 0;}
|
||||
.laydate-theme-grid .laydate-year-list>li{height: 43px; line-height: 43px;}
|
||||
.laydate-theme-grid .laydate-month-list>li{height: 71px; line-height: 71px;}
|
||||
|
After Width: | Height: | Size: 5.8 KiB |
After Width: | Height: | Size: 11 KiB |
@ -0,0 +1,179 @@
|
||||
/**
|
||||
|
||||
@Name: layer
|
||||
|
||||
**/
|
||||
|
||||
/* *html{background-image: url(about:blank); background-attachment: fixed;} */
|
||||
html #layuicss-layer{display: none; position: absolute; width: 1989px;}
|
||||
|
||||
/* common */
|
||||
.layui-layer-shade, .layui-layer{position:fixed; _position:absolute; pointer-events: auto;}
|
||||
.layui-layer-shade{top:0; left:0; width:100%; height:100%; _height:expression(document.body.offsetHeight+"px");}
|
||||
.layui-layer{-webkit-overflow-scrolling: touch;}
|
||||
.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);}
|
||||
.layui-layer-close{position:absolute;}
|
||||
.layui-layer-content{position:relative;}
|
||||
.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);}
|
||||
.layui-layer-load{background:url(loading-1.gif) #eee center center no-repeat;}
|
||||
.layui-layer-ico{ background:url(icon.png) no-repeat;}
|
||||
.layui-layer-dialog .layui-layer-ico,
|
||||
.layui-layer-setwin a,
|
||||
.layui-layer-btn a{display:inline-block; *display:inline; *zoom:1; vertical-align:top;}
|
||||
|
||||
.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;}
|
||||
.layui-layer-resize{position: absolute; width: 15px; height: 15px; right: 0; bottom: 0; cursor: se-resize;}
|
||||
|
||||
/* 动画 */
|
||||
.layer-anim{-webkit-animation-fill-mode: both; animation-fill-mode: both; -webkit-animation-duration:.3s; animation-duration:.3s;}
|
||||
|
||||
@-webkit-keyframes layer-bounceIn { /* 默认 */
|
||||
0% {opacity: 0; -webkit-transform: scale(.5); transform: scale(.5)}
|
||||
100% {opacity: 1; -webkit-transform: scale(1); transform: scale(1)}
|
||||
}
|
||||
@keyframes layer-bounceIn {
|
||||
0% {opacity: 0; -webkit-transform: scale(.5); -ms-transform: scale(.5); transform: scale(.5)}
|
||||
100% {opacity: 1; -webkit-transform: scale(1); -ms-transform: scale(1); transform: scale(1)}
|
||||
}
|
||||
.layer-anim-00{-webkit-animation-name: layer-bounceIn;animation-name: layer-bounceIn}
|
||||
|
||||
@-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}
|
||||
|
||||
@-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}
|
||||
|
||||
@-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}
|
||||
|
||||
@-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}
|
||||
|
||||
@keyframes layer-fadeIn{0%{opacity:0}100%{opacity:1}}.layer-anim-05{-webkit-animation-name:layer-fadeIn;animation-name:layer-fadeIn}
|
||||
|
||||
@-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}}
|
||||
|
||||
/* 标题栏 */
|
||||
.layui-layer-title{padding:0 80px 0 20px; height: 50px; line-height: 50px; border-bottom:1px solid #F0F0F0; font-size: 14px; color:#333; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-radius: 2px 2px 0 0;}
|
||||
.layui-layer-setwin{position:absolute; right: 15px; *right:0; top: 17px; font-size:0; line-height: initial;}
|
||||
.layui-layer-setwin a{position:relative; width: 16px; height:16px; margin-left:10px; font-size:12px; _overflow:hidden;}
|
||||
.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;}
|
||||
.layui-layer-setwin .layui-layer-min:hover cite{background-color:#2D93CA; }
|
||||
.layui-layer-setwin .layui-layer-max{background-position:-32px -40px;}
|
||||
.layui-layer-setwin .layui-layer-max:hover{background-position:-16px -40px;}
|
||||
.layui-layer-setwin .layui-layer-maxmin{background-position:-65px -40px;}
|
||||
.layui-layer-setwin .layui-layer-maxmin:hover{background-position:-49px -40px;}
|
||||
.layui-layer-setwin .layui-layer-close1{background-position: 1px -40px; cursor: pointer;}
|
||||
.layui-layer-setwin .layui-layer-close1:hover{opacity:0.7;}
|
||||
.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;}
|
||||
.layui-layer-setwin .layui-layer-close2:hover{ background-position:-180px -31px;}
|
||||
|
||||
/* 按钮栏 */
|
||||
.layui-layer-btn{text-align: right; padding: 0 15px 12px; pointer-events: auto; user-select: none; -webkit-user-select: none;}
|
||||
.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;}
|
||||
.layui-layer-btn a:hover{opacity: 0.9; text-decoration: none;}
|
||||
.layui-layer-btn a:active{opacity: 0.8;}
|
||||
.layui-layer-btn .layui-layer-btn0{border-color: #1E9FFF; background-color: #1E9FFF; color:#fff;}
|
||||
.layui-layer-btn-l{text-align: left;}
|
||||
.layui-layer-btn-c{text-align: center;}
|
||||
|
||||
/* 定制化 */
|
||||
.layui-layer-dialog{min-width: 300px;}
|
||||
.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;}
|
||||
.layui-layer-dialog .layui-layer-content .layui-layer-ico{position:absolute; top:16px; left:15px; _left:-40px; width:30px; height:30px;}
|
||||
.layui-layer-ico1{background-position:-30px 0 }
|
||||
.layui-layer-ico2{background-position:-60px 0;}
|
||||
.layui-layer-ico3{background-position:-90px 0;}
|
||||
.layui-layer-ico4{background-position:-120px 0;}
|
||||
.layui-layer-ico5{background-position:-150px 0;}
|
||||
.layui-layer-ico6{background-position:-180px 0;}
|
||||
.layui-layer-rim{border:6px solid #8D8D8D; border:6px solid rgba(0,0,0,.3); border-radius:5px; box-shadow: none;}
|
||||
.layui-layer-msg{min-width:180px; border:1px solid #D3D4D3; box-shadow: none;}
|
||||
.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;}
|
||||
.layui-layer-hui .layui-layer-content{padding:12px 25px; text-align:center;}
|
||||
.layui-layer-dialog .layui-layer-padding{padding: 20px 20px 20px 55px; text-align: left;}
|
||||
.layui-layer-page .layui-layer-content{position:relative; overflow:auto;}
|
||||
.layui-layer-page .layui-layer-btn,.layui-layer-iframe .layui-layer-btn{padding-top:10px;}
|
||||
.layui-layer-nobg{background:none;}
|
||||
.layui-layer-iframe iframe{display: block; width: 100%;}
|
||||
|
||||
.layui-layer-loading{border-radius:100%; background:none; box-shadow:none; border:none;}
|
||||
.layui-layer-loading .layui-layer-content{width:60px; height:24px; background:url(loading-0.gif) no-repeat;}
|
||||
.layui-layer-loading .layui-layer-loading1{width:37px; height:37px; background:url(loading-1.gif) no-repeat;}
|
||||
.layui-layer-loading .layui-layer-loading2, .layui-layer-ico16{width:32px; height:32px; background:url(loading-2.gif) no-repeat;}
|
||||
.layui-layer-tips{background: none; box-shadow:none; border:none;}
|
||||
.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;}
|
||||
.layui-layer-tips .layui-layer-close{right:-2px; top:-1px;}
|
||||
.layui-layer-tips i.layui-layer-TipsG{ position:absolute; width:0; height:0; border-width:8px; border-color:transparent; border-style:dashed; *overflow:hidden;}
|
||||
.layui-layer-tips i.layui-layer-TipsT, .layui-layer-tips i.layui-layer-TipsB{left:5px; border-right-style:solid; border-right-color: #000;}
|
||||
.layui-layer-tips i.layui-layer-TipsT{bottom:-8px;}
|
||||
.layui-layer-tips i.layui-layer-TipsB{top:-8px;}
|
||||
.layui-layer-tips i.layui-layer-TipsR, .layui-layer-tips i.layui-layer-TipsL{top: 5px; border-bottom-style:solid; border-bottom-color: #000;}
|
||||
.layui-layer-tips i.layui-layer-TipsR{left:-8px;}
|
||||
.layui-layer-tips i.layui-layer-TipsL{right:-8px;}
|
||||
|
||||
/* skin */
|
||||
.layui-layer-lan[type="dialog"]{min-width:280px;}
|
||||
.layui-layer-lan .layui-layer-title{background:#4476A7; color:#fff; border: none;}
|
||||
.layui-layer-lan .layui-layer-btn{padding: 5px 10px 10px; text-align: right; border-top:1px solid #E9E7E7}
|
||||
.layui-layer-lan .layui-layer-btn a{background: #fff; border-color: #E9E7E7; color: #333;}
|
||||
.layui-layer-lan .layui-layer-btn .layui-layer-btn1{background:#C9C5C5;}
|
||||
.layui-layer-molv .layui-layer-title{background: #009f95; color:#fff; border: none;}
|
||||
.layui-layer-molv .layui-layer-btn a{background: #009f95; border-color: #009f95;}
|
||||
.layui-layer-molv .layui-layer-btn .layui-layer-btn1{background:#92B8B1;}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@Name: layer拓展样式
|
||||
|
||||
*/
|
||||
|
||||
.layui-layer-iconext{background:url(icon-ext.png) no-repeat;}
|
||||
|
||||
/* prompt模式 */
|
||||
.layui-layer-prompt .layui-layer-input{display: block; width: 260px; height: 36px; margin: 0 auto; line-height: 30px; padding-left: 10px; border: 1px solid #e6e6e6; color: #333;}
|
||||
.layui-layer-prompt textarea.layui-layer-input{width: 300px; height: 100px; line-height: 20px; padding: 6px 10px;}
|
||||
.layui-layer-prompt .layui-layer-content{padding: 20px;}
|
||||
.layui-layer-prompt .layui-layer-btn{padding-top: 0;}
|
||||
|
||||
/* tab模式 */
|
||||
.layui-layer-tab{box-shadow:1px 1px 50px rgba(0,0,0,.4);}
|
||||
.layui-layer-tab .layui-layer-title{padding-left:0; overflow: visible;}
|
||||
.layui-layer-tab .layui-layer-title span{position:relative; float:left; min-width:80px; max-width: 300px; padding:0 20px; text-align:center; cursor:default; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; cursor: pointer;}
|
||||
.layui-layer-tab .layui-layer-title span.layui-this{height: 51px; border-left: 1px solid #eee; border-right: 1px solid #eee; background-color: #fff; z-index: 10;}
|
||||
.layui-layer-tab .layui-layer-title span:first-child{border-left:none;}
|
||||
.layui-layer-tabmain{line-height:24px; clear:both;}
|
||||
.layui-layer-tabmain .layui-layer-tabli{display:none;}
|
||||
.layui-layer-tabmain .layui-layer-tabli.layui-this{display: block;}
|
||||
|
||||
/* photo模式 */
|
||||
.layui-layer-photos{background: none; box-shadow: none;}
|
||||
.layui-layer-photos .layui-layer-content{overflow:hidden; text-align: center;}
|
||||
.layui-layer-photos .layui-layer-phimg img{position: relative; width:100%; display: inline-block; *display:inline; *zoom:1; vertical-align:top;}
|
||||
.layui-layer-imgprev, .layui-layer-imgnext{position: fixed; top: 50%; width: 27px; _width: 44px; height: 44px; margin-top:-22px; outline:none;blr:expression(this.onFocus=this.blur());}
|
||||
.layui-layer-imgprev{left: 30px; background-position:-5px -5px; _background-position:-70px -5px;}
|
||||
.layui-layer-imgprev:hover{background-position:-33px -5px; _background-position:-120px -5px;}
|
||||
.layui-layer-imgnext{right: 30px; _right:8px; background-position:-5px -50px; _background-position:-70px -50px;}
|
||||
.layui-layer-imgnext:hover{background-position: -33px -50px; _background-position: -120px -50px;}
|
||||
.layui-layer-imgbar{position: fixed; left:0; right: 0; bottom:0; width:100%; height: 40px; line-height: 40px; background-color:#000\9; filter:Alpha(opacity=60); background-color: rgba(2,0,0,.35); color: #fff; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; font-size:0;}
|
||||
.layui-layer-imgtit{/*position:absolute; left:20px;*/}
|
||||
.layui-layer-imgtit *{display:inline-block; *display:inline; *zoom:1; vertical-align:top; font-size:12px;}
|
||||
.layui-layer-imgtit a{max-width:65%; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; color:#fff;}
|
||||
.layui-layer-imgtit a:hover{color:#fff; text-decoration:underline;}
|
||||
.layui-layer-imgtit em{padding-left:10px; font-style: normal;}
|
||||
|
||||
/* 关闭动画 */
|
||||
@-webkit-keyframes layer-bounceOut {
|
||||
100% {opacity: 0; -webkit-transform: scale(.7); transform: scale(.7)}
|
||||
30% {-webkit-transform: scale(1.05); transform: scale(1.05)}
|
||||
0% {-webkit-transform: scale(1); transform: scale(1);}
|
||||
}
|
||||
@keyframes layer-bounceOut {
|
||||
100% {opacity: 0; -webkit-transform: scale(.7); -ms-transform: scale(.7); transform: scale(.7);}
|
||||
30% {-webkit-transform: scale(1.05); -ms-transform: scale(1.05); transform: scale(1.05);}
|
||||
0% {-webkit-transform: scale(1); -ms-transform: scale(1);transform: scale(1);}
|
||||
}
|
||||
.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;}
|
||||
|
||||
@media screen and (max-width: 1100px) {
|
||||
.layui-layer-iframe{overflow-y: auto; -webkit-overflow-scrolling: touch;}
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 5.7 KiB |
After Width: | Height: | Size: 701 B |
After Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
After Width: | Height: | Size: 299 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,59 @@
|
||||
|
||||
/**
|
||||
* code 代码修饰器
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
layui.define('jquery', function(exports){
|
||||
"use strict";
|
||||
|
||||
var $ = layui.$;
|
||||
|
||||
exports('code', function(options){
|
||||
var elems = [];
|
||||
options = options || {};
|
||||
options.elem = $(options.elem||'.layui-code');
|
||||
options.lang = 'lang' in options ? options.lang : 'code';
|
||||
|
||||
options.elem.each(function(){
|
||||
elems.push(this);
|
||||
});
|
||||
|
||||
layui.each(elems.reverse(), function(index, item){
|
||||
var othis = $(item), html = othis.html();
|
||||
|
||||
//转义HTML标签
|
||||
if(othis.attr('lay-encode') || options.encode){
|
||||
html = html.replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&')
|
||||
.replace(/</g, '<').replace(/>/g, '>').replace(/'/g, ''').replace(/"/g, '"')
|
||||
}
|
||||
|
||||
othis.html('<ol class="layui-code-ol"><li>' + html.replace(/[\r\t\n]+/g, '</li><li>') + '</li></ol>')
|
||||
|
||||
if(!othis.find('>.layui-code-h3')[0]){
|
||||
othis.prepend('<h3 class="layui-code-h3">'+ (othis.attr('lay-title')||options.title||'</>') + '<a href="javascript:;">'+ (othis.attr('lay-lang')||options.lang||'') +'</a>' + '</h3>');
|
||||
}
|
||||
|
||||
var ol = othis.find('>.layui-code-ol');
|
||||
othis.addClass('layui-box layui-code-view');
|
||||
|
||||
//识别皮肤
|
||||
if(othis.attr('lay-skin') || options.skin){
|
||||
othis.addClass('layui-code-' +(othis.attr('lay-skin') || options.skin));
|
||||
}
|
||||
|
||||
//按行数适配左边距
|
||||
if((ol.find('li').length/100|0) > 0){
|
||||
ol.css('margin-left', (ol.find('li').length/100|0) + 'px');
|
||||
}
|
||||
|
||||
//设置最大高度
|
||||
if(othis.attr('lay-height') || options.height){
|
||||
ol.css('max-height', othis.attr('lay-height') || options.height);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
}).addcss('modules/code.css?v=2', 'skincodecss');
|
||||
|
@ -0,0 +1,691 @@
|
||||
|
||||
/*!
|
||||
* colorpicker
|
||||
* 颜色选择组件
|
||||
*/
|
||||
|
||||
layui.define(['jquery', 'lay'], function(exports){
|
||||
"use strict";
|
||||
|
||||
var $ = layui.jquery
|
||||
,lay = layui.lay
|
||||
,device = layui.device()
|
||||
,clickOrMousedown = (device.mobile ? 'click' : 'mousedown')
|
||||
|
||||
//外部接口
|
||||
,colorpicker = {
|
||||
config: {}
|
||||
,index: layui.colorpicker ? (layui.colorpicker.index + 10000) : 0
|
||||
|
||||
//设置全局项
|
||||
,set: function(options){
|
||||
var that = this;
|
||||
that.config = $.extend({}, that.config, options);
|
||||
return that;
|
||||
}
|
||||
|
||||
//事件
|
||||
,on: function(events, callback){
|
||||
return layui.onevent.call(this, 'colorpicker', events, callback);
|
||||
}
|
||||
}
|
||||
|
||||
//操作当前实例
|
||||
,thisColorPicker = function(){
|
||||
var that = this
|
||||
,options = that.config;
|
||||
|
||||
return {
|
||||
config: options
|
||||
}
|
||||
}
|
||||
|
||||
//字符常量
|
||||
,MOD_NAME = 'colorpicker', SHOW = 'layui-show', THIS = 'layui-this', ELEM = 'layui-colorpicker'
|
||||
|
||||
,ELEM_MAIN = '.layui-colorpicker-main', ICON_PICKER_DOWN = 'layui-icon-down', ICON_PICKER_CLOSE = 'layui-icon-close'
|
||||
,PICKER_TRIG_SPAN = 'layui-colorpicker-trigger-span', PICKER_TRIG_I = 'layui-colorpicker-trigger-i', PICKER_SIDE = 'layui-colorpicker-side', PICKER_SIDE_SLIDER = 'layui-colorpicker-side-slider'
|
||||
,PICKER_BASIS = 'layui-colorpicker-basis', PICKER_ALPHA_BG = 'layui-colorpicker-alpha-bgcolor', PICKER_ALPHA_SLIDER = 'layui-colorpicker-alpha-slider', PICKER_BASIS_CUR = 'layui-colorpicker-basis-cursor', PICKER_INPUT = 'layui-colorpicker-main-input'
|
||||
|
||||
//RGB转HSB
|
||||
,RGBToHSB = function(rgb){
|
||||
var hsb = {h:0, s:0, b:0};
|
||||
var min = Math.min(rgb.r, rgb.g, rgb.b);
|
||||
var max = Math.max(rgb.r, rgb.g, rgb.b);
|
||||
var delta = max - min;
|
||||
hsb.b = max;
|
||||
hsb.s = max != 0 ? 255*delta/max : 0;
|
||||
if(hsb.s != 0){
|
||||
if(rgb.r == max){
|
||||
hsb.h = (rgb.g - rgb.b) / delta;
|
||||
}else if(rgb.g == max){
|
||||
hsb.h = 2 + (rgb.b - rgb.r) / delta;
|
||||
}else{
|
||||
hsb.h = 4 + (rgb.r - rgb.g) / delta;
|
||||
}
|
||||
}else{
|
||||
hsb.h = -1;
|
||||
};
|
||||
if(max == min){
|
||||
hsb.h = 0;
|
||||
};
|
||||
hsb.h *= 60;
|
||||
if(hsb.h < 0) {
|
||||
hsb.h += 360;
|
||||
};
|
||||
hsb.s *= 100/255;
|
||||
hsb.b *= 100/255;
|
||||
return hsb;
|
||||
}
|
||||
|
||||
//HEX转HSB
|
||||
,HEXToHSB = function(hex){
|
||||
var hex = hex.indexOf('#') > -1 ? hex.substring(1) : hex;
|
||||
if(hex.length == 3){
|
||||
var num = hex.split("");
|
||||
hex = num[0]+num[0]+num[1]+num[1]+num[2]+num[2]
|
||||
};
|
||||
hex = parseInt(hex, 16);
|
||||
var rgb = {r:hex >> 16, g:(hex & 0x00FF00) >> 8, b:(hex & 0x0000FF)};
|
||||
return RGBToHSB(rgb);
|
||||
}
|
||||
|
||||
//HSB转RGB
|
||||
,HSBToRGB = function(hsb){
|
||||
var rgb = {};
|
||||
var h = hsb.h;
|
||||
var s = hsb.s*255/100;
|
||||
var b = hsb.b*255/100;
|
||||
if(s == 0){
|
||||
rgb.r = rgb.g = rgb.b = b;
|
||||
}else{
|
||||
var t1 = b;
|
||||
var t2 = (255 - s) * b /255;
|
||||
var t3 = (t1 - t2) * (h % 60) /60;
|
||||
if(h == 360) h = 0;
|
||||
if(h < 60) {rgb.r=t1; rgb.b=t2; rgb.g=t2+t3}
|
||||
else if(h < 120) {rgb.g=t1; rgb.b=t2; rgb.r=t1-t3}
|
||||
else if(h < 180) {rgb.g=t1; rgb.r=t2; rgb.b=t2+t3}
|
||||
else if(h < 240) {rgb.b=t1; rgb.r=t2; rgb.g=t1-t3}
|
||||
else if(h < 300) {rgb.b=t1; rgb.g=t2; rgb.r=t2+t3}
|
||||
else if(h < 360) {rgb.r=t1; rgb.g=t2; rgb.b=t1-t3}
|
||||
else {rgb.r=0; rgb.g=0; rgb.b=0}
|
||||
}
|
||||
return {r:Math.round(rgb.r), g:Math.round(rgb.g), b:Math.round(rgb.b)};
|
||||
}
|
||||
|
||||
//HSB转HEX
|
||||
,HSBToHEX = function(hsb){
|
||||
var rgb = HSBToRGB(hsb);
|
||||
var hex = [
|
||||
rgb.r.toString(16)
|
||||
,rgb.g.toString(16)
|
||||
,rgb.b.toString(16)
|
||||
];
|
||||
$.each(hex, function(nr, val){
|
||||
if(val.length == 1){
|
||||
hex[nr] = '0' + val;
|
||||
}
|
||||
});
|
||||
return hex.join('');
|
||||
}
|
||||
|
||||
//转化成所需rgb格式
|
||||
,RGBSTo = function(rgbs){
|
||||
var regexp = /[0-9]{1,3}/g;
|
||||
var re = rgbs.match(regexp) || [];
|
||||
return {r:re[0], g:re[1], b:re[2]};
|
||||
}
|
||||
|
||||
,$win = $(window)
|
||||
,$doc = $(document)
|
||||
|
||||
//构造器
|
||||
,Class = function(options){
|
||||
var that = this;
|
||||
that.index = ++colorpicker.index;
|
||||
that.config = $.extend({}, that.config, colorpicker.config, options);
|
||||
that.render();
|
||||
};
|
||||
|
||||
//默认配置
|
||||
Class.prototype.config = {
|
||||
color: '' //默认颜色,默认没有
|
||||
,size: null //选择器大小
|
||||
,alpha: false //是否开启透明度
|
||||
,format: 'hex' //颜色显示/输入格式,可选 rgb,hex
|
||||
,predefine: false //预定义颜色是否开启
|
||||
,colors: [ //默认预定义颜色列表
|
||||
'#009688', '#5FB878', '#1E9FFF', '#FF5722', '#FFB800', '#01AAED', '#999', '#c00', '#ff8c00','#ffd700'
|
||||
,'#90ee90', '#00ced1', '#1e90ff', '#c71585', 'rgb(0, 186, 189)', 'rgb(255, 120, 0)', 'rgb(250, 212, 0)', '#393D49', 'rgba(0,0,0,.5)', 'rgba(255, 69, 0, 0.68)', 'rgba(144, 240, 144, 0.5)', 'rgba(31, 147, 255, 0.73)'
|
||||
]
|
||||
};
|
||||
|
||||
//初始颜色选择框
|
||||
Class.prototype.render = function(){
|
||||
var that = this
|
||||
,options = that.config
|
||||
|
||||
//颜色选择框对象
|
||||
,elemColorBox = $(['<div class="layui-unselect layui-colorpicker">'
|
||||
,'<span '+ (options.format == 'rgb' && options.alpha
|
||||
? 'class="layui-colorpicker-trigger-bgcolor"'
|
||||
: '') +'>'
|
||||
,'<span class="layui-colorpicker-trigger-span" '
|
||||
,'lay-type="'+ (options.format == 'rgb' ? (options.alpha ? 'rgba' : 'torgb') : '') +'" '
|
||||
,'style="'+ function(){
|
||||
var bgstr = '';
|
||||
if(options.color){
|
||||
bgstr = options.color;
|
||||
|
||||
if((options.color.match(/[0-9]{1,3}/g) || []).length > 3){ //需要优化
|
||||
if(!(options.alpha && options.format == 'rgb')){
|
||||
bgstr = '#' + HSBToHEX(RGBToHSB(RGBSTo(options.color)))
|
||||
}
|
||||
}
|
||||
|
||||
return 'background: '+ bgstr;
|
||||
}
|
||||
|
||||
return bgstr;
|
||||
}() +'">'
|
||||
,'<i class="layui-icon layui-colorpicker-trigger-i '+ (options.color
|
||||
? ICON_PICKER_DOWN
|
||||
: ICON_PICKER_CLOSE) +'"></i>'
|
||||
,'</span>'
|
||||
,'</span>'
|
||||
,'</div>'].join(''))
|
||||
|
||||
//初始化颜色选择框
|
||||
var othis = $(options.elem);
|
||||
options.size && elemColorBox.addClass('layui-colorpicker-'+ options.size); //初始化颜色选择框尺寸
|
||||
|
||||
//插入颜色选择框
|
||||
othis.addClass('layui-inline').html(
|
||||
that.elemColorBox = elemColorBox
|
||||
);
|
||||
|
||||
//获取背景色值
|
||||
that.color = that.elemColorBox.find('.'+ PICKER_TRIG_SPAN)[0].style.background;
|
||||
|
||||
//相关事件
|
||||
that.events();
|
||||
};
|
||||
|
||||
//渲染颜色选择器
|
||||
Class.prototype.renderPicker = function(){
|
||||
var that = this
|
||||
,options = that.config
|
||||
,elemColorBox = that.elemColorBox[0]
|
||||
|
||||
//颜色选择器对象
|
||||
,elemPicker = that.elemPicker = $(['<div id="layui-colorpicker'+ that.index +'" data-index="'+ that.index +'" class="layui-anim layui-anim-downbit layui-colorpicker-main">'
|
||||
//颜色面板
|
||||
,'<div class="layui-colorpicker-main-wrapper">'
|
||||
,'<div class="layui-colorpicker-basis">'
|
||||
,'<div class="layui-colorpicker-basis-white"></div>'
|
||||
,'<div class="layui-colorpicker-basis-black"></div>'
|
||||
,'<div class="layui-colorpicker-basis-cursor"></div>'
|
||||
,'</div>'
|
||||
,'<div class="layui-colorpicker-side">'
|
||||
,'<div class="layui-colorpicker-side-slider"></div>'
|
||||
,'</div>'
|
||||
,'</div>'
|
||||
|
||||
//透明度条块
|
||||
,'<div class="layui-colorpicker-main-alpha '+ (options.alpha ? SHOW : '') +'">'
|
||||
,'<div class="layui-colorpicker-alpha-bgcolor">'
|
||||
,'<div class="layui-colorpicker-alpha-slider"></div>'
|
||||
,'</div>'
|
||||
,'</div>'
|
||||
|
||||
//预设颜色列表
|
||||
,function(){
|
||||
if(options.predefine){
|
||||
var list = ['<div class="layui-colorpicker-main-pre">'];
|
||||
layui.each(options.colors, function(i, v){
|
||||
list.push(['<div class="layui-colorpicker-pre'+ ((v.match(/[0-9]{1,3}/g) || []).length > 3
|
||||
? ' layui-colorpicker-pre-isalpha'
|
||||
: '') +'">'
|
||||
,'<div style="background:'+ v +'"></div>'
|
||||
,'</div>'].join(''));
|
||||
});
|
||||
list.push('</div>');
|
||||
return list.join('');
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}()
|
||||
|
||||
//底部表单元素区域
|
||||
,'<div class="layui-colorpicker-main-input">'
|
||||
,'<div class="layui-inline">'
|
||||
,'<input type="text" class="layui-input">'
|
||||
,'</div>'
|
||||
,'<div class="layui-btn-container">'
|
||||
,'<button class="layui-btn layui-btn-primary layui-btn-sm" colorpicker-events="clear">清空</button>'
|
||||
,'<button class="layui-btn layui-btn-sm" colorpicker-events="confirm">确定</button>'
|
||||
,'</div'
|
||||
,'</div>'
|
||||
,'</div>'].join(''))
|
||||
|
||||
,elemColorBoxSpan = that.elemColorBox.find('.' + PICKER_TRIG_SPAN)[0];
|
||||
|
||||
//如果当前点击的颜色盒子已经存在选择器,则关闭
|
||||
if($(ELEM_MAIN)[0] && $(ELEM_MAIN).data('index') == that.index){
|
||||
that.removePicker(Class.thisElemInd);
|
||||
} else { //插入颜色选择器
|
||||
that.removePicker(Class.thisElemInd);
|
||||
$('body').append(elemPicker);
|
||||
}
|
||||
|
||||
Class.thisElemInd = that.index; //记录最新打开的选择器索引
|
||||
Class.thisColor = elemColorBox.style.background //记录最新打开的选择器颜色选中值
|
||||
|
||||
that.position();
|
||||
that.pickerEvents();
|
||||
};
|
||||
|
||||
//颜色选择器移除
|
||||
Class.prototype.removePicker = function(index){
|
||||
var that = this
|
||||
,options = that.config;
|
||||
$('#layui-colorpicker'+ (index || that.index)).remove();
|
||||
return that;
|
||||
};
|
||||
|
||||
//定位算法
|
||||
Class.prototype.position = function(){
|
||||
var that = this
|
||||
,options = that.config;
|
||||
lay.position(that.bindElem || that.elemColorBox[0], that.elemPicker[0], {
|
||||
position: options.position
|
||||
,align: 'center'
|
||||
});
|
||||
return that;
|
||||
};
|
||||
|
||||
//颜色选择器赋值
|
||||
Class.prototype.val = function(){
|
||||
var that = this
|
||||
,options = that.config
|
||||
|
||||
,elemColorBox = that.elemColorBox.find('.' + PICKER_TRIG_SPAN)
|
||||
,elemPickerInput = that.elemPicker.find('.' + PICKER_INPUT)
|
||||
,e = elemColorBox[0]
|
||||
,bgcolor = e.style.backgroundColor;
|
||||
|
||||
//判断是否有背景颜色
|
||||
if(bgcolor){
|
||||
|
||||
//转化成hsb格式
|
||||
var hsb = RGBToHSB(RGBSTo(bgcolor))
|
||||
,type = elemColorBox.attr('lay-type');
|
||||
|
||||
//同步滑块的位置及颜色选择器的选择
|
||||
that.select(hsb.h, hsb.s, hsb.b);
|
||||
|
||||
//如果格式要求为rgb
|
||||
if(type === 'torgb'){
|
||||
elemPickerInput.find('input').val(bgcolor);
|
||||
};
|
||||
|
||||
//如果格式要求为rgba
|
||||
if(type === 'rgba'){
|
||||
var rgb = RGBSTo(bgcolor);
|
||||
|
||||
//如果开启透明度而没有设置,则给默认值
|
||||
if((bgcolor.match(/[0-9]{1,3}/g) || []).length == 3){
|
||||
elemPickerInput.find('input').val('rgba('+ rgb.r +', '+ rgb.g +', '+ rgb.b +', 1)');
|
||||
that.elemPicker.find('.'+ PICKER_ALPHA_SLIDER).css("left", 280);
|
||||
} else {
|
||||
elemPickerInput.find('input').val(bgcolor);
|
||||
var left = bgcolor.slice(bgcolor.lastIndexOf(",") + 1, bgcolor.length - 1) * 280;
|
||||
that.elemPicker.find('.'+ PICKER_ALPHA_SLIDER).css("left", left);
|
||||
};
|
||||
|
||||
//设置span背景色
|
||||
that.elemPicker.find('.'+ PICKER_ALPHA_BG)[0].style.background = 'linear-gradient(to right, rgba('+ rgb.r +', '+ rgb.g +', '+ rgb.b +', 0), rgb('+ rgb.r +', '+ rgb.g +', '+ rgb.b +'))';
|
||||
};
|
||||
|
||||
}else{
|
||||
//如果没有背景颜色则默认到最初始的状态
|
||||
that.select(0,100,100);
|
||||
elemPickerInput.find('input').val("");
|
||||
that.elemPicker.find('.'+ PICKER_ALPHA_BG)[0].style.background = '';
|
||||
that.elemPicker.find('.'+ PICKER_ALPHA_SLIDER).css("left", 280);
|
||||
}
|
||||
};
|
||||
|
||||
//颜色选择器滑动 / 点击
|
||||
Class.prototype.side = function(){
|
||||
var that = this
|
||||
,options = that.config
|
||||
|
||||
,span = that.elemColorBox.find('.' + PICKER_TRIG_SPAN)
|
||||
,type = span.attr('lay-type')
|
||||
|
||||
,side = that.elemPicker.find('.' + PICKER_SIDE)
|
||||
,slider = that.elemPicker.find('.' + PICKER_SIDE_SLIDER)
|
||||
,basis = that.elemPicker.find('.' + PICKER_BASIS)
|
||||
,choose = that.elemPicker.find('.' + PICKER_BASIS_CUR)
|
||||
,alphacolor = that.elemPicker.find('.' + PICKER_ALPHA_BG)
|
||||
,alphaslider = that.elemPicker.find('.' + PICKER_ALPHA_SLIDER)
|
||||
|
||||
,_h = slider[0].offsetTop/180*360
|
||||
,_b = 100 - (choose[0].offsetTop + 3)/180*100
|
||||
,_s = (choose[0].offsetLeft + 3)/260*100
|
||||
,_a = Math.round(alphaslider[0].offsetLeft/280*100)/100
|
||||
|
||||
,i = that.elemColorBox.find('.' + PICKER_TRIG_I)
|
||||
,pre = that.elemPicker.find('.layui-colorpicker-pre').children('div')
|
||||
|
||||
,change = function(x,y,z,a){
|
||||
that.select(x, y, z);
|
||||
var rgb = HSBToRGB({h:x, s:y, b:z});
|
||||
i.addClass(ICON_PICKER_DOWN).removeClass(ICON_PICKER_CLOSE);
|
||||
span[0].style.background = 'rgb('+ rgb.r +', '+ rgb.g +', '+ rgb.b +')';
|
||||
|
||||
if(type === 'torgb'){
|
||||
that.elemPicker.find('.' + PICKER_INPUT).find('input').val('rgb('+ rgb.r +', '+ rgb.g +', '+ rgb.b +')');
|
||||
};
|
||||
|
||||
if(type === 'rgba'){
|
||||
var left = 0;
|
||||
left = a * 280;
|
||||
alphaslider.css("left", left);
|
||||
that.elemPicker.find('.' + PICKER_INPUT).find('input').val('rgba('+ rgb.r +', '+ rgb.g +', '+ rgb.b +', '+ a +')');
|
||||
span[0].style.background = 'rgba('+ rgb.r +', '+ rgb.g +', '+ rgb.b +', '+ a +')';
|
||||
alphacolor[0].style.background = 'linear-gradient(to right, rgba('+ rgb.r +', '+ rgb.g +', '+ rgb.b +', 0), rgb('+ rgb.r +', '+ rgb.g +', '+ rgb.b +'))'
|
||||
};
|
||||
|
||||
//回调更改的颜色
|
||||
options.change && options.change(that.elemPicker.find('.' + PICKER_INPUT).find('input').val());
|
||||
}
|
||||
|
||||
//拖拽元素
|
||||
,elemMove = $(['<div class="layui-auxiliar-moving" id="LAY-colorpicker-moving"></div>'].join(''))
|
||||
,createMoveElem = function(call){
|
||||
$('#LAY-colorpicker-moving')[0] || $('body').append(elemMove);
|
||||
elemMove.on('mousemove', call);
|
||||
elemMove.on('mouseup', function(){
|
||||
elemMove.remove();
|
||||
}).on('mouseleave', function(){
|
||||
elemMove.remove();
|
||||
});
|
||||
};
|
||||
|
||||
//右侧主色选择
|
||||
slider.on('mousedown', function(e){
|
||||
var oldtop = this.offsetTop
|
||||
,oldy = e.clientY;
|
||||
var move = function(e){
|
||||
var top = oldtop + (e.clientY - oldy)
|
||||
,maxh = side[0].offsetHeight;
|
||||
if(top < 0)top = 0;
|
||||
if(top > maxh)top = maxh;
|
||||
var h = top/180*360;
|
||||
_h = h;
|
||||
change(h, _s, _b, _a);
|
||||
e.preventDefault();
|
||||
};
|
||||
|
||||
createMoveElem(move);
|
||||
//layui.stope(e);
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
side.on('click', function(e){
|
||||
var top = e.clientY - $(this).offset().top;
|
||||
if(top < 0)top = 0;
|
||||
if(top > this.offsetHeight)top = this.offsetHeight;
|
||||
var h = top/180*360;
|
||||
_h = h;
|
||||
change(h, _s, _b, _a);
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
//中间小圆点颜色选择
|
||||
choose.on('mousedown', function(e){
|
||||
var oldtop = this.offsetTop
|
||||
,oldleft = this.offsetLeft
|
||||
,oldy = e.clientY
|
||||
,oldx = e.clientX;
|
||||
var move = function(e){
|
||||
var top = oldtop + (e.clientY - oldy)
|
||||
,left = oldleft + (e.clientX - oldx)
|
||||
,maxh = basis[0].offsetHeight - 3
|
||||
,maxw = basis[0].offsetWidth - 3;
|
||||
if(top < -3)top = -3;
|
||||
if(top > maxh)top = maxh;
|
||||
if(left < -3)left = -3;
|
||||
if(left > maxw)left = maxw;
|
||||
var s = (left + 3)/260*100
|
||||
,b = 100 - (top + 3)/180*100;
|
||||
_b = b;
|
||||
_s = s;
|
||||
change(_h, s, b, _a);
|
||||
e.preventDefault();
|
||||
};
|
||||
layui.stope(e);
|
||||
createMoveElem(move);
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
basis.on('mousedown', function(e){
|
||||
var top = e.clientY - $(this).offset().top - 3 + $win.scrollTop()
|
||||
,left = e.clientX - $(this).offset().left - 3 + $win.scrollLeft()
|
||||
if(top < -3)top = -3;
|
||||
if(top > this.offsetHeight - 3)top = this.offsetHeight - 3;
|
||||
if(left < -3)left = -3;
|
||||
if(left > this.offsetWidth - 3)left = this.offsetWidth - 3;
|
||||
var s = (left + 3)/260*100
|
||||
,b = 100 - (top + 3)/180*100;
|
||||
_b = b;
|
||||
_s = s;
|
||||
change(_h, s, b, _a);
|
||||
layui.stope(e);
|
||||
e.preventDefault();
|
||||
choose.trigger(e, 'mousedown');
|
||||
});
|
||||
|
||||
//底部透明度选择
|
||||
alphaslider.on('mousedown', function(e){
|
||||
var oldleft = this.offsetLeft
|
||||
,oldx = e.clientX;
|
||||
var move = function(e){
|
||||
var left = oldleft + (e.clientX - oldx)
|
||||
,maxw = alphacolor[0].offsetWidth;
|
||||
if(left < 0)left = 0;
|
||||
if(left > maxw)left = maxw;
|
||||
var a = Math.round(left /280*100) /100;
|
||||
_a = a;
|
||||
change(_h, _s, _b, a);
|
||||
e.preventDefault();
|
||||
};
|
||||
|
||||
createMoveElem(move);
|
||||
e.preventDefault();
|
||||
});
|
||||
alphacolor.on('click', function(e){
|
||||
var left = e.clientX - $(this).offset().left
|
||||
if(left < 0)left = 0;
|
||||
if(left > this.offsetWidth)left = this.offsetWidth;
|
||||
var a = Math.round(left /280*100) /100;
|
||||
_a = a;
|
||||
change(_h, _s, _b, a);
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
//预定义颜色选择
|
||||
pre.each(function(){
|
||||
$(this).on('click', function(){
|
||||
$(this).parent('.layui-colorpicker-pre').addClass('selected').siblings().removeClass('selected');
|
||||
var color = this.style.backgroundColor
|
||||
,hsb = RGBToHSB(RGBSTo(color))
|
||||
,a = color.slice(color.lastIndexOf(",") + 1, color.length - 1),left;
|
||||
_h = hsb.h;
|
||||
_s = hsb.s;
|
||||
_b = hsb.b;
|
||||
if((color.match(/[0-9]{1,3}/g) || []).length == 3) a = 1;
|
||||
_a = a;
|
||||
left = a * 280;
|
||||
change(hsb.h, hsb.s, hsb.b, a);
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
//颜色选择器hsb转换
|
||||
Class.prototype.select = function(h, s, b, type){
|
||||
var that = this
|
||||
,options = that.config
|
||||
,hex = HSBToHEX({h:h, s:100, b:100})
|
||||
,color = HSBToHEX({h:h, s:s, b:b})
|
||||
,sidetop = h/360*180
|
||||
,top = 180 - b/100*180 - 3
|
||||
,left = s/100*260 - 3;
|
||||
|
||||
that.elemPicker.find('.' + PICKER_SIDE_SLIDER).css("top", sidetop); //滑块的top
|
||||
that.elemPicker.find('.' + PICKER_BASIS)[0].style.background = '#' + hex; //颜色选择器的背景
|
||||
|
||||
//选择器的top left
|
||||
that.elemPicker.find('.' + PICKER_BASIS_CUR).css({
|
||||
"top": top
|
||||
,"left": left
|
||||
});
|
||||
|
||||
if(type === 'change') return;
|
||||
|
||||
//选中的颜色
|
||||
that.elemPicker.find('.' + PICKER_INPUT).find('input').val('#' + color);
|
||||
};
|
||||
|
||||
Class.prototype.pickerEvents = function(){
|
||||
var that = this
|
||||
,options = that.config
|
||||
|
||||
,elemColorBoxSpan = that.elemColorBox.find('.' + PICKER_TRIG_SPAN) //颜色盒子
|
||||
,elemPickerInput = that.elemPicker.find('.' + PICKER_INPUT + ' input') //颜色选择器表单
|
||||
|
||||
,pickerEvents = {
|
||||
//清空
|
||||
clear: function(othis){
|
||||
elemColorBoxSpan[0].style.background ='';
|
||||
that.elemColorBox.find('.' + PICKER_TRIG_I).removeClass(ICON_PICKER_DOWN).addClass(ICON_PICKER_CLOSE);
|
||||
that.color = '';
|
||||
|
||||
options.done && options.done('');
|
||||
that.removePicker();
|
||||
}
|
||||
|
||||
//确认
|
||||
,confirm: function(othis, change){
|
||||
var value = elemPickerInput.val()
|
||||
,colorValue = value
|
||||
,hsb = {};
|
||||
|
||||
if(value.indexOf(',') > -1){
|
||||
hsb = RGBToHSB(RGBSTo(value));
|
||||
that.select(hsb.h, hsb.s, hsb.b);
|
||||
elemColorBoxSpan[0].style.background = (colorValue = '#' + HSBToHEX(hsb));
|
||||
|
||||
if((value.match(/[0-9]{1,3}/g) || []).length > 3 && elemColorBoxSpan.attr('lay-type') === 'rgba'){
|
||||
var left = value.slice(value.lastIndexOf(",") + 1, value.length - 1) * 280;
|
||||
that.elemPicker.find('.' + PICKER_ALPHA_SLIDER).css("left", left);
|
||||
elemColorBoxSpan[0].style.background = value;
|
||||
colorValue = value;
|
||||
};
|
||||
} else {
|
||||
hsb = HEXToHSB(value);
|
||||
elemColorBoxSpan[0].style.background = (colorValue = '#' + HSBToHEX(hsb));
|
||||
that.elemColorBox.find('.' + PICKER_TRIG_I).removeClass(ICON_PICKER_CLOSE).addClass(ICON_PICKER_DOWN);
|
||||
};
|
||||
|
||||
if(change === 'change'){
|
||||
that.select(hsb.h, hsb.s, hsb.b, change);
|
||||
options.change && options.change(colorValue);
|
||||
return;
|
||||
}
|
||||
that.color = value;
|
||||
|
||||
options.done && options.done(value);
|
||||
that.removePicker();
|
||||
}
|
||||
};
|
||||
|
||||
//选择器面板点击事件
|
||||
that.elemPicker.on('click', '*[colorpicker-events]', function(){
|
||||
var othis = $(this)
|
||||
,attrEvent = othis.attr('colorpicker-events');
|
||||
pickerEvents[attrEvent] && pickerEvents[attrEvent].call(this, othis);
|
||||
});
|
||||
|
||||
//输入框事件
|
||||
elemPickerInput.on('keyup', function(e){
|
||||
var othis = $(this)
|
||||
pickerEvents.confirm.call(this, othis, e.keyCode === 13 ? null : 'change');
|
||||
});
|
||||
}
|
||||
|
||||
//颜色选择器输入
|
||||
Class.prototype.events = function(){
|
||||
var that = this
|
||||
,options = that.config
|
||||
|
||||
,elemColorBoxSpan = that.elemColorBox.find('.' + PICKER_TRIG_SPAN)
|
||||
|
||||
//弹出颜色选择器
|
||||
that.elemColorBox.on('click' , function(){
|
||||
that.renderPicker();
|
||||
if($(ELEM_MAIN)[0]){
|
||||
that.val();
|
||||
that.side();
|
||||
};
|
||||
});
|
||||
|
||||
if(!options.elem[0] || that.elemColorBox[0].eventHandler) return;
|
||||
|
||||
//绑定关闭控件事件
|
||||
$doc.on(clickOrMousedown, function(e){
|
||||
//如果点击的元素是颜色框
|
||||
if($(e.target).hasClass(ELEM)
|
||||
|| $(e.target).parents('.'+ELEM)[0]
|
||||
) return;
|
||||
|
||||
//如果点击的元素是选择器
|
||||
if($(e.target).hasClass(ELEM_MAIN.replace(/\./g, ''))
|
||||
|| $(e.target).parents(ELEM_MAIN)[0]
|
||||
) return;
|
||||
|
||||
if(!that.elemPicker) return;
|
||||
|
||||
if(that.color){
|
||||
var hsb = RGBToHSB(RGBSTo(that.color));
|
||||
that.select(hsb.h, hsb.s, hsb.b);
|
||||
} else {
|
||||
that.elemColorBox.find('.' + PICKER_TRIG_I).removeClass(ICON_PICKER_DOWN).addClass(ICON_PICKER_CLOSE);
|
||||
}
|
||||
elemColorBoxSpan[0].style.background = that.color || '';
|
||||
|
||||
that.removePicker();
|
||||
});
|
||||
|
||||
//自适应定位
|
||||
$win.on('resize', function(){
|
||||
if(!that.elemPicker || !$(ELEM_MAIN)[0]){
|
||||
return false;
|
||||
}
|
||||
that.position();
|
||||
});
|
||||
|
||||
that.elemColorBox[0].eventHandler = true;
|
||||
};
|
||||
|
||||
//核心入口
|
||||
colorpicker.render = function(options){
|
||||
var inst = new Class(options);
|
||||
return thisColorPicker.call(inst);
|
||||
};
|
||||
|
||||
exports(MOD_NAME, colorpicker);
|
||||
});
|
@ -0,0 +1,135 @@
|
||||
|
||||
/*!
|
||||
* MODULE_DEMO_NAME 模块组件通用结构
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
layui.define([''], function(exports){
|
||||
"use strict";
|
||||
|
||||
var $ = layui.$
|
||||
|
||||
//模块名
|
||||
,MOD_NAME = 'MODULE_DEMO_NAME'
|
||||
,MOD_INDEX = 'layui_'+ MOD_NAME +'_index' //模块索引名
|
||||
|
||||
//外部接口
|
||||
,MODULE_DEMO_NAME = {
|
||||
config: {}
|
||||
,index: layui[MOD_NAME] ? (layui[MOD_NAME].index + 10000) : 0
|
||||
|
||||
//设置全局项
|
||||
,set: function(options){
|
||||
var that = this;
|
||||
that.config = $.extend({}, that.config, options);
|
||||
return that;
|
||||
}
|
||||
|
||||
//事件
|
||||
,on: function(events, callback){
|
||||
return layui.onevent.call(this, MOD_NAME, events, callback);
|
||||
}
|
||||
}
|
||||
|
||||
//操作当前实例
|
||||
,thisModule = function(){
|
||||
var that = this
|
||||
,options = that.config
|
||||
,id = options.id || that.index;
|
||||
|
||||
thisModule.that[id] = that; //记录当前实例对象
|
||||
|
||||
return {
|
||||
config: options
|
||||
//重置实例
|
||||
,reload: function(options){
|
||||
that.reload.call(that, options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//字符常量
|
||||
,STR_ELEM = 'layui-MODULE_DEMO_NAME', STR_HIDE = 'layui-hide', STR_DISABLED = 'layui-disabled', STR_NONE = 'layui-none'
|
||||
|
||||
//主模板
|
||||
,TPL_MAIN = [''].join('')
|
||||
|
||||
//构造器
|
||||
,Class = function(options){
|
||||
var that = this;
|
||||
that.index = ++MODULE_DEMO_NAME.index;
|
||||
that.config = $.extend({}, that.config, MODULE_DEMO_NAME.config, options);
|
||||
that.render();
|
||||
};
|
||||
|
||||
//默认配置
|
||||
Class.prototype.config = {
|
||||
|
||||
};
|
||||
|
||||
//重载实例
|
||||
Class.prototype.reload = function(options){
|
||||
var that = this;
|
||||
|
||||
//防止数组深度合并
|
||||
layui.each(options, function(key, item){
|
||||
if(layui._typeof(item) === 'array') delete that.config[key];
|
||||
});
|
||||
|
||||
that.config = $.extend(true, {}, that.config, options);
|
||||
that.render();
|
||||
};
|
||||
|
||||
//渲染
|
||||
Class.prototype.render = function(){
|
||||
var that = this
|
||||
,options = that.config;
|
||||
|
||||
//解析模板
|
||||
var thisElem = that.elem = $(laytpl(TPL_MAIN).render({
|
||||
data: options
|
||||
,index: that.index //索引
|
||||
}));
|
||||
|
||||
var othis = options.elem = $(options.elem);
|
||||
if(!othis[0]) return;
|
||||
|
||||
|
||||
|
||||
that.events(); //事件
|
||||
};
|
||||
|
||||
//事件
|
||||
Class.prototype.events = function(){
|
||||
var that = this
|
||||
,options = that.config;
|
||||
|
||||
|
||||
};
|
||||
|
||||
//记录所有实例
|
||||
thisModule.that = {}; //记录所有实例对象
|
||||
|
||||
//获取当前实例对象
|
||||
thisModule.getThis = function(id){
|
||||
var that = thisModule.that[id];
|
||||
if(!that) hint.error(id ? (MOD_NAME +' instance with ID \''+ id +'\' not found') : 'ID argument required');
|
||||
return that
|
||||
};
|
||||
|
||||
//重载实例
|
||||
MODULE_DEMO_NAME.reload = function(id, options){
|
||||
var that = thisModule.that[id];
|
||||
that.reload(options);
|
||||
|
||||
return thisModule.call(that);
|
||||
};
|
||||
|
||||
//核心入口
|
||||
MODULE_DEMO_NAME.render = function(options){
|
||||
var inst = new Class(options);
|
||||
return thisModule.call(inst);
|
||||
};
|
||||
|
||||
exports(MOD_NAME, MODULE_DEMO_NAME);
|
||||
});
|
@ -0,0 +1,510 @@
|
||||
|
||||
/*!
|
||||
* element 常用元素操作
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
layui.define('jquery', function(exports){
|
||||
"use strict";
|
||||
|
||||
var $ = layui.$
|
||||
,hint = layui.hint()
|
||||
,device = layui.device()
|
||||
|
||||
,MOD_NAME = 'element', THIS = 'layui-this', SHOW = 'layui-show'
|
||||
|
||||
,Element = function(){
|
||||
this.config = {};
|
||||
};
|
||||
|
||||
//全局设置
|
||||
Element.prototype.set = function(options){
|
||||
var that = this;
|
||||
$.extend(true, that.config, options);
|
||||
return that;
|
||||
};
|
||||
|
||||
//表单事件
|
||||
Element.prototype.on = function(events, callback){
|
||||
return layui.onevent.call(this, MOD_NAME, events, callback);
|
||||
};
|
||||
|
||||
//外部Tab新增
|
||||
Element.prototype.tabAdd = function(filter, options){
|
||||
var TITLE = '.layui-tab-title'
|
||||
,tabElem = $('.layui-tab[lay-filter='+ filter +']')
|
||||
,titElem = tabElem.children(TITLE)
|
||||
,barElem = titElem.children('.layui-tab-bar')
|
||||
,contElem = tabElem.children('.layui-tab-content')
|
||||
,li = '<li'+ function(){
|
||||
var layAttr = [];
|
||||
layui.each(options, function(key, value){
|
||||
if(/^(title|content)$/.test(key)) return;
|
||||
layAttr.push('lay-'+ key +'="'+ value +'"');
|
||||
});
|
||||
if(layAttr.length > 0) layAttr.unshift(''); //向前插,预留空格
|
||||
return layAttr.join(' ');
|
||||
}() +'>'+ (options.title || 'unnaming') +'</li>';
|
||||
|
||||
barElem[0] ? barElem.before(li) : titElem.append(li);
|
||||
contElem.append('<div class="layui-tab-item">'+ (options.content || '') +'</div>');
|
||||
call.hideTabMore(true);
|
||||
call.tabAuto();
|
||||
return this;
|
||||
};
|
||||
|
||||
//外部Tab删除
|
||||
Element.prototype.tabDelete = function(filter, layid){
|
||||
var TITLE = '.layui-tab-title'
|
||||
,tabElem = $('.layui-tab[lay-filter='+ filter +']')
|
||||
,titElem = tabElem.children(TITLE)
|
||||
,liElem = titElem.find('>li[lay-id="'+ layid +'"]');
|
||||
call.tabDelete(null, liElem);
|
||||
return this;
|
||||
};
|
||||
|
||||
//外部Tab切换
|
||||
Element.prototype.tabChange = function(filter, layid){
|
||||
var TITLE = '.layui-tab-title'
|
||||
,tabElem = $('.layui-tab[lay-filter='+ filter +']')
|
||||
,titElem = tabElem.children(TITLE)
|
||||
,liElem = titElem.find('>li[lay-id="'+ layid +'"]');
|
||||
call.tabClick.call(liElem[0], null, null, liElem);
|
||||
return this;
|
||||
};
|
||||
|
||||
//自定义Tab选项卡
|
||||
Element.prototype.tab = function(options){
|
||||
options = options || {};
|
||||
dom.on('click', options.headerElem, function(e){
|
||||
var index = $(this).index();
|
||||
call.tabClick.call(this, e, index, null, options);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
//动态改变进度条
|
||||
Element.prototype.progress = function(filter, percent){
|
||||
var ELEM = 'layui-progress'
|
||||
,elem = $('.'+ ELEM +'[lay-filter='+ filter +']')
|
||||
,elemBar = elem.find('.'+ ELEM +'-bar')
|
||||
,text = elemBar.find('.'+ ELEM +'-text');
|
||||
elemBar.css('width', percent).attr('lay-percent', percent);
|
||||
text.text(percent);
|
||||
return this;
|
||||
};
|
||||
|
||||
var NAV_ELEM = '.layui-nav', NAV_ITEM = 'layui-nav-item', NAV_BAR = 'layui-nav-bar'
|
||||
,NAV_TREE = 'layui-nav-tree', NAV_CHILD = 'layui-nav-child', NAV_CHILD_C = 'layui-nav-child-c'
|
||||
,NAV_MORE = 'layui-nav-more', NAV_DOWN = 'layui-icon-down', NAV_ANIM = 'layui-anim layui-anim-upbit'
|
||||
|
||||
//基础事件体
|
||||
,call = {
|
||||
//Tab 点击
|
||||
tabClick: function(e, index, liElem, options){
|
||||
options = options || {};
|
||||
var othis = liElem || $(this)
|
||||
,index = index || othis.parent().children('li').index(othis)
|
||||
,parents = options.headerElem ? othis.parent() : othis.parents('.layui-tab').eq(0)
|
||||
,item = options.bodyElem ? $(options.bodyElem) : parents.children('.layui-tab-content').children('.layui-tab-item')
|
||||
,elemA = othis.find('a')
|
||||
,isJump = elemA.attr('href') !== 'javascript:;' && elemA.attr('target') === '_blank' //是否存在跳转
|
||||
,unselect = typeof othis.attr('lay-unselect') === 'string' //是否禁用选中
|
||||
,filter = parents.attr('lay-filter');
|
||||
|
||||
//执行切换
|
||||
if(!(isJump || unselect)){
|
||||
othis.addClass(THIS).siblings().removeClass(THIS);
|
||||
item.eq(index).addClass(SHOW).siblings().removeClass(SHOW);
|
||||
}
|
||||
|
||||
layui.event.call(this, MOD_NAME, 'tab('+ filter +')', {
|
||||
elem: parents
|
||||
,index: index
|
||||
});
|
||||
}
|
||||
|
||||
//Tab删除
|
||||
,tabDelete: function(e, othis){
|
||||
var li = othis || $(this).parent(), index = li.index()
|
||||
,parents = li.parents('.layui-tab').eq(0)
|
||||
,item = parents.children('.layui-tab-content').children('.layui-tab-item')
|
||||
,filter = parents.attr('lay-filter');
|
||||
|
||||
if(li.hasClass(THIS)){
|
||||
if(li.next()[0]){
|
||||
call.tabClick.call(li.next()[0], null, index + 1);
|
||||
} else if(li.prev()[0]){
|
||||
call.tabClick.call(li.prev()[0], null, index - 1);
|
||||
}
|
||||
}
|
||||
|
||||
li.remove();
|
||||
item.eq(index).remove();
|
||||
setTimeout(function(){
|
||||
call.tabAuto();
|
||||
}, 50);
|
||||
|
||||
layui.event.call(this, MOD_NAME, 'tabDelete('+ filter +')', {
|
||||
elem: parents
|
||||
,index: index
|
||||
});
|
||||
}
|
||||
|
||||
//Tab自适应
|
||||
,tabAuto: function(){
|
||||
var SCROLL = 'layui-tab-scroll', MORE = 'layui-tab-more', BAR = 'layui-tab-bar'
|
||||
,CLOSE = 'layui-tab-close', that = this;
|
||||
|
||||
$('.layui-tab').each(function(){
|
||||
var othis = $(this)
|
||||
,title = othis.children('.layui-tab-title')
|
||||
,item = othis.children('.layui-tab-content').children('.layui-tab-item')
|
||||
,STOPE = 'lay-stope="tabmore"'
|
||||
,span = $('<span class="layui-unselect layui-tab-bar" '+ STOPE +'><i '+ STOPE +' class="layui-icon"></i></span>');
|
||||
|
||||
if(that === window && device.ie != 8){
|
||||
call.hideTabMore(true)
|
||||
}
|
||||
|
||||
//允许关闭
|
||||
if(othis.attr('lay-allowClose')){
|
||||
title.find('li').each(function(){
|
||||
var li = $(this);
|
||||
if(!li.find('.'+CLOSE)[0]){
|
||||
var close = $('<i class="layui-icon layui-icon-close layui-unselect '+ CLOSE +'"></i>');
|
||||
close.on('click', call.tabDelete);
|
||||
li.append(close);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if(typeof othis.attr('lay-unauto') === 'string') return;
|
||||
|
||||
//响应式
|
||||
if(title.prop('scrollWidth') > title.outerWidth()+1){
|
||||
if(title.find('.'+BAR)[0]) return;
|
||||
title.append(span);
|
||||
othis.attr('overflow', '');
|
||||
span.on('click', function(e){
|
||||
title[this.title ? 'removeClass' : 'addClass'](MORE);
|
||||
this.title = this.title ? '' : '收缩';
|
||||
});
|
||||
} else {
|
||||
title.find('.'+BAR).remove();
|
||||
othis.removeAttr('overflow');
|
||||
}
|
||||
});
|
||||
}
|
||||
//隐藏更多Tab
|
||||
,hideTabMore: function(e){
|
||||
var tsbTitle = $('.layui-tab-title');
|
||||
if(e === true || $(e.target).attr('lay-stope') !== 'tabmore'){
|
||||
tsbTitle.removeClass('layui-tab-more');
|
||||
tsbTitle.find('.layui-tab-bar').attr('title','');
|
||||
}
|
||||
}
|
||||
|
||||
//点击一级菜单
|
||||
/*
|
||||
,clickThis: function(){
|
||||
var othis = $(this), parents = othis.parents(NAV_ELEM)
|
||||
,filter = parents.attr('lay-filter')
|
||||
,elemA = othis.find('a')
|
||||
,unselect = typeof othis.attr('lay-unselect') === 'string';
|
||||
|
||||
if(othis.find('.'+NAV_CHILD)[0]) return;
|
||||
|
||||
if(!(elemA.attr('href') !== 'javascript:;' && elemA.attr('target') === '_blank') && !unselect){
|
||||
parents.find('.'+THIS).removeClass(THIS);
|
||||
othis.addClass(THIS);
|
||||
}
|
||||
|
||||
layui.event.call(this, MOD_NAME, 'nav('+ filter +')', othis);
|
||||
}
|
||||
)
|
||||
*/
|
||||
|
||||
//点击菜单 - a标签触发
|
||||
,clickThis: function(){
|
||||
var othis = $(this)
|
||||
,parents = othis.parents(NAV_ELEM)
|
||||
,filter = parents.attr('lay-filter')
|
||||
,parent = othis.parent()
|
||||
,child = othis.siblings('.'+NAV_CHILD)
|
||||
,unselect = typeof parent.attr('lay-unselect') === 'string'; //是否禁用选中
|
||||
|
||||
if(!(othis.attr('href') !== 'javascript:;' && othis.attr('target') === '_blank') && !unselect){
|
||||
if(!child[0]){
|
||||
parents.find('.'+THIS).removeClass(THIS);
|
||||
parent.addClass(THIS);
|
||||
}
|
||||
}
|
||||
|
||||
//如果是垂直菜单
|
||||
if(parents.hasClass(NAV_TREE)){
|
||||
child.removeClass(NAV_ANIM);
|
||||
|
||||
//如果有子菜单,则展开
|
||||
if(child[0]){
|
||||
parent[child.css('display') === 'none' ? 'addClass': 'removeClass'](NAV_ITEM+'ed');
|
||||
if(parents.attr('lay-shrink') === 'all'){
|
||||
parent.siblings().removeClass(NAV_ITEM + 'ed');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
layui.event.call(this, MOD_NAME, 'nav('+ filter +')', othis);
|
||||
}
|
||||
|
||||
//点击子菜单选中
|
||||
/*
|
||||
,clickChild: function(){
|
||||
var othis = $(this), parents = othis.parents(NAV_ELEM)
|
||||
,filter = parents.attr('lay-filter');
|
||||
parents.find('.'+THIS).removeClass(THIS);
|
||||
othis.addClass(THIS);
|
||||
layui.event.call(this, MOD_NAME, 'nav('+ filter +')', othis);
|
||||
}
|
||||
*/
|
||||
|
||||
//折叠面板
|
||||
,collapse: function(){
|
||||
var othis = $(this), icon = othis.find('.layui-colla-icon')
|
||||
,elemCont = othis.siblings('.layui-colla-content')
|
||||
,parents = othis.parents('.layui-collapse').eq(0)
|
||||
,filter = parents.attr('lay-filter')
|
||||
,isNone = elemCont.css('display') === 'none';
|
||||
|
||||
//是否手风琴
|
||||
if(typeof parents.attr('lay-accordion') === 'string'){
|
||||
var show = parents.children('.layui-colla-item').children('.'+SHOW);
|
||||
show.siblings('.layui-colla-title').children('.layui-colla-icon').html('');
|
||||
show.removeClass(SHOW);
|
||||
}
|
||||
|
||||
elemCont[isNone ? 'addClass' : 'removeClass'](SHOW);
|
||||
icon.html(isNone ? '' : '');
|
||||
|
||||
layui.event.call(this, MOD_NAME, 'collapse('+ filter +')', {
|
||||
title: othis
|
||||
,content: elemCont
|
||||
,show: isNone
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
//初始化元素操作
|
||||
Element.prototype.init = function(type, filter){
|
||||
var that = this, elemFilter = function(){
|
||||
return filter ? ('[lay-filter="' + filter +'"]') : '';
|
||||
}(), items = {
|
||||
|
||||
//Tab选项卡
|
||||
tab: function(){
|
||||
call.tabAuto.call({});
|
||||
}
|
||||
|
||||
//导航菜单
|
||||
,nav: function(){
|
||||
var TIME = 200, timer = {}, timerMore = {}, timeEnd = {}, NAV_TITLE = 'layui-nav-title'
|
||||
|
||||
//滑块跟随
|
||||
,follow = function(bar, nav, index){
|
||||
var othis = $(this), child = othis.find('.'+NAV_CHILD);
|
||||
if(nav.hasClass(NAV_TREE)){
|
||||
//无子菜单时跟随
|
||||
if(!child[0]){
|
||||
var thisA = othis.children('.'+ NAV_TITLE);
|
||||
bar.css({
|
||||
top: othis.offset().top - nav.offset().top
|
||||
,height: (thisA[0] ? thisA : othis).outerHeight()
|
||||
,opacity: 1
|
||||
});
|
||||
}
|
||||
} else {
|
||||
child.addClass(NAV_ANIM);
|
||||
|
||||
//若居中对齐
|
||||
if(child.hasClass(NAV_CHILD_C)) child.css({
|
||||
left: -(child.outerWidth() - othis.width())/2
|
||||
});
|
||||
|
||||
//滑块定位
|
||||
if(child[0]){ //若有子菜单,则滑块消失
|
||||
bar.css({
|
||||
left: bar.position().left + bar.width()/2
|
||||
,width: 0
|
||||
,opacity: 0
|
||||
});
|
||||
} else { //bar 跟随
|
||||
bar.css({
|
||||
left: othis.position().left + parseFloat(othis.css('marginLeft'))
|
||||
,top: othis.position().top + othis.height() - bar.height()
|
||||
});
|
||||
}
|
||||
|
||||
//渐显滑块并适配宽度
|
||||
timer[index] = setTimeout(function(){
|
||||
bar.css({
|
||||
width: child[0] ? 0 : othis.width()
|
||||
,opacity: child[0] ? 0 : 1
|
||||
});
|
||||
}, device.ie && device.ie < 10 ? 0 : TIME);
|
||||
|
||||
//显示子菜单
|
||||
clearTimeout(timeEnd[index]);
|
||||
if(child.css('display') === 'block'){
|
||||
clearTimeout(timerMore[index]);
|
||||
}
|
||||
timerMore[index] = setTimeout(function(){
|
||||
child.addClass(SHOW);
|
||||
othis.find('.'+NAV_MORE).addClass(NAV_MORE+'d');
|
||||
}, 300);
|
||||
}
|
||||
};
|
||||
|
||||
//遍历导航
|
||||
$(NAV_ELEM + elemFilter).each(function(index){
|
||||
var othis = $(this)
|
||||
,bar = $('<span class="'+ NAV_BAR +'"></span>')
|
||||
,itemElem = othis.find('.'+NAV_ITEM);
|
||||
|
||||
//hover 滑动效果
|
||||
if(!othis.find('.'+NAV_BAR)[0]){
|
||||
othis.append(bar);
|
||||
(othis.hasClass(NAV_TREE)
|
||||
? itemElem.find('dd,>.'+ NAV_TITLE)
|
||||
: itemElem).on('mouseenter', function(){
|
||||
follow.call(this, bar, othis, index);
|
||||
}).on('mouseleave', function(){ //鼠标移出
|
||||
//是否为垂直导航
|
||||
if(othis.hasClass(NAV_TREE)){
|
||||
bar.css({
|
||||
height: 0
|
||||
,opacity: 0
|
||||
});
|
||||
} else {
|
||||
//隐藏子菜单
|
||||
clearTimeout(timerMore[index]);
|
||||
timerMore[index] = setTimeout(function(){
|
||||
othis.find('.'+NAV_CHILD).removeClass(SHOW);
|
||||
othis.find('.'+NAV_MORE).removeClass(NAV_MORE+'d');
|
||||
}, 300);
|
||||
}
|
||||
});
|
||||
othis.on('mouseleave', function(){
|
||||
clearTimeout(timer[index])
|
||||
timeEnd[index] = setTimeout(function(){
|
||||
if(!othis.hasClass(NAV_TREE)){
|
||||
bar.css({
|
||||
width: 0
|
||||
,left: bar.position().left + bar.width()/2
|
||||
,opacity: 0
|
||||
});
|
||||
}
|
||||
}, TIME);
|
||||
});
|
||||
}
|
||||
|
||||
//展开子菜单
|
||||
itemElem.find('a').each(function(){
|
||||
var thisA = $(this)
|
||||
,parent = thisA.parent()
|
||||
,child = thisA.siblings('.'+NAV_CHILD);
|
||||
|
||||
//输出小箭头
|
||||
if(child[0] && !thisA.children('.'+NAV_MORE)[0]){
|
||||
thisA.append('<i class="layui-icon '+ NAV_DOWN +' '+ NAV_MORE +'"></i>');
|
||||
}
|
||||
|
||||
thisA.off('click', call.clickThis).on('click', call.clickThis); //点击菜单
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
//面包屑
|
||||
,breadcrumb: function(){
|
||||
var ELEM = '.layui-breadcrumb';
|
||||
|
||||
$(ELEM + elemFilter).each(function(){
|
||||
var othis = $(this)
|
||||
,ATTE_SPR = 'lay-separator'
|
||||
,separator = othis.attr(ATTE_SPR) || '/'
|
||||
,aNode = othis.find('a');
|
||||
if(aNode.next('span['+ ATTE_SPR +']')[0]) return;
|
||||
aNode.each(function(index){
|
||||
if(index === aNode.length - 1) return;
|
||||
$(this).after('<span '+ ATTE_SPR +'>'+ separator +'</span>');
|
||||
});
|
||||
othis.css('visibility', 'visible');
|
||||
});
|
||||
}
|
||||
|
||||
//进度条
|
||||
,progress: function(){
|
||||
var ELEM = 'layui-progress';
|
||||
$('.' + ELEM + elemFilter).each(function(){
|
||||
var othis = $(this)
|
||||
,elemBar = othis.find('.layui-progress-bar')
|
||||
,percent = elemBar.attr('lay-percent');
|
||||
|
||||
elemBar.css('width', function(){
|
||||
return /^.+\/.+$/.test(percent)
|
||||
? (new Function('return '+ percent)() * 100) + '%'
|
||||
: percent;
|
||||
}());
|
||||
|
||||
if(othis.attr('lay-showPercent')){
|
||||
setTimeout(function(){
|
||||
elemBar.html('<span class="'+ ELEM +'-text">'+ percent +'</span>');
|
||||
},350);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//折叠面板
|
||||
,collapse: function(){
|
||||
var ELEM = 'layui-collapse';
|
||||
|
||||
$('.' + ELEM + elemFilter).each(function(){
|
||||
var elemItem = $(this).find('.layui-colla-item')
|
||||
elemItem.each(function(){
|
||||
var othis = $(this)
|
||||
,elemTitle = othis.find('.layui-colla-title')
|
||||
,elemCont = othis.find('.layui-colla-content')
|
||||
,isNone = elemCont.css('display') === 'none';
|
||||
|
||||
//初始状态
|
||||
elemTitle.find('.layui-colla-icon').remove();
|
||||
elemTitle.append('<i class="layui-icon layui-colla-icon">'+ (isNone ? '' : '') +'</i>');
|
||||
|
||||
//点击标题
|
||||
elemTitle.off('click', call.collapse).on('click', call.collapse);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return items[type] ? items[type]() : layui.each(items, function(index, item){
|
||||
item();
|
||||
});
|
||||
};
|
||||
|
||||
Element.prototype.render = Element.prototype.init;
|
||||
|
||||
var element = new Element(), dom = $(document);
|
||||
|
||||
$(function(){
|
||||
element.render();
|
||||
});
|
||||
|
||||
var TITLE = '.layui-tab-title li';
|
||||
dom.on('click', TITLE, call.tabClick); //Tab切换
|
||||
dom.on('click', call.hideTabMore); //隐藏展开的Tab
|
||||
$(window).on('resize', call.tabAuto); //自适应
|
||||
|
||||
exports(MOD_NAME, element);
|
||||
});
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue