Browse Source

Merge branch 'loadFollowing' of https://github.com/msjoinder/twister-html into msjoinder-loadFollowing

master
Miguel Freitas 11 years ago
parent
commit
b8e67dc9b7
  1. 39
      css/style.css
  2. 27
      following.html
  3. 26
      home.html
  4. 29
      interface_common.js
  5. 17
      mobile_abstract.js
  6. 6
      twister_actions.js
  7. 20
      twister_following.js

39
css/style.css

@ -1324,6 +1324,45 @@ button.disabled:hover @@ -1324,6 +1324,45 @@ button.disabled:hover
margin-left: 0;
}
/*************************************
****************** FOLLOWING MODAL
**************************************/
.following-modal .modal-wrapper
{
width: 560px;
height: 470px;
margin: -200px 0 0 -280px;
overflow-x: hidden;
}
.following-modal .modal-content
{
padding: 15px;
overflow-y: auto;
}
.following-modal .modal-buttons
{
display: none;
}
.following-modal ol
{
margin: 5px;
}
.following-modal .open-profile-modal:hover
{
text-decoration: none;
}
.following-modal .open-profile-modal img
{
float: none;
}
.following-modal .open-profile-modal span
{
vertical-align: middle;
}
.following-modal .open-profile-modal span:hover
{
text-decoration: underline;
}
/*************************************
****************** LOADER ************
**************************************/
.postboard-loading

27
following.html

@ -346,7 +346,7 @@ @@ -346,7 +346,7 @@
</div>
<ul class="module profile-data">
<li><a href="#"><span class="posts-count">&nbsp;</span>Posts</a></li>
<li><a href="#"><span class="following-count">&nbsp;</span>Following</a></li>
<li><a href="#" class="open-following-modal"><span class="following-count">&nbsp;</span>Following</a></li>
<li><a href="#"><span class="followers-count">&nbsp;</span>Followers</a></li>
</ul>
<button class="follow" href="#">Follow</button>
@ -391,6 +391,31 @@ @@ -391,6 +391,31 @@
</div>
<!-- MODAL DE HASHTAGS END -->
<!-- MODAL DE FOLLOWING -->
<div id="following-modal-template">
<!-- ÁREA DE PROFILE PHOTO INIT -->
<h2>All users publicly followed by <span class="following-screen-name">@<b></b></span></h2>
<!-- ÁREA DE PROFILE END -->
<!-- ÁREA DE FOLLOWING INIT -->
<ol class="following-list">
<li id="following-by-user-template" style="display: none;">
<div class="mini-following-info" data-screen-name="">
<a href="#" class="open-profile-modal">
<img class="mini-profile-photo" src="img/grayed_avatar_placeholder_24.png" alt="user-photo"/>
<span class="mini-following-name">Fulano da Silva</span>
<span class="mini-screen-name">@
<b class="following-screen-name"></b>
</span>
</a>
</div>
</li>
</ol>
<!-- ÁREA DE FOLLOWERS END -->
</div>
<!-- MODAL DE FOLLOWING END -->
</div>
<!-- TEMPLATES END -->

26
home.html

@ -353,7 +353,7 @@ @@ -353,7 +353,7 @@
</div>
<ul class="module profile-data">
<li><a href="#"><span class="posts-count">&nbsp;</span>Posts</a></li>
<li><a href="#"><span class="following-count">&nbsp;</span>Following</a></li>
<li><a href="#" class="open-following-modal"><span class="following-count">&nbsp;</span>Following</a></li>
<li><a href="#"><span class="followers-count">&nbsp;</span>Followers</a></li>
</ul>
<button class="follow" href="#">Follow</button>
@ -398,6 +398,30 @@ @@ -398,6 +398,30 @@
</div>
<!-- MODAL DE HASHTAGS END -->
<!-- MODAL DE FOLLOWING -->
<div id="following-modal-template">
<!-- ÁREA DE PROFILE PHOTO INIT -->
<h2>All users publicly followed by <span class="following-screen-name">@<b></b></span></h2>
<!-- ÁREA DE PROFILE END -->
<!-- ÁREA DE FOLLOWING INIT -->
<ol class="following-list">
<li id="following-by-user-template" style="display: none;">
<div class="mini-following-info" data-screen-name="">
<a href="#" class="open-profile-modal">
<img class="mini-profile-photo" src="img/grayed_avatar_placeholder_24.png" alt="user-photo"/>
<span class="mini-following-name">Fulano da Silva</span>
<span class="mini-screen-name">@
<b class="following-screen-name"></b>
</span>
</a>
</div>
</li>
</ol>
<!-- ÁREA DE FOLLOWERS END -->
</div>
<!-- MODAL DE FOLLOWING END -->
</div>
<!-- TEMPLATES END -->

29
interface_common.js

@ -100,7 +100,7 @@ function timeSincePost(t) { @@ -100,7 +100,7 @@ function timeSincePost(t) {
}
//
// Profile, mentions and hashtag modal
// Profile, mentions, hashtag, and following modal
// -----------------------------------
function newProfileModal(username) {
@ -198,6 +198,32 @@ function openMentionsModal(e) @@ -198,6 +198,32 @@ function openMentionsModal(e)
resetMentionsCount();
}
function newFollowingModal(username) {
var followingModalContent = $( "#following-modal-template" ).children().clone(true);
updateFollowingData(followingModalContent, username);
return followingModalContent;
}
function openFollowingModal(e)
{
e.stopPropagation();
e.preventDefault();
var $this = $( this );
var username = $.MAL.followingUrlToUser( $this.attr("href") );
var followingModalClass = "following-modal";
openModal( followingModalClass );
var followingModalContent = newFollowingModal( username );
followingModalContent.appendTo("." +followingModalClass + " .modal-content");
//título do modal
$( "."+followingModalClass + " h3" ).text( "Followed by " + username );
}
//
// Post actions, submit, count characters
// --------------------------------------
@ -438,5 +464,6 @@ function initInterfaceCommon() { @@ -438,5 +464,6 @@ function initInterfaceCommon() {
$( ".open-profile-modal").bind( "click", openProfileModal );
$( ".open-hashtag-modal").bind( "click", openHashtagModal );
$( ".open-following-modal").bind( "click", openFollowingModal );
$( ".userMenu-connections a").bind( "click", openMentionsModal );
}

17
mobile_abstract.js

@ -147,6 +147,15 @@ var MAL = function() @@ -147,6 +147,15 @@ var MAL = function()
return "";
}
this.followingUrlToUser = function(url) {
var dummyUrl = this.isFollowingUrl("");
var urlIdx = url.indexOf(dummyUrl);
if( urlIdx >= 0 )
return url.substr(urlIdx + dummyUrl.length);
else
return "";
}
this.mentionsUrl = function(username) {
if( $.hasOwnProperty("mobile") ) {
return "#mentions?user=" + username;
@ -170,6 +179,14 @@ var MAL = function() @@ -170,6 +179,14 @@ var MAL = function()
return "#dmchat?user=" + username;
}
}
this.isFollowingUrl = function(username) {
if( $.hasOwnProperty("mobile") ) {
return "#following?user=" + username;
} else {
return "#following?user=" + username;
}
}
this.followUrl = function(username) {
if( $.hasOwnProperty("mobile") ) {

6
twister_actions.js

@ -174,10 +174,16 @@ function updateProfileData(profileModalContent, username) { @@ -174,10 +174,16 @@ function updateProfileData(profileModalContent, username) {
getPostsCount( username, profileModalContent.find(".posts-count") );
getFollowers( username, profileModalContent.find(".followers-count") );
getNumFollowing( username, profileModalContent.find(".following-count") );
profileModalContent.find(".following-count").parent().attr("href", $.MAL.isFollowingUrl(username));
requestPostRecursively(profileModalContent.find(".postboard-posts"),username,"status",10);
}
function updateFollowingData(followingModalContent, username) {
followingModalContent.find(".following-screen-name b").text(username);
loadFollowingIntoList( username, $(followingModalContent[1]) );
}
function clearHashtagProcessed() {
_hashtagProcessedMap = {};

20
twister_following.js

@ -83,6 +83,26 @@ function getNumFollowing( username, item ) { @@ -83,6 +83,26 @@ function getNumFollowing( username, item ) {
}, null);
}
function loadFollowingIntoList( username, html_list ) {
loadFollowingFromDht( username, 1, [], 0,
function(args, following, seqNum) {
html_list.html("");
$.each(following, function(i, following_user){
var following_user_li = $( "#following-by-user-template" ).children().clone(true);
// link follower to profile page
$(following_user_li.children()[0]).attr("data-screen-name", following_user);
$(following_user_li.children()[0]).attr("href", $.MAL.userUrl(following_user));
following_user_li.find(".following-screen-name b").text(following_user);
getAvatar( following_user, following_user_li.find(".mini-profile-photo") );
getFullname( following_user, following_user_li.find(".mini-following-name") );
html_list.append( following_user_li );
});
}, null);
}
// load following list from localStorage and then from the dht resource
function loadFollowing(cbFunc, cbArg) {
loadFollowingFromStorage();

Loading…
Cancel
Save