Merge branch 'MDL-56380_master' of git://github.com/markn86/moodle

This commit is contained in:
David Monllao 2016-10-24 10:04:45 +08:00
commit 40e342718b
2 changed files with 25 additions and 7 deletions

View File

@ -1 +1 @@
define(["jquery","core/ajax","core/templates","core/notification","core/str","core/config","core/custom_interaction_events","core_message/message_area_events"],function(a,b,c,d,e,f,g,h){function i(a){this.messageArea=a,this._init()}var j={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']",SHOWCONTACTS:"[data-action='show-contacts']",MESSAGESAREA:"[data-region='messages-area']",MESSAGINGAREA:"[data-region='messaging-area']"};return i.prototype.messageArea=null,i.prototype._init=function(){g.define(this.messageArea.node,[g.events.activate]),this.messageArea.onCustomEvent(h.CONTACTSELECTED,this._viewProfile.bind(this)),this.messageArea.onDelegateEvent(g.events.activate,j.PROFILEVIEW,this._viewFullProfile.bind(this)),this.messageArea.onDelegateEvent(g.events.activate,j.PROFILESENDMESSAGE,this._sendMessage.bind(this)),this.messageArea.onDelegateEvent(g.events.activate,j.PROFILEUNBLOCKCONTACT,this._unblockContact.bind(this)),this.messageArea.onDelegateEvent(g.events.activate,j.PROFILEBLOCKCONTACT,this._blockContact.bind(this)),this.messageArea.onDelegateEvent(g.events.activate,j.PROFILEADDCONTACT,this._addContact.bind(this)),this.messageArea.onDelegateEvent(g.events.activate,j.PROFILEREMOVECONTACT,this._removeContact.bind(this)),this.messageArea.onDelegateEvent(g.events.activate,j.SHOWCONTACTS,this._hideMessagingArea.bind(this))},i.prototype._viewProfile=function(a,e){c.render("core/loading",{}).done(function(a,b){c.replaceNodeContents(this.messageArea.find(j.MESSAGESAREA),a,b)}.bind(this));var f=b.call([{methodname:"core_message_data_for_messagearea_get_profile",args:{currentuserid:this.messageArea.getCurrentUserId(),otheruserid:e}}]);return f[0].then(function(a){return c.render("core_message/message_area_profile",a)}).then(function(a,b){c.replaceNodeContents(this.messageArea.find(j.MESSAGESAREA),a,b)}.bind(this)).fail(d.exception)},i.prototype._viewFullProfile=function(){window.location.href=f.wwwroot+"/user/profile.php?id="+this._getUserId()},i.prototype._sendMessage=function(){this.messageArea.trigger(h.SENDMESSAGE,this._getUserId())},i.prototype._blockContact=function(){var a=this._performAction("core_message_block_contacts","unblockcontact","profile-block-contact","profile-unblock-contact","");return a.then(function(){this.messageArea.trigger(h.CONTACTBLOCKED,this._getUserId())}.bind(this))},i.prototype._unblockContact=function(){var a=this._performAction("core_message_unblock_contacts","blockcontact","profile-unblock-contact","profile-block-contact","danger");return a.then(function(){this.messageArea.trigger(h.CONTACTUNBLOCKED,this._getUserId())}.bind(this))},i.prototype._addContact=function(){var a=this._performAction("core_message_create_contacts","removecontact","profile-add-contact","profile-remove-contact","danger");return a.then(function(){this.messageArea.trigger(h.CONTACTADDED,this._getUserId())}.bind(this))},i.prototype._removeContact=function(){var a=this._performAction("core_message_delete_contacts","addcontact","profile-remove-contact","profile-add-contact","");return a.then(function(){this.messageArea.trigger(h.CONTACTREMOVED,this._getUserId())}.bind(this))},i.prototype._performAction=function(a,c,f,g,h){var i=b.call([{methodname:a,args:{userid:this.messageArea.getCurrentUserId(),userids:[this._getUserId()]}}]);return i[0].then(function(){return e.get_string(c,"message")}).then(function(a){this._changeText(a,f,g,h)}.bind(this)).fail(d.exception)},i.prototype._changeText=function(a,b,c,d){var e=this.messageArea.find("[data-action='"+b+"']");e.text(a),e.removeClass(),d&&e.addClass(d),e.attr("data-action",c)},i.prototype._getUserId=function(){return this.messageArea.find(j.PROFILE).data("userid")},i.prototype._hideMessagingArea=function(){this.messageArea.find(j.MESSAGINGAREA).removeClass("show-messages").addClass("hide-messages")},i});
define(["jquery","core/ajax","core/templates","core/notification","core/str","core/config","core/custom_interaction_events","core_message/message_area_events"],function(a,b,c,d,e,f,g,h){function i(a){this.messageArea=a,this._init()}var j={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']",SHOWCONTACTS:"[data-action='show-contacts']",MESSAGESAREA:"[data-region='messages-area']",MESSAGINGAREA:"[data-region='messaging-area']"};return i.prototype.messageArea=null,i.prototype._init=function(){g.define(this.messageArea.node,[g.events.activate]),this.messageArea.onCustomEvent(h.CONTACTSELECTED,this._viewProfile.bind(this)),this.messageArea.onDelegateEvent(g.events.activate,j.PROFILEVIEW,function(a,b){this._viewFullProfile(),b.originalEvent.preventDefault()}.bind(this)),this.messageArea.onDelegateEvent(g.events.activate,j.PROFILESENDMESSAGE,function(a,b){this._sendMessage(),b.originalEvent.preventDefault()}.bind(this)),this.messageArea.onDelegateEvent(g.events.activate,j.PROFILEUNBLOCKCONTACT,function(a,b){this._unblockContact(),b.originalEvent.preventDefault()}.bind(this)),this.messageArea.onDelegateEvent(g.events.activate,j.PROFILEBLOCKCONTACT,function(a,b){this._blockContact(),b.originalEvent.preventDefault()}.bind(this)),this.messageArea.onDelegateEvent(g.events.activate,j.PROFILEADDCONTACT,function(a,b){this._addContact(),b.originalEvent.preventDefault()}.bind(this)),this.messageArea.onDelegateEvent(g.events.activate,j.PROFILEREMOVECONTACT,function(a,b){this._removeContact(),b.originalEvent.preventDefault()}.bind(this)),this.messageArea.onDelegateEvent(g.events.activate,j.SHOWCONTACTS,this._hideMessagingArea.bind(this))},i.prototype._viewProfile=function(a,e){c.render("core/loading",{}).done(function(a,b){c.replaceNodeContents(this.messageArea.find(j.MESSAGESAREA),a,b)}.bind(this));var f=b.call([{methodname:"core_message_data_for_messagearea_get_profile",args:{currentuserid:this.messageArea.getCurrentUserId(),otheruserid:e}}]);return f[0].then(function(a){return c.render("core_message/message_area_profile",a)}).then(function(a,b){c.replaceNodeContents(this.messageArea.find(j.MESSAGESAREA),a,b)}.bind(this)).fail(d.exception)},i.prototype._viewFullProfile=function(){window.location.href=f.wwwroot+"/user/profile.php?id="+this._getUserId()},i.prototype._sendMessage=function(){this.messageArea.trigger(h.SENDMESSAGE,this._getUserId())},i.prototype._blockContact=function(){var a=this._performAction("core_message_block_contacts","unblockcontact","profile-block-contact","profile-unblock-contact","");return a.then(function(){this.messageArea.trigger(h.CONTACTBLOCKED,this._getUserId())}.bind(this))},i.prototype._unblockContact=function(){var a=this._performAction("core_message_unblock_contacts","blockcontact","profile-unblock-contact","profile-block-contact","danger");return a.then(function(){this.messageArea.trigger(h.CONTACTUNBLOCKED,this._getUserId())}.bind(this))},i.prototype._addContact=function(){var a=this._performAction("core_message_create_contacts","removecontact","profile-add-contact","profile-remove-contact","danger");return a.then(function(){this.messageArea.trigger(h.CONTACTADDED,this._getUserId())}.bind(this))},i.prototype._removeContact=function(){var a=this._performAction("core_message_delete_contacts","addcontact","profile-remove-contact","profile-add-contact","");return a.then(function(){this.messageArea.trigger(h.CONTACTREMOVED,this._getUserId())}.bind(this))},i.prototype._performAction=function(a,c,f,g,h){var i=b.call([{methodname:a,args:{userid:this.messageArea.getCurrentUserId(),userids:[this._getUserId()]}}]);return i[0].then(function(){return e.get_string(c,"message")}).then(function(a){this._changeText(a,f,g,h)}.bind(this)).fail(d.exception)},i.prototype._changeText=function(a,b,c,d){var e=this.messageArea.find("[data-action='"+b+"']");e.text(a),e.removeClass(),d&&e.addClass(d),e.attr("data-action",c)},i.prototype._getUserId=function(){return this.messageArea.find(j.PROFILE).data("userid")},i.prototype._hideMessagingArea=function(){this.messageArea.find(j.MESSAGINGAREA).removeClass("show-messages").addClass("hide-messages")},i});

View File

@ -64,17 +64,35 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
this.messageArea.onCustomEvent(Events.CONTACTSELECTED, this._viewProfile.bind(this));
this.messageArea.onDelegateEvent(CustomEvents.events.activate, SELECTORS.PROFILEVIEW,
this._viewFullProfile.bind(this));
function(e, data) {
this._viewFullProfile();
data.originalEvent.preventDefault();
}.bind(this));
this.messageArea.onDelegateEvent(CustomEvents.events.activate, SELECTORS.PROFILESENDMESSAGE,
this._sendMessage.bind(this));
function(e, data) {
this._sendMessage();
data.originalEvent.preventDefault();
}.bind(this));
this.messageArea.onDelegateEvent(CustomEvents.events.activate, SELECTORS.PROFILEUNBLOCKCONTACT,
this._unblockContact.bind(this));
function(e, data) {
this._unblockContact();
data.originalEvent.preventDefault();
}.bind(this));
this.messageArea.onDelegateEvent(CustomEvents.events.activate, SELECTORS.PROFILEBLOCKCONTACT,
this._blockContact.bind(this));
function(e, data) {
this._blockContact();
data.originalEvent.preventDefault();
}.bind(this));
this.messageArea.onDelegateEvent(CustomEvents.events.activate, SELECTORS.PROFILEADDCONTACT,
this._addContact.bind(this));
function(e, data) {
this._addContact();
data.originalEvent.preventDefault();
}.bind(this));
this.messageArea.onDelegateEvent(CustomEvents.events.activate, SELECTORS.PROFILEREMOVECONTACT,
this._removeContact.bind(this));
function(e, data) {
this._removeContact();
data.originalEvent.preventDefault();
}.bind(this));
this.messageArea.onDelegateEvent(CustomEvents.events.activate, SELECTORS.SHOWCONTACTS,
this._hideMessagingArea.bind(this));
};