/** * 页面加载完毕。 */ $(function() { // 选中的新闻类型。 // 0:集团新闻。1:集团视频。2:集团周刊。 var newsType = sessionStorage["newsTabIndex"] || 0; // 设置对应的新闻类型Tab项被选中。 $(".tabs-container .tab") .eq(newsType) // .addClass("active"); // 根据选中的Tab显示对应的新闻列表。 showNewsByTab(newsType); // 切换Tab。 $(".tabs-container .tab").on("click", function() { // 当前选中的Tab的下标。 var index = $(this).index(); // 切换样式。 $(this).addClass("active"); $(this) .siblings(".tab") .removeClass("active"); // 根据选中的Tab显示对应的新闻列表。 showNewsByTab(index); }); // 弹出视频。 $(".tab-2-content .item").on("click", function () { var src = $(this).attr('data-src'); // $('#video').attr('src', src); $(".video-player-container").show(); // $(".video-player-container").html( // '' // ); $("body").append('' ); initVideo(); }); // 关闭视频。 $(".video-player-container").on("click", function () { $('#video').remove(); $(this).hide(); }); // 添加播放按钮旋转动画。 $(".tab-2-content .item").on('mouseover', function () { $(this).addClass('rotate360'); }); $(".tab-2-content .item").on("mouseout", function() { $(this).removeClass("rotate360"); }); }); /** * 根据选中的Tab显示对应的内容。 * @param {Number} index Tab下标。 */ function showNewsByTab(index) { // 选中集团新闻Tab。 if (index == 0) { sessionStorage["newsTabIndex"] = 0; } // 选中集团视频。 else if (index == 1) { sessionStorage["newsTabIndex"] = 1; } // 选中集团期刊。 else if (index == 2) { sessionStorage["newsTabIndex"] = 2; } }