This commit is contained in:
Dan Hansen 2011-08-21 20:45:40 -05:00
parent 3ed50cab94
commit 545611fffa
25 changed files with 100 additions and 66 deletions

View file

@ -102,7 +102,7 @@ end
group :test do group :test do
gem 'mysql2', '0.2.6' gem 'mysql2', '0.2.6'
gem 'pg' #gem 'pg'
gem 'factory_girl_rails' gem 'factory_girl_rails'
gem 'fixture_builder', '0.2.2' gem 'fixture_builder', '0.2.2'
gem 'selenium-webdriver', '2.4' gem 'selenium-webdriver', '2.4'

View file

@ -319,7 +319,6 @@ GEM
oa-openid (= 0.2.6) oa-openid (= 0.2.6)
open4 (1.1.0) open4 (1.1.0)
orm_adapter (0.0.5) orm_adapter (0.0.5)
pg (0.11.0)
polyglot (0.3.2) polyglot (0.3.2)
pyu-ruby-sasl (0.0.3.3) pyu-ruby-sasl (0.0.3.3)
rack (1.2.3) rack (1.2.3)
@ -499,7 +498,6 @@ DEPENDENCIES
oauth2-provider (= 0.0.16) oauth2-provider (= 0.0.16)
ohai (= 0.5.8) ohai (= 0.5.8)
omniauth (= 0.2.6) omniauth (= 0.2.6)
pg
rails (= 3.0.9) rails (= 3.0.9)
rails-i18n rails-i18n
rcov rcov

View file

@ -1,5 +1,10 @@
WebSocketReceiver.processComment("<%= @comment.post.guid %>", WebSocketReceiver.processComment("<%= @comment.post.guid %>",
"<%= @comment.guid%>", "<%= @comment.guid%>",
"<%= escape_javascript(render(:partial => 'comments/comment', :locals => { :comment => @comment, :person => current_user.person}))%>", "<%= escape_javascript(render(:partial => 'comments/comment', :locals => { :comment => @comment, :person => current_user.person}))%>",
false); false);
Diaspora.page
.stream
.streamElements["<%= @comment.post.guid %>"]
.commentStream
.instantiateCommentWidgets();

View file

@ -4,4 +4,4 @@ $(".stream_element", "#conversation_inbox").removeClass('selected');
$(".stream_element[data-guid='<%= @conversation.id %>']", "#conversation_inbox").addClass('selected'); $(".stream_element[data-guid='<%= @conversation.id %>']", "#conversation_inbox").addClass('selected');
$(".stream_element[data-guid='<%= @conversation.id %>']", "#conversation_inbox").find(".unread_message_count").remove() $(".stream_element[data-guid='<%= @conversation.id %>']", "#conversation_inbox").find(".unread_message_count").remove()
Diaspora.Page.timeAgo.updateTimeAgo(); Diaspora.page.timeAgo.updateTimeAgo();

View file

@ -42,6 +42,7 @@ javascripts:
- public/javascripts/widgets/stream-element.js - public/javascripts/widgets/stream-element.js
- public/javascripts/widgets/comment-stream.js - public/javascripts/widgets/comment-stream.js
- public/javascripts/widgets/comment-toggler.js - public/javascripts/widgets/comment-toggler.js
- public/javascripts/widgets/comment-form.js
- public/javascripts/widgets/comment.js - public/javascripts/widgets/comment.js
- public/javascripts/widgets/likes.js - public/javascripts/widgets/likes.js
- public/javascripts/widgets/hovercard.js - public/javascripts/widgets/hovercard.js
@ -50,6 +51,7 @@ javascripts:
- public/javascripts/view.js - public/javascripts/view.js
- public/javascripts/stream.js - public/javascripts/stream.js
- public/javascripts/content-updater.js - public/javascripts/content-updater.js
- public/javascripts/aspects-dropdown.js
- public/javascripts/contact-edit.js - public/javascripts/contact-edit.js
- public/javascripts/contact-list.js - public/javascripts/contact-list.js
- public/javascripts/aspect-sorting.js - public/javascripts/aspect-sorting.js

View file

@ -394,7 +394,8 @@ ActiveRecord::Schema.define(:version => 20110818212541) do
t.string "language" t.string "language"
t.string "email", :default => "", :null => false t.string "email", :default => "", :null => false
t.string "encrypted_password", :limit => 128, :default => "", :null => false t.string "encrypted_password", :limit => 128, :default => "", :null => false
t.string "invitation_token", :limit => 60 t.string "password_salt", :default => "", :null => false
t.string "invitation_token", :limit => 20
t.datetime "invitation_sent_at" t.datetime "invitation_sent_at"
t.string "reset_password_token" t.string "reset_password_token"
t.string "remember_token" t.string "remember_token"

View file

@ -152,7 +152,7 @@ var AspectFilters = {
// reinit listeners on stream // reinit listeners on stream
photozone.html(photos_html); photozone.html(photos_html);
Diaspora.Page.publish("stream/reloaded"); Diaspora.page.publish("stream/reloaded");
// fade contents back in // fade contents back in
AspectFilters.fadeIn(); AspectFilters.fadeIn();

View file

@ -9,25 +9,24 @@ var AspectsDropdown = {
if (number == 0) { if (number == 0) {
button.removeClass(inAspectClass); button.removeClass(inAspectClass);
replacement = Diaspora.widgets.i18n.t("aspect_dropdown.toggle.zero"); replacement = Diaspora.I18n.t("aspect_dropdown.toggle.zero");
}else if (number == 1) { }else if (number == 1) {
button.addClass(inAspectClass); button.addClass(inAspectClass);
replacement = dropdown.find(".selected").first().text(); replacement = dropdown.find(".selected").first().text();
}else if (number < 3) { }else if (number < 3) {
replacement = Diaspora.widgets.i18n.t('aspect_dropdown.toggle.few', { count: number.toString()}) replacement = Diaspora.I18n.t('aspect_dropdown.toggle.few', { count: number.toString()})
}else if (number > 3) { }else if (number > 3) {
replacement = Diaspora.widgets.i18n.t('aspect_dropdown.toggle.many', { count: number.toString()}) replacement = Diaspora.I18n.t('aspect_dropdown.toggle.many', { count: number.toString()})
}else { }else {
//the above one are a tautology, but I want to have them here once for once we figure out a neat way i18n them //the above one are a tautology, but I want to have them here once for once we figure out a neat way i18n them
replacement = Diaspora.widgets.i18n.t('aspect_dropdown.toggle.other', { count: number.toString()}) replacement = Diaspora.I18n.t('aspect_dropdown.toggle.other', { count: number.toString()})
} }
button.html(replacement + ' ▼'); button.html(replacement + ' ▼');
}, },
toggleCheckbox: toggleCheckbox: function(check) {
function(check){ check.toggleClass('selected');
check.toggleClass('selected'); }
},
}; };

View file

@ -5,7 +5,7 @@
var ContactEdit = { var ContactEdit = {
init: function(){ init: function(){
$.extend(ContactEdit, AspectsDropdown); $.extend(ContactEdit, AspectsDropdown);
$('.dropdown.aspect_membership .dropdown_list > li, .dropdown.inviter .dropdown_list >li').live('click', function(evt){ $('.dropdown.aspect_membership .dropdown_list > li, .dropdown.inviter .dropdown_list > li').live('click', function(evt){
ContactEdit.processClick($(this), evt); ContactEdit.processClick($(this), evt);
}); });
// $('.button.resend').live('click', function(evt){ // $('.button.resend').live('click', function(evt){
@ -24,19 +24,17 @@ var ContactEdit = {
if (number == 0) { if (number == 0) {
button.removeClass("in_aspects"); button.removeClass("in_aspects");
replacement = Diaspora.widgets.i18n.t("aspect_dropdown.toggle.zero"); replacement = Diaspora.I18n.t("aspect_dropdown.toggle.zero");
}else if (number == 1) { }else if (number == 1) {
button.addClass("in_aspects"); button.addClass("in_aspects");
replacement = dropdown.find(".selected").first().text(); replacement = dropdown.find(".selected").first().text();
}else if (number < 3) { }else if (number < 3) {
replacement = Diaspora.widgets.i18n.t('aspect_dropdown.toggle.few', { count: number.toString()}) replacement = Diaspora.I18n.t('aspect_dropdown.toggle.few', { count: number.toString()})
}else if (number > 3) { }else if (number > 3) {
replacement = Diaspora.widgets.i18n.t('aspect_dropdown.toggle.many', { count: number.toString()}) replacement = Diaspora.I18n.t('aspect_dropdown.toggle.many', { count: number.toString()})
}else { }else {
//the above one are a tautology, but I want to have them here once for once we figure out a neat way i18n them //the above one are a tautology, but I want to have them here once for once we figure out a neat way i18n them
replacement = Diaspora.widgets.i18n.t('aspect_dropdown.toggle.other', { count: number.toString()}) replacement = Diaspora.I18n.t('aspect_dropdown.toggle.other', { count: number.toString()})
}
else {
ContactEdit.toggleAspectMembership(li, evt); ContactEdit.toggleAspectMembership(li, evt);
} }
}, },
@ -61,6 +59,18 @@ var ContactEdit = {
} }
}, },
processClick: function(li, evt){
var dropdown = li.closest('.dropdown');
li.addClass('loading');
if (dropdown.hasClass('inviter')) {
ContactEdit.inviteFriend(li, evt);
dropdown.html('sending, please wait...');
}
else {
ContactEdit.toggleAspectMembership(li, evt);
}
},
toggleAspectMembership: function(li, evt) { toggleAspectMembership: function(li, evt) {
var button = li.find('.button'); var button = li.find('.button');
if(button.hasClass('disabled') || li.hasClass('newItem')){ return; } if(button.hasClass('disabled') || li.hasClass('newItem')){ return; }
@ -73,7 +83,8 @@ var ContactEdit = {
"person_id": li.parent().data("person_id"), "person_id": li.parent().data("person_id"),
"_method": (selected) ? "DELETE" : "POST" "_method": (selected) ? "DELETE" : "POST"
}, function(aspectMembership) { }, function(aspectMembership) {
ContactEdit.toggleCheckbox(checkbox); li.removeClass("loading");
ContactEdit.toggleCheckbox(li);
ContactEdit.updateNumber(li.closest(".dropdown_list"), li.parent().data("person_id"), aspectMembership.aspect_ids.length); ContactEdit.updateNumber(li.closest(".dropdown_list"), li.parent().data("person_id"), aspectMembership.aspect_ids.length);
Diaspora.page.publish("aspectDropdown/updated", [li.parent().data("person_id"), li.parents(".dropdown").parent(".right").html()]); Diaspora.page.publish("aspectDropdown/updated", [li.parent().data("person_id"), li.parents(".dropdown").parent(".right").html()]);

View file

@ -64,7 +64,10 @@
$(function() { $(function() {
if(typeof Diaspora.Pages[Diaspora.Page] === "undefined") { throw new Error("Page " + Diaspora.Page + " does not exist"); } if (typeof Diaspora.Pages[Diaspora.Page] === "undefined") {
Diaspora.page = Diaspora.EventBroker.extend(Diaspora.BaseWidget);
return;
}
var Page = Diaspora.Pages[Diaspora.Page]; var Page = Diaspora.Pages[Diaspora.Page];
$.extend(Page.prototype, Diaspora.EventBroker.extend(Diaspora.BaseWidget)); $.extend(Page.prototype, Diaspora.EventBroker.extend(Diaspora.BaseWidget));

View file

@ -7,7 +7,7 @@ $(document).ready(function(){
$('a.conversation').live('click', function(){ $('a.conversation').live('click', function(){
$.getScript(this.href, function() { $.getScript(this.href, function() {
Diaspora.Page.directionDetector.updateBinds(); Diaspora.page.directionDetector.updateBinds();
}); });
history.pushState(null, "", this.href); history.pushState(null, "", this.href);
@ -32,7 +32,7 @@ $(document).ready(function(){
$(window).bind("popstate", function(){ $(window).bind("popstate", function(){
if (location.href.match(/conversations\/\d+/) !== null) { if (location.href.match(/conversations\/\d+/) !== null) {
$.getScript(location.href, function() { $.getScript(location.href, function() {
Diaspora.Page.directionDetector.updateBinds(); Diaspora.page.directionDetector.updateBinds();
}); });
return false; return false;
} }

View file

@ -2,7 +2,7 @@ Diaspora.Pages.AspectsIndex = function() {
var self = this; var self = this;
this.subscribe("page/ready", function(evt, document) { this.subscribe("page/ready", function(evt, document) {
self.stream = self.instantiate("Stream", document.find("#main_stream")); self.stream = self.instantiate("Stream", document.find("#aspect_stream_container"));
self.header = self.instantiate("Header", document.find("header")); self.header = self.instantiate("Header", document.find("header"));
self.hoverCard = self.instantiate("HoverCard", document.find("#hovercard")); self.hoverCard = self.instantiate("HoverCard", document.find("#hovercard"));

View file

@ -3,5 +3,6 @@ Diaspora.Pages.ConversationsIndex = function() {
this.subscribe("page/ready", function(evt, body) { this.subscribe("page/ready", function(evt, body) {
self.header = self.instantiate("Header", body.find("header")); self.header = self.instantiate("Header", body.find("header"));
self.directionDetector = self.instantiate("DirectionDetector");
}); });
}; };

View file

@ -0,0 +1,7 @@
Diaspora.Pages.UsersEdit = function() {
var self = this;
this.subscribe("page/ready", function(evt, body) {
self.header = self.instantiate("Header", body.find("header"));
});
};

View file

@ -3,20 +3,17 @@
var self = this; var self = this;
this.subscribe("widget/ready", function(evt, commentFormElement) { this.subscribe("widget/ready", function(evt, commentFormElement) {
$.extend({ $.extend(self, {
commentFormElement: commentFormElement commentFormElement: commentFormElement,
commentInput: commentFormElement.find("textarea")
}); });
self.commentFormElement.submit(self.submitComment); self.commentInput.focus(self.showCommentForm);
}); });
this.submitComment = function(evt) { this.showCommentForm = function() {
evt.preventDefault(); self.commentFormElement.addClass("open");
};
$.post(self.commentFormElement.attr("action"), self.commentFormElement.serialize(), function() {
});
}
}; };
Diaspora.Widgets.CommentForm = CommentForm; Diaspora.Widgets.CommentForm = CommentForm;

View file

@ -6,8 +6,7 @@
$.extend(self, { $.extend(self, {
commentStream: commentStream, commentStream: commentStream,
commentToggler: self.instantiate("CommentToggler", commentStream), commentToggler: self.instantiate("CommentToggler", commentStream),
commentForm: self.instantiate("CommentForm", commentStream.find(".new_comment_form")), comments: {}
comments: []
}); });
self.commentStream.delegate(".new_comment", "ajax:failure", function() { self.commentStream.delegate(".new_comment", "ajax:failure", function() {
@ -41,10 +40,10 @@
}); });
this.instantiateCommentWidgets = function() { this.instantiateCommentWidgets = function() {
self.comments = []; self.comments = {};
$.each(self.commentStream.find("li.comment"), function(index, element) { $.each(self.commentStream.find("li.comment"), function() {
self.comments.push(self.instantiate("Comment", $(element))); self.comments[this.id] = self.instantiate("Comment", $(this));
}); });
}; };
}; };

View file

@ -43,7 +43,7 @@
this.reInitialize = function() { this.reInitialize = function() {
$("#main_stream").infinitescroll("destroy"); $("#main_stream").infinitescroll("destroy");
self.trigger("widget/ready"); self.publish("widget/ready");
}; };
this.globalSubscribe("stream/reloaded", self.reInitialize, this); this.globalSubscribe("stream/reloaded", self.reInitialize, this);

View file

@ -80,7 +80,7 @@
url: "/notifications/" + notification.id, url: "/notifications/" + notification.id,
type: "PUT", type: "PUT",
success: function() { success: function() {
Diaspora.Page.notifications.decrementCount(); Diaspora.page.header.notifications.decrementCount();
} }
}); });
} }

View file

@ -6,6 +6,7 @@
self.postGuid = element.attr("id"); self.postGuid = element.attr("id");
$.extend(self, { $.extend(self, {
commentForm: self.instantiate("CommentForm", element.find("form.new_comment")),
commentStream: self.instantiate("CommentStream", element.find("ul.comments")), commentStream: self.instantiate("CommentStream", element.find("ul.comments")),
embedder: self.instantiate("Embedder", element.find("div.content")), embedder: self.instantiate("Embedder", element.find("div.content")),
likes: self.instantiate("Likes", element.find("div.likes_container")), likes: self.instantiate("Likes", element.find("div.likes_container")),

View file

@ -1,12 +1,20 @@
(function() { (function() {
var Stream = function() { var Stream = function() {
var self = this; var self = this;
this.streamElements = [];
this.subscribe("widget/ready", function(evt, element) { this.subscribe("widget/ready", function(evt, stream) {
$.each(element.find(".stream_element"), function(index, element) { $.extend(self, {
self.addPost($(element)); stream: $(stream),
streamElements: {}
}); });
$.each(self.stream.find(".stream_element"), function() {
self.addPost($(this));
});
});
this.globalSubscribe("stream/reloaded", function() {
self.publish("widget/ready", self.stream);
}); });
this.globalSubscribe("stream/post/added", function(evt, post) { this.globalSubscribe("stream/post/added", function(evt, post) {
@ -14,9 +22,7 @@
}); });
this.addPost = function(post) { this.addPost = function(post) {
self.streamElements.push( self.streamElements[post.attr("id")] = self.instantiate("StreamElement", post);
self.instantiate("StreamElement", post)
);
}; };
}; };

View file

@ -8,7 +8,7 @@
}); });
self.menuElement.click(self.toggleDropdown); self.menuElement.click(self.toggleDropdown);
self.menuElement.find("li a").slice(1, 3).click(function(evt) { evt.stopPropagation(); }); self.menuElement.find("li a").slice(1).click(function(evt) { evt.stopPropagation(); });
$(document.body).click(self.hideDropdown); $(document.body).click(self.hideDropdown);
}); });

View file

@ -2,9 +2,6 @@ describe("Diaspora.Alert", function() {
beforeEach(function() { beforeEach(function() {
spec.loadFixture("aspects_index"); spec.loadFixture("aspects_index");
Diaspora.page = new Diaspora.Pages.TestPage();
Diaspora.page.directionDetector = Diaspora.BaseWidget.instantiate("DirectionDetector");
$(document).trigger("close.facebox"); $(document).trigger("close.facebox");
}); });

View file

@ -3,10 +3,6 @@
* the COPYRIGHT file. * the COPYRIGHT file.
*/ */
Diaspora.Pages.TestPage = function() { };
Diaspora.Page = "TestPage";
describe("Diaspora", function() { describe("Diaspora", function() {
describe("EventBroker", function() { describe("EventBroker", function() {
describe("extend", function() { describe("extend", function() {

View file

@ -14,6 +14,20 @@ beforeEach(function() {
// NOTE Commented (as well as in afterEach) to keep the listeners from rails.js alive. // NOTE Commented (as well as in afterEach) to keep the listeners from rails.js alive.
//spec.clearLiveEventBindings(); //spec.clearLiveEventBindings();
jasmine.Clock.useMock(); jasmine.Clock.useMock();
Diaspora.Pages.TestPage = function() {
var self = this;
this.subscribe("page/ready", function() {
self.timeAgo = self.instantiate("TimeAgo", "abbr.timeago");
self.directionDetector = self.instantiate("DirectionDetector");
});
};
var Page = Diaspora.Pages["TestPage"];
$.extend(Page.prototype, Diaspora.EventBroker.extend(Diaspora.BaseWidget));
Diaspora.page = new Page();
Diaspora.page.publish("page/ready", [$(document.body)])
}); });
afterEach(function() { afterEach(function() {
@ -84,4 +98,5 @@ spec.retrieveFixture = function(fixtureName) {
}; };
spec.loadFixtureCount = 0; spec.loadFixtureCount = 0;
spec.cachedFixtures = {}; spec.cachedFixtures = {};

View file

@ -8,10 +8,6 @@ describe("Stream", function() {
jasmine.Clock.useMock(); jasmine.Clock.useMock();
spec.loadFixture('aspects_index_with_posts'); spec.loadFixture('aspects_index_with_posts');
Diaspora.I18n.locale = { }; Diaspora.I18n.locale = { };
Diaspora.page = new Diaspora.Pages.TestPage();
Diaspora.page.timeAgo = Diaspora.BaseWidget.instantiate("TimeAgo");
Diaspora.page.directionDetector = Diaspora.BaseWidget.instantiate("DirectionDetector");
}); });
describe("collapseText", function() { describe("collapseText", function() {