Current Path : C:/Users/Mahmood/Desktop/moodle8/user/amd/build/ |
Current File : C:/Users/Mahmood/Desktop/moodle8/user/amd/build/participants.min.js |
define ("core_user/participants",["jquery","core/str","core/modal_factory","core/modal_events","core/templates","core/notification","core/ajax"],function(a,b,c,d,e,f,g){var h={BULKACTIONSELECT:"#formactionid",BULKUSERCHECKBOXES:"input.usercheckbox",BULKUSERNOSCHECKBOXES:"input.usercheckbox[value='0']",BULKUSERSELECTEDCHECKBOXES:"input.usercheckbox:checked",BULKACTIONFORM:"#participantsform",CHECKALLBUTTON:"#checkall",CHECKALLNOSBUTTON:"#checkallnos"},i=function(a){this.courseId=a.courseid;this.noteStateNames=a.noteStateNames;this.stateHelpIcon=a.stateHelpIcon;this.attachEventListeners()};i.prototype.modal=null;i.prototype.courseId=-1;i.prototype.noteStateNames={};i.prototype.stateHelpIcon="";i.prototype.attachEventListeners=function(){a(h.BULKACTIONSELECT).on("change",function(b){var c=a(b.target).val();if(-1!==c.indexOf("#")){b.preventDefault();var d=[];a(h.BULKUSERSELECTEDCHECKBOXES).each(function(b,c){var e=a(c).attr("name"),f=e.replace("user","");d.push(f)});if("#messageselect"==c){this.showSendMessage(d).fail(f.exception)}else if("#addgroupnote"==c){this.showAddNote(d).fail(f.exception)}a(h.BULKACTIONSELECT+" option[value=\"\"]").prop("selected","selected")}else if(""!==c){if(0<a(h.BULKUSERSELECTEDCHECKBOXES).length){a(h.BULKACTIONFORM).submit()}else{a(h.BULKACTIONSELECT+" option[value=\"\"]").prop("selected","selected")}}}.bind(this));a(h.CHECKALLBUTTON).on("click",function(){var b=a(this).data("showallink");if(b){window.location=b}});a(h.CHECKALLNOSBUTTON).on("click",function(){a(h.BULKUSERNOSCHECKBOXES).prop("checked",!0)})};i.prototype.showAddNote=function(f){if(0==f.length){return a.Deferred().resolve().promise()}var g=[];for(var i in this.noteStateNames){switch(i){case"draft":g.push({value:"personal",label:this.noteStateNames[i]});break;case"public":g.push({value:"course",label:this.noteStateNames[i],selected:1});break;case"site":g.push({value:i,label:this.noteStateNames[i]});break;}}var j={stateNames:g,stateHelpIcon:this.stateHelpIcon},k=null;if(1==f.length){k=b.get_string("addbulknotesingle","core_notes")}else{k=b.get_string("addbulknote","core_notes",f.length)}return a.when(c.create({type:c.types.SAVE_CANCEL,body:e.render("core_user/add_bulk_note",j)}),k).then(function(b,c){this.modal=b;this.modal.setTitle(c);this.modal.setSaveButtonText(c);this.modal.getRoot().on(d.hidden,function(){var b=a("#user-notifications [role=alert]");if(b.length){b.focus()}else{a(h.BULKACTIONSELECT).focus()}this.modal.getRoot().remove()}.bind(this));this.modal.getRoot().on(d.save,this.submitAddNote.bind(this,f));this.modal.show();return this.modal}.bind(this))};i.prototype.submitAddNote=function(a){var c=this.modal.getRoot().find("form textarea").val(),d=this.modal.getRoot().find("form select").val(),e=[],h=0;for(h=0;h<a.length;h++){e.push({userid:a[h],text:c,courseid:this.courseId,publishstate:d})}return g.call([{methodname:"core_notes_create_notes",args:{notes:e}}])[0].then(function(a){if(1==a.length){return b.get_string("addbulknotedonesingle","core_notes")}else{return b.get_string("addbulknotedone","core_notes",a.length)}}).then(function(a){f.addNotification({message:a,type:"success"});return!0}).catch(f.exception)};i.prototype.showSendMessage=function(f){if(0==f.length){return a.Deferred().resolve().promise()}var g=null;if(1==f.length){g=b.get_string("sendbulkmessagesingle","core_message")}else{g=b.get_string("sendbulkmessage","core_message",f.length)}return a.when(c.create({type:c.types.SAVE_CANCEL,body:e.render("core_user/send_bulk_message",{})}),g).then(function(b,c){this.modal=b;this.modal.setTitle(c);this.modal.setSaveButtonText(c);this.modal.getRoot().on(d.hidden,function(){a(h.BULKACTIONSELECT).focus();this.modal.getRoot().remove()}.bind(this));this.modal.getRoot().on(d.save,this.submitSendMessage.bind(this,f));this.modal.show();return this.modal}.bind(this))};i.prototype.submitSendMessage=function(a){var c=this.modal.getRoot().find("form textarea").val(),d=[],e=0;for(e=0;e<a.length;e++){d.push({touserid:a[e],text:c})}return g.call([{methodname:"core_message_send_instant_messages",args:{messages:d}}])[0].then(function(a){if(1==a.length){return b.get_string("sendbulkmessagesentsingle","core_message")}else{return b.get_string("sendbulkmessagesent","core_message",a.length)}}).then(function(a){f.addNotification({message:a,type:"success"});return!0}).catch(f.exception)};return{init:function init(a){return new i(a)}}}); //# sourceMappingURL=participants.min.js.map