-
Notifications
You must be signed in to change notification settings - Fork 594
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit '3d639a365142ab76e0f90ecb5b0832a4b5c6ee35' as 'BackToTop'
- Loading branch information
Showing
7 changed files
with
168 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
<?php | ||
/** | ||
* 东方返回顶部样式 | ||
* | ||
* @package BackToTop | ||
* @author 夏目贵志 | ||
* @version 1.0 | ||
* @link https://xiamuyourenzhang.cn/ | ||
*/ | ||
|
||
class BackToTop_Plugin implements Typecho_Plugin_Interface | ||
{ | ||
/** | ||
* 激活插件方法,如果激活失败,直接抛出异常 | ||
* | ||
* @access public | ||
* @return void | ||
* @throws Typecho_Plugin_Exception | ||
*/ | ||
public static function activate() { | ||
Typecho_Plugin::factory('Widget_Archive')->header = array('BackToTop_Plugin', 'header'); | ||
Typecho_Plugin::factory('Widget_Archive')->footer = array('BackToTop_Plugin', 'footer'); | ||
} | ||
|
||
/** | ||
* 禁用插件方法,如果禁用失败,直接抛出异常 | ||
* | ||
* @static | ||
* @access public | ||
* @return void | ||
* @throws Typecho_Plugin_Exception | ||
*/ | ||
public static function deactivate() { | ||
|
||
} | ||
|
||
/** | ||
* 获取插件配置面板 | ||
* | ||
* @access public | ||
* @param Typecho_Widget_Helper_Form $form 配置面板 | ||
* @return void | ||
*/ | ||
public static function config(Typecho_Widget_Helper_Form $form) { | ||
$jquery = new Typecho_Widget_Helper_Form_Element_Checkbox('jquery', array('jquery' => '禁止加载jQuery'), null, _t('Js设置'), _t('插件需要加载jQuery,如果主题模板已经引用加载JQuery,则可以勾选。')); | ||
$form->addInput($jquery); | ||
} | ||
|
||
|
||
/** | ||
* 个人用户的配置面板 | ||
* | ||
* @access public | ||
* @param Typecho_Widget_Helper_Form $form | ||
* @return void | ||
*/ | ||
public static function personalConfig(Typecho_Widget_Helper_Form $form) { | ||
|
||
} | ||
|
||
|
||
/** | ||
* 页头输出相关代码 | ||
* | ||
* @access public | ||
* @param unknown header | ||
* @return unknown | ||
*/ | ||
public static function header() { | ||
$Path = Helper::options()->pluginUrl . '/BackToTop/'; | ||
echo '<link rel="stylesheet" type="text/css" href="' . $Path . 'css/BackToTop.css" />'; | ||
} | ||
|
||
|
||
/** | ||
* 页脚输出相关代码 | ||
* | ||
* @access public | ||
* @param unknown footer | ||
* @return unknown | ||
*/ | ||
public static function footer() { | ||
srand( microtime() * 1000000 ); | ||
$num = rand( 1, 3 ); | ||
|
||
switch( $num ) | ||
{ | ||
case 1: $image_file = "flandre.png"; | ||
break; | ||
case 2: $image_file = "marisa.png"; | ||
break; | ||
case 3: $image_file = "reimu.png"; | ||
break; | ||
} | ||
$Options = Helper::options()->plugin('BackToTop'); | ||
$Path = Helper::options()->pluginUrl . '/BackToTop/'; | ||
echo '<img id="BackToTop" src="' . $Path . 'images/'.$image_file.'" title="返回顶部~">'; | ||
if (!$Options->jquery || !in_array('jquery', $Options->jquery)) { | ||
echo '<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>'; | ||
} | ||
echo ' | ||
<script type="text/javascript"> | ||
$(function(){ | ||
$("#BackToTop").click(function() { | ||
$("html,body").animate({scrollTop:0}, 500); | ||
}); | ||
}) | ||
</script> | ||
'; | ||
} | ||
} | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# BackToTop | ||
|
||
- 简单 | ||
- 轻量级 | ||
|
||
随机三款东方样式,刷新页面改变 | ||
|
||
## 【食用方法】 | ||
|
||
Download ZIP, 解压 | ||
|
||
重命名文件夹为BackToTop | ||
|
||
上传至usr/plugins目录 | ||
|
||
登录后台启用即可 | ||
|
||
如果主题模板已加载jquery,可以在插件设置内禁用加载jquery | ||
|
||
## 【更新日志】 | ||
2018.4.2 1.0 项目完成 | ||
|
||
2018.5.31 修复开启JQ插件后报错bug | ||
|
||
## 【插件声明】 | ||
|
||
插件代码借用`Gotop插件` | ||
|
||
>Gotop项目地址:https://github.com/xiamuguizhi/GoTop | ||
>样式来自:https://www.mokeyjay.com | ||
[](https://wx2.sinaimg.cn/large/006eY07Igy1fpya477yfvj30lj0jljtl.jpg "样式一") | ||
|
||
[](https://wx2.sinaimg.cn/large/006eY07Igy1fpya4jew27j30j40fugm2.jpg "样式二") | ||
|
||
[](https://wx2.sinaimg.cn/large/006eY07Igy1fpya4r8f92j30i90h83yy.jpg "样式三") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#BackToTop { | ||
bottom:0px; | ||
right:0px; | ||
position:fixed; | ||
opacity:0.5; | ||
transition:all .5s; | ||
cursor:pointer; | ||
transform:scale(.7,.7); | ||
transform-origin:right bottom; | ||
} | ||
#BackToTop:hover { | ||
opacity:1; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.