[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 YUI.add("moodle-core_message-messenger",function(e,t){var n={},r={};r.MANAGER={SENDMESSAGE:'[data-trigger="core_message-messenger::sendmessage"]'};var i=function(){i.superclass.constructor.apply(this,arguments)};e.namespace("M.core_message.messenger").Manager=e.extend(i,e.Base,{_sendMessageDialog:null,_events:[],initializer:function(){this._setEvents()},sendMessage:function(t,n,r){var i;this._sendMessageDialog||(i=e.namespace("M.core_message.messenger.sendMessage"),this._sendMessageDialog=new i({url:this.get("url")})),this._sendMessageDialog.prepareForUser(t,n),this._sendMessageDialog.show(r)},alertBlocked:function(e,t){new M.core.alert({title:M.util.get_string("error","core"),message:M.util.get_string(e,"message",t)})},_setEvents:function(){var t=function(e){var t=e.currentTarget,n=parseInt(t.getData("userid"),10),r=t.getData("fullname"),i=t.getData("blocked-string");if(!n||!r)return;e.preventDefault(),i?this.alertBlocked(i,r):this.sendMessage(n,r,e)};this._events.push(e.delegate("click",t,"body",r.MANAGER.SENDMESSAGE,this)),this._events.push(e.one(e.config.doc).delegate("key",t,"space",r.MANAGER.SENDMESSAGE,this))}},{NAME:"core_message-messenger-manager",ATTRS:{url:{readonly:!0,value:M.cfg.wwwroot+"/message/ajax.php"}}});var s;e.namespace("M.core_message.messenger").init=function(e){return s||(s=new i(e)),s},n.SENDMSGDIALOG={ACCESSHIDE:"accesshide",ACTIONS:"message-actions",FOOTER:"message-footer",HIDDEN:"hidden",HISTORYLINK:"message-history",INPUT:"message-input",INPUTAREA:"message-area",NOTICE:"message-notice",NOTICEAREA:"message-notice-area",PREFIX:"core_message-messenger-sendmessage",SENDBTN:"message-send",WRAPPER:"message-wrapper"},r.SENDMSGDIALOG={FORM:"form",HISTORYLINK:".message-history",INPUT:".message-input",NOTICE:".message-notice div",NOTICEAREA:".message-notice-area",SENDBTN:".message-send"};var o=function(){o.superclass.constructor.apply(this,arguments)};e.namespace("M.core_message.messenger").sendMessage=e.extend(o,M.core.dialogue,{_bb:null,_sendLock:!1,_hide:null,initializer:function(){var t,r;this._bb=this.get("boundingBox"),this._hide=this.hide,t=e.Handlebars.compile('<form action="#" id="messageform"><div class="{{CSSR.INPUTAREA}}"><label class="{{CSSR.ACCESSHIDE}}" for="{{id}}">{{labelStr}}</label><textarea class="{{CSSR.INPUT}}" id="{{id}}"></textarea><div class="{{CSSR.NOTICEAREA}}" style="display: none;" aria-live="assertive"><div class="{{CSSR.NOTICE}}"><div></div></div></div></div><div class="{{CSSR.ACTIONS}}"><input type="submit" value="{{sendStr}}" class="{{CSSR.SENDBTN}}"><a href="#" class="{{CSSR.HISTORYLINK}}">{{viewHistoryStr}}</a><div style="clear: both;"></div></div></form>'),r=e.Node.create(t({CSSR:n.SENDMSGDIALOG,id:e.guid(),labelStr:M.util.get_string("messagetosend","core_message"),loadingIcon:M.util.image_url("i/loading","moodle"),sendStr:M.util.get_string("sendmessage","core_message"),viewHistoryStr:M.util.get_string("viewconversation","core_message")})),this.setStdModContent(e.WidgetStdMod.BODY,r,e.WidgetStdMod.REPLACE),this._bb.one(".moodle-dialogue-wrap").addClass("moodle-dialogue-content"),this._setEvents()},prepareForUser:function(t,n){var i;this.set("userid",t),this.set("fullname",n),i=e.Node.create("<h1>"+e.Escape.html(n)+"</h1>"),this.setStdModContent(e.WidgetStdMod.HEADER,i,e.WidgetStdMod.REPLACE),this._bb.one(r.SENDMSGDIALOG.HISTORYLINK).set("href",M.cfg.wwwroot+"/message/index.php?id="+this.get("userid")),this._bb.one(r.SENDMSGDIALOG.INPUT).set("value",""),e.use("moodle-core-formchangechecker",function(){M.core_formchangechecker.init({formid:"messageform"})})},sendMessage:function(t){if(this._sendLock)return;if(!t||!this._validateMessage(t))return;this._ioSend=e.io(this.get("url"),{method:"POST",data:{sesskey:M.cfg.sesskey,action:"sendmessage",userid:this.get("userid"),message:t},on:{start:function(){var e='<img alt="" role="presentation" src="'+M.util.image_url("i/loading_small","moodle")+'">';this.setSendLock(!0),this.showNotice(e+" "+M.util.get_string("sendingmessage","core_message"))},success:function(t,n){var r=null;try{r=e.JSON.parse(n.responseText);if(r.error){this.hideNotice(),new M.core.ajaxException(r);return}}catch(i){this.hideNotice(),new M.core.exception(i);return}this.showNotice(M.util.get_string("messagesent","core_message")),e.later(1300,this,function(){this.setSendLock(!1),this.hideNotice(),this.hide()})},failure:function(){this.setSendLock(!1),this.hideNotice(),new M.core.alert({title:M.util.get_string("error","core"),message:M.util.get_string("errorwhilesendingmessage","core_message")})}},context:this})},hide:function(){var t=this;if(!M.core_formchangechecker.get_form_dirty_state())return o.superclass.hide.call(this,arguments);e.use("moodle-core-notification-confirm",function(){var e=new M.core.confirm({title:M.util.get_string("confirm","moodle"),question:M.util.get_string("changesmadereallygoaway","moodle"),yesLabel:M.util.get_string("confirm","moodle"),noLabel:M.util.get_string("cancel","moodle")});e.on("complete-yes",function(){return M.core_formchangechecker.reset_form_dirty_state(),e.hide(),e.destroy(),o.superclass.hide.call(this,arguments)},t)})},hideNotice:function(){this._bb.one(r.SENDMSGDIALOG.NOTICEAREA).hide()},showNotice:function(e){this._bb.one(r.SENDMSGDIALOG.NOTICE).setHTML(e),this._bb.one(r.SENDMSGDIALOG.NOTICEAREA).show()},setSendLock:function(e){e?this._sendLock=!0:this._sendLock=!1},_setEvents:function(){this._bb.one(r.SENDMSGDIALOG.FORM).on("submit",function(e){var t=this._bb.one(r.SENDMSGDIALOG.INPUT).get("value");e.preventDefault(),this.sendMessage(t)},this)},_validateMessage:function(e){var t;return e?(t=e.replace(" ","").replace(" ","").replace(/(<br\s*\/?>(<\/br\s*\/?>)?)+/,"").trim(),t.length>1):!1}},{NAME:"core_message-messenger-sendmessage",CSS_PREFIX:n.SENDMSGDIALOG.PREFIX,ATTRS:{fullname:{validator:e.Lang.isString,value:""},url:{validator:e.Lang.isString,value:null},userid:{validator:e.Lang.isNumber,value:0}}}),e.Base.modifyAttrs(e.namespace("M.core_message.messenger.sendMessage"),{extraClasses 2 :{value:["core_message-messenger-sendmessage"]},focusOnPreviousTargetAfterHide:{value:!0},width:{value:"360px"},visible:{value:!1},modal:{value:!0},draggable:{value:!1},center:{value:!0}})},"@VERSION@",{requires:["escape","handlebars","io-base","moodle-core-notification-ajaxexception","moodle-core-notification-alert","moodle-core-notification-dialogue","moodle-core-notification-exception"]});
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |