Merge pull request #105 from spirit1431007/pr-branch

主题切换功能重构
This commit is contained in:
Spirit 2019-08-22 21:32:08 +08:00 committed by GitHub
commit 3692370876
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 143 additions and 121 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
/*! Lazy Load 2.0.0-beta.2 - MIT license - Copyright 2007-2017 Mika Tuupola */
!function(t,e){"object"==typeof exports?module.exports=e(t):"function"==typeof define&&define.amd?define([],e(t)):t.LazyLoad=e(t)}("undefined"!=typeof global?global:this.window||this.global,function(t){"use strict";function e(t,e){this.settings=r(s,e||{}),this.images=t||document.querySelectorAll(this.settings.selector),this.observer=null,this.init()}const s={src:"data-src",srcset:"data-srcset",selector:".lazyload"},r=function(){let t={},e=!1,s=0,o=arguments.length;"[object Boolean]"===Object.prototype.toString.call(arguments[0])&&(e=arguments[0],s++);for(;s<o;s++)!function(s){for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&(e&&"[object Object]"===Object.prototype.toString.call(s[o])?t[o]=r(!0,t[o],s[o]):t[o]=s[o])}(arguments[s]);return t};if(e.prototype={init:function(){if(!t.IntersectionObserver)return void this.loadImages();let e=this,s={root:null,rootMargin:"0px",threshold:[0]};this.observer=new IntersectionObserver(function(t){t.forEach(function(t){if(t.intersectionRatio>0){e.observer.unobserve(t.target);let s=t.target.getAttribute(e.settings.src),r=t.target.getAttribute(e.settings.srcset);"img"===t.target.tagName.toLowerCase()?(s&&(t.target.src=s),r&&(t.target.srcset=r)):t.target.style.backgroundImage="url("+s+")"}})},s),this.images.forEach(function(t){e.observer.observe(t)})},loadAndDestroy:function(){this.settings&&(this.loadImages(),this.destroy())},loadImages:function(){if(!this.settings)return;let t=this;this.images.forEach(function(e){let s=e.getAttribute(t.settings.src),r=e.getAttribute(t.settings.srcset);"img"===e.tagName.toLowerCase()?(s&&(e.src=s),r&&(e.srcset=r)):e.style.backgroundImage="url("+s+")"})},destroy:function(){this.settings&&(this.observer.disconnect(),this.settings=null)}},t.lazyload=function(t,s){return new e(t,s)},t.jQuery){const s=t.jQuery;s.fn.lazyload=function(t){return t=t||{},t.attribute=t.attribute||"data-src",new e(s.makeArray(this),t),this}}return e});
!function(t,e){"object"==typeof exports?module.exports=e(t):"function"==typeof define&&define.amd?define([],e(t)):t.LazyLoad=e(t)}("undefined"!=typeof global?global:this.window||this.global,function(t){"use strict";function e(t,e){this.settings=r(s,e||{}),this.images=t||document.querySelectorAll(this.settings.selector),this.observer=null,this.init()}const s={src:"data-src",srcset:"data-srcset",selector:".lazyload"},r=function(){let t={},e=!1,s=0,o=arguments.length;"[object Boolean]"===Object.prototype.toString.call(arguments[0])&&(e=arguments[0],s++);for(;s<o;s++)!function(s){for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&(e&&"[object Object]"===Object.prototype.toString.call(s[o])?t[o]=r(!0,t[o],s[o]):t[o]=s[o])}(arguments[s]);return t};if(e.prototype={init:function(){if(!t.IntersectionObserver)return void this.loadImages();let e=this,s={root:null,rootMargin:"0px",threshold:[0]};this.observer=new IntersectionObserver(function(t){t.forEach(function(t){if(t.isIntersecting){e.observer.unobserve(t.target);let s=t.target.getAttribute(e.settings.src),r=t.target.getAttribute(e.settings.srcset);"img"===t.target.tagName.toLowerCase()?(s&&(t.target.src=s),r&&(t.target.srcset=r)):t.target.style.backgroundImage="url("+s+")"}})},s),this.images.forEach(function(t){e.observer.observe(t)})},loadAndDestroy:function(){this.settings&&(this.loadImages(),this.destroy())},loadImages:function(){if(!this.settings)return;let t=this;this.images.forEach(function(e){let s=e.getAttribute(t.settings.src),r=e.getAttribute(t.settings.srcset);"img"===e.tagName.toLowerCase()?(s&&(e.src=s),r&&(e.srcset=r)):e.style.backgroundImage="url("+s+")"})},destroy:function(){this.settings&&(this.observer.disconnect(),this.settings=null)}},t.lazyload=function(t,s){return new e(t,s)},t.jQuery){const s=t.jQuery;s.fn.lazyload=function(t){return t=t||{},t.attribute=t.attribute||"data-src",new e(s.makeArray(this),t),this}}return e});

View File

@ -95,7 +95,7 @@
<script type="text/javascript"><?php echo akina_option('site_statistics'); ?></script>
</div>
<?php } ?>
<div class="changeSkin-gear no-select">
<div class="changeSkin-gear no-select" style="bottom: -999px;">
<div class="keys">
<span id="open-skinMenu">
<i class="iconfont icon-gear inline-block rotating"></i>&nbsp; 切换主题 | SCHEME TOOL

View File

@ -7,7 +7,7 @@
* @package Sakura
*/
define( 'SAKURA_VERSION', '3.2.3' );
define( 'SAKURA_VERSION', '3.2.4' );
define( 'BUILD_VERSION', '3' );
define( 'JSDELIVR_VERSION', '3.6.7' );

View File

@ -45,6 +45,10 @@ if ( akina_option('theme_skin') ) { ?>
background: <?php echo akina_option('theme_skin'); ?>
}
.changeSkin-gear,.toc{
background:rgba(255,255,255,<?php echo akina_option('sakura_skin_alpha','') ?>);
}
<?php if(akina_option('entry_content_theme') == "sakura"){ ?>
.entry-content th {
background-color: <?php echo akina_option('theme_skin'); ?>

View File

@ -17,6 +17,26 @@ mashiro_option.qq_api_url = "https://api.2heng.xin/qqinfo/";
mashiro_option.qq_avatar_api_url = "https://api.2heng.xin/qqinfo/";
mashiro_option.live_search = <?php if ( akina_option('live_search') ){ echo 'true'; } else { echo 'false'; } ?>;
<?php if( akina_option('sakura_skin_bg' )){ $bg_arry=explode(" ", akina_option('sakura_skin_bg' ));?>
mashiro_option.skin_bg0 = "<?php echo $bg_arry[0] ?>";
mashiro_option.skin_bg1 = "<?php echo $bg_arry[1] ?>";
mashiro_option.skin_bg2 = "<?php echo $bg_arry[2] ?>";
mashiro_option.skin_bg3 = "<?php echo $bg_arry[3] ?>";
mashiro_option.skin_bg4 = "<?php echo $bg_arry[4] ?>";
mashiro_option.skin_bg5 = "<?php echo $bg_arry[5] ?>";
mashiro_option.skin_bg6 = "<?php echo $bg_arry[6] ?>";
mashiro_option.skin_bg7 = "<?php echo $bg_arry[7] ?>";
<?php }else {?>
mashiro_option.skin_bg0 = "none";
mashiro_option.skin_bg1 = "https://cdn.jsdelivr.net/gh/spirit1431007/cdn@1.6/img/sakura.png";
mashiro_option.skin_bg2 = "https://cdn.jsdelivr.net/gh/spirit1431007/cdn@1.6/img/plaid2dbf8.jpg";
mashiro_option.skin_bg3 = "https://cdn.jsdelivr.net/gh/spirit1431007/cdn@1.6/img/star02.png";
mashiro_option.skin_bg4 = "https://cdn.jsdelivr.net/gh/spirit1431007/cdn@1.6/img/kyotoanimation.png";
mashiro_option.skin_bg5 = "https://cdn.jsdelivr.net/gh/spirit1431007/cdn@1.6/img/dot_orange.gif";
mashiro_option.skin_bg6 = "https://api.mashiro.top/bing/";
mashiro_option.skin_bg7 = "https://cdn.jsdelivr.net/gh/moezx/cdn@3.1.2/other-sites/api-index/images/me.png";
<?php } ?>
<?php if( is_home() ){ ?>
mashiro_option.land_at_home = true;
<?php }else {?>

View File

@ -5,9 +5,7 @@
* @date 2019.8.3
*/
mashiro_global.variables = new function () {
this.has_bot_ui = false;
this.isNight = false;
this.skinSecter = false;
this.skinSecter = true;
}
mashiro_global.ini = new function () {
this.normalize = function () {
@ -16,6 +14,7 @@ mashiro_global.ini = new function () {
mashiro_global.post_list_show_animation.ini();
copy_code_block();
coverVideoIni();
checkskinSecter();
}
this.pjax = function () {
pjaxInit();
@ -23,6 +22,7 @@ mashiro_global.ini = new function () {
mashiro_global.post_list_show_animation.ini();
copy_code_block();
coverVideoIni();
checkskinSecter();
}
}
@ -288,30 +288,27 @@ function scrollBar() {
}
scrollBar();
function checkskinSecter() {
if (mashiro_global.variables.skinSecter === false) {
$(".pattern-center").removeClass('pattern-center').addClass('pattern-center-sakura');
$(".headertop-bar").removeClass('headertop-bar').addClass('headertop-bar-sakura');
} else {
$(".pattern-center-sakura").removeClass('pattern-center-sakura').addClass('pattern-center');
$(".headertop-bar-sakura").removeClass('headertop-bar-sakura').addClass('headertop-bar');
}
}
function checkBgImgCookie() {
var bgurl = getCookie("bgImgSetting");
if (bgurl != "") {
if (bgurl == "https://view.moezx.cc/images/2018/01/03/sakura.png" || bgurl == "https://view.moezx.cc/images/2018/01/03/plaid2dbf8.jpg" || bgurl == "https://view.moezx.cc/images/2018/01/10/star02.png" || bgurl == "https://view.moezx.cc/images/2018/01/24/kyotoanimation.png" || bgurl == "https://view.moezx.cc/images/2018/03/27/dot_orange.gif") {
mashiro_global.variables.skinSecter = true;
mashiro_global.variables.isNight = false;
$("#night-mode-cover").css("visibility", "hidden");
$("body").css("background-image", "url(" + bgurl + ")");
$(".blank").css("background-color", "rgba(255,255,255,1)");
$(".pattern-center").removeClass('pattern-center').addClass('pattern-center-sakura');
$(".headertop-bar").removeClass('headertop-bar').addClass('headertop-bar-sakura');
} else if (bgurl == "https://api.shino.cc/bing/") {
mashiro_global.variables.skinSecter = true;
mashiro_global.variables.isNight = true;
$("#night-mode-cover").css("visibility", "hidden");
$("body").css("background-image", "url(" + bgurl + ")");
$(".blank").css("background-color", "rgba(255,255,255,1)");
$(".pattern-center").removeClass('pattern-center').addClass('pattern-center-sakura');
$(".headertop-bar").removeClass('headertop-bar').addClass('headertop-bar-sakura');
} else {}
} else {}
$(".skin-menu #" + bgurl).click();
} else {
$(".skin-menu #white-bg").click();
}
}
if (document.body.clientWidth > 860) {
checkBgImgCookie();
setTimeout(function() {
checkBgImgCookie();
}, 100);
}
function no_right_click() {
@ -320,87 +317,68 @@ function no_right_click() {
});
}
no_right_click();
if (mashiro_global.variables.isNight) {
$(".changeSkin-gear, .toc").css("background", "rgba(255,255,255,0.8)");
} else {
$(".changeSkin-gear, .toc").css("background", "none");
}
$(document).ready(function () {
function changeBG(tagid, url) {
$(".skin-menu " + tagid).click(function () {
mashiro_global.variables.skinSecter = true;
mashiro_global.variables.isNight = false;
$("#night-mode-cover").css("visibility", "hidden");
$("body").css("background-image", "url(" + url + ")");
$(".blank").css("background-color", "rgba(255,255,255,1)");
$(".pattern-center").removeClass('pattern-center').addClass('pattern-center-sakura');
$(".headertop-bar").removeClass('headertop-bar').addClass('headertop-bar-sakura');
closeSkinMenu();
setCookie("bgImgSetting", url, 30);
$(document).ready(function() {
function checkskin_bg(a){
return a == "none" ? "" : a
}
function changeBG() {
$(".menu-list li").each(function() {
var tagid = this.id;
$(".skin-menu #" + tagid).click(function() {
if (tagid == "white-bg") {
mashiro_global.variables.skinSecter = true;
checkskinSecter();
} else {
mashiro_global.variables.skinSecter = false;
checkskinSecter();
}
if (tagid == "dark-bg") {
$("#night-mode-cover").css("visibility", "visible");
} else
$("#night-mode-cover").css("visibility", "hidden");
switch (tagid) {
case "white-bg":
$("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg0) + ")");
break;
case "sakura-bg":
$("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg1) + ")");
break;
case "gribs-bg":
$("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg2) + ")");
break;
case "pixiv-bg":
$("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg3) + ")");
break;
case "KAdots-bg":
$("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg4) + ")");
break;
case "totem-bg":
$("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg5) + ")");
break;
case "bing-bg":
$("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg6) + ")");
break;
case "dark-bg":
$("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg7) + ")");
break;
}
setCookie("bgImgSetting", tagid, 30);
closeSkinMenu();
});
});
}
function changeBGnoTrans(tagid, url) {
$(".skin-menu " + tagid).click(function () {
mashiro_global.variables.skinSecter = true;
mashiro_global.variables.isNight = true;
$("#night-mode-cover").css("visibility", "hidden");
$("body").css("background-image", "url(" + url + ")");
$(".blank").css("background-color", "rgba(255,255,255,1)");
$(".pattern-center").removeClass('pattern-center').addClass('pattern-center-sakura');
$(".headertop-bar").removeClass('headertop-bar').addClass('headertop-bar-sakura');
closeSkinMenu();
setCookie("bgImgSetting", url, 30);
});
}
changeBG("#sakura-bg", "https://view.moezx.cc/images/2018/01/03/sakura.png");
changeBG("#gribs-bg", "https://view.moezx.cc/images/2018/01/03/plaid2dbf8.jpg");
changeBG("#pixiv-bg", "https://view.moezx.cc/images/2018/01/10/star02.png");
changeBG("#KAdots-bg", "https://view.moezx.cc/images/2018/01/24/kyotoanimation.png");
changeBG("#totem-bg", "https://view.moezx.cc/images/2018/03/27/dot_orange.gif");
changeBGnoTrans("#bing-bg", "https://api.shino.cc/bing/");
$(".skin-menu #white-bg").click(function () {
mashiro_global.variables.skinSecter = false;
mashiro_global.variables.isNight = false;
$("#night-mode-cover").css("visibility", "hidden");
$("body").css("background-image", "none");
$(".blank").css("background-color", "rgba(255,255,255,.0)");
$(".pattern-center-sakura").removeClass('pattern-center-sakura').addClass('pattern-center');
$(".headertop-bar-sakura").removeClass('headertop-bar-sakura').addClass('headertop-bar');
closeSkinMenu();
setCookie("bgImgSetting", "Hello World!", 30);
});
$(".skin-menu #dark-bg").click(function () {
mashiro_global.variables.skinSecter = true;
mashiro_global.variables.isNight = true;
$("body").css("background-image", "url(https://cdn.jsdelivr.net/gh/moezx/cdn@3.1.2/other-sites/api-index/images/me.png)");
$(".blank").css("background-color", "rgba(255,255,255,.8)");
$("#night-mode-cover").css("visibility", "visible");
$(".pattern-center").removeClass('pattern-center').addClass('pattern-center-sakura');
$(".headertop-bar").removeClass('headertop-bar').addClass('headertop-bar-sakura');
closeSkinMenu();
});
changeBG();
function closeSkinMenu() {
$(".skin-menu").removeClass('show');
setTimeout(function () {
setTimeout(function() {
$(".changeSkin-gear").css("visibility", "visible");
}, 300);
if (mashiro_global.variables.isNight) {
$(".changeSkin-gear, .toc").css("background", "rgba(255,255,255,0.8)");
} else {
$(".changeSkin-gear, .toc").css("background", "none");
}
}
$(".changeSkin-gear").click(function () {
$(".changeSkin-gear").click(function() {
$(".skin-menu").toggleClass('show');
if (mashiro_global.variables.isNight) {
$(".changeSkin").css("background", "rgba(255,255,255,0.8)");
} else {
$(".changeSkin").css("background", "none");
}
})
$(".skin-menu #close-skinMenu").click(function () {
$(".skin-menu #close-skinMenu").click(function() {
closeSkinMenu();
});
add_upload_tips();
@ -431,9 +409,9 @@ if (document.body.clientWidth <= 860) {
function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
document.getElementById("moblieGoTop").style.display = "block";
addComment.I("moblieGoTop").style.display = "block";
} else {
document.getElementById("moblieGoTop").style.display = "none";
addComment.I("moblieGoTop").style.display = "none";
}
}
@ -497,8 +475,8 @@ timeSeriesReload();
/*视频feature*/
function coverVideo() {
var video = document.getElementById("coverVideo");
var btn = document.getElementById("coverVideo-btn");
var video = addComment.I("coverVideo");
var btn = addComment.I("coverVideo-btn");
if (video.paused) {
video.play();
@ -516,8 +494,8 @@ function coverVideo() {
}
function killCoverVideo() {
var video = document.getElementById("coverVideo");
var btn = document.getElementById("coverVideo-btn");
var video = addComment.I("coverVideo");
var btn = addComment.I("coverVideo-btn");
if (video.paused) {
//console.info('none:killCoverVideo()');
@ -532,7 +510,7 @@ function killCoverVideo() {
function coverVideoIni() {
if ($('video').hasClass('hls')) {
var video = document.getElementById('coverVideo');
var video = addComment.I('coverVideo');
var video_src = $('#coverVideo').attr('data-src');
if(Hls.isSupported()) {
var hls = new Hls();
@ -617,14 +595,6 @@ var pjaxInit = function () {
reloadHermit();
} catch (e) {};
}
if (mashiro_global.variables.skinSecter === true) {
$(".pattern-center").removeClass('pattern-center').addClass('pattern-center-sakura');
$(".headertop-bar").removeClass('headertop-bar').addClass('headertop-bar-sakura');
if (mashiro_global.variables.isNight) {
$(".blank").css("background-color", "rgba(255,255,255,1)");
$(".toc").css("background-color", "rgba(255,255,255,0.8)");
}
}
$('.iconflat').css('width', '50px').css('height', '50px');
$('.openNav').css('height', '50px');
$("#bg-next").click(function () {
@ -710,8 +680,8 @@ function grin(tag, type, before, after) {
} else {
tag = ' :' + tag + ': ';
}
if (document.getElementById('comment') && document.getElementById('comment').type == 'textarea') {
myField = document.getElementById('comment');
if (addComment.I('comment') && addComment.I('comment').type == 'textarea') {
myField = addComment.I('comment');
} else {
return false;
}
@ -1391,8 +1361,8 @@ var home = location.href,
var QueryStorage = [];
search_a("https://"+document.domain+"/wp-json/cache_search/v1/json/");
var otxt = document.getElementById("search-input"),
list = document.getElementById("PostlistBox"),
var otxt = addComment.I("search-input"),
list = addComment.I("PostlistBox"),
Record = list.innerHTML,
searchFlag = null;
otxt.oninput = function () {
@ -1502,7 +1472,7 @@ var home = location.href,
break
}
}
w && (y = y + G + "文章" + E + w + D), u && (y = y + G + "页面" + E + u + D), r && (y = y + G + "分类" + E + r + D), p && (y = y + G + "标签" + E + p + D), F && (y = y + G + "评论" + E + F + D), s = document.getElementById("PostlistBox"), s.innerHTML = y
w && (y = y + G + "文章" + E + w + D), u && (y = y + G + "页面" + E + u + D), r && (y = y + G + "分类" + E + r + D), p && (y = y + G + "标签" + E + p + D), F && (y = y + G + "评论" + E + F + D), s = addComment.I("PostlistBox"), s.innerHTML = y
}
}
});
@ -1555,9 +1525,9 @@ var home = location.href,
var intersectionObserver = new IntersectionObserver(function (entries) {
if (entries[0].intersectionRatio <= 0) return;
var page_next = $('#pagination a').attr("href");
var load_key = document.getElementById("add_post_time");
var load_key = addComment.I("add_post_time");
if(page_next!=undefined && load_key ){
var load_time = document.getElementById("add_post_time").title;
var load_time = addComment.I("add_post_time").title;
if(load_time !="233"){
console.log("%c 自动加载时倒计时 %c","background:#9a9da2; color:#ffffff; border-radius:4px;","","",load_time);
load_post_timer=setTimeout(function(){load_post();},load_time*1000);
@ -1876,7 +1846,7 @@ if ((isWebkit || isOpera || isIe) && document.getElementById && window.addEventL
if (!(/^[A-z0-9_-]+$/.test(id))) {
return;
}
element = document.getElementById(id);
element = addComment.I(id);
if (element) {
if (!(/^(?:a|select|input|button|textarea)$/i.test(element.tagName))) {
element.tabIndex = -1;

View File

@ -134,6 +134,34 @@ function optionsframework_options() {
'type' => "color"
);
$options[] = array(
'name' => __('切换主题菜单透明度', 'options_framework_theme'),
'desc' => __('调整切换主题菜单透明度,值越小越透明,默认透明度0.8', 'options_framework_theme'),
'id' => 'sakura_skin_alpha',
'std' => '0.8',
'type' => 'select',
'options'=>array(
'0'=> __('全透明',''),
'0.1'=> __('透明度0.1',''),
'0.2'=> __('透明度0.2',''),
'0.3'=> __('透明度0.3',''),
'0.4'=> __('透明度0.4',''),
'0.5'=> __('透明度0.5',''),
'0.6'=> __('透明度0.6',''),
'0.7'=> __('透明度0.7',''),
'0.8'=> __('透明度0.8',''),
'0.9'=> __('透明度0.9',''),
'1'=> __('不透明',''),
));
$options[] = array(
'name' => __('切换网页背景', 'options_framework_theme'),
'desc' => __('前台切换网页背景共8个url使用空格分隔顺序对应前台切换主题按钮位置按钮顺序从左至右从上至下,如不需要背景则填写对应位置为none。<strong>注意如果主题是从3.2.3及以下更新过来的,请务必在<a href="/wp-admin/themes.php?page=options-framework">这里</a>修改【版本控制】参数为任意新值!</strong>
', 'options_framework_theme'),
'id' => 'sakura_skin_bg',
'std' => 'none https://cdn.jsdelivr.net/gh/spirit1431007/cdn@1.6/img/sakura.png https://cdn.jsdelivr.net/gh/spirit1431007/cdn@1.6/img/plaid2dbf8.jpg https://cdn.jsdelivr.net/gh/spirit1431007/cdn@1.6/img/star02.png https://cdn.jsdelivr.net/gh/spirit1431007/cdn@1.6/img/kyotoanimation.png https://cdn.jsdelivr.net/gh/spirit1431007/cdn@1.6/img/dot_orange.gif https://api.mashiro.top/bing/ https://cdn.jsdelivr.net/gh/moezx/cdn@3.1.2/other-sites/api-index/images/me.png',
'type' => 'textarea');
$options[] = array(
'name' => __('个人头像', 'options_framework_theme'),
'desc' => __('最佳高度尺寸130*130px。', 'options_framework_theme'),

View File

@ -5,7 +5,7 @@ Theme URI: https://2heng.xin/theme-sakura/
Author: Mashiro, Louie, Fuzzz
Author URI: http://2heng.xin
Description: Akina主题分支原版地址 http://www.akina.pw/themeakina
Version: 3.2.3
Version: 3.2.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: akina