/*-----判断IE6、7、8-----*/ var userAgent = window.navigator.userAgent.toLowerCase(); $.browser.msie8 = $.browser.msie && /msie 8\.0/i.test(userAgent); $.browser.msie7 = $.browser.msie && /msie 7\.0/i.test(userAgent); $.browser.msie6 = !$.browser.msie8 && !$.browser.msie7 && $.browser.msie && /msie 6\.0/i.test(userAgent); if ($.browser.msie6 || $.browser.msie7) { alert('您的浏览器版本太低,为了更好的浏览网站,请升级浏览器,谢谢。'); } /*-----css3-----*/ function supportCss3(style) { var prefix = ['webkit', 'Moz', 'ms', 'o'], i, humpString = [], htmlStyle = document.documentElement.style, _toHumb = function (string) { return string.replace(/-(\w)/g, function ($0, $1) { return $1.toUpperCase(); }); }; for (i in prefix) humpString.push(_toHumb(prefix[i] + '-' + style)); humpString.push(_toHumb(style)); for (i in humpString) if (humpString[i] in htmlStyle) return true; return false; } $(function () { /*-----主导航选中状态-----*/ var nav = $('#nav'); nav.find('.col').eq(0).addClass('cur'); /*-----导航显隐-----*/ var navpf = $('#navPf'); var mask = $('#mask'); $('.open').click(function(event) { navpf.addClass('nav-pf-on'); mask.fadeIn(400); }); $('#navC').click(function(event) { navpf.removeClass('nav-pf-on'); mask.fadeOut(400); }); mask.click(function(event) { navpf.removeClass('nav-pf-on'); mask.fadeOut(400); }); /*幻灯片*/ var banner = $('#banner'), banItem = banner.find('.witem'), banbtn = banner.find('.bitem'), banIx = 0, autoTime; banner.css('height', $(window).height() - $('#header').height() - $('#copypf').height() + 'px'); banbtn.click(function() { banIx = $(this).index(); $(this).addClass('cur').siblings('.bitem').removeClass('cur'); banItem.eq(banIx).stop(false, true).fadeIn('600', function() { $(this).find('.lazy').each(function(index, el) { var temp = $(this); var imgsrc = temp.attr('data-original'); temp.prop('src', imgsrc).load(function() { var imgw, imgh, imgl, imgt; var tw = temp[0].getBoundingClientRect().width; var th = temp[0].getBoundingClientRect().height; var ww = temp.parent()[0].getBoundingClientRect().width; var wh = temp.parent()[0].getBoundingClientRect().height; if (th < wh) { var tml = (ww - wh*tw/th)/2; temp.css({'margin-left': tml + 'px', 'width': 'auto', 'height': wh + 'px'}); } else { var tmt = Math.round((wh - th)/2); temp.css({'margin-top': tmt + 'px'}); } }); temp.removeClass('lazy'); }); }).siblings('.witem').stop(false, true).fadeOut(400); }).eq(0).trigger('click'); /*banner.hover(function() { autoTime = window.clearInterval(autoTime); }, function() {*/ autoTime = window.setInterval(function (){ banIx++; if (banIx > banItem.length - 1) { banIx = 0; } banbtn.eq(banIx).trigger('click'); }, 3600); //}); /*全屏滚动*/ $("#fullpage").fullpage({ anchors: ['home', 'products', 'project', 'aboutus', 'newsinfo', 'footer'], menu: '#fpmenu', afterLoad: function(anchorLink, index){ if (index == 1){ $('#headpf').css('top', '-70px'); } else if (index == 6) { $('#copypf').css('bottom', '-50px'); } else { $('#copypf').css('bottom', '0'); $('#headpf').css('top', '0'); } console.log(anchorLink); if (anchorLink=='products') { $('#product').find('.link').eq(0).trigger('mouseover'); } else if (anchorLink=='project') { $('#case').find('.bitem').eq(0).trigger('click'); $('#case').find('.btnbox').find('.imglazy').each(function(index, el) { var temp = $(this); var imgsrc = temp.attr('data-original'); temp.prop('src', imgsrc).load(function() { var tw = temp[0].getBoundingClientRect().width; var th = temp[0].getBoundingClientRect().height; var ww = temp.parent()[0].getBoundingClientRect().width; var wh = temp.parent()[0].getBoundingClientRect().height; if (th < wh) { var tml = (ww - wh*tw/th)/2; temp.css({'margin-left': tml + 'px', 'width': 'auto', 'height': wh + 'px'}); } else { var tmt = Math.round((wh - th)/2); temp.css({'margin-top': tmt + 'px'}); } temp.removeClass('imglazy'); }); }); } else if (anchorLink=='aboutus') { $('#about').find('.img-plate').each(function(index, el) { var temp = $(this); var imgsrc = temp.attr('data-original'); if (imgsrc) { temp.hide().prop('src', imgsrc).load(function() { temp.fadeIn(300).removeClass('img-plate lazyload'); }); } }); var honor = $('#honor'), hItem = honor.find('.item'), hbtn = honor.find('.bitem'), hIx = 0, hTime; hbtn.click(function() { hIx = $(this).index(); $(this).addClass('cur').siblings('.bitem').removeClass('cur'); hItem.eq(hIx).stop(false, true).fadeIn(600).siblings('.item').stop(false, true).fadeOut(400); hItem.eq(hIx).find('.lazyload').each(function(index, el) { var temp = $(this); var imgsrc = temp.attr('data-original'); if (imgsrc) { temp.hide().prop('src', imgsrc).load(function() { temp.fadeIn(300).removeClass('lazyload'); }); } }); }).eq(0).trigger('click'); hTime = window.setInterval(function (){ hIx++; if (hIx > hItem.length - 1) { hIx = 0; } hbtn.eq(hIx).trigger('click'); }, 3600); } else if (anchorLink=='newsinfo') { $('#news').find('.lazyload').each(function(index, el) { var temp = $(this); var imgsrc = temp.attr('data-original'); if (imgsrc) { temp.hide().prop('src', imgsrc).load(function() { temp.fadeIn(300).removeClass('lazyload'); }); } }); } } }); }); $(window).load(function() { /*产品*/ var product = $('#product'); product.find('.link').hover(function() { var tindex = $(this).index(); $(this).addClass('cur').siblings('.link').removeClass('cur'); product.find('.titem').eq(tindex).stop(false, true).slideDown('400', function() { product.find('.titem').eq(tindex).find('.imglazy').each(function(index, el) { var temp = $(this); var imgsrc = temp.attr('data-original'); temp.prop('src', imgsrc).load(function() { var imgw, imgh, imgl, imgt; var realw = temp.width(); var realh = temp.height(); var ww = temp.parents('.imgwr').width(); var wh = temp.parents('.imgwr').outerHeight(); imgh = ww*realh/realw; if (realh < wh) { imgt = (wh - realh)/2; temp.css({'margin-top': imgt + 'px'}); } }); }); }).siblings('.titem').stop(false, true).slideUp(400); }); product.find('.titem').each(function () { var temp = $(this), tindex = temp.index(), wrapS = temp.find('.slidewr'), wrapL = temp.find('.imglist').find('.item').length, windex = 0, wleft; if (wrapL < 1) { wrapL = 1; } temp.find('.prev').click(function(event) { windex--; if (windex < 0) { windex = wrapL - 2; } slidefn(windex); }); temp.find('.next').click(function(event) { windex++; if (windex > wrapL - 2) { windex = 0; } slidefn(windex); }); function slidefn(index) { wleft = -index*2.6; wleft2 = -index*52; if (!supportCss3('animation-play-state')) { wrapS.removeClass('trs06s'); wrapS.stop(false, true).animate({left: wleft2 + '%'}, 600); } else { wrapS.css({ '-webkit-transform': 'translate3d(' + wleft + '%, 0px, 0px)', '-ms-transform': 'translate3d(' + wleft + '%, 0px, 0px)', '-o-transform': 'translate3d(' + wleft + '%, 0px, 0px)', 'transform': 'translate3d(' + wleft + '%, 0px, 0px)' }); } } }); /*工程*/ var casewr = $('#case'); var caseS = casewr.find('.slidewr'); casewr.find('.bitem').click(function(event) { $(this).addClass('cur').siblings('.bitem').removeClass('cur'); var wleft = -$(this).index()*10; var wleft2 = -$(this).index()*100; if (!supportCss3('animation-play-state')) { caseS.removeClass('trs06s'); caseS.stop(false, true).animate({left: wleft2 + '%'}, 600); } else { caseS.css({ '-webkit-transform': 'translate3d(' + wleft + '%, 0px, 0px)', '-ms-transform': 'translate3d(' + wleft + '%, 0px, 0px)', '-o-transform': 'translate3d(' + wleft + '%, 0px, 0px)', 'transform': 'translate3d(' + wleft + '%, 0px, 0px)' }); } casewr.find('.item').eq($(this).index()).find('.imglazy').each(function(index, el) { var temp = $(this); var imgsrc = temp.attr('data-original'); temp.prop('src', imgsrc).load(function() { var tw = temp[0].getBoundingClientRect().width; var th = temp[0].getBoundingClientRect().height; var ww = temp.parent()[0].getBoundingClientRect().width; var wh = temp.parent()[0].getBoundingClientRect().height; if (th < wh) { var tml = (ww - wh*tw/th)/2; temp.css({'margin-left': tml + 'px', 'width': 'auto', 'height': wh + 'px'}); } else { var tmt = Math.round((wh - th)/2); temp.css({'margin-top': tmt + 'px'}); } temp.removeClass('imglazy'); }); }); }); /*荣誉 var honor = $('#honor'), hItem = honor.find('.item'), hbtn = honor.find('.bitem'), hIx = 0, hTime; hbtn.click(function() { hIx = $(this).index(); $(this).addClass('cur').siblings('.bitem').removeClass('cur'); hItem.eq(hIx).stop(false, true).fadeIn(600).siblings('.item').stop(false, true).fadeOut(400); }).eq(0).trigger('click'); hTime = window.setInterval(function (){ hIx++; if (hIx > hItem.length - 1) { hIx = 0; } hbtn.eq(hIx).addClass('cur').siblings('.bitem').removeClass('cur'); hItem.eq(hIx).stop(false, true).fadeIn(600).siblings('.item').stop(false, true).fadeOut(400); }, 3600);*/ /*新闻*/ var news = $('#news'); var npid = news.find('.top').find('.tit').attr('data-artid'); news.find('.row').eq(6).hide(); news.find('.list').find('.tit').each(function () { var aid = $(this).attr('data-artid'); if (aid == npid) { $(this).parents('.row').hide(); news.find('.row').eq(6).show(); } }); }); /*window.onload = function () { imgCenter('case'); }*/ /*-----图片调整尺寸 居中外框 外框不确定-----*/ function imgCenter(oid) { var imgH, imgW, imgL, imgT; var imgArray = document.getElementById(oid).getElementsByTagName('img'); for (var i = imgArray.length - 1; i >= 0; i--) { ww = imgArray[i].parentNode.offsetWidth; wh = imgArray[i].parentNode.offsetHeight; imgH = imgArray[i].offsetHeight; if (imgH < wh) { imgW = ww*wh/imgH; imgL = (ww - imgW)/2; imgArray[i].style.marginLeft = imgL + 'px'; imgArray[i].style.width = imgW + 'px'; imgArray[i].style.height = wh + 'px'; } else { imgT = (wh - imgH)/2; imgArray[i].style.marginTop = imgT + 'px'; } } }