Merge branch '559-posting-empty-messages' of https://github.com/grzuy/diaspora into sharebutton
This commit is contained in:
commit
ba439b9413
2 changed files with 67 additions and 1 deletions
|
|
@ -12,6 +12,7 @@ var Publisher = {
|
||||||
open: function(){
|
open: function(){
|
||||||
Publisher.form().removeClass('closed');
|
Publisher.form().removeClass('closed');
|
||||||
Publisher.form().find("textarea").css('min-height', '42px');
|
Publisher.form().find("textarea").css('min-height', '42px');
|
||||||
|
Publisher.determineSubmitAvailability();
|
||||||
},
|
},
|
||||||
cachedForm : false,
|
cachedForm : false,
|
||||||
form: function(){
|
form: function(){
|
||||||
|
|
@ -27,6 +28,13 @@ var Publisher = {
|
||||||
}
|
}
|
||||||
return Publisher.cachedInput;
|
return Publisher.cachedInput;
|
||||||
},
|
},
|
||||||
|
cachedSubmit : false,
|
||||||
|
submit: function(){
|
||||||
|
if(!Publisher.cachedSubmit){
|
||||||
|
Publisher.cachedSubmit = Publisher.form().find('#status_message_submit');
|
||||||
|
}
|
||||||
|
return Publisher.cachedSubmit;
|
||||||
|
},
|
||||||
|
|
||||||
cachedHiddenInput : false,
|
cachedHiddenInput : false,
|
||||||
hiddenInput: function(){
|
hiddenInput: function(){
|
||||||
|
|
@ -36,6 +44,14 @@ var Publisher = {
|
||||||
return Publisher.cachedHiddenInput;
|
return Publisher.cachedHiddenInput;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
cachedSubmit : false,
|
||||||
|
submit: function(){
|
||||||
|
if(!Publisher.cachedSubmit){
|
||||||
|
Publisher.cachedSubmit = Publisher.form().find('#status_message_submit');
|
||||||
|
}
|
||||||
|
return Publisher.cachedSubmit;
|
||||||
|
},
|
||||||
|
|
||||||
autocompletion: {
|
autocompletion: {
|
||||||
options : function(){return {
|
options : function(){return {
|
||||||
minChars : 1,
|
minChars : 1,
|
||||||
|
|
@ -184,6 +200,7 @@ var Publisher = {
|
||||||
|
|
||||||
keyUpHandler : function(event){
|
keyUpHandler : function(event){
|
||||||
Publisher.autocompletion.repopulateHiddenInput();
|
Publisher.autocompletion.repopulateHiddenInput();
|
||||||
|
Publisher.determineSubmitAvailability();
|
||||||
},
|
},
|
||||||
|
|
||||||
keyDownHandler : function(event){
|
keyDownHandler : function(event){
|
||||||
|
|
@ -252,6 +269,15 @@ var Publisher = {
|
||||||
Publisher.oldInputContent = Publisher.input().val();
|
Publisher.oldInputContent = Publisher.input().val();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
determineSubmitAvailability: function(){
|
||||||
|
var onlyWhitespaces = (Publisher.input().val().trim() == '');
|
||||||
|
var isSubmitDisabled = Publisher.submit().attr('disabled');
|
||||||
|
if (onlyWhitespaces && !isSubmitDisabled) {
|
||||||
|
Publisher.submit().attr('disabled', true);
|
||||||
|
} else if (!onlyWhitespaces && isSubmitDisabled) {
|
||||||
|
Publisher.submit().removeAttr('disabled');
|
||||||
|
}
|
||||||
|
},
|
||||||
clear: function(){
|
clear: function(){
|
||||||
this.autocompletion.mentionList.clear();
|
this.autocompletion.mentionList.clear();
|
||||||
$("#photodropzone").find('li').remove();
|
$("#photodropzone").find('li').remove();
|
||||||
|
|
@ -261,6 +287,7 @@ var Publisher = {
|
||||||
Publisher.cachedForm = false;
|
Publisher.cachedForm = false;
|
||||||
Publisher.cachedInput = false;
|
Publisher.cachedInput = false;
|
||||||
Publisher.cachedHiddenInput = false;
|
Publisher.cachedHiddenInput = false;
|
||||||
|
Publisher.cachedSubmit = false;
|
||||||
$("div.public_toggle input").live("click", function(evt) {
|
$("div.public_toggle input").live("click", function(evt) {
|
||||||
$("#publisher_service_icons").toggleClass("dim");
|
$("#publisher_service_icons").toggleClass("dim");
|
||||||
if ($(this).attr('checked') == true) {
|
if ($(this).attr('checked') == true) {
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,11 @@ describe("Publisher", function() {
|
||||||
Publisher.open();
|
Publisher.open();
|
||||||
expect(Publisher.form().hasClass('closed')).toBeFalsy();
|
expect(Publisher.form().hasClass('closed')).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
it("disables the share button", function() {
|
||||||
|
expect(Publisher.submit().attr('disabled')).toBeFalsy();
|
||||||
|
Publisher.open();
|
||||||
|
expect(Publisher.submit().attr('disabled')).toBeTruthy();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
describe("close", function() {
|
describe("close", function() {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
|
|
@ -212,7 +217,41 @@ describe("Publisher", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("keyUpHandler", function(){
|
||||||
|
var input;
|
||||||
|
var submit;
|
||||||
|
beforeEach(function(){
|
||||||
|
spec.loadFixture('aspects_index');
|
||||||
|
Publisher.initialize();
|
||||||
|
input = Publisher.input();
|
||||||
|
submit = Publisher.submit();
|
||||||
|
Publisher.open();
|
||||||
|
});
|
||||||
|
it("keep the share button disabled when adding only whitespaces", function(){
|
||||||
|
expect(submit.attr('disabled')).toBeTruthy();
|
||||||
|
input.val(' ');
|
||||||
|
input.keyup();
|
||||||
|
expect(submit.attr('disabled')).toBeTruthy();
|
||||||
|
});
|
||||||
|
it("enable the share button when adding non-whitespace characters", function(){
|
||||||
|
expect(submit.attr('disabled')).toBeTruthy();
|
||||||
|
input.val('some text');
|
||||||
|
input.keyup();
|
||||||
|
expect(submit.attr('disabled')).toBeFalsy();
|
||||||
|
});
|
||||||
|
it("should toggle share button disable/enable when playing with input", function(){
|
||||||
|
expect(submit.attr('disabled')).toBeTruthy();
|
||||||
|
input.val(' ');
|
||||||
|
input.keyup();
|
||||||
|
expect(submit.attr('disabled')).toBeTruthy();
|
||||||
|
input.val('text');
|
||||||
|
input.keyup();
|
||||||
|
expect(submit.attr('disabled')).toBeFalsy();
|
||||||
|
input.val('');
|
||||||
|
input.keyup();
|
||||||
|
expect(submit.attr('disabled')).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("addMentionToInput", function(){
|
describe("addMentionToInput", function(){
|
||||||
var func;
|
var func;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue