$(function () {
wowInt();
findTel();
phoneTargetSelf();
nav();
search();
share()
if($(window).width()>767){
ScollText(".index_scoll");
}
$(window).resize();
$(document).on("click",".bay_close",function(){
$(".p_bay").stop().fadeOut();
})
})
//share
function share(){
$(".share_facebook").click(function () {//Facebook
var url = $(this).data("txt");
var url = window.location.href;
var title = document.title;
var op = "https://www.facebook.com/sharer.php?s=100&p[title]=" + title + "&p[summary]=!&p[url]=" + encodeURIComponent(url) + ""
window.open(op)
})
$(".share_twitter").click(function () {//Twitter
var url = $(this).data("txt");
var url = window.location.href;
var title = document.title;
var op = "https://www.tumblr.com/login?redirect_to=https://www.tumblr.com/widgets/share/tool?shareSource=legacy&canonicalUrl=&url=" + encodeURIComponent(url) + "&title=" + title + "";
window.open(op)
})
$(".share_wb").click(function () {//寰崥
var url = $(this).data("txt");
var url = window.location.href;
// var title = document.title;
var title = $(".d_title h1").text();
var op = "http://service.weibo.com/share/share.php?title=" + title + "&url=" + encodeURIComponent(url) + "";
window.open(op)
})
$(".share_qqkj").click(function () {//鑵捐寰崥
var url = $(this).data("txt");
var url = window.location.href;
var title = document.title;
var op = "https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?title=" + title + "&url=" + encodeURIComponent(url) + "";
window.open(op)
})
$(".share_qq").click(function () {//QQ
var url = $(this).data("txt");
var url = window.location.href;
var title = document.title;
var op = "http://connect.qq.com/widget/shareqq/index.html?url=" + encodeURIComponent(url) + "";
window.open(op);
})
$(".share_douban").click(function () {//璞嗙摚
var url = $(this).data("txt");
var url = window.location.href;
var title = document.title;
var op = "https://www.douban.com/share/service?title=" + title + "&url=" + encodeURIComponent(url) + "";
window.open(op);
})
$(".share_bd").click(function () {//鐧惧害璐村惂
var url = $(this).data("txt");
var url = window.location.href;
var title = document.title;
var op = "http://s.share.baidu.com/mshare?url=" + title + "&url=" + encodeURIComponent(url) + "";
window.open(op);
})
//寰俊
$(".share_wx").attr("data-qrcode","http://www.xinhongru.com/qrcode/qrcode.php?content="+window.location.href);
$(".share_wx").click(function () {//寰俊
//var url = "/qrCode/Index.aspx?url=" + window.location.href;
var url = $(this).attr("data-qrcode")
console.log(url)
var title = ""
title += "
"
title += "x"
title += "
二维码
"
title += ""
title += "
扫一扫
"
title += "
"
$("body").remove(".weixin");
$("body").append(title)
})
$(document).on("click", ".weixin .c", function () {
$(".weixin").remove();
})
}
function nav(){
$(window).scroll(function () {
if ($(this).scrollTop() > 0) {
$('body').addClass('scrollHeader');
} else {
$('body').removeClass('scrollHeader');
}
});
if($(window).width()>1024){
$(".nav li").hover(function(){
$(this).find(".nav_list").stop().fadeIn();
$(this).siblings().find(".nav_list").stop().fadeOut()
},function(){
$(this).find(".nav_list").stop().fadeOut()
})
$(".header_t ul li").hover(function(){
$(this).find(".sub").stop().fadeIn();
$(this).siblings().find(".sub").stop().fadeOut()
},function(){
$(this).find(".sub").stop().fadeOut()
})
}else{
$(".menu_button").click(function(){
$(this).toggleClass("visible_nav");
$("body").toggleClass("navbody");
$(".nav>ul>li").removeClass("cur");
})
}
$(".nav>ul>li>span").click(function(){
$(this).parent("li").addClass("cur");
$(this).parent("li").siblings().removeClass("cur");
})
$(".return_a").click(function(){
$(this).parents("li").removeClass("cur");
})
if($(window).width()<1025){
$(".header_box").on('touchmove',function(event){
event.preventDefault();
event.stopPropagation();
})
}
}
function search(){
$(".search span").click(function(e){
e.preventDefault();
e.stopPropagation();
$(".search").toggleClass("cur");
})
$(".search_box").click(function(e){
e.preventDefault();
e.stopPropagation();
})
$(document).click(function(){
$(".search").removeClass("cur");
})
}
function ScollText(obj){
if($(obj).length>0){
$(obj).mCustomScrollbar({
mouseWheelPixels:500,
autoDraggerLength:false,
advanced: {
autoScrollOnFocus: ""
}
});
}
}
function wowInt(){
if (!(/msie [6|7|8|9]/i.test(navigator.userAgent))){
var wow = new WOW({
boxClass: 'wow',
animateClass: 'animated',
offset: 100,
mobile: false,
live: true
});
wow.init();
};
}
/*手机端链接改为本窗口打开*/
function phoneTargetSelf(context){
if ($(window).width()<1024) {
if(context==undefined){
context=$(document);
}
$('a',context).each(function(){
var target=$(this);
var link=target.attr('target');
target.attr('target','_self');
})
}
}
/*电话链接取消默认事件并添加样式*/
function findTel(context){
if ($(window).width()>1024) {
var condition = /^tel\:([0-9\-]+)|tel\:\+([0-9\-]+)$/;
if(context==undefined){
context=$(document);
}
$('a',context).each(function(index, el) {
var target=$(this);
var href=target.attr('href');
if (condition.test(href)) {
target.addClass('tel_link');
target.on('click',function(event){
event.preventDefault();
})
}
});
}
}
/*ie9的placeholder包含密码框的兼容*/
$(function() {
// 如果不支持placeholder,用jQuery来完成
if(!isSupportPlaceholder()) {
// 遍历所有input对象, 除了密码框
$('input').not("input[type='password']").each(
function() {
var self = $(this);
var val = self.attr("placeholder");
input(self, val);
}
);
/**//* 对password框的特殊处理
* 1.创建一个text框
* 2.获取焦点和失去焦点的时候切换
*/
$('input[type="password"]').each(
function(i) {
var pwdField = $(this);
var pwdVal = pwdField.attr('placeholder');
var pwdId = pwdField.attr('id');
// 重命名该input的id为原id后跟1
pwdField.after('');
var pwdPlaceholder = $('#' + pwdId + ''+i+'');
pwdPlaceholder.show();
pwdField.hide();
pwdPlaceholder.focus(function(){
pwdPlaceholder.hide();
pwdField.show();
pwdField.focus();
});
pwdField.blur(function(){
if(pwdField.val() == '') {
pwdPlaceholder.show();
pwdField.hide();
}
});
}
);
}
});
// 判断浏览器是否支持placeholder属性
function isSupportPlaceholder() {
var input = document.createElement('input');
return 'placeholder' in input;
}
// jQuery替换placeholder的处理
function input(obj, val) {
var $input = obj;
var val = val;
$input.attr({value:val});
$input.focus(function() {
if ($input.val() == val) {
$(this).attr({value:""});
}
}).blur(function() {
if ($input.val() == "") {
$(this).attr({value:val});
}
});
}
//end