var isIE6 = !-[1,] && !window.XMLHttpRequest, isIE = !!window.ActiveXObject, isIE7 = isIE && navigator.appVersion.split(";")[1].replace(/[ ]/g,"")=="MSIE7.0"; /****************************************** *** *** *** 瀵勭敓缁勫悎寮忕户鎵 *** *** *** ******************************************/ function inheritPrototype(subType, superType) { function F(){}; F.prototype = superType.prototype; var prototype = new F(); prototype.constructor = subType; //澧炲己瀵硅薄 subType.prototype = prototype; //鎸囧畾瀵硅薄 } /****************************************** *** *** *** 妯℃嫙婊氬姩鏉 *** *** *** ******************************************/ function ImitateScroll(scrollBox, scrollObj, scrollBar, scrollBtn) {//scrollBox琚粴鍔ㄥ璞″妗嗭紝scrollObj琚粴鍔ㄥ璞★紝scrollBar婊氬姩鏉″潡锛屾粴鍔ㄦ潯鎸夐挳 this.init(scrollBox, scrollObj, scrollBar, scrollBtn); } ImitateScroll.prototype = { scale:function() {//琚粴鍔ㄥ璞′笌琚粴鍔ㄥ璞″妗嗙殑楂樺害姣斾緥璁$畻 return (this.scrollObj.scrollHeight/this.scrollBox.clientHeight); }, scrollBtnMouseDown:function(ev) {//婊氬姩鎸夐挳鎸変笅 var _this = this; var disY = ev.clientY - this.scrollBtn.offsetTop;//榧犳爣Y鍧愭爣璺濈婊氬姩鎸夐挳澶撮儴鐨勮窛绂 var maxTop = this.scrollBar.clientHeight - this.scrollBtn.offsetHeight; document.onmousemove = function(ev) { if (document.all) {//ie 绂佹閫夋嫨 document.body.onselectstart = new Function("return false"); } else {// chrome, ff $("body").addClass("chromeOnselectstart") } var oEvent = ev || event; var t = oEvent.clientY - disY; t = t>maxTop ? maxTop : t; t = t<0 ? 0 : t; _this.scrollBtn.style.top = t + "px"; _this.scrollObj.style.top = -t / _this.scrollBar.clientHeight * _this.scrollObj.scrollHeight + "px"; }; document.onmouseup = function() { if (document.all) {//ie 瑙i櫎绂佹閫夋嫨 document.body.onselectstart = new Function("return true"); } else {// chrome, ff $("body").removeClass("chromeOnselectstart") } document.onmousemove = document.onmouseup = null;//娓呴櫎move鍜寀p浜嬩欢 }; }, scrollBoxMousewheel:function(ev) {//榧犳爣婊氳疆婊氬姩 var direct = 0; var topCur = this.scrollBtn.offsetTop; var maxTop = this.scrollBar.clientHeight - this.scrollBtn.offsetHeight; //婊氳疆姣忔婊氬姩锛屾粴鍔ㄦ寜閽璧扮殑璺濈锛屾祴璇昪hrome婊?娆″樊涓嶅涓€灞 var directTop = this.scrollBox.clientHeight / 8 / this.scrollObj.scrollHeight * this.scrollBar.clientHeight; directTop = directTop>0 ? Math.ceil(directTop) : Math.floor(directTop); stopDefault(ev);//绂佹娴忚鍣ㄨ嚜韬殑婊氬姩鏉℃粴鍔ㄦ晥鏋 if (ev.wheelDelta) {//IE/Opera/Chrome direct = ev.wheelDelta; } else if (ev.detail) {//Firefox direct = ev.detail * (-1); } if(parseFloat(direct) > 0) { var topEnd = topCur - directTop; if (topEnd < 0) {topEnd = 0;} } else { var topEnd = topCur + directTop; topEnd = topEnd>maxTop ? maxTop : topEnd; } this.scrollBtn.style.top = topEnd + "px"; this.scrollObj.style.top = -topEnd / this.scrollBar.clientHeight * this.scrollObj.scrollHeight + "px"; }, init:function(scrollBox, scrollObj, scrollBar, scrollBtn) {//鍒濆鍖 this.scrollBox = typeof scrollBox == "string" ? document.getElementById(scrollBox) : scrollBox; this.scrollObj = typeof scrollObj == "string" ? document.getElementById(scrollObj) : scrollObj; this.scrollBar = typeof scrollBar == "string" ? document.getElementById(scrollBar) : scrollBar; this.scrollBtn = typeof scrollBtn == "string" ? document.getElementById(scrollBtn) : scrollBtn; var scale = this.scale();////琚粴鍔ㄥ璞′笌琚粴鍔ㄥ璞″妗嗙殑楂樺害姣斾緥 if (scale <= 1) {//鍒ゆ柇鏄惁杈惧埌浜х敓婊氬姩鏉$殑鏉′欢 this.scrollBar.style.display = "none"; return; } else { this.scrollBar.style.display = "block"; } // if(_this.scrollObj.scrollHeight+_this.scrollObj.offsetTop < _this.scrollBox.clientHeight) // {//鍒ゆ柇琚粴鍔ㄥ璞℃槸鍚︽粴杩囧ご浜 // _this.scrollObj.style.top = _this.scrollBox.clientHeight-_this.scrollObj.scrollHeight+"px"; // } //鍒濆鍖栨粴鍔ㄦ寜閽殑楂樺害鍜宼op鍊 this.scrollBtn.style.height = this.scrollBar.clientHeight / scale + "px";//璁惧畾婊氬姩鎸夐挳鐨勯珮搴 //this.scrollBtn.style.top = -this.scrollObj.offsetTop/this.scrollObj.scrollHeight*this.scrollBar.clientHeight + "px"; var _this = this; this.scrollBtn.onmousedown = function(e) {//婊氬姩鎸夐挳鎷栨嫿浜嬩欢 var e = e || event; _this.scrollBtnMouseDown(e); }; //缁戝畾婊氳疆浜嬩欢 if (this.scrollBox.addEventListener) {//ff3.5浠ヤ笅 this.scrollBox.addEventListener("DOMMouseScroll", function(e) { var e = e || event; _this.scrollBoxMousewheel(e) }, false); } //W3C this.scrollBox.onmousewheel = function(e) { var e = e || event; _this.scrollBoxMousewheel(e) }; //IE/Opera/Chrome } } /****************************************** *** *** *** 绉诲姩涓婂幓涓婄Щ10px *** *** *** ******************************************/ function topMove(el, topTarget) { topTarget = topTarget || 5; $(el).css("position", "relative").hover(function() { $(this).stop().animate({top: -topTarget}, 300); }, function() { $(this).stop().animate({top: 0}, 300); }); }; /****************************************** *** *** *** 婊氬姩鍒颁綅缃 *** *** *** ******************************************/ function scrollTo(target, time) { var $html = $("html, body") time = time || 1000; // 鍒ゆ柇浼犲叆鐨勬槸涓€涓暟瀛楄繕鏄竴涓璞 switch (typeof target) { case "number": break; default: target = $(target).offset().top; } // 婊氬姩杩囩▼涓墜鍔ㄨЕ鍙戜簡婊氳疆浜嬩欢锛屽垯鍋滄婊氬姩 $html.on("mousewheel.scrollTo", function() { $("html, body").stop(); $html.off("mousewheel.scrollTo"); }); // 寮€濮嬫粴鍔 $("html, body").animate({scrollTop: target}, time, "easeInOutCubic", function() { $html.off("mousewheel.scrollTo"); }); } /****************************************** *** *** *** 鍥剧墖鍗犳弧 *** *** *** ******************************************/ function imgFull(imgParent) { /***** 鍥剧墖灏哄鑷€傚簲鐖剁骇瀹瑰櫒锛屼笉鍙樺舰 * 涓嶅浐瀹氬昂瀵稿浘鐗囷紝纭繚鍦ㄧ埗绾ф拺婊 * 濡傦細鍥剧墖楂樺害姣斾緥灏忥紝鍒欓珮搴︽拺婊★紝瀹藉害瓒呭嚭鎴彇 * imgParent: 闇€瑕佽嚜閫傚簲鐨勫浘鐗囩殑鐖跺鍣紝涔熷彲涓轰竴缁勫浘鐗囩殑绁栧厛瀹瑰櫒 * 鍥剧墖鍙拺婊$埗绾э紝闈炵鍏堢骇鍒 */ // 鑾峰彇鍥剧墖锛屽鏈紶鍏ュ弬鏁帮紝鍒欒幏鍙杁ata-img=full鐨勫浘鐗 var $imgArr = imgParent ? $(imgParent).find("img") : $("[data-img=full]"), len = $imgArr.length, i = 0; // 鍥剧墖鍘嬬缉(鎷変几)瑁佸壀 function init() { var width = $(this).width(), height = $(this).height(), $parent = $(this).parent(), parentWidth = $parent.width(), parentHeight = $parent.height(); // 鍒ゆ柇闀垮姣斾緥 if (width/parentWidth < height/parentHeight) { $(this).width(parentWidth); $(this).height("auto"); //alert(this.src); $(this).css({"position": "absolute", "left": "0", "top": -($(this).height() - parentHeight)/2}); } else { $(this).width("auto"); $(this).height(parentHeight); $(this).css({"position": "absolute", "top": "0", "left": -($(this).width()- parentWidth)/2}); } // 鍒ゆ柇鏄惁鍔犺浇瀹岋紝闅愯棌loading鍥炬爣 if (++i == len) { removeLoading(); } //$(this).stop().animate({opacity: 1}, 500); } $imgArr.each(function() { var $parent = $(this).parent(), img = new Image(), $self = $(this); // 鍒濆鍖栫埗绾ц秴鍑洪殣钘 $parent.css({"overflow": "hidden"}); if ($parent.css("position") != "absolute") { $parent.css({"position": "relative"}); } init.call($self[0]); // 鍥剧墖鍔犺浇瀹屾垚鎵ц鍘嬬缉 img.onload = img.onComplete = function() { init.call($self[0]); this.onload = this.onerror = null; img = null; }; img.onerror = function() { img.onload = img.onerror = null; img = null; } img.src = $(this).attr("src"); }); } /****************************************** *** *** *** loading绉婚櫎 *** *** *** ******************************************/ function removeLoading() { $("body").css("overflow", "visible"); $("#loading").fadeOut(); }; $(function() { if ($("#loading")[0]) { $("body").css("overflow", "hidden"); } }); /****************************************** *** *** *** 瀵艰埅鍖哄煙鑷姩鏀剁缉 *** *** *** ******************************************/ var packupHeader, expansionHeader; $(function() { /***** header ******************/ (function() { var $header = $(".header"), // $logo = $header.find(".logo a"), // $guide = $header.find(".guide"), isExpansion = true; packupHeader = function() { if (isIE6) {return;} // $guide.stop().animate({opacity: 0}, 800, function() { // $(this).hide(); // }); // $header.stop().animate({left: "-100%"}, 800, "easeInOutCubic").css("overflow","hidden"); $header.stop().animate({left: "0"}, 800, "easeInOutCubic").css("overflow","visible"); // $logo.stop().animate({height: 67}, 800, "easeInOutCubic"); isExpansion = false; }; expansionHeader = function() { if (isIE6) {return;} $header.stop().animate({left: "0"}, 800, "easeInOutCubic").css("overflow","visible"); // $header.stop().animate({left: "-100%"}, 400, "easeInOutCubic"); // $logo.stop().animate({height: 93}, 400, "easeInOutCubic"); // $guide.show().stop().animate({opacity: 1}, 400); isExpansion = true; }; $(window).on("scroll", function() { var scrollTop = $(this).scrollTop(); if (scrollTop >= 400 && isExpansion) { packupHeader(); } else if (scrollTop < 400 && isExpansion == false) { expansionHeader(); } }); })(); }); // Header // $(function(){ // // Header // (function() { // var $navLi = $(".nav li"), // $proseMenu = $(".prosemenu"), // $ulWrap = $(".prosemenuUl"), // $ul = $ulWrap.find("ul"), // isExpansion = false, // expansionType = 0, // $proseTopA = $(".prosemenuTop dd a"), // $proseBottomA = $(".prosemenuBot dd a"); // // Header Other // $navLi.hover(function(){ // var _height = $(this).find(".semenu").find(".semenuMid a").size()*36 + 17; // $(this).find(".semenu").stop().animate({"height":_height},200); // }, function(){ // $(this).find(".semenu").stop().animate({"height":"0"},200); // }); // $(".semenu a").on("click", function() { // $(".semenu").stop().animate({"height":"0"},200); // }); // // Header VEHICLES // $navLi.eq(2).on("mouseleave", function() { // $proseMenu.stop().animate({height: 0}, 200).hide(); // }).find(".nav-tl").on("mouseenter", function () { // $proseMenu.stop().show().animate({height: 212}, 200); // }); // // 鍒濆鍖杣l鐨勫搴 // $ul.each(function() { // $(this).width(function() { // var $li = $(this).find("li"); // return $li.outerWidth()*$li.length; // }); // }); // var timer; // // 闅愯棌$ulWrap // function hideUlWrap() { // timer = window.setTimeout(function() { // $proseTopA.removeClass("cur"); // $proseBottomA.removeClass("cur"); // $ulWrap.stop().animate({height: 0}, 500, function() { // $proseMenu.height(212); // isExpansion = false; // expansionType = 0; // }); // }, 10); // }; // $proseTopA.hover(function() { // var index = $(this).index(); // clearTimeout(timer); // $proseMenu.height(439); // $proseTopA.removeClass("cur"); // $proseBottomA.removeClass("cur"); // $(this).addClass("cur"); // // 鍒ゆ柇鏄剧ず鐨勬槸鍝睆 // if (expansionType != 1) { // $ulWrap.find("ul").eq(0).css({left: -950*index}); // $ulWrap.find("ul").eq(1).stop(); // } else { // $ulWrap.find("ul").eq(0).stop().animate({left: -950*index}, 500, "easeInOutCubic"); // } // // 鍒ゆ柇榛樿鏄惁灞曞紑 // if (isExpansion) { // $ulWrap.stop().animate({scrollTop: 0, height: 227}, 500); // } else { // $ulWrap.scrollTop(0); // $ulWrap.stop().animate({height: 227}, 500); // isExpansion = true; // } // expansionType = 1; // }, function() { // hideUlWrap(); // }); // $proseBottomA.hover(function() { // var index = $(this).index(); // clearTimeout(timer); // $proseMenu.height(439); // $proseTopA.removeClass("cur"); // $proseBottomA.removeClass("cur"); // $(this).addClass("cur"); // // 鍒ゆ柇鏄剧ず鐨勬槸鍝睆 // if (expansionType != 2) { // $ulWrap.find("ul").eq(0).stop(); // $ulWrap.find("ul").eq(1).css({left: -950*index}); // } else { // $ulWrap.find("ul").eq(1).stop().animate({left: -950*index}, 500, "easeInOutCubic"); // } // // 鍒ゆ柇榛樿鏄惁灞曞紑 // if (isExpansion) { // $ulWrap.stop().animate({scrollTop: 227, height: 227}, 500); // } else { // $ulWrap.scrollTop(227); // $ulWrap.stop().animate({height: 227}, 500); // isExpansion = true; // } // expansionType = 2; // }, function() { // hideUlWrap(); // }); // $ulWrap.hover(function() { // clearTimeout(timer); // }, function() { // hideUlWrap(); // }); // })(); // // global site // $(".global-site").hover(function() { // $(this).find("span").stop().slideDown(); // }, function() { // $(this).find("span").stop().slideUp(); // }); // }); // $(function() { // scrollTo(".cars-interior"); // }) // /**** 棣栭〉鏂伴椈鑷姩婊氬姩 *****/ // var $rmdCont = $(".index-news .cont"), // rmdTimer = null; // function rmdAnimate() { // $rmdCont.stop().animate({scrollTop: 33}, 500, function() { // $rmdCont[0].scrollTop = 0; // $rmdCont.find("a").eq(0).appendTo($rmdCont); // }); // } // if ($rmdCont.find("a").length >= 1) { // rmdTimer = setInterval(rmdAnimate, 5000); // $rmdCont.hover(function() { // clearInterval(rmdTimer); // }, function() { // rmdTimer = setInterval(rmdAnimate, 5000); // }); // }