Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #7394 from borjasalguero/bug_826085

[Bug 826085 ][B2G] [SMS] Contacts : SMS message deleted when choosing contact for sea...
  • Loading branch information...
commit 92ed2a2f7a4b7d3965de841822174d180fbff2f8 2 parents 6eaab8f + f903089
Francisco Borja Salguero Castellano authored
View
2  apps/sms/index.html
@@ -90,7 +90,7 @@ <h1 id="list-edit-title" data-l10n-id="editMode">Edit mode</h1>
<section id="thread-messages" class="panel" role="region">
<header class="view-header regular-header">
- <a href="#thread-list" role="link">
+ <a role="link" id="go-to-threadlist">
<span class="icon icon-back"></span>
</a>
<menu type="toolbar">
View
47 apps/sms/js/sms.js
@@ -663,6 +663,11 @@ var ThreadUI = {
return this.contactInput = document.getElementById('receiver-input');
},
+ get backButton() {
+ delete this.backButton;
+ return this.backButton = document.getElementById('go-to-threadlist');
+ },
+
get clearButton() {
delete this.clearButton;
return this.clearButton = document.getElementById('clear-search');
@@ -751,7 +756,8 @@ var ThreadUI = {
event.target.classList.remove('active');
}
);
-
+ this.backButton.addEventListener('click',
+ this.onBackAction.bind(this));
this.pickButton.addEventListener('click', this.pickContact.bind(this));
this.selectAllButton.addEventListener('click',
this.selectAllMessages.bind(this));
@@ -772,6 +778,18 @@ var ThreadUI = {
this.sendForm.addEventListener('submit', this);
},
+ onBackAction: function thui_onBackAction() {
+ if (ThreadUI.input.value.length == 0) {
+ window.location.hash = '#thread-list';
+ return;
+ }
+ var response = window.confirm(_('discard-sms'));
+ if (response) {
+ ThreadUI.cleanFields(true);
+ window.location.hash = '#thread-list';
+ }
+ },
+
enableSend: function thui_enableSend() {
if (this.input.value.length > 0) {
this.updateCounter();
@@ -1170,12 +1188,25 @@ var ThreadUI = {
}
},
- cleanFields: function thui_cleanFields() {
- this.sendButton.disabled = true;
- this.sendButton.dataset.counter = '';
- this.contactInput.value = '';
- this.input.value = '';
- this.updateInputHeight();
+ cleanFields: function thui_cleanFields(forceClean) {
+ var self = this;
+ var clean = function clean() {
+ self.input.value = '';
+ self.sendButton.disabled = true;
+ self.sendButton.dataset.counter = '';
+ self.contactInput.value = '';
+ self.updateInputHeight();
+ };
+ if (window.location.hash == this.previousHash ||
+ this.previousHash == '#new') {
+ if (forceClean) {
+ clean();
+ }
+ } else {
+ clean();
+ }
+ this.enableSend();
+ this.previousHash = window.location.hash;
},
sendMessage: function thui_sendMessage(resendText) {
@@ -1204,7 +1235,7 @@ var ThreadUI = {
}
}
// Clean fields (this lock any repeated click in 'send' button)
- this.cleanFields();
+ this.cleanFields(true);
// Retrieve normalized phone number
// TODO Remove with
View
1  apps/sms/locales/sms.en-US.properties
@@ -43,6 +43,7 @@ carrier-unknown = Carrier unknown
no-results = No results returned
# Modal Dialogs
+discard-sms = Are you sure you want to discard this message?
resend-confirmation = The message could not be sent. Try again?
deleteMessages-confirmation = Delete selected messages?
deleteThreads-confirmation2 = Delete selected message threads?
Please sign in to comment.
Something went wrong with that request. Please try again.