first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
/**
* Module for viewing a discussion.
*
* @module mod_forum/discussion
* @copyright 2019 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("mod_forum/discussion",["jquery","core/custom_interaction_events","mod_forum/selectors","core/pubsub","mod_forum/forum_events","core/str","core/notification"],(function($,CustomEvents,Selectors,PubSub,ForumEvents,String,Notification){var isElementInInPageReplySection=function(element){return!!$(element).closest(Selectors.post.inpageReplyContent).length},initAccessibilityKeyboardNav=function(root){root.find(Selectors.post.post).each((function(index,post){var actions=$(post).find(Selectors.post.action),firstAction=actions.first();actions.attr("tabindex","-1"),firstAction.attr("tabindex",0)})),CustomEvents.define(root,[CustomEvents.events.up,CustomEvents.events.down,CustomEvents.events.next,CustomEvents.events.previous,CustomEvents.events.home,CustomEvents.events.end]),root.on(CustomEvents.events.up,(function(e,data){var activeElement=document.activeElement;if(!isElementInInPageReplySection(activeElement)){var focusPost=$(activeElement).closest(Selectors.post.post);focusPost.length?function(currentPost){var prevPost=currentPost.prev(Selectors.post.post);if(prevPost.length){var replyPost=prevPost.find(Selectors.post.post).last();replyPost.length?replyPost.focus():prevPost.focus()}else currentPost.parents(Selectors.post.post).first().focus()}(focusPost):root.find(Selectors.post.post).first().focus(),data.originalEvent.preventDefault()}})),root.on(CustomEvents.events.down,(function(e,data){var activeElement=document.activeElement;if(!isElementInInPageReplySection(activeElement)){var focusPost=$(activeElement).closest(Selectors.post.post);focusPost.length?function(currentPost){var replyPost=currentPost.find(Selectors.post.post).first();if(replyPost.length)replyPost.focus();else{var siblingPost=currentPost.next(Selectors.post.post);if(siblingPost.length)siblingPost.focus();else for(var parentPosts=currentPost.parents(Selectors.post.post).toArray(),i=0;i<parentPosts.length;i++){var ancestorSiblingPost=$(parentPosts[i]).next(Selectors.post.post);if(ancestorSiblingPost.length){ancestorSiblingPost.focus();break}}}}(focusPost):root.find(Selectors.post.post).first().focus(),data.originalEvent.preventDefault()}})),root.on(CustomEvents.events.home,(function(e,data){isElementInInPageReplySection(document.activeElement)||(root.find(Selectors.post.post).first().focus(),data.originalEvent.preventDefault())})),root.on(CustomEvents.events.end,(function(e,data){isElementInInPageReplySection(document.activeElement)||(root.find(Selectors.post.post).last().focus(),data.originalEvent.preventDefault())})),root.on(CustomEvents.events.next,Selectors.post.action,(function(e,data){var currentAction=$(e.target),actions=currentAction.closest(Selectors.post.actionsContainer).find(Selectors.post.action),nextAction=currentAction.next(Selectors.post.action);actions.attr("tabindex","-1"),nextAction.length||(nextAction=actions.first()),nextAction.attr("tabindex",0),nextAction.focus(),data.originalEvent.preventDefault()})),root.on(CustomEvents.events.previous,Selectors.post.action,(function(e,data){var currentAction=$(e.target),actions=currentAction.closest(Selectors.post.actionsContainer).find(Selectors.post.action),nextAction=currentAction.prev(Selectors.post.action);actions.attr("tabindex","-1"),nextAction.length||(nextAction=actions.last()),nextAction.attr("tabindex",0),nextAction.focus(),data.originalEvent.preventDefault()})),root.on(CustomEvents.events.home,Selectors.post.action,(function(e,data){var actions=$(e.target).closest(Selectors.post.actionsContainer).find(Selectors.post.action),firstAction=actions.first();actions.attr("tabindex","-1"),firstAction.attr("tabindex",0),firstAction.focus(),e.stopPropagation(),data.originalEvent.preventDefault()})),root.on(CustomEvents.events.end,Selectors.post.action,(function(e,data){var actions=$(e.target).closest(Selectors.post.actionsContainer).find(Selectors.post.action),lastAction=actions.last();actions.attr("tabindex","-1"),lastAction.attr("tabindex",0),lastAction.focus(),e.stopPropagation(),data.originalEvent.preventDefault()})),PubSub.subscribe(ForumEvents.SUBSCRIPTION_TOGGLED,(function(data){var updateMessage=data.subscriptionState?"discussionsubscribed":"discussionunsubscribed";String.get_string(updateMessage,"forum").then((function(s){return Notification.addNotification({message:s,type:"info"})})).catch(Notification.exception)}))};return{init:function(root){initAccessibilityKeyboardNav(root)}}}));
//# sourceMappingURL=discussion.min.js.map
File diff suppressed because one or more lines are too long
+10
View File
@@ -0,0 +1,10 @@
/**
* Module for the list of discussions on when viewing a forum.
*
* @module mod_forum/discussion_list
* @copyright 2019 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("mod_forum/discussion_list",["jquery","core/templates","core/str","core/notification","mod_forum/subscription_toggle","mod_forum/selectors","mod_forum/repository","core/pubsub","mod_forum/forum_events","core_form/changechecker"],(function($,Templates,Str,Notification,SubscriptionToggle,Selectors,Repository,PubSub,ForumEvents,FormChangeChecker){return{init:function(root){SubscriptionToggle.init(root,!1,(function(toggleElement,context){var toggleId=toggleElement.attr("id"),newTargetState=context.userstate.subscribed?0:1;toggleElement.data("targetstate",newTargetState);var stringKey=context.userstate.subscribed?"unsubscribediscussion":"subscribediscussion";return Str.get_string(stringKey,"mod_forum").then((function(string){return toggleElement.closest("td").find('label[for="'+toggleId+'"]').find("span").text(string),string}))})),function(root){PubSub.subscribe(ForumEvents.SUBSCRIPTION_TOGGLED,(function(data){var discussionId=data.discussionId,subscribed=data.subscriptionState,discussionListItem=root.find(Selectors.discussion.item+"[data-discussionid= "+discussionId+"]"),subscribedLabel=discussionListItem.find(Selectors.discussion.subscribedLabel);subscribed?(discussionListItem.addClass("subscribed"),subscribedLabel.removeAttr("hidden")):(discussionListItem.removeClass("subscribed"),subscribedLabel.attr("hidden",!0))})),root.on("click",Selectors.post.inpageCancelButton,(function(e){FormChangeChecker.resetFormDirtyState(e.currentTarget)})),root.on("click",Selectors.favourite.toggle,(function(e){e.preventDefault();var toggleElement=$(this),forumId=toggleElement.data("forumid"),discussionId=toggleElement.data("discussionid"),subscriptionState=toggleElement.data("targetstate");Repository.setFavouriteDiscussionState(forumId,discussionId,subscriptionState).then((function(){return location.reload()})).catch(Notification.exception)})),root.on("click",Selectors.pin.toggle,(function(e){e.preventDefault();var toggleElement=$(this),forumId=toggleElement.data("forumid"),discussionId=toggleElement.data("discussionid"),state=toggleElement.data("targetstate");Repository.setPinDiscussionState(forumId,discussionId,state).then((function(){return location.reload()})).catch(Notification.exception)})),root.on("click",Selectors.lock.toggle,(function(e){var toggleElement=$(this),forumId=toggleElement.data("forumid"),discussionId=toggleElement.data("discussionid"),state=toggleElement.data("state");Repository.setDiscussionLockState(forumId,discussionId,state).then((function(context){var icon=toggleElement.parents(Selectors.summary.actions).find(Selectors.lock.icon),lockedLabel=toggleElement.parents(Selectors.discussion.item).find(Selectors.discussion.lockedLabel);return context.locked?(icon.removeClass("hidden"),lockedLabel.removeAttr("hidden")):(icon.addClass("hidden"),lockedLabel.attr("hidden",!0)),context})).then((function(context){return context.forumid=forumId,Templates.render("mod_forum/discussion_lock_toggle",context)})).then((function(html,js){return Templates.replaceNode(toggleElement,html,js)})).then((function(){return Str.get_string("lockupdated","forum").done((function(s){return Notification.addNotification({message:s,type:"info"})}))})).catch(Notification.exception),e.preventDefault()}))}(root)}}}));
//# sourceMappingURL=discussion_list.min.js.map
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+11
View File
@@ -0,0 +1,11 @@
/**
* Handle discussion subscription toggling on a discussion list in
* the forum view.
*
* @module mod_forum/favourite_toggle
* @copyright 2019 Peter Dias <peter@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("mod_forum/favourite_toggle",["jquery","core/templates","core/notification","mod_forum/repository","mod_forum/selectors","core/str"],(function($,Templates,Notification,Repository,Selectors,String){return{init:function(root,preventDefault,callback){root.on("click",Selectors.favourite.toggle,(function(e){var toggleElement=$(this),forumId=toggleElement.data("forumid"),discussionId=toggleElement.data("discussionid"),subscriptionState=toggleElement.data("targetstate");Repository.setFavouriteDiscussionState(forumId,discussionId,subscriptionState).then((function(context){return callback(toggleElement,context)})).then((function(){return String.get_string("favouriteupdated","forum").done((function(s){return Notification.addNotification({message:s,type:"info"})}))})).catch(Notification.exception),preventDefault&&e.preventDefault()}))}}}));
//# sourceMappingURL=favourite_toggle.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"favourite_toggle.min.js","sources":["../src/favourite_toggle.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Handle discussion subscription toggling on a discussion list in\n * the forum view.\n *\n * @module mod_forum/favourite_toggle\n * @copyright 2019 Peter Dias <peter@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/templates',\n 'core/notification',\n 'mod_forum/repository',\n 'mod_forum/selectors',\n 'core/str',\n ], function(\n $,\n Templates,\n Notification,\n Repository,\n Selectors,\n String\n ) {\n\n /**\n * Register event listeners for the subscription toggle.\n *\n * @param {object} root The discussion list root element\n * @param {boolean} preventDefault Should the default action of the event be prevented\n * @param {function} callback Success callback\n */\n var registerEventListeners = function(root, preventDefault, callback) {\n root.on('click', Selectors.favourite.toggle, function(e) {\n var toggleElement = $(this);\n var forumId = toggleElement.data('forumid');\n var discussionId = toggleElement.data('discussionid');\n var subscriptionState = toggleElement.data('targetstate');\n\n Repository.setFavouriteDiscussionState(forumId, discussionId, subscriptionState)\n .then(function(context) {\n return callback(toggleElement, context);\n })\n .then(function() {\n return String.get_string(\"favouriteupdated\", \"forum\")\n .done(function(s) {\n return Notification.addNotification({\n message: s,\n type: \"info\"\n });\n });\n })\n .catch(Notification.exception);\n\n if (preventDefault) {\n e.preventDefault();\n }\n });\n };\n\n return {\n init: registerEventListeners\n };\n});\n"],"names":["define","$","Templates","Notification","Repository","Selectors","String","init","root","preventDefault","callback","on","favourite","toggle","e","toggleElement","this","forumId","data","discussionId","subscriptionState","setFavouriteDiscussionState","then","context","get_string","done","s","addNotification","message","type","catch","exception"],"mappings":";;;;;;;;AAuBAA,oCAAO,CACC,SACA,iBACA,oBACA,uBACA,sBACA,aACD,SACCC,EACAC,UACAC,aACAC,WACAC,UACAC,cAsCG,CACHC,KA7ByB,SAASC,KAAMC,eAAgBC,UACxDF,KAAKG,GAAG,QAASN,UAAUO,UAAUC,QAAQ,SAASC,OAC9CC,cAAgBd,EAAEe,MAClBC,QAAUF,cAAcG,KAAK,WAC7BC,aAAeJ,cAAcG,KAAK,gBAClCE,kBAAoBL,cAAcG,KAAK,eAE3Cd,WAAWiB,4BAA4BJ,QAASE,aAAcC,mBACzDE,MAAK,SAASC,gBACJb,SAASK,cAAeQ,YAElCD,MAAK,kBACKhB,OAAOkB,WAAW,mBAAoB,SACxCC,MAAK,SAASC,UACJvB,aAAawB,gBAAgB,CAChCC,QAASF,EACTG,KAAM,eAIrBC,MAAM3B,aAAa4B,WAEpBtB,gBACAK,EAAEL"}
+10
View File
@@ -0,0 +1,10 @@
/**
* Enrolled user selector module.
*
* @module mod_forum/form-user-selector
* @copyright 2019 Shamim Rezaie
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("mod_forum/form-user-selector",["jquery","core/ajax","core/templates"],(function($,Ajax,Templates){return{processResults:function(selector,results){var users=[];return $.each(results,(function(index,user){users.push({value:user.id,label:user._label})})),users},transport:function(selector,query,success,failure){var courseid=$(selector).attr("courseid"),contextid=$(selector).attr("data-contextid");Ajax.call([{methodname:"core_enrol_search_users",args:{courseid:courseid,search:query,searchanywhere:!0,page:0,perpage:30,contextid:contextid}}])[0].then((function(results){var promises=[],i=0;return $.each(results,(function(index,user){promises.push(Templates.render("mod_forum/form-user-selector-suggestion",user))})),$.when.apply($.when,promises).then((function(){var args=arguments;$.each(results,(function(index,user){user._label=args[i],i++})),success(results)}))})).fail(failure)}}}));
//# sourceMappingURL=form-user-selector.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"form-user-selector.min.js","sources":["../src/form-user-selector.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Enrolled user selector module.\n *\n * @module mod_forum/form-user-selector\n * @copyright 2019 Shamim Rezaie\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/ajax', 'core/templates'], function($, Ajax, Templates) {\n return /** @alias module:mod_forum/form-user-selector */ {\n processResults: function(selector, results) {\n var users = [];\n $.each(results, function(index, user) {\n users.push({\n value: user.id,\n label: user._label\n });\n });\n return users;\n },\n\n transport: function(selector, query, success, failure) {\n var promise;\n var courseid = $(selector).attr('courseid');\n var contextid = $(selector).attr('data-contextid');\n\n promise = Ajax.call([{\n methodname: 'core_enrol_search_users',\n args: {\n courseid: courseid,\n search: query,\n searchanywhere: true,\n page: 0,\n perpage: 30,\n contextid: contextid,\n }\n }]);\n\n promise[0].then(function(results) {\n var promises = [],\n i = 0;\n\n // Render the label.\n $.each(results, function(index, user) {\n promises.push(Templates.render('mod_forum/form-user-selector-suggestion', user));\n });\n\n // Apply the label to the results.\n return $.when.apply($.when, promises).then(function() {\n var args = arguments;\n $.each(results, function(index, user) {\n user._label = args[i];\n i++;\n });\n success(results);\n return;\n });\n\n }).fail(failure);\n }\n\n };\n\n});\n"],"names":["define","$","Ajax","Templates","processResults","selector","results","users","each","index","user","push","value","id","label","_label","transport","query","success","failure","courseid","attr","contextid","call","methodname","args","search","searchanywhere","page","perpage","then","promises","i","render","when","apply","arguments","fail"],"mappings":";;;;;;;AAuBAA,sCAAO,CAAC,SAAU,YAAa,mBAAmB,SAASC,EAAGC,KAAMC,iBACP,CACrDC,eAAgB,SAASC,SAAUC,aAC3BC,MAAQ,UACZN,EAAEO,KAAKF,SAAS,SAASG,MAAOC,MAC5BH,MAAMI,KAAK,CACPC,MAAOF,KAAKG,GACZC,MAAOJ,KAAKK,YAGbR,OAGXS,UAAW,SAASX,SAAUY,MAAOC,QAASC,aAEtCC,SAAWnB,EAAEI,UAAUgB,KAAK,YAC5BC,UAAYrB,EAAEI,UAAUgB,KAAK,kBAEvBnB,KAAKqB,KAAK,CAAC,CACjBC,WAAY,0BACZC,KAAM,CACFL,SAAUA,SACVM,OAAQT,MACRU,gBAAgB,EAChBC,KAAM,EACNC,QAAS,GACTP,UAAWA,cAIX,GAAGQ,MAAK,SAASxB,aACjByB,SAAW,GACXC,EAAI,SAGR/B,EAAEO,KAAKF,SAAS,SAASG,MAAOC,MAC5BqB,SAASpB,KAAKR,UAAU8B,OAAO,0CAA2CvB,UAIvET,EAAEiC,KAAKC,MAAMlC,EAAEiC,KAAMH,UAAUD,MAAK,eACnCL,KAAOW,UACXnC,EAAEO,KAAKF,SAAS,SAASG,MAAOC,MAC5BA,KAAKK,OAASU,KAAKO,GACnBA,OAEJd,QAAQZ,eAIb+B,KAAKlB"}
+10
View File
@@ -0,0 +1,10 @@
/**
* Events for the forum activity.
*
* @module mod_forum/forum_events
* @copyright 2019 Jun Pataleta <jun@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("mod_forum/forum_events",[],(function(){return{SUBSCRIPTION_TOGGLED:"mod_forum/subscription_toggle:subscriptionToggled"}}));
//# sourceMappingURL=forum_events.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"forum_events.min.js","sources":["../src/forum_events.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Events for the forum activity.\n *\n * @module mod_forum/forum_events\n * @copyright 2019 Jun Pataleta <jun@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([], function() {\n return {\n SUBSCRIPTION_TOGGLED: 'mod_forum/subscription_toggle:subscriptionToggled',\n };\n});\n"],"names":["define","SUBSCRIPTION_TOGGLED"],"mappings":";;;;;;;AAsBAA,gCAAO,IAAI,iBACA,CACHC,qBAAsB"}
+10
View File
@@ -0,0 +1,10 @@
define("mod_forum/grades/expandconversation",["exports","./grader/selectors","mod_forum/repository","core/notification","core/templates","core/modal_cancel","core/modal_events"],(function(_exports,ForumSelectors,_repository,_notification,_templates,_modal_cancel,ModalEvents){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}return newObj.default=obj,cache&&cache.set(obj,newObj),newObj}
/**
* This module handles the creation of a Modal that shows the user's post in context of the entire discussion.
*
* @module mod_forum/grades/expandconversation
* @copyright 2019 Mathew May <mathew.solutions>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.registerEventListeners=void 0,ForumSelectors=_interopRequireWildcard(ForumSelectors),_repository=_interopRequireDefault(_repository),_templates=_interopRequireDefault(_templates),_modal_cancel=_interopRequireDefault(_modal_cancel),ModalEvents=_interopRequireWildcard(ModalEvents);_exports.registerEventListeners=rootNode=>{rootNode.addEventListener("click",(e=>{const rootNode=e.target.closest(ForumSelectors.expandConversation);if(rootNode){e.preventDefault();try{!async function(rootNode){let{focusOnClose:focusOnClose=null}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const postId=rootNode.dataset.postid,discussionId=rootNode.dataset.discussionid,discussionName=rootNode.dataset.name,experimentalDisplayMode="1"==rootNode.dataset.experimentalDisplayMode,[allPosts,modal]=await Promise.all([_repository.default.getDiscussionPosts(parseInt(discussionId)),_modal_cancel.default.create({title:discussionName,large:!0,removeOnClose:!0,returnElement:focusOnClose})]),postsById=new Map(allPosts.posts.map((post=>(post.readonly=!0,post.hasreplies=!1,post.replies=[],[post.id,post]))));let posts=[];allPosts.posts.forEach((post=>{if(post.parentid){const parent=postsById.get(post.parentid);parent?(post.parentauthorname=parent.author.fullname,parent.hasreplies=!0,parent.replies.push(post)):posts.push(post)}else posts.push(post)})),modal.getRoot().on(ModalEvents.bodyRendered,(()=>{const relevantPost=modal.getRoot()[0].querySelector("#p".concat(postId));relevantPost&&relevantPost.scrollIntoView({behavior:"smooth"})})),modal.show();const templatePromise=_templates.default.render("mod_forum/grades/grader/discussion/post_modal",{posts:posts,experimentaldisplaymode:experimentalDisplayMode});modal.setBody(templatePromise)}(rootNode,{focusOnClose:e.target})}catch(err){(0,_notification.exception)(err)}}}))}}));
//# sourceMappingURL=expandconversation.min.js.map
File diff suppressed because one or more lines are too long
+10
View File
@@ -0,0 +1,10 @@
define("mod_forum/grades/grader",["exports","./grader/selectors","mod_forum/repository","core/templates","../local/grades/grader","core/notification","core_course/repository","core/url"],(function(_exports,Selectors,_repository,_templates,Grader,_notification,_repository2,_url){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}return newObj.default=obj,cache&&cache.set(obj,newObj),newObj}
/**
* This module will tie together all of the different calls the gradable module will make.
*
* @module mod_forum/grades/grader
* @copyright 2019 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.registerLaunchListeners=void 0,Selectors=_interopRequireWildcard(Selectors),_repository=_interopRequireDefault(_repository),_templates=_interopRequireDefault(_templates),Grader=_interopRequireWildcard(Grader),_notification=_interopRequireDefault(_notification),_repository2=_interopRequireDefault(_repository2);const templateNames_contentRegion="mod_forum/grades/grader/discussion/posts",getContentForUserIdFunction=(cmid,experimentalDisplayMode)=>userid=>_repository.default.getDiscussionByUserID(userid,cmid).then((context=>(context.discussions=context.discussions.map(discussionPostMapper),context.experimentaldisplaymode=!!experimentalDisplayMode,_templates.default.render(templateNames_contentRegion,context)))).catch(_notification.default.exception),getGradableUsersForCourseidFunction=(courseID,groupID,onlyActive)=>async()=>(await _repository2.default.getGradableUsersFromCourseID(courseID,groupID,onlyActive)).users,findGradableNode=node=>node.closest(Selectors.gradableItem),discussionPostMapper=discussion=>{const parentMap=new Map;discussion.posts.parentposts.forEach((post=>parentMap.set(post.id,post)));const userPosts=discussion.posts.userposts.map((post=>{post.readonly=!0,post.hasreplies=!1,post.replies=[];const parent=post.parentid?parentMap.get(post.parentid):null;return parent&&(parent.hasreplies=!1,parent.replies=[],parent.readonly=!0,post.parentauthorname=parent.author.fullname),{parent:parent,post:post}}));return{...discussion,posts:userPosts}};_exports.registerLaunchListeners=()=>{document.addEventListener("click",(async e=>{if(e.target.matches(Selectors.launch)){const rootNode=findGradableNode(e.target);if(!rootNode)throw Error("Unable to find a gradable item");if(!rootNode.matches(Selectors.gradableItems.wholeForum))throw Error("Unable to find a valid gradable item");e.preventDefault();try{await async function(rootNode){let{focusOnClose:focusOnClose=null}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const data=rootNode.dataset,gradingPanelFunctions=await Grader.getGradingPanelFunctions("mod_forum",data.contextid,data.gradingComponent,data.gradingComponentSubtype,data.gradableItemtype),groupID=data.group?data.group:0,onlyActive=data.gradeOnlyActiveUsers;await Grader.launch(getGradableUsersForCourseidFunction(data.courseId,groupID,onlyActive),getContentForUserIdFunction(data.cmid,"1"==data.experimentalDisplayMode),gradingPanelFunctions.getter,gradingPanelFunctions.setter,{groupid:data.groupid,initialUserId:data.initialuserid,moduleName:data.name,courseName:data.courseName,courseUrl:(0,_url.relativeUrl)("/course/view.php",{id:data.courseId}),sendStudentNotifications:data.sendStudentNotifications,focusOnClose:focusOnClose})}(rootNode,{focusOnClose:e.target})}catch(error){_notification.default.exception(error)}}if(e.target.matches(Selectors.viewGrade)){e.preventDefault();const rootNode=findGradableNode(e.target);if(!rootNode)throw Error("Unable to find a gradable item");if(!rootNode.matches(Selectors.gradableItems.wholeForum))throw Error("Unable to find a valid gradable item");e.preventDefault();try{await async function(rootNode){let{focusOnClose:focusOnClose=null}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const data=rootNode.dataset,gradingPanelFunctions=await Grader.getGradingPanelFunctions("mod_forum",data.contextid,data.gradingComponent,data.gradingComponentSubtype,data.gradableItemtype);await Grader.view(gradingPanelFunctions.getter,data.userid,data.name,{focusOnClose:focusOnClose})}(rootNode,{focusOnClose:e.target})}catch(error){_notification.default.exception(error)}}}))}}));
//# sourceMappingURL=grader.min.js.map
File diff suppressed because one or more lines are too long
+3
View File
@@ -0,0 +1,3 @@
define("mod_forum/grades/grader/selectors",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;return _exports.default={launch:'[data-grade-action="launch"]',gradableItem:"[data-gradable-itemtype]",gradableItems:{wholeForum:'[data-gradable-itemtype="forum"]'},expandConversation:'[data-action="view-context"]',posts:'[data-region="posts"]',viewGrade:'[data-grade-action="view"]'},_exports.default}));
//# sourceMappingURL=selectors.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"selectors.min.js","sources":["../../../src/grades/grader/selectors.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * This module will tie together all of the different calls the gradable module will make.\n *\n * @module mod_forum/grades/grader/selectors\n * @copyright 2019 Andrew Nicols <andrew@nicols.co.uk>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nexport default {\n launch: '[data-grade-action=\"launch\"]',\n gradableItem: '[data-gradable-itemtype]',\n gradableItems: {\n wholeForum: '[data-gradable-itemtype=\"forum\"]',\n },\n expandConversation: '[data-action=\"view-context\"]',\n posts: '[data-region=\"posts\"]',\n viewGrade: '[data-grade-action=\"view\"]',\n};\n"],"names":["launch","gradableItem","gradableItems","wholeForum","expandConversation","posts","viewGrade"],"mappings":"mLAsBe,CACXA,OAAQ,+BACRC,aAAc,2BACdC,cAAe,CACXC,WAAY,oCAEhBC,mBAAoB,+BACpBC,MAAO,wBACPC,UAAW"}
+10
View File
@@ -0,0 +1,10 @@
/**
* This module handles the in page replying to forum posts.
*
* @module mod_forum/inpage_reply
* @copyright 2019 Peter Dias
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("mod_forum/inpage_reply",["jquery","core/templates","core/notification","mod_forum/repository","mod_forum/selectors","core_form/changechecker"],(function($,Templates,Notification,Repository,Selectors,FormChangeChecker){var DISPLAYCONSTANTS_NESTED_V2=4,DISPLAYCONSTANTS_THREADED=2,DISPLAYCONSTANTS_NESTED=3,DISPLAYCONSTANTS_FLAT_NEWEST_FIRST=-1,EVENTS={POST_CREATED:"mod_forum-post-created"},CONTENT_FORMATS={MOODLE:0},hideSubmitButtonLoadingIcon=function(button){var textContainer=button.find(Selectors.post.inpageSubmitBtnText),loadingIconContainer=button.find(Selectors.post.loadingIconContainer);button.css("width",""),textContainer.removeClass("hidden"),loadingIconContainer.addClass("hidden")},registerEventListeners=function(root){root.on("click",Selectors.post.inpageSubmitBtn,(function(e){e.preventDefault();var newid,button,textContainer,loadingIconContainer,width,submitButton=$(e.currentTarget),allButtons=submitButton.parent().find(Selectors.post.inpageReplyButton),form=submitButton.parents(Selectors.post.inpageReplyForm).get(0),message=form.elements.post.value.trim(),messageformat=CONTENT_FORMATS.MOODLE,postid=form.elements.reply.value,subject=form.elements.subject.value,currentRoot=submitButton.closest(Selectors.post.post),isprivatereply=null!=form.elements.privatereply&&form.elements.privatereply.checked,modeSelector=root.find(Selectors.post.modeSelect),mode=modeSelector.length?parseInt(modeSelector.get(0).value):null;message.length&&(textContainer=(button=submitButton).find(Selectors.post.inpageSubmitBtnText),loadingIconContainer=button.find(Selectors.post.loadingIconContainer),width=button.outerWidth(),button.css("width",width),textContainer.addClass("hidden"),loadingIconContainer.removeClass("hidden"),allButtons.prop("disabled",!0),Repository.addDiscussionPost(postid,subject,message,messageformat,isprivatereply,!0).then((function(context){var message=context.messages.reduce((function(carry,message){return"success"==message.type&&(carry+="<p>"+message.message+"</p>"),carry}),"");return Notification.addNotification({message:message,type:"success"}),context})).then((function(context){form.reset();var post=context.post;switch(newid=post.id,mode){case DISPLAYCONSTANTS_NESTED_V2:var capabilities=post.capabilities,currentAuthorName=currentRoot.children().not(Selectors.post.repliesContainer).find(Selectors.post.authorName).text();return post.parentauthorname=currentAuthorName,post.showactionmenu=capabilities.view||capabilities.controlreadstatus||capabilities.edit||capabilities.split||capabilities.delete||capabilities.export||post.urls.viewparent,Templates.render("mod_forum/forum_discussion_nested_v2_post_reply",post);case DISPLAYCONSTANTS_THREADED:return Templates.render("mod_forum/forum_discussion_threaded_post",post);case DISPLAYCONSTANTS_NESTED:return Templates.render("mod_forum/forum_discussion_nested_post",post);default:return Templates.render("mod_forum/forum_discussion_post",post)}})).then((function(html,js){var repliesnode=currentRoot.find(Selectors.post.repliesContainer).first();return mode==DISPLAYCONSTANTS_FLAT_NEWEST_FIRST?Templates.prependNodeContents(repliesnode,html,js):Templates.appendNodeContents(repliesnode,html,js)})).then((function(){return submitButton.trigger(EVENTS.POST_CREATED,newid),hideSubmitButtonLoadingIcon(submitButton),allButtons.prop("disabled",!1),FormChangeChecker.resetFormDirtyState(submitButton[0]),currentRoot.find(Selectors.post.inpageReplyContent).hide()})).then((function(){location.href="#p"+newid,location.reload()})).catch((function(error){return hideSubmitButtonLoadingIcon(submitButton),allButtons.prop("disabled",!1),Notification.exception(error)})))})),root.on("click",Selectors.post.inpageCancelButton,(function(e){FormChangeChecker.resetFormDirtyState(e.currentTarget)}))};return{init:function(root){registerEventListeners(root)},CONTENT_FORMATS:CONTENT_FORMATS,EVENTS:EVENTS}}));
//# sourceMappingURL=inpage_reply.min.js.map
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,10 @@
define("mod_forum/local/grades/local/grader/gradingpanel",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;var _systemImportTransformerGlobalIdentifier="undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:{};
/**
* Grading panel functions.
*
* @module mod_forum/local/grades/local/grader/gradingpanel
* @copyright 2019 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/return _exports.default=async(component,context,gradingComponent,gradingSubtype,itemName)=>{let gradingMethodHandler="".concat(gradingComponent,"/grades/grader/gradingpanel");gradingSubtype&&(gradingMethodHandler+="/".concat(gradingSubtype));const GradingMethod=await("function"==typeof _systemImportTransformerGlobalIdentifier.define&&_systemImportTransformerGlobalIdentifier.define.amd?new Promise((function(resolve,reject){_systemImportTransformerGlobalIdentifier.require([gradingMethodHandler],resolve,reject)})):"undefined"!=typeof module&&module.exports&&"undefined"!=typeof require||"undefined"!=typeof module&&module.component&&_systemImportTransformerGlobalIdentifier.require&&"component"===_systemImportTransformerGlobalIdentifier.require.loader?Promise.resolve(require(gradingMethodHandler)):Promise.resolve(_systemImportTransformerGlobalIdentifier[gradingMethodHandler]));return{getter:userId=>GradingMethod.fetchCurrentGrade(component,context,itemName,userId),setter:(userId,notifyStudent,formData)=>GradingMethod.storeCurrentGrade(component,context,itemName,userId,notifyStudent,formData)}},_exports.default}));
//# sourceMappingURL=gradingpanel.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"gradingpanel.min.js","sources":["../../../../../src/local/grades/local/grader/gradingpanel.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Grading panel functions.\n *\n * @module mod_forum/local/grades/local/grader/gradingpanel\n * @copyright 2019 Andrew Nicols <andrew@nicols.co.uk>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * Get the grade panel setter and getter for the current component.\n * This function dynamically pulls the relevant gradingpanel JS file defined in the grading method.\n * We do this because we do not know until execution time what the grading type is and we do not want to import unused files.\n *\n * @method\n * @param {String} component The component being graded\n * @param {Number} context The contextid of the thing being graded\n * @param {String} gradingComponent The thing providing the grading type\n * @param {String} gradingSubtype The subtype fo the grading component\n * @param {String} itemName The name of the thing being graded\n * @return {Object}\n */\nexport default async(component, context, gradingComponent, gradingSubtype, itemName) => {\n let gradingMethodHandler = `${gradingComponent}/grades/grader/gradingpanel`;\n if (gradingSubtype) {\n gradingMethodHandler += `/${gradingSubtype}`;\n }\n\n const GradingMethod = await import(gradingMethodHandler);\n\n return {\n getter: (userId) => GradingMethod.fetchCurrentGrade(component, context, itemName, userId),\n setter: (userId, notifyStudent, formData) => GradingMethod.storeCurrentGrade(\n component, context, itemName, userId, notifyStudent, formData),\n };\n};\n\n"],"names":["async","component","context","gradingComponent","gradingSubtype","itemName","gradingMethodHandler","GradingMethod","getter","userId","fetchCurrentGrade","setter","notifyStudent","formData","storeCurrentGrade"],"mappings":";;;;;;;6BAoCeA,MAAMC,UAAWC,QAASC,iBAAkBC,eAAgBC,gBACnEC,+BAA0BH,gDAC1BC,iBACAE,iCAA4BF,uBAG1BG,oOAA6BD,gYAAAA,8BAE5B,CACHE,OAASC,QAAWF,cAAcG,kBAAkBT,UAAWC,QAASG,SAAUI,QAClFE,OAAQ,CAACF,OAAQG,cAAeC,WAAaN,cAAcO,kBACvDb,UAAWC,QAASG,SAAUI,OAAQG,cAAeC"}
@@ -0,0 +1,11 @@
define("mod_forum/local/grades/local/grader/selectors",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;
/**
* Define all of the selectors we will be using on the grading interface.
*
* @module mod_forum/local/grades/local/grader/selectors
* @copyright 2019 Mathew May <mathew.solutions>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
const getDataSelector=(name,value)=>"[data-".concat(name,'="').concat(value,'"]');var _default={buttons:{toggleFullscreen:getDataSelector("action","togglefullscreen"),closeGrader:getDataSelector("action","closegrader"),collapseGradingDrawer:getDataSelector("action","collapse-grading-drawer"),saveGrade:getDataSelector("action","savegrade"),selectUser:getDataSelector("action","select-user"),toggleSearch:getDataSelector("action","toggle-search")},regions:{bodyContainer:getDataSelector("region","body-container"),moduleContainer:getDataSelector("region","module_content_container"),moduleReplace:getDataSelector("region","module_content"),pickerRegion:getDataSelector("region","user_picker"),gradingInfoContainer:getDataSelector("region","grading-info-container"),gradingPanel:getDataSelector("region","grade"),gradingPanelContainer:getDataSelector("region","grading-panel-container"),gradingPanelErrors:getDataSelector("region","grade-errors"),searchResultsContainer:getDataSelector("region","search-results-container"),statusContainer:getDataSelector("region","status-container"),userSearchContainer:getDataSelector("region","user-search-container"),userSearchInput:getDataSelector("region","user-search-input")},values:{sendStudentNotifications:'[data-region="notification"] input[type="radio"]:checked'}};return _exports.default=_default,_exports.default}));
//# sourceMappingURL=selectors.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"selectors.min.js","sources":["../../../../../src/local/grades/local/grader/selectors.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Define all of the selectors we will be using on the grading interface.\n *\n * @module mod_forum/local/grades/local/grader/selectors\n * @copyright 2019 Mathew May <mathew.solutions>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * A small helper function to build queryable data selectors.\n * @param {String} name\n * @param {String} value\n * @return {string}\n */\nconst getDataSelector = (name, value) => {\n return `[data-${name}=\"${value}\"]`;\n};\n\nexport default {\n buttons: {\n toggleFullscreen: getDataSelector('action', 'togglefullscreen'),\n closeGrader: getDataSelector('action', 'closegrader'),\n collapseGradingDrawer: getDataSelector('action', 'collapse-grading-drawer'),\n saveGrade: getDataSelector('action', 'savegrade'),\n selectUser: getDataSelector('action', 'select-user'),\n toggleSearch: getDataSelector('action', 'toggle-search')\n },\n regions: {\n bodyContainer: getDataSelector('region', 'body-container'),\n moduleContainer: getDataSelector('region', 'module_content_container'),\n moduleReplace: getDataSelector('region', 'module_content'),\n pickerRegion: getDataSelector('region', 'user_picker'),\n gradingInfoContainer: getDataSelector('region', 'grading-info-container'),\n gradingPanel: getDataSelector('region', 'grade'),\n gradingPanelContainer: getDataSelector('region', 'grading-panel-container'),\n gradingPanelErrors: getDataSelector('region', 'grade-errors'),\n searchResultsContainer: getDataSelector('region', 'search-results-container'),\n statusContainer: getDataSelector('region', 'status-container'),\n userSearchContainer: getDataSelector('region', 'user-search-container'),\n userSearchInput: getDataSelector('region', 'user-search-input')\n },\n values: {\n sendStudentNotifications: '[data-region=\"notification\"] input[type=\"radio\"]:checked',\n }\n};\n\n"],"names":["getDataSelector","name","value","buttons","toggleFullscreen","closeGrader","collapseGradingDrawer","saveGrade","selectUser","toggleSearch","regions","bodyContainer","moduleContainer","moduleReplace","pickerRegion","gradingInfoContainer","gradingPanel","gradingPanelContainer","gradingPanelErrors","searchResultsContainer","statusContainer","userSearchContainer","userSearchInput","values","sendStudentNotifications"],"mappings":";;;;;;;;MA6BMA,gBAAkB,CAACC,KAAMC,wBACXD,kBAASC,yBAGd,CACXC,QAAS,CACLC,iBAAkBJ,gBAAgB,SAAU,oBAC5CK,YAAaL,gBAAgB,SAAU,eACvCM,sBAAuBN,gBAAgB,SAAU,2BACjDO,UAAWP,gBAAgB,SAAU,aACrCQ,WAAYR,gBAAgB,SAAU,eACtCS,aAAcT,gBAAgB,SAAU,kBAE5CU,QAAS,CACLC,cAAeX,gBAAgB,SAAU,kBACzCY,gBAAiBZ,gBAAgB,SAAU,4BAC3Ca,cAAeb,gBAAgB,SAAU,kBACzCc,aAAcd,gBAAgB,SAAU,eACxCe,qBAAsBf,gBAAgB,SAAU,0BAChDgB,aAAchB,gBAAgB,SAAU,SACxCiB,sBAAuBjB,gBAAgB,SAAU,2BACjDkB,mBAAoBlB,gBAAgB,SAAU,gBAC9CmB,uBAAwBnB,gBAAgB,SAAU,4BAClDoB,gBAAiBpB,gBAAgB,SAAU,oBAC3CqB,oBAAqBrB,gBAAgB,SAAU,yBAC/CsB,gBAAiBtB,gBAAgB,SAAU,sBAE/CuB,OAAQ,CACJC,yBAA0B"}
@@ -0,0 +1,10 @@
define("mod_forum/local/grades/local/grader/user_picker",["exports","core/templates","./user_picker/selectors","core/str"],(function(_exports,_templates,_selectors,_str){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}
/**
* This module will tie together all of the different calls the gradable module will make.
*
* @module mod_forum/local/grades/local/grader/user_picker
* @copyright 2019 Mathew May <mathew.solutions>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_templates=_interopRequireDefault(_templates),_selectors=_interopRequireDefault(_selectors);class UserPicker{constructor(userList,showUserCallback,preChangeUserCallback){this.userList=userList,this.showUserCallback=showUserCallback,this.preChangeUserCallback=preChangeUserCallback,this.currentUserIndex=0,this.render=this.render.bind(this),this.setUserId=this.setUserId.bind(this)}setUserId(userId){const userIndex=this.userList.findIndex((user=>user.id===parseInt(userId)));if(-1===userIndex)throw Error("User with id ".concat(userId," not found"));this.currentUserIndex=userIndex}async render(){this.root=document.createElement("div");const{html:html,js:js}=await this.renderNavigator();_templates.default.replaceNodeContents(this.root,html,js),await this.showUser(this.currentUser),this.registerEventListeners()}renderNavigator(){return _templates.default.renderForPromise("".concat("mod_forum/local/grades/local/grader","/user_picker"),{})}renderUserChange(context){return _templates.default.renderForPromise("".concat("mod_forum/local/grades/local/grader","/user_picker/user"),context)}async showUser(user){const[{html:html,js:js}]=await Promise.all([this.renderUserChange(user),this.showUserCallback(user)]),userRegion=this.root.querySelector(_selectors.default.regions.userRegion);_templates.default.replaceNodeContents(userRegion,html,js);this.root.querySelector(_selectors.default.regions.currentUser).textContent=await(0,_str.getString)("nowgradinguser","mod_forum",user.fullname)}registerEventListeners(){this.root.addEventListener("click",(async e=>{const button=e.target.closest(_selectors.default.actions.changeUser);if(button){(await this.preChangeUserCallback(this.currentUser)).failed||(this.updateIndex(parseInt(button.dataset.direction)),await this.showUser(this.currentUser))}}))}updateIndex(direction){return this.currentUserIndex+=direction,this.currentUserIndex<0?this.currentUserIndex=this.userList.length-1:this.currentUserIndex>this.userList.length-1&&(this.currentUserIndex=0),this.currentUserIndex}get currentUser(){return{...this.userList[this.currentUserIndex],total:this.userList.length,displayIndex:this.currentUserIndex+1}}get rootNode(){return this.root}}return _exports.default=async function(users,showUserCallback,preChangeUserCallback){let{initialUserId:initialUserId=null}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const userPicker=new UserPicker(users,showUserCallback,preChangeUserCallback);return initialUserId&&userPicker.setUserId(initialUserId),await userPicker.render(),userPicker},_exports.default}));
//# sourceMappingURL=user_picker.min.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,3 @@
define("mod_forum/local/grades/local/grader/user_picker/selectors",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;return _exports.default={regions:{currentUser:'[data-region="user_picker/current_user"]',userRegion:'[data-region="user_picker/user"]'},actions:{changeUser:'[data-action="change-user"]'}},_exports.default}));
//# sourceMappingURL=selectors.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"selectors.min.js","sources":["../../../../../../src/local/grades/local/grader/user_picker/selectors.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Define all of the selectors we will be using on the grading interface.\n *\n * @module mod_forum/local/grades/local/grader/user_picker/selectors\n * @copyright 2019 Mathew May <mathew.solutions>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nexport default {\n regions: {\n currentUser: '[data-region=\"user_picker/current_user\"]',\n userRegion: '[data-region=\"user_picker/user\"]',\n },\n actions: {\n changeUser: '[data-action=\"change-user\"]',\n }\n};\n\n"],"names":["regions","currentUser","userRegion","actions","changeUser"],"mappings":"2MAuBe,CACXA,QAAS,CACLC,YAAa,2CACbC,WAAY,oCAEhBC,QAAS,CACLC,WAAY"}
+10
View File
@@ -0,0 +1,10 @@
define("mod_forum/local/layout/fullscreen",["exports","core/loadingicon","core/toast","core/local/aria/focuslock"],(function(_exports,_loadingicon,_toast,FocusLockManager){function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.createLayout=void 0,FocusLockManager=function(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}newObj.default=obj,cache&&cache.set(obj,newObj);return newObj}
/**
* Full screen window layout.
*
* @module mod_forum/local/layout/fullscreen
* @copyright 2019 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/(FocusLockManager);_exports.createLayout=function(){let{fullscreen:fullscreen=!0,showLoader:showLoader=!1,focusOnClose:focusOnClose=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const container=document.createElement("div");document.body.append(container),container.classList.add("layout"),container.classList.add("fullscreen"),container.setAttribute("role","application"),(0,_toast.addToastRegion)(container),lockBodyScroll(),FocusLockManager.trapFocus(container);const helpers=getLayoutHelpers(container,FocusLockManager,focusOnClose);return showLoader&&helpers.showLoadingIcon(),fullscreen&&helpers.requestFullscreen(),helpers};const getLayoutHelpers=(layoutNode,FocusLockManager,focusOnClose)=>{const contentNode=document.createElement("div");layoutNode.append(contentNode);const loadingNode=document.createElement("div");layoutNode.append(loadingNode);const requestFullscreen=()=>{layoutNode.requestFullscreen?layoutNode.requestFullscreen():layoutNode.msRequestFullscreen?layoutNode.msRequestFullscreen():layoutNode.mozRequestFullscreen?layoutNode.mozRequestFullscreen():layoutNode.webkitRequestFullscreen?layoutNode.webkitRequestFullscreen():layoutNode.setTop(0)},exitFullscreen=()=>{if(document.exitRequestFullScreen){if(document.fullScreenElement!==layoutNode)return;document.exitRequestFullScreen()}else if(document.msExitFullscreen){if(document.msFullscreenElement!==layoutNode)return;document.msExitFullscreen()}else if(document.mozCancelFullScreen){if(document.mozFullScreenElement!==layoutNode)return;document.mozCancelFullScreen()}else if(document.webkitExitFullscreen){if(document.webkitFullscreenElement!==layoutNode)return;document.webkitExitFullscreen()}},hideLoadingIcon=()=>{let child=loadingNode.lastElementChild;for(;child;)loadingNode.removeChild(child),child=loadingNode.lastElementChild};return{close:()=>{if(exitFullscreen(),unlockBodyScroll(),FocusLockManager.untrapFocus(),layoutNode.remove(),focusOnClose)try{focusOnClose.focus()}catch(e){}},toggleFullscreen:()=>{document.exitRequestFullScreen?document.fullScreenElement===layoutNode?exitFullscreen():requestFullscreen():document.msExitFullscreen?document.msFullscreenElement===layoutNode?exitFullscreen():requestFullscreen():document.mozCancelFullScreen?document.mozFullScreenElement===layoutNode?exitFullscreen():requestFullscreen():document.webkitExitFullscreen&&(document.webkitFullscreenElement===layoutNode?exitFullscreen():requestFullscreen())},requestFullscreen:requestFullscreen,exitFullscreen:exitFullscreen,getContainer:()=>contentNode,setContent:content=>{hideLoadingIcon();let child=contentNode.lastElementChild;for(;child;)contentNode.removeChild(child),child=contentNode.lastElementChild;contentNode.append(content)},showLoadingIcon:()=>{(0,_loadingicon.addIconToContainer)(loadingNode)},hideLoadingIcon:hideLoadingIcon}},lockBodyScroll=()=>{document.querySelector("body").classList.add("overflow-hidden")},unlockBodyScroll=()=>{document.querySelector("body").classList.remove("overflow-hidden")}}));
//# sourceMappingURL=fullscreen.min.js.map
File diff suppressed because one or more lines are too long
+3
View File
@@ -0,0 +1,3 @@
define("mod_forum/local/layouts",["exports","./layout/fullscreen"],(function(_exports,_fullscreen){Object.defineProperty(_exports,"__esModule",{value:!0}),Object.defineProperty(_exports,"createFullScreenWindow",{enumerable:!0,get:function(){return _fullscreen.createLayout}})}));
//# sourceMappingURL=layouts.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"layouts.min.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
+10
View File
@@ -0,0 +1,10 @@
/**
* Handle the manual locking of individual discussions
*
* @module mod_forum/lock_toggle
* @copyright 2019 Peter Dias <peter@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("mod_forum/lock_toggle",["jquery","core/templates","core/notification","mod_forum/repository","mod_forum/selectors"],(function($,Templates,Notification,Repository,Selectors){return{init:function(root,preventDefault){root.on("click",Selectors.lock.toggle,(function(e){var toggleElement=$(this),forumId=toggleElement.data("forumid"),discussionId=toggleElement.data("discussionid"),state=toggleElement.data("state");Repository.setDiscussionLockState(forumId,discussionId,state).then((function(){return location.reload()})).catch(Notification.exception),preventDefault&&e.preventDefault()}))}}}));
//# sourceMappingURL=lock_toggle.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"lock_toggle.min.js","sources":["../src/lock_toggle.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Handle the manual locking of individual discussions\n *\n * @module mod_forum/lock_toggle\n * @copyright 2019 Peter Dias <peter@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/templates',\n 'core/notification',\n 'mod_forum/repository',\n 'mod_forum/selectors',\n ], function(\n $,\n Templates,\n Notification,\n Repository,\n Selectors\n ) {\n\n /**\n * Register event listeners for the subscription toggle.\n *\n * @param {object} root The discussion list root element\n * @param {boolean} preventDefault Should the default action of the event be prevented\n */\n var registerEventListeners = function(root, preventDefault) {\n root.on('click', Selectors.lock.toggle, function(e) {\n var toggleElement = $(this);\n var forumId = toggleElement.data('forumid');\n var discussionId = toggleElement.data('discussionid');\n var state = toggleElement.data('state');\n\n Repository.setDiscussionLockState(forumId, discussionId, state)\n .then(function() {\n return location.reload();\n })\n .catch(Notification.exception);\n\n if (preventDefault) {\n e.preventDefault();\n }\n });\n };\n\n return {\n init: registerEventListeners\n };\n});\n"],"names":["define","$","Templates","Notification","Repository","Selectors","init","root","preventDefault","on","lock","toggle","e","toggleElement","this","forumId","data","discussionId","state","setDiscussionLockState","then","location","reload","catch","exception"],"mappings":";;;;;;;AAsBAA,+BAAO,CACC,SACA,iBACA,oBACA,uBACA,wBACD,SACCC,EACAC,UACAC,aACAC,WACAC,iBA4BG,CACHC,KApByB,SAASC,KAAMC,gBACxCD,KAAKE,GAAG,QAASJ,UAAUK,KAAKC,QAAQ,SAASC,OACzCC,cAAgBZ,EAAEa,MAClBC,QAAUF,cAAcG,KAAK,WAC7BC,aAAeJ,cAAcG,KAAK,gBAClCE,MAAQL,cAAcG,KAAK,SAE/BZ,WAAWe,uBAAuBJ,QAASE,aAAcC,OACpDE,MAAK,kBACKC,SAASC,YAEnBC,MAAMpB,aAAaqB,WAEpBhB,gBACAI,EAAEJ"}
+14
View File
@@ -0,0 +1,14 @@
/**
* This module is the highest level module for the calendar. It is
* responsible for initialising all of the components required for
* the calendar to run. It also coordinates the interaction between
* components by listening for and responding to different events
* triggered within the calendar UI.
*
* @module mod_forum/pin_toggle
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("mod_forum/pin_toggle",["jquery","core/ajax","core/str","core/templates","core/notification","mod_forum/repository","mod_forum/selectors","core/str"],(function($,Ajax,Str,Templates,Notification,Repository,Selectors,String){return{init:function(root,preventDefault,callback){root.on("click",Selectors.pin.toggle,(function(e){var toggleElement=$(this),forumid=toggleElement.data("forumid"),discussionid=toggleElement.data("discussionid"),pinstate=toggleElement.data("targetstate");Repository.setPinDiscussionState(forumid,discussionid,pinstate).then((function(context){return callback(toggleElement,context)})).then((function(){return String.get_string("pinupdated","forum").done((function(s){return Notification.addNotification({message:s,type:"info"})}))})).fail(Notification.exception),preventDefault&&e.preventDefault()}))}}}));
//# sourceMappingURL=pin_toggle.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"pin_toggle.min.js","sources":["../src/pin_toggle.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * This module is the highest level module for the calendar. It is\n * responsible for initialising all of the components required for\n * the calendar to run. It also coordinates the interaction between\n * components by listening for and responding to different events\n * triggered within the calendar UI.\n *\n * @module mod_forum/pin_toggle\n * @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/ajax',\n 'core/str',\n 'core/templates',\n 'core/notification',\n 'mod_forum/repository',\n 'mod_forum/selectors',\n 'core/str',\n], function(\n $,\n Ajax,\n Str,\n Templates,\n Notification,\n Repository,\n Selectors,\n String\n) {\n\n /**\n * Registery event listeners for the pin toggle.\n *\n * @param {object} root The calendar root element\n * @param {boolean} preventDefault Should the default action of the event be prevented\n * @param {function} callback Success callback\n */\n var registerEventListeners = function(root, preventDefault, callback) {\n root.on('click', Selectors.pin.toggle, function(e) {\n var toggleElement = $(this);\n var forumid = toggleElement.data('forumid');\n var discussionid = toggleElement.data('discussionid');\n var pinstate = toggleElement.data('targetstate');\n Repository.setPinDiscussionState(forumid, discussionid, pinstate)\n .then(function(context) {\n return callback(toggleElement, context);\n })\n .then(function() {\n return String.get_string(\"pinupdated\", \"forum\")\n .done(function(s) {\n return Notification.addNotification({\n message: s,\n type: \"info\"\n });\n });\n })\n .fail(Notification.exception);\n\n if (preventDefault) {\n e.preventDefault();\n }\n });\n };\n\n return {\n init: registerEventListeners\n };\n});"],"names":["define","$","Ajax","Str","Templates","Notification","Repository","Selectors","String","init","root","preventDefault","callback","on","pin","toggle","e","toggleElement","this","forumid","data","discussionid","pinstate","setPinDiscussionState","then","context","get_string","done","s","addNotification","message","type","fail","exception"],"mappings":";;;;;;;;;;;AA0BAA,8BAAO,CACH,SACA,YACA,WACA,iBACA,oBACA,uBACA,sBACA,aACD,SACCC,EACAC,KACAC,IACAC,UACAC,aACAC,WACAC,UACAC,cAqCO,CACHC,KA5ByB,SAASC,KAAMC,eAAgBC,UACxDF,KAAKG,GAAG,QAASN,UAAUO,IAAIC,QAAQ,SAASC,OACxCC,cAAgBhB,EAAEiB,MAClBC,QAAUF,cAAcG,KAAK,WAC7BC,aAAeJ,cAAcG,KAAK,gBAClCE,SAAWL,cAAcG,KAAK,eAClCd,WAAWiB,sBAAsBJ,QAASE,aAAcC,UACnDE,MAAK,SAASC,gBACJb,SAASK,cAAeQ,YAElCD,MAAK,kBACKhB,OAAOkB,WAAW,aAAc,SAClCC,MAAK,SAASC,UACJvB,aAAawB,gBAAgB,CAChCC,QAASF,EACTG,KAAM,eAIrBC,KAAK3B,aAAa4B,WAEnBtB,gBACAK,EAAEL"}
+14
View File
@@ -0,0 +1,14 @@
/**
* This module is the highest level module for the calendar. It is
* responsible for initialising all of the components required for
* the calendar to run. It also coordinates the interaction between
* components by listening for and responding to different events
* triggered within the calendar UI.
*
* @module mod_forum/posts_list
* @copyright 2019 Peter Dias
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("mod_forum/posts_list",["jquery","core/templates","core/notification","core/pending","mod_forum/selectors","mod_forum/inpage_reply","core_form/changechecker"],(function($,Templates,Notification,Pending,Selectors,InPageReply,FormChangeChecker){return{init:function(root,throttlingwarningmsg){!function(root,throttlingwarningmsg){root.on("click",Selectors.post.inpageReplyLink,(function(e){if(e.preventDefault(),window.location.hash){var url=window.location.href.split("#")[0];history.pushState({},document.title,url)}var pending=new Pending("inpage-reply"),currentTarget=$(e.currentTarget).parents(Selectors.post.forumCoreContent),currentSubject=currentTarget.find(Selectors.post.forumSubject),currentRoot=$(e.currentTarget).parents(Selectors.post.forumContent),context={postid:$(currentRoot).data("post-id"),reply_url:$(e.currentTarget).attr("href"),sesskey:M.cfg.sesskey,parentsubject:currentSubject.data("replySubject"),canreplyprivately:$(e.currentTarget).data("can-reply-privately"),postformat:InPageReply.CONTENT_FORMATS.MOODLE,throttlingwarningmsg:throttlingwarningmsg};if(currentRoot.find(Selectors.post.inpageReplyContent).length){var form=currentRoot.find(Selectors.post.inpageReplyContent);form.slideToggle(300,pending.resolve),form.is(":visible")&&form.find("textarea").focus()}else Templates.render("mod_forum/inpage_reply",context).then((function(html,js){return Templates.appendNodeContents(currentTarget,html,js)})).then((function(){return currentRoot.find(Selectors.post.inpageReplyContent).slideToggle(300,pending.resolve).find("textarea").focus()})).then((function(){FormChangeChecker.watchFormById("inpage-reply-".concat(context.postid))})).catch(Notification.exception)}))}(root,throttlingwarningmsg),InPageReply.init(root)}}}));
//# sourceMappingURL=posts_list.min.js.map
File diff suppressed because one or more lines are too long
+11
View File
@@ -0,0 +1,11 @@
/**
* Forum repository class to encapsulate all of the AJAX requests that subscribe or unsubscribe
* can be sent for forum.
*
* @module mod_forum/repository
* @copyright 2019 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("mod_forum/repository",["core/ajax"],(function(Ajax){return{setDiscussionSubscriptionState:function(forumId,discussionId,targetState){var request={methodname:"mod_forum_set_subscription_state",args:{forumid:forumId,discussionid:discussionId,targetstate:targetState}};return Ajax.call([request])[0]},addDiscussionPost:function(postid,subject,message,messageformat,isprivatereply,topreferredformat){var request={methodname:"mod_forum_add_discussion_post",args:{postid:postid,message:message,messageformat:messageformat,subject:subject,options:[{name:"private",value:isprivatereply},{name:"topreferredformat",value:topreferredformat}]}};return Ajax.call([request])[0]},setDiscussionLockState:function(forumId,discussionId,targetState){var request={methodname:"mod_forum_set_lock_state",args:{forumid:forumId,discussionid:discussionId,targetstate:targetState}};return Ajax.call([request])[0]},setFavouriteDiscussionState:function(forumId,discussionId,targetState){var request={methodname:"mod_forum_toggle_favourite_state",args:{discussionid:discussionId,targetstate:targetState}};return Ajax.call([request])[0]},setPinDiscussionState:function(forumid,discussionid,targetstate){var request={methodname:"mod_forum_set_pin_state",args:{discussionid:discussionid,targetstate:targetstate}};return Ajax.call([request])[0]},getDiscussionByUserID:function(userid,cmid){let sortby=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"modified",sortdirection=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"DESC";var request={methodname:"mod_forum_get_discussion_posts_by_userid",args:{userid:userid,cmid:cmid,sortby:sortby,sortdirection:sortdirection}};return Ajax.call([request])[0]},getDiscussionPosts:function(discussionId){let sortby=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"created",sortdirection=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"ASC";var request={methodname:"mod_forum_get_discussion_posts",args:{discussionid:discussionId,sortby:sortby,sortdirection:sortdirection}};return Ajax.call([request])[0]}}}));
//# sourceMappingURL=repository.min.js.map
File diff suppressed because one or more lines are too long
+10
View File
@@ -0,0 +1,10 @@
/**
* Common CSS selectors for the forum UI.
*
* @module mod_forum/selectors
* @copyright 2019 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("mod_forum/selectors",[],(function(){return{subscription:{toggle:"[data-type='subscription-toggle'][data-action='toggle']"},summary:{actions:"[data-container='discussion-summary-actions']"},post:{post:'[data-region="post"]',action:'[data-region="post-action"]',actionsContainer:'[data-region="post-actions-container"]',authorName:'[data-region="author-name"]',forumCoreContent:"[data-region-content='forum-post-core']",forumContent:"[data-content='forum-post']",forumSubject:"[data-region-content='forum-post-core-subject']",inpageCancelButton:"button[name='cancelbtn']",inpageReplyButton:"button",inpageReplyLink:"[data-action='collapsible-link']",inpageReplyCancelButton:"[data-action='cancel-inpage-reply']",inpageReplyCreateButton:"[data-action='create-inpage-reply']",inpageReplyContainer:'[data-region="inpage-reply-container"]',inpageReplyContent:"[data-content='inpage-reply-content']",inpageReplyForm:"form[data-content='inpage-reply-form']",inpageSubmitBtn:"[data-action='forum-inpage-submit']",inpageSubmitBtnText:"[data-region='submit-text']",loadingIconContainer:"[data-region='loading-icon-container']",repliesContainer:"[data-region='replies-container']",replyCount:'[data-region="reply-count"]',modeSelect:"select[name='mode']",showReplies:'[data-action="show-replies"]',hideReplies:'[data-action="hide-replies"]',repliesVisibilityToggleContainer:'[data-region="replies-visibility-toggle-container"]'},lock:{toggle:"[data-action='toggle'][data-type='lock-toggle']",icon:"[data-region='locked-icon']"},favourite:{toggle:"[data-type='favorite-toggle'][data-action='toggle']"},pin:{toggle:"[data-type='pin-toggle'][data-action='toggle']"},discussion:{tools:'[data-container="discussion-tools"]',item:'[data-region="discussion-list-item"]',lockedLabel:"[data-region='locked-label']",subscribedLabel:"[data-region='subscribed-label']",timedLabel:"[data-region='timed-label']"}}}));
//# sourceMappingURL=selectors.min.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"selectors.min.js","sources":["../src/selectors.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Common CSS selectors for the forum UI.\n *\n * @module mod_forum/selectors\n * @copyright 2019 Andrew Nicols <andrew@nicols.co.uk>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([], function() {\n return {\n subscription: {\n toggle: \"[data-type='subscription-toggle'][data-action='toggle']\",\n },\n summary: {\n actions: \"[data-container='discussion-summary-actions']\"\n },\n post: {\n post: '[data-region=\"post\"]',\n action: '[data-region=\"post-action\"]',\n actionsContainer: '[data-region=\"post-actions-container\"]',\n authorName: '[data-region=\"author-name\"]',\n forumCoreContent: \"[data-region-content='forum-post-core']\",\n forumContent: \"[data-content='forum-post']\",\n forumSubject: \"[data-region-content='forum-post-core-subject']\",\n inpageCancelButton: \"button[name='cancelbtn']\",\n inpageReplyButton: \"button\",\n inpageReplyLink: \"[data-action='collapsible-link']\",\n inpageReplyCancelButton: \"[data-action='cancel-inpage-reply']\",\n inpageReplyCreateButton: \"[data-action='create-inpage-reply']\",\n inpageReplyContainer: '[data-region=\"inpage-reply-container\"]',\n inpageReplyContent: \"[data-content='inpage-reply-content']\",\n inpageReplyForm: \"form[data-content='inpage-reply-form']\",\n inpageSubmitBtn: \"[data-action='forum-inpage-submit']\",\n inpageSubmitBtnText: \"[data-region='submit-text']\",\n loadingIconContainer: \"[data-region='loading-icon-container']\",\n repliesContainer: \"[data-region='replies-container']\",\n replyCount: '[data-region=\"reply-count\"]',\n modeSelect: \"select[name='mode']\",\n showReplies: '[data-action=\"show-replies\"]',\n hideReplies: '[data-action=\"hide-replies\"]',\n repliesVisibilityToggleContainer: '[data-region=\"replies-visibility-toggle-container\"]'\n },\n lock: {\n toggle: \"[data-action='toggle'][data-type='lock-toggle']\",\n icon: \"[data-region='locked-icon']\"\n },\n favourite: {\n toggle: \"[data-type='favorite-toggle'][data-action='toggle']\",\n },\n pin: {\n toggle: \"[data-type='pin-toggle'][data-action='toggle']\",\n },\n discussion: {\n tools: '[data-container=\"discussion-tools\"]',\n item: '[data-region=\"discussion-list-item\"]',\n lockedLabel: \"[data-region='locked-label']\",\n subscribedLabel: \"[data-region='subscribed-label']\",\n timedLabel: \"[data-region='timed-label']\",\n },\n };\n});\n"],"names":["define","subscription","toggle","summary","actions","post","action","actionsContainer","authorName","forumCoreContent","forumContent","forumSubject","inpageCancelButton","inpageReplyButton","inpageReplyLink","inpageReplyCancelButton","inpageReplyCreateButton","inpageReplyContainer","inpageReplyContent","inpageReplyForm","inpageSubmitBtn","inpageSubmitBtnText","loadingIconContainer","repliesContainer","replyCount","modeSelect","showReplies","hideReplies","repliesVisibilityToggleContainer","lock","icon","favourite","pin","discussion","tools","item","lockedLabel","subscribedLabel","timedLabel"],"mappings":";;;;;;;AAsBAA,6BAAO,IAAI,iBACA,CACHC,aAAc,CACVC,OAAQ,2DAEZC,QAAS,CACLC,QAAS,iDAEbC,KAAM,CACFA,KAAM,uBACNC,OAAQ,8BACRC,iBAAkB,yCAClBC,WAAY,8BACZC,iBAAkB,0CAClBC,aAAc,8BACdC,aAAc,kDACdC,mBAAoB,2BACpBC,kBAAmB,SACnBC,gBAAiB,mCACjBC,wBAAyB,sCACzBC,wBAAyB,sCACzBC,qBAAsB,yCACtBC,mBAAoB,wCACpBC,gBAAiB,yCACjBC,gBAAiB,sCACjBC,oBAAqB,8BACrBC,qBAAsB,yCACtBC,iBAAkB,oCAClBC,WAAY,8BACZC,WAAY,sBACZC,YAAa,+BACbC,YAAa,+BACbC,iCAAkC,uDAEtCC,KAAM,CACF3B,OAAQ,kDACR4B,KAAM,+BAEVC,UAAW,CACP7B,OAAQ,uDAEZ8B,IAAK,CACD9B,OAAQ,kDAEZ+B,WAAY,CACRC,MAAO,sCACPC,KAAM,uCACNC,YAAa,+BACbC,gBAAiB,mCACjBC,WAAY"}
+11
View File
@@ -0,0 +1,11 @@
/**
* Handle discussion subscription toggling on a discussion list in
* the forum view.
*
* @module mod_forum/subscription_toggle
* @copyright 2019 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("mod_forum/subscription_toggle",["jquery","core/templates","core/notification","mod_forum/repository","mod_forum/selectors","core/pubsub","mod_forum/forum_events"],(function($,Templates,Notification,Repository,Selectors,PubSub,ForumEvents){return{init:function(root,preventDefault,callback){root.on("click",Selectors.subscription.toggle,(function(e){var toggleElement=$(this),forumId=toggleElement.data("forumid"),discussionId=toggleElement.data("discussionid"),subscriptionState=toggleElement.data("targetstate");Repository.setDiscussionSubscriptionState(forumId,discussionId,subscriptionState).then((function(context){return PubSub.publish(ForumEvents.SUBSCRIPTION_TOGGLED,{discussionId:discussionId,subscriptionState:subscriptionState}),callback(toggleElement,context)})).catch(Notification.exception),preventDefault&&e.preventDefault()}))}}}));
//# sourceMappingURL=subscription_toggle.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"subscription_toggle.min.js","sources":["../src/subscription_toggle.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Handle discussion subscription toggling on a discussion list in\n * the forum view.\n *\n * @module mod_forum/subscription_toggle\n * @copyright 2019 Andrew Nicols <andrew@nicols.co.uk>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/templates',\n 'core/notification',\n 'mod_forum/repository',\n 'mod_forum/selectors',\n 'core/pubsub',\n 'mod_forum/forum_events',\n ], function(\n $,\n Templates,\n Notification,\n Repository,\n Selectors,\n PubSub,\n ForumEvents\n ) {\n\n /**\n * Register event listeners for the subscription toggle.\n *\n * @param {object} root The discussion list root element\n * @param {boolean} preventDefault Should the default action of the event be prevented\n * @param {function} callback Success callback\n */\n var registerEventListeners = function(root, preventDefault, callback) {\n root.on('click', Selectors.subscription.toggle, function(e) {\n var toggleElement = $(this);\n var forumId = toggleElement.data('forumid');\n var discussionId = toggleElement.data('discussionid');\n var subscriptionState = toggleElement.data('targetstate');\n\n Repository.setDiscussionSubscriptionState(forumId, discussionId, subscriptionState)\n .then(function(context) {\n PubSub.publish(ForumEvents.SUBSCRIPTION_TOGGLED, {\n discussionId: discussionId,\n subscriptionState: subscriptionState\n });\n return callback(toggleElement, context);\n })\n .catch(Notification.exception);\n\n if (preventDefault) {\n e.preventDefault();\n }\n });\n };\n\n return {\n init: registerEventListeners\n };\n});\n"],"names":["define","$","Templates","Notification","Repository","Selectors","PubSub","ForumEvents","init","root","preventDefault","callback","on","subscription","toggle","e","toggleElement","this","forumId","data","discussionId","subscriptionState","setDiscussionSubscriptionState","then","context","publish","SUBSCRIPTION_TOGGLED","catch","exception"],"mappings":";;;;;;;;AAuBAA,uCAAO,CACC,SACA,iBACA,oBACA,uBACA,sBACA,cACA,2BACD,SACCC,EACAC,UACAC,aACAC,WACAC,UACAC,OACAC,mBAiCG,CACHC,KAxByB,SAASC,KAAMC,eAAgBC,UACxDF,KAAKG,GAAG,QAASP,UAAUQ,aAAaC,QAAQ,SAASC,OACjDC,cAAgBf,EAAEgB,MAClBC,QAAUF,cAAcG,KAAK,WAC7BC,aAAeJ,cAAcG,KAAK,gBAClCE,kBAAoBL,cAAcG,KAAK,eAE3Cf,WAAWkB,+BAA+BJ,QAASE,aAAcC,mBAC5DE,MAAK,SAASC,gBACXlB,OAAOmB,QAAQlB,YAAYmB,qBAAsB,CAC7CN,aAAcA,aACdC,kBAAmBA,oBAEhBV,SAASK,cAAeQ,YAElCG,MAAMxB,aAAayB,WAEpBlB,gBACAK,EAAEL"}