18 lines
3.6 KiB
JavaScript
18 lines
3.6 KiB
JavaScript
/*
|
|
* Solo - A small and beautiful blogging system written in Java.
|
|
* Copyright (c) 2010-2019, b3log.org & hacpai.com
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
var Skin={_initCommon:function(e){$(window).scroll(function(){125<$(window).scrollTop()?e.show():e.hide(),0<$(".side .b3-solo-list").length&&(50<$(window).scrollTop()?$(".side").css("position","fixed"):$(".side").css("position","initial"))})},_initAnimation:function(){if(!("IntersectionObserver"in window))return $(".item").addClass("item--active"),!1;window.imageIntersectionObserver?window.imageIntersectionObserver.disconnect():window.imageIntersectionObserver=new IntersectionObserver(function(e){e.forEach(function(e){if(void 0===e.isIntersecting?0!==e.intersectionRatio:e.isIntersecting)$(e.target).addClass("item--active");else{if(1===$(e.target).closest(".side").length||1===$(e.target).closest("#articlePage").length||768<$(e.target).outerHeight())return;$(e.target).removeClass("item--active")}})}),$(".item").each(function(){window.imageIntersectionObserver.observe(this)})},init:function(){Util.initPjax(function(){Skin._initAnimation(),0===$("#articlePage").length&&$(".b3-solo-list").closest(".module").remove()}),Skin._initAnimation(),$("body").on("click",".content-reset img",function(){window.open(this.src)}),this._initCommon($(".icon__up")),$(".header__nav a, .header__m a").each(function(){this.href===location.href&&(this.className="current")}).click(function(){$(".header__nav a, .header__m a").removeClass("current"),this.className="current",$(".header__m .module__list").hide()}),$(".header__logo").click(function(){$(".header__nav a, .header__m a").removeClass("current")})},_initArticleCommon:function(){if(768<$(window).width()){if(0===$("#articlePage .b3-solo-list li").length)return $(".side .b3-solo-list").closest(".module").remove(),void $(".side").css({height:"auto",position:"initial"});$("#articlePage").width($(".main").width()-310),0===$(".side .b3-solo-list").length&&$(".side").prepend('<div class="module"><div class="module__list"></div></div>').css({right:($(window).width()-$(".main").width())/2,position:"fixed",overflow:"auto",height:$(window).height()-30,top:30}),$(".side .module:eq(0) .module__list").html($(".b3-solo-list")),$(window).scroll(),$(".side").scrollTop(0)}else{if(0===$("#articlePage .b3-solo-list li").length)return void $(".header__m .icon__list").hide().next().hide();$(".header__m .icon__list").show().next().html($(".b3-solo-list")),$(".b3-solo-list a").click(function(){$(this).closest(".module__list").hide()})}},initArticle:function(){this._initArticleCommon(),setTimeout(function(){0===$("#externalRelevantArticlesWrap li").length&&($("#externalRelevantArticlesWrap").next().remove(),$("#externalRelevantArticlesWrap").remove()),0===$("#relevantArticlesWrap li").length&&($("#relevantArticlesWrap").prev().remove(),$("#relevantArticlesWrap").remove()),0===$("#randomArticlesWrap li").length&&($("#randomArticlesWrap").prev().remove(),$("#randomArticlesWrap").remove())},1e3)}};Skin.init(); |