Skip to content

Commit

Permalink
0.880
Browse files Browse the repository at this point in the history
  • Loading branch information
solstice23 committed Mar 8, 2020
1 parent 3dc99d5 commit 9407568
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 89 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ Argon 使用 [GPL V3.0](https://github.com/solstice23/argon-theme/blob/master/LI

# 更新日志

## 20200309 v0.880
+ 增加夜间模式切换方案 (默认日间/默认夜间/跟随系统自动切换/根据时间自动切换)
+ 优化性能
+ 修 BUG

## 20200308 v0.873
+ 优化侧栏的搜索体验
+ 修复 Safari 上的渲染问题
Expand Down
22 changes: 15 additions & 7 deletions argontheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ function getCookie(cname) {
toolbar.classList.remove("navbar-ontop");
}
changeToolbarTransparency();
$(window).scroll(function(){
changeToolbarTransparency();
});
document.addEventListener("scroll", changeToolbarTransparency, {passive: true});
}();

/*顶栏搜索*/
Expand Down Expand Up @@ -112,10 +110,15 @@ $(document).on("keydown" , "#leftbar_search_input" , function(e){
!function(){
let $leftbarPart1 = $('#leftbar_part1');
let $leftbarPart2 = $('#leftbar_part2');
let leftbarPart1 = document.getElementById('leftbar_part1');
let leftbarPart2 = document.getElementById('leftbar_part2');

let part1OffsetTop = $('#leftbar_part1').offset().top;
let part1OuterHeight = $('#leftbar_part1').outerHeight();

function changeLeftbarStickyStatus(){
let scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
if( $('#leftbar_part1').offset().top + $('#leftbar_part1').outerHeight() + 10 - scrollTop <= 90 ){
if( part1OffsetTop + part1OuterHeight + 10 - scrollTop <= 90 ){
//滚动条在页面中间浮动状态
leftbarPart2.classList.add('sticky');
}else{
Expand All @@ -124,12 +127,17 @@ $(document).on("keydown" , "#leftbar_search_input" , function(e){
}
}
changeLeftbarStickyStatus();
$(window).scroll(function(){
changeLeftbarStickyStatus();
});
document.addEventListener("scroll", changeLeftbarStickyStatus, {passive: true});
$(window).resize(function(){
part1OffsetTop = $('#leftbar_part1').offset().top;
part1OuterHeight = $('#leftbar_part1').outerHeight();
changeLeftbarStickyStatus();
});
new MutationObserver(function(){
part1OffsetTop = $('#leftbar_part1').offset().top;
part1OuterHeight = $('#leftbar_part1').outerHeight();
changeLeftbarStickyStatus();
}).observe(leftbarPart1, {attributes: true, childList: true, subtree: true});
}();


Expand Down
3 changes: 3 additions & 0 deletions footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
<?php }?>
</div>
</div>
<?php
wp_enqueue_script("argonjs", get_bloginfo('template_url') . "/assets/js/argon.min.js", null, wp_get_theme('argon') -> Version, true);
?>
<?php wp_footer(); ?>
</body>

Expand Down
144 changes: 81 additions & 63 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,8 @@ function themeoptions_page(){
<input type="hidden" name="update_themeoptions" value="true" />
<table class="form-table">
<tbody>
<tr><th class="subtitle"><h2>主题色</h2></th></tr>
<tr><th class="subtitle"><h2>全局</h2></th></tr>
<tr><th class="subtitle"><h3>主题色</h3></th></tr>
<tr>
<th><label>主题颜色</label></th>
<td>
Expand Down Expand Up @@ -1293,7 +1294,21 @@ function themeoptions_page(){
</p>
</td>
</tr>
<tr><th class="subtitle"><h2>圆角</h2></th></tr>
<tr><th class="subtitle"><h3>夜间模式</h3></th></tr>
<tr>
<th><label>夜间模式方案</label></th>
<td>
<select name="argon_darkmode_autoswitch">
<?php $argon_darkmode_autoswitch = get_option('argon_darkmode_autoswitch'); ?>
<option value="false" <?php if ($argon_darkmode_autoswitch=='false'){echo 'selected';} ?>>默认使用日间模式</option>
<option value="alwayson" <?php if ($argon_darkmode_autoswitch=='alwayson'){echo 'selected';} ?>>默认使用夜间模式</option>
<option value="system" <?php if ($argon_darkmode_autoswitch=='system'){echo 'selected';} ?>>跟随系统夜间模式</option>
<option value="time" <?php if ($argon_darkmode_autoswitch=='time'){echo 'selected';} ?>>根据时间切换夜间模式 (21:00 ~ 7:00)</option>
</select>
<p class="description">Argon 主题会根据这里的选项来决定是否默认使用夜间模式。</br>用户也可以手动切换夜间模式,用户的设置将保留到标签页关闭为止。</p>
</td>
</tr>
<tr><th class="subtitle"><h3>圆角</h3></th></tr>
<tr>
<th><label>卡片圆角大小</label></th>
<td>
Expand Down Expand Up @@ -1979,80 +1994,83 @@ function themeoptions_page(){
<?php
}
add_action('admin_menu', 'themeoptions_admin_menu');
function argon_update_option($name){
update_option($name, htmlspecialchars(stripslashes($_POST[$name])));
}
function argon_update_option_allow_tags($name){
update_option($name, stripslashes($_POST[$name]));
}
if ($_POST['update_themeoptions'] == 'true'){
//配置项
update_option('argon_toolbar_icon', $_POST['argon_toolbar_icon']);
update_option('argon_toolbar_icon_link', $_POST['argon_toolbar_icon_link']);
update_option('argon_toolbar_title', $_POST['argon_toolbar_title']);
update_option('argon_sidebar_banner_title', $_POST['argon_sidebar_banner_title']);
update_option('argon_sidebar_banner_subtitle', $_POST['argon_sidebar_banner_subtitle']);
update_option('argon_sidebar_auther_name', $_POST['argon_sidebar_auther_name']);
update_option('argon_sidebar_auther_image', $_POST['argon_sidebar_auther_image']);
update_option('argon_banner_title', $_POST['argon_banner_title']);
update_option('argon_banner_subtitle', $_POST['argon_banner_subtitle']);
update_option('argon_banner_background_url', $_POST['argon_banner_background_url']);
update_option('argon_banner_background_color_type', $_POST['argon_banner_background_color_type']);
update_option('argon_banner_background_hide_shapes', $_POST['argon_banner_background_hide_shapes']);
update_option('argon_enable_smoothscroll_type', $_POST['argon_enable_smoothscroll_type']);
update_option('argon_enable_v2ex_gravatar', $_POST['argon_enable_v2ex_gravatar']);
update_option('argon_footer_html', stripslashes($_POST['argon_footer_html']));
update_option('argon_show_readingtime', $_POST['argon_show_readingtime']);
update_option('argon_reading_speed', $_POST['argon_reading_speed']);
update_option('argon_show_sharebtn', $_POST['argon_show_sharebtn']);
update_option('argon_enable_timezone_fix', $_POST['argon_enable_timezone_fix']);
update_option('argon_donate_qrcode_url', $_POST['argon_donate_qrcode_url']);
update_option('argon_hide_shortcode_in_preview', $_POST['argon_hide_shortcode_in_preview']);
update_option('argon_show_thumbnail_in_banner_in_content_page', $_POST['argon_show_thumbnail_in_banner_in_content_page']);
update_option('argon_update_source', $_POST['argon_update_source']);
update_option('argon_enable_into_article_animation', $_POST['argon_enable_into_article_animation']);
update_option('argon_fab_show_darkmode_button', $_POST['argon_fab_show_darkmode_button']);
update_option('argon_fab_show_settings_button', $_POST['argon_fab_show_settings_button']);
update_option('argon_show_headindex_number', $_POST['argon_show_headindex_number']);
update_option('argon_theme_color', $_POST['argon_theme_color']);
argon_update_option('argon_toolbar_icon');
argon_update_option('argon_toolbar_icon_link');
argon_update_option('argon_toolbar_title');
argon_update_option('argon_sidebar_banner_title');
argon_update_option('argon_sidebar_banner_subtitle');
argon_update_option('argon_sidebar_auther_name');
argon_update_option('argon_sidebar_auther_image');
argon_update_option('argon_banner_title');
argon_update_option('argon_banner_subtitle');
argon_update_option('argon_banner_background_url');
argon_update_option('argon_banner_background_color_type');
argon_update_option('argon_banner_background_hide_shapes');
argon_update_option('argon_enable_smoothscroll_type');
argon_update_option('argon_enable_v2ex_gravatar');
argon_update_option_allow_tags('argon_footer_html');
argon_update_option('argon_show_readingtime');
argon_update_option('argon_reading_speed');
argon_update_option('argon_show_sharebtn');
argon_update_option('argon_enable_timezone_fix');
argon_update_option('argon_donate_qrcode_url');
argon_update_option('argon_hide_shortcode_in_preview');
argon_update_option('argon_show_thumbnail_in_banner_in_content_page');
argon_update_option('argon_update_source');
argon_update_option('argon_enable_into_article_animation');
argon_update_option('argon_fab_show_darkmode_button');
argon_update_option('argon_fab_show_settings_button');
argon_update_option('argon_show_headindex_number');
argon_update_option('argon_theme_color');
update_option('argon_show_customize_theme_color_picker', ($_POST['argon_show_customize_theme_color_picker'] == 'true')?'true':'false');
update_option('argon_seo_description', stripslashes($_POST['argon_seo_description']));
update_option('argon_seo_keywords', $_POST['argon_seo_keywords']);
update_option('argon_enable_mobile_scale', $_POST['argon_enable_mobile_scale']);
update_option('argon_page_background_url', $_POST['argon_page_background_url']);
update_option('argon_page_background_opacity', $_POST['argon_page_background_opacity']);
update_option('argon_page_background_banner_style', $_POST['argon_page_background_banner_style']);
update_option('argon_hide_name_email_site_input', $_POST['argon_hide_name_email_site_input']);
update_option('argon_comment_need_captcha', $_POST['argon_comment_need_captcha']);
update_option('argon_hide_footer_author', $_POST['argon_hide_footer_author']);
update_option('argon_card_radius', $_POST['argon_card_radius']);
update_option('argon_comment_avatar_vcenter', $_POST['argon_comment_avatar_vcenter']);
update_option('argon_pjax_disabled', $_POST['argon_pjax_disabled']);
update_option('argon_comment_allow_markdown', $_POST['argon_comment_allow_markdown']);
update_option('argon_home_show_shuoshuo', $_POST['argon_home_show_shuoshuo']);
argon_update_option_allow_tags('argon_seo_description');
argon_update_option('argon_seo_keywords');
argon_update_option('argon_enable_mobile_scale');
argon_update_option('argon_page_background_url');
argon_update_option('argon_page_background_opacity');
argon_update_option('argon_page_background_banner_style');
argon_update_option('argon_hide_name_email_site_input');
argon_update_option('argon_comment_need_captcha');
argon_update_option('argon_hide_footer_author');
argon_update_option('argon_card_radius');
argon_update_option('argon_comment_avatar_vcenter');
argon_update_option('argon_pjax_disabled');
argon_update_option('argon_comment_allow_markdown');
argon_update_option('argon_home_show_shuoshuo');
argon_update_option('argon_darkmode_autoswitch');

//LazyLoad 相关
update_option('argon_enable_lazyload', $_POST['argon_enable_lazyload']);
update_option('argon_lazyload_effect', $_POST['argon_lazyload_effect']);
update_option('argon_lazyload_threshold', $_POST['argon_lazyload_threshold']);
update_option('argon_lazyload_loading_style', $_POST['argon_lazyload_loading_style']);
argon_update_option('argon_enable_lazyload');
argon_update_option('argon_lazyload_effect');
argon_update_option('argon_lazyload_threshold');
argon_update_option('argon_lazyload_loading_style');

//Zoomify 相关
update_option('argon_enable_zoomify', $_POST['argon_enable_zoomify']);
update_option('argon_zoomify_duration', $_POST['argon_zoomify_duration']);
update_option('argon_zoomify_easing', $_POST['argon_zoomify_easing']);
update_option('argon_zoomify_scale', $_POST['argon_zoomify_scale']);
argon_update_option('argon_enable_zoomify');
argon_update_option('argon_zoomify_duration');
argon_update_option('argon_zoomify_easing');
argon_update_option('argon_zoomify_scale');

//Mathjax 相关配置项
update_option('argon_mathjax_enable', $_POST['argon_mathjax_enable']);
update_option('argon_mathjax_cdn_url', $_POST['argon_mathjax_cdn_url']);
update_option('argon_mathjax_v2_enable', $_POST['argon_mathjax_v2_enable']);
update_option('argon_mathjax_v2_cdn_url', $_POST['argon_mathjax_v2_cdn_url']);
/*update_option('argon_mathjax_loading_msg_type', $_POST['argon_mathjax_loading_msg_type']);
update_option('argon_mathjax_zoom_cond', $_POST['argon_mathjax_zoom_cond']);
update_option('argon_mathjax_zoom_scale', $_POST['argon_mathjax_zoom_scale']);
update_option('argon_mathjax_show_menu', $_POST['argon_mathjax_show_menu']);*/
argon_update_option('argon_mathjax_enable');
argon_update_option('argon_mathjax_cdn_url');
argon_update_option('argon_mathjax_v2_enable');
argon_update_option('argon_mathjax_v2_cdn_url');

//页头页尾脚本
update_option('argon_custom_html_head', stripslashes($_POST['argon_custom_html_head']));
update_option('argon_custom_html_foot', stripslashes($_POST['argon_custom_html_foot']));
argon_update_option_allow_tags('argon_custom_html_head');
argon_update_option_allow_tags('argon_custom_html_foot');

//公告
update_option('argon_sidebar_announcement', stripslashes($_POST['argon_sidebar_announcement']));
argon_update_option_allow_tags('argon_sidebar_announcement');
}
/*主题菜单*/
register_nav_menus( array(
Expand Down
73 changes: 59 additions & 14 deletions header.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,72 @@
<?php if ( is_singular() && pings_open( get_queried_object() ) ) : ?>
<link rel="pingback" href="<?php echo esc_url( get_bloginfo( 'pingback_url' ) ); ?>">
<?php endif; ?>
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700" rel="stylesheet">
<link href="<?php bloginfo('template_url'); ?>/assets/argon_css_merged.css?v<?php echo wp_get_theme('argon') -> Version; ?>" rel="stylesheet">
<link href="<?php bloginfo('template_url'); ?>/style.css?v<?php echo wp_get_theme('argon') -> Version; ?>" type='text/css' media='all' rel='stylesheet'>
<script src="<?php bloginfo('template_url'); ?>/assets/argon_js_merged.js"></script>
<link href="https://fonts.googleapis.com/css?family=Noto+Serif+SC:300&display=swap" rel="stylesheet">

<?php
wp_enqueue_style("argon_css_merged", get_bloginfo('template_url') . "/assets/argon_css_merged.css", null, wp_get_theme('argon') -> Version);
wp_enqueue_style("style", get_bloginfo('template_url') . "/style.css", null, wp_get_theme('argon') -> Version);
wp_enqueue_style("googlefont", "//fonts.googleapis.com/css?family=Open+Sans:300,400,600,700|Noto+Serif+SC:300,600&display=swap");
wp_enqueue_script("argon_js_merged", get_bloginfo('template_url') . "/assets/argon_js_merged.js", null, wp_get_theme('argon') -> Version);
wp_enqueue_script("argonjs", get_bloginfo('template_url') . "/assets/js/argon.min.js", null, wp_get_theme('argon') -> Version);
?>
<?php wp_head(); ?>
<script>
var darkmodeAutoSwitch = "<?php echo (get_option("argon_darkmode_autoswitch") == '' ? 'false' : get_option("argon_darkmode_autoswitch"));?>";
function setDarkmode(enable){
if (enable == true){
$("html").addClass("darkmode");
}else{
$("html").removeClass("darkmode");
}
$(window).trigger("scroll");
}
function toggleDarkmode(){
$("html").toggleClass("darkmode");
if ($("html").hasClass("darkmode")){
setDarkmode(false);
localStorage.setItem("Argon_Enable_Dark_Mode", "false");
}else{
setDarkmode(true);
localStorage.setItem("Argon_Enable_Dark_Mode", "true");
}
}
if (sessionStorage.getItem("Argon_Enable_Dark_Mode") == "true"){
setDarkmode("true");
}
function toggleDarkmodeByPrefersColorScheme(media){
if (sessionStorage.getItem('Argon_Enable_Dark_Mode') == "true"){
return;
}
if (media.matches){
setDarkmode(true);
}else{
localStorage.setItem("Argon_Enable_Dark_Mode", "false");
setDarkmode(false);
}
$(window).trigger("scroll");
}
if (localStorage.getItem("Argon_Enable_Dark_Mode") == "true"){
toggleDarkmode();
function toggleDarkmodeByTime(){
if (sessionStorage.getItem('Argon_Enable_Dark_Mode') == "true"){
return;
}
let hour = new Date().getHours();
if (hour < 7 || hour >= 21){
setDarkmode(true);
}else{
setDarkmode(false);
}
}
if (darkmodeAutoSwitch == 'system'){
var darkmodeMediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
darkmodeMediaQuery.addListener(toggleDarkmodeByPrefersColorScheme);
toggleDarkmodeByPrefersColorScheme(darkmodeMediaQuery);
}
if (darkmodeAutoSwitch == 'time'){
toggleDarkmodeByTime();
}
if (darkmodeAutoSwitch == 'alwayson'){
setDarkmode(true);
}
</script>
<script>
if (navigator.userAgent.indexOf("Safari") !== -1 && navigator.userAgent.indexOf("Chrome") === -1){
$("html").addClass("using-safari");
}
</script>

Expand All @@ -95,9 +143,6 @@ function toggleDarkmode(){
<?php }else if (get_option('argon_enable_smoothscroll_type') != 'disabled'){?>
<script src="<?php bloginfo('template_url'); ?>/assets/vendor/smoothscroll/smoothscroll1.js"></script>
<?php }?>

<script src="<?php bloginfo('template_url'); ?>/assets/js/argon.min.js"></script>
<?php wp_head(); ?>
</head>

<?php echo get_option('argon_custom_html_head'); ?>
Expand Down
4 changes: 2 additions & 2 deletions info.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version" : "0.873",
"version" : "0.880",
"details_url" : "https://github.com/solstice23/argon-theme/releases",
"download_url" : "https://github.com/solstice23/argon-theme/releases/download/v0.873/argon.zip"
"download_url" : "https://github.com/solstice23/argon-theme/releases/download/v0.880/argon.zip"
}
8 changes: 5 additions & 3 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Theme Name: argon
Author: solstice23
Author URI: https://solstice23.top/
Description: 轻盈、简洁、美观的 Wordpress 主题
Version: 0.873
Version: 0.880
License: GNU General Public License v3.0
License URI: https://www.gnu.org/licenses/gpl-3.0.html
Tags: 简约, 两栏, 侧栏在左边, 浮动侧栏, 文章目录, 自适应, 夜间模式, 可自定义
Expand Down Expand Up @@ -227,8 +227,10 @@ a.text-primary:focus , a.text-primary:hover {
border-color: var(--themecolor-dark2) !important;
background-color: var(--themecolor-dark2) !important;
}
.page-item.active .page-link ,
.custom-checkbox .custom-control-input:checked~.custom-control-label::before{
.page-item.active .page-link ,
.custom-checkbox .custom-control-input:checked~.custom-control-label::before ,
.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before ,
.custom-control-input:not(:disabled):active~.custom-control-label::before{
border-color: var(--themecolor);
background-color: var(--themecolor);
}
Expand Down

0 comments on commit 9407568

Please sign in to comment.