$(function(){
if(!placeholdersupport()){
$('[placeholder]').focus(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
input.removeclass('placeholder');
}
}).blur(function() {
var input = $(this);
if (input.val() == '' || input.val() == input.attr('placeholder')) {
input.addclass('placeholder');
input.val(input.attr('placeholder'));
}
}).blur();
};
if(!ispc()){$('body').addclass('touch_body')}
//ie浏览器
if(isie()){$('html').addclass('isie');}
// 获取当前url
var url_location = window.location.pathname;
var arr = [];
arr = url_location.split('/');
})
function placeholdersupport() {
return 'placeholder' in document.createelement('input');
}
function scrollt($dom){
if($(window).scrolltop()+$(window).height()>=$dom.offset().top+200){
return true;
}
}
function mainbgresize1($img, width, height, w_b, h_b) {
var sw = width,
sh = width / w_b * h_b
if (sh < height) {
sh = height;
sw = height / h_b * w_b
}
$img.css({height:sh,width:sw, margintop: -(sh - height) / 2, marginleft: -(sw - width) / 2, 'visibility': 'visible' });
}
//判断是否firefox浏览器
function isfirefox(){
if (navigator.useragent.indexof("firefox") > -1)
return true;
else
return false;
}
//判断是否ie浏览器
function isie() {
if (!!window.activexobject || "activexobject" in window)
return true;
else
return false;
}
function ispc() {
var useragentinfo = navigator.useragent;
var agents = new array("android", "iphone", "symbianos", "windows phone", "ipad", "ipod");
var flag = true;
for (var v = 0; v < agents.length; v++) {
if (useragentinfo.indexof(agents[v]) > 0) { flag = false; break; }
}
return flag;
}
//导航按钮
$('.nav_btn').click(function(){
$('.header').toggleclass('btn_click');
if($('.header').hasclass('btn_click')){
$('.nav_right>ul>li').removeclass('cur');
$('.nav_right>ul>li').find('dl').hide();
$('.nav_er').hide();
}
});
//首页移动端导航
$(window).resize(function(){
// $('.header .nav_right>ul').css({
// 'height':$(window).height()-70
// });
//针对ipadpro设置样式
if($(window).height()>=1024 && $(window).width()<=1300){
$('body').removeclass('ipadpro1024');
$('body').addclass('ipadpro1366');
}else if($('.touch_body').size()>0 && $(window).width()>1300){
$('body').removeclass('ipadpro1366');
$('body').addclass('ipadpro1024');
}
}).resize();
/**
* @fileoverview 简单切签
* @example
* 1、调用切签:
var tabchange = require("./common/tabchange");
tabchange({
targetele:'#com_title li',
curclass:'on'
});
2、修改html:
*/
function tabchange(opts){
var defaultopts = {
targetele:'#com_title li', //切签头部要点击的元素
curclass:'on', //切签头部选中后的样式
tabclass:null, //tab的class
needpause:false //点击前是否先暂停动画
};
this.changeevent = null;
$.extend(defaultopts,opts);
if(!(this instanceof tabchange)){
return new tabchange(defaultopts);
}
this.init.apply(this,[defaultopts]);
}
tabchange.prototype = {
init:function(data){
var targetele = data.targetele,
curclass = data.curclass,
tabcur = null,
self = this;
$(targetele).on('click',function(){
var tabid = $(this).attr('data-tab');
tabcur = '';
if( $(this).siblings("."+curclass).length > 0 ){
$(this).siblings().removeclass(curclass);
}else{
$(this).parent().siblings().children().removeclass(curclass);
}
$(this).addclass(curclass);
if( !data.tabclass ){
$('#'+tabid).parent().children('div').addclass('none');
}else{
$('#'+tabid).parent().children('div.'+data.tabclass).addclass('none');
}
$('#'+tabid).removeclass('none');
});
}
}
//保留小数点后两位,四舍五入
function todecimal(x) {
var f = parsefloat(x);
if (isnan(f)) {
return false;
}
var f = math.round(x*100)/100;
var s = f.tostring();
var rs = s.indexof('.');
if (rs < 0) {
rs = s.length;
s += '.';
}
while (s.length <= rs + 2) {
s += '0';
}
return s;
}
//移动二级导航
function movemenulink(){
if($(window).width() <= 1250){
if(!$('.nav_right>ul>li').eq(0).children('a').attr('data-href')){
$('.nav_right>ul>li').each(function(){
var shref = $(this).children('a').attr('href');
$(this).children('a').attr('data-href',shref);
$(this).children('a').attr('href','javascript:;');
});
}
}else{
if($('.nav_right>ul>li').eq(0).children('a').attr('data-href')){
$('.nav_right>ul>li').each(function(){
var dhref = $(this).children('a').attr('data-href');
$(this).children('a').attr('href',dhref);
$(this).children('a').removeattr('data-href');
});
}
}
}
movemenulink();
//二级导航
function menubar(){
$('.nav_right>ul>li').find('dl').hide();
if($(window).width() > 1250){
$('.nav_right>ul>li').removeclass('cur');
$('.nav_right>ul>li').find('dl').hide();
$('.nav_right>ul>li').off('mouseenter').off('click').on('mouseenter',function(){
$(this).find('dl').stop().show();
});
$('.nav_right>ul>li').off('mouseleave').off('click').on('mouseleave',function(){
$(this).find('dl').stop().hide();
});
}else{
$('.header').removeclass('btn_click');
$('.header.btn_click .nav_right').css('opacity',0.8);
$('.nav_right>ul>li').removeclass('cur');
$('.nav_right>ul>li').find('dl').hide();
$('.nav_right>ul>li').off('mouseenter').off('mouseleave').off('click').on('click',function(){
$('.nav_right>ul>li').removeclass('cur');
if($(this).find('dl').css('display')=='none'){
$('.nav_right>ul>li').find('dl').hide();
$(this).addclass('cur');
$(this).find('dl').stop().show();
}else{
$(this).removeclass('cur');
$(this).find('dl').stop().hide();
}
});
$('.nav_right>ul>li>dl>dd').off('mouseenter').off('mouseleave').off('click').on('click',function(evt){
evt.stoppropagation();
});
}
}
menubar();
$(window).on('resize',function(){
movemenulink();
menubar();
});
//动态调整banner中文字位置
function resizebannert(){
if($(window).width() >= 1280){
$('.banner_area').css({'width':1280});
}else{
$('.banner_area').css({'width':$(window).width()});
}
}
resizebannert();
$(window).on('resize',function(){
resizebannert();
});
//显隐底部右下角微信图片
$('.bds_weixin').hover(function(){
$(this).find('.ewm_img').show();
},function(){
$(this).find('.ewm_img').hide();
});
//绑定事件监听
function addevent(eve,callback){
if (window.attachevent){
window.attachevent("on"+eve,callback);
}else if(window.addeventlistener) {
window.addeventlistener(eve,callback,false);
}
}
//判断pad横屏竖屏,刷新页面
addevent('load', function(){
// orientationchange();
window.onorientationchange = orientationchange;
});
function orientationchange() {
switch(window.orientation) {
case 0:
//alert("肖像模式 0,screen-width: " + screen.width + "; screen-height:" + screen.height);
window.location.reload();
break;
case -90:
//alert("左旋 -90,screen-width: " + screen.width + "; screen-height:" + screen.height);
window.location.reload();
break;
case 90:
// alert("右旋 90,screen-width: " + screen.width + "; screen-height:" + screen.height);
window.location.reload();
break;
case 180:
//alert("风景模式 180,screen-width: " + screen.width + "; screen-height:" + screen.height);
window.location.reload();
break;
}
};