WordPress主題的jQuery應用之TAB切換效果

首先在header.php的head標簽中加載jQuery庫

1
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js"></script>

新建一個JS文件,在header.php的head標簽中加載,JS文件中加入下例代碼:

1
2
3
4
5
6
7
8
9
$(document).ready(function(){
$(".entry-foot span:first").addClass("current");  // 為第一個span添加 .current 的樣式,默認選中
$(".entry-foot ul:not(:first)").hide();  //ul 不是第一個時隱藏
$(".entry-foot span").mouseover(function(){  // 鼠標移到 span 上時觸發函數
$(".entry-foot span").removeClass("current");  //為第一個 span 移除 .current 樣式
$(this).addClass("current");  //為觸發的 span 添加樣式
$(".entry-foot ul").hide();  // 隱藏 ul
$("."+$(this).attr("id")).fadeIn("slow");  // 這句是核心,class(.) 和觸發 span 的ID 一致的 fadeIn(漸顯)
});});

HTML代碼如下:

1
2
3
4
5
6
7
8
9
<div class="tab">
<p>
<span ID="tab1">tab1</span>
<span ID="tab2">tab2</span>
<span ID="tab3">tab3</span></p>
<ul class="tab1">以 LI 形式呈現的 tab1 的內容</ul>
<ul class="tab2">以 LI 形式呈現的 tab2 的內容</ul>
<ul class="tab3">以 LI 形式呈現的 tab3 的內容</ul>
</div>

添加CSS代碼如下:

1
2
3
4
5
6
7
.entry-foot{background-color:#FAFAFA;margin:5px 8px;padding:5px 10px;}
.entry-foot p span{background-color:#EFEFEF;border:1px solid
#CCCCCC;cursor:pointer;margin-right:6px;padding:2px 5px;}
.entry-foot p span.current{background-color:#FAFAFA; border-bottom-color:#fafafa;}
.entry-foot p{border-bottom:1px solid #CCCCCC;font-weight:bold;padding:0 10px 2px;}
.entry-foot li{border-bottom:1px dotted #CCCCCC;padding-bottom:3px;margin:5px 0;}
.entry-foot .mhot,.entry-foot.allhot{display:none;}

原文:http://www.xiaorsz.com/jquery-realize-tab-switch-effect/

WordPress主題的jQuery應用之幻燈片效果

首先在header.php的head標簽中加載jQuery庫

1
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js"></script>

新建一個JS文件,在header.php的head標簽中加載,JS文件中加入下例代碼:

1
2
3
4
5
6
7
8
9
10
11
12
13
function slideSwitch() {
var $current = $("#slideshow div.current");
if ( $current.length == 0 ) $current = $("#slideshow div:last");
var $next = $current.next().length ? $current.next() : $("#slideshow div:first");
$current.addClass('prev');
$next.css({opacity: 0.0}).addClass("current").animate({opacity: 1.0}, 1000, function() {
$current.removeClass("current prev");
});
} $(function() {
$("#slideshow span").css("opacity","0.7");
$(".current").css("opacity","1.0");
setInterval( "slideSwitch()", 3000 );
});

HTML代碼如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<div ID="slideshow">
    <div class="current">
        <a href="http://www.jssanhong.com/"><img src="1.jpg" alt="" /></a>
        <span>The First Image</span>
    </div>
    <div>
        <a href="http://www.jssanhong.com/"><img src="2.jpg" alt="" /></a>
        <span>The Second Image</span>
    </div>
    <div>
        <a href="http://www.jssanhong.com/"><img src="3.jpg" alt="" /></a>
        <span>Yes, thd third.</span>
    </div>
</div>

添加CSS代碼如下:

1
2
3
4
5
6
#slideshow{position:relative;height:195px;width:425px;border:10px solid #ddd;margin:0 auto 15px;}
#slideshow div{position:absolute;top:0;left:0;z-index:3;opacity:0.0;height:195px;overflow:hidden;background-color:#FFF;}
#slideshow div.current{z-index:5;}
#slideshow div.prev{z-index:4;}
#slideshow div img{display:block;border:0;margin-bottom:10px;}
#slideshow div span{display:none;position:absolute;bottom:0;left:0;height:50px;line-height:50px;background:#000;color:#fff;width:100%;}

原文:http://www.happinesz.cn/archives/1015/

WordPress主題的jQuery應用之返回頂部滑動效果

首先在header.php的head標簽中加載jQuery庫

1
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js"></script>

新建一個JS文件,在header.php的head標簽中加載,JS文件中加入下例代碼:

1
2
$('.top').click(function(){$('html,body').animate({scrollTop: '0px'}, 800);});
$('.bot').click(function(){$('html,body').animate({scrollTop:$('#footer').offset().top}, 800);});

在footer.php文件中加入代碼:

1
2
3
4
<div ID="goto">
    <div class="top">頂端</div>
    <div class="bot">底端</div>
</div>

在CSS文件中添加下例代碼:

1
2
3
4
5
*html #goto { position: absolute; top: expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight/2));}
#goto { position: fixed; left: 50%; top: 50%; bottom: auto; margin-left: -500px; z-index: 999;}
#goto .top, #goto .bot { width: 28px; height: 41px; margin: 5px 0; background-image: url('images/goto.gif'); background-repeat: no-repeat; display: block; text-indent: -9999px; cursor: pointer;}
#goto .top { background-position: 0 0;}
#goto .bot { background-position: 0 100%;}

原文:http://immmmm.com/added-sliding-effect-enhanced.html

WordPress主題的jQuery應用之標題提示

首先在header.php的head標簽中加載jQuery庫

1
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js"></script>

新建一個JS文件,在header.php的head標簽中加載,JS文件中加入下例代碼:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var sweetTitles = {
    x : 10,                            
    y : 20,                            
    tipElements : "a",                 
    init : function() {
        $(this.tipElements).mouseover(function(e){
            this.myTitle = this.title;
            this.myHref = this.href;
            this.myHref = (this.myHref.length > 30 ? this.myHref.toString().substring(0,30)+"..." : this.myHref);       // url 超過 30 個字符的部分用 ... 代替
            this.title = "";
            var tooltip = "<div id='tooltip'><p>"+this.myTitle+"<em>"+this.myHref+"</em>"+"</p></div>";
            $('body').append(tooltip);
            $('#tooltip')
                .css({
                    "opacity":"0.8",                   // 0.8 為透明度可自行根據喜好調整數字
                    "top":(e.pageY+20)+"px",
                    "left":(e.pageX+10)+"px"
                }).show('fast');   
        }).mouseout(function(){
            this.title = this.myTitle;
            $('#tooltip').remove();
        }).mousemove(function(e){
            $('#tooltip')
            .css({
                "top":(e.pageY+20)+"px",
                "left":(e.pageX+10)+"px"
            });
        });
    }
};
$(function(){
    sweetTitles.init();
});

在CSS文件中添加下例代碼:

1
2
3
body div#tooltip { position:absolute;z-index:1000;max-width:220px;width:auto !important;width:220px;background:#000;text-align:left;padding:5px;min-height:1em;}
body div#tooltip p { margin:0;padding:0;color:#fff;font:12px verdana,arial,sans-serif; }
body div#tooltip p em { display:block;margin-top:3px;color:#f60;font-style:normal;font-weight:bold; }

如果你還用了@回復這樣的jQuery提示效果的話會被標題提示遮掉,可以參照下面解決:
代碼中的tipElements : “a”改成tipElements : “a:not(‘.atreply’)”來排除class為atreply的a標簽,或者用tipElements : “a:not([href^=’#’])”來排除href為錨點的a標簽

原文:http://leeiio.me/sweet-titles-for-jquery/

分享到豆瓣/QQ/開心網/人人網/百度/Google等代碼

推薦到豆瓣

1
<a rel="nofollow" class="fav_douban" href="javascript:void(function(){var%20d=document,e=encodeURIComponent,s1=window.getSelection,s2=d.getSelection,s3=d.selection,s=s1?s1():s2?s2():s3?s3.createRange().text:'',r='http://www.douban.com/recommend/?url='+e(d.location.href)+'&title='+e(d.title)+'&sel='+e(s)+'&v=1',x=function(){if(!window.open(r,'douban','toolbar=0,resizable=1,scrollbars=yes,status=1,width=450,height=330'))location.href=r+'&r=1'};if(/Firefox/.test(navigator.userAgent)){setTimeout(x,0)}else{x()}})()"></a>

或者用這個

1
<a rel="nofollow" class="fav_douban" href="javascript:window.open('http://www.douban.com/recommend/?url='+encodeURIComponent(document.location.href)+'&title='+encodeURIComponent(document.title));void(0)">豆瓣</a>

收藏到QQ書簽

1
<a rel="nofollow" class="fav_qq" href="javascript:window.open('http://shuqian.qq.com/post?from=3&title='+encodeURIComponent(document.title)+'&uri='+encodeURIComponent(document.location.href)+'&jumpback=2&noui=1','favit','width=930,height=470,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes');void(0)">QQ書簽</a>

轉貼到開心網

1
<a rel="nofollow" class="fav_kaixin" href="javascript:window.open('http://www.kaixin001.com/repaste/share.php?rtitle='+encodeURIComponent(document.title)+'&rurl='+encodeURIComponent(document.location.href)+'&rcontent=');void(0)">開心網</a>

分享到人人

1
<a rel="nofollow" class="fav_renren" href="javascript:window.open('http://share.renren.com/share/buttonshare.do?link='+encodeURIComponent(document.location.href)+'&title='+encodeURIComponent(document.title));void(0)">人人網</a>

添加到百度搜藏

1
<a rel="nofollow" class="fav_baidu" href="javascript:window.open('http://cang.baidu.com/do/add?it='+encodeURIComponent(document.title.substring(0,76))+'&iu='+encodeURIComponent(location.href)+'&fr=ien#nw=1','scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes'); void 0">百度搜藏</a>

GOOGLE書簽

1
<a rel="nofollow" class="fav_google" href="javascript:window.open('http://www.google.com/bookmarks/mark?op=add&bkmk='+encodeURIComponent(document.location.href)+'&title='+encodeURIComponent(document.title));void(0)">Google</a>

GOOGLE Buzz

1
<a rel="nofollow" class="fav_buzz" href="javascript:window.open('http://www.google.com/reader/link?url='+encodeURIComponent(document.location.href)+'&title='+encodeURIComponent(document.title)+'&srcURL=http://www.jssanhong.com');void(0)">Google Buzz</a>

分享到 Twitter

1
<a rel="nofollow" class="fav_twitter" href="javascript:window.open('http://twitter.com/home?status='+encodeURIComponent(document.location.href)+'&nbsp;'+encodeURIComponent(document.title));void(0)">Twitter</a>

分享到 Facebook

1
<a rel="nofollow" class="fav_facebook" href="javascript:window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(document.location.href)+'&t='+encodeURIComponent(document.title));void(0)">Facebook</a>

Delicious書簽

1
<a rel="nofollow" class="fav_delicious" href="javascript:window.open('http://del.icio.us/post?url='+encodeURIComponent(document.location.href)+'&title='+encodeURIComponent(document.title)+'&notes=');void(0)">Delicious</a>

自定義 WordPress 后臺用戶聯系方式

在 WordPress 后臺,個人設置(Profile)中,除了可以設置電子郵件和 Website 之外,還可以設置自己的聯系方式,比如 AIM, Yahoo IM, Jabber/Google Talk。但是除了 Gtalk 之外,其他兩個中國人基本不用,那么如何去掉我們基本不用的 AIM 和 Yahoo IM,并加上國人常用的 QQ, MSN 和飛信呢?

其實在 WordPress 中實現這樣的功能是非常容易的,只需要調用下 custom_contactmethods 這個 WordPress Filter 既可以實現在后臺支持常用的 QQ, MSN 和飛信等聯系方式,代碼如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
/*
Plugin Name: Custom Contact
Plugin URI: http://wpjam.com/
Description: 自定義博客的聯系方式,從 WordPress 默認的 AIM, Yahoo IM 改為中國常見的 QQ, MSN 和飛信。
Version: 1.0
Author: Neekey
Author URI: http://photozero.net/
*/

 
add_filter('user_contactmethods','custom_contactmethods');
function custom_contactmethods($user_contactmethods ){
    $user_contactmethods  = array(
        'qq' => 'QQ',
        'msn' => 'MSN',
        'jabber' => __('Jabber / Google Talk'),
        'fetion' => '飛信'
    );
    return $user_contactmethods ;
}
?>

把上面這些代碼保存下來,存為一個 PHP 文件,保存為 UTF-8 without BOM 格式,上傳到 WordPress 插件目錄,然后激活即可。如果你需要加入其他聯系方式,只需要按照同樣的方式在上面數組中添加即可,這里就不一一詳細介紹。

原文:http://fairyfish.net/2010/01/30/custom-contact/

修正IE6不支持position:fixed的bug

眾所周知IE6不支持position:fixed,這個bug與IE6的雙倍margin和不支持PNG透明等bug一樣臭名昭著。前些天我做自己的博客模板的時候,遇到了這個問題。當時就簡單的無視了IE6——盡管有幾個使用IE6的朋友,一起BS我……但是對于大項目或商業網站,如果有用到這個屬性的時候,是不可能直接無視的。

你是如何讓position:fixed在IE6中工作的?

本文所使用的技巧是用了一條Internet Explorer的CSS表達式(expression)。你不可以直接使用該表達式,因為它可能會因為緩存而不更新。解決這一點的最簡單的方式是使用eval包裹你的語句。
如何解決“振動”的問題?

顯然IE有一個多步的渲染進程。當你滾動或調整你的瀏覽器大小的時候,它將重置所有內容并重畫頁面,這個時候它就會重新處理css表達式。這會引起一個丑陋的“振動”bug,在此處固定位置的元素需要調整以跟上你的(頁面的)滾動,于是就會“跳動”。
繼續閱讀

Discuz版塊設置只有版主和發貼人能回復

修改post.php 這個文件,在59行處

1
2
3
if($thread['readperm'] && $thread['readperm'] > $readaccess && !$forum['ismoderator'] && $thread['authorid'] != $discuz_uid) {
   showmessage('thread_nopermission', NULL, 'NOPERM');
  }

的下面添加下面代碼即可。

1
2
3
4
5
  //只有版主和發貼人自己能回復
  if(($forum['fid']==42) && ($thread['authorid']!=$discuz_uid) && !$forum['ismoderator']  )
  {
           showmessage('只有版主和發貼人才能回復', NULL, 'NOPERM');
  }

江陰印刷網新版風格

其實江陰印刷網換上新風格有一段時間了,只是首頁的JS幻燈片一直沒有完成。今天總算找到了一個,換上了。

風格仿的是Discuz的Supesite的默認風格,支持二級分類,后臺自定義MEAT,廣告,統計代碼等。

主題要改的地方是index.php文件的array(1,3,4,5,6,7),把里面的數字改成你想顯示的分類ID號,幻燈片是自動讀取文章中的圖片,演示中最下面的最新圖片是用advanced-post-image做的(注意:這個插件要求在你的uploads目錄下建立thumb目錄及寫入權限)

下載:CMS THEME NO.1
截圖
jyprint

在用的WP風格

沒什么技術含量的,都是東抄西借,想名字也麻煩,就直接用縮寫命名了(Blog Theme No. 1),主題側欄支持 WordPress 自帶的 Widgets 功能。
后臺可自定義關鍵,Meta,可選顯示頁面或分類,可用Google自定義搜索,帶公告欄(在博客首頁的文章區域上方顯示),自主義側欄RSS訂閱地址,可選顯示廣告,可選顯示備案和統計。

btn1

下載:btn1