646 |
646 |
647 |
647 |
648 var lastPos, lastDuration, lastTopics; |
648 var lastPos, lastDuration, lastTopics; |
649 |
649 |
650 var tweetTemplate = _.template( |
650 var tweetTemplate = _.template( |
651 '<li class="tweet" data-timestamp="<%= timestamp %>" data-topic-id="<%= topic.topic %>">' |
651 '<li class="tweet" data-timestamp="<%= timestamp %>" data-topic-id="<%= topic.topic %>" data-tweet-id="<%- data.id_str %>">' |
652 + '<% if (show_link) { %><a href="#" data-user-id="<%- data.from_user_id %>"><% } %>' |
652 + '<% if (show_link) { %><a href="#" data-user-id="<%- data.from_user_id %>"><% } %>' |
653 + '<img src="<%- data.profile_image_url %>" /><% if (show_link) { %></a><% } %>' |
653 + '<img src="<%- data.profile_image_url %>" /><% if (show_link) { %></a><% } %>' |
654 + '<p><% if (show_link) { %><a href="#" data-user-id="<%- data.from_user_id %>"><% } %>' |
654 + '<p><% if (show_link) { %><a href="#" data-user-id="<%- data.from_user_id %>"><% } %>' |
655 + '@<%- data.from_user_name %>:<% if (show_link) { %></a><% } %> <%= htext %></p>' |
655 + '@<%- data.from_user_name %>:<% if (show_link) { %></a><% } %> <%= htext %></p>' |
656 + '<% if (show_time) { %><p><%- secsToString(timestamp) %></p><% } %>' |
656 + '<% if (show_time) { %><p><%- secsToString(timestamp) %></p><% } %>' |
1089 htext: _(tweet.text).escape(), |
1089 htext: _(tweet.text).escape(), |
1090 show_link: false, |
1090 show_link: false, |
1091 show_time: true |
1091 show_time: true |
1092 }); |
1092 }); |
1093 },""); |
1093 },""); |
1094 $(".user-tweets").show(); |
1094 var utl = $(".user-tweets-list"); |
1095 $(".user-tweets-list").html(html); |
1095 utl.html(html); |
|
1096 var currentTweetLi = $(".user-tweets-list").find(".tweet[data-tweet-id='" + currentTweet + "']"); |
|
1097 if (currentTweetLi.length) { |
|
1098 currentTweetLi.css("margin-left",0); |
|
1099 utl.scrollTop(currentTweetLi.offset().top - utl.offset().top + utl.scrollTop() - utl.height() / 2 + currentTweetLi.height() / 2); |
|
1100 } |
|
1101 |
1096 $(".user-name").text(tweets[0].from_user_name); |
1102 $(".user-name").text(tweets[0].from_user_name); |
1097 } |
1103 } |
|
1104 |
|
1105 var currentTweet = 0; |
1098 |
1106 |
1099 $(".play-localtweets").on("click", "li a", function() { |
1107 $(".play-localtweets").on("click", "li a", function() { |
1100 var userid = $(this).attr("data-user-id"); |
1108 var userid = $(this).attr("data-user-id"); |
1101 $(".user-tweets").show(); |
1109 currentTweet = $(this).parents("li.tweet").attr("data-tweet-id"); |
|
1110 $(".user-tweets").css({ |
|
1111 display: "block", |
|
1112 left: $(window).width() + 20 |
|
1113 }).animate({ |
|
1114 left: "420px" |
|
1115 }); |
1102 $(".user-tweets-list").html("<li class='loading'>Chargement en cours</li>"); |
1116 $(".user-tweets-list").html("<li class='loading'>Chargement en cours</li>"); |
1103 $(".user-name").text($(this).parents("li.tweet").find("p a").text().replace(/(^@|:$)/g,"")); |
1117 $(".user-name").text($(this).parents("li.tweet").find("p a").text().replace(/(^@|:$)/g,"")); |
1104 if (!usersCache[userid]) { |
1118 if (!usersCache[userid]) { |
1105 usersCache[userid] = []; |
1119 usersCache[userid] = []; |
1106 $.getJSON( |
1120 $.getJSON( |
1144 $(this).removeClass("locked").attr("title", "Coupler la lecture et la visualisation"); |
1158 $(this).removeClass("locked").attr("title", "Coupler la lecture et la visualisation"); |
1145 } |
1159 } |
1146 return false; |
1160 return false; |
1147 }); |
1161 }); |
1148 |
1162 |
1149 $(window).on("resize", throttledShowLocal); |
1163 $(window).on("resize", function() { |
|
1164 throttledShowLocal |
|
1165 $(".user-tweets").width($(window).width()-480); |
|
1166 }); |
1150 |
1167 |
1151 $(".close-user-tweets").click(function() { |
1168 $(".close-user-tweets").click(function() { |
1152 currentTweetTc = -1; |
1169 currentTweetTc = -1; |
1153 $(".user-tweets").hide(); |
1170 $(".user-tweets").animate({ |
|
1171 left: $(window).width() + 20 |
|
1172 }, function(){ |
|
1173 $(this).hide(); |
|
1174 }); |
1154 return false; |
1175 return false; |
1155 }) |
1176 }) |
1156 |
1177 |
|
1178 $(".user-tweets").width($(window).width()-480); |
1157 checkOrGoNext(); |
1179 checkOrGoNext(); |
1158 } |
1180 } |
1159 |
1181 |
1160 var data = { topics: [] }, |
1182 var data = { topics: [] }, |
1161 colorset = ["#E41A1C", "#377EB8", "#4DAF4A", "#984EA3", "#FF7F00", "#A65628", "#F781BF"]; |
1183 colorset = ["#E41A1C", "#377EB8", "#4DAF4A", "#984EA3", "#FF7F00", "#A65628", "#F781BF"]; |