/* name:changan date:2014.10.10 */ // 文件路径 // var styles_url = base_url+'s/styles/'; // var scripts_url = base_url+'s/scripts/'; // var jwplayer_url = base_url+'s/jwplayer/'; // 加载 $(function(){ data.init(); lead.init(); indexbanner(); }); // 初始化屏宽区间 var oldmedia = getmedia(); $(window).on({ 'load':function(){ vsize(); justscroll(); videomedia(); }, resize:function(){ var newmedia = getmedia(); if( newmedia != oldmedia ){ vsize(); oldmedia = newmedia; } videomedia(); }, 'scroll':function(){ vscroll(); } }) // 判断浏览器 function mybrowser(){ var useragent = window.navigator.useragent; var isopera = useragent.indexof("opera") > -1; var isie = useragent.indexof("compatible") > -1 && useragent.indexof("msie") > -1 && !isopera ; var isff = useragent.indexof("firefox") > -1 ; var issafari = useragent.indexof("safari") > -1 ; if(isie){ if( /msie 6.0/ig.test(useragent) ){ return 'ie6' } if( /msie 7.0/ig.test(useragent) ){ return 'ie7' } if( /msie 8.0/ig.test(useragent) ){ return 'ie8' } if( /msie 9.0/ig.test(useragent) ){ return 'ie9' } return 'ie'; } if(isff){ return "ff"; } if(isopera){ return "opera"; } return false; } // 判断是否为phone function isphone(){ var useragent = window.navigator.useragent; var agents = new array("android", "iphone", "symbianos", "windows phone"); var flag = false; for (var v = 0; v < agents.length; v++) { if (useragent.indexof(agents[v]) > -1) { flag = true; break; } } return flag; } // window resize function vsize(){ var media = getmedia(); // if( mybrowser() == 'ie7' || mybrowser() == 'ie6' ){ ie7fun(media) } if( media == 'xs' ){ phoneauto = function(){ var wrap = $('.phone-nav-wrap'); phonenavwidth = parseint( wrap.width()/4 ); wrap.children("ul").css('left','-'+phonenavwidth*phonepage+'px').children("li").width(phonenavwidth); } $(window).resize(phoneauto); if(phonebloor){ phonenav(); phonebloor = false; } } // 首页banner // if( media == 'xs' ){ // var _width = $(window).width(); // var _size = 640/300; // var _height = _width/_size; // var _img = $('.index-ph-banner .slides img'); // // $('.index-ph-banner').height(_height) // var imgwidth = _img.eq(0).width(); // _img.css({marginleft:'-'+ (imgwidth/2) +'px' }); // } } function indexbanner(){ var winb = $(window).width(); var bansize = 1920/700; $('.index-banner').height(winb/bansize); } function videomedia(){ // 视频调整 if( $('#video-cell').length > 0 ){ var cell = $('#video-cell'); var cwidth = cell.width(); var csize = 650/405; var chei = parseint(cwidth/csize) cell.children().css({width:cwidth+'px',height:chei+'px'}) } } function getmedia(){ var winwidth = $(window).width(); if( winwidth > 1200 ){ return 'lg'; }else if( winwidth > 992 ){ return 'md'; }else if( winwidth > 768 ){ return 'sm'; }else{ return 'xs'; } } // ie7兼容 function ie7fun(param){ if( param != 'xs' ){ var head = $('head:eq(0)'); $('.iebootstrap',head).remove(); head.append(''); $('.iebootstrap',head).attr({rel:'stylesheet',type:'text/css',href:'../../css/changan/iebootstrap-'+param+'.css'}); } } function vscroll(){ var top = $(document).scrolltop(); if( top > 100 ){ $('.backtop').fadein(300) }else{ $('.backtop').fadeout(300) } } var data = { point:function(){ $('.data-focus').each(function(){ var _text = $(this).val(); $(this).on({ 'focus':function(){ if( $(this).val() == _text ){ $(this).val('') } }, 'blur':function(){ if( $(this).val() == '' ){ $(this).val(_text) } } }) }) }, select:function(){ $('.data-select').each(function(index){ var _this = $(this); var width = _this.width(); var option = _this.children('option'); var length = option.length; var str = ''; var selectedtxt = option.eq(0).text(); _this.hide().after('
'); for(var i = 0;i'+option.eq(i).text()+''; } var wrap = _this.next('.temp-select'); var html = '

'+selectedtxt+'

'+str+'

'; wrap.append(html); var up = wrap.children('.up'); var down = wrap.children('.down'); up.bind('click',function(e){ e.preventdefault(); e.stoppropagation(); if($(this).hasclass('on')){ down.hide(); $(this).removeclass('on'); }else{ down.show(); $(this).addclass('on'); $(this).parent().siblings('.temp-select').children('.up').removeclass('on').next('.down').hide(); } }); down.children('a').bind("click",function(e){ e.preventdefault(); var text = $(this).text(); var param = $(this).index(); if(text=='2014'){ $('.sel-show').eq(1).show().siblings('.sel-show').hide();; }if(text=='2013'){ $('.sel-show').eq(0).show().siblings('.sel-show').hide(); } up.text(text); _this.children().eq(param).prop('selected',true).siblings().prop('selected',false); down.hide(); up.removeclass('on'); if( _this.attr('onchange') ){ _this.change(); } }); $(document).bind('click',function(){ down.hide(); up.removeclass('on'); }) }); }, slide:function(){ $('.temp-menu .list').each(function(){ var _this = $(this); var dot = _this.children(".dot"); var ul = _this.children(".down"); $(this).children(".dot").click(function(e){ if( ul.children().length > 0 ){ e.preventdefault(); if($(this).hasclass('active')){ ul.slideup() }else{ ul.slidedown() } $(this).toggleclass('active'); $(this).parent('li').siblings().find('.down').slideup(); $(this).parent('li').siblings().find('.dot').removeclass('active'); } }) }); $('.temp-big a').click(function(e){ e.preventdefault(); if( $(e.target).hasclass('a3') ){ $('.temp-right-bd').css('fontsize','16px') }else if( $(e.target).hasclass('a1') ){ $('.temp-right-bd').css('fontsize','12px') }else if( $(e.target).hasclass('a2') ){ $('.temp-right-bd').css('fontsize','14px') } $(this).addclass('on').siblings().removeclass("on") }) }, phone:function(){ var header = $('.header'); var icon = $('.phone-icon',header); var cell = $('.phone-cell',header); var nav = $('.phone-menu',header); icon.children("a").click(function(e){ e.preventdefault(); if( $(this).hasclass('a1') ){ if($(this).hasclass('on')){ cell.hide(); nav.find('ul').hide(); nav.find('a').removeclass('active'); }else{ cell.show(); } $(this).toggleclass('on'); } }) nav.find('li').each(function(){ var _this = $(this); var dot = _this.children('a'); var ul = _this.children('ul'); dot.on('click',function(e){ if( ul.length < 1 ){ return true } e.preventdefault(); if( $(this).hasclass('active') ){ $(this).removeclass('active'); ul.slideup(200); }else{ $(this).parent().siblings('li').children('ul').slideup(); $(this).parent().siblings('li').children('a').removeclass('active'); $(this).parents('.li01').siblings('li').find('.li02').each(function(){ $(this).children('ul').hide().siblings('a').removeclass('active'); }); $(this).addclass('active'); ul.slidedown(200); } }) }); }, init:function(){ this.point(); this.select(); this.slide(); this.phone(); } } var lead = { top:function(){ $('.backtop a').click(function(e){ e.preventdefault(); $('html,body').animate({scrolltop:0}) }) }, product:function(){ $('.service-unit').each(function(){ $(this).hover(function(){ $(this).addclass('service-active') },function(){ $(this).removeclass('service-active') }) }); $('.service-unit .color p').hover(function(){ $(this).children("span").show(); },function(){ $(this).children("span").hide(); }) }, turn:function(){ if( oldmedia !='xs' ){ function code(){ var _this = $(this); var _html = _this.html(); _this.children().wrapall('

'); _this.children('p').append(_html).children(':last').addclass('a1'); } $('.turn-code li').each(code); $('.footer-code dd:not(".dot")').each(code); $('.turn-code li').hover(function(){ $(this).children("p").stop(true,true).animate({'top':'-20px'},300) },function(){ $(this).children("p").stop(true,true).animate({'top':'0px'},300) }) $('.footer-code dd p').hover(function(){ $(this).stop(true,true).animate({'top':'-20px'},300) },function(){ $(this).stop(true,true).animate({'top':'0px'},300) }) } }, init:function(){ this.top(); this.product(); this.turn(); } } function justscroll(){ if( !$.isfunction( $.fn.myscroll ) ) return false; $('.pei-table').myscroll({ maincell:'.pei-sufer', rollcell:'.pei-hd' }) /*20151202 lussen*/ $('.pei-table1').myscroll({ maincell:'.pei-sufer1', rollcell:'.pei-hd1' }) }