diff --git a/lang/en/langconfig.php b/lang/en/langconfig.php index f597c33a613..7ec6c455991 100644 --- a/lang/en/langconfig.php +++ b/lang/en/langconfig.php @@ -37,8 +37,10 @@ $string['localewincharset'] = ''; $string['oldcharset'] = 'ISO-8859-1'; $string['parentlanguage'] = ''; $string['strftimedate'] = '%d %B %Y'; +$string['strftimedatemonthabbr'] = '%d %b %Y'; $string['strftimedatefullshort'] = '%d/%m/%y'; $string['strftimedateshort'] = '%d %B'; +$string['strftimedateshortmonthabbr'] = '%d %b'; $string['strftimedatetime'] = '%d %B %Y, %I:%M %p'; $string['strftimedatetimeshort'] = '%d/%m/%y, %H:%M'; $string['strftimedaydate'] = '%A, %d %B %Y'; diff --git a/mod/forum/amd/build/discussion.min.js b/mod/forum/amd/build/discussion.min.js index 4da859b5154..332ee1f7c75 100644 --- a/mod/forum/amd/build/discussion.min.js +++ b/mod/forum/amd/build/discussion.min.js @@ -1,2 +1,2 @@ -define ("mod_forum/discussion",["jquery","core/custom_interaction_events","mod_forum/selectors"],function(a,b,c){var d=function(a){var b=a.prev(c.post.post);if(b.length){var d=b.find(c.post.post).last();if(d.length){d.focus()}else{b.focus()}}else{a.parents(c.post.post).first().focus()}},e=function(b){var d=b.find(c.post.post).first();if(d.length){d.focus()}else{var e=b.next(c.post.post);if(e.length){e.focus()}else{for(var f=b.parents(c.post.post).toArray(),g=0,h;g.\n\n/**\n * Module for viewing a discussion.\n *\n * @module mod_forum/discussion_list\n * @package mod_forum\n * @copyright 2019 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(\n[\n 'jquery',\n 'core/custom_interaction_events',\n 'mod_forum/selectors'\n],\nfunction(\n $,\n CustomEvents,\n Selectors\n) {\n\n /**\n * Set the focus on the previous post in the list. Previous post is calculated\n * based on position in list as viewed top to bottom.\n *\n * @param {Object} currentPost The post that currently has focus\n */\n var focusPreviousPost = function(currentPost) {\n // See if there is a previous sibling post.\n var prevPost = currentPost.prev(Selectors.post.post);\n\n if (prevPost.length) {\n // The previous post might have replies that appear visually between\n // it and the current post (see nested view) so if that's the case\n // then the last reply will be the previous post in the list.\n var replyPost = prevPost.find(Selectors.post.post).last();\n\n if (replyPost.length) {\n // Focus the last reply.\n replyPost.focus();\n } else {\n // No replies so we can focus straight on the sibling.\n prevPost.focus();\n }\n } else {\n // If there are no siblings then jump up the tree to the parent\n // post and focus the first parent post we find.\n currentPost.parents(Selectors.post.post).first().focus();\n }\n };\n\n /**\n * Set the focus on the next post in the list. Previous post is calculated\n * based on position in list as viewed top to bottom.\n *\n * @param {Object} currentPost The post that currently has focus\n */\n var focusNextPost = function(currentPost) {\n // The next post in the visual list would be the first reply to this one\n // so let's see if we have one.\n var replyPost = currentPost.find(Selectors.post.post).first();\n\n if (replyPost.length) {\n // Got a reply.\n replyPost.focus();\n } else {\n // If we don't have a reply then the next post in the visual list would\n // be a sibling post (replying to the same parent).\n var siblingPost = currentPost.next(Selectors.post.post);\n\n if (siblingPost.length) {\n siblingPost.focus();\n } else {\n // No siblings either. That means we're the lowest level reply in a thread\n // so we need to walk back up the tree of posts and find an ancestor post that\n // has a sibling post we can focus.\n var parentPosts = currentPost.parents(Selectors.post.post).toArray();\n\n for (var i = 0; i < parentPosts.length; i++) {\n var ancestorSiblingPost = $(parentPosts[i]).next(Selectors.post.post);\n\n if (ancestorSiblingPost.length) {\n ancestorSiblingPost.focus();\n break;\n }\n }\n }\n }\n };\n\n /**\n * Check if the element is inside the in page reply section.\n *\n * @param {Object} element The element to check\n * @return {Boolean}\n */\n var isElementInInPageReplySection = function(element) {\n var inPageReply = $(element).closest(Selectors.post.inpageReplyContent);\n return inPageReply.length ? true : false;\n };\n\n /**\n * Initialise the keyboard accessibility controls for the discussion.\n *\n * @param {Object} root The discussion root element\n */\n var initAccessibilityKeyboardNav = function(root) {\n var posts = root.find(Selectors.post.post);\n\n // Take each post action out of the tab index.\n posts.each(function(index, post) {\n var actions = $(post).find(Selectors.post.action);\n var firstAction = actions.first();\n actions.attr('tabindex', '-1');\n firstAction.attr('tabindex', 0);\n });\n\n CustomEvents.define(root, [\n CustomEvents.events.up,\n CustomEvents.events.down,\n CustomEvents.events.next,\n CustomEvents.events.previous,\n CustomEvents.events.home,\n CustomEvents.events.end,\n ]);\n\n root.on(CustomEvents.events.up, function(e, data) {\n var activeElement = document.activeElement;\n\n if (isElementInInPageReplySection(activeElement)) {\n // Focus is currently inside the in page reply section so don't move focus\n // to another post.\n return;\n }\n\n var focusPost = $(activeElement).closest(Selectors.post.post);\n\n if (focusPost.length) {\n focusPreviousPost(focusPost);\n } else {\n root.find(Selectors.post.post).first().focus();\n }\n\n data.originalEvent.preventDefault();\n });\n\n root.on(CustomEvents.events.down, function(e, data) {\n var activeElement = document.activeElement;\n\n if (isElementInInPageReplySection(activeElement)) {\n // Focus is currently inside the in page reply section so don't move focus\n // to another post.\n return;\n }\n\n var focusPost = $(activeElement).closest(Selectors.post.post);\n\n if (focusPost.length) {\n focusNextPost(focusPost);\n } else {\n root.find(Selectors.post.post).first().focus();\n }\n\n data.originalEvent.preventDefault();\n });\n\n root.on(CustomEvents.events.home, function(e, data) {\n if (isElementInInPageReplySection(document.activeElement)) {\n // Focus is currently inside the in page reply section so don't move focus\n // to another post.\n return;\n }\n root.find(Selectors.post.post).first().focus();\n data.originalEvent.preventDefault();\n });\n\n root.on(CustomEvents.events.end, function(e, data) {\n if (isElementInInPageReplySection(document.activeElement)) {\n // Focus is currently inside the in page reply section so don't move focus\n // to another post.\n return;\n }\n root.find(Selectors.post.post).last().focus();\n data.originalEvent.preventDefault();\n });\n\n root.on(CustomEvents.events.next, Selectors.post.action, function(e, data) {\n var currentAction = $(e.target);\n var container = currentAction.closest(Selectors.post.actionsContainer);\n var actions = container.find(Selectors.post.action);\n var nextAction = currentAction.next(Selectors.post.action);\n\n actions.attr('tabindex', '-1');\n\n if (!nextAction.length) {\n nextAction = actions.first();\n }\n\n nextAction.attr('tabindex', 0);\n nextAction.focus();\n\n data.originalEvent.preventDefault();\n });\n\n root.on(CustomEvents.events.previous, Selectors.post.action, function(e, data) {\n var currentAction = $(e.target);\n var container = currentAction.closest(Selectors.post.actionsContainer);\n var actions = container.find(Selectors.post.action);\n var nextAction = currentAction.prev(Selectors.post.action);\n\n actions.attr('tabindex', '-1');\n\n if (!nextAction.length) {\n nextAction = actions.last();\n }\n\n nextAction.attr('tabindex', 0);\n nextAction.focus();\n\n data.originalEvent.preventDefault();\n });\n\n root.on(CustomEvents.events.home, Selectors.post.action, function(e, data) {\n var currentAction = $(e.target);\n var container = currentAction.closest(Selectors.post.actionsContainer);\n var actions = container.find(Selectors.post.action);\n var firstAction = actions.first();\n\n actions.attr('tabindex', '-1');\n firstAction.attr('tabindex', 0);\n firstAction.focus();\n\n e.stopPropagation();\n data.originalEvent.preventDefault();\n });\n\n root.on(CustomEvents.events.end, Selectors.post.action, function(e, data) {\n var currentAction = $(e.target);\n var container = currentAction.closest(Selectors.post.actionsContainer);\n var actions = container.find(Selectors.post.action);\n var lastAction = actions.last();\n\n actions.attr('tabindex', '-1');\n lastAction.attr('tabindex', 0);\n lastAction.focus();\n\n e.stopPropagation();\n data.originalEvent.preventDefault();\n });\n };\n\n return {\n init: function(root) {\n initAccessibilityKeyboardNav(root);\n }\n };\n});\n"],"file":"discussion.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/discussion.js"],"names":["define","$","CustomEvents","Selectors","PubSub","ForumEvents","String","Notification","focusPreviousPost","currentPost","prevPost","prev","post","length","replyPost","find","last","focus","parents","first","focusNextPost","siblingPost","next","parentPosts","toArray","i","ancestorSiblingPost","isElementInInPageReplySection","element","inPageReply","closest","inpageReplyContent","initAccessibilityKeyboardNav","root","posts","each","index","actions","action","firstAction","attr","events","up","down","previous","home","end","on","e","data","activeElement","document","focusPost","originalEvent","preventDefault","currentAction","target","container","actionsContainer","nextAction","stopPropagation","lastAction","subscribe","SUBSCRIPTION_TOGGLED","subscribed","subscriptionState","updateMessage","get_string","then","s","addNotification","message","type","catch","exception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GAEA+B,CAAC,CAACY,eAAF,GACAX,CAAI,CAACI,aAAL,CAAmBC,cAAnB,EACH,CAZD,EAcAlD,CAAM,CAAC0D,SAAP,CAAiBzD,CAAW,CAAC0D,oBAA7B,CAAmD,SAASd,CAAT,CAAe,IAC1De,CAAAA,CAAU,CAAGf,CAAI,CAACgB,iBADwC,CAE1DC,CAAa,CAAGF,CAAU,CAAG,sBAAH,CAA4B,wBAFI,CAG9D1D,CAAM,CAAC6D,UAAP,CAAkBD,CAAlB,CAAiC,OAAjC,EACKE,IADL,CACU,SAASC,CAAT,CAAY,CACd,MAAO9D,CAAAA,CAAY,CAAC+D,eAAb,CAA6B,CAChCC,OAAO,CAAEF,CADuB,CAEhCG,IAAI,CAAE,MAF0B,CAA7B,CAIV,CANL,EAOKC,KAPL,CAOWlE,CAAY,CAACmE,SAPxB,CAQH,CAXD,CAYH,CAnPH,CAqPE,MAAO,CACHC,IAAI,CAAE,cAAS1C,CAAT,CAAe,CACjBD,CAA4B,CAACC,CAAD,CAC/B,CAHE,CAKV,CA5QK,CAAN","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 .\n\n/**\n * Module for viewing a discussion.\n *\n * @module mod_forum/discussion_list\n * @package mod_forum\n * @copyright 2019 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(\n[\n 'jquery',\n 'core/custom_interaction_events',\n 'mod_forum/selectors',\n 'core/pubsub',\n 'mod_forum/forum_events',\n 'core/str',\n 'core/notification',\n],\nfunction(\n $,\n CustomEvents,\n Selectors,\n PubSub,\n ForumEvents,\n String,\n Notification\n) {\n\n /**\n * Set the focus on the previous post in the list. Previous post is calculated\n * based on position in list as viewed top to bottom.\n *\n * @param {Object} currentPost The post that currently has focus\n */\n var focusPreviousPost = function(currentPost) {\n // See if there is a previous sibling post.\n var prevPost = currentPost.prev(Selectors.post.post);\n\n if (prevPost.length) {\n // The previous post might have replies that appear visually between\n // it and the current post (see nested view) so if that's the case\n // then the last reply will be the previous post in the list.\n var replyPost = prevPost.find(Selectors.post.post).last();\n\n if (replyPost.length) {\n // Focus the last reply.\n replyPost.focus();\n } else {\n // No replies so we can focus straight on the sibling.\n prevPost.focus();\n }\n } else {\n // If there are no siblings then jump up the tree to the parent\n // post and focus the first parent post we find.\n currentPost.parents(Selectors.post.post).first().focus();\n }\n };\n\n /**\n * Set the focus on the next post in the list. Previous post is calculated\n * based on position in list as viewed top to bottom.\n *\n * @param {Object} currentPost The post that currently has focus\n */\n var focusNextPost = function(currentPost) {\n // The next post in the visual list would be the first reply to this one\n // so let's see if we have one.\n var replyPost = currentPost.find(Selectors.post.post).first();\n\n if (replyPost.length) {\n // Got a reply.\n replyPost.focus();\n } else {\n // If we don't have a reply then the next post in the visual list would\n // be a sibling post (replying to the same parent).\n var siblingPost = currentPost.next(Selectors.post.post);\n\n if (siblingPost.length) {\n siblingPost.focus();\n } else {\n // No siblings either. That means we're the lowest level reply in a thread\n // so we need to walk back up the tree of posts and find an ancestor post that\n // has a sibling post we can focus.\n var parentPosts = currentPost.parents(Selectors.post.post).toArray();\n\n for (var i = 0; i < parentPosts.length; i++) {\n var ancestorSiblingPost = $(parentPosts[i]).next(Selectors.post.post);\n\n if (ancestorSiblingPost.length) {\n ancestorSiblingPost.focus();\n break;\n }\n }\n }\n }\n };\n\n /**\n * Check if the element is inside the in page reply section.\n *\n * @param {Object} element The element to check\n * @return {Boolean}\n */\n var isElementInInPageReplySection = function(element) {\n var inPageReply = $(element).closest(Selectors.post.inpageReplyContent);\n return inPageReply.length ? true : false;\n };\n\n /**\n * Initialise the keyboard accessibility controls for the discussion.\n *\n * @param {Object} root The discussion root element\n */\n var initAccessibilityKeyboardNav = function(root) {\n var posts = root.find(Selectors.post.post);\n\n // Take each post action out of the tab index.\n posts.each(function(index, post) {\n var actions = $(post).find(Selectors.post.action);\n var firstAction = actions.first();\n actions.attr('tabindex', '-1');\n firstAction.attr('tabindex', 0);\n });\n\n CustomEvents.define(root, [\n CustomEvents.events.up,\n CustomEvents.events.down,\n CustomEvents.events.next,\n CustomEvents.events.previous,\n CustomEvents.events.home,\n CustomEvents.events.end,\n ]);\n\n root.on(CustomEvents.events.up, function(e, data) {\n var activeElement = document.activeElement;\n\n if (isElementInInPageReplySection(activeElement)) {\n // Focus is currently inside the in page reply section so don't move focus\n // to another post.\n return;\n }\n\n var focusPost = $(activeElement).closest(Selectors.post.post);\n\n if (focusPost.length) {\n focusPreviousPost(focusPost);\n } else {\n root.find(Selectors.post.post).first().focus();\n }\n\n data.originalEvent.preventDefault();\n });\n\n root.on(CustomEvents.events.down, function(e, data) {\n var activeElement = document.activeElement;\n\n if (isElementInInPageReplySection(activeElement)) {\n // Focus is currently inside the in page reply section so don't move focus\n // to another post.\n return;\n }\n\n var focusPost = $(activeElement).closest(Selectors.post.post);\n\n if (focusPost.length) {\n focusNextPost(focusPost);\n } else {\n root.find(Selectors.post.post).first().focus();\n }\n\n data.originalEvent.preventDefault();\n });\n\n root.on(CustomEvents.events.home, function(e, data) {\n if (isElementInInPageReplySection(document.activeElement)) {\n // Focus is currently inside the in page reply section so don't move focus\n // to another post.\n return;\n }\n root.find(Selectors.post.post).first().focus();\n data.originalEvent.preventDefault();\n });\n\n root.on(CustomEvents.events.end, function(e, data) {\n if (isElementInInPageReplySection(document.activeElement)) {\n // Focus is currently inside the in page reply section so don't move focus\n // to another post.\n return;\n }\n root.find(Selectors.post.post).last().focus();\n data.originalEvent.preventDefault();\n });\n\n root.on(CustomEvents.events.next, Selectors.post.action, function(e, data) {\n var currentAction = $(e.target);\n var container = currentAction.closest(Selectors.post.actionsContainer);\n var actions = container.find(Selectors.post.action);\n var nextAction = currentAction.next(Selectors.post.action);\n\n actions.attr('tabindex', '-1');\n\n if (!nextAction.length) {\n nextAction = actions.first();\n }\n\n nextAction.attr('tabindex', 0);\n nextAction.focus();\n\n data.originalEvent.preventDefault();\n });\n\n root.on(CustomEvents.events.previous, Selectors.post.action, function(e, data) {\n var currentAction = $(e.target);\n var container = currentAction.closest(Selectors.post.actionsContainer);\n var actions = container.find(Selectors.post.action);\n var nextAction = currentAction.prev(Selectors.post.action);\n\n actions.attr('tabindex', '-1');\n\n if (!nextAction.length) {\n nextAction = actions.last();\n }\n\n nextAction.attr('tabindex', 0);\n nextAction.focus();\n\n data.originalEvent.preventDefault();\n });\n\n root.on(CustomEvents.events.home, Selectors.post.action, function(e, data) {\n var currentAction = $(e.target);\n var container = currentAction.closest(Selectors.post.actionsContainer);\n var actions = container.find(Selectors.post.action);\n var firstAction = actions.first();\n\n actions.attr('tabindex', '-1');\n firstAction.attr('tabindex', 0);\n firstAction.focus();\n\n e.stopPropagation();\n data.originalEvent.preventDefault();\n });\n\n root.on(CustomEvents.events.end, Selectors.post.action, function(e, data) {\n var currentAction = $(e.target);\n var container = currentAction.closest(Selectors.post.actionsContainer);\n var actions = container.find(Selectors.post.action);\n var lastAction = actions.last();\n\n actions.attr('tabindex', '-1');\n lastAction.attr('tabindex', 0);\n lastAction.focus();\n\n e.stopPropagation();\n data.originalEvent.preventDefault();\n });\n\n PubSub.subscribe(ForumEvents.SUBSCRIPTION_TOGGLED, function(data) {\n var subscribed = data.subscriptionState;\n var updateMessage = subscribed ? 'discussionsubscribed' : 'discussionunsubscribed';\n String.get_string(updateMessage, \"forum\")\n .then(function(s) {\n return Notification.addNotification({\n message: s,\n type: \"info\"\n });\n })\n .catch(Notification.exception);\n });\n };\n\n return {\n init: function(root) {\n initAccessibilityKeyboardNav(root);\n }\n };\n});\n"],"file":"discussion.min.js"} \ No newline at end of file diff --git a/mod/forum/amd/build/discussion_list.min.js b/mod/forum/amd/build/discussion_list.min.js index 1112d8f1e8b..be3944b92c6 100644 --- a/mod/forum/amd/build/discussion_list.min.js +++ b/mod/forum/amd/build/discussion_list.min.js @@ -1,2 +1,2 @@ -define ("mod_forum/discussion_list",["jquery","core/templates","core/str","core/notification","mod_forum/subscription_toggle","mod_forum/selectors","mod_forum/repository"],function(a,b,c,d,e,f,g){var h=function(e){e.on("click",f.favourite.toggle,function(){var b=a(this),c=b.data("forumid"),e=b.data("discussionid"),f=b.data("targetstate");g.setFavouriteDiscussionState(c,e,f).then(function(){return location.reload()}).catch(d.exception)});e.on("click",f.pin.toggle,function(b){b.preventDefault();var c=a(this),e=c.data("forumid"),f=c.data("discussionid"),h=c.data("targetstate");g.setPinDiscussionState(e,f,h).then(function(){return location.reload()}).catch(d.exception)});e.on("click",f.lock.toggle,function(h){var e=a(this),i=e.data("forumid"),j=e.data("discussionid"),k=e.data("state");g.setDiscussionLockState(i,j,k).then(function(a){var b=e.parents(f.summary.actions).find(f.lock.icon);if(a.locked){b.removeClass("hidden")}else{b.addClass("hidden")}return a}).then(function(a){a.forumid=i;return b.render("mod_forum/discussion_lock_toggle",a)}).then(function(a,c){return b.replaceNode(e,a,c)}).then(function(){return c.get_string("lockupdated","forum").done(function(a){return d.addNotification({message:a,type:"info"})})}).catch(d.exception);h.preventDefault()})};return{init:function init(a){e.init(a);h(a)}}}); +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"],function(a,b,c,d,e,f,g,h,i){var j=function(e){h.subscribe(i.SUBSCRIPTION_TOGGLED,function(a){var b=a.discussionId,c=a.subscriptionState,d=e.find(f.discussion.item+"[data-discussionid= "+b+"] "+f.discussion.subscribedLabel);if(c){d.removeAttr("hidden")}else{d.attr("hidden",!0)}});e.on("click",f.favourite.toggle,function(){var b=a(this),c=b.data("forumid"),e=b.data("discussionid"),f=b.data("targetstate");g.setFavouriteDiscussionState(c,e,f).then(function(){return location.reload()}).catch(d.exception)});e.on("click",f.pin.toggle,function(b){b.preventDefault();var c=a(this),e=c.data("forumid"),f=c.data("discussionid"),h=c.data("targetstate");g.setPinDiscussionState(e,f,h).then(function(){return location.reload()}).catch(d.exception)});e.on("click",f.lock.toggle,function(h){var e=a(this),i=e.data("forumid"),j=e.data("discussionid"),k=e.data("state");g.setDiscussionLockState(i,j,k).then(function(a){var b=e.parents(f.summary.actions).find(f.lock.icon),c=e.parents(f.discussion.item).find(f.discussion.lockedLabel);if(a.locked){b.removeClass("hidden");c.removeAttr("hidden")}else{b.addClass("hidden");c.attr("hidden",!0)}return a}).then(function(a){a.forumid=i;return b.render("mod_forum/discussion_lock_toggle",a)}).then(function(a,c){return b.replaceNode(e,a,c)}).then(function(){return c.get_string("lockupdated","forum").done(function(a){return d.addNotification({message:a,type:"info"})})}).catch(d.exception);h.preventDefault()})};return{init:function init(a){e.init(a);j(a)}}}); //# sourceMappingURL=discussion_list.min.js.map diff --git a/mod/forum/amd/build/discussion_list.min.js.map b/mod/forum/amd/build/discussion_list.min.js.map index de8b7d6ae0b..9d8b2fb6524 100644 --- a/mod/forum/amd/build/discussion_list.min.js.map +++ b/mod/forum/amd/build/discussion_list.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/discussion_list.js"],"names":["define","$","Templates","String","Notification","SubscriptionToggle","Selectors","Repository","registerEventListeners","root","on","favourite","toggle","toggleElement","forumId","data","discussionId","subscriptionState","setFavouriteDiscussionState","then","location","reload","catch","exception","pin","e","preventDefault","state","setPinDiscussionState","lock","setDiscussionLockState","context","icon","parents","summary","actions","find","locked","removeClass","addClass","forumid","render","html","js","replaceNode","get_string","done","s","addNotification","message","type","init"],"mappings":"AAuBAA,OAAM,6BAAC,CACH,QADG,CAEH,gBAFG,CAGH,UAHG,CAIH,mBAJG,CAKH,+BALG,CAMH,qBANG,CAOH,sBAPG,CAAD,CAQH,SACCC,CADD,CAECC,CA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,SAASC,CAAT,CAAY,CACd,MAAO3C,CAAAA,CAAY,CAAC4C,eAAb,CAA6B,CAChCC,OAAO,CAAEF,CADuB,CAEhCG,IAAI,CAAE,MAF0B,CAA7B,CAIV,CANE,CAOV,CAzBL,EA0BK5B,KA1BL,CA0BWlB,CAAY,CAACmB,SA1BxB,EA4BAE,CAAC,CAACC,cAAF,EACH,CAnCD,CAoCH,CA9DD,CAgEA,MAAO,CACHyB,IAAI,CAAE,cAAS1C,CAAT,CAAe,CACjBJ,CAAkB,CAAC8C,IAAnB,CAAwB1C,CAAxB,EACAD,CAAsB,CAACC,CAAD,CACzB,CAJE,CAMV,CAvFK,CAAN","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 .\n\n/**\n * Module for the list of discussions on when viewing a forum.\n *\n * @module mod_forum/discussion_list\n * @package mod_forum\n * @copyright 2019 Andrew Nicols \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/templates',\n 'core/str',\n 'core/notification',\n 'mod_forum/subscription_toggle',\n 'mod_forum/selectors',\n 'mod_forum/repository',\n], function(\n $,\n Templates,\n String,\n Notification,\n SubscriptionToggle,\n Selectors,\n Repository\n) {\n var registerEventListeners = function(root) {\n root.on('click', Selectors.favourite.toggle, function() {\n var toggleElement = $(this);\n var forumId = toggleElement.data('forumid');\n var discussionId = toggleElement.data('discussionid');\n var subscriptionState = toggleElement.data('targetstate');\n Repository.setFavouriteDiscussionState(forumId, discussionId, subscriptionState)\n .then(function() {\n return location.reload();\n })\n .catch(Notification.exception);\n });\n\n root.on('click', Selectors.pin.toggle, function(e) {\n e.preventDefault();\n var toggleElement = $(this);\n var forumId = toggleElement.data('forumid');\n var discussionId = toggleElement.data('discussionid');\n var state = toggleElement.data('targetstate');\n Repository.setPinDiscussionState(forumId, discussionId, state)\n .then(function() {\n return location.reload();\n })\n .catch(Notification.exception);\n });\n\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(context) {\n var icon = toggleElement.parents(Selectors.summary.actions).find(Selectors.lock.icon);\n if (context.locked) {\n icon.removeClass('hidden');\n } else {\n icon.addClass('hidden');\n }\n return context;\n })\n .then(function(context) {\n context.forumid = forumId;\n return Templates.render('mod_forum/discussion_lock_toggle', context);\n })\n .then(function(html, js) {\n return Templates.replaceNode(toggleElement, html, js);\n })\n .then(function() {\n return String.get_string('lockupdated', 'forum')\n .done(function(s) {\n return Notification.addNotification({\n message: s,\n type: \"info\"\n });\n });\n })\n .catch(Notification.exception);\n\n e.preventDefault();\n });\n };\n\n return {\n init: function(root) {\n SubscriptionToggle.init(root);\n registerEventListeners(root);\n }\n };\n});\n"],"file":"discussion_list.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/discussion_list.js"],"names":["define","$","Templates","String","Notification","SubscriptionToggle","Selectors","Repository","PubSub","ForumEvents","registerEventListeners","root","subscribe","SUBSCRIPTION_TOGGLED","data","discussionId","subscribed","subscriptionState","subscribedLabel","find","discussion","item","removeAttr","attr","on","favourite","toggle","toggleElement","forumId","setFavouriteDiscussionState","then","location","reload","catch","exception","pin","e","preventDefault","state","setPinDiscussionState","lock","setDiscussionLockState","context","icon","parents","summary","actions","lockedLabel","locked","removeClass","addClass","forumid","render","html","js","replaceNode","get_string","done","s","addNotification","message","type","init"],"mappings":"AAuBAA,OAAM,6BAAC,CACH,QADG,CAEH,gBAFG,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,CAAD,CACzB,CAJE,CAMV,CA1GK,CAAN","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 .\n\n/**\n * Module for the list of discussions on when viewing a forum.\n *\n * @module mod_forum/discussion_list\n * @package mod_forum\n * @copyright 2019 Andrew Nicols \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/templates',\n 'core/str',\n 'core/notification',\n 'mod_forum/subscription_toggle',\n 'mod_forum/selectors',\n 'mod_forum/repository',\n 'core/pubsub',\n 'mod_forum/forum_events',\n], function(\n $,\n Templates,\n String,\n Notification,\n SubscriptionToggle,\n Selectors,\n Repository,\n PubSub,\n ForumEvents\n) {\n var registerEventListeners = function(root) {\n PubSub.subscribe(ForumEvents.SUBSCRIPTION_TOGGLED, function(data) {\n var discussionId = data.discussionId;\n var subscribed = data.subscriptionState;\n var subscribedLabel = root.find(Selectors.discussion.item + '[data-discussionid= ' + discussionId + '] '\n + Selectors.discussion.subscribedLabel);\n if (subscribed) {\n subscribedLabel.removeAttr('hidden');\n } else {\n subscribedLabel.attr('hidden', true);\n }\n });\n\n root.on('click', Selectors.favourite.toggle, function() {\n var toggleElement = $(this);\n var forumId = toggleElement.data('forumid');\n var discussionId = toggleElement.data('discussionid');\n var subscriptionState = toggleElement.data('targetstate');\n Repository.setFavouriteDiscussionState(forumId, discussionId, subscriptionState)\n .then(function() {\n return location.reload();\n })\n .catch(Notification.exception);\n });\n\n root.on('click', Selectors.pin.toggle, function(e) {\n e.preventDefault();\n var toggleElement = $(this);\n var forumId = toggleElement.data('forumid');\n var discussionId = toggleElement.data('discussionid');\n var state = toggleElement.data('targetstate');\n Repository.setPinDiscussionState(forumId, discussionId, state)\n .then(function() {\n return location.reload();\n })\n .catch(Notification.exception);\n });\n\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(context) {\n var icon = toggleElement.parents(Selectors.summary.actions).find(Selectors.lock.icon);\n var lockedLabel = toggleElement.parents(Selectors.discussion.item).find(Selectors.discussion.lockedLabel);\n if (context.locked) {\n icon.removeClass('hidden');\n lockedLabel.removeAttr('hidden');\n } else {\n icon.addClass('hidden');\n lockedLabel.attr('hidden', true);\n }\n return context;\n })\n .then(function(context) {\n context.forumid = forumId;\n return Templates.render('mod_forum/discussion_lock_toggle', context);\n })\n .then(function(html, js) {\n return Templates.replaceNode(toggleElement, html, js);\n })\n .then(function() {\n return String.get_string('lockupdated', 'forum')\n .done(function(s) {\n return Notification.addNotification({\n message: s,\n type: \"info\"\n });\n });\n })\n .catch(Notification.exception);\n\n e.preventDefault();\n });\n };\n\n return {\n init: function(root) {\n SubscriptionToggle.init(root);\n registerEventListeners(root);\n }\n };\n});\n"],"file":"discussion_list.min.js"} \ No newline at end of file diff --git a/mod/forum/amd/build/forum_events.min.js b/mod/forum/amd/build/forum_events.min.js new file mode 100644 index 00000000000..87d4f07b1d3 --- /dev/null +++ b/mod/forum/amd/build/forum_events.min.js @@ -0,0 +1,2 @@ +define ("mod_forum/forum_events",[],function(){return{SUBSCRIPTION_TOGGLED:"mod_forum/subscription_toggle:subscriptionToggled"}}); +//# sourceMappingURL=forum_events.min.js.map diff --git a/mod/forum/amd/build/forum_events.min.js.map b/mod/forum/amd/build/forum_events.min.js.map new file mode 100644 index 00000000000..e0343be744a --- /dev/null +++ b/mod/forum/amd/build/forum_events.min.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/forum_events.js"],"names":["define","SUBSCRIPTION_TOGGLED"],"mappings":"AAuBAA,OAAM,0BAAC,EAAD,CAAK,UAAW,CAClB,MAAO,CACHC,oBAAoB,CAAE,mDADnB,CAGV,CAJK,CAAN","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 .\n\n/**\n * Events for the forum activity.\n *\n * @module mod_forum/forum_events\n * @package mod_forum\n * @copyright 2019 Jun Pataleta \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"],"file":"forum_events.min.js"} \ No newline at end of file diff --git a/mod/forum/amd/build/selectors.min.js b/mod/forum/amd/build/selectors.min.js index f1c788b34a6..2bb490eaef4 100644 --- a/mod/forum/amd/build/selectors.min.js +++ b/mod/forum/amd/build/selectors.min.js @@ -1,2 +1,2 @@ -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']",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\"]"}}}); +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']",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 diff --git a/mod/forum/amd/build/selectors.min.js.map b/mod/forum/amd/build/selectors.min.js.map index 2a4d3af522d..7b67eb41748 100644 --- a/mod/forum/amd/build/selectors.min.js.map +++ b/mod/forum/amd/build/selectors.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/selectors.js"],"names":["define","subscription","toggle","summary","actions","post","action","actionsContainer","authorName","forumCoreContent","forumContent","forumSubject","inpageReplyButton","inpageReplyLink","inpageReplyCancelButton","inpageReplyCreateButton","inpageReplyContainer","inpageReplyContent","inpageReplyForm","inpageSubmitBtn","inpageSubmitBtnText","loadingIconContainer","repliesContainer","replyCount","modeSelect","showReplies","hideReplies","repliesVisibilityToggleContainer","lock","icon","favourite","pin","discussion","tools"],"mappings":"AAuBAA,OAAM,uBAAC,EAAD,CAAK,UAAW,CAClB,MAAO,CACHC,YAAY,CAAE,CACVC,MAAM,CAAE,yDADE,CADX,CAIHC,OAAO,CAAE,CACLC,OAAO,CAAE,+CADJ,CAJN,CAOHC,IAAI,CAAE,CACFA,IAAI,CAAE,wBADJ,CAEFC,MAAM,CAAE,+BAFN,CAGFC,gBAAgB,CAAE,0CAHhB,CAIFC,UAAU,CAAE,+BAJV,CAKFC,gBAAgB,CAAE,yCALhB,CAMFC,YAAY,CAAE,6BANZ,CAOFC,YAAY,CAAE,iDAPZ,CAQFC,iBAAiB,CAAE,QARjB,CASFC,eAAe,CAAE,kCATf,CAUFC,uBAAuB,CAAE,qCAVvB,CAWFC,uBAAuB,CAAE,qCAXvB,CAYFC,oBAAoB,CAAE,0CAZpB,CAaFC,kBAAkB,CAAE,uCAblB,CAcFC,eAAe,CAAE,wCAdf,CAeFC,eAAe,CAAE,qCAff,CAgBFC,mBAAmB,CAAE,6BAhBnB,CAiBFC,oBAAoB,CAAE,wCAjBpB,CAkBFC,gBAAgB,CAAE,mCAlBhB,CAmBFC,UAAU,CAAE,+BAnBV,CAoBFC,UAAU,CAAE,qBApBV,CAqBFC,WAAW,CAAE,gCArBX,CAsBFC,WAAW,CAAE,gCAtBX,CAuBFC,gCAAgC,CAAE,uDAvBhC,CAPH,CAgCHC,IAAI,CAAE,CACF1B,MAAM,CAAE,iDADN,CAEF2B,IAAI,CAAE,6BAFJ,CAhCH,CAoCHC,SAAS,CAAE,CACP5B,MAAM,CAAE,qDADD,CApCR,CAuCH6B,GAAG,CAAE,CACD7B,MAAM,CAAE,gDADP,CAvCF,CA0CH8B,UAAU,CAAE,CACRC,KAAK,CAAE,uCADC,CA1CT,CA8CV,CA/CK,CAAN","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 .\n\n/**\n * Common CSS selectors for the forum UI.\n *\n * @module mod_forum/selectors\n * @package mod_forum\n * @copyright 2019 Andrew Nicols \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 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 }\n };\n});\n"],"file":"selectors.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/selectors.js"],"names":["define","subscription","toggle","summary","actions","post","action","actionsContainer","authorName","forumCoreContent","forumContent","forumSubject","inpageReplyButton","inpageReplyLink","inpageReplyCancelButton","inpageReplyCreateButton","inpageReplyContainer","inpageReplyContent","inpageReplyForm","inpageSubmitBtn","inpageSubmitBtnText","loadingIconContainer","repliesContainer","replyCount","modeSelect","showReplies","hideReplies","repliesVisibilityToggleContainer","lock","icon","favourite","pin","discuss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,CAAN","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 .\n\n/**\n * Common CSS selectors for the forum UI.\n *\n * @module mod_forum/selectors\n * @package mod_forum\n * @copyright 2019 Andrew Nicols \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 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"],"file":"selectors.min.js"} \ No newline at end of file diff --git a/mod/forum/amd/build/subscription_toggle.min.js b/mod/forum/amd/build/subscription_toggle.min.js index 9f5d8a39318..505c13d9a92 100644 --- a/mod/forum/amd/build/subscription_toggle.min.js +++ b/mod/forum/amd/build/subscription_toggle.min.js @@ -1,2 +1,2 @@ -define ("mod_forum/subscription_toggle",["jquery","core/templates","core/notification","mod_forum/repository","mod_forum/selectors"],function(a,b,c,d,e){var f=function(f){f.on("click",e.subscription.toggle,function(f){var e=a(this),g=e.data("forumid"),h=e.data("discussionid"),i=e.data("targetstate");d.setDiscussionSubscriptionState(g,h,i).then(function(a){return b.render("mod_forum/discussion_subscription_toggle",a)}).then(function(a,c){return b.replaceNode(e,a,c)}).catch(c.exception);f.preventDefault()})};return{init:function init(a){f(a)}}}); +define ("mod_forum/subscription_toggle",["jquery","core/templates","core/notification","mod_forum/repository","mod_forum/selectors","core/pubsub","mod_forum/forum_events"],function(a,b,c,d,e,f,g){var h=function(h){h.on("click",e.subscription.toggle,function(h){var e=a(this),i=e.data("forumid"),j=e.data("discussionid"),k=e.data("targetstate");d.setDiscussionSubscriptionState(i,j,k).then(function(a){f.publish(g.SUBSCRIPTION_TOGGLED,{discussionId:j,subscriptionState:k});return b.render("mod_forum/discussion_subscription_toggle",a)}).then(function(a,c){return b.replaceNode(e,a,c)}).catch(c.exception);h.preventDefault()})};return{init:function init(a){h(a)}}}); //# sourceMappingURL=subscription_toggle.min.js.map diff --git a/mod/forum/amd/build/subscription_toggle.min.js.map b/mod/forum/amd/build/subscription_toggle.min.js.map index 803b5d234d6..6ecb9672b19 100644 --- a/mod/forum/amd/build/subscription_toggle.min.js.map +++ b/mod/forum/amd/build/subscription_toggle.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/subscription_toggle.js"],"names":["define","$","Templates","Notification","Repository","Selectors","registerEventListeners","root","on","subscription","toggle","e","toggleElement","forumId","data","discussionId","subscriptionState","setDiscussionSubscriptionState","then","context","render","html","js","replaceNode","catch","exception","preventDefault","init"],"mappings":"AAwBAA,OAAM,iCAAC,CACC,QADD,CAEC,gBAFD,CAGC,mBAHD,CAIC,sBAJD,CAKC,qBALD,CAAD,CAMC,SACCC,CADD,CAECC,CAFD,CAGCC,CAHD,CAICC,CAJD,CAKCC,CALD,CAMD,CAOF,GAAIC,CAAAA,CAAsB,CAAG,SAASC,CAAT,CAAe,CACxCA,CAAI,CAACC,EAAL,CAAQ,OAAR,CAAiBH,CAAS,CAACI,YAAV,CAAuBC,MAAxC,CAAgD,SAASC,CAAT,CAAY,IACpDC,CAAAA,CAAa,CAAGX,CAAC,CAAC,IAAD,CADmC,CAEpDY,CAAO,CAAGD,CAAa,CAACE,IAAd,CAAmB,SAAnB,CAF0C,CAGpDC,CAAY,CAAGH,CAAa,CAACE,IAAd,CAAmB,cAAnB,CAHqC,CAIpDE,CAAiB,CAAGJ,CAAa,CAACE,IAAd,CAAmB,aAAnB,CAJgC,CAMxDV,CAAU,CAACa,8BAAX,CAA0CJ,CAA1C,CAAmDE,CAAnD,CAAiEC,CAAjE,EACKE,IADL,CACU,SAASC,CAAT,CAAkB,CACpB,MAAOjB,CAAAA,CAAS,CAACkB,MAAV,CAAiB,0CAAjB,CAA6DD,CAA7D,CACV,CAHL,EAIKD,IAJL,CAIU,SAASG,CAAT,CAAeC,CAAf,CAAmB,CACrB,MAAOpB,CAAAA,CAAS,CAACqB,WAAV,CAAsBX,CAAtB,CAAqCS,CAArC,CAA2CC,CAA3C,CACV,CANL,EAOKE,KAPL,CAOWrB,CAAY,CAACsB,SAPxB,EASAd,CAAC,CAACe,cAAF,EACH,CAhBD,CAiBH,CAlBD,CAoBA,MAAO,CACHC,IAAI,CAAE,cAASpB,CAAT,CAAe,CACjBD,CAAsB,CAACC,CAAD,CACzB,CAHE,CAKV,CA5CK,CAAN","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 .\n\n/**\n * Handle discussion subscription toggling on a discussion list in\n * the forum view.\n *\n * @module mod_forum/subscription_toggle\n * @package mod_forum\n * @copyright 2019 Andrew Nicols \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 */\n var registerEventListeners = function(root) {\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 return Templates.render('mod_forum/discussion_subscription_toggle', context);\n })\n .then(function(html, js) {\n return Templates.replaceNode(toggleElement, html, js);\n })\n .catch(Notification.exception);\n\n e.preventDefault();\n });\n };\n\n return {\n init: function(root) {\n registerEventListeners(root);\n }\n };\n});\n"],"file":"subscription_toggle.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/subscription_toggle.js"],"names":["define","$","Templates","Notification","Repository","Selectors","PubSub","ForumEvents","registerEventListeners","root","on","subscription","toggle","e","toggleElement","forumId","data","discussionId","subscriptionState","setDiscussionSubscriptionState","then","context","publish","SUBSCRIPTION_TOGGLED","render","html","js","replaceNode","catch","exception","preventDefault","init"],"mappings":"AAwBAA,OAAM,iCAAC,CACC,QADD,CAEC,gBAFD,CAGC,mBAHD,CAIC,sBAJD,CAKC,qBALD,CAMC,aAND,CAOC,wBAPD,CAAD,CAQC,SACCC,CADD,CAECC,CAFD,CAGCC,CAHD,CAICC,CAJD,CAKCC,CALD,CAMCC,CAND,CAOCC,CAPD,CAQD,CAOF,GAAIC,CAAAA,CAAsB,CAAG,SAASC,CAAT,CAAe,CACxCA,CAAI,CAACC,EAAL,CAAQ,OAAR,CAAiBL,CAAS,CAACM,YAAV,CAAuBC,MAAxC,CAAgD,SAASC,CAAT,CAAY,IACpDC,CAAAA,CAAa,CAAGb,CAAC,CAAC,IAAD,CADmC,CAEpDc,CAAO,CAAGD,CAAa,CAACE,IAAd,CAAmB,SAAnB,CAF0C,CAGpDC,CAAY,CAAGH,CAAa,CAACE,IAAd,CAAmB,cAAnB,CAHqC,CAIpDE,CAAiB,CAAGJ,CAAa,CAACE,IAAd,CAAmB,aAAnB,CAJgC,CAMxDZ,CAAU,CAACe,8BAAX,CAA0CJ,CAA1C,CAAmDE,CAAnD,CAAiEC,CAAjE,EACKE,IADL,CACU,SAASC,CAAT,CAAkB,CACpBf,CAAM,CAACgB,OAAP,CAAef,CAAW,CAACgB,oBAA3B,CAAiD,CAC7CN,YAAY,CAAEA,CAD+B,CAE7CC,iBAAiB,CAAEA,CAF0B,CAAjD,EAIA,MAAOhB,CAAAA,CAAS,CAACsB,MAAV,CAAiB,0CAAjB,CAA6DH,CAA7D,CACV,CAPL,EAQKD,IARL,CAQU,SAASK,CAAT,CAAeC,CAAf,CAAmB,CACrB,MAAOxB,CAAAA,CAAS,CAACyB,WAAV,CAAsBb,CAAtB,CAAqCW,CAArC,CAA2CC,CAA3C,CACV,CAVL,EAWKE,KAXL,CAWWzB,CAAY,CAAC0B,SAXxB,EAaAhB,CAAC,CAACiB,cAAF,EACH,CApBD,CAqBH,CAtBD,CAwBA,MAAO,CACHC,IAAI,CAAE,cAAStB,CAAT,CAAe,CACjBD,CAAsB,CAACC,CAAD,CACzB,CAHE,CAKV,CApDK,CAAN","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 .\n\n/**\n * Handle discussion subscription toggling on a discussion list in\n * the forum view.\n *\n * @module mod_forum/subscription_toggle\n * @package mod_forum\n * @copyright 2019 Andrew Nicols \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 */\n var registerEventListeners = function(root) {\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 Templates.render('mod_forum/discussion_subscription_toggle', context);\n })\n .then(function(html, js) {\n return Templates.replaceNode(toggleElement, html, js);\n })\n .catch(Notification.exception);\n\n e.preventDefault();\n });\n };\n\n return {\n init: function(root) {\n registerEventListeners(root);\n }\n };\n});\n"],"file":"subscription_toggle.min.js"} \ No newline at end of file diff --git a/mod/forum/amd/src/discussion.js b/mod/forum/amd/src/discussion.js index 81afd8fd7ac..bad0b363078 100644 --- a/mod/forum/amd/src/discussion.js +++ b/mod/forum/amd/src/discussion.js @@ -25,12 +25,20 @@ define( [ 'jquery', 'core/custom_interaction_events', - 'mod_forum/selectors' + 'mod_forum/selectors', + 'core/pubsub', + 'mod_forum/forum_events', + 'core/str', + 'core/notification', ], function( $, CustomEvents, - Selectors + Selectors, + PubSub, + ForumEvents, + String, + Notification ) { /** @@ -261,6 +269,19 @@ function( e.stopPropagation(); data.originalEvent.preventDefault(); }); + + PubSub.subscribe(ForumEvents.SUBSCRIPTION_TOGGLED, function(data) { + var subscribed = data.subscriptionState; + var updateMessage = subscribed ? 'discussionsubscribed' : 'discussionunsubscribed'; + String.get_string(updateMessage, "forum") + .then(function(s) { + return Notification.addNotification({ + message: s, + type: "info" + }); + }) + .catch(Notification.exception); + }); }; return { diff --git a/mod/forum/amd/src/discussion_list.js b/mod/forum/amd/src/discussion_list.js index b24718a0fa1..2dafd3930f6 100644 --- a/mod/forum/amd/src/discussion_list.js +++ b/mod/forum/amd/src/discussion_list.js @@ -29,6 +29,8 @@ define([ 'mod_forum/subscription_toggle', 'mod_forum/selectors', 'mod_forum/repository', + 'core/pubsub', + 'mod_forum/forum_events', ], function( $, Templates, @@ -36,9 +38,23 @@ define([ Notification, SubscriptionToggle, Selectors, - Repository + Repository, + PubSub, + ForumEvents ) { var registerEventListeners = function(root) { + PubSub.subscribe(ForumEvents.SUBSCRIPTION_TOGGLED, function(data) { + var discussionId = data.discussionId; + var subscribed = data.subscriptionState; + var subscribedLabel = root.find(Selectors.discussion.item + '[data-discussionid= ' + discussionId + '] ' + + Selectors.discussion.subscribedLabel); + if (subscribed) { + subscribedLabel.removeAttr('hidden'); + } else { + subscribedLabel.attr('hidden', true); + } + }); + root.on('click', Selectors.favourite.toggle, function() { var toggleElement = $(this); var forumId = toggleElement.data('forumid'); @@ -73,10 +89,13 @@ define([ Repository.setDiscussionLockState(forumId, discussionId, state) .then(function(context) { var icon = toggleElement.parents(Selectors.summary.actions).find(Selectors.lock.icon); + var lockedLabel = toggleElement.parents(Selectors.discussion.item).find(Selectors.discussion.lockedLabel); if (context.locked) { icon.removeClass('hidden'); + lockedLabel.removeAttr('hidden'); } else { icon.addClass('hidden'); + lockedLabel.attr('hidden', true); } return context; }) diff --git a/mod/forum/amd/src/forum_events.js b/mod/forum/amd/src/forum_events.js new file mode 100644 index 00000000000..f446ca6bed1 --- /dev/null +++ b/mod/forum/amd/src/forum_events.js @@ -0,0 +1,28 @@ +// This file is part of Moodle - http://moodle.org/ +// +// Moodle is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Moodle is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Moodle. If not, see . + +/** + * Events for the forum activity. + * + * @module mod_forum/forum_events + * @package mod_forum + * @copyright 2019 Jun Pataleta + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define([], function() { + return { + SUBSCRIPTION_TOGGLED: 'mod_forum/subscription_toggle:subscriptionToggled', + }; +}); diff --git a/mod/forum/amd/src/selectors.js b/mod/forum/amd/src/selectors.js index 258652b14cc..1beb6ccbbac 100644 --- a/mod/forum/amd/src/selectors.js +++ b/mod/forum/amd/src/selectors.js @@ -65,7 +65,11 @@ define([], function() { toggle: "[data-type='pin-toggle'][data-action='toggle']", }, discussion: { - tools: '[data-container="discussion-tools"]' - } + 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']", + }, }; }); diff --git a/mod/forum/amd/src/subscription_toggle.js b/mod/forum/amd/src/subscription_toggle.js index f4f39b390cd..f631fe1fed0 100644 --- a/mod/forum/amd/src/subscription_toggle.js +++ b/mod/forum/amd/src/subscription_toggle.js @@ -28,12 +28,16 @@ define([ 'core/notification', 'mod_forum/repository', 'mod_forum/selectors', + 'core/pubsub', + 'mod_forum/forum_events', ], function( $, Templates, Notification, Repository, - Selectors + Selectors, + PubSub, + ForumEvents ) { /** @@ -50,6 +54,10 @@ define([ Repository.setDiscussionSubscriptionState(forumId, discussionId, subscriptionState) .then(function(context) { + PubSub.publish(ForumEvents.SUBSCRIPTION_TOGGLED, { + discussionId: discussionId, + subscriptionState: subscriptionState + }); return Templates.render('mod_forum/discussion_subscription_toggle', context); }) .then(function(html, js) { diff --git a/mod/forum/classes/local/builders/exported_discussion_summaries.php b/mod/forum/classes/local/builders/exported_discussion_summaries.php index 6e49a629aba..33c1cedab64 100644 --- a/mod/forum/classes/local/builders/exported_discussion_summaries.php +++ b/mod/forum/classes/local/builders/exported_discussion_summaries.php @@ -180,7 +180,13 @@ class exported_discussion_summaries { 'isrepliesdesc' => $sortorder == $discussionlistvault::SORTORDER_REPLIES_DESC, 'isrepliesasc' => $sortorder == $discussionlistvault::SORTORDER_REPLIES_ASC, 'iscreateddesc' => $sortorder == $discussionlistvault::SORTORDER_CREATED_DESC, - 'iscreatedasc' => $sortorder == $discussionlistvault::SORTORDER_CREATED_ASC + 'iscreatedasc' => $sortorder == $discussionlistvault::SORTORDER_CREATED_ASC, + 'isdiscussiondesc' => $sortorder == $discussionlistvault::SORTORDER_DISCUSSION_DESC, + 'isdiscussionasc' => $sortorder == $discussionlistvault::SORTORDER_DISCUSSION_ASC, + 'isstarterdesc' => $sortorder == $discussionlistvault::SORTORDER_STARTER_DESC, + 'isstarterasc' => $sortorder == $discussionlistvault::SORTORDER_STARTER_ASC, + 'isgroupdesc' => $sortorder == $discussionlistvault::SORTORDER_GROUP_DESC, + 'isgroupasc' => $sortorder == $discussionlistvault::SORTORDER_GROUP_ASC, ); $exportedposts['state']['sortorder'] = $sortoptions; diff --git a/mod/forum/classes/local/exporters/discussion.php b/mod/forum/classes/local/exporters/discussion.php index a008de4a73f..44e11b0cbd4 100644 --- a/mod/forum/classes/local/exporters/discussion.php +++ b/mod/forum/classes/local/exporters/discussion.php @@ -180,9 +180,11 @@ class discussion extends exporter { if (!$group->hidepicture) { $url = get_group_picture_url($group, $forum->get_course_id(), true); - if (!empty($url)) { - $groupdata['urls']['picture'] = $url; + if (empty($url)) { + // Get a generic group image URL. + $url = $output->image_url('g/g1')->out(false); } + $groupdata['urls']['picture'] = $url; } if ($capabilitymanager->can_view_participants($user, $discussion)) { diff --git a/mod/forum/classes/local/exporters/forum.php b/mod/forum/classes/local/exporters/forum.php index ad396159228..e12ddfc0caf 100644 --- a/mod/forum/classes/local/exporters/forum.php +++ b/mod/forum/classes/local/exporters/forum.php @@ -89,6 +89,12 @@ class forum extends exporter { 'sortlastpostdesc' => ['type' => PARAM_URL], 'sortcreatedasc' => ['type' => PARAM_URL], 'sortcreateddesc' => ['type' => PARAM_URL], + 'sortdiscussionasc' => ['type' => PARAM_URL], + 'sortdiscussiondesc' => ['type' => PARAM_URL], + 'sortstarterasc' => ['type' => PARAM_URL], + 'sortstarterdesc' => ['type' => PARAM_URL], + 'sortgroupasc' => ['type' => PARAM_URL], + 'sortgroupdesc' => ['type' => PARAM_URL], ], ], ]; @@ -137,7 +143,19 @@ class forum extends exporter { 'sortcreatedasc' => $urlfactory->get_forum_view_url_from_forum($this->forum, null, $discussionvault::SORTORDER_CREATED_ASC)->out(false), 'sortcreateddesc' => $urlfactory->get_forum_view_url_from_forum($this->forum, null, - $discussionvault::SORTORDER_CREATED_DESC)->out(false) + $discussionvault::SORTORDER_CREATED_DESC)->out(false), + 'sortdiscussionasc' => $urlfactory->get_forum_view_url_from_forum($this->forum, null, + $discussionvault::SORTORDER_DISCUSSION_ASC)->out(false), + 'sortdiscussiondesc' => $urlfactory->get_forum_view_url_from_forum($this->forum, null, + $discussionvault::SORTORDER_DISCUSSION_DESC)->out(false), + 'sortstarterasc' => $urlfactory->get_forum_view_url_from_forum($this->forum, null, + $discussionvault::SORTORDER_STARTER_ASC)->out(false), + 'sortstarterdesc' => $urlfactory->get_forum_view_url_from_forum($this->forum, null, + $discussionvault::SORTORDER_STARTER_DESC)->out(false), + 'sortgroupasc' => $urlfactory->get_forum_view_url_from_forum($this->forum, null, + $discussionvault::SORTORDER_GROUP_ASC)->out(false), + 'sortgroupdesc' => $urlfactory->get_forum_view_url_from_forum($this->forum, null, + $discussionvault::SORTORDER_GROUP_DESC)->out(false), ], ]; } diff --git a/mod/forum/classes/local/renderers/discussion.php b/mod/forum/classes/local/renderers/discussion.php index 4c0f95e3ecf..72aca461dcf 100644 --- a/mod/forum/classes/local/renderers/discussion.php +++ b/mod/forum/classes/local/renderers/discussion.php @@ -219,10 +219,6 @@ class discussion { $capabilities = (array) $exporteddiscussion['capabilities']; - if ($capabilities['subscribe']) { - $exporteddiscussion['html']['subscribe'] = $this->get_subscription_button_html(); - } - if ($capabilities['move']) { $exporteddiscussion['html']['movediscussion'] = $this->get_move_discussion_html(); } @@ -295,26 +291,6 @@ class discussion { return $this->renderer->render($select); } - /** - * Get the HTML to render the subscription button. - * - * @return string - */ - private function get_subscription_button_html() : string { - global $PAGE; - - $forumrecord = $this->forumrecord; - $discussion = $this->discussion; - $html = html_writer::div( - forum_get_discussion_subscription_icon($forumrecord, $discussion->get_id(), null, true), - 'discussionsubscription' - ); - $html .= forum_get_discussion_subscription_icon_preloaders(); - // Add the subscription toggle JS. - $PAGE->requires->yui_module('moodle-mod_forum-subscriptiontoggle', 'Y.M.mod_forum.subscriptiontoggle.init'); - return $html; - } - /** * Get the HTML to render the move discussion selector and button. * diff --git a/mod/forum/classes/local/vaults/discussion_list.php b/mod/forum/classes/local/vaults/discussion_list.php index a4a345b76e6..07bc0dbfb85 100644 --- a/mod/forum/classes/local/vaults/discussion_list.php +++ b/mod/forum/classes/local/vaults/discussion_list.php @@ -26,6 +26,7 @@ namespace mod_forum\local\vaults; defined('MOODLE_INTERNAL') || die(); +use core_group\output\group_details; use mod_forum\local\vaults\preprocessors\extract_record as extract_record_preprocessor; use mod_forum\local\vaults\preprocessors\extract_user as extract_user_preprocessor; use mod_forum\local\renderers\discussion_list as discussion_list_renderer; @@ -70,6 +71,18 @@ class discussion_list extends db_table_vault { public const SORTORDER_REPLIES_DESC = 5; /** Sort by number of replies desc */ public const SORTORDER_REPLIES_ASC = 6; + /** Sort by discussion name desc */ + public const SORTORDER_DISCUSSION_DESC = 7; + /** Sort by discussion name asc */ + public const SORTORDER_DISCUSSION_ASC = 8; + /** Sort by discussion starter's name desc */ + public const SORTORDER_STARTER_DESC = 9; + /** Sort by discussion starter's name asc */ + public const SORTORDER_STARTER_ASC = 10; + /** Sort by group name desc */ + public const SORTORDER_GROUP_DESC = 11; + /** Sort by group name asc */ + public const SORTORDER_GROUP_ASC = 12; /** * Get the table alias. @@ -94,14 +107,12 @@ class discussion_list extends db_table_vault { * * @param string|null $wheresql Where conditions for the SQL * @param string|null $sortsql Order by conditions for the SQL - * @param string|null $joinsql Additional join conditions for the sql - * @param int|null $userid The ID of the user we are performing this query for + * @param int|null $userid The ID of the user we are performing this query for * * @return string */ protected function generate_get_records_sql(string $wheresql = null, ?string $sortsql = null, ?int $userid = null) : string { $alias = $this->get_table_alias(); - $db = $this->get_db(); $includefavourites = $userid ? true : false; @@ -153,6 +164,18 @@ class discussion_list extends db_table_vault { ) r ON d.id = r.id'; } + $groupsortorders = [ + $this->get_sort_order(self::SORTORDER_GROUP_DESC, $includefavourites), + $this->get_sort_order(self::SORTORDER_GROUP_ASC, $includefavourites) + ]; + $sortbygroup = in_array($sortsql, $groupsortorders); + if ($sortbygroup) { + $groupstable = new dml_table('groups', 'g', 'g'); + $fields .= ', ' . $groupstable->get_field_select(); + // Join groups. + $tables .= 'LEFT JOIN {groups} g ON g.id = d.groupid'; + } + $selectsql = 'SELECT ' . $fields . ' FROM ' . $tables; $selectsql .= $wheresql ? ' WHERE ' . $wheresql : ''; $selectsql .= $sortsql ? ' ORDER BY ' . $sortsql : ''; @@ -226,6 +249,8 @@ class discussion_list extends db_table_vault { * @return string */ protected function get_keyfield(?int $sortmethod) : string { + global $CFG; + switch ($sortmethod) { case self::SORTORDER_CREATED_DESC: case self::SORTORDER_CREATED_ASC: @@ -233,6 +258,30 @@ class discussion_list extends db_table_vault { case self::SORTORDER_REPLIES_DESC: case self::SORTORDER_REPLIES_ASC: return 'replycount'; + case self::SORTORDER_DISCUSSION_DESC: + case self::SORTORDER_DISCUSSION_ASC: + return 'dname'; + case self::SORTORDER_STARTER_DESC: + case self::SORTORDER_STARTER_ASC: + // We'll sort by the first name field of the discussion starter's name. + + // Let's get the full name display config first. + $nameformat = $CFG->fullnamedisplay; + if ($CFG->fullnamedisplay === 'language') { + $nameformat = get_string('fullnamedisplay', '', (object)['firstname' => 'firstname', 'lastname' => 'lastname']); + } + // Fetch all the available user name fields. + $availablefields = order_in_string(get_all_user_name_fields(), $nameformat); + // We'll default to the first name if there's no available name field. + $returnfield = 'firstname'; + if (!empty($availablefields)) { + // Use the first name field. + $returnfield = reset($availablefields); + } + return 'fauserrecord' . $returnfield; + case self::SORTORDER_GROUP_DESC: + case self::SORTORDER_GROUP_ASC: + return 'gname'; default: global $CFG; $alias = $this->get_table_alias(); @@ -255,11 +304,16 @@ class discussion_list extends db_table_vault { case self::SORTORDER_LASTPOST_ASC: case self::SORTORDER_CREATED_ASC: case self::SORTORDER_REPLIES_ASC: + case self::SORTORDER_DISCUSSION_ASC: + case self::SORTORDER_STARTER_ASC: + case self::SORTORDER_GROUP_ASC: return "ASC"; case self::SORTORDER_LASTPOST_DESC: case self::SORTORDER_CREATED_DESC: case self::SORTORDER_REPLIES_DESC: - return "DESC"; + case self::SORTORDER_DISCUSSION_DESC: + case self::SORTORDER_STARTER_DESC: + case self::SORTORDER_GROUP_DESC: default: return "DESC"; } diff --git a/mod/forum/lang/en/forum.php b/mod/forum/lang/en/forum.php index f8ce0b69837..697cc1442d4 100644 --- a/mod/forum/lang/en/forum.php +++ b/mod/forum/lang/en/forum.php @@ -166,10 +166,16 @@ $string['disallowsubscribeteacher'] = 'Subscriptions not allowed (except for tea $string['discussion'] = 'Discussion'; $string['discussionlistsortbycreatedasc'] = 'Sort by creation date in ascending order'; $string['discussionlistsortbycreateddesc'] = 'Sort by creation date in descending order'; +$string['discussionlistsortbydiscussionasc'] = 'Sort by discussion name in ascending order'; +$string['discussionlistsortbydiscussiondesc'] = 'Sort by discussion name in descending order'; +$string['discussionlistsortbygroupasc'] = 'Sort by group in ascending order'; +$string['discussionlistsortbygroupdesc'] = 'Sort by group in descending order'; $string['discussionlistsortbylastpostdesc'] = 'Sort by last post creation date in descending order'; $string['discussionlistsortbylastpostasc'] = 'Sort by last post creation date in ascending order'; $string['discussionlistsortbyrepliesasc'] = 'Sort by number of replies in ascending order'; $string['discussionlistsortbyrepliesdesc'] = 'Sort by number of replies in descending order'; +$string['discussionlistsortbystarterasc'] = 'Sort by discussion starter name in ascending order'; +$string['discussionlistsortbystarterdesc'] = 'Sort by discussion starter name in descending order'; $string['discussionlocked'] = 'This discussion has been locked so you can no longer reply to it.'; $string['discussionlockingheader'] = 'Discussion locking'; $string['discussionlockingdisabled'] = 'Do not lock discussions'; @@ -182,6 +188,7 @@ $string['discussionpin'] = 'Pin'; $string['discussionpinned'] = 'Pinned'; $string['discussionpinned_help'] = 'Pinned discussions will appear at the top of a forum.'; $string['discussionsplit'] = 'Discussion has been split'; +$string['discussionsubscribed'] = 'You are now subscribed to this discussion.'; $string['discussionsubscribestop'] = 'I don\'t want to be notified of new posts in this discussion'; $string['discussionsubscribestart'] = 'Send me notifications of new posts in this discussion'; $string['discussionsubscription'] = 'Discussion subscription'; @@ -191,13 +198,16 @@ $string['discussionsstartedby'] = 'Discussions started by {$a}'; $string['discussionsstartedbyrecent'] = 'Discussions recently started by {$a}'; $string['discussionsstartedbyuserincourse'] = 'Discussions started by {$a->fullname} in {$a->coursename}'; $string['discussionunpin'] = 'Unpin'; +$string['discussionunsubscribed'] = 'You are now unsubscribed from this discussion.'; $string['discussthistopic'] = 'Discuss this topic'; $string['displayend'] = 'Display end'; $string['displayend_help'] = 'This setting specifies whether a forum post should be hidden after a certain date. Note that administrators can always view forum posts.'; +$string['displayenddate'] = 'Display end: {$a}.'; $string['displaymode'] = 'Display mode'; $string['displayperiod'] = 'Display period'; $string['displaystart'] = 'Display start'; $string['displaystart_help'] = 'This setting specifies whether a forum post should be displayed from a certain date. Note that administrators can always view forum posts.'; +$string['displaystartdate'] = 'Display start: {$a}.'; $string['displaywordcount'] = 'Display word count'; $string['displaywordcount_help'] = 'This setting specifies whether the word count of each post should be displayed or not.'; $string['duedate'] = 'Due date'; @@ -350,6 +360,7 @@ $string['mailnow'] = 'Send forum post notifications with no editing-time delay'; $string['manydiscussions'] = 'Discussions per page'; $string['managesubscriptionsoff'] = 'Finish managing subscriptions'; $string['managesubscriptionson'] = 'Manage subscribers'; +$string['markasread'] = 'Mark as read'; $string['markalldread'] = 'Mark all posts in this discussion read.'; $string['markallread'] = 'Mark all posts in this forum read.'; $string['markasreadonnotification'] = 'When sending forum post notifications'; @@ -642,6 +653,8 @@ $string['tagsdeleted'] = 'Forum tags have been deleted'; $string['thisforumisthrottled'] = 'This forum has a limit to the number of forum postings you can make in a given time period - this is currently set at {$a->blockafter} posting(s) in {$a->blockperiod}'; $string['thisforumisdue'] = 'The due date for posting to this forum was {$a}.'; $string['thisforumhasduedate'] = 'The due date for posting to this forum is {$a}.'; +$string['timed'] = 'Timed'; +$string['timeddiscussion'] = 'Timed discussion'; $string['timedhidden'] = 'Timed status: Hidden from students'; $string['timedposts'] = 'Timed posts'; $string['timedvisible'] = 'Timed status: Visible to all users'; diff --git a/mod/forum/lib.php b/mod/forum/lib.php index f1f13f87076..3bfdb80a9f8 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -2426,7 +2426,7 @@ function forum_get_discussion_subscription_icon($forum, $discussionid, $returnur return html_writer::link($subscriptionlink, $output, array( 'title' => get_string('clicktounsubscribe', 'forum'), - 'class' => 'discussiontoggle iconsmall', + 'class' => 'discussiontoggle btn btn-link', 'data-forumid' => $forum->id, 'data-discussionid' => $discussionid, 'data-includetext' => $includetext, @@ -2440,7 +2440,7 @@ function forum_get_discussion_subscription_icon($forum, $discussionid, $returnur return html_writer::link($subscriptionlink, $output, array( 'title' => get_string('clicktosubscribe', 'forum'), - 'class' => 'discussiontoggle iconsmall', + 'class' => 'discussiontoggle btn btn-link', 'data-forumid' => $forum->id, 'data-discussionid' => $discussionid, 'data-includetext' => $includetext, diff --git a/mod/forum/subscribe_ajax.php b/mod/forum/subscribe_ajax.php deleted file mode 100644 index 00aad245d36..00000000000 --- a/mod/forum/subscribe_ajax.php +++ /dev/null @@ -1,70 +0,0 @@ -. - -/** - * Subscribe to or unsubscribe from a forum discussion. - * - * @package mod_forum - * @copyright 2014 Andrew Nicols - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -define('AJAX_SCRIPT', true); -require(__DIR__.'/../../config.php'); -require_once($CFG->dirroot . '/mod/forum/lib.php'); - -$forumid = required_param('forumid', PARAM_INT); // The forum to subscribe or unsubscribe. -$discussionid = optional_param('discussionid', null, PARAM_INT); // The discussionid to subscribe. -$includetext = optional_param('includetext', false, PARAM_BOOL); - -$forum = $DB->get_record('forum', array('id' => $forumid), '*', MUST_EXIST); -$course = $DB->get_record('course', array('id' => $forum->course), '*', MUST_EXIST); -if (!$discussion = $DB->get_record('forum_discussions', array('id' => $discussionid, 'forum' => $forumid))) { - print_error('invaliddiscussionid', 'forum'); -} -$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id, false, MUST_EXIST); -$context = context_module::instance($cm->id); - -require_sesskey(); -require_login($course, false, $cm); -require_capability('mod/forum:viewdiscussion', $context); - -$return = new stdClass(); - -if (is_guest($context, $USER)) { - // is_guest should be used here as this also checks whether the user is a guest in the current course. - // Guests and visitors cannot subscribe - only enrolled users. - throw new moodle_exception('noguestsubscribe', 'mod_forum'); -} - -if (!\mod_forum\subscriptions::is_subscribable($forum)) { - // Nothing to do. We won't actually output any content here though. - echo json_encode($return); - die; -} - -if (\mod_forum\subscriptions::is_subscribed($USER->id, $forum, $discussion->id, $cm)) { - // The user is subscribed, unsubscribe them. - \mod_forum\subscriptions::unsubscribe_user_from_discussion($USER->id, $discussion, $context); -} else { - // The user is unsubscribed, subscribe them. - \mod_forum\subscriptions::subscribe_user_to_discussion($USER->id, $discussion, $context); -} - -// Now return the updated subscription icon. -$return->icon = forum_get_discussion_subscription_icon($forum, $discussion->id, null, $includetext); -echo json_encode($return); -die; diff --git a/mod/forum/templates/discussion_list.mustache b/mod/forum/templates/discussion_list.mustache index 6ac2f83ccb8..a5b489a3102 100644 --- a/mod/forum/templates/discussion_list.mustache +++ b/mod/forum/templates/discussion_list.mustache @@ -73,41 +73,57 @@ {{#str}} showingcountoftotaldiscussions, mod_forum, {"count": "{{visiblediscussioncount}}", "total":"{{totaldiscussioncount}}"} {{/str}} {{$discussion_list_header}} - - - + + {{#forum.state.groupmode}} - + {{/forum.state.groupmode}} - {{#forum.capabilities.viewdiscussions}} - - - {{#forum.userstate.tracked}} - - {{/forum.userstate.tracked}} - {{/forum.capabilities.viewdiscussions}} + - + {{/forum.capabilities.viewdiscussions}} + - - {{/discussion_list_header}} @@ -143,8 +165,11 @@ {{#summaries}} - - + - - + {{#forum.state.groupmode}} + + {{/forum.state.groupmode}} + - {{#forum.state.groupmode}} - - {{/forum.state.groupmode}} - {{#forum.capabilities.viewdiscussions}} - - {{#forum.userstate.tracked}} - - {{/forum.userstate.tracked}} - {{/forum.capabilities.viewdiscussions}} - - - - + {{/forum.capabilities.viewdiscussions}} +
 {{#str}}discussion, mod_forum{{/str}}{{#str}}startedby, mod_forum{{/str}} + {{#str}}status{{/str}} + + {{#state.sortorder.isdiscussiondesc}} + {{#str}}discussion, mod_forum{{/str}} {{#pix}}t/downlong, core, {{#str}}desc, core{{/str}}{{/pix}} + {{/state.sortorder.isdiscussiondesc}} + {{#state.sortorder.isdiscussionasc}} + {{#str}}discussion, mod_forum{{/str}} {{#pix}}t/uplong, core, {{#str}}asc, core{{/str}}{{/pix}} + {{/state.sortorder.isdiscussionasc}} + {{^state.sortorder.isdiscussiondesc}} + {{^state.sortorder.isdiscussionasc}} + {{#str}}discussion, mod_forum{{/str}} + {{/state.sortorder.isdiscussionasc}} + {{/state.sortorder.isdiscussiondesc}} + {{#str}}group{{/str}} + {{#state.sortorder.isgroupdesc}} + {{#str}}group{{/str}} {{#pix}}t/downlong, core, {{#str}}desc, core{{/str}}{{/pix}} + {{/state.sortorder.isgroupdesc}} + {{#state.sortorder.isgroupasc}} + {{#str}}group{{/str}} {{#pix}}t/uplong, core, {{#str}}asc, core{{/str}}{{/pix}} + {{/state.sortorder.isgroupasc}} + {{^state.sortorder.isgroupdesc}} + {{^state.sortorder.isgroupasc}} + {{#str}}group{{/str}} + {{/state.sortorder.isgroupasc}} + {{/state.sortorder.isgroupdesc}} + - {{#state.sortorder.isrepliesdesc}} - {{#str}}replies, mod_forum{{/str}} {{#pix}}t/downlong, core, {{#str}}desc, core{{/str}}{{/pix}} - {{/state.sortorder.isrepliesdesc}} - {{#state.sortorder.isrepliesasc}} - {{#str}}replies, mod_forum{{/str}} {{#pix}}t/uplong, core, {{#str}}asc, core{{/str}}{{/pix}} - {{/state.sortorder.isrepliesasc}} - {{^state.sortorder.isrepliesdesc}} - {{^state.sortorder.isrepliesasc}} - {{#str}}replies, mod_forum{{/str}} - {{/state.sortorder.isrepliesasc}} - {{/state.sortorder.isrepliesdesc}} - - {{#str}}unread, mod_forum{{/str}} - {{#pix}}t/markasread, core, {{#str}}markallread, mod_forum{{/str}}{{/pix}} - + {{#state.sortorder.isstarterdesc}} + {{#str}}startedby, mod_forum{{/str}} {{#pix}}t/downlong, core, {{#str}}desc, core{{/str}}{{/pix}} + {{/state.sortorder.isstarterdesc}} + {{#state.sortorder.isstarterasc}} + {{#str}}startedby, mod_forum{{/str}} {{#pix}}t/uplong, core, {{#str}}asc, core{{/str}}{{/pix}} + {{/state.sortorder.isstarterasc}} + {{^state.sortorder.isstarterdesc}} + {{^state.sortorder.isstarterasc}} + {{#str}}startedby, mod_forum{{/str}} + {{/state.sortorder.isstarterasc}} + {{/state.sortorder.isstarterdesc}} + {{#state.sortorder.islastpostdesc}} {{#str}}lastpost, mod_forum{{/str}} {{#pix}}t/downlong, core, {{#str}}desc, core{{/str}}{{/pix}} @@ -121,21 +137,27 @@ {{/state.sortorder.islastpostasc}} {{/state.sortorder.islastpostdesc}} - {{#state.sortorder.iscreateddesc}} - {{#str}}created, mod_forum{{/str}} {{#pix}}t/downlong, core, {{#str}}desc, core{{/str}}{{/pix}} - {{/state.sortorder.iscreateddesc}} - {{#state.sortorder.iscreatedasc}} - {{#str}}created, mod_forum{{/str}} {{#pix}}t/uplong, core, {{#str}}asc, core{{/str}}{{/pix}} - {{/state.sortorder.iscreatedasc}} - {{^state.sortorder.iscreateddesc}} - {{^state.sortorder.iscreatedasc}} - {{#str}}created, mod_forum{{/str}} - {{/state.sortorder.iscreatedasc}} - {{/state.sortorder.iscreateddesc}} + {{#forum.capabilities.viewdiscussions}} + + {{#state.sortorder.isrepliesdesc}} + {{#str}}replies, mod_forum{{/str}} {{#pix}}t/downlong, core, {{#str}}desc, core{{/str}}{{/pix}} + {{/state.sortorder.isrepliesdesc}} + {{#state.sortorder.isrepliesasc}} + {{#str}}replies, mod_forum{{/str}} {{#pix}}t/uplong, core, {{#str}}asc, core{{/str}}{{/pix}} + {{/state.sortorder.isrepliesasc}} + {{^state.sortorder.isrepliesdesc}} + {{^state.sortorder.isrepliesasc}} + {{#str}}replies, mod_forum{{/str}} + {{/state.sortorder.isrepliesasc}} + {{/state.sortorder.isrepliesdesc}} + {{#forum.userstate.tracked}} + {{#pix}}t/markasread, core, {{#str}}markallread, mod_forum{{/str}}{{/pix}} + {{/forum.userstate.tracked}} + + {{#str}}actions{{/str}}  
+
{{#discussion.pinned}} {{#pix}}i/pinned, mod_forum, {{#str}}discussionpinned, mod_forum{{/str}}{{/pix}} {{/discussion.pinned}} @@ -154,146 +179,100 @@ {{/discussion}} {{/discussion.pinned}} - {{{discussion.name}}} - + +
+ + {{#shortentext}}100, {{{discussion.name}}}{{/shortentext}} + +
+ + {{#str}}locked, forum{{/str}} + + + {{#str}}subscribed, forum{{/str}} + + {{#discussion.timed.istimed}} + + + + {{/discussion.timed.istimed}} +
+
+
+ {{#discussion.group}} + {{#str}} pictureof, core, {{name}} {{/str}} + {{#urls.userlist}} + + {{#shortentext}}30, {{name}}{{/shortentext}} + + {{/urls.userlist}} + {{^urls.userlist}} + {{name}} + {{/urls.userlist}} + {{/discussion.group}} + {{#firstpostauthor}}
- {{#str}}pictureof, moodle, {{fullname}}{{/str}} + {{#str}}pictureof, moodle, {{fullname}}{{/str}}
-
- {{fullname}} +
+
{{fullname}}
+
+ {{#userdate}}{{discussion.times.created}}, {{#str}}strftimedatemonthabbr, langconfig{{/str}}{{/userdate}} +
{{/firstpostauthor}}
- {{#discussion.group}} - {{#urls.picture}} - {{#urls.userlist}} - - - - {{/urls.userlist}} - {{^urls.userlist}} - {{#str}} pictureof, core, {{name}} {{/str}} - {{/urls.userlist}} - {{/urls.picture}} - {{^urls.picture}} - {{#urls.userlist}} - {{name}} - {{/urls.userlist}} - {{^urls.userlist}} - {{name}} - {{/urls.userlist}} - {{/urls.picture}} - {{/discussion.group}} - - - {{replies}} - - - {{#unread}} - {{! TODO Rewrite as AJAX}} - - {{unread}} - {{#pix}}t/markasread, core, {{#str}}markalldread, mod_forum{{/str}}{{/pix}} - - {{/unread}} - {{^unread}} - - 0 - - {{/unread}} - + {{! TODO Check q&a, eachuser }} {{#latestpostid}} - + + {{#userdate}} + {{discussion.times.modified}}, {{#str}}strftimedateshortmonthabbr, langconfig{{/str}} + {{/userdate}} + {{/latestpostid}} - {{#userdate}}{{discussion.times.created}}, {{#str}}strftimerecentfull{{/str}}{{/userdate}} - - {{#discussion.timed.istimed}} -
- {{#pix}} - i/calendar, moodle, - {{#discussion.times.start}} - {{! }}{{#str}} displaystart, mod_forum {{/str}}: {{#userdate}}{{.}}, {{#str}}strftimerecentfull {{/str}}{{/userdate}} - {{/discussion.times.start}} - {{#discussion.times.end}} - {{! }}{{#str}} displayend, mod_forum {{/str}}: {{#userdate}}{{.}}, {{#str}} strftimerecentfull {{/str}}{{/userdate}} - {{/discussion.times.end}} - {{#discussion.timed.visible}} - {{! }}{{#str}} timedvisible, mod_forum {{/str}} - {{/discussion.timed.visible}} - {{^discussion.timed.visible}} - {{! }}{{#str}} timedhidden, mod_forum {{/str}} - {{/discussion.timed.visible}} - {{/pix}} -
- {{/discussion.timed.istimed}} -
+ {{#forum.capabilities.viewdiscussions}} + + {{replies}} + {{#forum.userstate.tracked}} + {{#unread}} + {{! TODO Rewrite as AJAX}} + + + {{unread}} + + + {{/unread}} + {{/forum.userstate.tracked}} + {{#discussion}} -
-
- {{#pix}}i/lock, core, {{#str}}locked, forum{{/str}}{{/pix}} -
- {{#forum.capabilities.subscribe}} -
- {{> mod_forum/discussion_subscription_toggle}} -
- {{/forum.capabilities.subscribe}} +
{{#hasanyactions}} -
- {{> mod_forum/forum_action_menu}} -
+
+ {{> mod_forum/forum_action_menu}} +
{{/hasanyactions}}
{{/discussion}} diff --git a/mod/forum/templates/discussion_subscription_toggle.mustache b/mod/forum/templates/discussion_subscription_toggle.mustache index 9817f9519de..00d0dfe8040 100644 --- a/mod/forum/templates/discussion_subscription_toggle.mustache +++ b/mod/forum/templates/discussion_subscription_toggle.mustache @@ -26,16 +26,26 @@ * none Context variables required for this template: - * TODO + * capabilities Object - Uses the "subscribe" attribute to determine whether to render the subscribe action. + * urls Object - Uses the "subscribe" attribute for the subscription URl. + * id int - The discussion ID. + * forumid int - The forum ID. + * userstate Object - Uses the "subscribed" attribute to determine the action that will be performed upon toggling. Example context (json): { + "capabilities": { "subscribe": true }, + "urls": { "subscribe": "#" }, + "id": 1, + "forumid": 1, + "userstate": { "subscribed": true } } }} {{#capabilities.subscribe}} {{#userstate.subscribed}} - {{#pix}}t/subscribed, mod_forum, {{#str}}clicktounsubscribe, mod_forum{{/str}}{{/pix}} + {{#str}}unsubscribediscussion, forum{{/str}} {{/userstate.subscribed}} {{^userstate.subscribed}} - {{#pix}}t/unsubscribed, mod_forum, {{#str}}clicktosubscribe, mod_forum{{/str}}{{/pix}} + {{#str}}subscribediscussion, forum{{/str}} {{/userstate.subscribed}} {{/capabilities.subscribe}} diff --git a/mod/forum/templates/discussion_times.mustache b/mod/forum/templates/discussion_times.mustache new file mode 100644 index 00000000000..e35828d1513 --- /dev/null +++ b/mod/forum/templates/discussion_times.mustache @@ -0,0 +1,59 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template mod_forum/discussion_times + + Template to display the discussion times. + + Classes required for JS: + * none + + Data attributes required for JS: + * none + + Context variables required for this template: + * start int - The discussion start timestamp + * end int - The discussion end timestamp + * visible boolean - Whether the discussion is visible to students or not. + + Example context (json): + { + "start": 1, + "end": 1, + "visible": true + } +}} +
    +{{#start}} +
  • + {{#str}} displaystartdate, mod_forum, {{#userdate}}{{.}}, {{#str}}strftimerecentfull {{/str}}{{/userdate}} {{/str}} +
  • +{{/start}} +{{#end}} +
  • + {{#str}} displayenddate, mod_forum, {{#userdate}}{{.}}, {{#str}}strftimerecentfull {{/str}}{{/userdate}} {{/str}} +
  • +{{/end}} +
  • + {{#visible}} + {{#str}} timedvisible, mod_forum {{/str}} + {{/visible}} + {{^visible}} + {{#str}} timedhidden, mod_forum {{/str}} + {{/visible}} +
  • +
diff --git a/mod/forum/templates/forum_action_menu.mustache b/mod/forum/templates/forum_action_menu.mustache index 89e38e1c459..8a00523a79e 100644 --- a/mod/forum/templates/forum_action_menu.mustache +++ b/mod/forum/templates/forum_action_menu.mustache @@ -15,18 +15,42 @@ along with Moodle. If not, see . }} {{! - @template mod_forum/forum-action-menu + @template mod_forum/forum_action_menu - This template renders action menu for each course. + This template renders action menu for a forum discussion. + + Context variables required for this template: + * capabilities Object - Uses the following attributes: + * manage boolean - Whether to render the lock action. + * favourite boolean - Whether to render the star/unstar action. + * pin boolean - Whether to render the star/unstar action. + * subscribe boolean - Whether to render the subscribe action. + * id int - The discussion ID. + * forumid int - The forum ID. + * istimelocked boolean - Whether this forum is time locked. + * settings Object - Uses the following attributes: + * excludetext boolean - Whether to show an icon only. + * togglemoreicon - Whether to show a toggle-more icon or not. Example context (json): { - + "capabilities": { + "manage": true, + "favourite": true, + "pin": true, + "subscribe": true + }, + "id": 1, + "forumid": 1, + "istimelocked": false, + "settings": { + "excludetext": false, + "togglemoreicon": false + } } }} diff --git a/mod/forum/templates/forum_discussion.mustache b/mod/forum/templates/forum_discussion.mustache index 8d661ff1648..6ce8e44150f 100644 --- a/mod/forum/templates/forum_discussion.mustache +++ b/mod/forum/templates/forum_discussion.mustache @@ -34,13 +34,11 @@ {{#html}} {{#hasanyactions}}
-
{{> mod_forum/forum_action_menu}}
-
{{{subscribe}}}
{{/hasanyactions}} {{{neighbourlinks}}} @@ -61,8 +59,9 @@ {{#html.neighbourlinks}}{{{.}}}{{/html.neighbourlinks}}
{{#js}} -require(['jquery', 'mod_forum/discussion', 'mod_forum/posts_list', 'mod_forum/lock_toggle', 'mod_forum/favourite_toggle', 'mod_forum/pin_toggle'], - function($, Discussion, PostsList, LockToggle, FavouriteToggle, Pin) { +require(['jquery', 'mod_forum/discussion', 'mod_forum/posts_list', 'mod_forum/lock_toggle', 'mod_forum/favourite_toggle', + 'mod_forum/pin_toggle', 'mod_forum/subscription_toggle'], + function($, Discussion, PostsList, LockToggle, FavouriteToggle, Pin, SubscribeToggle) { var root = $("[data-content='forum-discussion']"); Discussion.init(root); PostsList.init(root); @@ -70,5 +69,6 @@ require(['jquery', 'mod_forum/discussion', 'mod_forum/posts_list', 'mod_forum/lo LockToggle.init(root); FavouriteToggle.init(root); Pin.init(root); + SubscribeToggle.init(root); }); {{/js}} \ No newline at end of file diff --git a/mod/forum/templates/mark_as_read.mustache b/mod/forum/templates/mark_as_read.mustache new file mode 100644 index 00000000000..a5296678c70 --- /dev/null +++ b/mod/forum/templates/mark_as_read.mustache @@ -0,0 +1,40 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template mod_forum/mark_as_read + + Template to mark as read menu item. + + Classes required for JS: + * none + + Data attributes required for JS: + * none + + Context variables required for this template: + * urls Object - Uses the 'markasread' attribute for the URL. + + Example context (json): + { + "urls": { + "markasread": "#" + } + } +}} + + {{#str}}markasread, mod_forum{{/str}} + diff --git a/mod/forum/tests/behat/split_forum_discussion.feature b/mod/forum/tests/behat/split_forum_discussion.feature index 51bae11ec85..0cbd00dcf33 100644 --- a/mod/forum/tests/behat/split_forum_discussion.feature +++ b/mod/forum/tests/behat/split_forum_discussion.feature @@ -25,18 +25,18 @@ Feature: Forum discussions can be split | Forum type | Standard forum for general use | | Description | Forum to discuss your coursework. | And I add a new discussion to "Study discussions" forum with: - | Subject | Photosynethis discussion | - | Message | Lets discuss our learning about Photosynethis this week in this thread. | + | Subject | Photosynthesis discussion | + | Message | Lets discuss our learning about Photosynthesis this week in this thread. | And I log out And I log in as "student1" And I am on "Science 101" course homepage - And I reply "Photosynethis discussion" post from "Study discussions" forum with: + And I reply "Photosynthesis discussion" post from "Study discussions" forum with: | Message | Can anyone tell me which number is the mass number in the periodic table? | And I log out And I log in as "student2" And I am on "Science 101" course homepage And I follow "Study discussions" - And I follow "Photosynethis discussion" + And I follow "Photosynthesis discussion" And I click on "Reply" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' forumpost ')][contains(., 'Can anyone tell me which number is the mass number in the periodic table?')]" "xpath_element" And I wait to be redirected And I set the following fields to these values: @@ -48,17 +48,15 @@ Feature: Forum discussions can be split Given I log in as "teacher1" And I am on "Science 101" course homepage And I follow "Study discussions" - And I follow "Photosynethis discussion" + And I follow "Photosynthesis discussion" When I follow "Split" And I set the following fields to these values: | Discussion name | Mass number in periodic table | And I press "Split" Then I should see "Mass number in periodic table" And I follow "Study discussions" - And I should see "Teacher 1" in the "Photosynethis" "table_row" + And I should see "Teacher 1" in the "Photosynthesis" "table_row" # Confirm that the last post author has been updated. - And I should not see "Student 2" in the "Photosynethis" "table_row" - # Confirm that the corrent author has been shown for the new split discussion. + And I should not see "Student 2" in the "Photosynthesis" "table_row" + # Confirm that the current author has been shown for the new split discussion. And I should see "Student 1" in the "Mass number in periodic table" "table_row" - # Confirm that the last post author has been updated for the new discussion. - And I should see "Student 2" in the "Mass number in periodic table" "table_row" diff --git a/mod/forum/tests/behat/timed_discussions.feature b/mod/forum/tests/behat/timed_discussions.feature index b7334290cde..406fa615eac 100644 --- a/mod/forum/tests/behat/timed_discussions.feature +++ b/mod/forum/tests/behat/timed_discussions.feature @@ -37,12 +37,12 @@ Feature: Users can choose to set start and end time for display of their discuss And I follow "Test forum name" And I should see "Discussion 2 timed" And I should see "Discussion 3 timed" - And ".timedpost" "css_element" should exist + And "[data-region=timed-label]" "css_element" should exist And I log out And I log in as "student1" When I am on "Course 1" course homepage And I follow "Test forum name" Then I should see "Discussion 1" And I should not see "Discussion 2 timed" - And ".timedpost" "css_element" should not exist + And "[data-region=timed-label]" "css_element" should not exist And I should see "Discussion 3 timed" diff --git a/mod/forum/view.php b/mod/forum/view.php index 5085da55fe6..f07a18a4d7e 100644 --- a/mod/forum/view.php +++ b/mod/forum/view.php @@ -86,7 +86,7 @@ $displaymode = get_user_preferences('forum_displaymode', $CFG->forum_displaymode $PAGE->set_context($forum->get_context()); $PAGE->set_title($forum->get_name()); -$PAGE->add_body_class('forumtype-' . $forum->get_type()); +$PAGE->add_body_class('forumtype-' . $forum->get_type() . ' reset-style'); $PAGE->set_heading($course->fullname); $PAGE->set_button(forum_search_form($course, $search)); diff --git a/mod/forum/yui/build/moodle-mod_forum-subscriptiontoggle/moodle-mod_forum-subscriptiontoggle-debug.js b/mod/forum/yui/build/moodle-mod_forum-subscriptiontoggle/moodle-mod_forum-subscriptiontoggle-debug.js deleted file mode 100644 index 44313f095bc..00000000000 --- a/mod/forum/yui/build/moodle-mod_forum-subscriptiontoggle/moodle-mod_forum-subscriptiontoggle-debug.js +++ /dev/null @@ -1,119 +0,0 @@ -YUI.add('moodle-mod_forum-subscriptiontoggle', function (Y, NAME) { - -// This file is part of Moodle - http://moodle.org/ -// -// Moodle is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Moodle is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Moodle. If not, see . - -/** - * A utility to check whether the connection to the Moodle server is still - * active. - * - * @module moodle-core-subscriptiontoggle - * @package mod_forum - * @copyright 2014 Andrew Nicols - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * @main moodle-mod_forum-subscriptiontoggle - */ - -/** - * @namespace M.mod_forum - * @class subscriptiontoggle - */ - -function SubscriptionToggle() { - SubscriptionToggle.superclass.constructor.apply(this, arguments); -} - -var LOGNAME = 'moodle-mod_forum-subscriptiontoggle'; - -Y.extend(SubscriptionToggle, Y.Base, { - initializer: function() { - Y.delegate('click', this._toggleSubscription, Y.config.doc.body, '.discussionsubscription .discussiontoggle', this); - }, - _toggleSubscription: function(e) { - var clickedLink = e.currentTarget; - - Y.io(this.get('uri'), { - data: { - sesskey: M.cfg.sesskey, - forumid: clickedLink.getData('forumid'), - discussionid: clickedLink.getData('discussionid'), - includetext: clickedLink.getData('includetext') - }, - context: this, - 'arguments': { - clickedLink: clickedLink - }, - on: { - complete: this._handleCompletion - } - }); - - // Prevent the standard browser behaviour now. - e.preventDefault(); - }, - - _handleCompletion: function(tid, response, args) { - var responseObject; - // Attempt to parse the response into an object. - try { - responseObject = Y.JSON.parse(response.response); - if (responseObject.error) { - Y.use('moodle-core-notification-ajaxexception', function() { - return new M.core.ajaxException(responseObject); - }); - return this; - } - } catch (error) { - Y.use('moodle-core-notification-exception', function() { - return new M.core.exception(error); - }); - return this; - } - - if (!responseObject.icon) { - Y.log('No icon received. Skipping the current value replacement', 'warn', LOGNAME); - return; - } - - var container = args.clickedLink.ancestor('.discussionsubscription'); - if (container) { - // We should just receive the new value for the table. - // Note: We do not need to escape the HTML here as it should be provided sanitised from the JS response already. - container.set('innerHTML', responseObject.icon); - } - } -}, { - NAME: 'subscriptionToggle', - ATTRS: { - /** - * The AJAX endpoint which controls the subscription toggle. - * - * @attribute uri - * @type String - * @default M.cfg.wwwroot + '/mod/forum/subscribe_ajax.php' - */ - uri: { - value: M.cfg.wwwroot + '/mod/forum/subscribe_ajax.php' - } - } -}); - -var NS = Y.namespace('M.mod_forum.subscriptiontoggle'); -NS.init = function(config) { - return new SubscriptionToggle(config); -}; - - -}, '@VERSION@', {"requires": ["base-base", "io-base"]}); diff --git a/mod/forum/yui/build/moodle-mod_forum-subscriptiontoggle/moodle-mod_forum-subscriptiontoggle-min.js b/mod/forum/yui/build/moodle-mod_forum-subscriptiontoggle/moodle-mod_forum-subscriptiontoggle-min.js deleted file mode 100644 index b920e9f22d8..00000000000 --- a/mod/forum/yui/build/moodle-mod_forum-subscriptiontoggle/moodle-mod_forum-subscriptiontoggle-min.js +++ /dev/null @@ -1 +0,0 @@ -YUI.add("moodle-mod_forum-subscriptiontoggle",function(e,t){function n(){n.superclass.constructor.apply(this,arguments)}var r="moodle-mod_forum-subscriptiontoggle";e.extend(n,e.Base,{initializer:function(){e.delegate("click",this._toggleSubscription,e.config.doc.body,".discussionsubscription .discussiontoggle",this)},_toggleSubscription:function(t){var n=t.currentTarget;e.io(this.get("uri"),{data:{sesskey:M.cfg.sesskey,forumid:n.getData("forumid"),discussionid:n.getData("discussionid"),includetext:n.getData("includetext")},context:this,arguments:{clickedLink:n},on:{complete:this._handleCompletion}}),t.preventDefault()},_handleCompletion:function(t,n,r){var i;try{i=e.JSON.parse(n.response);if(i.error)return e.use("moodle-core-notification-ajaxexception",function(){return new M.core.ajaxException(i)}),this}catch(s){return e.use("moodle-core-notification-exception",function(){return new M.core.exception(s)}),this}if(!i.icon)return;var o=r.clickedLink.ancestor(".discussionsubscription");o&&o.set("innerHTML",i.icon)}},{NAME:"subscriptionToggle",ATTRS:{uri:{value:M.cfg.wwwroot+"/mod/forum/subscribe_ajax.php"}}});var i=e.namespace("M.mod_forum.subscriptiontoggle");i.init=function(e){return new n(e)}},"@VERSION@",{requires:["base-base","io-base"]}); diff --git a/mod/forum/yui/build/moodle-mod_forum-subscriptiontoggle/moodle-mod_forum-subscriptiontoggle.js b/mod/forum/yui/build/moodle-mod_forum-subscriptiontoggle/moodle-mod_forum-subscriptiontoggle.js deleted file mode 100644 index 66692237d92..00000000000 --- a/mod/forum/yui/build/moodle-mod_forum-subscriptiontoggle/moodle-mod_forum-subscriptiontoggle.js +++ /dev/null @@ -1,118 +0,0 @@ -YUI.add('moodle-mod_forum-subscriptiontoggle', function (Y, NAME) { - -// This file is part of Moodle - http://moodle.org/ -// -// Moodle is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Moodle is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Moodle. If not, see . - -/** - * A utility to check whether the connection to the Moodle server is still - * active. - * - * @module moodle-core-subscriptiontoggle - * @package mod_forum - * @copyright 2014 Andrew Nicols - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * @main moodle-mod_forum-subscriptiontoggle - */ - -/** - * @namespace M.mod_forum - * @class subscriptiontoggle - */ - -function SubscriptionToggle() { - SubscriptionToggle.superclass.constructor.apply(this, arguments); -} - -var LOGNAME = 'moodle-mod_forum-subscriptiontoggle'; - -Y.extend(SubscriptionToggle, Y.Base, { - initializer: function() { - Y.delegate('click', this._toggleSubscription, Y.config.doc.body, '.discussionsubscription .discussiontoggle', this); - }, - _toggleSubscription: function(e) { - var clickedLink = e.currentTarget; - - Y.io(this.get('uri'), { - data: { - sesskey: M.cfg.sesskey, - forumid: clickedLink.getData('forumid'), - discussionid: clickedLink.getData('discussionid'), - includetext: clickedLink.getData('includetext') - }, - context: this, - 'arguments': { - clickedLink: clickedLink - }, - on: { - complete: this._handleCompletion - } - }); - - // Prevent the standard browser behaviour now. - e.preventDefault(); - }, - - _handleCompletion: function(tid, response, args) { - var responseObject; - // Attempt to parse the response into an object. - try { - responseObject = Y.JSON.parse(response.response); - if (responseObject.error) { - Y.use('moodle-core-notification-ajaxexception', function() { - return new M.core.ajaxException(responseObject); - }); - return this; - } - } catch (error) { - Y.use('moodle-core-notification-exception', function() { - return new M.core.exception(error); - }); - return this; - } - - if (!responseObject.icon) { - return; - } - - var container = args.clickedLink.ancestor('.discussionsubscription'); - if (container) { - // We should just receive the new value for the table. - // Note: We do not need to escape the HTML here as it should be provided sanitised from the JS response already. - container.set('innerHTML', responseObject.icon); - } - } -}, { - NAME: 'subscriptionToggle', - ATTRS: { - /** - * The AJAX endpoint which controls the subscription toggle. - * - * @attribute uri - * @type String - * @default M.cfg.wwwroot + '/mod/forum/subscribe_ajax.php' - */ - uri: { - value: M.cfg.wwwroot + '/mod/forum/subscribe_ajax.php' - } - } -}); - -var NS = Y.namespace('M.mod_forum.subscriptiontoggle'); -NS.init = function(config) { - return new SubscriptionToggle(config); -}; - - -}, '@VERSION@', {"requires": ["base-base", "io-base"]}); diff --git a/mod/forum/yui/src/subscriptiontoggle/build.json b/mod/forum/yui/src/subscriptiontoggle/build.json deleted file mode 100644 index 955f268f65a..00000000000 --- a/mod/forum/yui/src/subscriptiontoggle/build.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "moodle-mod_forum-subscriptiontoggle", - "builds": { - "moodle-mod_forum-subscriptiontoggle": { - "jsfiles": [ - "toggle.js" - ] - } - } -} diff --git a/mod/forum/yui/src/subscriptiontoggle/js/toggle.js b/mod/forum/yui/src/subscriptiontoggle/js/toggle.js deleted file mode 100644 index d269baa7fc0..00000000000 --- a/mod/forum/yui/src/subscriptiontoggle/js/toggle.js +++ /dev/null @@ -1,114 +0,0 @@ -// This file is part of Moodle - http://moodle.org/ -// -// Moodle is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Moodle is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Moodle. If not, see . - -/** - * A utility to check whether the connection to the Moodle server is still - * active. - * - * @module moodle-core-subscriptiontoggle - * @package mod_forum - * @copyright 2014 Andrew Nicols - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * @main moodle-mod_forum-subscriptiontoggle - */ - -/** - * @namespace M.mod_forum - * @class subscriptiontoggle - */ - -function SubscriptionToggle() { - SubscriptionToggle.superclass.constructor.apply(this, arguments); -} - -var LOGNAME = 'moodle-mod_forum-subscriptiontoggle'; - -Y.extend(SubscriptionToggle, Y.Base, { - initializer: function() { - Y.delegate('click', this._toggleSubscription, Y.config.doc.body, '.discussionsubscription .discussiontoggle', this); - }, - _toggleSubscription: function(e) { - var clickedLink = e.currentTarget; - - Y.io(this.get('uri'), { - data: { - sesskey: M.cfg.sesskey, - forumid: clickedLink.getData('forumid'), - discussionid: clickedLink.getData('discussionid'), - includetext: clickedLink.getData('includetext') - }, - context: this, - 'arguments': { - clickedLink: clickedLink - }, - on: { - complete: this._handleCompletion - } - }); - - // Prevent the standard browser behaviour now. - e.preventDefault(); - }, - - _handleCompletion: function(tid, response, args) { - var responseObject; - // Attempt to parse the response into an object. - try { - responseObject = Y.JSON.parse(response.response); - if (responseObject.error) { - Y.use('moodle-core-notification-ajaxexception', function() { - return new M.core.ajaxException(responseObject); - }); - return this; - } - } catch (error) { - Y.use('moodle-core-notification-exception', function() { - return new M.core.exception(error); - }); - return this; - } - - if (!responseObject.icon) { - Y.log('No icon received. Skipping the current value replacement', 'warn', LOGNAME); - return; - } - - var container = args.clickedLink.ancestor('.discussionsubscription'); - if (container) { - // We should just receive the new value for the table. - // Note: We do not need to escape the HTML here as it should be provided sanitised from the JS response already. - container.set('innerHTML', responseObject.icon); - } - } -}, { - NAME: 'subscriptionToggle', - ATTRS: { - /** - * The AJAX endpoint which controls the subscription toggle. - * - * @attribute uri - * @type String - * @default M.cfg.wwwroot + '/mod/forum/subscribe_ajax.php' - */ - uri: { - value: M.cfg.wwwroot + '/mod/forum/subscribe_ajax.php' - } - } -}); - -var NS = Y.namespace('M.mod_forum.subscriptiontoggle'); -NS.init = function(config) { - return new SubscriptionToggle(config); -}; diff --git a/mod/forum/yui/src/subscriptiontoggle/meta/subscriptiontoggle.json b/mod/forum/yui/src/subscriptiontoggle/meta/subscriptiontoggle.json deleted file mode 100644 index 140953d7df8..00000000000 --- a/mod/forum/yui/src/subscriptiontoggle/meta/subscriptiontoggle.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "moodle-mod_forum-subscriptiontoggle": { - "requires": [ - "base-base", - "io-base" - ] - } -}