MDL-55774 core_message: ensure selectors are isolated
This commit is contained in:
@@ -108,10 +108,10 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
|
||||
this.messageArea.onDelegateEvent('blur', this.messageArea.SELECTORS.SEARCHBOX, this._clearSearching.bind(this));
|
||||
|
||||
// Now enable the ability to infinitely scroll through conversations and contacts.
|
||||
customEvents.define(this.messageArea.SELECTORS.CONVERSATIONS, [
|
||||
customEvents.define(this.messageArea.find(this.messageArea.SELECTORS.CONVERSATIONS), [
|
||||
customEvents.events.scrollBottom
|
||||
]);
|
||||
customEvents.define(this.messageArea.SELECTORS.CONTACTS, [
|
||||
customEvents.define(this.messageArea.find(this.messageArea.SELECTORS.CONTACTS), [
|
||||
customEvents.events.scrollBottom
|
||||
]);
|
||||
this.messageArea.onDelegateEvent(customEvents.events.scrollBottom, this.messageArea.SELECTORS.CONVERSATIONS,
|
||||
@@ -223,10 +223,10 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
|
||||
// Add loading icon to the end of the list.
|
||||
return templates.render('core/loading', {}).then(function(html, js) {
|
||||
if (this._numConversationsDisplayed) {
|
||||
templates.appendNodeContents(this.messageArea.SELECTORS.CONVERSATIONS,
|
||||
templates.appendNodeContents(this.messageArea.find(this.messageArea.SELECTORS.CONVERSATIONS),
|
||||
"<div style='text-align:center'>" + html + "</div>", js);
|
||||
} else { // No conversations, just replace contents.
|
||||
templates.replaceNodeContents(this.messageArea.SELECTORS.CONVERSATIONS,
|
||||
templates.replaceNodeContents(this.messageArea.find(this.messageArea.SELECTORS.CONVERSATIONS),
|
||||
"<div style='text-align:center'>" + html + "</div>", js);
|
||||
}
|
||||
return this._getItems('core_message_data_for_messagearea_conversations',
|
||||
@@ -241,12 +241,12 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
|
||||
// Only append data if we got data back.
|
||||
if (numberreceived > 0) {
|
||||
// Show the new content.
|
||||
templates.appendNodeContents(this.messageArea.SELECTORS.CONVERSATIONS, html, js);
|
||||
templates.appendNodeContents(this.messageArea.find(this.messageArea.SELECTORS.CONVERSATIONS), html, js);
|
||||
// Increment the number of conversations displayed.
|
||||
this._numConversationsDisplayed += numberreceived;
|
||||
} else if (!this._numConversationsDisplayed) {
|
||||
// If we didn't receive any contacts and there are currently none, then we want to show a message.
|
||||
templates.replaceNodeContents(this.messageArea.SELECTORS.CONVERSATIONS, html, js);
|
||||
templates.replaceNodeContents(this.messageArea.find(this.messageArea.SELECTORS.CONVERSATIONS), html, js);
|
||||
}
|
||||
// Mark that we are no longer busy loading data.
|
||||
this._isLoadingConversations = false;
|
||||
@@ -276,10 +276,10 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
|
||||
// Add loading icon to the end of the list.
|
||||
return templates.render('core/loading', {}).then(function(html, js) {
|
||||
if (this._numContactsDisplayed) {
|
||||
templates.appendNodeContents(this.messageArea.SELECTORS.CONTACTS,
|
||||
templates.appendNodeContents(this.messageArea.find(this.messageArea.SELECTORS.CONTACTS),
|
||||
"<div style='text-align:center'>" + html + "</div>", js);
|
||||
} else { // No contacts, just replace contents.
|
||||
templates.replaceNodeContents(this.messageArea.SELECTORS.CONTACTS,
|
||||
templates.replaceNodeContents(this.messageArea.find(this.messageArea.SELECTORS.CONTACTS),
|
||||
"<div style='text-align:center'>" + html + "</div>", js);
|
||||
}
|
||||
return this._getItems('core_message_data_for_messagearea_contacts',
|
||||
@@ -294,12 +294,12 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
|
||||
// Only append data if we got data back.
|
||||
if (numberreceived > 0) {
|
||||
// Show the new content.
|
||||
templates.appendNodeContents(this.messageArea.SELECTORS.CONTACTS, html, js);
|
||||
templates.appendNodeContents(this.messageArea.find(this.messageArea.SELECTORS.CONTACTS), html, js);
|
||||
// Increment the number of contacts displayed.
|
||||
this._numContactsDisplayed += numberreceived;
|
||||
} else if (!this._numContactsDisplayed) {
|
||||
// If we didn't receive any contacts and there are currently none, then we want to show a message.
|
||||
templates.replaceNodeContents(this.messageArea.SELECTORS.CONTACTS, html, js);
|
||||
templates.replaceNodeContents(this.messageArea.find(this.messageArea.SELECTORS.CONTACTS), html, js);
|
||||
}
|
||||
// Mark that we are no longer busy loading data.
|
||||
this._isLoadingContacts = false;
|
||||
|
||||
@@ -125,7 +125,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
|
||||
var numberreceived = 0;
|
||||
// Show loading template.
|
||||
return templates.render('core/loading', {}).then(function(html, js) {
|
||||
templates.replaceNodeContents(this.messageArea.SELECTORS.MESSAGESAREA, html, js);
|
||||
templates.replaceNodeContents(this.messageArea.find(this.messageArea.SELECTORS.MESSAGESAREA), html, js);
|
||||
return markMessagesAsRead[0];
|
||||
}.bind(this)).then(function() {
|
||||
var conversationnode = this.messageArea.find(this.messageArea.SELECTORS.CONVERSATIONS + " " +
|
||||
@@ -142,7 +142,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
|
||||
// We have the data - lets render the template with it.
|
||||
return templates.render('core_message/message_area_messages_area', data);
|
||||
}).then(function(html, js) {
|
||||
templates.replaceNodeContents(this.messageArea.SELECTORS.MESSAGESAREA, html, js);
|
||||
templates.replaceNodeContents(this.messageArea.find(this.messageArea.SELECTORS.MESSAGESAREA), html, js);
|
||||
// Scroll to the bottom.
|
||||
this._scrollBottom();
|
||||
// Only increment if data was returned.
|
||||
@@ -151,7 +151,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
|
||||
this._numMessagesDisplayed = numberreceived;
|
||||
}
|
||||
// Now enable the ability to infinitely scroll through messages.
|
||||
customEvents.define(this.messageArea.SELECTORS.MESSAGES, [
|
||||
customEvents.define(this.messageArea.find(this.messageArea.SELECTORS.MESSAGES), [
|
||||
customEvents.events.scrollTop
|
||||
]);
|
||||
// Assign the event for scrolling.
|
||||
@@ -176,7 +176,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
|
||||
var numberreceived = 0;
|
||||
// Show loading template.
|
||||
return templates.render('core/loading', {}).then(function(html, js) {
|
||||
templates.prependNodeContents(this.messageArea.SELECTORS.MESSAGES,
|
||||
templates.prependNodeContents(this.messageArea.find(this.messageArea.SELECTORS.MESSAGES),
|
||||
"<div style='text-align:center'>" + html + "</div>", js);
|
||||
return this._getMessages(this._getUserId());
|
||||
}.bind(this)).then(function(data) {
|
||||
@@ -200,7 +200,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
|
||||
// Get height before we add the messages.
|
||||
var oldheight = this.messageArea.find(this.messageArea.SELECTORS.MESSAGES)[0].scrollHeight;
|
||||
// Show the new content.
|
||||
templates.prependNodeContents(this.messageArea.SELECTORS.MESSAGES, html, js);
|
||||
templates.prependNodeContents(this.messageArea.find(this.messageArea.SELECTORS.MESSAGES), html, js);
|
||||
// Get height after we add the messages.
|
||||
var newheight = this.messageArea.find(this.messageArea.SELECTORS.MESSAGES)[0].scrollHeight;
|
||||
// Make sure scroll bar is at the location before we loaded more messages.
|
||||
@@ -433,7 +433,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
|
||||
return promises[0].then(function(data) {
|
||||
return templates.render('core_message/message_area_message', data);
|
||||
}).then(function(html, js) {
|
||||
templates.appendNodeContents(this.messageArea.SELECTORS.MESSAGES, html, js);
|
||||
templates.appendNodeContents(this.messageArea.find(this.messageArea.SELECTORS.MESSAGES), html, js);
|
||||
// Empty the response text area.
|
||||
this.messageArea.find(this.messageArea.SELECTORS.SENDMESSAGETEXT).val('').trigger('input');
|
||||
// Scroll down.
|
||||
|
||||
@@ -66,7 +66,7 @@ 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(this.messageArea.SELECTORS.MESSAGESAREA, html, js);
|
||||
templates.replaceNodeContents(this.messageArea.find(this.messageArea.SELECTORS.MESSAGESAREA), html, js);
|
||||
}.bind(this));
|
||||
|
||||
// Call the web service to return the profile.
|
||||
@@ -82,7 +82,7 @@ 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(this.messageArea.SELECTORS.MESSAGESAREA, html, js);
|
||||
templates.replaceNodeContents(this.messageArea.find(this.messageArea.SELECTORS.MESSAGESAREA), html, js);
|
||||
}.bind(this)).fail(notification.exception);
|
||||
};
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
|
||||
}.bind(this));
|
||||
|
||||
// Event listeners for scrolling through messages and people in courses.
|
||||
customEvents.define(this.messageArea.SELECTORS.SEARCHRESULTSAREA, [
|
||||
customEvents.define(this.messageArea.find(this.messageArea.SELECTORS.SEARCHRESULTSAREA), [
|
||||
customEvents.events.scrollBottom
|
||||
]);
|
||||
this.messageArea.onDelegateEvent(customEvents.events.scrollBottom, this.messageArea.SELECTORS.SEARCHRESULTSAREA,
|
||||
@@ -228,7 +228,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
|
||||
var numberreceived = 0;
|
||||
// Add loading icon to the end of the list.
|
||||
return templates.render('core/loading', {}).then(function(html, js) {
|
||||
templates.appendNodeContents(this.messageArea.SELECTORS.SEARCHRESULTSAREA,
|
||||
templates.appendNodeContents(this.messageArea.find(this.messageArea.SELECTORS.SEARCHRESULTSAREA),
|
||||
"<div style='text-align:center'>" + html + "</div>", js);
|
||||
return promises[0];
|
||||
}.bind(this)).then(function(data) {
|
||||
@@ -241,12 +241,12 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
|
||||
// Only append data if we got data back.
|
||||
if (numberreceived > 0) {
|
||||
// Show the new content.
|
||||
templates.appendNodeContents(this.messageArea.SELECTORS.SEARCHRESULTSAREA, html, js);
|
||||
templates.appendNodeContents(this.messageArea.find(this.messageArea.SELECTORS.SEARCHRESULTSAREA), html, js);
|
||||
// Increment the number of contacts displayed.
|
||||
this._numMessagesDisplayed += numberreceived;
|
||||
} else if (this._numMessagesDisplayed == 0) { // Must have nothing to begin with.
|
||||
// Replace the new content.
|
||||
templates.replaceNodeContents(this.messageArea.SELECTORS.SEARCHRESULTSAREA, html, js);
|
||||
templates.replaceNodeContents(this.messageArea.find(this.messageArea.SELECTORS.SEARCHRESULTSAREA), html, js);
|
||||
}
|
||||
// Mark that we are no longer busy loading data.
|
||||
this._isLoading = false;
|
||||
@@ -274,13 +274,13 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
|
||||
|
||||
// Perform the search and replace the content.
|
||||
return templates.render('core/loading', {}).then(function(html, js) {
|
||||
templates.replaceNodeContents(this.messageArea.SELECTORS.SEARCHRESULTSAREA,
|
||||
templates.replaceNodeContents(this.messageArea.find(this.messageArea.SELECTORS.SEARCHRESULTSAREA),
|
||||
"<div style='text-align:center'>" + html + "</div>", js);
|
||||
return promises[0];
|
||||
}.bind(this)).then(function(data) {
|
||||
return templates.render('core_message/message_area_people_search_results', data);
|
||||
}).then(function(html, js) {
|
||||
templates.replaceNodeContents(this.messageArea.SELECTORS.SEARCHRESULTSAREA, html, js);
|
||||
templates.replaceNodeContents(this.messageArea.find(this.messageArea.SELECTORS.SEARCHRESULTSAREA), html, js);
|
||||
}.bind(this)).fail(notification.exception);
|
||||
};
|
||||
|
||||
@@ -316,7 +316,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
|
||||
var numberreceived = 0;
|
||||
// Add loading icon to the end of the list.
|
||||
return templates.render('core/loading', {}).then(function(html, js) {
|
||||
templates.appendNodeContents(this.messageArea.SELECTORS.SEARCHRESULTSAREA,
|
||||
templates.appendNodeContents(this.messageArea.find(this.messageArea.SELECTORS.SEARCHRESULTSAREA),
|
||||
"<div style='text-align:center'>" + html + "</div>", js);
|
||||
return promises[0];
|
||||
}.bind(this)).then(function(data) {
|
||||
@@ -329,12 +329,12 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
|
||||
// Only append data if we got data back.
|
||||
if (numberreceived > 0) {
|
||||
// Show the new content.
|
||||
templates.appendNodeContents(this.messageArea.SELECTORS.SEARCHRESULTSAREA, html, js);
|
||||
templates.appendNodeContents(this.messageArea.find(this.messageArea.SELECTORS.SEARCHRESULTSAREA), html, js);
|
||||
// Increment the number of contacts displayed.
|
||||
this._numPeopleDisplayed += numberreceived;
|
||||
} else if (this._numPeopleDisplayed == 0) { // Must have nothing to begin with.
|
||||
// Replace the new content.
|
||||
templates.replaceNodeContents(this.messageArea.SELECTORS.SEARCHRESULTSAREA, html, js);
|
||||
templates.replaceNodeContents(this.messageArea.find(this.messageArea.SELECTORS.SEARCHRESULTSAREA), html, js);
|
||||
}
|
||||
// Mark that we are no longer busy loading data.
|
||||
this._isLoading = false;
|
||||
|
||||
Reference in New Issue
Block a user