forked from miguelfreitas/twister-html
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interface_home.js
85 lines (73 loc) · 3.24 KB
/
interface_home.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
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// interface_home.js
// 2013 Lucas Leal, Miguel Freitas
//
// Specific interface functions for home.html
//***********************************************
//******************* DECLARATIONS **************
//***********************************************
var InterfaceFunctions = function()
{
//faço os binds no init
this.init = function()
{
$( ".wrapper .postboard-news").click(function() {
requestTimelineUpdate("latest",postsPerRefresh,followingUsers);});
initInterfaceCommon();
initUserSearch();
initInterfaceDirectMsg();
initUser(initHome);
}
function initHome(cbFunc, cbArg) {
if( !defaultScreenName ) {
alert(polyglot.t("username_undefined"));
$.MAL.goLogin();
return;
}
checkNetworkStatusAndAskRedirect();
//$("span.screen-name").text('@' + user);
var $miniProfile = $(".mini-profile");
$miniProfile.find("a.mini-profile-name").attr("href",$.MAL.userUrl(defaultScreenName));
$miniProfile.find("a.open-profile-modal").attr("href",$.MAL.userUrl(defaultScreenName));
$miniProfile.find(".mini-profile-name").text(defaultScreenName);
getFullname( defaultScreenName, $miniProfile.find(".mini-profile-name") );
getAvatar( defaultScreenName, $miniProfile.find(".mini-profile-photo").find("img") );
getPostsCount( defaultScreenName, $miniProfile.find(".posts-count") );
getFollowers( defaultScreenName, $miniProfile.find(".followers-count") );
loadFollowing( function(args) {
$(".mini-profile .following-count").text(followingUsers.length-1);
requestLastHave();
setInterval("requestLastHave()", 1000);
initMentionsCount();
initDMsCount();
requestTimelineUpdate("latestFirstTime",postsPerRefresh,followingUsers);
// install scrollbottom handler to load more posts as needed
$(window).scroll(function(){
if ($(window).scrollTop() >= $(document).height() - $(window).height() - 20){
if( timelineLoaded ) {
requestTimelineUpdate("older", postsPerRefresh, followingUsers);
}
}
});
setTimeout("getRandomFollowSuggestion(processSuggestion)", 1000);
setTimeout("getRandomFollowSuggestion(processSuggestion)", 1000);
setTimeout("getRandomFollowSuggestion(processSuggestion)", 1000);
if( args.cbFunc )
args.cbFunc(args.cbArg);
}, {cbFunc:cbFunc, cbArg:cbArg});
}
}
//***********************************************
//******************* INIT **************
//***********************************************
var interfaceFunctions = new InterfaceFunctions;
$( document ).ready( interfaceFunctions.init );
//função no window que fixa o header das postagens
function fixDiv()
{
var $cache = $('.postboard h2');
if ($(window).scrollTop() > 26)
$cache.addClass( "fixed" );
else
$cache.removeClass( "fixed" );
}
$(window).scroll(fixDiv);