<?php
/*
Plugin Name: 一键返回顶部
Version: 1.0
Plugin URL:
Description: 页面返回顶部
Author: 五哥
Author URL: http://s.yylog.cn
*/

!defined('EMLOG_ROOT') && exit('access deined!');

function backToTop(){
    $plugin_storage = Storage::getInstance('yy_top');
    $iconTop = $plugin_storage->getValue('iconTop');
?>

	<span class="backToTopBtn iconfont <?=$iconTop?:'icon-top1'?>"></span>
	<link href="//at.alicdn.com/t/c/font_4257850_psk8xh442na.css" rel="stylesheet" />
	<style>.backToTopBtn {font-size: 30px;position: fixed;right: 15px;bottom: 30px;background-color: rgb(0 0 0 / 60%);color: white;padding: 12px;line-height: initial;border-radius: 5px;display: none;z-index: 9201;</style>
	<script>
		$(document).ready(function() {
			$(window).scroll(function() {
				if ($(window).scrollTop() > 100) {
					$(".backToTopBtn").fadeIn(200);
				} else {
					$(".backToTopBtn").fadeOut(200);
				}
			});
			$(window).scroll();
			$(".backToTopBtn").click(function() {
				$('body,html').animate({
					scrollTop: 0
				}, 500);
				return false;
			});
		});
	</script>

	<?php
}


addAction('index_footer', 'backToTop');



?>