diff --git a/mod/forum/amd/build/discussion_list.min.js b/mod/forum/amd/build/discussion_list.min.js index b0493dc537cc5..be3944b92c6e9 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","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(b){var c=b.discussionId,d=b.subscriptionState,e=a(f.discussion.item+"[data-discussionid= "+c+"] "+f.discussion.subscribedLabel);if(d){e.removeAttr("hidden")}else{e.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()});e.on("click",f.discussion.timedLabel,function(a){a.preventDefault()})};return{init:function init(a){e.init(a);j(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 060f8a83f9c7f..9d8b2fb65240e 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","PubSub","ForumEvents","registerEventListeners","root","subscribe","SUBSCRIPTION_TOGGLED","data","discussionId","subscribed","subscriptionState","subscribedLabel","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","find","lockedLabel","locked","removeClass","addClass","forumid","render","html","js","replaceNode","get_string","done","s","addNotification","message","type","timedLabel","init"],"mappings":"AAuBAA,OAAM,6BAAC,CACH,QADG,CAEH,gBAFG,CAGH,UAHG,CAIH,mBAJG,CAKH,+BALG,CAMH,qBANG,CAOH,sBAPG,CAQH,aARG,CASH,wBATG,CAAD,CAUH,SACCC,CADD,CAECC,CAFD,CAGCC,CAHD,CAICC,CAJD,CAKCC,CALD,CAMCC,CAND,CAOCC,CAPD,CAQCC,CARD,CASCC,CATD,CAUD,CACE,GAAIC,CAAAA,CAAsB,CAAG,SAASC,CAAT,CAAe,CACxCH,CAAM,CAACI,SAAP,CAAiBH,CAAW,CAACI,oBAA7B,CAAmD,SAASC,CAAT,CAAe,IAC1DC,CAAAA,CAAY,CAAGD,CAAI,CAACC,YADsC,CAE1DC,CAAU,CAAGF,CAAI,CAACG,iBAFwC,CAG1DC,CAAe,CAAGjB,CAAC,CAACK,CAAS,CAACa,UAAV,CAAqBC,IAArB,CAA4B,sBAA5B,CAAqDL,CAArD,CAAoE,IAApE,CAClBT,CAAS,CAACa,UAAV,CAAqBD,eADJ,CAHuC,CAK9D,GAAIF,CAAJ,CAAgB,CACZE,CAAe,CAACG,UAAhB,CAA2B,QAA3B,CACH,CAFD,IAEO,CACHH,CAAe,CAACI,IAAhB,CAAqB,QAArB,IACH,CACJ,CAVD,EAYAX,CAAI,CAACY,EAAL,CAAQ,OAAR,CAAiBjB,CAAS,CAACkB,SAAV,CAAoBC,MAArC,CAA6C,UAAW,IAChDC,CAAAA,CAAa,CAAGzB,CAAC,CAAC,IAAD,CAD+B,CAEhD0B,CAAO,CAAGD,CAAa,CAACZ,IAAd,CAAmB,SAAnB,CA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C,OAAO,CAAEF,CADuB,CAEhCG,IAAI,CAAE,MAF0B,CAA7B,CAIV,CANE,CAOV,CA5BL,EA6BK7B,KA7BL,CA6BW5B,CAAY,CAAC6B,SA7BxB,EA+BAE,CAAC,CAACC,cAAF,EACH,CAtCD,EAwCAzB,CAAI,CAACY,EAAL,CAAQ,OAAR,CAAiBjB,CAAS,CAACa,UAAV,CAAqB2C,UAAtC,CAAkD,SAAS3B,CAAT,CAAY,CAE1DA,CAAC,CAACC,cAAF,EACH,CAHD,CAIH,CAlFD,CAoFA,MAAO,CACH2B,IAAI,CAAE,cAASpD,CAAT,CAAe,CACjBN,CAAkB,CAAC0D,IAAnB,CAAwBpD,CAAxB,EACAD,CAAsB,CAACC,CAAD,CACzB,CAJE,CAMV,CA/GK,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 = $(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 root.on('click', Selectors.discussion.timedLabel, function(e) {\n // Prevent clicking on the timed discussion label from causing the page to jump.\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,CAGH,UAHG,CAIH,mBAJG,CAKH,+BALG,CAMH,qBANG,CAOH,sBAPG,CAQH,aARG,CASH,wBATG,CAAD,CAUH,SACCC,CADD,CAECC,CAFD,CAGCC,CAHD,CAICC,CAJD,CAKCC,CALD,CAMCC,CAND,CAOCC,CAPD,CAQCC,CARD,CASCC,CATD,CAUD,CACE,GAAIC,CAAAA,CAAsB,CAAG,SAASC,CAAT,CAAe,CACxCH,CAAM,CAACI,SAAP,CAAiBH,CAAW,CAACI,oBAA7B,CAAmD,SAASC,CAAT,CAAe,IAC1DC,CAAAA,CAAY,CAAGD,CAAI,CAACC,YADsC,CAE1DC,CAAU,CAAGF,CAAI,CAACG,iBAFwC,CAG1DC,CAAe,CAAGP,CAAI,CAACQ,IAAL,CAAUb,CAAS,CAACc,UAAV,CAAqBC,IAArB,CAA4B,sBAA5B,CAAqDN,CAArD,CAAoE,IAApE,CAC1BT,CAAS,CAACc,UAAV,CAAqBF,eADL,CAHwC,CAK9D,GAAIF,CAAJ,CAAgB,CACZE,CAAe,CAACI,UAAhB,CAA2B,QAA3B,CACH,CAFD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AACqD,WAAV,CAAsB5B,CAAtB,CAAqC0B,CAArC,CAA2CC,CAA3C,CACV,CAnBL,EAoBKxB,IApBL,CAoBU,UAAW,CACb,MAAO3B,CAAAA,CAAM,CAACqD,UAAP,CAAkB,aAAlB,CAAiC,OAAjC,EACFC,IADE,CACG,SAASC,CAAT,CAAY,CACd,MAAOtD,CAAAA,CAAY,CAACuD,eAAb,CAA6B,CAChCC,OAAO,CAAEF,CADuB,CAEhCG,IAAI,CAAE,MAF0B,CAA7B,CAIV,CANE,CAOV,CA5BL,EA6BK5B,KA7BL,CA6BW7B,CAAY,CAAC8B,SA7BxB,EA+BAE,CAAC,CAACC,cAAF,EACH,CAtCD,CAuCH,CA7ED,CA+EA,MAAO,CACHyB,IAAI,CAAE,cAASnD,CAAT,CAAe,CACjBN,CAAkB,CAACyD,IAAnB,CAAwBnD,CAAxB,EACAD,CAAsB,CAACC,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/src/discussion_list.js b/mod/forum/amd/src/discussion_list.js index 30aa82782806a..2dafd3930f616 100644 --- a/mod/forum/amd/src/discussion_list.js +++ b/mod/forum/amd/src/discussion_list.js @@ -46,7 +46,7 @@ define([ PubSub.subscribe(ForumEvents.SUBSCRIPTION_TOGGLED, function(data) { var discussionId = data.discussionId; var subscribed = data.subscriptionState; - var subscribedLabel = $(Selectors.discussion.item + '[data-discussionid= ' + discussionId + '] ' + var subscribedLabel = root.find(Selectors.discussion.item + '[data-discussionid= ' + discussionId + '] ' + Selectors.discussion.subscribedLabel); if (subscribed) { subscribedLabel.removeAttr('hidden'); @@ -119,11 +119,6 @@ define([ e.preventDefault(); }); - - root.on('click', Selectors.discussion.timedLabel, function(e) { - // Prevent clicking on the timed discussion label from causing the page to jump. - e.preventDefault(); - }); }; return { diff --git a/mod/forum/templates/discussion_list.mustache b/mod/forum/templates/discussion_list.mustache index 7de247843dfb2..a5b489a3102a9 100644 --- a/mod/forum/templates/discussion_list.mustache +++ b/mod/forum/templates/discussion_list.mustache @@ -169,7 +169,7 @@ data-region="discussion-list-item" data-discussionid="{{id}}" data-forumid="{{forumid}}"> - + {{#discussion.pinned}} {{#pix}}i/pinned, mod_forum, {{#str}}discussionpinned, mod_forum{{/str}}{{/pix}} {{/discussion.pinned}} @@ -182,7 +182,7 @@
- {{#shortentext}}72, {{{discussion.name}}}{{/shortentext}} + {{#shortentext}}100, {{{discussion.name}}}{{/shortentext}}
@@ -192,12 +192,14 @@ {{#str}}subscribed, forum{{/str}} {{#discussion.timed.istimed}} - - {{#str}}timed, forum{{/str}} - + + + {{/discussion.timed.istimed}}
@@ -210,8 +212,9 @@ src="{{{urls.picture}}}" title="{{#str}} pictureof, core, {{name}} {{/str}}"> {{#urls.userlist}} - - {{#shortentext}}15, {{name}}{{/shortentext}} + + {{#shortentext}}30, {{name}}{{/shortentext}} {{/urls.userlist}} {{^urls.userlist}} @@ -249,12 +252,12 @@ {{#forum.capabilities.viewdiscussions}} - {{replies}} + {{replies}} {{#forum.userstate.tracked}} {{#unread}} {{! TODO Rewrite as AJAX}} - - + {{unread}} @@ -263,9 +266,9 @@ {{/forum.userstate.tracked}} {{/forum.capabilities.viewdiscussions}} - + {{#discussion}} -
+
{{#hasanyactions}}
{{> mod_forum/forum_action_menu}} diff --git a/mod/forum/view.php b/mod/forum/view.php index 5085da55fe696..f07a18a4d7eeb 100644 --- a/mod/forum/view.php +++ b/mod/forum/view.php @@ -86,7 +86,7 @@ $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));