first changes to 1 window on Linux

This commit is contained in:
jeena 2013-03-24 19:31:04 +01:00
parent 682c60df2d
commit c6220b1dc1
25 changed files with 346 additions and 69 deletions

View file

@ -14,15 +14,15 @@ function(HostApp, Core, Paths, URI) {
this.action = "conversation";
document.body.innerHTML = "";
this.body = document.createElement("ol");
this.body.className = this.action;
document.body.appendChild(this.body);
document.getElementById("content").appendChild(this.body);
this.hide();
}
Conversation.prototype = Object.create(Core.prototype);
Conversation.addStatus = function(status) {

View file

@ -17,11 +17,13 @@ function(HostApp, Timeline, URI, Paths) {
this.action = "mentions";
this.body.className = this.action;
this.hide();
}
Mentions.prototype = Object.create(Timeline.prototype);
Mentions.prototype.newStatus = function(statuses) {
Timeline.prototype.newStatus.call(this, statuses);

View file

@ -14,12 +14,25 @@ function(HostApp, Core, Paths, URI) {
this.action = "profile";
document.body.innerHTML = "";
this.container = document.createElement("div");
document.getElementById("content").appendChild(this.container);
this.initProfileTemplate();
this.hide();
this.showProfileForEntity(); // Load users profile on start
}
Profile.prototype = Object.create(Core.prototype);
Profile.prototype.show = function() {
$(this.container).show();
}
Profile.prototype.hide = function() {
$(this.container).hide();
};
Profile.prototype.showList = function(list) {
$(this.body).hide();
@ -30,6 +43,10 @@ function(HostApp, Core, Paths, URI) {
Profile.prototype.showProfileForEntity = function(entity) {
if (!entity) {
entity = HostApp.stringForKey("entity");
};
this.clear();
this.entity = entity;
this.following = null;
@ -46,8 +63,9 @@ function(HostApp, Core, Paths, URI) {
var _this = this;
var header = document.createElement("header");
header.className = "profile"
document.body.appendChild(header);
header.className = "profile";
this.container.appendChild(header);
this.profile_template = {
avatar: document.createElement("img"),
@ -139,15 +157,15 @@ function(HostApp, Core, Paths, URI) {
this.body = document.createElement("ol");
this.body.className = this.action;
document.body.appendChild(this.body);
this.container.appendChild(this.body);
this.followingsBody = document.createElement("ol");
this.followingsBody.className = this.action + " followings";
document.body.appendChild(this.followingsBody);
this.container.appendChild(this.followingsBody);
this.followersBody = document.createElement("ol");
this.followersBody.className = this.action + " folloewds";
document.body.appendChild(this.followersBody);
this.container.appendChild(this.followersBody);
}

View file

@ -0,0 +1,182 @@
define([
"helper/HostApp",
"helper/Paths",
"helper/Cache"
],
function(HostApp, Paths, Cache) {
function Sidebar() {
this.cache = new Cache();
this.body = document.createElement("ul");
this.body.class = "sidebar";
var _this = this;
this.menu = {};
this.menu.user = this.createItem("User", function() { _this.onEntity() }, "img/sidebar/user.png", "img/sidebar/user.png");
this.menu.timeline = this.createItem("Timeline", function() { _this.onTimeline() }, "img/sidebar/timeline.png", "img/sidebar/timeline_active.png", true);
this.menu.mentions = this.createItem("Mentions", function() { _this.onMentions() }, "img/sidebar/mentions.png", "img/sidebar/mentions_active.png");
this.menu.conversation = this.createItem("Conversation", function() { _this.onConversation() }, "img/sidebar/conversation.png", "img/sidebar/conversation_active.png");
this.menu.entityProfile = this.createItem("Profile", function() { _this.onEntityProfile() }, "img/sidebar/profile.png", "img/sidebar/profile_active.png");
this.menu.search = this.createItem("Search", function() { _this.onSearch() }, "img/sidebar/search.png", "img/sidebar/search_active.png")
this.body.appendChild(this.menu.user);
this.body.appendChild(this.menu.timeline);
this.body.appendChild(this.menu.mentions);
this.body.appendChild(this.menu.conversation);
this.body.appendChild(this.menu.entityProfile);
this.body.appendChild(this.menu.search);
document.getElementById("sidebar").appendChild(this.body);
this.setEntityAvatar();
}
Sidebar.prototype.createItem = function(name, callback, src_inactive, src_active, active) {
var li = document.createElement("li");
li.className = "sidebar-" + name.toLowerCase();
li.active = false;
li.title = name;
li.name = name;
var a = document.createElement("a");
a.href = "#";
a.onclick = callback;
var img = document.createElement("img");
img.src = active ? src_active : src_inactive;
img.src_inactive = src_inactive;
img.src_active = src_active;
img.alt = name;
a.appendChild(img);
li.appendChild(a);
return li;
}
Sidebar.prototype.setEntityAvatar = function() {
var entity = HostApp.stringForKey("entity");
this.menu.user.title = entity;
var img = this.menu.user.getElementsByTagName("img")[0];
var _this = this;
var profile_callback = function(p) {
var basic = p["https://tent.io/types/info/basic/v0.1.0"];
if (p && basic) {
if(basic.name) {
_this.menu.user.title = basic.name;
}
if(basic.avatar_url) {
img.onerror = function() {
img.src = "img/sidebar/user.png";
img.src_inactive = img.src;
img.src_active = img.src;
}
img.src = basic.avatar_url;
img.src_inactive = basic.avatar_url;
img.src_active = basic.avatar_url;
}
}
}
var p = this.cache.profiles.getItem(entity);
if (p && p != "null") {
profile_callback(p);
} else {
Paths.findProfileURL(entity, function(profile_url) {
if (profile_url) {
Paths.getURL(profile_url, "GET", function(resp) {
var p = JSON.parse(resp.responseText);
if (p && p != "null") {
_this.cache.profiles.setItem(entity, p);
profile_callback(p);
}
}, null, false); // do not send auth-headers
}
});
}
}
Sidebar.prototype.showContentFor = function(active_part, active_li) {
// Show active content
var parts = [
bungloo.timeline,
bungloo.mentions,
bungloo.conversation,
bungloo.entityProfile,
bungloo.search
];
for (var i = 0; i < parts.length; i++) {
if (parts[i] != active_part && parts[i] != null) {
parts[i].hide();
}
}
active_part.show();
// Show active icon
for(var li in this.menu) {
if (this.menu[li] != active_part) {
var img = this.menu[li].getElementsByTagName("img")[0];
img.src = img.src_inactive;
}
}
var img = active_li.getElementsByTagName("img")[0];
img.src = img.src_active;
}
Sidebar.prototype.onEntity = function() {
bungloo.entityProfile.showProfileForEntity();
this.onEntityProfile();
}
Sidebar.prototype.onTimeline = function() {
this.showContentFor(bungloo.timeline, this.menu.timeline);
}
Sidebar.prototype.onMentions = function() {
this.showContentFor(bungloo.mentions, this.menu.mentions);
bungloo.mentions.setAllMentionsRead();
}
Sidebar.prototype.onConversation = function() {
this.showContentFor(bungloo.conversation, this.menu.conversation);
}
Sidebar.prototype.onEntityProfile = function() {
this.showContentFor(bungloo.entityProfile, this.menu.entityProfile);
}
Sidebar.prototype.onSearch = function() {
debug("Search not implemented yet")
}
return Sidebar;
});

View file

@ -14,7 +14,7 @@ function(Core, Paths, HostApp, URI) {
this.action = "timeline";
this.reload_blocked = false;
this.max_length = 200;
this.max_length = 20;
this.timeout = 10 * 1000; // every 10 seconds
this.since_id = null;
this.since_id_entity = null;
@ -22,7 +22,7 @@ function(Core, Paths, HostApp, URI) {
this.body = document.createElement("ol");
this.body.className = this.action;
document.body.appendChild(this.body);
document.getElementById("content").appendChild(this.body);
var _this = this;
this.reloadIntervall = setInterval(function() { _this.getNewData() }, this.timeout);
@ -31,7 +31,7 @@ function(Core, Paths, HostApp, URI) {
}
Timeline.prototype = Object.create(Core.prototype);
Timeline.prototype.newStatus = function(statuses) {