feat: Argon WordPress主题完整版本
- 基于Argon主题的WordPress博客主题 - 支持响应式设计和暗色模式 - 包含完整的文章管理和评论系统 - 集成友情链接管理功能 - 支持多种自定义设置选项 - 优化的用户界面和交互体验
This commit is contained in:
163
assets/js/argon.js
Normal file
163
assets/js/argon.js
Normal file
@@ -0,0 +1,163 @@
|
||||
/*!
|
||||
|
||||
=========================================================
|
||||
* Argon Design System - v1.1.0
|
||||
=========================================================
|
||||
|
||||
* Product Page: https://www.creative-tim.com/product/argon-design-system
|
||||
* Copyright 2019 Creative Tim (https://www.creative-tim.com)
|
||||
* Licensed under MIT (https://github.com/creativetimofficial/argon-design-system/blob/master/LICENSE.md)
|
||||
|
||||
* Coded by www.creative-tim.com
|
||||
|
||||
=========================================================
|
||||
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
$(document).ready(function() {
|
||||
|
||||
// Collapse navigation
|
||||
$('.navbar-main .collapse').on('hide.bs.collapse', function () {
|
||||
var $this = $(this);
|
||||
$this.addClass('collapsing-out');
|
||||
});
|
||||
|
||||
$('.navbar-main .collapse').on('hidden.bs.collapse', function () {
|
||||
var $this = $(this);
|
||||
$this.removeClass('collapsing-out');
|
||||
});
|
||||
|
||||
$('.navbar-main .dropdown').on('hide.bs.dropdown', function () {
|
||||
var $this = $(this).find('.dropdown-menu');
|
||||
|
||||
$this.addClass('close');
|
||||
|
||||
setTimeout(function(){
|
||||
$this.removeClass('close');
|
||||
}, 200);
|
||||
|
||||
});
|
||||
|
||||
// Headroom - show/hide navbar on scroll
|
||||
if($('.headroom')[0]) {
|
||||
var headroom = new Headroom(document.querySelector("#navbar-main"), {
|
||||
offset: 300,
|
||||
tolerance : {
|
||||
up : 30,
|
||||
down : 30
|
||||
},
|
||||
});
|
||||
headroom.init();
|
||||
}
|
||||
|
||||
// Datepicker
|
||||
$('.datepicker')[0] && $('.datepicker').each(function() {
|
||||
$('.datepicker').datepicker({
|
||||
disableTouchKeyboard: true,
|
||||
autoclose: false
|
||||
});
|
||||
});
|
||||
|
||||
// Tooltip
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
|
||||
// Popover
|
||||
$('[data-toggle="popover"]').each(function() {
|
||||
var popoverClass = '';
|
||||
if($(this).data('color')) {
|
||||
popoverClass = 'popover-'+$(this).data('color');
|
||||
}
|
||||
$(this).popover({
|
||||
trigger: 'focus',
|
||||
template: '<div class="popover '+ popoverClass +'" role="tooltip"><div class="arrow"></div><h3 class="popover-header"></h3><div class="popover-body"></div></div>'
|
||||
})
|
||||
});
|
||||
|
||||
// Additional .focus class on form-groups
|
||||
$('.form-control').on('focus blur', function(e) {
|
||||
$(this).parents('.form-group').toggleClass('focused', (e.type === 'focus' || this.value.length > 0));
|
||||
}).trigger('blur');
|
||||
|
||||
// NoUI Slider
|
||||
if ($(".input-slider-container")[0]) {
|
||||
$('.input-slider-container').each(function() {
|
||||
|
||||
var slider = $(this).find('.input-slider');
|
||||
var sliderId = slider.attr('id');
|
||||
var minValue = slider.data('range-value-min');
|
||||
var maxValue = slider.data('range-value-max');
|
||||
|
||||
var sliderValue = $(this).find('.range-slider-value');
|
||||
var sliderValueId = sliderValue.attr('id');
|
||||
var startValue = sliderValue.data('range-value-low');
|
||||
|
||||
var c = document.getElementById(sliderId),
|
||||
d = document.getElementById(sliderValueId);
|
||||
|
||||
noUiSlider.create(c, {
|
||||
start: [parseInt(startValue)],
|
||||
connect: [true, false],
|
||||
//step: 1000,
|
||||
range: {
|
||||
'min': [parseInt(minValue)],
|
||||
'max': [parseInt(maxValue)]
|
||||
}
|
||||
});
|
||||
|
||||
c.noUiSlider.on('update', function(a, b) {
|
||||
d.textContent = a[b];
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
if ($("#input-slider-range")[0]) {
|
||||
var c = document.getElementById("input-slider-range"),
|
||||
d = document.getElementById("input-slider-range-value-low"),
|
||||
e = document.getElementById("input-slider-range-value-high"),
|
||||
f = [d, e];
|
||||
|
||||
noUiSlider.create(c, {
|
||||
start: [parseInt(d.getAttribute('data-range-value-low')), parseInt(e.getAttribute('data-range-value-high'))],
|
||||
connect: !0,
|
||||
range: {
|
||||
min: parseInt(c.getAttribute('data-range-value-min')),
|
||||
max: parseInt(c.getAttribute('data-range-value-max'))
|
||||
}
|
||||
}), c.noUiSlider.on("update", function(a, b) {
|
||||
f[b].textContent = a[b]
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// When in viewport
|
||||
$('[data-toggle="on-screen"]')[0] && $('[data-toggle="on-screen"]').onScreen({
|
||||
container: window,
|
||||
direction: 'vertical',
|
||||
doIn: function() {
|
||||
//alert();
|
||||
},
|
||||
doOut: function() {
|
||||
// Do something to the matched elements as they get off scren
|
||||
},
|
||||
tolerance: 200,
|
||||
throttle: 50,
|
||||
toggleClass: 'on-screen',
|
||||
debug: false
|
||||
});
|
||||
|
||||
// Scroll to anchor with scroll animation
|
||||
$('[data-toggle="scroll"]').on('click', function(event) {
|
||||
var hash = $(this).attr('href');
|
||||
var offset = $(this).data('offset') ? $(this).data('offset') : 0;
|
||||
|
||||
// Animate scroll to the selected section
|
||||
$('html, body').stop(true, true).animate({
|
||||
scrollTop: $(hash).offset().top - offset
|
||||
}, 600);
|
||||
|
||||
event.preventDefault();
|
||||
});
|
||||
});
|
||||
224
assets/js/argon.min.js
vendored
Normal file
224
assets/js/argon.min.js
vendored
Normal file
@@ -0,0 +1,224 @@
|
||||
/*!
|
||||
* Argon 主题辅助 JavaScript 文件
|
||||
* 包含 jQuery 插件注册
|
||||
* 版本: 3.3.3
|
||||
*/
|
||||
|
||||
// 等待 jQuery 加载后注册插件
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
function initPlugins() {
|
||||
if (typeof jQuery === 'undefined') {
|
||||
setTimeout(initPlugins, 10);
|
||||
return;
|
||||
}
|
||||
|
||||
var $ = jQuery;
|
||||
|
||||
// 注册 headIndex 插件(目录生成)
|
||||
if (typeof $.fn.headIndex === 'undefined') {
|
||||
$.fn.headIndex = function(options) {
|
||||
var defaults = {
|
||||
articleWrapSelector: '#post_content',
|
||||
indexBoxSelector: '#leftbar_catalog',
|
||||
subItemBoxClass: 'index-subItem-box',
|
||||
scrollOffset: 80,
|
||||
activeClass: 'active'
|
||||
};
|
||||
|
||||
var settings = $.extend({}, defaults, options);
|
||||
var $articleWrap = $(settings.articleWrapSelector);
|
||||
var $indexBox = $(settings.indexBoxSelector);
|
||||
|
||||
if (!$articleWrap.length || !$indexBox.length) {
|
||||
return this;
|
||||
}
|
||||
|
||||
var $headings = $articleWrap.find('h1, h2, h3, h4, h5, h6');
|
||||
|
||||
if ($headings.length === 0) {
|
||||
$indexBox.html('<div class="no-catalog">暂无目录</div>');
|
||||
return this;
|
||||
}
|
||||
|
||||
// 生成目录 HTML
|
||||
var catalogHtml = '<ul class="catalog-list">';
|
||||
var minLevel = 6;
|
||||
|
||||
$headings.each(function() {
|
||||
var level = parseInt(this.tagName.substring(1));
|
||||
if (level < minLevel) minLevel = level;
|
||||
});
|
||||
|
||||
$headings.each(function(index) {
|
||||
var $heading = $(this);
|
||||
var level = parseInt(this.tagName.substring(1));
|
||||
var text = $heading.text().trim();
|
||||
var id = $heading.attr('id') || 'heading-' + index;
|
||||
|
||||
if (!$heading.attr('id')) {
|
||||
$heading.attr('id', id);
|
||||
}
|
||||
|
||||
var indent = (level - minLevel) * 15;
|
||||
catalogHtml += '<li style="padding-left: ' + indent + 'px;">' +
|
||||
'<a href="#' + id + '" class="catalog-link" data-target="' + id + '">' +
|
||||
text + '</a></li>';
|
||||
});
|
||||
|
||||
catalogHtml += '</ul>';
|
||||
$indexBox.html(catalogHtml);
|
||||
|
||||
// 点击事件
|
||||
$indexBox.off('click.headIndex').on('click.headIndex', '.catalog-link', function(e) {
|
||||
e.preventDefault();
|
||||
var targetId = $(this).data('target');
|
||||
var $target = $('#' + targetId);
|
||||
|
||||
if ($target.length) {
|
||||
$('html, body').animate({
|
||||
scrollTop: $target.offset().top - settings.scrollOffset
|
||||
}, 500);
|
||||
|
||||
$indexBox.find('.catalog-link').removeClass(settings.activeClass);
|
||||
$(this).addClass(settings.activeClass);
|
||||
}
|
||||
});
|
||||
|
||||
// 滚动高亮
|
||||
var throttleTimer = null;
|
||||
$(window).off('scroll.headIndex').on('scroll.headIndex', function() {
|
||||
if (throttleTimer) clearTimeout(throttleTimer);
|
||||
|
||||
throttleTimer = setTimeout(function() {
|
||||
var scrollTop = $(window).scrollTop();
|
||||
var currentHeading = null;
|
||||
|
||||
$headings.each(function() {
|
||||
var headingTop = $(this).offset().top - settings.scrollOffset - 50;
|
||||
if (scrollTop >= headingTop) {
|
||||
currentHeading = $(this).attr('id');
|
||||
}
|
||||
});
|
||||
|
||||
if (currentHeading) {
|
||||
$indexBox.find('.catalog-link').removeClass(settings.activeClass);
|
||||
$indexBox.find('.catalog-link[data-target="' + currentHeading + '"]')
|
||||
.addClass(settings.activeClass);
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
|
||||
return this;
|
||||
};
|
||||
}
|
||||
|
||||
// 注册简化版 tooltip 插件
|
||||
if (typeof $.fn.tooltip === 'undefined') {
|
||||
$.fn.tooltip = function(option) {
|
||||
return this.each(function() {
|
||||
var $el = $(this);
|
||||
var title = $el.attr('title') || $el.attr('tooltip') || $el.data('original-title');
|
||||
|
||||
if (!title || $el.data('tooltip-bindings')) return;
|
||||
|
||||
$el.data('tooltip-bindings', true);
|
||||
$el.attr('data-original-title', title).removeAttr('title');
|
||||
|
||||
$el.on('mouseenter.simpleTooltip', function() {
|
||||
var $tip = $('<div class="simple-tooltip">' + title + '</div>');
|
||||
$('body').append($tip);
|
||||
|
||||
var offset = $el.offset();
|
||||
var tipWidth = $tip.outerWidth();
|
||||
var tipHeight = $tip.outerHeight();
|
||||
|
||||
$tip.css({
|
||||
position: 'absolute',
|
||||
top: offset.top - tipHeight - 8,
|
||||
left: offset.left + ($el.outerWidth() - tipWidth) / 2,
|
||||
zIndex: 10000
|
||||
});
|
||||
|
||||
$el.data('tooltip-el', $tip);
|
||||
});
|
||||
|
||||
$el.on('mouseleave.simpleTooltip', function() {
|
||||
var $tip = $el.data('tooltip-el');
|
||||
if ($tip) $tip.remove();
|
||||
});
|
||||
});
|
||||
};
|
||||
$.fn.tooltip.Constructor = function() {};
|
||||
}
|
||||
}
|
||||
|
||||
// 立即执行
|
||||
initPlugins();
|
||||
})();
|
||||
|
||||
// 添加样式
|
||||
(function() {
|
||||
var styles = document.createElement('style');
|
||||
styles.textContent = [
|
||||
'.simple-tooltip {',
|
||||
' background: rgba(0,0,0,0.85);',
|
||||
' color: #fff;',
|
||||
' padding: 5px 10px;',
|
||||
' border-radius: 4px;',
|
||||
' font-size: 12px;',
|
||||
' white-space: nowrap;',
|
||||
' box-shadow: 0 2px 8px rgba(0,0,0,0.15);',
|
||||
' animation: tooltipFadeIn 0.2s ease;',
|
||||
'}',
|
||||
'@keyframes tooltipFadeIn {',
|
||||
' from { opacity: 0; transform: translateY(5px); }',
|
||||
' to { opacity: 1; transform: translateY(0); }',
|
||||
'}',
|
||||
'.catalog-list {',
|
||||
' list-style: none;',
|
||||
' padding: 0;',
|
||||
' margin: 0;',
|
||||
'}',
|
||||
'.catalog-list li {',
|
||||
' margin: 5px 0;',
|
||||
'}',
|
||||
'.catalog-link {',
|
||||
' display: block;',
|
||||
' padding: 5px 10px;',
|
||||
' color: #666;',
|
||||
' text-decoration: none;',
|
||||
' border-radius: 4px;',
|
||||
' transition: all 0.2s ease;',
|
||||
' font-size: 14px;',
|
||||
' line-height: 1.4;',
|
||||
' overflow: hidden;',
|
||||
' text-overflow: ellipsis;',
|
||||
' white-space: nowrap;',
|
||||
'}',
|
||||
'.catalog-link:hover {',
|
||||
' background: rgba(94,114,228,0.1);',
|
||||
' color: #5e72e4;',
|
||||
' text-decoration: none;',
|
||||
'}',
|
||||
'.catalog-link.active {',
|
||||
' background: var(--themecolor, #5e72e4);',
|
||||
' color: #fff;',
|
||||
'}',
|
||||
'.no-catalog {',
|
||||
' padding: 20px;',
|
||||
' text-align: center;',
|
||||
' color: #999;',
|
||||
' font-size: 14px;',
|
||||
'}'
|
||||
].join('\n');
|
||||
|
||||
if (document.head) {
|
||||
document.head.appendChild(styles);
|
||||
} else {
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
document.head.appendChild(styles);
|
||||
});
|
||||
}
|
||||
})();
|
||||
213
assets/js/easter-egg.js
Normal file
213
assets/js/easter-egg.js
Normal file
@@ -0,0 +1,213 @@
|
||||
/**
|
||||
* Git 徽章彩蛋
|
||||
* 点击超过10次触发
|
||||
*/
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
var clickCount = 0;
|
||||
var isInit = false;
|
||||
var safeDistance = 80; // 安全距离,鼠标靠近这个距离就跑
|
||||
var checkInterval = null;
|
||||
|
||||
function createModal() {
|
||||
if (document.getElementById('git-easter-egg-overlay')) return;
|
||||
|
||||
var overlay = document.createElement('div');
|
||||
overlay.className = 'git-easter-egg-overlay';
|
||||
overlay.id = 'git-easter-egg-overlay';
|
||||
overlay.innerHTML =
|
||||
'<div class="git-easter-egg-modal">' +
|
||||
'<div class="git-easter-egg-emoji">😈</div>' +
|
||||
'<div class="git-easter-egg-content">你点了这么多次点出了魔丸=v=</div>' +
|
||||
'<div class="git-easter-egg-buttons">' +
|
||||
'<button class="git-easter-egg-btn btn-good">好</button>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'<button class="git-easter-egg-btn btn-bad" id="runaway-btn">坏</button>';
|
||||
|
||||
document.body.appendChild(overlay);
|
||||
return overlay;
|
||||
}
|
||||
|
||||
var mouseX = 0, mouseY = 0;
|
||||
|
||||
function showModal() {
|
||||
var overlay = document.getElementById('git-easter-egg-overlay') || createModal();
|
||||
var badBtn = document.getElementById('runaway-btn');
|
||||
var goodBtn = overlay.querySelector('.btn-good');
|
||||
|
||||
// 获取好按钮位置,把坏按钮放在旁边
|
||||
setTimeout(function() {
|
||||
var goodRect = goodBtn.getBoundingClientRect();
|
||||
badBtn.style.transition = 'none';
|
||||
badBtn.style.left = (goodRect.right + 15) + 'px';
|
||||
badBtn.style.top = goodRect.top + 'px';
|
||||
badBtn.style.transform = 'translate(0, 0)';
|
||||
|
||||
setTimeout(function() {
|
||||
badBtn.style.transition = '';
|
||||
overlay.classList.add('show');
|
||||
startTracking();
|
||||
}, 20);
|
||||
}, 10);
|
||||
}
|
||||
|
||||
function hideModal() {
|
||||
var overlay = document.getElementById('git-easter-egg-overlay');
|
||||
if (overlay) {
|
||||
overlay.classList.remove('show');
|
||||
}
|
||||
stopTracking();
|
||||
}
|
||||
|
||||
function startTracking() {
|
||||
if (checkInterval) return;
|
||||
checkInterval = setInterval(checkDistance, 30);
|
||||
}
|
||||
|
||||
function stopTracking() {
|
||||
if (checkInterval) {
|
||||
clearInterval(checkInterval);
|
||||
checkInterval = null;
|
||||
}
|
||||
}
|
||||
|
||||
function checkDistance() {
|
||||
var badBtn = document.getElementById('runaway-btn');
|
||||
var overlay = document.getElementById('git-easter-egg-overlay');
|
||||
if (!badBtn || !overlay || !overlay.classList.contains('show')) return;
|
||||
|
||||
var rect = badBtn.getBoundingClientRect();
|
||||
var btnCenterX = rect.left + rect.width / 2;
|
||||
var btnCenterY = rect.top + rect.height / 2;
|
||||
|
||||
var distance = Math.sqrt(
|
||||
Math.pow(mouseX - btnCenterX, 2) +
|
||||
Math.pow(mouseY - btnCenterY, 2)
|
||||
);
|
||||
|
||||
// 鼠标靠近就跑
|
||||
if (distance < safeDistance) {
|
||||
runAwayFromMouse(badBtn, rect);
|
||||
}
|
||||
}
|
||||
|
||||
function runAwayFromMouse(btn, rect) {
|
||||
var btnCenterX = rect.left + rect.width / 2;
|
||||
var btnCenterY = rect.top + rect.height / 2;
|
||||
|
||||
// 计算逃跑方向(远离鼠标)
|
||||
var angle = Math.atan2(btnCenterY - mouseY, btnCenterX - mouseX);
|
||||
|
||||
// 逃跑距离
|
||||
var escapeDistance = 120 + Math.random() * 80;
|
||||
|
||||
var newX = btnCenterX + Math.cos(angle) * escapeDistance - btn.offsetWidth / 2;
|
||||
var newY = btnCenterY + Math.sin(angle) * escapeDistance - btn.offsetHeight / 2;
|
||||
|
||||
// 边界检测
|
||||
var padding = 20;
|
||||
var maxX = window.innerWidth - btn.offsetWidth - padding;
|
||||
var maxY = window.innerHeight - btn.offsetHeight - padding;
|
||||
|
||||
// 如果跑出边界,换个方向
|
||||
if (newX < padding || newX > maxX || newY < padding || newY > maxY) {
|
||||
// 尝试跑向"好"按钮附近,引导用户点好
|
||||
var goodBtn = document.querySelector('.btn-good');
|
||||
if (goodBtn) {
|
||||
var goodRect = goodBtn.getBoundingClientRect();
|
||||
// 随机出现在好按钮周围
|
||||
var positions = [
|
||||
{ x: goodRect.left - btn.offsetWidth - 20, y: goodRect.top },
|
||||
{ x: goodRect.right + 20, y: goodRect.top },
|
||||
{ x: goodRect.left, y: goodRect.bottom + 20 },
|
||||
{ x: goodRect.left, y: goodRect.top - btn.offsetHeight - 20 }
|
||||
];
|
||||
var pos = positions[Math.floor(Math.random() * positions.length)];
|
||||
newX = pos.x;
|
||||
newY = pos.y;
|
||||
}
|
||||
}
|
||||
|
||||
// 确保在屏幕内
|
||||
newX = Math.max(padding, Math.min(maxX, newX));
|
||||
newY = Math.max(padding, Math.min(maxY, newY));
|
||||
|
||||
btn.style.left = newX + 'px';
|
||||
btn.style.top = newY + 'px';
|
||||
|
||||
// 随机轻微旋转
|
||||
var rotation = (Math.random() - 0.5) * 15;
|
||||
btn.style.transform = 'translate(0, 0) rotate(' + rotation + 'deg)';
|
||||
}
|
||||
|
||||
function init() {
|
||||
if (isInit) return;
|
||||
isInit = true;
|
||||
|
||||
var badge = document.getElementById('git-badge');
|
||||
if (!badge) return;
|
||||
|
||||
createModal();
|
||||
|
||||
var overlay = document.getElementById('git-easter-egg-overlay');
|
||||
var goodBtn = overlay.querySelector('.btn-good');
|
||||
var badBtn = document.getElementById('runaway-btn');
|
||||
|
||||
// 追踪鼠标位置
|
||||
document.addEventListener('mousemove', function(e) {
|
||||
mouseX = e.clientX;
|
||||
mouseY = e.clientY;
|
||||
});
|
||||
|
||||
// 点击徽章
|
||||
badge.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
clickCount++;
|
||||
if (clickCount > 10) {
|
||||
showModal();
|
||||
clickCount = 0;
|
||||
}
|
||||
});
|
||||
|
||||
// 好按钮关闭
|
||||
goodBtn.addEventListener('click', function() {
|
||||
hideModal();
|
||||
});
|
||||
|
||||
// 坏按钮 - 永远点不到,但以防万一
|
||||
badBtn.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
// 移动端触摸追踪
|
||||
document.addEventListener('touchmove', function(e) {
|
||||
if (e.touches.length > 0) {
|
||||
mouseX = e.touches[0].clientX;
|
||||
mouseY = e.touches[0].clientY;
|
||||
}
|
||||
});
|
||||
|
||||
badBtn.addEventListener('touchstart', function(e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
// 禁止选中
|
||||
overlay.addEventListener('mousedown', function(e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
overlay.addEventListener('selectstart', function(e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
|
||||
// DOM 加载完成后初始化
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', init);
|
||||
} else {
|
||||
init();
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user