Skip to content
Extraits de code Groupes Projets
Valider 8039ab31 rédigé par Dan Hansen's avatar Dan Hansen
Parcourir les fichiers

publisher is now a hot widget

parent d533f46c
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -48,7 +48,7 @@ javascripts:
- public/javascripts/aspect-edit.js
- public/javascripts/contact-list.js
home:
- public/javascripts/publisher.js
- public/javascripts/widgets/publisher.js
- public/javascripts/aspect-filters.js
- public/javascripts/contact-list.js
people:
......
/* 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);
})();
/* Copyright (c) 2010, Diaspora Inc. This file is
* licensed under the Affero General Public License version 3 or later. See
* the COPYRIGHT file.
*/
* licensed under the Affero General Public License version 3 or later. See
* the COPYRIGHT file.
*/
describe("Publisher", function() {
describe("initialize", function(){
it("calls updateHiddenField", function(){
spec.loadFixture('aspects_index_prefill');
spyOn(Publisher, 'updateHiddenField');
Publisher.initialize();
expect(Publisher.updateHiddenField).toHaveBeenCalled();
});
describe("Diaspora", function() {
describe("widgets", function() {
describe("publisher", function() {
describe("start", function() {
it("calls updateHiddenField", function() {
spec.loadFixture('aspects_index_prefill');
spyOn(Diaspora.widgets.publisher, 'updateHiddenField');
Diaspora.widgets.publisher.start();
expect(Diaspora.widgets.publisher.updateHiddenField).toHaveBeenCalled();
});
it("attaches updateHiddenField to the change handler on fake_message", function(){
spec.loadFixture('aspects_index_prefill');
spyOn(Publisher, 'updateHiddenField');
Publisher.initialize();
Publisher.form().find('#status_message_fake_message').change();
expect(Publisher.updateHiddenField.mostRecentCall.args[0].type).toBe('change');
});
it("attaches updateHiddenField to the change handler on fake_message", function() {
spec.loadFixture('aspects_index_prefill');
spyOn(Diaspora.widgets.publisher, 'updateHiddenField');
Diaspora.widgets.publisher.start();
Diaspora.widgets.publisher.$fakeMessage.change();
expect(Diaspora.widgets.publisher.updateHiddenField.mostRecentCall.args[0].type).toBe('change');
});
it("calls close when it does not have text", function(){
spec.loadFixture('aspects_index');
spyOn(Publisher, 'close');
Publisher.initialize();
expect(Publisher.close).toHaveBeenCalled();
});
it("calls toggle when it does not have text", function() {
spec.loadFixture('aspects_index');
spyOn(Diaspora.widgets.publisher, 'toggle');
Diaspora.widgets.publisher.start();
expect(Diaspora.widgets.publisher.toggle).toHaveBeenCalled();
});
it("does not call close when there is prefilled text", function(){
spec.loadFixture('aspects_index_prefill');
spyOn(Publisher, 'close');
Publisher.initialize();
expect(Publisher.close).wasNotCalled();
it("does not call toggle when there is prefilled text", function() {
spec.loadFixture('aspects_index_prefill');
spyOn(Diaspora.widgets.publisher, 'toggle');
Diaspora.widgets.publisher.start();
expect(Diaspora.widgets.publisher.toggle).not.toHaveBeenCalled();
});
});
describe("open", function() {
beforeEach(function() {
spec.loadFixture('aspects_index');
Publisher.initialize();
});
it("removes the closed class", function() {
expect(Publisher.form().hasClass('closed')).toBeTruthy();
Publisher.open();
expect(Publisher.form().hasClass('closed')).toBeFalsy();
describe("toggle", function() {
beforeEach(function() {
spec.loadFixture('aspects_index');
Diaspora.widgets.publisher.start();
});
it("shows the options_and_submit div", function() {
expect(Publisher.form().find(".options_and_submit:visible").length).toBe(0);
Publisher.open();
expect(Publisher.form().find(".options_and_submit:visible").length).toBe(1);
});
});
describe("close", function() {
beforeEach(function() {
spec.loadFixture('aspects_index_prefill');
Publisher.initialize();
});
it("adds the closed class", function() {
expect(Publisher.form().hasClass('closed')).toBeFalsy();
Publisher.close();
expect(Publisher.form().hasClass('closed')).toBeTruthy();
it("toggles the closed class", function() {
expect(Diaspora.widgets.publisher.$publisher.hasClass('closed')).toBeTruthy();
Diaspora.widgets.publisher.toggle();
expect(Diaspora.widgets.publisher.$publisher.hasClass('closed')).toBeFalsy();
expect(Diaspora.widgets.publisher.$publisher.hasClass('closed')).toBeFalsy();
Diaspora.widgets.publisher.toggle();
expect(Diaspora.widgets.publisher.$publisher.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);
it("toggles the options_and_submit div", function() {
expect(Diaspora.widgets.publisher.$publisher.find(".options_and_submit").is(":visible")).toBeFalsy();
Diaspora.widgets.publisher.toggle();
expect(Diaspora.widgets.publisher.$publisher.find(".options_and_submit").is(":visible")).toBeTruthy();
expect(Diaspora.widgets.publisher.$publisher.find(".options_and_submit").is(":visible")).toBeTruthy();
Diaspora.widgets.publisher.toggle();
expect(Diaspora.widgets.publisher.$publisher.find(".options_and_submit").is(":visible")).toBeFalsy();
});
});
describe("updateHiddenField", function(){
beforeEach(function(){
spec.loadFixture('aspects_index_prefill');
});
it("copies the value of fake_message to message",function(){
Publisher.updateHiddenField();
expect(Publisher.form().find('#status_message_message').val()).toBe(
Publisher.form().find('#status_message_fake_message').val());
describe("updateHiddenField", function() {
beforeEach(function() {
spec.loadFixture('aspects_index_prefill');
});
it("copies the value of fake_message to message", function() {
Diaspora.widgets.publisher.updateHiddenField();
expect(Diaspora.widgets.publisher.$realMessage.val()).toBe(
Diaspora.widgets.publisher.$fakeMessage.val());
});
});
});
});
});
});
\ No newline at end of file
......@@ -24,12 +24,12 @@ src_files:
- public/javascripts/widgets/embedder.js
- public/javascripts/widgets/i18n.js
- public/javascripts/widgets/timeago.js
- public/javascripts/widgets/publisher.js
- public/javascripts/mobile.js
- public/javascripts/aspect-edit.js
- public/javascripts/aspect-contacts.js
- public/javascripts/web-socket-receiver.js
- public/javascripts/view.js
- public/javascripts/publisher.js
- public/javascripts/stream.js
- public/javascripts/validation.js
- public/javascripts/rails.js
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter