MDL-54682 core_message: do not disable left panel when deleting messages

This commit is contained in:
Mark Nelson
2016-10-12 21:45:33 +08:00
parent d68472984a
commit 2127ca2cde
6 changed files with 14 additions and 89 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
define(["core/custom_interaction_events","core_message/message_area_events"],function(a,b){function c(a){this.messageArea=a,this._init()}var d={ACTIVECONTACTSTAB:"[data-region='contacts-area'] [role='tab'][aria-selected='true']",CONTACTSPANELS:"[data-region='contacts']",VIEWCONTACTS:"[data-action='contacts-view']",VIEWCONVERSATIONS:"[data-action='conversations-view']"};return c.prototype._isDeleting=!1,c.prototype.messageArea=null,c.prototype._init=function(){a.define(this.messageArea.node,[a.events.activate,a.events.up,a.events.down,a.events.next,a.events.previous,a.events.ctrlPageUp,a.events.ctrlPageDown]),this.messageArea.onDelegateEvent(a.events.activate,d.VIEWCONVERSATIONS,this._viewConversations.bind(this)),this.messageArea.onDelegateEvent(a.events.activate,d.VIEWCONTACTS,this._viewContacts.bind(this)),this.messageArea.onDelegateEvent(a.events.up,d.VIEWCONVERSATIONS,this._toggleTabs.bind(this)),this.messageArea.onDelegateEvent(a.events.down,d.VIEWCONVERSATIONS,this._toggleTabs.bind(this)),this.messageArea.onDelegateEvent(a.events.next,d.VIEWCONVERSATIONS,this._toggleTabs.bind(this)),this.messageArea.onDelegateEvent(a.events.previous,d.VIEWCONVERSATIONS,this._toggleTabs.bind(this)),this.messageArea.onDelegateEvent(a.events.up,d.VIEWCONTACTS,this._toggleTabs.bind(this)),this.messageArea.onDelegateEvent(a.events.down,d.VIEWCONTACTS,this._toggleTabs.bind(this)),this.messageArea.onDelegateEvent(a.events.next,d.VIEWCONTACTS,this._toggleTabs.bind(this)),this.messageArea.onDelegateEvent(a.events.previous,d.VIEWCONTACTS,this._toggleTabs.bind(this)),this.messageArea.onDelegateEvent(a.events.ctrlPageUp,d.CONTACTSPANELS,this._toggleTabs.bind(this)),this.messageArea.onDelegateEvent(a.events.ctrlPageDown,d.CONTACTSPANELS,this._toggleTabs.bind(this)),this.messageArea.onCustomEvent(b.CHOOSEMESSAGESTODELETE,function(){this._isDeleting=!0}.bind(this)),this.messageArea.onCustomEvent(b.MESSAGESDELETED,function(){this._isDeleting=!1}.bind(this)),this.messageArea.onCustomEvent(b.CONVERSATIONDELETED,function(){this._isDeleting=!1}.bind(this)),this.messageArea.onCustomEvent(b.CANCELDELETEMESSAGES,function(){this._isDeleting=!1}.bind(this)),this.messageArea.onCustomEvent(b.MESSAGESENT,function(){this._selectTab(d.VIEWCONVERSATIONS,d.VIEWCONTACTS)}.bind(this))},c.prototype._viewConversations=function(){this._isDeleting||(this.messageArea.trigger(b.CONVERSATIONSSELECTED),this._selectTab(d.VIEWCONVERSATIONS,d.VIEWCONTACTS))},c.prototype._viewContacts=function(){this._isDeleting||(this.messageArea.trigger(b.CONTACTSSELECTED),this._selectTab(d.VIEWCONTACTS,d.VIEWCONVERSATIONS))},c.prototype._selectTab=function(a,b){b=this.messageArea.find(b),b.removeClass("selected"),b.attr("aria-selected","false"),b.attr("tabindex","-1"),a=this.messageArea.find(a),a.addClass("selected"),a.attr("aria-selected","true"),a.attr("tabindex","0")},c.prototype._toggleTabs=function(a,b){var c=this.messageArea.find(d.ACTIVECONTACTSTAB);c.is(d.VIEWCONVERSATIONS)?this._viewContacts():this._viewConversations(),this.messageArea.find(d.ACTIVECONTACTSTAB).focus(),a.preventDefault(),a.stopPropagation(),b.originalEvent.preventDefault(),b.originalEvent.stopPropagation()},c});
define(["core/custom_interaction_events","core_message/message_area_events"],function(a,b){function c(a){this.messageArea=a,this._init()}var d={ACTIVECONTACTSTAB:"[data-region='contacts-area'] [role='tab'][aria-selected='true']",CONTACTSPANELS:"[data-region='contacts']",VIEWCONTACTS:"[data-action='contacts-view']",VIEWCONVERSATIONS:"[data-action='conversations-view']"};return c.prototype.messageArea=null,c.prototype._init=function(){a.define(this.messageArea.node,[a.events.activate,a.events.up,a.events.down,a.events.next,a.events.previous,a.events.ctrlPageUp,a.events.ctrlPageDown]),this.messageArea.onDelegateEvent(a.events.activate,d.VIEWCONVERSATIONS,this._viewConversations.bind(this)),this.messageArea.onDelegateEvent(a.events.activate,d.VIEWCONTACTS,this._viewContacts.bind(this)),this.messageArea.onDelegateEvent(a.events.up,d.VIEWCONVERSATIONS,this._toggleTabs.bind(this)),this.messageArea.onDelegateEvent(a.events.down,d.VIEWCONVERSATIONS,this._toggleTabs.bind(this)),this.messageArea.onDelegateEvent(a.events.next,d.VIEWCONVERSATIONS,this._toggleTabs.bind(this)),this.messageArea.onDelegateEvent(a.events.previous,d.VIEWCONVERSATIONS,this._toggleTabs.bind(this)),this.messageArea.onDelegateEvent(a.events.up,d.VIEWCONTACTS,this._toggleTabs.bind(this)),this.messageArea.onDelegateEvent(a.events.down,d.VIEWCONTACTS,this._toggleTabs.bind(this)),this.messageArea.onDelegateEvent(a.events.next,d.VIEWCONTACTS,this._toggleTabs.bind(this)),this.messageArea.onDelegateEvent(a.events.previous,d.VIEWCONTACTS,this._toggleTabs.bind(this)),this.messageArea.onDelegateEvent(a.events.ctrlPageUp,d.CONTACTSPANELS,this._toggleTabs.bind(this)),this.messageArea.onDelegateEvent(a.events.ctrlPageDown,d.CONTACTSPANELS,this._toggleTabs.bind(this)),this.messageArea.onCustomEvent(b.MESSAGESENT,function(){this._selectTab(d.VIEWCONVERSATIONS,d.VIEWCONTACTS)}.bind(this))},c.prototype._viewConversations=function(){this.messageArea.trigger(b.CONVERSATIONSSELECTED),this._selectTab(d.VIEWCONVERSATIONS,d.VIEWCONTACTS)},c.prototype._viewContacts=function(){this.messageArea.trigger(b.CONTACTSSELECTED),this._selectTab(d.VIEWCONTACTS,d.VIEWCONVERSATIONS)},c.prototype._selectTab=function(a,b){b=this.messageArea.find(b),b.removeClass("selected"),b.attr("aria-selected","false"),b.attr("tabindex","-1"),a=this.messageArea.find(a),a.addClass("selected"),a.attr("aria-selected","true"),a.attr("tabindex","0")},c.prototype._toggleTabs=function(a,b){var c=this.messageArea.find(d.ACTIVECONTACTSTAB);c.is(d.VIEWCONVERSATIONS)?this._viewContacts():this._viewConversations(),this.messageArea.find(d.ACTIVECONTACTSTAB).focus(),a.preventDefault(),a.stopPropagation(),b.originalEvent.preventDefault(),b.originalEvent.stopPropagation()},c});
+11 -24
View File
@@ -58,9 +58,6 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
this._init();
}
/** @type {Boolean} checks if we are currently deleting */
Contacts.prototype._isDeleting = false;
/** @type {Boolean} checks if we are currently loading conversations */
Contacts.prototype._isLoadingConversations = false;
@@ -163,7 +160,6 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
* @private
*/
Contacts.prototype._startDeleting = function() {
this._isDeleting = true;
this.messageArea.find(SELECTORS.CONTACTSAREA).addClass('editing');
};
@@ -173,7 +169,6 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
* @private
*/
Contacts.prototype._stopDeleting = function() {
this._isDeleting = false;
this.messageArea.find(SELECTORS.CONTACTSAREA).removeClass('editing');
};
@@ -258,10 +253,6 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
* @private
*/
Contacts.prototype._loadConversations = function() {
if (this._isDeleting) {
return false;
}
if (this._isLoadingConversations) {
return false;
}
@@ -313,10 +304,6 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
* @private
*/
Contacts.prototype._loadContacts = function() {
if (this._isDeleting) {
return false;
}
if (this._isLoadingContacts) {
return false;
}
@@ -367,9 +354,8 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
* @private
*/
Contacts.prototype._viewConversation = function(event) {
if (this._isDeleting) {
this.messageArea.trigger(Events.CANCELDELETEMESSAGES, userid);
}
// Cancel any deletion of messages we may have.
this.messageArea.trigger(Events.CANCELDELETEMESSAGES);
var userid = $(event.currentTarget).data('userid');
var messageid = $(event.currentTarget).data('messageid');
@@ -394,14 +380,15 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
* @private
*/
Contacts.prototype._viewContact = function(event) {
if (!this._isDeleting) {
var userid = $(event.currentTarget).data('userid');
this._setSelectedUser("[data-userid='" + userid + "']");
this.messageArea.trigger(Events.CONTACTSELECTED, userid);
// Don't highlight the conversation because the message region has changed.
this.messageArea.find(SELECTORS.SELECTEDVIEWCONVERSATION).removeClass('selected');
this._showMessagingArea();
}
// Cancel any deletion of messages we may have.
this.messageArea.trigger(Events.CANCELDELETEMESSAGES);
var userid = $(event.currentTarget).data('userid');
this._setSelectedUser("[data-userid='" + userid + "']");
this.messageArea.trigger(Events.CONTACTSELECTED, userid);
// Don't highlight the conversation because the message region has changed.
this.messageArea.find(SELECTORS.SELECTEDVIEWCONVERSATION).removeClass('selected');
this._showMessagingArea();
};
/**
-39
View File
@@ -129,21 +129,6 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
this._searchArea = this._searchAreas.MESSAGES;
this._setPlaceholderText('searchmessages');
}.bind(this));
this.messageArea.onCustomEvent(Events.CHOOSEMESSAGESTODELETE, function() {
this._hideSearchResults();
this._searchArea = this._searchAreas.MESSAGES;
this._setPlaceholderText('searchmessages');
this._disableSearching();
}.bind(this));
this.messageArea.onCustomEvent(Events.CANCELDELETEMESSAGES, function() {
this._enableSearching();
}.bind(this));
this.messageArea.onCustomEvent(Events.CONVERSATIONDELETED, function() {
this._enableSearching();
}.bind(this));
this.messageArea.onCustomEvent(Events.MESSAGESDELETED, function() {
this._enableSearching();
}.bind(this));
// Event listeners for scrolling through messages and users in courses.
CustomEvents.define(this.messageArea.find(SELECTORS.SEARCHRESULTSAREA), [
@@ -430,29 +415,5 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
this.messageArea.find(SELECTORS.SEARCHRESULTSAREA).hide();
};
/**
* Disable search.
*
* @private
*/
Search.prototype._disableSearching = function() {
this.messageArea.find(SELECTORS.SEARCHBOX).prop('disabled', true);
if (this._searchArea == this._searchAreas.MESSAGES) {
this.messageArea.trigger(Events.MESSAGESEARCHCANCELED);
} else if (this._searchArea == this._searchAreas.USERS) {
this.messageArea.trigger(Events.USERSSEARCHCANCELED);
}
};
/**
* Enable search.
*
* @private
*/
Search.prototype._enableSearching = function() {
this.messageArea.find(SELECTORS.SEARCHBOX).prop('disabled', false);
};
return Search;
});
-23
View File
@@ -41,9 +41,6 @@ define(['core/custom_interaction_events', 'core_message/message_area_events'], f
this._init();
}
/** @type {Boolean} checks if we are currently deleting */
Tabs.prototype._isDeleting = false;
/** @type {Messagearea} The messaging area object. */
Tabs.prototype.messageArea = null;
@@ -92,18 +89,6 @@ define(['core/custom_interaction_events', 'core_message/message_area_events'], f
this.messageArea.onDelegateEvent(CustomEvents.events.ctrlPageDown, SELECTORS.CONTACTSPANELS,
this._toggleTabs.bind(this));
this.messageArea.onCustomEvent(Events.CHOOSEMESSAGESTODELETE, function() {
this._isDeleting = true;
}.bind(this));
this.messageArea.onCustomEvent(Events.MESSAGESDELETED, function() {
this._isDeleting = false;
}.bind(this));
this.messageArea.onCustomEvent(Events.CONVERSATIONDELETED, function() {
this._isDeleting = false;
}.bind(this));
this.messageArea.onCustomEvent(Events.CANCELDELETEMESSAGES, function() {
this._isDeleting = false;
}.bind(this));
this.messageArea.onCustomEvent(Events.MESSAGESENT, function() {
this._selectTab(SELECTORS.VIEWCONVERSATIONS, SELECTORS.VIEWCONTACTS);
}.bind(this));
@@ -115,10 +100,6 @@ define(['core/custom_interaction_events', 'core_message/message_area_events'], f
* @private
*/
Tabs.prototype._viewConversations = function() {
if (this._isDeleting) {
return;
}
this.messageArea.trigger(Events.CONVERSATIONSSELECTED);
this._selectTab(SELECTORS.VIEWCONVERSATIONS, SELECTORS.VIEWCONTACTS);
};
@@ -129,10 +110,6 @@ define(['core/custom_interaction_events', 'core_message/message_area_events'], f
* @private
*/
Tabs.prototype._viewContacts = function() {
if (this._isDeleting) {
return;
}
this.messageArea.trigger(Events.CONTACTSSELECTED);
this._selectTab(SELECTORS.VIEWCONTACTS, SELECTORS.VIEWCONVERSATIONS);
};