File: /www/wwwroot/www.sainao.net/bf/js/public.js
$(function(){
var winH=$(window).height();
var winW=$(window).width();
//pc端导航部分
if(winW>767){
pc_nav();
}else{
$(document).on('click','.page-nav-open',function(){
$('.nav_phone_con>ul>li').removeClass('on');
$('.nav_phone_btn').addClass('visible_nav');
$('body').addClass('body_nav_phone');
$("html,body").css({overflow:"hidden"});
$(this).removeClass(".page-nav-open");
});
$(document).on('click','.phone-nav-bg,.visible_nav',function(){
$('.nav_phone_con>ul>li').removeClass('on');
$('.nav_phone_btn').addClass('page-nav-open');
$('body').removeClass('body_nav_phone');
$("html,body").css({overflow:"visible"});
$('.nav_phone_btn').removeClass('visible_nav');
});
$(document).on('click','.nav_phone_con>ul>li',function(){
$(this).addClass('on');
});
$(document).on('click','.nav_phone_con>ul>li ul>li:first-child',function(e){
$('.nav_phone_con>ul>li').removeClass('on');
e.stopPropagation();
});
$(document).on('click','.nav_phone_con>ul>li .menu_3',function(e){
$(this).parents("li").addClass('on');
e.stopPropagation();
});
$(document).on('click','.nav_phone_con>ul>li dl>dd:first-child',function(e){
$('.nav_phone_con>ul>li ul>li').removeClass('on');
e.stopPropagation();
});
}
// JavaScript Document
$(document).ready(function () {
$(window).scroll(function(){
if($(this).scrollTop()>0){
$('body').addClass('scrollHeader');
}else{
$('body').removeClass('scrollHeader');
}
});
});
//end
//return_top
$(window).scroll(function(){
if($(window).scrollTop() > 10){
$(".page-back-top").fadeIn("slow");
}else{
$(".page-back-top").fadeOut("slow");
};
});
$(".page-back-top").click(function(){
$("html,body").animate({scrollTop:"0px"}, 500);
});
//分享
var title_2 = encodeURIComponent("交控科技股份有限公司");
$(".page-news-share .news-sina").click(function () {//新浪微博
var url = window.location.href;
var img = ""
var title = document.title;
var op = "http://service.weibo.com/share/share.php?url=" + encodeURIComponent(url) + "&title=" + title + "&searchPic=" + img + ""
window.open(op)
})
$(".weixin_but").click(function () {//微信
var url = $(this).attr("data-qrcode")
//alert(url)
var title = ""
title += "<div class='weixin'>"
title += "<i class='c'>x</i>"
title += "<h2>二维码</h2>"
title += "<div class='img'><img src='" + url + "' width='100px;' height='100px;'></div>"
title += "<p>扫一扫</p>"
title += "</div>"
$("body").remove(".weixin");
$("body").append(title)
//var op="http://service.weibo.com/share/share.html?url='"+ url +"'&title='"+ title +"'&searchPic=false"
//window.open(op)
})
$(document).on("click", ".weixin .c", function () {
//alert(0)
$(".weixin").remove();
})
//
//搜索展开
if(winW>750){
$(document).on("mouseenter", ".page-header .hd-search", function () {
$(this).addClass("open");
});
$(document).on("mouseleave", ".page-header .hd-search", function () {
$(this).removeClass("open");
});
}else{
// 搜索
$(".search_box .sear_but").click(function (e) {
e.preventDefault();
e.stopPropagation();
if ($(".search_wrap").hasClass("on")) {
$(".search_wrap,.sear_but").removeClass("on");
} else {
$(".search_wrap,.sear_but").addClass("on");
}
})
$(".search_wrap .sear").click(function (e) {
e.preventDefault();
e.stopPropagation();
})
$(document).click(function(){
$(".search_wrap").removeClass("on");
})
// 搜索
}
//
//公共选项卡切换
$(document).on("mouseover", ".tab-box .tab-a", function () {
$(this).addClass("on").siblings().removeClass("on");
var ii = $(this).index();
$(this).parents(".tab-box").find(".tab-b").eq(ii).show().siblings().hide();
})
//
$(".tab-box").each(function (i) {
$(this).find(".tab-a:eq(0)").addClass("on");
$(this).find(".tab-b").eq(0).show().siblings().hide();
});
/*图片转背景*/
$(".bg_container img").each(function () {
$(this).parents(".bg_container").css("background-image", "url(" + $(this).attr("src") + ")");
});
//页面加载效果
if (!(/msie [6|7|8|9]/i.test(navigator.userAgent))){
var wow = new WOW({
boxClass: 'wow',
animateClass: 'animated',
offset: 100,
mobile: true,
live: true
});
wow.init();
};
})
function pc_nav(){
$('.page-header .nav>ul>li .navlist').fadeOut(0);
$('.page-header .nav>ul>li').each(function(){
if ($(this).find('li').length>-2) {
$(this).mouseover(function() {
var i = $(this).index()-1;
$(this).find('.navlist').stop(true,true).delay(200).slideDown(200);
$(this).siblings().find('.navlist').slideUp(200);
});
}
});
$('.page-header').mouseleave(function(){
$('.page-header .navlist').slideUp(300);
$(".nav-bg").slideUp(300);
})
}