Revert "publisher is now a hot widget"

This reverts commit 8039ab312a.
This commit is contained in:
zhitomirskiyi 2011-02-05 15:24:20 -08:00
parent 4a925d192f
commit 59f0dca7c7
4 changed files with 74 additions and 140 deletions

View file

@ -48,7 +48,7 @@ javascripts:
- public/javascripts/aspect-edit.js - public/javascripts/aspect-edit.js
- public/javascripts/contact-list.js - public/javascripts/contact-list.js
home: home:
- public/javascripts/widgets/publisher.js - public/javascripts/publisher.js
- public/javascripts/aspect-filters.js - public/javascripts/aspect-filters.js
- public/javascripts/contact-list.js - public/javascripts/contact-list.js
people: people:

View file

@ -1,68 +0,0 @@
/* Copyright (c) 2010, Diaspora Inc. This file is
* licensed under the Affero General Public License version 3 or later. See
* the COPYRIGHT file.
*/
(function() {
var Publisher = function() {
var self = this;
this.start = function() {
this.$publisher = $("#publisher");
this.$realMessage = this.$publisher.find("#status_message_message");
this.$fakeMessage = this.$publisher.find("#status_message_fake_message");
if(this.$fakeMessage.val() === "") {
this.toggle();
}
$("div.public_toggle input").live("click", function(evt) {
$("#publisher_service_icons").toggleClass("dim");
if (this.checked) {
$(".question_mark").click();
}
});
self
.$publisher
.find("textarea")
.focus(self.toggle)
.blur(self.toggle);
self
.$fakeMessage
.change(self.updateHiddenField);
self.updateHiddenField();
};
this.toggle = function() {
self
.$publisher
.toggleClass("closed")
.find(".options_and_submit")
.toggle(
!self.$publisher.hasClass("closed")
);
self
.$fakeMessage
.css("min-height", (self.$publisher.hasClass("closed"))
? ""
: "42px");
};
this.updateHiddenField = function() {
self
.$realMessage
.val(
self.$fakeMessage.val()
);
};
};
Diaspora.widgets.add("publisher", Publisher);
})();

View file

@ -3,77 +3,79 @@
* the COPYRIGHT file. * the COPYRIGHT file.
*/ */
describe("Diaspora", function() { describe("Publisher", function() {
describe("widgets", function() {
describe("publisher", function() { describe("initialize", function(){
describe("start", function() {
it("calls updateHiddenField", function(){ it("calls updateHiddenField", function(){
spec.loadFixture('aspects_index_prefill'); spec.loadFixture('aspects_index_prefill');
spyOn(Diaspora.widgets.publisher, 'updateHiddenField'); spyOn(Publisher, 'updateHiddenField');
Diaspora.widgets.publisher.start(); Publisher.initialize();
expect(Diaspora.widgets.publisher.updateHiddenField).toHaveBeenCalled(); expect(Publisher.updateHiddenField).toHaveBeenCalled();
}); });
it("attaches updateHiddenField to the change handler on fake_message", function(){ it("attaches updateHiddenField to the change handler on fake_message", function(){
spec.loadFixture('aspects_index_prefill'); spec.loadFixture('aspects_index_prefill');
spyOn(Diaspora.widgets.publisher, 'updateHiddenField'); spyOn(Publisher, 'updateHiddenField');
Diaspora.widgets.publisher.start(); Publisher.initialize();
Diaspora.widgets.publisher.$fakeMessage.change(); Publisher.form().find('#status_message_fake_message').change();
expect(Diaspora.widgets.publisher.updateHiddenField.mostRecentCall.args[0].type).toBe('change'); expect(Publisher.updateHiddenField.mostRecentCall.args[0].type).toBe('change');
}); });
it("calls toggle when it does not have text", function() { it("calls close when it does not have text", function(){
spec.loadFixture('aspects_index'); spec.loadFixture('aspects_index');
spyOn(Diaspora.widgets.publisher, 'toggle'); spyOn(Publisher, 'close');
Diaspora.widgets.publisher.start(); Publisher.initialize();
expect(Diaspora.widgets.publisher.toggle).toHaveBeenCalled(); expect(Publisher.close).toHaveBeenCalled();
}); });
it("does not call toggle when there is prefilled text", function() { it("does not call close when there is prefilled text", function(){
spec.loadFixture('aspects_index_prefill'); spec.loadFixture('aspects_index_prefill');
spyOn(Diaspora.widgets.publisher, 'toggle'); spyOn(Publisher, 'close');
Diaspora.widgets.publisher.start(); Publisher.initialize();
expect(Diaspora.widgets.publisher.toggle).not.toHaveBeenCalled(); expect(Publisher.close).wasNotCalled();
}); });
}); });
describe("toggle", function() { describe("open", function() {
beforeEach(function() { beforeEach(function() {
spec.loadFixture('aspects_index'); spec.loadFixture('aspects_index');
Diaspora.widgets.publisher.start(); Publisher.initialize();
}); });
it("toggles the closed class", function() { it("removes the closed class", function() {
expect(Diaspora.widgets.publisher.$publisher.hasClass('closed')).toBeTruthy(); expect(Publisher.form().hasClass('closed')).toBeTruthy();
Diaspora.widgets.publisher.toggle(); Publisher.open();
expect(Diaspora.widgets.publisher.$publisher.hasClass('closed')).toBeFalsy(); expect(Publisher.form().hasClass('closed')).toBeFalsy();
expect(Diaspora.widgets.publisher.$publisher.hasClass('closed')).toBeFalsy();
Diaspora.widgets.publisher.toggle();
expect(Diaspora.widgets.publisher.$publisher.hasClass('closed')).toBeTruthy;
}); });
it("shows the options_and_submit div", function() {
it("toggles the options_and_submit div", function() { expect(Publisher.form().find(".options_and_submit:visible").length).toBe(0);
expect(Diaspora.widgets.publisher.$publisher.find(".options_and_submit").is(":visible")).toBeFalsy(); Publisher.open();
Diaspora.widgets.publisher.toggle(); expect(Publisher.form().find(".options_and_submit:visible").length).toBe(1);
expect(Diaspora.widgets.publisher.$publisher.find(".options_and_submit").is(":visible")).toBeTruthy(); });
});
describe("close", function() {
expect(Diaspora.widgets.publisher.$publisher.find(".options_and_submit").is(":visible")).toBeTruthy(); beforeEach(function() {
Diaspora.widgets.publisher.toggle(); spec.loadFixture('aspects_index_prefill');
expect(Diaspora.widgets.publisher.$publisher.find(".options_and_submit").is(":visible")).toBeFalsy(); Publisher.initialize();
});
it("adds the closed class", function() {
expect(Publisher.form().hasClass('closed')).toBeFalsy();
Publisher.close();
expect(Publisher.form().hasClass('closed')).toBeTruthy();
});
it("hides the options_and_submit div", function() {
expect(Publisher.form().find(".options_and_submit:visible").length).toBe(1);
Publisher.close();
expect(Publisher.form().find(".options_and_submit:visible").length).toBe(0);
}); });
}); });
describe("updateHiddenField", function(){ describe("updateHiddenField", function(){
beforeEach(function(){ beforeEach(function(){
spec.loadFixture('aspects_index_prefill'); spec.loadFixture('aspects_index_prefill');
}); });
it("copies the value of fake_message to message",function(){ it("copies the value of fake_message to message",function(){
Diaspora.widgets.publisher.updateHiddenField(); Publisher.updateHiddenField();
expect(Diaspora.widgets.publisher.$realMessage.val()).toBe( expect(Publisher.form().find('#status_message_message').val()).toBe(
Diaspora.widgets.publisher.$fakeMessage.val()); Publisher.form().find('#status_message_fake_message').val());
});
});
}); });
}); });
}); });

View file

@ -24,12 +24,12 @@ src_files:
- public/javascripts/widgets/embedder.js - public/javascripts/widgets/embedder.js
- public/javascripts/widgets/i18n.js - public/javascripts/widgets/i18n.js
- public/javascripts/widgets/timeago.js - public/javascripts/widgets/timeago.js
- public/javascripts/widgets/publisher.js
- public/javascripts/mobile.js - public/javascripts/mobile.js
- public/javascripts/aspect-edit.js - public/javascripts/aspect-edit.js
- public/javascripts/aspect-contacts.js - public/javascripts/aspect-contacts.js
- public/javascripts/web-socket-receiver.js - public/javascripts/web-socket-receiver.js
- public/javascripts/view.js - public/javascripts/view.js
- public/javascripts/publisher.js
- public/javascripts/stream.js - public/javascripts/stream.js
- public/javascripts/validation.js - public/javascripts/validation.js
- public/javascripts/rails.js - public/javascripts/rails.js