summaryrefslogtreecommitdiff
path: root/web-ui
diff options
context:
space:
mode:
authorFolker Bernitt <fbernitt@thoughtworks.com>2015-03-24 10:47:39 +0100
committerFolker Bernitt <fbernitt@thoughtworks.com>2015-03-24 11:36:29 +0100
commita34d504758fff87f6827b0fe23887c08758975e0 (patch)
tree1d29252201904643ca9546b7dad0a0f20e94ce82 /web-ui
parent66963c9f30a29748b00dd9dc8c25e46523ea2b88 (diff)
Smaller refactoring of send button code.
- Issue #189
Diffstat (limited to 'web-ui')
-rw-r--r--web-ui/app/js/mail_view/ui/recipients/recipients_input.js2
-rw-r--r--web-ui/app/js/mail_view/ui/send_button.js24
-rw-r--r--web-ui/app/js/page/events.js4
-rw-r--r--web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js12
-rw-r--r--web-ui/test/spec/mail_view/ui/send_button.spec.js18
5 files changed, 30 insertions, 30 deletions
diff --git a/web-ui/app/js/mail_view/ui/recipients/recipients_input.js b/web-ui/app/js/mail_view/ui/recipients/recipients_input.js
index 459c8b24..012d7fb9 100644
--- a/web-ui/app/js/mail_view/ui/recipients/recipients_input.js
+++ b/web-ui/app/js/mail_view/ui/recipients/recipients_input.js
@@ -136,7 +136,7 @@ define([
};
this.warnSendButtonOfInputState = function () {
- var toTrigger = _.isEmpty(this.$node.val()) ? events.ui.recipients.inputHasNoMail : events.ui.recipients.inputHasMail;
+ var toTrigger = _.isEmpty(this.$node.val()) ? events.ui.recipients.inputFieldIsEmpty : events.ui.recipients.inputFieldHasCharacters;
this.trigger(document, toTrigger, { name: this.attr.name });
};
diff --git a/web-ui/app/js/mail_view/ui/send_button.js b/web-ui/app/js/mail_view/ui/send_button.js
index 3e8d0a23..c3adacf4 100644
--- a/web-ui/app/js/mail_view/ui/send_button.js
+++ b/web-ui/app/js/mail_view/ui/send_button.js
@@ -37,17 +37,17 @@ define([
this.$node.prop('disabled', true);
};
- this.atLeastOneFieldHasRecipients = function () {
+ this.atLeastOneInputFieldHasRecipients = function () {
return _.any(_.values(this.attr.recipients), function (e) { return !_.isEmpty(e); });
};
- this.atLeastOneInputHasMail = function () {
- return _.any(_.values(this.attr.inputHasMail), function (e) { return e === true; });
+ this.atLeastOneInputFieldHasCharacters = function () {
+ return _.any(_.values(this.attr.inputFieldHasCharacters), function (e) { return e === true; });
};
this.updateButton = function () {
if (this.attr.sendingInProgress === false) {
- if (this.atLeastOneInputHasMail() || this.atLeastOneFieldHasRecipients()) {
+ if (this.atLeastOneInputFieldHasCharacters() || this.atLeastOneInputFieldHasRecipients()) {
this.enableButton();
} else {
this.disableButton();
@@ -55,19 +55,19 @@ define([
}
};
- this.inputHasNoMail = function (ev, data) {
- this.attr.inputHasMail[data.name] = false;
+ this.inputFieldIsEmpty = function (ev, data) {
+ this.attr.inputFieldHasCharacters[data.name] = false;
this.updateButton();
};
- this.inputHasMail = function (ev, data) {
- this.attr.inputHasMail[data.name] = true;
+ this.inputFieldHasCharacters = function (ev, data) {
+ this.attr.inputFieldHasCharacters[data.name] = true;
this.updateButton();
};
this.updateRecipientsForField = function (ev, data) {
this.attr.recipients[data.recipientsName] = data.newRecipients;
- this.attr.inputHasMail[data.recipientsName] = false;
+ this.attr.inputFieldHasCharacters[data.recipientsName] = false;
this.updateButton();
};
@@ -95,11 +95,11 @@ define([
this.after('initialize', function () {
this.attr.recipients = {};
- this.attr.inputHasMail = {};
+ this.attr.inputFieldHasCharacters = {};
this.resetButton()
- this.on(document, events.ui.recipients.inputHasMail, this.inputHasMail);
- this.on(document, events.ui.recipients.inputHasNoMail, this.inputHasNoMail);
+ this.on(document, events.ui.recipients.inputFieldHasCharacters, this.inputFieldHasCharacters);
+ this.on(document, events.ui.recipients.inputFieldIsEmpty, this.inputFieldIsEmpty);
this.on(document, events.ui.recipients.updated, this.updateRecipientsForField);
this.on(this.$node, 'click', this.updateRecipientsAndSendMail);
diff --git a/web-ui/app/js/page/events.js b/web-ui/app/js/page/events.js
index ff9ed10a..f7e626f8 100644
--- a/web-ui/app/js/page/events.js
+++ b/web-ui/app/js/page/events.js
@@ -85,8 +85,8 @@ define(function () {
selectLast: 'ui:recipients:selectLast',
unselectAll: 'ui:recipients:unselectAll',
addressesExist: 'ui:recipients:addressesExist',
- inputHasMail: 'ui:recipients:inputHasMail',
- inputHasNoMail: 'ui:recipients:inputHasNoMail',
+ inputFieldHasCharacters: 'ui:recipients:inputFieldHasCharacters',
+ inputFieldIsEmpty: 'ui:recipients:inputFieldIsEmpty',
doCompleteInput: 'ui:recipients:doCompleteInput',
doCompleteRecipients: 'ui:recipients:doCompleteRecipients'
}
diff --git a/web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js b/web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js
index 70ae9301..24d57953 100644
--- a/web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js
+++ b/web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js
@@ -105,22 +105,22 @@ describeComponent('mail_view/ui/recipients/recipients_input',function () {
});
describe('on keyup', function () {
- it('triggers inputHasNoMail if input is empty', function () {
- var inputHasNoMailEvent = spyOnEvent(document, Pixelated.events.ui.recipients.inputHasNoMail);
+ it('triggers inputFieldIsEmpty if input is empty', function () {
+ var inputFieldIsEmptyEvent = spyOnEvent(document, Pixelated.events.ui.recipients.inputFieldIsEmpty);
this.$node.val('');
this.$node.trigger('keyup');
- expect(inputHasNoMailEvent).toHaveBeenTriggeredOn(document);
+ expect(inputFieldIsEmptyEvent).toHaveBeenTriggeredOn(document);
});
- it('triggers inputHasMail if input is not empty', function () {
- var inputHasMailEvent = spyOnEvent(document, Pixelated.events.ui.recipients.inputHasMail);
+ it('triggers inputFieldHasCharacters if input is not empty', function () {
+ var inputFieldHasCharactersEvent = spyOnEvent(document, Pixelated.events.ui.recipients.inputFieldHasCharacters);
this.$node.val('lalala');
this.$node.trigger('keyup');
- expect(inputHasMailEvent).toHaveBeenTriggeredOn(document, { name: 'to' });
+ expect(inputFieldHasCharactersEvent).toHaveBeenTriggeredOn(document, { name: 'to' });
});
});
diff --git a/web-ui/test/spec/mail_view/ui/send_button.spec.js b/web-ui/test/spec/mail_view/ui/send_button.spec.js
index dca8f02c..ff1eecde 100644
--- a/web-ui/test/spec/mail_view/ui/send_button.spec.js
+++ b/web-ui/test/spec/mail_view/ui/send_button.spec.js
@@ -14,8 +14,8 @@ describeComponent('mail_view/ui/send_button', function () {
this.$node.prop('disabled', true);
});
- it('gets enabled in a inputHasMail event', function () {
- $(document).trigger(Pixelated.events.ui.recipients.inputHasMail, { name: 'to' });
+ it('gets enabled in a inputFieldHasCharacters event', function () {
+ $(document).trigger(Pixelated.events.ui.recipients.inputFieldHasCharacters, { name: 'to' });
expect(this.$node).not.toBeDisabled();
});
@@ -28,20 +28,20 @@ describeComponent('mail_view/ui/send_button', function () {
});
describe('multiple events', function () {
- it('gets enabled and remains enabled when a inputHasMail is followed by a recipients:updated with NO new recipients', function () {
+ it('gets enabled and remains enabled when a inputFieldHasCharacters is followed by a recipients:updated with NO new recipients', function () {
this.$node.prop('disabled', true);
- $(document).trigger(Pixelated.events.ui.recipients.inputHasMail, { name: 'to' });
+ $(document).trigger(Pixelated.events.ui.recipients.inputFieldHasCharacters, { name: 'to' });
$(document).trigger(Pixelated.events.ui.recipients.updated, { newRecipients: [] });
expect(this.$node).not.toBeDisabled();
});
- it('gets enabled and remains enabled when a recipients:updated with recipients is followed by a inputHasNoMail', function () {
+ it('gets enabled and remains enabled when a recipients:updated with recipients is followed by a inputFieldIsEmpty', function () {
this.$node.prop('disabled', true);
$(document).trigger(Pixelated.events.ui.recipients.updated, { newRecipients: ['a@b.c']});
- $(document).trigger(Pixelated.events.ui.recipients.inputHasNoMail, { name: 'to' });
+ $(document).trigger(Pixelated.events.ui.recipients.inputFieldIsEmpty, { name: 'to' });
expect(this.$node).not.toBeDisabled();
});
@@ -52,8 +52,8 @@ describeComponent('mail_view/ui/send_button', function () {
this.$node.prop('disabled', false);
});
- it('gets disabled in a inputHasNoMail', function () {
- $(document).trigger(Pixelated.events.ui.recipients.inputHasNoMail, { name: 'to' });
+ it('gets disabled in a inputFieldIsEmpty', function () {
+ $(document).trigger(Pixelated.events.ui.recipients.inputFieldIsEmpty, { name: 'to' });
expect(this.$node).toBeDisabled();
});
@@ -65,7 +65,7 @@ describeComponent('mail_view/ui/send_button', function () {
});
it('gets disabled if recipients:updated with invalid email', function () {
- $(document).trigger(Pixelated.events.ui.recipients.inputHasMail, { name: 'to' });
+ $(document).trigger(Pixelated.events.ui.recipients.inputFieldHasCharacters, { name: 'to' });
$(document).trigger(Pixelated.events.ui.recipients.updated, { newRecipients: ['InvalidEmail']});
expect(this.$node).not.toBeDisabled();