MDL-62781 question/privacy: fix tests with CodeRunner is installed
[moodle.git] / message / amd / build / message_area_tabs.min.js
blob9c3daf335cbf7c7ad3f2977bb9a43c2f78ffe067
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.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});