Use toggle() to hide the poll creator

This commit is contained in:
Jonne Haß 2014-05-24 21:40:48 +02:00
parent 77133a4062
commit e6348aa705
2 changed files with 5 additions and 3 deletions

View file

@ -202,7 +202,7 @@ app.views.Publisher = Backbone.View.extend({
}, },
togglePollCreator: function(){ togglePollCreator: function(){
this.view_poll_creator.$el.toggleClass('active'); this.view_poll_creator.$el.toggle();
this.el_input.focus(); this.el_input.focus();
}, },
@ -419,9 +419,9 @@ app.views.Publisher = Backbone.View.extend({
var onlyWhitespaces = ($.trim(this.el_input.val()) === ''), var onlyWhitespaces = ($.trim(this.el_input.val()) === ''),
isPhotoAttached = (this.el_photozone.children().length > 0), isPhotoAttached = (this.el_photozone.children().length > 0),
isValidPoll = this.view_poll_creator.isValidPoll(); isValidPoll = this.view_poll_creator.isValidPoll();
// show poll errors // show poll errors
this.view_poll_creator.validatePoll(); this.view_poll_creator.validatePoll();
return (!onlyWhitespaces || isPhotoAttached) && isValidPoll && !this.disabled; return (!onlyWhitespaces || isPhotoAttached) && isValidPoll && !this.disabled;
}, },

View file

@ -150,6 +150,8 @@ describe("app.views.Publisher", function() {
}); });
it("disables submitting", function() { it("disables submitting", function() {
this.view.togglePollCreator();
this.view.setText('TESTING'); this.view.setText('TESTING');
expect(this.view.el_submit.prop('disabled')).toBeFalsy(); expect(this.view.el_submit.prop('disabled')).toBeFalsy();
expect(this.view.el_preview.prop('disabled')).toBeFalsy(); expect(this.view.el_preview.prop('disabled')).toBeFalsy();