/*(c) copyright 2018 reenoo-大芒果 * chuck_home@163.com * 2018-10-22 */ var reenoo = { init: function() { switch(flagclass) { case 'index': this.home(); break; } this.commom(); this.url = null; }, commom: function() { //load header and footer this.url = location.href; if(this.url.indexof('aspx') < 0 && this.url.indexof('html') > 0) { $(".header").load("header.html", function() { navpos(); var headerbar = new sliderbar({ obj: ".header .linkbox" }); }); $(".footer").load("footer.html",function(){ // navpos(); }); } else { navpos(); var headerbar = new sliderbar({ obj: ".header .linkbox" }); } // 导航栏定位 function navpos() { $(".header .subnav a").each(function() { var urlstr = location.href; //返回完整的url // console.log(urlstr) var pathname = location.pathname; //返回的url路径名 var he_orign=location.orign; var thishref = $(this).attr('href'); var nav_name = thishref.replace(/(.*\/)*([^.]+).*/ig, "$2").replace(/\d+/g, ''); this.url = location.href; if(this.url.indexof('aspx') < 0 && this.url.indexof('html') > 0) { if((urlstr + '/').indexof(thishref) > -1 && $(this).attr('href') != '') { $(this).addclass("on"); $(this).parents('li').addclass('active').siblings().removeclass('active'); return false; } else if((urlstr + '/').indexof("newsdetail") > -1 && $(this).attr('href') != '') { $(".header .nav li").eq(2).addclass("active").siblings().removeclass("active"); } else if((urlstr + '/').indexof("product") > -1 && $(this).attr('href') != '') { $(".header .nav li").eq(3).addclass("active").siblings().removeclass("active"); } else { $(".header .nav li").eq(0).addclass("active").siblings().removeclass("active"); } } else { if((urlstr + '/').indexof(thishref) > -1 && $(this).attr('href') != '') { // console.log(urlstr.replace(he_orign,'')) // if(location.href.replace(location.origin,"")==='/'+thishref){ $(this).addclass("on"); $(this).parents('li').addclass('active').siblings().removeclass('active'); return false; } else if((urlstr + '/').indexof("index") > -1 && $(this).attr('href') != '') { $(".header nav li").first().addclass('active').siblings().removeclass('active'); return false; } if(pathname === '/') { $(".header nav li").first().addclass('active').siblings().removeclass('active'); return false; } } // if((urlstr + '/').indexof(nav_name) > -1 && $(this).attr('href') != '') { // $(this).addclass("on"); // $(this).parents('li').addclass('active').siblings().removeclass('active'); // return false; // } }); // 针对业务版图添加class if(location.href == "http://www.rfchina.com/about.aspx?type=38"){ $(".header nav li.active .subnav a").each(function(){ var text = $(this).text(); if(text === "业务版图"){ $(this).addclass("on").siblings().removeclass("on"); } }); } $(".header nav li>a").each(function(){ var i = $(this); var thishref = $(this).attr('href'); var nav_name = thishref.replace(/(.*\/)*([^.]+).*/ig, "$2").replace(/\d+/g, ''); this.url = location.href; if((this.url + '/').indexof(thishref) > -1 && $(this).attr('href') != '') { $(this).addclass("active"); if(!$(this).next().find(".draplink a.on").length){ $(this).next().find(".draplink a").first().addclass('on').siblings().removeclass('on'); } } }); // $(".header .subnav a").each(function(){ // // var a_href = $(this).attr("href"); // var url_ild = "/about.aspx?type=38"; // var pathname_url = window.location.pathname + window.location.search; // console.log(url_ild) // if(pathname_url == url_ild){ // $(this).addclass("on").siblings().removeclass("on"); // // alert(1) // }else{ // return false // } // }); // 声明以及地图 window_hei = $(window).height(); $(".legal_webmap").height(window_hei); // 网站地图栏目间距 // $(".wab_mapnav li").eq(2).find(".a_nav a").eq(3).css({"margin-right":"40px"}); // $(".wab_mapnav li").eq(3).find(".a_nav a").eq(2).css({"margin-right":"90px"}); // $(".wab_mapnav li").eq(4).find(".a_nav a").eq(2).css({"margin-right":"80px"}); // 弹出网站地图 $(".hamburger").on("click",function(){ $(".webmap_box").animate({right:'0'},500); }); $(".webmap_box .right_close").click(function(){ $(".webmap_box").animate({right:'-420px'},500); }); // 弹出法律声明 $(".legal_btn").on("click",function(){ $(".legal_box").animate({right:'0'},500); }); // 关闭 $(".legal_box .right_close").click(function(){ $(".legal_box").animate({right:'-420px'},500); }); // 弹出语言切换 $(".header_right .idx_lan .lan").hover(function(){ $(this).find(".language").slidedown(); },function(){ $(this).find(".language").slideup(); }); // 首页边距 $("#content.index").parent("body").css({"padding-top":"0"}); $("#content.index").siblings("header").removeclass("inner_header").addclass("idx_header"); $(".idx_header").find(".header_right .idx_lan .lan .box p").css({"color":"#fff"}); // 商业运营的交通信息 function traffic(){ $(".traffic").each(function(){ var text = $(this).find(".text p").text(); if(text.length == 0){ $(this).find(".text").addclass("on") } }); } traffic(); }; //scroll to fixed header $(window).scroll(function() { fixedhead(); }) fixedhead(); function fixedhead() { var _top = $(window).scrolltop(); if(_top > 120) { $(".header").addclass("on"); $(".idx_header.on").find(".header_right .idx_lan .lan .box p").css({"color":"#0052ac"}); } else { $(".header").removeclass("on"); $(".idx_header").find(".header_right .idx_lan .lan .box p").css({"color":"#fff"}); } if(_top > 50){ $(".idx_top .box").slidedown(); } } //use wow.js if(!(/msie [8|9]/i.test(navigator.useragent))) new wow().init(); //back to top !(function backtop() { $("body").prepend('
'); var offset = 300, offset_opacity = 1200, scroll_top_duration = 500, $back_to_top = $('.model_back_top'); ($(this).scrolltop() > offset) ? $back_to_top.addclass('active'): $back_to_top.removeclass('active'); $(window).scroll(function() { ($(this).scrolltop() > offset) ? $back_to_top.addclass('active'): $back_to_top.removeclass('active'); if($(this).scrolltop() > offset_opacity) { $back_to_top.addclass('active'); } }); $back_to_top.click(function(event) { event.preventdefault(); $('body,html').animate({ scrolltop: 0, }, scroll_top_duration); }); })(); }, home: function() { jquery(".idx_business .slidebox").slide({ maincell: ".bd ul", autoplay: true, intertime: 5000, effect: "leftloop", delaytime: 800, // trigger: "click", startfun: function(i, c,slider,maincell) { settimeout(function() { idxbar.refreshcur() }, 10) $(".idx_business .txtbox .txt").eq(i).stop().fadein("slow").siblings().stop().hide(); }, endfun: function() { } }); var idxbar = new sliderbar({ obj: ".idx_business .linkbox", currentclass: "on" }); $(".idx_business .prev,.idx_business .next").click(function() { idxbar.refreshcur(); }) $(".idx_business .btn a").mouseenter(function() { var idx = $(this).index(); if(idx === 0) { $(".idx_business .slidebox .btn .bg").addclass("on"); } else { $(".idx_business .slidebox .btn .bg").removeclass("on"); } }) var winhei = $(window).height(); winhei = winhei > 805 ? winhei : 805; $(".ms-slide").css({ "min-width": "1280px!important" }) var slider = new masterslider(); slider.setup('masterslider', { width: 1200, // slider standard width height: winhei, // slider standard height space: 0, start: 1, grabcursor: true, swipe: true, mouse: true, keyboard: false, layout: "fullwidth", wheel: false, autoplay: true, instantstartlayers: true, loop: true, shuffle: false, preload: 0, heightlimit: true, autoheight: false, smoothheight: true, endpause: false, overpause: true, fillmode: "fill", centercontrols: false, startonappear: false, layersmode: "center", autofilltarget: "", hidelayers: false, fullscreenmargin: 0, speed: 15, dir: "h", parallaxmode: 'swipe', view: "parallaxmask" }); // adds arrows navigation control to the slider. slider.control('arrows'); slider.control('bullets', { autohide: false, overvideo: true, dir: 'h', align: 'bottom', space: 6, margin: 30 }); } } $(function() { flagclass = $("#content").attr("class"); reenoo.init(); }) var sliderbar = function(props) { this._obj = $(props.obj) || $(this.defaults.obj); this._slip = props.slip ? this._obj.find(props.slip) : this._obj.find(this.defaults.slip); this._li = props.li ? this._obj.find(props.li) : this._obj.find(this.defaults.li); this._cur = props.currentclass || this.defaults.currentclass; this._a = this._obj.find("." + this._cur); this.curidx = props.curidx || this.currentidx; if(this.defaults.init) { this.init(); } } sliderbar.prototype.defaults = { init: true, obj: ".linkbox", slip: ".sliderbar", li: "li", currentclass: "active", currentidx: 0 } sliderbar.prototype.init = function() { if(this._slip.length === 0 || this._a.length === 0) { return } //初始化滑块 this._slip.animate({ 'width': this._a.outerwidth(), 'left': parseint(this._a.position().left) + 'px' }); this._slip.show(); var self = this; // this._li.hover(function() { $(this).addclass(self._cur).siblings().removeclass(self._cur); //移动滑块 self._slip.stop().animate({ width: $(this).outerwidth(), left: parseint($(this).position().left) + 'px' }, 300); }, function() { self._a.addclass(self._cur).siblings().removeclass(self._cur); self._slip.stop().animate({ width: self._a.outerwidth(), left: parseint(self._a.position().left) + 'px' }, 300); }); this._li.click(function() { self.refreshcur(); }) } sliderbar.prototype.refreshcur = function() { this._a = this._obj.find("." + this._cur); this._slip.stop().animate({ 'width': this._a.outerwidth(), 'left': parseint(this._a.position().left) + 'px' }, 300); } $(".idx_news_box .a_tit a").eq(0).addclass("on"); $(".idx_news_box .a_box a").hide().eq(0).show(); $(".idx_news_box .a_tit a").click(function(){ var i = $(this).index(); $(this).addclass("on").siblings().removeclass(); $(".idx_news_box .a_box a").eq(i).fadein().siblings().hide(); });