Skip to content

Commit

Permalink
Merge pull request typecho-fans#71 from ghosx/master
Browse files Browse the repository at this point in the history
新增一款插件
  • Loading branch information
jzwalk authored Jan 25, 2019
2 parents 0adb4b5 + 55abf8c commit 55dd04c
Show file tree
Hide file tree
Showing 11 changed files with 2,801 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,4 @@
[YoduBGM](YoduBGM) | 微型背景音乐播放器插件(支持Pjax) | 1.5.0 | [Jrotty](/~https://github.com/jrotty) | [Download](/~https://github.com/typecho-fans/plugins/releases/download/plugins-S_to_Z/YoduBGM.zip)
[YoduPlayer](YoduPlayer) | 悬浮式音乐播放器插件(支持Pjax) | 2.2.2 | [Jrotty](/~https://github.com/jrotty) | [Download](/~https://github.com/typecho-fans/plugins/releases/download/plugins-S_to_Z/YoduPlayer.zip)
[Zan](Zan) | 自定义字段输出文章点赞次数插件 | 1.0.0 | [冰剑](/~https://github.com/binjoo) | [Download](/~https://github.com/typecho-fans/plugins/releases/download/plugins-S_to_Z/Zan.zip)
[TopTop](TopTop) | typecho 博客的一款返回顶部插件 | 1.0.0 | [夜雨](/~https://github.com/ghosx) | [Download](/~https://github.com/ghosx/plugins/archive/releases.zip)
104 changes: 104 additions & 0 deletions TopTop/Plugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php
/**
* typecho 博客的一款返回顶部插件
*
* @package TopTop
* @author Heeeepin
* @version 1.0.0
* @link http://heeeepin.com
*/

class TopTop_Plugin implements Typecho_Plugin_Interface
{
/**
* 激活插件方法,如果激活失败,直接抛出异常
*
* @access public
* @return void
* @throws Typecho_Plugin_Exception
*/
public static function activate() {
Typecho_Plugin::factory('Widget_Archive')->header = array('TopTop_Plugin', 'header');
Typecho_Plugin::factory('Widget_Archive')->footer = array('TopTop_Plugin', 'footer');
return "插件启动成功";
}

/**
* 禁用插件方法,如果禁用失败,直接抛出异常
*
* @static
* @access public
* @return void
* @throws Typecho_Plugin_Exception
*/
public static function deactivate() {
return "插件禁用成功";
}

/**
* 获取插件配置面板
*
* @access public
* @param Typecho_Widget_Helper_Form $form 配置面板
* @return void
*/
public static function config(Typecho_Widget_Helper_Form $form) {
$m1 = Helper::options()->pluginUrl . '/TopTop/models/1.png';
$m2 = Helper::options()->pluginUrl . '/TopTop/models/2.png';
$model1 = "<img src=$m1 alt='模型1'/>";
$model2 = "<img src=$m2 alt='模型2'/>";
$jquery = new Typecho_Widget_Helper_Form_Element_Checkbox('jquery', array('jquery' => '禁止加载jQuery'), false, _t('Jquery设置'), _t('插件需要加载jQuery,如果主题模板已经引用加载JQuery,则可以勾选。'));
$model = new Typecho_Widget_Helper_Form_Element_Radio('model', array('model1' => $model1,'model2'=>$model2), 'model2', _t('模型设置'), _t('选择一个你喜欢的模型'));
$form->addInput($jquery);
$form->addInput($model);
}


/**
* 个人用户的配置面板
*
* @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 . '/TopTop/';
$options = Helper::options()->plugin('TopTop');
$model = $options->model;
echo '<link rel="stylesheet" type="text/css" href="' . $path . 'css/'.$model.'.css" />';
}


/**
* 页脚输出相关代码
*
* @access public
* @param unknown footer
* @return unknown
*/
public static function footer() {
$path = Helper::options()->pluginUrl . '/TopTop/';
$options = Helper::options()->plugin('TopTop');
echo '<div class="back-to-top" style="top: -700px;"></div>';
if (!$options->jquery) {
echo '<script type="text/javascript" src="' . $path . 'js/jquery.min.js"></script>';
}
echo '<script type="text/javascript" src="' . $path . 'js/toptop.js"></script>';
}
}




33 changes: 33 additions & 0 deletions TopTop/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# TopTop

typecho 博客的一款返回顶部插件

## 使用方法

Download ZIP, 解压

重命名文件夹为TopTop

上传至usr/plugins目录

登录后台启用即可

## 主题

自带两套主题,欢迎提供想法

在线体验: [夜雨博客](https://heeeepin.com)

![kk6h8K.png](https://s2.ax1x.com/2019/01/22/kk6h8K.png)
![kk64gO.png](https://s2.ax1x.com/2019/01/22/kk64gO.png)


## 感谢

[GoTop](/~https://github.com/NicoNicooooo/GoTop)






22 changes: 22 additions & 0 deletions TopTop/css/model1.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@media (max-width: 1000px) {
.back-to-top {
display: none !important;
}
}

.topButton {
display: none;
}

.back-to-top {
cursor: pointer;
position: fixed;
right: 80px;
top: -999px;
z-index: 2;
width: 70px;
height: 800px;
background: url(../images/1.png);
transition: all .5s ease-in-out;
opacity: 1;
}
22 changes: 22 additions & 0 deletions TopTop/css/model2.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@media (max-width: 1000px) {
.back-to-top {
display: none !important;
}
}

.topButton {
display: none;
}

.back-to-top {
cursor: pointer;
position: fixed;
right: 80px;
top: -999px;
z-index: 2;
width: 70px;
height: 800px;
background: url(../images/2.png);
transition: all .5s ease-in-out;
opacity: 1;
}
Binary file added TopTop/images/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added TopTop/images/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 55dd04c

Please sign in to comment.