$(function(){ search_width(); check_search("header_search"); open_css("index_gonggao"); gototop(); selectopen("gotopage"); }); $(window).load(function(){ $("article").removeclass("img_loading"); footer(); menu_fixed(); main_news_fixed(); main_product_fixed(); }); $(window).resize(function(){ search_width(); footer(); menu_fixed(); main_news_fixed(); main_product_fixed(); }); function search_width(){ var body_w = $(document.body).width(); var right = parseint($("header .icon").css("right")) * 2; var width = body_w - right; $("header .icon .icon_search dl").css("width",width+"px"); }; function check_search(id){ var css = "#"+id+" "; var dim_key = $(css+"input[name='wd']").attr("placeholder"); var get_key = ""; $(css).submit(function(){ get_key = $(css+"input[name='wd']").val().replace(/\ +/g,""); if(get_key == "" || dim_key == get_key){ alert(dim_key); $(css+"input[name='wd']").focus(); return false; } }); }; function footer(){ var html_h = $(window).height() + 5; var body_h = $(document.body).height() + 5; if(html_h >= body_h){ $("footer").attr("id","footer"); }else{ $("footer").removeattr("id"); }; //console.log(html_h+","+body_h); }; function open_css(css){ css = "."+css+" "; $(css+".classname .button").click(function(){ if(!$(css).hasclass("open")){ $(css).addclass("open"); }else{ $(css).removeclass("open"); } }); }; function gototop(){ var css = "footer .gototop"; $(function(){ $(window).scroll(function(){ if ($(window).scrolltop() > 200){ $(css).addclass("open"); }else{ $(css).removeclass("open"); } }); $(css).click(function(){ $("html,body").animate({scrolltop:0},350); }); }); }; function menu_fixed(){ var css = ".main_menu .menu.fixed"; if($(css).length > 0){ var top = $("main").offset().top; $(function(){ $(window).scroll(function(){ if($(window).scrolltop() > top){ $(css).attr("id","menu_fixed"); }else{ $(css).removeattr("id"); } }); }); } }; function main_news_fixed(){ if($("main .main_news_right.fixed").length > 0){ var main_h = $("main").height(); var main_l = $("main .main_news_right").height(); var menu_h = $(".main_menu").height(); if(main_h - menu_h > main_l){ var start = $("main").offset().top; var over = $("footer").offset().top - start - main_l - parseint($("footer").css("margintop")) - menu_h; $(window).scroll(function(){ var top = $(document).scrolltop() - 50; var stop = top - start; if(top < start){ stop = menu_h; }else if(top - start > over){ stop = over + menu_h; }else{ stop = stop + menu_h; } $("main .main_news_right").addclass("main_news_fixed").css("top",stop+"px"); }); } } }; function main_product_fixed(){ if($("main .main_product_right.fixed").length > 0){ var main_h = $("main").height(); var main_l = $("main .main_product_right").height(); var menu_h = $(".main_menu").height(); if(main_h - menu_h > main_l){ var start = $("main").offset().top; var over = $("footer").offset().top - start - main_l - parseint($("footer").css("margintop")) - menu_h; $(window).scroll(function(){ var top = $(document).scrolltop() - 50; var stop = top - start; if(top < start){ stop = menu_h; }else if(top - start > over){ stop = over + menu_h; }else{ stop = stop + menu_h; } $("main .main_product_right").addclass("main_product_fixed").css("top",stop+"px"); }); } } }; function selectopen(css){ $("."+css+" .value").click(function(){ if(!$(this).next("dl").hasclass("open")){//没有打开的情况 $(".allselect .open").removeclass("open"); if($("."+css+" dl.open").length == 1){ }else{ $(this).addclass("open"); $(this).next("dl").addclass("open"); } }else{//打开的情况 if($("."+css+" dl.open").length == 1){ $(this).removeclass("open") $(this).next("dl").removeclass("open"); }else{ } } return false; }); document.onclick = function(){ $(".allselect .open,.gotopage .open").removeclass("open"); //return false //加上这个a标签将不能链接; }; }; function img_view(title,alt){ $("article img").each(function(){ if(!$(this).hasclass("alt")){ $(this).removeattr("title").removeattr("alt"); $(this).attr("title",title).attr("alt",alt); } }); }; $(".tab_list li a").hover(function(){ var id = $(this).attr("data-id"); var css = "#"+$(this).parent().parent().parent().attr("id"); if(id != undefined){ $(css+" .tab_list .active").removeclass("active"); $(this).addclass("active"); $(css+" .tab_view").hide(); $(css+" .tab_view.view"+id).show(); } }); function hidepop(){ settimeout(function(){ $("#pop_div").removeattr("class"); },200); }; function showapply(id,name,edu){ var css = ".pop_apply "; if(id == 0){ return false; }else{ $(css+".tips").removeclass("hidden"); $(css+"input[name='job_gangwei']").val(name); $(css+"input[name='job_id']").val(id); $(css+"select[name='job_edu']").find("option[value='"+edu+"']").attr("selected",true); $(css+"select[name='job_edu'] option").each(function(){ if($(this).attr("value") < edu){ $(this).hide(); } }); } $("#pop_div,"+css).addclass("open"); }; $(".pop_apply .close").click(function(){ $(".pop_apply").removeclass("open"); hidepop(); }); $(".pop_apply .tips .submit").click(function(){ $(".pop_apply .tips").addclass("hidden"); });