commit
c3381bcc8a
204
js/sakura-app.js
204
js/sakura-app.js
|
@ -11,7 +11,7 @@ mashiro_global.ini = new function () {
|
|||
this.normalize = function () {
|
||||
lazyload();
|
||||
social_share();
|
||||
mashiro_global.post_list_show_animation.ini();
|
||||
post_list_show_animation();
|
||||
copy_code_block();
|
||||
coverVideoIni();
|
||||
checkskinSecter();
|
||||
|
@ -19,7 +19,7 @@ mashiro_global.ini = new function () {
|
|||
this.pjax = function () {
|
||||
pjaxInit();
|
||||
social_share();
|
||||
mashiro_global.post_list_show_animation.ini();
|
||||
post_list_show_animation();
|
||||
copy_code_block();
|
||||
coverVideoIni();
|
||||
checkskinSecter();
|
||||
|
@ -64,33 +64,32 @@ function imgError(ele, type) {
|
|||
}
|
||||
}
|
||||
|
||||
mashiro_global.post_list_show_animation = new function () {
|
||||
this.ini = function (ajax) {
|
||||
$("article.post-list-thumb").each(function (i) {
|
||||
if (ajax) {
|
||||
var window_height = $(window).height();
|
||||
} else {
|
||||
if ($(".headertop").hasClass("headertop-bar")) {
|
||||
var window_height = 0;
|
||||
function post_list_show_animation() {
|
||||
if ($("article").hasClass("post-list-thumb")) {
|
||||
var options = {
|
||||
root: null,
|
||||
threshold: [0.66]
|
||||
}
|
||||
var io = new IntersectionObserver(callback, options);
|
||||
var articles = document.querySelectorAll('.post-list-thumb');
|
||||
function callback(entries) {
|
||||
entries.forEach((article) => {
|
||||
if (article.target.classList.contains("post-list-show")) {
|
||||
io.unobserve(article.target)
|
||||
} else {
|
||||
if (mashiro_option.land_at_home) {
|
||||
var window_height = $(window).height() - 300;
|
||||
} else {
|
||||
var window_height = $(window).height();
|
||||
if (article.isIntersecting) {
|
||||
article.target.classList.add("post-list-show");
|
||||
io.unobserve(article.target)
|
||||
}
|
||||
}
|
||||
}
|
||||
var article_height = $("article.post-list-thumb").eq(i).offset().top;
|
||||
if ($(window).height() + $(window).scrollTop() >= article_height)
|
||||
$("article.post-list-thumb").eq(i).addClass('post-list-show');
|
||||
$(window).scroll(function () {
|
||||
var scrolltop = $(window).scrollTop();
|
||||
if (scrolltop + window_height >= article_height && scrolltop)
|
||||
$("article.post-list-thumb").eq(i).addClass("post-list-show");
|
||||
});
|
||||
});
|
||||
})
|
||||
}
|
||||
articles.forEach((article) => {
|
||||
io.observe(article)
|
||||
})
|
||||
}
|
||||
}
|
||||
window.onpopstate = post_list_show_animation;
|
||||
mashiro_global.font_control = new function () {
|
||||
this.change_font = function () {
|
||||
if ($("body").hasClass("serif")) {
|
||||
|
@ -166,6 +165,7 @@ if (Poi.reply_link_version == 'new'){
|
|||
}
|
||||
|
||||
function attach_image() {
|
||||
var cached = $('.insert-image-tips');
|
||||
$('#upload-img-file').change(function () {
|
||||
if (this.files.length > 10) {
|
||||
addComment.createButterbar("每次上传上限为10张.<br>10 files max per request.");
|
||||
|
@ -187,13 +187,13 @@ function attach_image() {
|
|||
contentType: false,
|
||||
data: formData,
|
||||
beforeSend: function (xhr) {
|
||||
$('.insert-image-tips').html('<i class="fa fa-spinner rotating" aria-hidden="true"></i>');
|
||||
cached.html('<i class="fa fa-spinner rotating" aria-hidden="true"></i>');
|
||||
addComment.createButterbar("上传中...<br>Uploading...");
|
||||
},
|
||||
success: function (res) {
|
||||
$('.insert-image-tips').html('<i class="fa fa-check" aria-hidden="true"></i>');
|
||||
cached.html('<i class="fa fa-check" aria-hidden="true"></i>');
|
||||
setTimeout(function () {
|
||||
$('.insert-image-tips').html('<i class="fa fa-picture-o" aria-hidden="true"></i>');
|
||||
cached.html('<i class="fa fa-picture-o" aria-hidden="true"></i>');
|
||||
}, 1000);
|
||||
var get_the_url = res.data.url;
|
||||
$('#upload-img-show').append('<img class="lazyload upload-image-preview" src="https://cdn.jsdelivr.net/gh/moezx/cdn@3.0.2/img/svg/loader/trans.ajax-spinner-preloader.svg" data-src="' + get_the_url + '" onclick="window.open(\'' + get_the_url + '\')" onerror="imgError(this)" />');
|
||||
|
@ -202,10 +202,10 @@ function attach_image() {
|
|||
grin(res.data.url.replace('https://i.loli.net/', '{UPLOAD}'), type = 'Img');
|
||||
},
|
||||
error: function () {
|
||||
$('.insert-image-tips').html('<i class="fa fa-times" aria-hidden="true" style="color:red"></i>');
|
||||
cached.html('<i class="fa fa-times" aria-hidden="true" style="color:red"></i>');
|
||||
alert("上传失败,请重试.\nUpload failed, please try again.");
|
||||
setTimeout(function () {
|
||||
$('.insert-image-tips').html('<i class="fa fa-picture-o" aria-hidden="true"></i>');
|
||||
cached.html('<i class="fa fa-picture-o" aria-hidden="true"></i>');
|
||||
}, 1000);
|
||||
}
|
||||
})
|
||||
|
@ -231,7 +231,7 @@ function add_upload_tips() {
|
|||
|
||||
function click_to_view_image() {
|
||||
$(".comment_inline_img").click(function () {
|
||||
var temp_url = $(this).attr('src');
|
||||
var temp_url = this.src;
|
||||
window.open(temp_url);
|
||||
});
|
||||
}
|
||||
|
@ -260,26 +260,27 @@ function cmt_showPopup(ele) {
|
|||
function scrollBar() {
|
||||
if (document.body.clientWidth > 860) {
|
||||
$(window).scroll(function () {
|
||||
var s = $(window).scrollTop();
|
||||
var a = $(document).height();
|
||||
var b = $(window).height();
|
||||
var result = parseInt(s / (a - b) * 100);
|
||||
$("#bar").css("width", result + "%");
|
||||
var s = $(window).scrollTop(),
|
||||
a = $(document).height(),
|
||||
b = $(window).height(),
|
||||
result = parseInt(s / (a - b) * 100),
|
||||
cached = $("#bar");
|
||||
cached.css("width", result + "%");
|
||||
if (false) {
|
||||
if (result >= 0 && result <= 19)
|
||||
$("#bar").css("background", "#cccccc");
|
||||
cached.css("background", "#cccccc");
|
||||
if (result >= 20 && result <= 39)
|
||||
$("#bar").css("background", "#50bcb6");
|
||||
cached.css("background", "#50bcb6");
|
||||
if (result >= 40 && result <= 59)
|
||||
$("#bar").css("background", "#85c440");
|
||||
cached.css("background", "#85c440");
|
||||
if (result >= 60 && result <= 79)
|
||||
$("#bar").css("background", "#f2b63c");
|
||||
cached.css("background", "#f2b63c");
|
||||
if (result >= 80 && result <= 99)
|
||||
$("#bar").css("background", "#FF0000");
|
||||
cached.css("background", "#FF0000");
|
||||
if (result == 100)
|
||||
$("#bar").css("background", "#5aaadb");
|
||||
cached.css("background", "#5aaadb");
|
||||
} else {
|
||||
$("#bar").css("background", "orange");
|
||||
cached.css("background", "orange");
|
||||
}
|
||||
$(".toc-container").css("height", $(".site-content").outerHeight());
|
||||
$(".skin-menu").removeClass('show');
|
||||
|
@ -300,9 +301,9 @@ function checkskinSecter() {
|
|||
function checkBgImgCookie() {
|
||||
var bgurl = getCookie("bgImgSetting");
|
||||
if (bgurl != "") {
|
||||
$(".skin-menu #" + bgurl).click();
|
||||
$("#" + bgurl).click();
|
||||
} else {
|
||||
$(".skin-menu #white-bg").click();
|
||||
$("#white-bg").click();
|
||||
}
|
||||
}
|
||||
if (document.body.clientWidth > 860) {
|
||||
|
@ -322,9 +323,10 @@ $(document).ready(function() {
|
|||
return a == "none" ? "" : a
|
||||
}
|
||||
function changeBG() {
|
||||
$(".menu-list li").each(function() {
|
||||
var cached=$(".menu-list");
|
||||
cached.find("li").each(function() {
|
||||
var tagid = this.id;
|
||||
$(".skin-menu #" + tagid).click(function() {
|
||||
cached.on("click", "#" + tagid, function(){
|
||||
if (tagid == "white-bg") {
|
||||
mashiro_global.variables.skinSecter = true;
|
||||
checkskinSecter();
|
||||
|
@ -422,8 +424,9 @@ if (document.body.clientWidth <= 860) {
|
|||
}
|
||||
|
||||
function timeSeriesReload(flag) {
|
||||
var cached = $('#archives');
|
||||
if (flag == true) {
|
||||
$('#archives span.al_mon').click(function () {
|
||||
cached.find('span.al_mon').click(function () {
|
||||
$(this).next().slideToggle(400);
|
||||
return false;
|
||||
});
|
||||
|
@ -433,26 +436,26 @@ function timeSeriesReload(flag) {
|
|||
$('#al_expand_collapse,#archives span.al_mon').css({
|
||||
cursor: "s-resize"
|
||||
});
|
||||
$('#archives span.al_mon').each(function () {
|
||||
cached.find('span.al_mon').each(function () {
|
||||
var num = $(this).next().children('li').length;
|
||||
$(this).children('#post-num').text(num);
|
||||
});
|
||||
var $al_post_list = $('#archives ul.al_post_list'),
|
||||
$al_post_list_f = $('#archives ul.al_post_list:first');
|
||||
var $al_post_list = cached.find('ul.al_post_list'),
|
||||
$al_post_list_f = cached.find('ul.al_post_list:first');
|
||||
$al_post_list.hide(1, function () {
|
||||
$al_post_list_f.show();
|
||||
});
|
||||
$('#archives span.al_mon').click(function () {
|
||||
cached.find('span.al_mon').click(function () {
|
||||
$(this).next().slideToggle(400);
|
||||
return false;
|
||||
});
|
||||
if (document.body.clientWidth > 860) {
|
||||
$('#archives li.al_li').mouseover(function () {
|
||||
cached.find('li.al_li').mouseover(function () {
|
||||
$(this).children('.al_post_list').show(400);
|
||||
return false;
|
||||
});
|
||||
if (false) {
|
||||
$('#archives li.al_li').mouseout(function () {
|
||||
cached.find('li.al_li').mouseout(function () {
|
||||
$(this).children('.al_post_list').hide(400);
|
||||
return false;
|
||||
});
|
||||
|
@ -558,7 +561,7 @@ function tableOfContentScroll(flag) {
|
|||
var id = 1;
|
||||
$(".entry-content , .links").children("h1,h2,h3,h4,h5").each(function () {
|
||||
var hyphenated = "toc-head-" + id;
|
||||
$(this).attr('id', hyphenated);
|
||||
this.id = hyphenated;
|
||||
id++;
|
||||
});
|
||||
tocbot.init({
|
||||
|
@ -607,7 +610,6 @@ var pjaxInit = function () {
|
|||
timeSeriesReload();
|
||||
add_copyright();
|
||||
tableOfContentScroll(flag = true);
|
||||
console.log($("#myscript").text());
|
||||
}
|
||||
$(document).on("click", ".sm", function () {
|
||||
var msg = "您真的要设为私密吗?";
|
||||
|
@ -833,26 +835,26 @@ if(mashiro_option.float_player_on) {
|
|||
}
|
||||
|
||||
function getqqinfo() {
|
||||
var is_get_by_qq = false;
|
||||
var is_get_by_qq = false,cached = $('input');
|
||||
if (!getCookie('user_qq') && !getCookie('user_qq_email') && !getCookie('user_author')) {
|
||||
$('input#qq,input#author,input#email,input#url').val('');
|
||||
cached.filter('#qq,#author,#email,#url').val('');
|
||||
}
|
||||
if (getCookie('user_avatar') && getCookie('user_qq') && getCookie('user_qq_email')) {
|
||||
$('div.comment-user-avatar img').attr('src', getCookie('user_avatar'));
|
||||
$('input#author').val(getCookie('user_author'));
|
||||
$('input#email').val(getCookie('user_qq') + '@qq.com');
|
||||
$('input#qq').val(getCookie('user_qq'));
|
||||
cached.filter('#author').val(getCookie('user_author'));
|
||||
cached.filter('#email').val(getCookie('user_qq') + '@qq.com');
|
||||
cached.filter('#qq').val(getCookie('user_qq'));
|
||||
if (mashiro_option.qzone_autocomplete) {
|
||||
$('input#url').val('https://user.qzone.qq.com/' + getCookie('user_qq'));
|
||||
cached.filter('#url').val('https://user.qzone.qq.com/' + getCookie('user_qq'));
|
||||
}
|
||||
if ($('input#qq').val()) {
|
||||
if (cached.filter('#qq').val()) {
|
||||
$('.qq-check').css('display', 'block');
|
||||
$('.gravatar-check').css('display', 'none');
|
||||
}
|
||||
}
|
||||
var emailAddressFlag = $('input#email').val();
|
||||
$('input#author').on('blur', function () {
|
||||
var qq = $('input#author').val();
|
||||
var emailAddressFlag = cached.filter('#email').val();
|
||||
cached.filter('#author').on('blur', function () {
|
||||
var qq = cached.filter('#author').val();
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
url: mashiro_option.qq_api_url + '?type=getqqnickname&qq=' + qq,
|
||||
|
@ -860,15 +862,15 @@ function getqqinfo() {
|
|||
jsonp: 'callback',
|
||||
jsonpCallback: 'portraitCallBack',
|
||||
success: function (data) {
|
||||
$('input#author').val(data[qq][6]);
|
||||
$('input#email').val($.trim(qq) + '@qq.com');
|
||||
cached.filter('#author').val(data[qq][6]);
|
||||
cached.filter('#email').val($.trim(qq) + '@qq.com');
|
||||
if (mashiro_option.qzone_autocomplete) {
|
||||
$('input#url').val('https://user.qzone.qq.com/' + $.trim(qq));
|
||||
cached.filter('#url').val('https://user.qzone.qq.com/' + $.trim(qq));
|
||||
}
|
||||
$('div.comment-user-avatar img').attr('src', 'https://q2.qlogo.cn/headimg_dl?dst_uin=' + qq + '&spec=100');
|
||||
is_get_by_qq = true;
|
||||
$('input#qq').val($.trim(qq));
|
||||
if ($('input#qq').val()) {
|
||||
cached.filter('#qq').val($.trim(qq));
|
||||
if (cached.filter('#qq').val()) {
|
||||
$('.qq-check').css('display', 'block');
|
||||
$('.gravatar-check').css('display', 'none');
|
||||
}
|
||||
|
@ -877,16 +879,16 @@ function getqqinfo() {
|
|||
setCookie('is_user_qq', 'yes', 30);
|
||||
setCookie('user_qq_email', qq + '@qq.com', 30);
|
||||
setCookie('user_email', qq + '@qq.com', 30);
|
||||
emailAddressFlag = $('input#email').val();
|
||||
emailAddressFlag = cached.filter('#email').val();
|
||||
},
|
||||
error: function () {
|
||||
$('input#qq').val('');
|
||||
cached.filter('#qq').val('');
|
||||
$('.qq-check').css('display', 'none');
|
||||
$('.gravatar-check').css('display', 'block');
|
||||
$('div.comment-user-avatar img').attr('src', get_gravatar($('input#email').val(), 80));
|
||||
$('div.comment-user-avatar img').attr('src', get_gravatar(cached.filter('#email').val(), 80));
|
||||
setCookie('user_qq', '', 30);
|
||||
setCookie('user_email', $('input#email').val(), 30);
|
||||
setCookie('user_avatar', get_gravatar($('input#email').val(), 80), 30);
|
||||
setCookie('user_email', cached.filter('#email').val(), 30);
|
||||
setCookie('user_avatar', get_gravatar(cached.filter('#email').val(), 80), 30);
|
||||
}
|
||||
});
|
||||
$.ajax({
|
||||
|
@ -900,55 +902,55 @@ function getqqinfo() {
|
|||
setCookie('user_avatar', data[qq], 30);
|
||||
},
|
||||
error: function () {
|
||||
$('input#qq', 'input#email', 'input#url').val('');
|
||||
if (!$('input#qq').val()) {
|
||||
cached.filter('#qq,#email,#url').val('');
|
||||
if (!cached.filter('#qq').val()) {
|
||||
$('.qq-check').css('display', 'none');
|
||||
$('.gravatar-check').css('display', 'block');
|
||||
setCookie('user_qq', '', 30);
|
||||
$('div.comment-user-avatar img').attr('src', get_gravatar($('input#email').val(), 80));
|
||||
setCookie('user_avatar', get_gravatar($('input#email').val(), 80), 30);
|
||||
$('div.comment-user-avatar img').attr('src', get_gravatar(cached.filter('#email').val(), 80));
|
||||
setCookie('user_avatar', get_gravatar(cached.filter('#email').val(), 80), 30);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
if (getCookie('user_avatar') && getCookie('user_email') && getCookie('is_user_qq') == 'no' && !getCookie('user_qq_email')) {
|
||||
$('div.comment-user-avatar img').attr('src', getCookie('user_avatar'));
|
||||
$('input#email').val(getCookie('user_email'));
|
||||
$('input#qq').val('');
|
||||
if (!$('input#qq').val()) {
|
||||
cached.filter('#email').val(getCookie('user_email'));
|
||||
cached.filter('#qq').val('');
|
||||
if (!cached.filter('#qq').val()) {
|
||||
$('.qq-check').css('display', 'none');
|
||||
$('.gravatar-check').css('display', 'block');
|
||||
}
|
||||
}
|
||||
$('input#email').on('blur', function () {
|
||||
var emailAddress = $('input#email').val();
|
||||
cached.filter('#email').on('blur', function () {
|
||||
var emailAddress = cached.filter('#email').val();
|
||||
if (is_get_by_qq == false || emailAddressFlag != emailAddress) {
|
||||
$('div.comment-user-avatar img').attr('src', get_gravatar(emailAddress, 80));
|
||||
setCookie('user_avatar', get_gravatar(emailAddress, 80), 30);
|
||||
setCookie('user_email', emailAddress, 30);
|
||||
setCookie('user_qq_email', '', 30);
|
||||
setCookie('is_user_qq', 'no', 30);
|
||||
$('input#qq').val('');
|
||||
if (!$('input#qq').val()) {
|
||||
cached.filter('#qq').val('');
|
||||
if (!cached.filter('#qq').val()) {
|
||||
$('.qq-check').css('display', 'none');
|
||||
$('.gravatar-check').css('display', 'block');
|
||||
}
|
||||
}
|
||||
});
|
||||
if (getCookie('user_url')) {
|
||||
$('input#url').val(getCookie('user_url'));
|
||||
cached.filter('#url').val(getCookie('user_url'));
|
||||
}
|
||||
$('input#url').on('blur', function () {
|
||||
var URL_Address = $('input#url').val();
|
||||
$('input#url').val(URL_Address);
|
||||
cached.filter('#url').on('blur', function () {
|
||||
var URL_Address = cached.filter('#url').val();
|
||||
cached.filter('#url').val(URL_Address);
|
||||
setCookie('user_url', URL_Address, 30);
|
||||
});
|
||||
if (getCookie('user_author')) {
|
||||
$('input#author').val(getCookie('user_author'));
|
||||
cached.filter('#author').val(getCookie('user_author'));
|
||||
}
|
||||
$('input#author').on('blur', function () {
|
||||
var user_name = $('input#author').val();
|
||||
$('input#author').val(user_name);
|
||||
cached.filter('#author').on('blur', function () {
|
||||
var user_name = cached.filter('#author').val();
|
||||
cached.filter('#author').val(user_name);
|
||||
setCookie('user_author', user_name, 30);
|
||||
});
|
||||
}
|
||||
|
@ -1501,19 +1503,19 @@ var home = location.href,
|
|||
h2 = 50,
|
||||
ss = $(document).scrollTop();
|
||||
$(window).scroll(function () {
|
||||
var s = $(document).scrollTop();
|
||||
var s = $(document).scrollTop(),cached = $('.site-header');
|
||||
if (s == h1) {
|
||||
$('.site-header').removeClass('yya');
|
||||
cached.removeClass('yya');
|
||||
}
|
||||
if (s > h1) {
|
||||
$('.site-header').addClass('yya');
|
||||
cached.addClass('yya');
|
||||
}
|
||||
if (s > h2) {
|
||||
$('.site-header').addClass('gizle');
|
||||
cached.addClass('gizle');
|
||||
if (s > ss) {
|
||||
$('.site-header').removeClass('sabit');
|
||||
cached.removeClass('sabit');
|
||||
} else {
|
||||
$('.site-header').addClass('sabit');
|
||||
cached.addClass('sabit');
|
||||
}
|
||||
ss = s;
|
||||
}
|
||||
|
@ -1554,7 +1556,7 @@ var home = location.href,
|
|||
$("#pagination a").removeClass("loading").text("Previous");
|
||||
$('#add_post span').removeClass("loading").text("");
|
||||
lazyload();
|
||||
mashiro_global.post_list_show_animation.ini(50);
|
||||
post_list_show_animation();
|
||||
if (nextHref != undefined) {
|
||||
$("#pagination a").attr("href", nextHref);
|
||||
//加载完成上滑
|
||||
|
|
11
options.php
11
options.php
|
@ -253,6 +253,17 @@ function optionsframework_options() {
|
|||
'square' => __('方形', '')
|
||||
));
|
||||
|
||||
$options[] = array(
|
||||
'name' => __('首页文章特色图对齐方式(仅对图文风格生效,默认左右交替)', 'akina'),
|
||||
'id' => 'feature_align',
|
||||
'std' => "alternate",
|
||||
'type' => "radio",
|
||||
'options' => array(
|
||||
'left' => __('向左对齐', ''),
|
||||
'right' => __('向右对齐', ''),
|
||||
'alternate' => __('左右交替', '')
|
||||
));
|
||||
|
||||
$options[] = array(
|
||||
'name' => __('默认文章特色图', 'options_framework_theme'),
|
||||
'desc' => __('在未设置文章特色图的情况下展示的默认图像,留空则调用本地随机封面(要展示的图片放入 /wp-content/themes/Sakura/feature/gallery/ 目录)', 'options_framework_theme'),
|
||||
|
|
|
@ -11,7 +11,19 @@
|
|||
//}
|
||||
//add_filter('the_excerpt', 'custom_short_excerpt');
|
||||
$i=0; while ( have_posts() ) : the_post(); $i++;
|
||||
$class = ($i%2 == 0) ? 'post-list-thumb-left' : ''; // 如果为偶数
|
||||
switch (akina_option('feature_align')) {
|
||||
case "left":
|
||||
$class = 'post-list-thumb-left';
|
||||
break;
|
||||
case "right":
|
||||
$class = '';
|
||||
break;
|
||||
case "alternate":
|
||||
$class = ($i%2 == 0) ? 'post-list-thumb-left' : ''; // 如果为偶数
|
||||
break;
|
||||
default:
|
||||
$class = ($i%2 == 0) ? 'post-list-thumb-left' : '';
|
||||
}
|
||||
if(has_post_thumbnail()){
|
||||
$large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large');
|
||||
$post_img = $large_image_url[0];
|
||||
|
|
Loading…
Reference in New Issue