diff --git a/css/huaxia.css b/css/huaxia.css index b428495..0c379d1 100644 --- a/css/huaxia.css +++ b/css/huaxia.css @@ -173,6 +173,7 @@ ul li {list-style: none;padding: 0px;margin: 0px;} .tn{text-decoration: none;} #gotoTop{width: 57px;height: 57px; cursor: pointer;position: fixed;right: 60px;bottom: 110px;z-index: 20;display: none;} +.dmedia{display: inline;} /* 轮播图 */ .swiper-container { @@ -301,6 +302,16 @@ ul li {list-style: none;padding: 0px;margin: 0px;} .wc-box .ya-item-box:hover img{transform: scale(.9);transition: transform .5s;} .wc-box .ya-item-box:hover a{color: #cb1919;text-decoration:underline;} .wc-box>div>div>a:hover{color: #cb1919;text-decoration:underline;} + +.gongn{display: none;width: 50px;height: 50px;position: absolute;right: 50px;cursor: pointer;} +.xinxy-box{background: #f6f5f3;padding-bottom: 65px;} +.xinxy-box .dac{width: 102%;overflow: hidden;} +.syysj-box{background: #100e0d;padding-bottom: 65px;} +.syys-name{font-size: 30px;font-weight: bold;color: #cb1919;} +.sypx-box{background: url(../img/public/px-bac.png); background-size: 100% 100%;padding-bottom: 65px;} +.hz-jies{font-size: 14px;color: rgba(25,25,25,.5);margin-left: 10px;} +.hzly-box{padding: 30px;z-index: 1;} +.hz-input-box div{color: #FFFFFF;background: #cb1919;padding: 10px 50px;border-radius: 3px;} /* 资讯 */ .zx-nav,.szx-nav,.px-nav{padding: 0;} .zx-nav li,.szx-nav li,.px-nav li{margin-right: 50px;position: relative;padding: 20px 0 15px 0;} diff --git a/css/huaxiaMedia.css b/css/huaxiaMedia.css index f2c2826..a82313a 100644 --- a/css/huaxiaMedia.css +++ b/css/huaxiaMedia.css @@ -16,22 +16,101 @@ @media screen and (min-width:621px) and (max-width:720px) { } -@media screen and (min-width:721px) and (max-width:820px) { - +@media screen and (width:320px) { + .exhibition .item-box {height: 200px!important;} + .swiper-button-next, .swiper-button-prev {top: 40%!important;} } -@media screen and (min-width:821px) and (max-width:920px) { +@media screen and (max-width:750px) { + .logo{width: 60%;} + .head-box {top: 0px;} + .gongn{display: inline;right: 20px;width: 40px;height: 40px;} + .dmedia{display: none;} + .head-box{padding: 10px 20px;} + .p-zy180{padding: 10px 20px 0 20px;} + .cq-item-title-box {padding: 10px 0;} + .font-32 {font-size: 16px;} + .font-22 {font-size: 12px;} + .cq-gengd {font-size: 12px;color: #191919;} + .cq-item-title-box>div>div{background: -webkit-linear-gradient(left,red,rgba(255,255,255,0));height: 6px;bottom: 0;left: 0; width: 70px;opacity: .8;z-index: 0;} + .exhibition .item-box {height: 270px;} + .font-20 {font-size: 16px;} + .font-13 {font-size: 12px;} + .m-x16 {margin-bottom: 16px;} + .swiper-pagination-bullet,.swiper-container-horizontal > .swiper-pagination-bullets .swiper-pagination-bullet-active{width: 6px;height: 6px;} + .swiper-button-next, .swiper-button-prev {background: rgba(0,0,0,.6);width: 20px;height: 20px;top: 42%;} + .swiper-button-next::after, .swiper-button-prev::after {font-size: 12px;} + .m-sx16 {margin-top: 10px;margin-bottom: 10px;} + .m-x16 {margin-bottom: 2px;} + .m-x65 {margin-bottom: 20px;} + .p-sx20{padding-top: 0px;padding-bottom: 10px;} + .m-x37,.m-x32 {margin-bottom: 10px;} + .w25,.w48{width: 100%;} + .msg .dac{display: inline;} + .m-zy15 {margin-left: 10px; margin-right: 10px;margin-top: 10px;} + .font-18 {font-size: 16px;} + .xx-content {line-height: 20px;} + .msg .m-x32:nth-last-child(2) {margin-bottom: 10px;} + .djb{display: inline;} + .djb .w50{width: 100%;margin-bottom: 10px;} + .djb .w50 .m-zy30{margin-left: 0px;margin-right: 0px;margin-bottom: 10px;} + .ys-title {font-size: 16px;} + .ya-item-box .pr{padding-right: 0;} + .m-s37 {margin-top: 10px;} + .syysj-box,.xinxy-box{padding-bottom: 20px;} + .xinxy-box .dac{display: inline;} + .syysj-box .dac{display: inherit;} + .syysj-box .dac .m-zy30{margin-left: 10px;margin-right: 10px;height: 200px;} + .syysj-box .dac .m-zy30 .m-s30{margin-top: 20px;} + .syys-name{font-size: 18px;margin-top: 10px;margin-bottom: 10px;} + .ysj-name{line-height: 20px;} + .w20{width: 100%;padding-bottom: 10px;} + .wc-box > div > img {width: 100%;} + .sypx-box {padding-bottom: 20px;} + .sypx-box .djb .backf {padding-bottom: 10px;} + .sypx-box .djb .backf div{margin-top: 10px;} + .hz-jies{position: absolute;top: 25px;left: 0;margin-left: 0px;} + .hz-imgItem{margin-top: 20px;} + .hz-input-box{display: inherit;} + .hzly-box{padding: 20px;} + .hz-input-box .p-zy10{width: 94%;margin-top: 10px;} + .hz-input-box .p-zy10:first-child{margin-top: 30px;} + .hz-input-box div{margin-top: 10px;text-align: center;} + #gotoTop {width: 40px;height: 40px;right: 20px;bottom: 120px;} } -@media screen and (min-width:921px) and (max-width:1020px) { - -} -@media screen and (min-width:1021px) and (max-width:1120px) { +@media screen and (min-width:751px) and (max-width:850px) { .logo{width: 26%;} + .gongn{display: inline;} + .dmedia{display: none;} + .p-zy180,.head-box{padding: 10px 60px;} +} +@media screen and (min-width:851px) and (max-width:1000px) { + .logo{width: 26%;} + .gongn{display: inline;} + .dmedia{display: none;} + .input-box{display: none;} + .head-box{padding: 10px 60px 5px 60px;} + .p-zy180 {padding: 10px 60px;} + .dao-box>li{padding: 5px 16px;flex-shrink: 0;text-align: center;font-size: 16px;} + .dao-box>li:last-child{padding-right: 0;} + .dao-box>li>div{padding: 6px 0;} + .head-nav-box > div:last-child {margin-top: 0px;} + .redD {right: 6px;} +} +@media screen and (min-width:1001px) and (max-width:1120px) { + .logo{width: 26%;} + .input-box{display: none;} + .p-zy180,.head-box{padding: 10px 100px;} + .dao-box>li{padding: 5px 16px;flex-shrink: 0;text-align: center;font-size: 16px;} + .dao-box>li:last-child{padding-right: 0;} + .dao-box>li>div{padding: 6px 0;} + .head-nav-box > div:last-child {margin-top: 0px;} + .redD {right: 6px;} } @media screen and (min-width:1121px) and (max-width:1260px) { - .input-box{display: none;} .logo{width: 26%;} - .head-box{padding: 10px 100px;} + .input-box{display: none;} + .p-zy180,.head-box{padding: 10px 100px;} .dao-box>li{padding: 5px 16px;flex-shrink: 0;text-align: center;font-size: 16px;} .dao-box>li:last-child{padding-right: 0;} .dao-box>li>div{padding: 6px 0;} @@ -40,7 +119,7 @@ } @media screen and (min-width:1261px) and (max-width:1350px) { .logo{width: 26%;} - .head-box{padding: 10px 100px;} + .p-zy180,.head-box{padding: 10px 100px;} .dao-box>li{padding: 5px 16px;flex-shrink: 0;text-align: center;font-size: 16px;} .dao-box>li>div{padding: 6px 0;} .head-nav-box > div:last-child {margin-top: 10px;} @@ -48,12 +127,17 @@ } @media screen and (min-width:1351px) and (max-width:1620px) { .logo{width: 26%;} - .head-box{padding: 20px 100px;} + .p-zy180,.head-box{padding: 20px 100px;} .dao-box>li{padding: 5px 20px;flex-shrink: 0;text-align: center;font-size: 16px;} .dao-box>li>div{padding: 6px 0;} .redD {right: 8px;} } @media screen and (min-width:1621px) and (max-width:1820px) { .logo{width: 30%;} - .head-box{padding: 20px 100px;} + .p-zy180,.head-box{padding: 20px 100px;} } +@media screen and (min-width:751px) and (max-width:1820px) { + .cq-item-title-box {padding: 20px 0 15px 0;} + .font-32 {font-size: 26px;} +} + diff --git a/css/layer.css b/css/layer.css new file mode 100644 index 0000000..b9dbf20 --- /dev/null +++ b/css/layer.css @@ -0,0 +1 @@ +.layui-m-layer{position:relative;z-index:19891014}.layui-m-layer *{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}.layui-m-layermain,.layui-m-layershade{position:fixed;left:0;top:0;width:100%;height:100%}.layui-m-layershade{background-color:rgba(0,0,0,.7);pointer-events:auto}.layui-m-layermain{display:table;font-family:Helvetica,arial,sans-serif;pointer-events:none}.layui-m-layermain .layui-m-layersection{display:table-cell;vertical-align:middle;text-align:center}.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,.1);pointer-events:auto;-webkit-overflow-scrolling:touch;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:.2s;animation-duration:.2s}@-webkit-keyframes layui-m-anim-scale{0%{opacity:0;-webkit-transform:scale(.5);transform:scale(.5)}100%{opacity:1;-webkit-transform:scale(1);transform:scale(1)}}@keyframes layui-m-anim-scale{0%{opacity:0;-webkit-transform:scale(.5);transform:scale(.5)}100%{opacity:1;-webkit-transform:scale(1);transform:scale(1)}}.layui-m-anim-scale{animation-name:layui-m-anim-scale;-webkit-animation-name:layui-m-anim-scale}@-webkit-keyframes layui-m-anim-up{0%{opacity:0;-webkit-transform:translateY(800px);transform:translateY(800px)}100%{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}}@keyframes layui-m-anim-up{0%{opacity:0;-webkit-transform:translateY(800px);transform:translateY(800px)}100%{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}}.layui-m-anim-up{-webkit-animation-name:layui-m-anim-up;animation-name:layui-m-anim-up}.layui-m-layer0 .layui-m-layerchild{width:90%;max-width:640px}.layui-m-layer1 .layui-m-layerchild{border:none;border-radius:0}.layui-m-layer2 .layui-m-layerchild{width:auto;max-width:260px;min-width:40px;border:none;background:0 0;box-shadow:none;color:#fff}.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}.layui-m-layerbtn span,.layui-m-layerchild h3{text-overflow:ellipsis;overflow:hidden;white-space:nowrap}.layui-m-layercont{padding:50px 30px;line-height:22px;text-align:center}.layui-m-layer1 .layui-m-layercont{padding:0;text-align:left}.layui-m-layer2 .layui-m-layercont{text-align:center;padding:0;line-height:0}.layui-m-layer2 .layui-m-layercont i{width:25px;height:25px;margin-left:8px;display:inline-block;background-color:#fff;border-radius:100%;-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}.layui-m-layerbtn,.layui-m-layerbtn span{position:relative;text-align:center;border-radius:0 0 5px 5px}.layui-m-layer2 .layui-m-layercont p{margin-top:20px}@-webkit-keyframes layui-m-anim-loading{0%,100%,80%{transform:scale(0);-webkit-transform:scale(0)}40%{transform:scale(1);-webkit-transform:scale(1)}}@keyframes layui-m-anim-loading{0%,100%,80%{transform:scale(0);-webkit-transform:scale(0)}40%{transform:scale(1);-webkit-transform:scale(1)}}.layui-m-layer2 .layui-m-layercont i:first-child{margin-left:0;-webkit-animation-delay:-.32s;animation-delay:-.32s}.layui-m-layer2 .layui-m-layercont i.layui-m-layerload{-webkit-animation-delay:-.16s;animation-delay:-.16s}.layui-m-layer2 .layui-m-layercont>div{line-height:22px;padding-top:7px;margin-bottom:20px;font-size:14px}.layui-m-layerbtn{display:box;display:-moz-box;display:-webkit-box;width:100%;height:50px;line-height:50px;font-size:0;border-top:1px solid #D0D0D0;background-color:#F2F2F2}.layui-m-layerbtn span{display:block;-moz-box-flex:1;box-flex:1;-webkit-box-flex:1;font-size:14px;cursor:pointer}.layui-m-layerbtn span[yes]{color:#40AFFE}.layui-m-layerbtn span[no]{border-right:1px solid #D0D0D0;border-radius:0 0 0 5px}.layui-m-layerbtn span:active{background-color:#F6F6F6}.layui-m-layerend{position:absolute;right:7px;top:10px;width:30px;height:30px;border:0;font-weight:400;background:0 0;cursor:pointer;-webkit-appearance:none;font-size:30px}.layui-m-layerend::after,.layui-m-layerend::before{position:absolute;left:5px;top:15px;content:'';width:18px;height:1px;background-color:#999;transform:rotate(45deg);-webkit-transform:rotate(45deg);border-radius:3px}.layui-m-layerend::after{transform:rotate(-45deg);-webkit-transform:rotate(-45deg)}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:0 0}.layui-m-layer-footer .layui-m-layercont{padding:20px;border-radius:5px 5px 0 0;background-color:rgba(255,255,255,.8)}.layui-m-layer-footer .layui-m-layerbtn{display:block;height:auto;background:0 0;border-top:none}.layui-m-layer-footer .layui-m-layerbtn span{background-color:rgba(255,255,255,.8)}.layui-m-layer-footer .layui-m-layerbtn span[no]{color:#FD482C;border-top:1px solid #c2c2c2;border-radius:0 0 5px 5px}.layui-m-layer-footer .layui-m-layerbtn span[yes]{margin-top:10px;border-radius:5px}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}.layui-m-layer-msg .layui-m-layercont{padding:10px 20px} \ No newline at end of file diff --git a/img/public/gn.png b/img/public/gn.png new file mode 100644 index 0000000..2e3b12b Binary files /dev/null and b/img/public/gn.png differ diff --git a/index.html b/index.html index 4222c83..d1c5ee5 100644 --- a/index.html +++ b/index.html @@ -4,14 +4,14 @@ 华夏艺术网 - + - - + + @@ -39,9 +39,9 @@ mousewheel: false,//禁止鼠标滚动,切换 }); -
+
-
+
关于我们 @@ -104,6 +104,8 @@
+ +
@@ -193,32 +195,64 @@
-
+
信息动态Information News
@@ -258,7 +292,7 @@
-
+
@@ -326,7 +360,7 @@
-
+
艺术家Artist
View More +
@@ -334,7 +368,7 @@
-
张龙森
+
张龙森
职业画家
毕业于中央美术学院,硕士;曾留学在德国卡塞尔艺术学院,现工作生活于北京
文字后期后台替换无论你是追求精致生活的Ta,还是要文艺一把的男女青年,还是热爱潮流、追求个性的一族,又或者是一个不折不扣的吃货。来设计周吧!全方位的体验满足你的挑剔。文字后期后台替换无论你是追求精致生活的Ta,还是要文艺一把的男女青年,还是热爱潮流、追求个性的一族,又或者是一个不折不扣的吃货。来设计周吧!全方位的体验满足你的挑剔。
@@ -458,7 +492,7 @@
-
+
培训Cooperative Partner
View More +
@@ -466,16 +500,16 @@
-
艺术清酒--得寓(酒标作品)Delight Sake
+
艺术清酒--得寓(酒标作品)Delight Sake
-
艺术清酒--得寓(酒标作品)Delight Sake
+
艺术清酒--得寓(酒标作品)Delight Sake
-
艺术清酒--得寓(酒标作品)Delight Sake
+
艺术清酒--得寓(酒标作品)Delight Sake
@@ -483,10 +517,10 @@
-
合作伙伴Cooperative Partner 700+媒体合作、200+机构支持、5000+名艺术家
+
合作伙伴Cooperative Partner 700+媒体合作、200+机构支持、5000+名艺术家
View More +
-
+
@@ -499,15 +533,15 @@
-
+
-
合作留言Cooperation Message 如果您有意见建议请留言,我们将第一时间与您联系!
+
合作留言Cooperation Message 如果您有意见建议请留言,我们将第一时间与您联系!
-
- - - -
提交
+
+ + + +
提交
diff --git a/js/huaxia.js b/js/huaxia.js index d60caf6..a497ad1 100644 --- a/js/huaxia.js +++ b/js/huaxia.js @@ -1,4 +1,19 @@ $(function(){ + let reg_tel = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/; + $('#submitLY').click(function(){ + let name = $('input[name="username"]').val(); + let phone = $('input[name="userphone"]').val(); + let content = $('input[name="usercontent"]').val(); + if(!name){ + layer.msg('请输入联系人') + } else if(!reg_tel.test(phone)){ + console.log('请输入正确的联系电话'); + } else if(!content){ + console.log('请输入联系说明'); + } else { + console.log('提交成功'); + } + }) let headH = $('#huaxia-head').height() $(window).resize(function(){//监听窗口大小的改变 // console.log($(window).width()); diff --git a/js/layer.js b/js/layer.js new file mode 100644 index 0000000..f9cf693 --- /dev/null +++ b/js/layer.js @@ -0,0 +1,2 @@ +/*! layer mobile-v2.0.0 Web弹层组件 MIT License http://layer.layui.com/mobile By 贤心 */ + ;!function(e){"use strict";var t=document,n="querySelectorAll",i="getElementsByClassName",a=function(e){return t[n](e)},s={type:0,shade:!0,shadeClose:!0,fixed:!0,anim:"scale"},l={extend:function(e){var t=JSON.parse(JSON.stringify(s));for(var n in e)t[n]=e[n];return t},timer:{},end:{}};l.touch=function(e,t){e.addEventListener("click",function(e){t.call(this,e)},!1)};var r=0,o=["layui-m-layer"],c=function(e){var t=this;t.config=l.extend(e),t.view()};c.prototype.view=function(){var e=this,n=e.config,s=t.createElement("div");e.id=s.id=o[0]+r,s.setAttribute("class",o[0]+" "+o[0]+(n.type||0)),s.setAttribute("index",r);var l=function(){var e="object"==typeof n.title;return n.title?'

'+(e?n.title[0]:n.title)+"

":""}(),c=function(){"string"==typeof n.btn&&(n.btn=[n.btn]);var e,t=(n.btn||[]).length;return 0!==t&&n.btn?(e=''+n.btn[0]+"",2===t&&(e=''+n.btn[1]+""+e),'
'+e+"
"):""}();if(n.fixed||(n.top=n.hasOwnProperty("top")?n.top:100,n.style=n.style||"",n.style+=" top:"+(t.body.scrollTop+n.top)+"px"),2===n.type&&(n.content='

'+(n.content||"")+"

"),n.skin&&(n.anim="up"),"msg"===n.skin&&(n.shade=!1),s.innerHTML=(n.shade?"
':"")+'
"+l+'
'+n.content+"
"+c+"
",!n.type||2===n.type){var d=t[i](o[0]+n.type),y=d.length;y>=1&&layer.close(d[0].getAttribute("index"))}document.body.appendChild(s);var u=e.elem=a("#"+e.id)[0];n.success&&n.success(u),e.index=r++,e.action(n,u)},c.prototype.action=function(e,t){var n=this;e.time&&(l.timer[n.index]=setTimeout(function(){layer.close(n.index)},1e3*e.time));var a=function(){var t=this.getAttribute("type");0==t?(e.no&&e.no(),layer.close(n.index)):e.yes?e.yes(n.index):layer.close(n.index)};if(e.btn)for(var s=t[i]("layui-m-layerbtn")[0].children,r=s.length,o=0;o - */ - -/* global layui */ -/* eslint-disable max-nested-callbacks, fecs-indent */ - -var $ = layui.$; - -/** - * 是否基于`phantomjs`测试, 因为有些特殊的case在ie中是不可用的, 比如: `window.event = {}` - * - * @type {boolean} - */ -var IS_PHANTOMJS = layui.device('phantomjs').phantomjs; - -describe('layui', function() { - it('version', function() { - expect(layui.v).to.be.a('string'); - expect(layui.v).to.not.be.empty; - }); - - it('layui.config', function() { - expect(layui.config()).to.deep.equal(layui); - expect(layui.config({ - testName: 'layui' - })).to.deep.equal(layui); - expect(layui.cache.testName).to.equal('layui'); - }); - - describe('layui.router', function() { - var defaultData = { - path: [], - search: {}, - hash: '' - }; - - it('default params', function() { - expect(layui.router).to.be.a('function'); - expect(layui.router()).to.be.a('object').and.deep.equal(defaultData); - }); - - it('error router', function() { - [ - null, - '', - '#123', - '123', - '##' - ].forEach(function(key) { - expect(layui.router(key)).to.deep.equal(defaultData); - }); - }); - - it('router querystring', function() { - expect(layui.router('#/a=1/b=2/c=')).to.deep.equal($.extend({}, defaultData, { - href: '/a=1/b=2/c=', - search: { - a: '1', - b: '2', - c: '' - } - })); - - expect(layui.router('#/a=测试/b=2').search).to.deep.equal({ - a: '测试', - b: '2' - }); - - // todo - // urlencode - // urldecode - }); - - it('router hash', function() { - expect(layui.router('#/name#layui')).to.deep.equal($.extend({}, defaultData, { - hash: '#layui', - path: ['name'], - href: '/name#layui' - })); - expect(layui.router('#/name#layui').hash).to.equal('#layui'); - expect(layui.router('#/name#layui=1').hash).to.equal('#layui=1'); - expect(layui.router('#/name##layui').hash).to.equal('##layui'); - expect(layui.router('#/name=1#layui').hash).to.equal('#layui'); - expect(layui.router('#/name=1/b=2#layui').hash).to.equal('#layui'); - }); - - it('router path', function() { - expect(layui.router('#/a/b/c=2#hash')).to.deep.equal({ - path: ['a', 'b'], - search: { - c: '2' - }, - hash: '#hash', - href: '/a/b/c=2#hash' - }); - }); - }); - - describe('layui.each', function() { - it('check params', function() { - expect(layui.each).to.be.a('function'); - expect(layui.each()).to.deep.equal(layui); - expect(layui.each({})).to.deep.equal(layui); - expect(layui.each([])).to.deep.equal(layui); - expect(layui.each({}, function() {})).to.deep.equal(layui); - expect(layui.each([], function() {})).to.deep.equal(layui); - }); - - it('null params', function(done) { - var index = 0; - layui.each(null, function(index) { - index += 1; - }); - setTimeout(function() { - expect(index).to.equal(0); - done(); - }); - }); - - it('object each', function(done) { - layui.each({ - name: 'layui' - }, function(key, value) { - expect(this + '').to.deep.equal(value).and.equal('layui'); - expect(key).to.equal('name'); - done(); - }); - }); - - it('array each', function(done) { - layui.each([ - 'layui' - ], function(index, value) { - expect(this + '').to.deep.equal(value).and.equal('layui'); - expect(index).to.equal(0); - done(); - }); - }); - - it('break array each', function() { - var arr = new Array(100).join(',').split(','); - var flag = -1; - layui.each(arr, function(index) { - flag = index; - if (index > 5) { - return true; - } - }); - expect(flag).to.equal(6); - - flag = -1; - layui.each(arr, function(index) { - flag = index; - if (index > 5) { - return false; - } - }); - expect(flag).to.equal(99); - }); - - it('break object each', function() { - var obj = { - name: 'layui', - version: '2.x' - }; - var flag = null; - layui.each(obj, function(key) { - flag = key; - return true; - }); - expect(flag).to.equal('name'); - - flag = null; - layui.each(obj, function(key) { - flag = key; - return false; - }); - expect(flag).to.equal('version'); - }); - }); - - describe('layui.img', function() { - var base64 = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='; - it('success callback', function(done) { - layui.img(base64, function(img) { - expect(img).to.not.undefined; - expect(typeof(img)).to.equal('object', '是img对象'); - expect(img.nodeType).to.equal(1, 'img标签节点'); - - // 在ie11中不通过, 原因目前不明 - // expect(img.width).to.equal(1); - // expect(img.height).to.equal(1); - done(); - }); - }); - - it('error callback', function(done) { - layui.img('/api/mock?statusCode=404', function() {}, function(e) { - expect(e).to.not.undefined; - done(); - }); - }); - - // 先删除, 因为没有哪个图片是决定不变的 - // it('http 200', function (done) { - // layui.img('https://www.baidu.com/img/bd_logo1.png', function (img) { - // expect(img).to.not.undefined; - // done(); - // }); - // }); - - // 由于没有超时配置, 在部分设备中, dns解析可能超时 - // it('http 404', function (done) { - // layui.img('http://www.404.xx/logo.404.gif', function () {}, function (e) { - // expect(e).to.not.undefined; - // done(); - // }); - // }); - - it('load complete', function(done) { - layui.img(base64, function() { - layui.img(base64, function(img) { - expect(img).to.not.undefined; - done(); - }); - }); - }); - }); - - it('layui.hint', function() { - expect(layui.hint).to.be.a('function'); - expect(layui.hint()).to.be.a('object'); - expect(layui.hint().error).to.be.a('function'); - }); - - describe('layui.stope', function() { - it('stopPropagation', function(done) { - layui.stope({ - stopPropagation: function(e) { - expect(e).to.be.undefined; - done(); - } - }); - }); - - it('cancelBubble', function() { - var event = {}; - layui.stope(event); - expect(event.cancelBubble).to.be.true; - }); - - // ie中不支持, 只针对phantomjs测试 - if (IS_PHANTOMJS) { - it('window.event', function() { - var old = window.event; - var event = window.event = {}; - layui.stope(); - expect(event.cancelBubble).to.be.true; - window.event = old; - }); - } - }); - - describe('layui.onevent', function() { - it('check params and return value', function() { - expect(layui.onevent).to.be.a('function'); - expect(layui.onevent()).to.deep.equal(layui); - expect(layui.onevent([], [], [])).to.deep.equal(layui); - expect(layui.onevent({}, {}, {})).to.deep.equal(layui); - expect(layui.onevent('test-' + Date.now(), 'click', function() {})).to.not.deep - .equal(layui); - }); - - it('bind event', function(done) { - var id = 'test-bind-event'; - var data = { - name: 'layui' - }; - layui.onevent(id, 'click', function(param) { - expect(this).to.deep.equal(layui); - expect(param).to.deep.equal(data); - done(); - }); - layui.event(id, 'click', data); - }); - - it('coverage of the same name event', function() { - var id = 'test-same-event'; - var index = 0; - layui.onevent(id, 'click', function() { - index = 1; - }); - layui.onevent(id, 'click', function() { - index = 2; - }); - layui.event(id, 'click'); - expect(index).to.equal(2); - }); - }); - - describe('layui.event', function() { - it('trigger event', function(done) { - layui.onevent('test-trigger', 'click(*)', function(data) { - expect(data).to.be.true; - done(); - }); - layui.event('test-trigger', 'click(*)', true); - }); - - it.skip('trigger multiple', function() { - var index = 0; - var id = 'test-trigger-multiple'; - layui.onevent(id, 'nav', function() { - index += 1; - }); - layui.event(id, 'nav'); - layui.event(id, 'nav'); - layui.event(id, 'nav'); - expect(index).to.equal(3); - }); - - it('return value', function() { - expect(layui.event('id', 'event')).to.be.null; - - // 只有在返回 false 时, 结果才是 false - layui.onevent('test-return-value-1', 'click', function(data) { - return data; - }); - expect(layui.event('test-return-value-1', 'click', false)).to.be.false; - expect(layui.event('test-return-value-1', 'click', true)).to.be.null; - expect(layui.event('test-return-value-1', 'click')).to.be.null; - }); - }); - - describe('layui.sort', function() { - var numberData = [{ - name: 1 - }, - { - name: 3 - }, - { - name: 2 - } - ]; - - it('check params and return value', function() { - expect(layui.sort()).to.deep.equal([], '空参数时默认为空数组'); - - expect(layui.sort({})).to.deep.equal({}, '只传空对象默认返回'); - expect(layui.sort({ - name: 'layui' - })).to.deep.equal({ - name: 'layui' - }, '只传一个对象参数时返回'); - - expect(layui.sort([{ - name: 'layui' - }], 'name')).to.deep.equal([{ - name: 'layui' - }]); - - expect(layui.sort([{ - name: 'layui' - }], 'name', true)).to.deep.equal([{ - name: 'layui' - }]); - }); - - // 测试是否污染原数据 - it('clone object', function() { - var clone = layui.sort(numberData, 'name'); - - // 往clone对象添加 - clone.push('layui'); - - expect(clone).to.have.lengthOf(4); - expect(numberData).to.have.lengthOf(3); - }); - - it('format value number', function() { - var result = layui.sort([{ - key: '1' - }, - { - key: '-1' - }, - { - key: 2 - }, - { - key: 3 - } - ], 'key'); - expect(result).to.deep.equal([{ - key: '-1' - }, - { - key: '1' - }, - { - key: 2 - }, - { - key: 3 - } - ]); - }); - - it('asc order', function() { - var result = layui.sort(numberData, 'name'); - expect(result).to.deep.equal([{ - name: 1 - }, - { - name: 2 - }, - { - name: 3 - } - ]); - }); - - it('desc order', function() { - var result = layui.sort(numberData, 'name', true); - expect(result).to.deep.equal([{ - name: 3 - }, - { - name: 2 - }, - { - name: 1 - } - ]); - }); - - it('error data', function() { - var data = [ - // null, - { - name: 5 - }, - {}, - [], - 'test', - { - name: '3' - } - ]; - expect(layui.sort(data, 'name')).to.deep.equal([{}, - [], - 'test', - { - name: '3' - }, - { - name: 5 - } - ]); - }); - }); - - it('layui.device', function() { - expect(layui.device).to.be.a('function'); - expect(layui.device()).to.be.a('object'); - expect(layui.device().ie).to.be.not.undefined; - expect(layui.device().ios).to.be.not.undefined; - expect(layui.device().android).to.be.not.undefined; - expect(layui.device().weixin).to.be.a('boolean'); - expect(layui.device('weixin').weixin).to.be.false; - expect(layui.device('.*')['.*']).to.be.not.empty; - expect(layui.device('layui.com')['layui.com']).to.be.false; - }); - - describe('layui.getStyle', function() { - it('real test', function() { - var elem = $('
').css({ - position: 'fixed', - zIndex: 10 - }).appendTo('body').get(0); - - expect(layui.getStyle(elem, 'position')).to.equal('fixed'); - expect(layui.getStyle(elem, 'z-index')).to.equal('10'); - }); - - it('mock currentStyle', function(done) { - var node = { - currentStyle: { - getPropertyValue: function(name) { - expect(name).to.equal('layui'); - done(); - } - } - }; - layui.getStyle(node, 'layui'); - }); - }); - - it('layui.extend', function() { - expect(layui.extend).to.be.a('function'); - expect(layui.extend()).to.deep.equal(layui); - expect(layui.extend({ - v: 'v', - util: 'util' - })).to.deep.equal(layui); - - var id = 'test-extend-' + Date.now(); - var data = {}; - data[id] = id; - expect(layui.modules[id]).to.be.undefined; - layui.extend(data); - expect(layui.modules[id]).to.be.not.undefined; - expect(layui.modules[id]).to.equal(id); - delete layui.modules[id]; - }); - - describe('layui.data', function() { - if (IS_PHANTOMJS) { - it('not support JSON', function() { - var old = window.JSON; - window.JSON = null; - expect(layui.data()).to.be.undefined; - window.JSON = {}; - expect(layui.data()).to.be.undefined; - window.JSON = old; - }); - } - - // 在支持情况下才测试 - if (window.localStorage) { - it('delete table data', function() { - var id = 'test-delete-data'; - localStorage[id] = true; - expect(localStorage[id]).to.equal('true'); - expect(layui.data(id, null)).to.be.true; - expect(localStorage[id]).to.be.undefined; - }); - - it('get table data', function() { - var table = 'test-get-table-data'; - expect(layui.data(table)).to.deep.equal({}); - - layui.data(table, { - key: 'name', - value: 'layui' - }); - expect(layui.data(table)).to.deep.equal({ - name: 'layui' - }); - - // 删除数据 - layui.data(table, null); - }); - - it('get data', function() { - var id = 'test-get-data'; - - // 直接获取肯定为空 - expect(layui.data(null, id)).to.be.undefined; - - // 写入数据 - expect(layui.data(null, { - key: id, - value: true - })).to.be.true; - - expect(layui.data(null, id)).to.be.true; - - // 清除数据 - layui.data(null, { - key: id, - remove: true - }); - }); - - it('remove data', function() { - var id = 'test-remove-data'; - - layui.data(null, { - key: id, - value: true - }); - expect(layui.data(null, id)).to.be.true; - layui.data(null, { - key: id, - remove: true - }); - expect(layui.data(null, id)).to.be.undefined; - }); - } - }); -}); -/* eslint-enable max-nested-callbacks, fecs-indent */