Common.js:修订间差异
来自卡厄思梦境WIKI
无编辑摘要 |
无编辑摘要 |
||
| 第1行: | 第1行: | ||
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */ | /* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */ | ||
// 切换标签 | |||
(function() { | (function() { | ||
'use strict'; | 'use strict'; | ||
| 第71行: | 第72行: | ||
} | } | ||
})(); | })(); | ||
// 黑幕效果 | |||
$(document).ready(function() { | |||
// 处理黑幕元素 | |||
$('.blackout-text').each(function() { | |||
var $this = $(this); | |||
var originalText = $this.data('text'); | |||
// 添加提示工具提示 | |||
$this.append('<span class="blackout-tooltip">点击查看隐藏内容</span>'); | |||
// 鼠标悬停效果 | |||
$this.on('mouseenter', function() { | |||
$(this).css('color', '#fff'); | |||
}).on('mouseleave', function() { | |||
if (!$(this).hasClass('revealed')) { | |||
$(this).css('color', '#000'); | |||
} | |||
}); | |||
// 点击切换显示/隐藏 | |||
$this.on('click', function() { | |||
var $tooltip = $(this).find('.blackout-tooltip'); | |||
if ($(this).hasClass('revealed')) { | |||
// 隐藏文本 | |||
$(this).removeClass('revealed'); | |||
$(this).css('color', '#000'); | |||
$tooltip.text('点击查看隐藏内容'); | |||
} else { | |||
// 显示文本 | |||
$(this).addClass('revealed'); | |||
$(this).css('color', '#fff'); | |||
$tooltip.text('点击隐藏内容'); | |||
} | |||
}); | |||
// 触摸设备支持 | |||
$this.on('touchstart', function(e) { | |||
e.preventDefault(); | |||
$(this).trigger('click'); | |||
}); | |||
}); | |||
}); | |||
2025年9月23日 (二) 09:43的版本
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
// 切换标签
(function() {
'use strict';
function initTabSwitcher() {
var tabContainers = document.querySelectorAll('.resp-tabs');
tabContainers.forEach(function(container) {
var tabButtons = container.querySelectorAll('.czn-list-style');
if (tabButtons.length === 0) return;
// 检测模式
var tabContents = container.querySelectorAll('.resp-tab-content');
var portraitImages = document.querySelectorAll('.portrait-image');
// 初始化
tabButtons.forEach(function(button, index) {
button.classList.toggle('active', index === 0);
});
if (tabContents.length > 0) {
tabContents.forEach(function(content, index) {
content.style.display = index === 0 ? 'block' : 'none';
});
}
if (portraitImages.length > 0) {
portraitImages.forEach(function(image, index) {
image.style.display = index === 0 ? 'block' : 'none';
});
}
// 点击事件
tabButtons.forEach(function(button, index) {
button.addEventListener('click', function(e) {
e.preventDefault();
// 更新标签状态
tabButtons.forEach(function(btn, i) {
btn.classList.toggle('active', i === index);
});
// 传统模式切换
if (tabContents.length > 0) {
tabContents.forEach(function(content, i) {
content.style.display = i === index ? 'block' : 'none';
});
}
// 立绘模式切换
if (portraitImages.length > 0) {
portraitImages.forEach(function(image) {
image.style.display = 'none';
});
var targetImage = document.querySelector('.portrait-image[data-index="' + index + '"]');
if (targetImage) {
targetImage.style.display = 'block';
}
}
});
});
});
}
// 初始化
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initTabSwitcher);
} else {
initTabSwitcher();
}
})();
// 黑幕效果
$(document).ready(function() {
// 处理黑幕元素
$('.blackout-text').each(function() {
var $this = $(this);
var originalText = $this.data('text');
// 添加提示工具提示
$this.append('<span class="blackout-tooltip">点击查看隐藏内容</span>');
// 鼠标悬停效果
$this.on('mouseenter', function() {
$(this).css('color', '#fff');
}).on('mouseleave', function() {
if (!$(this).hasClass('revealed')) {
$(this).css('color', '#000');
}
});
// 点击切换显示/隐藏
$this.on('click', function() {
var $tooltip = $(this).find('.blackout-tooltip');
if ($(this).hasClass('revealed')) {
// 隐藏文本
$(this).removeClass('revealed');
$(this).css('color', '#000');
$tooltip.text('点击查看隐藏内容');
} else {
// 显示文本
$(this).addClass('revealed');
$(this).css('color', '#fff');
$tooltip.text('点击隐藏内容');
}
});
// 触摸设备支持
$this.on('touchstart', function(e) {
e.preventDefault();
$(this).trigger('click');
});
});
});