/* ---------- DOM加载完毕 ---------- */ $(document).ready(function(){ var sideH = $(".sidebar").height(); var mainH = $(".main").height(); if(sideH < mainH){ $(".sidebar .bd").css({'height':mainH -57}) }else{ $(".main").css('height',sideH-25) } $('.focusBox').each(function(){ var data = eval($(this).attr('focus-data')); var h = $(this).attr('focus-height'); var type = $(this).attr('focus-type'); type = type ? type : 'fade'; //console.log(data); $(this).scrollpic({ list: data, height: h, effect: type, showNumTxt: false, showTxt:false, showArr:false }); }); //新闻公告 $('.nfocusBox').each(function(){ var data = eval($(this).attr('focus-data')); var h = $(this).attr('focus-height'); var type = $(this).attr('focus-type'); type = type ? type : 'fade'; //console.log(data); $(this).scrollpic({ list: data, height: h, effect: type, showNumTxt: true, showTxt:true, showArr:false }); }); /* ============================== 公共脚本 ============================== Begin */ /* ---------- 去除虚线(部分元素) ---------- */ $("#JS_thumbnailSlide li a").bind("focus",function(){ if(this.blur){ this.blur(); }; }); /* 输入框点击去除默认文字 */ var inputval_h=$(".normal_search input").val(); $(".normal_search input").focus(function(){ if($(this).val()==inputval_h){ $(this).val(""); } }) .blur(function(){ if($(this).val()==""){ $(this).val(inputval_h); } }); /* 侧边栏email处输入框点击去除默认文字 */ var inputval_e=$(".email_search input").val(); $(".email_search input").focus(function(){ if($(this).val()==inputval_e){ $(this).val(""); } }) .blur(function(){ if($(this).val()==""){ $(this).val(inputval_e); } }); /* ---------- 关闭提示信息 remind ---------- */ $("span.remind_close").click(function(){ $(this).parent("div.remind").hide(); }); $("a.lightbox").lightBox(); /* ---------- 表单验证 form validate ---------- */ $("#form_validate").validate(); //默认表单验证 /*------------------index 页面效果--------------------*/ /*主导航点击后效果*/ $(".nav_item .nav_target").click(function(){ $(this).addClass("nav_target_current").parents(".nav_item").siblings(".nav_item").find(".nav_target").removeClass("nav_target_current"); }); $("#nav .nav_item").each(function(){$(this).hover(function(){ $(this).addClass("hover").children(".nav_sublist").show(100); },function(){ $(this).removeClass("hover").children(".nav_sublist").hide(100); });}) /*主导航 三级菜单 hover 后效果*/ $("#nav .nav_subitem").hover(function(){ $(this).addClass("nav_subitem_hover").children(".nav_extralist").show(100); },function(){ $(this).removeClass("nav_subitem_hover").children(".nav_extralist").hide(0); }); /* index页面的 hover 效果 */ $(".home_product_inner .pro_title").hover(function(){$(this).addClass("pro_title_hover"); },function(){$(this).removeClass("pro_title_hover") }); $(".column .btn_more").hover(function(){$(this).addClass("btn_more_hover"); },function(){$(this).removeClass("btn_more_hover") }); $(".normal_newsletter .btn_submit").hover(function(){$(this).addClass("btn_submit_hover"); },function(){$(this).removeClass("btn_submit_hover") }); /*category 页面 hover 效果*/ $(".pro_slide .btn_more").hover(function(){$(this).addClass("btn_more_hover"); },function(){$(this).removeClass("btn_more_hover") }); /*category 页面 pagination 点击后效果*/ $(".pagination .numb").click(function(){ $(this).addClass("numb_current").siblings(".numb").removeClass("numb_current"); }); /*product 页面按钮 hover 效果*/ $(".product_btn .btn_make, .btn_make_inquiry").hover(function(){$(this).addClass("btn_make_hover"); },function(){$(this).removeClass("btn_make_hover") }); $(".product_btn .btn_add").hover(function(){$(this).addClass("btn_add_hover"); },function(){$(this).removeClass("btn_add_hover") }); $(".product_btn .btn_enter").hover(function(){$(this).addClass("btn_enter_hover"); },function(){$(this).removeClass("btn_enter_hover") }); $(".inquiry_form_fill .btn_submit").hover(function(){$(this).addClass("btn_submit_hover"); },function(){$(this).removeClass("btn_submit_hover") }); $(".btn_make_inquiry_all").hover(function(){$(this).addClass("btn_make_inquiry_all_hover"); },function(){$(this).removeClass("btn_make_inquiry_all_hover") }); /*product页面*/ $(".pro_sheet .pro_data_table tr").each(function(){$(this).find("td:last").css("border-right", "none");}) $(".pro_data_table tbody tr:odd td").css("background-color","#f1f1f1"); $(".pro_data_table tbody tr:even td").css("background-color","#fff"); /*lens packing*/ $(".lens_table tbody tr:odd td").css("background-color","#f6f8f9"); $(".lens_pack_table tbody tr:even td, .material_table tbody tr:even td, .random_table tbody tr:even td").css("background-color","#f6f8f9"); $(".home_catalog a:last").css("background","none"); /* ============================== 公共脚本 ============================== End */ /*侧边sidenav栏点击后效果*/ /*$(".normal_target").first().toggleClass("normal_target_selected"); $(".normal_sublist").first().show();*/ $(".normal_target").hover(function(){ $(this).addClass("normal_target_hover").parent(".normal_item").siblings(".normal_item").removeClass("normal_target_hover"); },function(){ $(this).removeClass("normal_target_hover"); }); $(".normal_target").click(function(){ _this = $(this); if(_this.next(".normal_sublist").length > 0){ _this.addClass("normal_target_selected").next(".normal_sublist").slideToggle(0) .parent(".normal_item").siblings(".normal_item") .find(".normal_target").removeClass("normal_target_selected").end() .find(".normal_sublist").slideUp(0); return false; }else{ _this.removeClass("normal_target_selected") .parent(".normal_item").siblings(".normal_item") .find(".normal_target_selected").removeClass("normal_target_selected").next(".normal_sublist").slideUp(0); }; }); /* ============================== 首页 脚本 ============================== Begin */ /* ---------- 首页大图轮转 promo ---------- */ /*$("#JS_promo a").addClass("bigimg"); $("#JS_promo img").banner_thaw({ thumbObj:".slide_triggers", thumbNowClass:"current", changeTime:3000, delayTime:2000 });*/ /* ---------- 首页产品滚动 carousel ---------- */ $("#JS_promo").carousel({ btnNext: "#JS_promoTriggers_next", btnPrev: "#JS_promoTriggers_prev", scrolls: 1, auto:true, speed:1000, circular: false, visible: 1 }); /* ============================== 列表页 脚本 ============================== Begin */ /*filter*/ var timeFilterHover; $(".filter_select").hover(function(){ _this = $(this); timeFilterHover = setTimeout(function(){ _this.find(".select_list").show().parents(".filter_item").siblings().find(".select_list").hide() },100); },function(){ _this = $(this); clearTimeout(timeFilterHover); _this.find(".select_list").hide(); }); /* ============================== 产品页 脚本 ============================== Begin */ //gallery $("#JS_zoom").zoom({ xzoom: 360, yzoom: 360, offsetTop: 0, offset: 0, lens:1 }); $("#JS_thumbnailSlide").carousel({ btnNext:"#JS_thumbnailNext", btnPrev:"#JS_thumbnailPrev", scrolls:1, circular: false, visible:4 }); /* var small_img = 60; var mid_img = 360; $(".thumbnail ul li:first").addClass("hover"); var thumbTimeHover,thumbTimeOut; $(".thumbnail ul li").hover(function(){ var _this=$(this); clearTimeout(thumbTimeOut); thumbTimeHover = setTimeout(function(){ _this.addClass("hover").siblings().removeClass("hover"); $("#picture").attr("src",_this.find('img').attr("src").replace(small_img + "x" + small_img,mid_img + "x" + mid_img)); $("#picture").parent(".picbox").attr("href",_this.find('img').attr("src").replace("_" + small_img + "x" + small_img,"")); },150); },function(){ var _this=$(this); clearTimeout(thumbTimeHover); }); $(".thumbnail ul li").click(function(){ return false; })*/ var small_img = 60; var mid_img = 360; $(".thumbnail ul li:first").addClass("hover"); var thumbTimeHover,thumbTimeOut; $(".thumbnail ul li").hover(function(){ var _this=$(this); clearTimeout(thumbTimeOut); thumbTimeHover = setTimeout(function(){ _this.addClass("hover").siblings().removeClass("hover"); $("#picture").attr("src",_this.find('img').attr("src").replace(small_img + "x" + small_img,mid_img + "x" + mid_img)); $("#picture").parent("a").attr("href",_this.find('img').attr("src").replace("_" + small_img + "x" + small_img,"")); },150); },function(){ var _this=$(this); clearTimeout(thumbTimeHover); }); $(".thumbnail ul li").click(function(){ return false; }) //send inquiry $("#JS_btnSend").click(function(){ offsetTop=$("#detail").offset().top; $("html,body").animate({scrollTop:offsetTop},300); $("#JS_sendInquiryTab").click(); return false; }) //tips_inquiry close $(".tips_inquiryadd .btn_close").click(function(){ $(this).parent(".tips_inquiryadd").hide(); }); //detail tab $(".JS_tabHolder > li").each(function(index){ $(".JS_tabHolder > li:first").addClass("tab_item_current"); $(".JS_tabContent .JS_tabPanel:first").show(); $(this).click(function(){ var _this=this; $(_this).addClass("tab_item_current").siblings().removeClass("tab_item_current"); $(_this).parents(".tab_holder").siblings(".JS_tabContent").find(".JS_tabPanel").eq(index).show().siblings().hide(); }) }); /* ============================== 询盘页 脚本 ============================== */ //inquiry_fill $("#JS_inquiryInfoTitle").click(function(){ $(this).toggleClass("inquiry_info_hide"); $(this).parent(".hd").siblings(".bd").slideToggle(100); return false; }); $("#JS_btnMoreoption").click(function(){ $(this).toggleClass("btn_moreoption_hide"); if($(this).text()=="More options"){ $(this).text("Hide options"); }else{ $(this).text("More options"); } //$("#JS_moreoptions").slideToggle("100"); $("#JS_moreoptions").toggleClass("moreoptions"); return false; }); /*textarea 多行文本输入框字数控制*/ var MessageObj = $(".message_length"); MessageObj.keyup(function(){ var _len=$(this).val().length; if(_len > -1 && _len<=1000){ var _remain=parseInt(1000-_len)>'0'?parseInt(1000-_len):'0'; var _str = '
' + _remain + 'characters left.
' $(".message_tips_wrap").html(_str); }else{ $(this).val($(this).val().substr(0,1000)); $(".message_tips_wrap").html("
0 characters left
"); } }); //faq slide $(".faq_item_content").first().show(); $(".faq_name").first().addClass("faq_name_selected"); $(".faq_name").click(function(){ $(this).toggleClass("faq_name_selected"); $(this).parent().toggleClass("faq_item_selected"); $(this).next(".faq_item_content").slideToggle(100).parent().siblings().find(".faq_item_content").slideUp(100); $(this).parent().siblings().removeClass("faq_item_selected").find(".faq_name").removeClass("faq_name_selected"); }); /* ============================== certification 页 脚本 ============================== */ /**-----------------------------------------------------------* * @name : Imgshow JS * @type :* @explain :*/ var imgshowThumbItem = $("#JS_imgshowThumbSlide .list_item"); /*thumb slide*/ imgshowThumbItem.first().addClass("hover"); if(imgshowThumbItem.length > 0){ $("#JS_imgshowThumbSlide").carousel({ btnNext:"#JS_imgshowThumbNext", btnPrev:"#JS_imgshowThumbPrev", scrolls:1, vertical:false, circular: false, visible:3 }); }; /*change picture*/ var _small_img = 70; var imgshowPic = $("#JS_imgshowPic"); var imgshowPicBox = $("#JS_imgshowPicBox"); var imgshowPicId = "JS_imgshowPic"; var imgshowPicBoxId = "JS_imgshowPicBox"; imgshowPic.loadthumb({"src":imgshowPicBox.find("img").attr("src"),"imgId":imgshowPicId,"parentId":imgshowPicBoxId}); imgshowThumbItem.click(function(){ var _this=$(this); _this.addClass("hover").siblings().removeClass("hover"); imgshowPic.attr("src",_this.find('img').attr("src").replace("_" + _small_img + "x" + _small_img,"")); imgshowPicBox.find("a").attr("href",_this.find('img').attr("src").replace("_" + _small_img + "x" + _small_img,"")); imgshowPic.loadthumb({"src":imgshowPicBox.find("img").attr("src"),"imgId":imgshowPicId,"parentId":imgshowPicBoxId}); return false; }); $(".imgshow_thumb .cert_tips:first").show(); $("#JS_imgshowThumbSlide li").each(function(index){ $(this).click(function(){ $(this).addClass("hover").siblings().removeClass("hover"); $(this).parents(".imgshow_thumb").find(".cert_tips").eq(index).show().siblings().hide(); }); }); /*-----------------------------------------------------------end**/ });