$(document).ready(function() { // mh = $("body").height(); // fh = $(".header").height(); // $(window).scroll(function(e) { // s = $(document).scrollTop(); // if (s > fh) { // $(".header").addClass("fixed-head"); // } else { // $(".header").removeClass("fixed-head"); // } // }); $(function() { $("#return_top").click(function() { $("body,html").animate( { scrollTop: 0 }, "slow" ); return false; }); }); //头部浮动 mh = $('body').height(); fh = $('.header').height(); $(window).scroll(function(e){ s = $(document).scrollTop(); if(s > fh){ $('.header').addClass('fixed-head'); }else{ $('.header').removeClass('fixed-head'); } }); $(function() { $(".nav li").hover( function() { $(this) .children(".navbox") .stop(true, true) .slideDown(500); }, function() { $(this) .children(".navbox") .stop(true, true) .slideUp(0); } ); }); //通用切换 $(".tabSwitchHover").each(function(index, element) { var obj = $(this); obj.find(".tabTit") .children() .on("mouseover tab", function() { $(this) .addClass("cur") .siblings() .removeClass("cur"); if ( obj .find(".tabBox") .children() .eq($(this).index()).length > 0 ) obj.find(".tabBox") .children() .hide() .eq($(this).index()) .show(); if ( obj .find(".tabBox2") .children() .eq($(this).index()).length > 0 ) obj.find(".tabBox2") .children() .hide() .eq($(this).index()) .show(); //return false; }); obj.find(".tabTit .cur").trigger("tab"); }); }); function CheckSearch(o){ obj = $(o); obj.find('[type="submit"]').attr('disabled',true); msg = ''; searKey = obj.find('[name="searKey"]').val(); if (searKey.length <= 0){ msg += '请输入关键词\r'; } if (msg.length){ alert(msg); obj.find('[name="searKey"]').focus(); obj.find('[type="submit"]').attr('disabled',false); return false; } return true; } function CheckJobs(o){ var obj = $(o); obj.find('[type="submit"]').attr('disabled',true); var msg = ''; var searKey = obj.find('[name="searKey"]').val(); var cityid = obj.find('[name="cityid"]').val(); var pid = obj.find('[name="pid"]').val(); if (searKey.length <= 0 && cityid == 0 && pid == 0){ msg += '请输入关键字\r'; } if (msg.length){ alert(msg); obj.find('[name="searKey"]').focus(); obj.find('[type="submit"]').attr('disabled',false); return false; }else{ $.ajax({ type: 'POST', url: '/ajax', dataType: 'json', cache: false, data: {cityid:cityid, pid:pid, searKey:searKey, location:location.href, act:obj.find('[name="act"]').val(), formhash:obj.find('[name="formhash"]').val()}, error: function(){ alert('出错了!'); return false; }, success:function(json){ $('[name="formhash"]').val(json.formhash); if (json.errmsg == ''){ //layer.alert(json.msg, {icon: 1}); $('#jobs_list').html(json.msg); $(".joinNr ul li").eq(0).click(); //o.reset(); }else{ layer.alert(json.errmsg, {icon: 2}); } obj.find('[type="submit"]').attr('disabled',false); } }); } return false; } function CheckContact(o){ var obj = $(o); obj.find('[type="submit"]').attr('disabled',true); var msg = ''; layer.closeAll('tips'); var username = obj.find('[name="username"]').val(); var email = obj.find('[name="email"]').length ? obj.find('[name="email"]').val() : ''; var mobile = obj.find('[name="mobile"]').val(); var mess = obj.find('[name="mess"]').val(); if (username.length < 1 || username.length > 100){ msg = obj.find('[name="username"]').attr('placeholder')?obj.find('[name="username"]').attr('placeholder'):'请输入姓名'; obj.find('[name="username"]').inputError({'err': msg, 'tips': 3, tipsMore: true}); } if (mobile.length <= 0){ msg = obj.find('[name="mobile"]').attr('placeholder')?obj.find('[name="mobile"]').attr('placeholder'):'请输入手机'; obj.find('[name="mobile"]').inputError({'err': msg, 'tips': 3, tipsMore: true}); }else if (!CheckMobile(mobile)){ msg = obj.find('[name="mobile"]').attr('placeholder')?obj.find('[name="mobile"]').attr('placeholder'):'请输入正确的手机'; obj.find('[name="mobile"]').inputError({'err': msg, 'tips': 3, tipsMore: true}); } if (email.length > 0 && !CheckEmail(email)){ msg = obj.find('[name="email"]').attr('placeholder')?obj.find('[name="email"]').attr('placeholder'):'请输入正确的邮箱'; obj.find('[name="email"]').inputError({'err': msg, 'tips': 3, tipsMore: true}); } if (msg.length){ obj.find('[type="submit"]').attr('disabled',false); return false; }else{ $.ajax({ type: 'POST', url: '/ajax', dataType: 'json', cache: false, data: {username:username, mobile:mobile, email:email, mess:mess, location:location.href, act:obj.find('[name="act"]').val(), formhash:obj.find('[name="formhash"]').val()}, error: function(){ alert('出错了!'); return false; }, success:function(json){ $('[name="formhash"]').val(json.formhash); if (json.errmsg == ''){ layer.alert(json.msg, {icon: 1}); o.reset(); }else{ layer.alert(json.errmsg, {icon: 2}); } obj.find('[type="submit"]').attr('disabled',false); } }); } return false; } function CheckMobile(m){ var reg = /^(((1[0-9]{2}))+\d{8})$/; if (reg.test(m)) { return true; } return false; } function CheckEmail(m){ var reg = /^([a-zA-Z0-9+_]|\-|\.)+@(([a-zA-Z0-9_]|\-)+\.)+[a-zA-Z]{2,6}$/; if (reg.test(m)) { return true; } return false; } jQuery.fn.extend({ inputError: function(options) { return this.each(function() { new jQuery.inputError(this, options); }); } }); jQuery.inputError = function(inputobj, options) { var opt = options || {}; opt.class = opt.class || 'inputerror'; opt.err = opt.err || ''; opt.tips = opt.tips || 2; opt.tipsMore = opt.tipsMore || false; var obj = $(inputobj); if (!obj.data('placeholder')){ obj.data('data-placeholder', obj.attr('placeholder')); obj.attr('placeholder', opt.err?opt.err:obj.data('placeholder')); } obj.removeClass(opt.class).addClass(opt.class); //小tips layer.tips(opt.err, obj, {tips: [opt.tips, '#dd1721'], tipsMore: opt.tipsMore}); obj.unbind('focus').focus(function(event) { $(this).removeClass(opt.class); //obj.attr('placeholder', obj.data('placeholder')); }); obj.unbind('blur').blur(function(event) { $(this).removeClass(opt.class); obj.attr('placeholder', obj.data('placeholder')); }); if (obj.get(0).tagName!='INPUT' && obj.get(0).tagName!='TEXTAREA' && !obj.data('bindClick')){ obj.click(function(event) { $(this).removeClass(opt.class); obj.attr('placeholder', obj.data('placeholder')); }); obj.children().click(function(){obj.click()}); obj.data('bindClick',true); } }; //开始 $(document).ready(function() { npos = $(window).scrollTop(); SW = $(window).width(); SH = $(window).height(); IEFlag = (navigator.appVersion.indexOf("MSIE 7") > -1 || navigator.appVersion.indexOf("MSIE 8") > -1)?true:false; lnbFlag = false; var isrun = false; if ($('.banner img').length){ $(".banner img:eq(0)").one('load', function() { isrun = true; conInit(); }).each(function() { if(this.complete){ $(this).load(); return false; }; }) }else{ isrun = true; conInit(); } }); $(window).scroll(function() { npos = $(window).scrollTop(); SW = $(window).width(); SH = $(window).height(); });//chd scroll $(window).resize(function(){ SW = $(window).width(); SH = $(window).height(); });//chd resize function conInit(){ var Actions,Event,total; var cur = 0; var ncur = 0; var cTarget = $('body'); var item = []; if (cTarget.find('.maxbox').length == 0){ return false; } Init = { _start:function(){ //$('#main_nav ul').css('margin-top',(($('#main_nav ul').height()/2)+120)*-1); /************* / variable Add *************/ total = cTarget.find('.maxbox').length; //$('body,html').animate({scrollTop:0},300,'easeOutExpo') /************* / Event Add *************/ /************* / Item Add *************/ var _i = 0; cTarget.find('.maxbox').each(function($index){ var _t = $(this); item[$index] = { _data:_i, _target:_t, _moveFlag:true, _play:function(_posY){ var target = this._target; var f_t = target.position().top; var f_b = f_t+600; var p_y = _posY - f_t; var d_y; var target_w = target.width(); var target_h = target.height(); if(item[cur]._moveFlag){ var __i = 0; target.find('.TweenToDelayUp').each(function(){ var _d = __i*0.15 TweenMax.to($(this),0.8,{y:0,alpha:1,delay:_d,ease:Quad.easeOut}); __i++ }); target.find('.TweenToDelayUpChildren').children().each(function(){ var _d = __i*0.15 TweenMax.to($(this),0.8,{y:0,alpha:1,delay:_d,ease:Quad.easeOut}); __i++ }); target.find('.TweenToDelayDown').each(function(){ var _d = __i*0.15 TweenMax.to($(this),0.8,{y:0,alpha:1,delay:_d,ease:Quad.easeOut}); __i++ }); target.find('.TweenToShow').each(function(){ var _d = __i*0.15; TweenMax.to($(this),1.5,{y:0,alpha:1,delay:0,ease:Quad.easeOut}); __i++ }); target.find('.TweenToShowChildren').children().each(function(){ var _d = __i*0.15; TweenMax.to($(this),1.5,{y:0,alpha:1,delay:0,ease:Quad.easeOut}); __i++ }); target.find('.TweenToDelayShow').each(function(){ var _d = __i*0.15; TweenMax.to($(this),1.5,{y:0,alpha:1,delay:_d,ease:Quad.easeOut}); __i++ }); target.find('.TweenToDelayShowChildren').children().each(function(){ var _d = __i*0.15; TweenMax.to($(this),1.5,{y:0,alpha:1,delay:_d,ease:Quad.easeOut}); __i++ }); target.find('.TweenToLeft, .TweenToRight').each(function(){ var _d = __i*0.15; TweenMax.to($(this),1.5,{x:0,alpha:1,delay:0,ease:Quad.easeOut}); __i++ }); target.find('.TweenToLeftChildren, .TweenToRightChildren').children().each(function(){ var _d = __i*0.15; TweenMax.to($(this),1.5,{x:0,alpha:1,delay:0,ease:Quad.easeOut}); __i++ }); target.find('.TweenToDelayLeftChildren, .TweenToDelayRightChildren').children().each(function(){ var _d = __i*0.4;//console.log(__i); if (target.hasClass('oymc_div')){ if (__i % 2 > 0){ _d = old_d; } }else if (target.hasClass('TweenToUp')){ _d = 1.0; } TweenMax.to($(this),1.0,{x:0,alpha:1,delay:_d,ease:Quad.easeOut}); old_d = _d; __i++ }); target.find('.TweenScale').each(function(){ var _d = __i*0.15; TweenMax.to($(this),1.5,{scale:1.1,alpha:1,delay:0,ease:Quad.easeOut}); __i++ }); } this._moveFlag = false; }, _reset:function(){ var target = this._target; var target_w = target.width(); var target_h = target.height(); this._moveFlag = true target.find('.TweenToDelayUp').each(function(){ TweenMax.set($(this),{y:50,alpha:0}); }); target.find('.TweenToDelayUpChildren').children().each(function(){ TweenMax.set($(this),{y:50,alpha:0}); }); target.find('.TweenToDelayDown').each(function(){ TweenMax.set($(this),{y:-50,alpha:0}); }); target.find('.TweenToShow, .TweenToDelayShow').each(function(){ TweenMax.set($(this),{alpha:0}); }); target.find('.TweenToShowChildren, .TweenToDelayShowChildren').children().each(function(){ TweenMax.set($(this),{alpha:0}); }); target.find('.TweenToLeft, .TweenToDelayLeft').each(function(){ TweenMax.set($(this),{x:200,alpha:0}); }); target.find('.TweenToRight, .TweenToDelayRight').each(function(){ TweenMax.set($(this),{x:-200,alpha:0}); }); target.find('.TweenToLeftChildren, .TweenToDelayLeftChildren').children().each(function(){ TweenMax.set($(this),{x:200,alpha:0}); }); target.find('.TweenToRightChildren, .TweenToDelayRightChildren').children().each(function(){ TweenMax.set($(this),{x:-200,alpha:0}); }); } } item[$index]._reset(); _i++ }); item[cur]._play(npos); } }//init End Actions = { _pageMove:function(targetY){ $('html,body').stop().animate({scrollTop:targetY},1200) }, _pageHandler:function(_posY){ item[cur]._play(_posY); if(_posY == 0){ cTarget.find('.maxbox').each(function($index){ //item[$index]._reset(); }); //item[cur]._play(_posY); } }, _pageResize:function(){ cTarget.find('.maxbox').each(function($index){ //item[$index]._reset(); }); } }//Actions End Event = { _activeHandler:function(index){ var _mb = SH-(SH/2) cTarget.find('.maxbox').each(function(vi){ //console.log($(this).index('.maxbox')); if(vi != total-1){ if(index >= $(this).offset().top-_mb && index <= $(this).next().offset().top-_mb){ cur = vi; } if(index >= $(this).offset().top && index <= $(this).next().offset().top){ ncur = vi; } }else{ if(index >= $(this).offset().top-_mb){ cur = vi; } if(index >= $(this).offset().top){ ncur = vi; } } }); } }//Event End $(window).scroll(function() { npos = $(window).scrollTop(); SW = $(window).width(); SH = $(window).height(); Event._activeHandler(npos); Actions._pageHandler(npos); });//chd scroll $(window).resize(function(){ SW = $(window).width(); SH = $(window).height(); Actions._pageResize(); });//chd resize Init._start(); Event._activeHandler(npos); Actions._pageHandler(npos); }//conInit End