Repository navigation
Expand file tree
/
Copy pathCommentPages.js
More file actions
60 lines (56 loc) · 2.03 KB
/
Copy pathCommentPages.js
File metadata and controls
60 lines (56 loc) · 2.03 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
var jsCommentPages = function(){
var $activePage,
$activeTab,
init = function(){
$(".comments-tab").each(function(){
var $tab = $(this);
$tab.click(selectPage)
.addClass("js-inactive-tab");
switch ($tab.attr("id")){
case "blogger-comments":
$tab.prepend("<img src='http://lh6.googleusercontent.com/-_InM8Yxvqlg/Tg03QmGCkDI/AAAAAAAAAd8/Ozlnv5wP_C8/s800/blogger-white-B.png'>");
break;
case "twitter-comments":
$tab.prepend("<img src='http://lh6.googleusercontent.com/-7o7PRftYZaA/Tg0194rd1KI/AAAAAAAAAd4/0FEbtbBl760/s800/white-twitter-bird.png'>");
break;
case "fb-comments":
$tab.prepend("<img src='http://static.ak.fbcdn.net/rsrc.php/v1/yH/r/eIpbnVKI9lR.png'>");
break;
}
$tab = null;
});
getTweetCounts();
var $default = $(".js-default-tab:first"),
strDefault = "#blogger-comments";
if($default.length > 0){
strDefault = "#" + $default.attr("id");
}
//Set default tab and page Active
$activeTab = $(strDefault);
$activeTab.removeClass("js-inactive-tab");
$activePage = $(strDefault + "-page");
$activePage.show();
},
getTweetCounts = function(){
$(".js-page-tweet-count").each(
function(){
var $count = $(this);
$.getJSON("http://urls.api.twitter.com/1/urls/count.json?callback=?",
{url: $count.attr("href")},
function(json){$count.text(json.count);$count = null;});
}
);
},
selectPage = function() {
//Set old tab inactive, then set clicked tab active
$activeTab.addClass("js-inactive-tab");
$activeTab = $(this);
$activeTab.removeClass("js-inactive-tab");
//hide active page, then switch to page associated to clicked tab
$activePage.hide();
$activePage = $("#" + $activeTab.attr("id") + "-page");
$activePage.show();
};
$("head").append("<link id='js-comments-pages-styles' rel='stylesheet' type='text/css' href='http://panduan-template-blog-id.googlecode.com/files/CommentPages.css'/>");
$("document").ready(init);
}();