(function (window, $) { var menu_cur = 0, list_height = $('.main').height() * .9, more_height = $('.more').height(); var lm_Id = $.trim($('#lmId').text()); $('.top_nav li').each(function () { var mn_Name = $.trim($(this).find('span').text()); if (mn_Name == lm_Id) { $(this).addClass('focus'); } }); $('.menu li').on('click', function () { var menu_cur = $(this).index(); $('.menu li').removeClass('cur'); $(this).addClass('cur'); $('.list .one').hide(); $('.list .one:eq(' + menu_cur + ')').fadeIn(); // changeList(menu_cur); }); function changeList(num) { var $el = $('.list .one:eq(' + num + ')'), li_sum = $el.find('.showList li').length, temp_height = 0, h1_height = $el.find('h1').outerHeight(), roll_height = $('.roll_news').outerHeight(); for (var i = 0; i < li_sum; i++) { if (temp_height + more_height + h1_height + roll_height < list_height) { temp_height += $el.find('li:eq(' + i + ')').outerHeight(); } else { break; } } $el.find('.showList li:lt(' + (i - 1) + ')').addClass('show'); $el.find('.showList li:gt(' + (i - 2) + ')').hide(); }; // changeList(menu_cur); })(window, jQuery); (function (window, $) { var roll_cur = 0, roll_width = 0, roll_auto, roll_time = 100, $ul = $('.roll_title ul'); $ul.append($('.roll_title li').clone()); $('.roll_title li').each(function (idx, el) { // roll_width += $(el).outerWidth(); roll_width += window.parseFloat(window.getComputedStyle(el).width) + 1; }); $ul.width(Math.ceil(roll_width)); function rollUl() { $ul.stop(true, true).animate({ 'margin-left': -roll_cur }, roll_time, 'linear', function () { roll_cur += 10; if (roll_cur >= roll_width / 2) { $('.roll_title ul').css('margin-left', 0); roll_cur = 0; } }) } roll_auto = window.setInterval(rollUl, roll_time); $('.roll_title').on('mouseenter', function () { window.clearInterval(roll_auto); }).on('mouseleave', function () { roll_auto = window.setInterval(rollUl, roll_time); }) })(window, jQuery);