$(document).ready(function() { // 返回头部 $(function() { $(".return").click(function() { $("html,body").animate({ scrollTop: 0 }, 500); }); }); $(function () { $(".scroll_bottom").click(function () { $("html,body").animate({scrollTop: $('.footer').offset().top}, 500); }); }); //顶部浮动 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); }) }); //通用切换 $('.tabSwitch').each(function(index, element) { var obj = $(this); obj.find('.tabTit').children().on('click 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'); }); $('.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'); }); }); $(document).ready(function() { // Phone Nav = $(".navbtn").click(function (e) { $(".nav_box").animate({ left: "0" }); $("body").bind("touchmove", function (event) { event.preventDefault(), event.stopPropagation(); }); e.stopPropagation(); }); $(".nav_box .navclose").click(function () { $(".nav_box").animate({ left: "-100%" }); $("body").unbind("touchmove"); }); }); //session.js (function($){ var cookieExpireTime = 1209600; // cookie项过期时间 2周 $.session = { _id: null, _cookieCache: undefined, _init: function() { //if (!window.name) { // window.name = Math.random(); //} //this._id = window.name; // 如果id设置为动态,会导致浏览器不断生成cookie,进而导致取值有问题 this._id = 'sessionID'; this._initCache(); // See if we've changed protcols var matches = (new RegExp(this._generatePrefix() + "=([^;]+);")).exec(document.cookie); if (matches && document.location.protocol !== matches[1]) { this._clearSession(); for (var key in this._cookieCache) { try { window.sessionStorage.setItem(key, this._cookieCache[key]); } catch (e) {}; } } document.cookie = this._generatePrefix() + "=" + document.location.protocol + ';path=/;expires=' + (new Date((new Date).getTime() + 28800000 + cookieExpireTime)).toUTCString(); // 28800000 含义:世界时间+8天=北京时间 }, _generatePrefix: function() { return '__session:' + this._id + ':'; }, _initCache: function() { var cookies = document.cookie.split(';'); this._cookieCache = {}; for (var i in cookies) { var kv = cookies[i].split('='); if ((new RegExp(this._generatePrefix() + '.+')).test(kv[0]) && kv[1]) { this._cookieCache[kv[0].split(':', 3)[2]] = kv[1]; } } }, _setFallback: function(key, value, onceOnly) { var cookie = this._generatePrefix() + key + "=" + value + ";path=/"; if (onceOnly) { // 只一次设置项,为其添加过期时间,过期自动删除 cookie += ";expires=" + (new Date(Date.now() + 28800000 + cookieExpireTime)).toUTCString(); } document.cookie = cookie; this._cookieCache[key] = value; return this; }, _getFallback: function(key) { if (!this._cookieCache) { this._initCache(); } return this._cookieCache[key]; }, _clearFallback: function() { for (var i in this._cookieCache) { document.cookie = this._generatePrefix() + i + '=;path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT;'; } this._cookieCache = {}; }, _deleteFallback: function(key) { document.cookie = this._generatePrefix() + key + '=;path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT;'; // 把有效时间设置为过期 delete this._cookieCache[key]; }, get: function(key) { return window.sessionStorage.getItem(key) || this._getFallback(key); }, set: function(key, value, onceOnly) { try { window.sessionStorage.setItem(key, value); } catch (e) {} this._setFallback(key, value, onceOnly || false); return this; }, 'delete': function(key){ return this.remove(key); }, remove: function(key) { try { window.sessionStorage.removeItem(key); } catch (e) {}; this._deleteFallback(key); return this; }, _clearSession: function() { try { window.sessionStorage.clear(); } catch (e) { for (var i in window.sessionStorage) { window.sessionStorage.removeItem(i); } } }, clear: function() { this._clearSession(); this._clearFallback(); return this; } }; $.session._init(); })(jQuery); $(function() { var marqueeScroll = function(id1, id2, id3, timer) { var $parent = $("#" + id1); var $goal = $("#" + id2); var $closegoal = $("#" + id3); $closegoal.html($goal.html()); function Marquee() { if (parseInt($parent.scrollLeft()) - $closegoal.width() >= 0) { $parent.scrollLeft(parseInt($parent.scrollLeft()) - $goal.width()); } else { $parent.scrollLeft($parent.scrollLeft() + 1); } } setInterval(Marquee, timer); } var marqueeScroll1 = new marqueeScroll("marquee-box", "wave-list-box1", "wave-list-box2", 120); var marqueeScroll2 = new marqueeScroll("marquee-box3", "wave-list-box4", "wave-list-box5", 30); }); // 动画开始 $(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 / 4) 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 // 动画结束 $(function () { /* * 模拟网页中所有的下拉列表select */ function selectModel() { var $box = $('div.model-select-box'); var $option = $('ul.model-select-option', $box); var $txt = $('div.model-select-text', $box); var speed = 10; var $bg = $('b.bg1',$box) // 点击小三角 $bg.click(function(){ $option.not($(this).siblings('ul.model-select-option')).slideUp(speed, function () { }); $(this).siblings('ul.model-select-option').slideToggle(speed, function () { // int($(this)); }); return false; }) /* * 单击某个下拉列表时,显示当前下拉列表的下拉列表框 * 并隐藏页面中其他下拉列表 */ $txt.click(function (e) { $option.not($(this).siblings('ul.model-select-option')).slideUp(speed, function () { }); $(this).siblings('ul.model-select-option').slideToggle(speed, function () { // int($(this)); }); return false; }); //点击选择,关闭其他下拉 /* * 为每个下拉列表框中的选项设置默认选中标识 data-selected * 点击下拉列表框中的选项时,将选项的 data-option 属性的属性值赋给下拉列表的 data-value 属性,并改变默认选中标识 data-selected * 为选项添加 mouseover 事件 */ $option.find('li').each(function(index,element){ // console.log($(this) + '1'); if($(this).hasClass('selected')){ $(this).parent('.model-select-option').siblings('.model-select-text').text($(this).text()) } $(this).mousedown(function(){ $(this).parent().siblings('div.model-select-text').text($(this).text()) .attr('value', $(this).attr('data-option')); $option.slideUp(speed, function () { }); $(this).addClass('selected').siblings('li').removeClass('selected'); return false; }) $(this).on('mouseover',function(){ $(this).addClass('selected').siblings('li').removeClass('selected'); }) }) //点击文档,隐藏所有下拉 $(document).click(function (e) { $option.slideUp(speed, function () { }); }); } selectModel(); }) $(".header .nav ul li").hover(function(){ $(".header .nav ul li.cur").toggleClass("wbt"); }); $(".header .nav ul li.cur").hover(function(){ $(this).removeClass("wbt"); }); $(".footer .foott .foottr ul li").hover(function(){ $(".footer .foott .foottr ul li.cur").toggleClass("wbt"); }); $(".footer .foott .foottr ul li.cur").hover(function(){ $(this).removeClass("wbt"); });