$(function () { $.each([".ww",".www",".ee",".ff",".gg",".hh"],function(index,sClass){ $(sClass).on({ mouseover: function (){ $(this).find(".elegant-layer").stop(false,false,false).fadeIn(); }, mouseout: function (){ $(this).find(".elegant-layer").stop(false,false,false).fadeOut(); } }); }); $(".find-nav-box ul > li > a").each(function (index){ $(this).on({ mouseover: function (){ $(this).addClass("active"); }, mouseout: function (){ $(this).removeClass("active"); } }); }); var menu_index = -1; $(".nav li > a").each(function (index){ if($(this).is(".active")){ menu_index = index; } }); $(".nav ul > li").each(function (index){ $(this).on({ mouseover : function (){ $(this).find("ul").show(); }, mouseout : function (){ $(this).find("ul").hide(); } }); }); $(".nav ul > li li").each(function (index){ $(this).on({ mouseover : function (){ $(this).parent().parent().find("a").first().addClass("active"); }, mouseout : function (){ $(this).parent().parent().find("a").first().removeClass("active"); } }); }); $(".nav li").each(function(index){ $(this).on({ mouseover : function (){ $(".nav li > a").eq(index).addClass("active"); }, mouseout : function (){ $(".nav li > a").eq(index).removeClass("active"); if(menu_index != -1){ $(".nav li a").eq(menu_index).addClass("active"); } } }); }); $("#banner").banner(); }); ;(function ($) { $.fn.banner = function (){ if ($(this).size() <= 0) return; var sUl = $('ul', this); var sLi = $('ul li', this); var sImg = $('ul li img', this); var iNow = 0, timer = null, speed = 5000; var image = [], is_load = [],iWidth = 1920;; var arrHeight = []; var aFont = []; var _self = $(this); var reSize = function () { var veiwWidth = $(window).width(); if (veiwWidth > 1000) { for (var i = 0; i < sImg.size(); i++) { sImg.eq(i).css({left: -(iWidth - veiwWidth) / 2}); } } }; reSize(); $(window).resize(reSize); $("li:not(:first-child)", sUl).hide(); var string = $('
', {'class': 'loader-bg'}).css({ display: 'none', width: 48, height: 48, position: 'absolute', top: '50%', left: '48%', zIndex: 9999, background: 'url(images/loading.gif) no-repeat' }); $(this).prepend(string); $(".loader-bg").css('left', ($(this).outerWidth() - $(".loader-bg").outerWidth(true)) / 2); $('li img', sUl).each(function (index) { image[index] = $(this).data('src'); is_load[index] = false; aFont[index] = $(this).attr('alt'); }); var oImage = new Image(); var load = function (index, flag) { $('.loader-bg').show(); sLi.eq(index).find('img').attr('src', image[index]).one('load', function () { $('.loader-bg').hide(); is_load[index] = true; oImage.src = $(this).attr('src'); var iWidth = oImage.width; var iHeight = oImage.height; var veiwWidth = $(window).width(); $(this).css({left: -(iWidth - veiwWidth) / 2, height: iHeight}); arrHeight.push(iHeight); if (!flag) { sLi.eq(index).fadeIn(800); } else { fade(index); } }).each(function () { if (this.complete) { $(this).load(); } }); }; load(0, false); $(".banner-pageing a:first").addClass("active"); var fade = function (index) { $(".banner-pageing a").removeClass("active").eq(index).addClass("active"); $("li", sUl).filter(":visible").fadeOut(500).parent().children().eq(index).fadeIn(600); }; var checkLoad = function (index) { iNow = index; if (is_load[index]) { fade(index); } else { load(index, true); } }; var move = function () { if (iNow == sLi.size() - 1) { iNow = 0; } else { iNow++; } checkLoad(iNow); }; $(".banner-pageing a").each(function (index){ $(this).on("click",function (){ if($(sLi).eq(index).is(":visible")){ return ; } checkLoad(index); }); }); timer = setInterval(move, speed); $(this).on({ mouseover: function () { clearInterval(timer); }, mouseout: function () { timer = setInterval(move, speed); } }); }; })(jQuery);