(function(global) { 'use strict'; // 等待jQuery加载 function init($) { // 获取基础路径函数 var getBasePath = function() { var ip = global.location.origin; var links = document.querySelectorAll('link'); for (var i = 0; i < links.length; i++) { if (links[i].type == 'image/x-icon') { return links[i].href.replace(ip,'').replace('favicon.ico',''); } } return ''; }; // SDAPP初始化 if (global.SDAPP) { new global.SDAPP({ "menu": { type: "aside" } }); } // 搜索功能 $(".search-submit").click(function(event) { $(this).removeAttr("name"); event.preventDefault(); var val = $.trim($(".search-title").val()); if(val !== "") { $(".wp-search").find("form").submit(); } else { alert("请输入关键词"); } return false; }); $(".searchbox_btns").click(function() { $("#search-con").slideDown(); }); $(".layer .close").click(function() { $("#search-con").slideUp(); }); // 媒体链接hover效果 $(".shares li").each(function() { $(this).children("a").hover(function() { $(this).parent().find(".con").stop(true, true).fadeIn(); }, function() { $(this).parent().find(".con").stop(true, true).fadeOut(); }); }); // 友情链接下拉 $(".botlinks").each(function(index, el) { $(el) .find(".links-wrap") .hover( function() { $(this) .addClass("wrap-open") .children(".link-items") .stop(true, true) .slideDown(300); }, function() { $(this) .removeClass("wrap-open") .children(".link-items") .stop(true, true) .slideUp(100); } ); }); // Vivus SVG动画 global.addFirstDom = function(nodeList, callback) { nodeList.forEach(function(value, index) { var svgDom = document.createElement('div'); var firstDom = value.firstChild; svgDom.id = 'linkSvg' + index; value.insertBefore(svgDom, firstDom); var svg = new global.Vivus('linkSvg' + index, { duration: 100, start: 'inViewport', file: getBasePath() + 'images/link_icon' + (index + 1) + '.svg' }, callback); svgDom.parentElement.addEventListener('mouseover', function() { svg.getStatus() === 'end' ? svg.reset().play() : void 0; }); }); }; // 视频功能 var addElement = function(node, videoPath) { var video = document.createElement('video'); video.src = getBasePath() + videoPath; video.id = 'videos1'; video.autoplay = 'autoplay'; video.loop = 'loop'; video.muted = 'muted'; node?.appendChild(video); }; // 初始化视频 var videoDom = document.querySelector('.list #globalBanner .col_menu'); var videoPath = 'video/video1.mp4'; if (videoDom) { addElement(videoDom, videoPath); } } // 检查jQuery是否加载 if (global.jQuery) { init(global.jQuery); } else { var checkJQuery = setInterval(function() { if (global.jQuery) { clearInterval(checkJQuery); init(global.jQuery); } }, 100); } })(window); // 在SDAPP初始化后,确保事件绑定 setTimeout(function() { if ($(".navi-aside-toggle").length && !$._data($(".navi-aside-toggle")[0], "events")?.click) { // 重新执行app.js中的事件绑定代码 if (window.SDAPP) { new SDAPP({ "menu": { type: "aside" } }); } } }, 1000);