Skip to content

Commit

Permalink
修改bug,增加jquery导入选择
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaogouxo committed Nov 17, 2014
1 parent 383b7af commit 5e61958
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
21 changes: 10 additions & 11 deletions Like/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* @package Like
* @author skylzl
* @version 1.0.0
* @version 1.0.1
* @link http://www.phoneshuo.com
*/

Expand All @@ -20,7 +20,6 @@ class Like_Plugin implements Typecho_Plugin_Interface
*/
public static function activate()
{
Typecho_Plugin::factory('Widget_Archive')->footer = array('Like_Plugin', 'header');
Typecho_Plugin::factory('Widget_Archive')->footer = array('Like_Plugin', 'footer');
Helper::addAction('like', 'Like_Action');
$db = Typecho_Db::get();
Expand All @@ -39,7 +38,9 @@ public static function activate()
* @return void
* @throws Typecho_Plugin_Exception
*/
public static function deactivate(){}
public static function deactivate(){
Helper::removeAction('like');
}

/**
* 获取插件配置面板
Expand All @@ -53,8 +54,13 @@ public static function config(Typecho_Widget_Helper_Form $form){
$likeClass = new Typecho_Widget_Helper_Form_Element_Text(
'likeClass',NULL ,'post-like',
_t('点赞A标签的class'),
_t('点赞的自定义样式,默认为.post-like。可自定义CSS样式,无需加.')
_t('点赞的自定义样式,默认为.post-like。可自定义CSS样式,无需加.<br><a href="www.phoneshuo.com/PHP/typecho-like-plugin.html">使用帮助与更新</a>')
);
/** 是否加载jquery */
$jquery = new Typecho_Widget_Helper_Form_Element_Radio(
'jquery', array('0'=> '手动加载', '1'=> '自动加载'), 0, '选择jQuery来源',
'若选择"手动加载",则需要你手动加载jQuery到你的主题里,若选择"自动加载",本插件会自动加载jQuery到你的主题里。');
$form->addInput($jquery);
$form->addInput($likeClass);
}

Expand Down Expand Up @@ -133,13 +139,6 @@ public static function theMostLiked($limit = 10, $showlink = true, $before = '<b
echo "<li>N/A</li>\n";
}
}
/**
* 点赞相关css加载在头部
*/
public static function header() {
$cssUrl = Helper::options()->pluginUrl . '/Like/css/style.css';
echo '<link rel="stylesheet" type="text/css" href="' . $cssUrl . '" />';
}

/**
* 点赞相关js加载在尾部
Expand Down
6 changes: 0 additions & 6 deletions Like/css/style.css

This file was deleted.

8 changes: 7 additions & 1 deletion Like/like-js.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@
$jqueryScriptUrl = Helper::options()->pluginUrl . '/Like/js/jquery.js';
$macaroonScriptUrl = Helper::options()->pluginUrl . '/Like/js/jquery.fs.macaroon.js';
$settings = Helper::options()->plugin('Like');
$thumbUpImg = Helper::options()->pluginUrl . '/Like/thumb_up.png';
if($settings->jquery){
echo '<script src="'.$jqueryScriptUrl.'"></script>';
}
?>
<style type='text/css'>
.fa-thumbs-up{margin-right: 5px;top: 2px;width: 16px;height: 16px;display: inline-block; background: url(<?php echo $thumbUpImg; ?>) no-repeat left center; }
</style>

<script type="text/javascript" src="<?php echo $jqueryScriptUrl; ?>"></script>
<script type="text/javascript" src="<?php echo $macaroonScriptUrl; ?>"></script>
<script>
$(".<?php echo $settings->likeClass; ?>").on("click", function(){
Expand Down
File renamed without changes

0 comments on commit 5e61958

Please sign in to comment.