MDL-54687 core_message: added SELECTORS and EVENTS variables to tidy JS

This commit is contained in:
Mark Nelson
2016-10-07 16:26:40 +08:00
parent a4a804b8f9
commit 2a4bbaa3ff
6 changed files with 132 additions and 74 deletions
+48
View File
@@ -35,6 +35,54 @@ define(['jquery', 'core_message/message_area_actions', 'core_message/message_are
this._init();
}
/** @type {Object} The list of selectors for the message area. */
Messagearea.prototype.SELECTORS = {
BLOCKTIME: "[data-region='blocktime']",
CANCELDELETEMESSAGES: "[data-action='cancel-delete-messages']",
CONTACT: "[data-region='contact']",
CONTACTS: "[data-region='contacts'][data-region-content='contacts']",
CONVERSATIONS: "[data-region='contacts'][data-region-content='conversations']",
DELETECONVERSATIONCHECKBOX: "[data-region='delete-conversation-checkbox']",
DELETEMESSAGES: "[data-action='delete-messages']",
DELETEMESSAGECHECKBOX: "[data-region='delete-message-checkbox']",
LASTMESSAGE: '.lastmessage',
MESSAGE: "[data-region='message']",
MESSAGES: "[data-region='messages']",
MESSAGESAREA: "[data-region='messages-area']",
MESSAGERESPONSE: "[data-region='response']",
PROFILE: "[data-region='profile']",
PROFILEADDCONTACT: "[data-action='profile-add-contact']",
PROFILEBLOCKCONTACT: "[data-action='profile-block-contact']",
PROFILEREMOVECONTACT: "[data-action='profile-remove-contact']",
PROFILESENDMESSAGE: "[data-action='profile-send-message']",
PROFILEUNBLOCKCONTACT: "[data-action='profile-unblock-contact']",
PROFILEVIEW: "[data-action='profile-view']",
SENDMESSAGE: "[data-action='send-message']",
SENDMESSAGETEXT: "[data-region='send-message-txt']",
VIEWCONTACTS: "[data-action='contacts-view']",
VIEWCONVERSATION: "[data-action='view-contact-msg']",
VIEWCONVERSATIONS: "[data-action='conversations-view']",
VIEWPROFILE: "[data-action='view-contact-profile']"
};
/** @type {Object} The list of events triggered in the message area. */
Messagearea.prototype.EVENTS = {
CANCELDELETEMESSAGES: 'cancel-delete-messages',
CHOOSEMESSAGESTODELETE: 'choose-messages-to-delete',
CONTACTADDED: 'contact-added',
CONTACTBLOCKED: 'contact-blocked',
CONTACTREMOVED: 'contact-removed',
CONTACTSELECTED: 'contact-selected',
CONTACTSSELECTED: 'contacts-selected',
CONTACTUNBLOCKED: 'contact-unblocked',
CONVERSATIONDELETED: 'conversation-deleted',
CONVERSATIONSELECTED: 'conversation-selected',
CONVERSATIONSSELECTED: 'conversations-selected',
MESSAGESDELETED: 'messages-deleted',
MESSAGESENT: 'message-sent',
SENDMESSAGE: 'message-send'
};
/** @type {jQuery} The jQuery node for the page region containing the message area. */
Messagearea.prototype.node = null;
+1 -1
View File
@@ -39,7 +39,7 @@ define([], function() {
* Handles when we have selected to delete messages.
*/
Actions.prototype.chooseMessagesToDelete = function() {
this.messageArea.trigger('choose-messages-to-delete');
this.messageArea.trigger(this.messageArea.EVENTS.CHOOSEMESSAGESTODELETE);
};
return Actions;
+27 -24
View File
@@ -43,17 +43,20 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification'],
* @private
*/
Contacts.prototype._init = function() {
this.messageArea.onCustomEvent('conversations-selected', this._viewConversations.bind(this));
this.messageArea.onCustomEvent('contacts-selected', this._viewContacts.bind(this));
this.messageArea.onCustomEvent('messages-deleted', this._deleteConversations.bind(this));
this.messageArea.onCustomEvent('message-send', this._viewConversationsWithUserSelected.bind(this));
this.messageArea.onCustomEvent('message-sent', this._viewConversationsWithUserSelected.bind(this));
this.messageArea.onCustomEvent('contact-removed', this._removeContact.bind(this));
this.messageArea.onCustomEvent('contact-added', this._viewContacts.bind(this));
this.messageArea.onCustomEvent('choose-messages-to-delete', this._chooseConversationsToDelete.bind(this));
this.messageArea.onCustomEvent('cancel-messages-deleted', this._cancelConversationsToDelete.bind(this));
this.messageArea.onDelegateEvent('click', "[data-action='view-contact-msg']", this._viewConversation.bind(this));
this.messageArea.onDelegateEvent('click', "[data-action='view-contact-profile']", this._viewContact.bind(this));
this.messageArea.onCustomEvent(this.messageArea.EVENTS.CONVERSATIONSSELECTED, this._viewConversations.bind(this));
this.messageArea.onCustomEvent(this.messageArea.EVENTS.CONTACTSSELECTED, this._viewContacts.bind(this));
this.messageArea.onCustomEvent(this.messageArea.EVENTS.MESSAGESDELETED, this._deleteConversations.bind(this));
this.messageArea.onCustomEvent(this.messageArea.EVENTS.SENDMESSAGE, this._viewConversationsWithUserSelected.bind(this));
this.messageArea.onCustomEvent(this.messageArea.EVENTS.MESSAGESENT, this._viewConversationsWithUserSelected.bind(this));
this.messageArea.onCustomEvent(this.messageArea.EVENTS.CONTACTREMOVED, this._removeContact.bind(this));
this.messageArea.onCustomEvent(this.messageArea.EVENTS.CONTACTADDED, this._viewContacts.bind(this));
this.messageArea.onCustomEvent(this.messageArea.EVENTS.CHOOSEMESSAGESTODELETE,
this._chooseConversationsToDelete.bind(this));
this.messageArea.onCustomEvent(this.messageArea.EVENTS.CANCELDELETEMESSAGES,
this._cancelConversationsToDelete.bind(this));
this.messageArea.onDelegateEvent('click', this.messageArea.SELECTORS.VIEWCONVERSATION,
this._viewConversation.bind(this));
this.messageArea.onDelegateEvent('click', this.messageArea.SELECTORS.VIEWPROFILE, this._viewContact.bind(this));
};
/**
@@ -115,7 +118,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification'],
var userid = $(event.currentTarget).data('userid');
this._setSelectedUser(userid);
this.messageArea.trigger('conversation-selected', userid);
this.messageArea.trigger(this.messageArea.EVENTS.CONVERSATIONSELECTED, userid);
};
/**
@@ -128,7 +131,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification'],
if (!this._isCurrentlyDeleting()) {
var userid = $(event.currentTarget).data('userid');
this._setSelectedUser(userid);
this.messageArea.trigger('contact-selected', userid);
this.messageArea.trigger(this.messageArea.EVENTS.CONTACTSELECTED, userid);
}
};
@@ -169,8 +172,8 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification'],
*/
Contacts.prototype._chooseConversationsToDelete = function() {
// Only show the checkboxes for the contact if we are also deleting messages.
if (this.messageArea.find("[data-region='delete-message-checkbox']").length !== 0) {
this.messageArea.find("[data-region='delete-conversation-checkbox']").show();
if (this.messageArea.find(this.messageArea.SELECTORS.DELETEMESSAGECHECKBOX).length !== 0) {
this.messageArea.find(this.messageArea.SELECTORS.DELETECONVERSATIONCHECKBOX).show();
}
};
@@ -181,9 +184,9 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification'],
*/
Contacts.prototype._cancelConversationsToDelete = function() {
// Uncheck all checkboxes.
this.messageArea.find("[data-region='delete-conversation-checkbox'] input:checked").removeAttr('checked');
this.messageArea.find(this.messageArea.SELECTORS.DELETECONVERSATIONCHECKBOX + " input:checked").removeAttr('checked');
// Hide the checkboxes.
this.messageArea.find("[data-region='delete-conversation-checkbox']").hide();
this.messageArea.find(this.messageArea.SELECTORS.DELETECONVERSATIONCHECKBOX).hide();
};
/**
@@ -194,13 +197,13 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification'],
* @private
*/
Contacts.prototype._deleteConversations = function(event, userid) {
var checkboxes = this.messageArea.find("[data-region='delete-conversation-checkbox'] input:checked");
var checkboxes = this.messageArea.find(this.messageArea.SELECTORS.DELETECONVERSATIONCHECKBOX + " input:checked");
var requests = [];
// Go through all the checked checkboxes and prepare them for deletion.
checkboxes.each(function(id, element) {
var node = $(element);
var otheruserid = node.parents("[data-region='contact']").data('userid');
var otheruserid = node.parents(this.messageArea.SELECTORS.CONTACT).data('userid');
requests.push({
methodname: 'core_message_delete_conversation',
args: {
@@ -214,7 +217,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification'],
ajax.call(requests)[requests.length - 1].then(function() {
for (var i = 0; i <= requests.length - 1; i++) {
// Trigger conversation deleted events.
this.messageArea.trigger('conversation-deleted', requests[i].args.otheruserid);
this.messageArea.trigger(this.messageArea.EVENTS.CONVERSATIONDELETED, requests[i].args.otheruserid);
}
}.bind(this), notification.exception);
}
@@ -236,7 +239,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification'],
* @private
*/
Contacts.prototype._removeContact = function(event, userid) {
this.messageArea.find("[data-region='contact'][data-userid='" + userid + "']").remove();
this.messageArea.find(this.messageArea.SELECTORS.CONTACT + "[data-userid='" + userid + "']").remove();
};
/**
@@ -247,9 +250,9 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification'],
*/
Contacts.prototype._setSelectedUser = function(userid) {
// Remove the 'selected' class from any other contact.
this.messageArea.find("[data-region='contact']").removeClass('selected');
this.messageArea.find(this.messageArea.SELECTORS.CONTACT).removeClass('selected');
// Set the tab for the user to selected.
this.messageArea.find("[data-region='contact'][data-userid='" + userid + "']").addClass('selected');
this.messageArea.find(this.messageArea.SELECTORS.CONTACT + "[data-userid='" + userid + "']").addClass('selected');
};
/**
@@ -258,7 +261,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification'],
* @return {Boolean}
*/
Contacts.prototype._isCurrentlyDeleting = function() {
if (this.messageArea.find("[data-region='delete-conversation-checkbox']:visible").length !== 0) {
if (this.messageArea.find(this.messageArea.SELECTORS.DELETECONVERSATIONCHECKBOX + ":visible").length !== 0) {
return true;
}
+32 -28
View File
@@ -43,13 +43,13 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification'],
* @private
*/
Messages.prototype._init = function() {
this.messageArea.onCustomEvent('conversation-deleted', this._handleConversationDeleted.bind(this));
this.messageArea.onCustomEvent('conversation-selected', this._loadMessages.bind(this));
this.messageArea.onCustomEvent('message-send', this._loadMessages.bind(this));
this.messageArea.onCustomEvent('choose-messages-to-delete', this._chooseMessagesToDelete.bind(this));
this.messageArea.onDelegateEvent('click', "[data-action='send-message']", this._sendMessage.bind(this));
this.messageArea.onDelegateEvent('click', "[data-action='delete-messages']", this._deleteMessages.bind(this));
this.messageArea.onDelegateEvent('click', "[data-action='cancel-delete-messages']",
this.messageArea.onCustomEvent(this.messageArea.EVENTS.CONVERSATIONDELETED, this._handleConversationDeleted.bind(this));
this.messageArea.onCustomEvent(this.messageArea.EVENTS.CONVERSATIONSELECTED, this._loadMessages.bind(this));
this.messageArea.onCustomEvent(this.messageArea.EVENTS.SENDMESSAGE, this._loadMessages.bind(this));
this.messageArea.onCustomEvent(this.messageArea.EVENTS.CHOOSEMESSAGESTODELETE, this._chooseMessagesToDelete.bind(this));
this.messageArea.onDelegateEvent('click', this.messageArea.SELECTORS.SENDMESSAGE, this._sendMessage.bind(this));
this.messageArea.onDelegateEvent('click', this.messageArea.SELECTORS.DELETEMESSAGES, this._deleteMessages.bind(this));
this.messageArea.onDelegateEvent('click', this.messageArea.SELECTORS.CANCELDELETEMESSAGES,
this._cancelMessagesToDelete.bind(this));
};
@@ -64,8 +64,8 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification'],
Messages.prototype._loadMessages = function(event, userid) {
// Show loading template.
templates.render('core/loading', {}).done(function(html, js) {
templates.replaceNodeContents("[data-region='messages-area']", html, js);
});
templates.replaceNodeContents(this.messageArea.SELECTORS.MESSAGESAREA, html, js);
}.bind(this));
// Call the web service to get our data.
var promises = ajax.call([{
@@ -81,7 +81,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification'],
// We have the data - lets re-render the template with it.
return templates.render('core_message/message_area_messages', data);
}).then(function(html, js) {
templates.replaceNodeContents("[data-region='messages-area']", html, js);
templates.replaceNodeContents(this.messageArea.SELECTORS.MESSAGESAREA, html, js);
}.bind(this)).fail(notification.exception);
};
@@ -99,7 +99,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification'],
messages: [
{
touserid: this._getUserId(),
text: this.messageArea.find("[data-region='send-message-txt']").val()
text: this.messageArea.find(this.messageArea.SELECTORS.SENDMESSAGETEXT).val()
}
]
}
@@ -110,7 +110,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification'],
// Some variables to pass to the trigger.
var userid = this._getUserId();
// Fire an event to say the message was sent.
this.messageArea.trigger('message-sent', userid);
this.messageArea.trigger(this.messageArea.EVENTS.MESSAGESENT, userid);
// Update the messaging area.
this._addMessageToDom();
}.bind(this)).fail(notification.exception);
@@ -124,9 +124,10 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification'],
*/
Messages.prototype._chooseMessagesToDelete = function() {
// Show the checkboxes.
this.messageArea.find("[data-region='delete-message-checkbox']").show();
this.messageArea.find(this.messageArea.SELECTORS.DELETEMESSAGECHECKBOX).show();
// Display the confirmation message.
var responseSelector = "[data-region='messages-area'] [data-region='response']";
var responseSelector = this.messageArea.SELECTORS.MESSAGESAREA + " " +
this.messageArea.SELECTORS.MESSAGERESPONSE;
return templates.render('core_message/message_area_delete_confirmation', {}).then(function(html, js) {
templates.replaceNodeContents(responseSelector, html, js);
});
@@ -139,7 +140,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification'],
*/
Messages.prototype._deleteMessages = function() {
var userid = this.messageArea.getCurrentUserId();
var checkboxes = this.messageArea.find("[data-region='delete-message-checkbox'] input:checked");
var checkboxes = this.messageArea.find(this.messageArea.SELECTORS.DELETEMESSAGECHECKBOX + " input:checked");
var requests = [];
var messagestoremove = [];
@@ -148,7 +149,8 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification'],
var node = $(element);
var messageid = node.data('messageid');
var isread = node.data('messageread') ? 1 : 0;
var message = this.messageArea.find("[data-region='message'][data-id='" + messageid + '' + isread + "']");
var message = this.messageArea.find(this.messageArea.SELECTORS.MESSAGE +
"[data-id='" + messageid + '' + isread + "']");
messagestoremove.push(message);
requests.push({
methodname: 'core_message_delete_message',
@@ -171,8 +173,10 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification'],
$.each(messagestoremove, function(key, message) {
// First - let's make sure there are no more messages in that time block.
var blocktime = message.data('blocktime');
if (this.messageArea.find("[data-region='message'][data-blocktime='" + blocktime + "']").length === 0) {
this.messageArea.find("[data-region='blocktime'][data-blocktime='" + blocktime + "']").remove();
if (this.messageArea.find(this.messageArea.SELECTORS.MESSAGE +
"[data-blocktime='" + blocktime + "']").length === 0) {
this.messageArea.find(this.messageArea.SELECTORS.BLOCKTIME +
"[data-blocktime='" + blocktime + "']").remove();
}
}.bind(this));
}.bind(this), notification.exception);
@@ -182,8 +186,8 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification'],
this._hideDeleteAction();
// Trigger event letting other modules know messages were deleted.
this.messageArea.trigger('messages-deleted',
this.messageArea.find("[data-region='messages']").data('userid'));
this.messageArea.trigger(this.messageArea.EVENTS.MESSAGESDELETED,
this.messageArea.find(this.messageArea.SELECTORS.MESSAGES).data('userid'));
};
/**
@@ -196,7 +200,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification'],
Messages.prototype._handleConversationDeleted = function(event, userid) {
if (userid == this._getUserId()) {
// Clear the current panel.
this.messageArea.find("[data-region='messages-area']").empty();
this.messageArea.find(this.messageArea.SELECTORS.MESSAGESAREA).empty();
}
};
@@ -208,11 +212,11 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification'],
*/
Messages.prototype._hideDeleteAction = function() {
// Uncheck all checkboxes.
this.messageArea.find("[data-region='delete-message-checkbox'] input:checked").removeAttr('checked');
this.messageArea.find(this.messageArea.SELECTORS.DELETEMESSAGECHECKBOX + " input:checked").removeAttr('checked');
// Hide the checkboxes.
this.messageArea.find("[data-region='delete-message-checkbox']").hide();
this.messageArea.find(this.messageArea.SELECTORS.DELETEMESSAGECHECKBOX).hide();
// Remove the confirmation message.
var responseSelector = "[data-region='messages-area'] [data-region='response']";
var responseSelector = this.messageArea.SELECTORS.MESSAGESAREA + " " + this.messageArea.SELECTORS.MESSAGERESPONSE;
this.messageArea.find(responseSelector).empty();
// Only show a response text area if we are viewing the logged in user's messages.
if (this.messageArea.getLoggedInUserId() == this.messageArea.getCurrentUserId()) {
@@ -231,7 +235,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification'],
// Hide the items responsible for deleting messages.
this._hideDeleteAction();
// Trigger event letting other modules know message deletion was canceled.
this.messageArea.trigger('cancel-messages-deleted');
this.messageArea.trigger(this.messageArea.EVENTS.CANCELDELETEMESSAGES);
};
/**
@@ -254,9 +258,9 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification'],
return promises[0].then(function(data) {
return templates.render('core_message/message_area_message', data);
}).then(function(html, js) {
templates.appendNodeContents("[data-region='messages']", html, js);
templates.appendNodeContents(this.messageArea.SELECTORS.MESSAGES, html, js);
// Empty the response text area.
this.messageArea.find("[data-region='send-message-txt']").val('');
this.messageArea.find(this.messageArea.SELECTORS.SENDMESSAGETEXT).val('');
}.bind(this)).fail(notification.exception);
};
@@ -267,7 +271,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification'],
* @private
*/
Messages.prototype._getUserId = function() {
return this.messageArea.find("[data-region='messages']").data('userid');
return this.messageArea.find(this.messageArea.SELECTORS.MESSAGES).data('userid');
};
return Messages;
+20 -17
View File
@@ -43,13 +43,16 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
* @private
*/
Profile.prototype._init = function() {
this.messageArea.onCustomEvent('contact-selected', this._viewProfile.bind(this));
this.messageArea.onDelegateEvent('click', "[data-action='profile-view']", this._viewFullProfile.bind(this));
this.messageArea.onDelegateEvent('click', "[data-action='profile-send-message']", this._sendMessage.bind(this));
this.messageArea.onDelegateEvent('click', "[data-action='profile-unblock-contact']", this._unblockContact.bind(this));
this.messageArea.onDelegateEvent('click', "[data-action='profile-block-contact']", this._blockContact.bind(this));
this.messageArea.onDelegateEvent('click', "[data-action='profile-add-contact']", this._addContact.bind(this));
this.messageArea.onDelegateEvent('click', "[data-action='profile-remove-contact']", this._removeContact.bind(this));
this.messageArea.onCustomEvent(this.messageArea.EVENTS.CONTACTSELECTED, this._viewProfile.bind(this));
this.messageArea.onDelegateEvent('click', this.messageArea.SELECTORS.PROFILEVIEW, this._viewFullProfile.bind(this));
this.messageArea.onDelegateEvent('click', this.messageArea.SELECTORS.PROFILESENDMESSAGE, this._sendMessage.bind(this));
this.messageArea.onDelegateEvent('click', this.messageArea.SELECTORS.PROFILEUNBLOCKCONTACT,
this._unblockContact.bind(this));
this.messageArea.onDelegateEvent('click', this.messageArea.SELECTORS.PROFILEBLOCKCONTACT,
this._blockContact.bind(this));
this.messageArea.onDelegateEvent('click', this.messageArea.SELECTORS.PROFILEADDCONTACT, this._addContact.bind(this));
this.messageArea.onDelegateEvent('click', this.messageArea.SELECTORS.PROFILEREMOVECONTACT,
this._removeContact.bind(this));
};
/**
@@ -63,8 +66,8 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
Profile.prototype._viewProfile = function(event, userid) {
// Show loading template.
templates.render('core/loading', {}).done(function(html, js) {
templates.replaceNodeContents("[data-region='messages-area']", html, js);
});
templates.replaceNodeContents(this.messageArea.SELECTORS.MESSAGESAREA, html, js);
}.bind(this));
// Call the web service to return the profile.
var promises = ajax.call([{
@@ -79,8 +82,8 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
return promises[0].then(function(data) {
return templates.render('core_message/message_area_profile', data);
}).then(function(html, js) {
templates.replaceNodeContents("[data-region='messages-area']", html, js);
}).fail(notification.exception);
templates.replaceNodeContents(this.messageArea.SELECTORS.MESSAGESAREA, html, js);
}.bind(this)).fail(notification.exception);
};
/**
@@ -98,7 +101,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
* @private
*/
Profile.prototype._sendMessage = function() {
this.messageArea.trigger('message-send', this._getUserId());
this.messageArea.trigger(this.messageArea.EVENTS.SENDMESSAGE, this._getUserId());
};
/**
@@ -111,7 +114,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
var action = this._performAction('core_message_block_contacts', 'unblockcontact', 'profile-block-contact',
'profile-unblock-contact');
return action.then(function() {
this.messageArea.trigger('contact-blocked', this._getUserId());
this.messageArea.trigger(this.messageArea.EVENTS.CONTACTBLOCKED, this._getUserId());
}.bind(this));
};
@@ -125,7 +128,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
var action = this._performAction('core_message_unblock_contacts', 'blockcontact', 'profile-unblock-contact',
'profile-block-contact');
return action.then(function() {
this.messageArea.trigger('contact-unblocked', this._getUserId());
this.messageArea.trigger(this.messageArea.EVENTS.CONTACTUNBLOCKED, this._getUserId());
}.bind(this));
};
@@ -139,7 +142,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
var action = this._performAction('core_message_create_contacts', 'removecontact', 'profile-add-contact',
'profile-remove-contact');
return action.then(function() {
this.messageArea.trigger('contact-added', this._getUserId());
this.messageArea.trigger(this.messageArea.EVENTS.CONTACTADDED, this._getUserId());
}.bind(this));
};
@@ -153,7 +156,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
var action = this._performAction('core_message_delete_contacts', 'addcontact', 'profile-remove-contact',
'profile-add-contact');
return action.then(function() {
this.messageArea.trigger('contact-removed', this._getUserId());
this.messageArea.trigger(this.messageArea.EVENTS.CONTACTREMOVED, this._getUserId());
}.bind(this));
};
@@ -206,7 +209,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
* @private
*/
Profile.prototype._getUserId = function() {
return this.messageArea.find("[data-region='profile']").data('userid');
return this.messageArea.find(this.messageArea.SELECTORS.PROFILE).data('userid');
};
return Profile;
+4 -4
View File
@@ -42,8 +42,8 @@ define([], function() {
* @private
*/
Tabs.prototype._init = function() {
this.messageArea.onDelegateEvent('click', "[data-action='conversations-view']", this._viewConversations.bind(this));
this.messageArea.onDelegateEvent('click', "[data-action='contacts-view']", this._viewContacts.bind(this));
this.messageArea.onDelegateEvent('click', this.messageArea.SELECTORS.VIEWCONVERSATIONS, this._viewConversations.bind(this));
this.messageArea.onDelegateEvent('click', this.messageArea.SELECTORS.VIEWCONTACTS, this._viewContacts.bind(this));
};
/**
@@ -52,7 +52,7 @@ define([], function() {
* @private
*/
Tabs.prototype._viewConversations = function() {
this.messageArea.trigger('conversations-selected');
this.messageArea.trigger(this.messageArea.EVENTS.CONVERSATIONSSELECTED);
};
/**
@@ -61,7 +61,7 @@ define([], function() {
* @private
*/
Tabs.prototype._viewContacts = function() {
this.messageArea.trigger('contacts-selected');
this.messageArea.trigger(this.messageArea.EVENTS.CONTACTSSELECTED);
};
return Tabs;