feat: index - 首页及顶部导航处理
This commit is contained in:
1
public/static/index/js/before-after.min.js
vendored
Executable file
1
public/static/index/js/before-after.min.js
vendored
Executable file
@@ -0,0 +1 @@
|
||||
!function(a){function b(b,c,d){b.on("mousedown.ba-events touchstart.ba-events",function(e){b.addClass("ba-draggable"),c.addClass("ba-resizable");var f=e.pageX?e.pageX:e.originalEvent.touches[0].pageX,g=b.outerWidth(),h=b.offset().left+g-f,i=d.offset().left,j=d.outerWidth();minLeft=i+10,maxLeft=i+j-g-10,b.parents().on("mousemove.ba-events touchmove.ba-events",function(b){var c=b.pageX?b.pageX:b.originalEvent.touches[0].pageX;leftValue=c+h-g,leftValue<minLeft?leftValue=minLeft:leftValue>maxLeft&&(leftValue=maxLeft),widthValue=100*(leftValue+g/2-i)/j+"%",a(".ba-draggable").css("left",widthValue),a(".ba-resizable").css("width",widthValue)}).on("mouseup.ba-events touchend.ba-events touchcancel.ba-events",function(){b.removeClass("ba-draggable"),c.removeClass("ba-resizable"),a(this).off(".ba-events")}),e.preventDefault()})}a.fn.beforeAfter=function(){var c=this,d=c.width()+"px";c.find(".resize img").css("width",d),b(c.find(".handle"),c.find(".resize"),c),a(window).resize(function(){var a=c.width()+"px";c.find(".resize img").css("width",a)})}}(jQuery);
|
||||
51
public/static/index/js/headfoot.js
Normal file
51
public/static/index/js/headfoot.js
Normal file
@@ -0,0 +1,51 @@
|
||||
//加载公共头部和尾部
|
||||
async function loadHTML(url, targetId) {
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
const html = await response.text();
|
||||
document.getElementById(targetId).innerHTML = html;
|
||||
} catch (error) {
|
||||
console.error('Error loading HTML:', error);
|
||||
}
|
||||
}
|
||||
// 加载头部
|
||||
loadHTML('head.html', 'header');
|
||||
// 加载尾部
|
||||
loadHTML('footer.html', 'footer');
|
||||
$(document).ready(function() {
|
||||
// 封装一个函数用于处理鼠标悬停显示和隐藏内容
|
||||
function handleHover($element, $content) {
|
||||
$element.mouseenter(function() {
|
||||
$content.stop(true, true).slideDown(400);
|
||||
}).mouseleave(function() {
|
||||
$content.stop(true, true).slideUp(400);
|
||||
});
|
||||
}
|
||||
// 处理第一个导航项
|
||||
handleHover($('.navItem').eq(0), $('.navItem').eq(0).find('.navItemConten'));
|
||||
// 鼠标移入navItem_cyleft里面的li标签添加类,移除其他li的类
|
||||
$('.navItem_cyleft li').mouseenter(function() {
|
||||
$(this).addClass('it_active').siblings().removeClass('it_active');
|
||||
});
|
||||
// 处理第5 - 8个导航项
|
||||
for (let i = 4; i < 8; i++) {
|
||||
handleHover($('.navItem').eq(i), $('.navItem').eq(i).find('.navItemConten1'));
|
||||
}
|
||||
// 点击搜索
|
||||
$('#openModalBtn').click(function() {
|
||||
$('#scmodal').toggle();
|
||||
});
|
||||
$('.close-btn').click(function() {
|
||||
$('#scmodal').hide();
|
||||
});
|
||||
// 点击选择国家
|
||||
$('#countrycheck').click(function() {
|
||||
$('#top-country').toggle();
|
||||
});
|
||||
$('.closecountrybt').click(function() {
|
||||
$('#top-country').hide();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user