MDL-66477 mod_forum: remove duplicate listeners in settings drawer

This commit is contained in:
Ryan Wyllie 2019-09-19 10:42:59 +08:00 committed by Jun Pataleta
parent b53f15b111
commit 49f5b16c61
37 changed files with 216 additions and 357 deletions

View File

@ -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(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)}}});
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,!0,function(a,c){return b.render("mod_forum/discussion_subscription_toggle",c).then(function(c,d){return b.replaceNode(a,c,d)})});j(a)}}});
//# sourceMappingURL=discussion_list.min.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
define ("mod_forum/favourite_toggle",["jquery","core/templates","core/notification","mod_forum/repository","mod_forum/selectors","core/str","core/custom_interaction_events"],function(a,b,c,d,e,f,g){var h=function(h){h.on("click",e.favourite.toggle,function(g){var e=a(this),h=e.data("forumid"),i=e.data("discussionid"),j=e.data("targetstate");d.setFavouriteDiscussionState(h,i,j).then(function(a){return b.render("mod_forum/discussion_favourite_toggle",a)}).then(function(a,c){return b.replaceNode(e,a,c)}).then(function(){return f.get_string("favouriteupdated","forum").done(function(a){return c.addNotification({message:a,type:"info"})})}).catch(c.exception);g.preventDefault()});h.on(g.events.activate,e.favourite.toggleSwitch,function(b){var e=a(this),g=e.data("forumid"),h=e.data("discussionid"),i=e.data("targetstate");d.setFavouriteDiscussionState(g,h,i).then(function(a){var b=a.userstate.favourited?0:1;return e.data("targetstate",b)}).then(function(){return f.get_string("favouriteupdated","forum")}).then(function(a){return c.addNotification({message:a,type:"info"})}).catch(c.exception);b.preventDefault()})};return{init:function init(a){h(a)}}});
define ("mod_forum/favourite_toggle",["jquery","core/templates","core/notification","mod_forum/repository","mod_forum/selectors","core/str"],function(a,b,c,d,e,f){return{init:function registerEventListeners(b,g,h){b.on("click",e.favourite.toggle,function(b){var e=a(this),i=e.data("forumid"),j=e.data("discussionid"),k=e.data("targetstate");d.setFavouriteDiscussionState(i,j,k).then(function(a){return h(e,a)}).then(function(){return f.get_string("favouriteupdated","forum").done(function(a){return c.addNotification({message:a,type:"info"})})}).catch(c.exception);if(g){b.preventDefault()}})}}});
//# sourceMappingURL=favourite_toggle.min.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
define ("mod_forum/forum_events",["exports"],function(a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.default=void 0;a.default={SUBSCRIPTION_TOGGLED:"mod_forum/subscription_toggle:subscriptionToggled",TOGGLE_SETTINGS_DRAWER:"mod_forum/toggle:settings_drawer"};return a.default});
define ("mod_forum/forum_events",[],function(){return{SUBSCRIPTION_TOGGLED:"mod_forum/subscription_toggle:subscriptionToggled"}});
//# sourceMappingURL=forum_events.min.js.map

View File

@ -1 +1 @@
{"version":3,"sources":["../src/forum_events.js"],"names":["SUBSCRIPTION_TOGGLED","TOGGLE_SETTINGS_DRAWER"],"mappings":"kJAuBe,CACXA,oBAAoB,CAAE,mDADX,CAEXC,sBAAsB,CAAE,kCAFb,C","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Events for the forum activity.\n *\n * @module mod_forum/forum_events\n * @package mod_forum\n * @copyright 2019 Jun Pataleta <jun@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nexport default {\n SUBSCRIPTION_TOGGLED: 'mod_forum/subscription_toggle:subscriptionToggled',\n TOGGLE_SETTINGS_DRAWER: 'mod_forum/toggle:settings_drawer'\n};\n"],"file":"forum_events.min.js"}
{"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 <http://www.gnu.org/licenses/>.\n\n/**\n * Events for the forum activity.\n *\n * @module mod_forum/forum_events\n * @package mod_forum\n * @copyright 2019 Jun Pataleta <jun@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([], function() {\n return {\n SUBSCRIPTION_TOGGLED: 'mod_forum/subscription_toggle:subscriptionToggled',\n };\n});\n"],"file":"forum_events.min.js"}

View File

@ -1,2 +1,2 @@
define ("mod_forum/lock_toggle",["jquery","core/templates","core/notification","mod_forum/repository","mod_forum/selectors","core/custom_interaction_events"],function(a,b,c,d,e,f){var g=function(b){var b=a(b),e=b.data("forumid"),f=b.data("discussionid"),g=b.data("state");d.setDiscussionLockState(e,f,g).then(function(){return location.reload()}).catch(c.exception)},h=function(a){a.on("click",e.lock.toggle,function(a){g(this);a.preventDefault()});a.on(f.events.activate,e.lock.toggleSwitch,function(a){g(this);a.preventDefault()})};return{init:function init(a){h(a)}}});
define ("mod_forum/lock_toggle",["jquery","core/templates","core/notification","mod_forum/repository","mod_forum/selectors"],function(a,b,c,d,e){return{init:function registerEventListeners(b,f){b.on("click",e.lock.toggle,function(b){var e=a(this),g=e.data("forumid"),h=e.data("discussionid"),i=e.data("state");d.setDiscussionLockState(g,h,i).then(function(){return location.reload()}).catch(c.exception);if(f){b.preventDefault()}})}}});
//# sourceMappingURL=lock_toggle.min.js.map

View File

@ -1 +1 @@
{"version":3,"sources":["../src/lock_toggle.js"],"names":["define","$","Templates","Notification","Repository","Selectors","CustomEvents","toggleLockState","toggleElement","forumId","data","discussionId","state","setDiscussionLockState","then","location","reload","catch","exception","registerEventListeners","root","on","lock","toggle","e","preventDefault","events","activate","toggleSwitch","init"],"mappings":"AAuBAA,OAAM,yBAAC,CACC,QADD,CAEC,gBAFD,CAGC,mBAHD,CAIC,sBAJD,CAKC,qBALD,CAMC,gCAND,CAAD,CAOC,SACCC,CADD,CAECC,CAFD,CAGCC,CAHD,CAICC,CAJD,CAKCC,CALD,CAMCC,CAND,CAOD,IAOEC,CAAAA,CAAe,CAAG,SAASC,CAAT,CAAwB,IACtCA,CAAAA,CAAa,CAAGP,CAAC,CAACO,CAAD,CADqB,CAEtCC,CAAO,CAAGD,CAAa,CAACE,IAAd,CAAmB,SAAnB,CAF4B,CAGtCC,CAAY,CAAGH,CAAa,CAACE,IAAd,CAAmB,cAAnB,CAHuB,CAItCE,CAAK,CAAGJ,CAAa,CAACE,IAAd,CAAmB,OAAnB,CAJ8B,CAM1CN,CAAU,CAACS,sBAAX,CAAkCJ,CAAlC,CAA2CE,CAA3C,CAAyDC,CAAzD,EACKE,IADL,CACU,UAAW,CACb,MAAOC,CAAAA,QAAQ,CAACC,MAAT,EACV,CAHL,EAIKC,KAJL,CAIWd,CAAY,CAACe,SAJxB,CAKH,CAlBC,CAyBEC,CAAsB,CAAG,SAASC,CAAT,CAAe,CACxCA,CAAI,CAACC,EAAL,CAAQ,OAAR,CAAiBhB,CAAS,CAACiB,IAAV,CAAeC,MAAhC,CAAwC,SAASC,CAAT,CAAY,CAChDjB,CAAe,CAAC,IAAD,CAAf,CAEAiB,CAAC,CAACC,cAAF,EACH,CAJD,EAMAL,CAAI,CAACC,EAAL,CAAQf,CAAY,CAACoB,MAAb,CAAoBC,QAA5B,CAAsCtB,CAAS,CAACiB,IAAV,CAAeM,YAArD,CAAmE,SAASJ,CAAT,CAAY,CAC3EjB,CAAe,CAAC,IAAD,CAAf,CAEAiB,CAAC,CAACC,cAAF,EACH,CAJD,CAKH,CArCC,CAuCF,MAAO,CACHI,IAAI,CAAE,cAAST,CAAT,CAAe,CACjBD,CAAsB,CAACC,CAAD,CACzB,CAHE,CAKV,CA1DK,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 <http://www.gnu.org/licenses/>.\n\n/**\n * Handle the manual locking of individual discussions\n *\n * @module mod_forum/lock_toggle\n * @package mod_forum\n * @copyright 2019 Peter Dias <peter@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/templates',\n 'core/notification',\n 'mod_forum/repository',\n 'mod_forum/selectors',\n 'core/custom_interaction_events',\n ], function(\n $,\n Templates,\n Notification,\n Repository,\n Selectors,\n CustomEvents\n ) {\n\n /**\n * Toggles the locked state of a discussion and refreshes the page.\n *\n * @param {Object} toggleElement\n */\n var toggleLockState = function(toggleElement) {\n var toggleElement = $(toggleElement);\n var forumId = toggleElement.data('forumid');\n var discussionId = toggleElement.data('discussionid');\n var state = toggleElement.data('state');\n\n Repository.setDiscussionLockState(forumId, discussionId, state)\n .then(function() {\n return location.reload();\n })\n .catch(Notification.exception);\n };\n\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.lock.toggle, function(e) {\n toggleLockState(this);\n\n e.preventDefault();\n });\n\n root.on(CustomEvents.events.activate, Selectors.lock.toggleSwitch, function(e) {\n toggleLockState(this);\n\n e.preventDefault();\n });\n };\n\n return {\n init: function(root) {\n registerEventListeners(root);\n }\n };\n});\n"],"file":"lock_toggle.min.js"}
{"version":3,"sources":["../src/lock_toggle.js"],"names":["define","$","Templates","Notification","Repository","Selectors","init","registerEventListeners","root","preventDefault","on","lock","toggle","e","toggleElement","forumId","data","discussionId","state","setDiscussionLockState","then","location","reload","catch","exception"],"mappings":"AAuBAA,OAAM,yBAAC,CACC,QADD,CAEC,gBAFD,CAGC,mBAHD,CAIC,sBAJD,CAKC,qBALD,CAAD,CAMC,SACCC,CADD,CAECC,CAFD,CAGCC,CAHD,CAICC,CAJD,CAKCC,CALD,CAMD,CA2BF,MAAO,CACHC,IAAI,CApBqB,QAAzBC,CAAAA,sBAAyB,CAASC,CAAT,CAAeC,CAAf,CAA+B,CACxDD,CAAI,CAACE,EAAL,CAAQ,OAAR,CAAiBL,CAAS,CAACM,IAAV,CAAeC,MAAhC,CAAwC,SAASC,CAAT,CAAY,IAC5CC,CAAAA,CAAa,CAAGb,CAAC,CAAC,IAAD,CAD2B,CAE5Cc,CAAO,CAAGD,CAAa,CAACE,IAAd,CAAmB,SAAnB,CAFkC,CAG5CC,CAAY,CAAGH,CAAa,CAACE,IAAd,CAAmB,cAAnB,CAH6B,CAI5CE,CAAK,CAAGJ,CAAa,CAACE,IAAd,CAAmB,OAAnB,CAJoC,CAMhDZ,CAAU,CAACe,sBAAX,CAAkCJ,CAAlC,CAA2CE,CAA3C,CAAyDC,CAAzD,EACKE,IADL,CACU,UAAW,CACb,MAAOC,CAAAA,QAAQ,CAACC,MAAT,EACV,CAHL,EAIKC,KAJL,CAIWpB,CAAY,CAACqB,SAJxB,EAMA,GAAIf,CAAJ,CAAoB,CAChBI,CAAC,CAACJ,cAAF,EACH,CACJ,CAfD,CAgBH,CAEM,CAGV,CA1CK,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 <http://www.gnu.org/licenses/>.\n\n/**\n * Handle the manual locking of individual discussions\n *\n * @module mod_forum/lock_toggle\n * @package mod_forum\n * @copyright 2019 Peter Dias <peter@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/templates',\n 'core/notification',\n 'mod_forum/repository',\n 'mod_forum/selectors',\n ], function(\n $,\n Templates,\n Notification,\n Repository,\n Selectors\n ) {\n\n /**\n * Register event listeners for the subscription toggle.\n *\n * @param {object} root The discussion list root element\n * @param {boolean} preventDefault Should the default action of the event be prevented\n */\n var registerEventListeners = function(root, preventDefault) {\n root.on('click', Selectors.lock.toggle, function(e) {\n var toggleElement = $(this);\n var forumId = toggleElement.data('forumid');\n var discussionId = toggleElement.data('discussionid');\n var state = toggleElement.data('state');\n\n Repository.setDiscussionLockState(forumId, discussionId, state)\n .then(function() {\n return location.reload();\n })\n .catch(Notification.exception);\n\n if (preventDefault) {\n e.preventDefault();\n }\n });\n };\n\n return {\n init: registerEventListeners\n };\n});\n"],"file":"lock_toggle.min.js"}

View File

@ -1,2 +1,2 @@
define ("mod_forum/pin_toggle",["jquery","core/ajax","core/str","core/templates","core/notification","mod_forum/repository","mod_forum/selectors","core/str","core/custom_interaction_events"],function(a,b,c,d,f,g,h,i,j){var k=function(b){b.on("click",h.pin.toggle,function(b){var c=a(this),e=c.data("forumid"),h=c.data("discussionid"),j=c.data("targetstate");g.setPinDiscussionState(e,h,j).then(function(a){return d.render("mod_forum/discussion_pin_toggle",a)}).then(function(a,b){return d.replaceNode(c,a,b)}).then(function(){return i.get_string("pinupdated","forum").done(function(a){return f.addNotification({message:a,type:"info"})})}).fail(f.exception);b.preventDefault()});b.on(j.events.activate,h.pin.toggleSwitch,function(b){var c=a(this),d=c.data("forumid"),e=c.data("discussionid"),h=c.data("targetstate");g.setPinDiscussionState(d,e,h).then(function(a){var b=a.pinned?0:1;return c.data("targetstate",b)}).then(function(){return i.get_string("pinupdated","forum")}).then(function(a){return f.addNotification({message:a,type:"info"})}).fail(f.exception);b.preventDefault()})};return{init:function init(a){k(a)}}});
define ("mod_forum/pin_toggle",["jquery","core/ajax","core/str","core/templates","core/notification","mod_forum/repository","mod_forum/selectors","core/str"],function(a,b,c,d,f,g,h,i){return{init:function registerEventListeners(b,c,d){b.on("click",h.pin.toggle,function(b){var e=a(this),h=e.data("forumid"),j=e.data("discussionid"),k=e.data("targetstate");g.setPinDiscussionState(h,j,k).then(function(a){return d(e,a)}).then(function(){return i.get_string("pinupdated","forum").done(function(a){return f.addNotification({message:a,type:"info"})})}).fail(f.exception);if(c){b.preventDefault()}})}}});
//# sourceMappingURL=pin_toggle.min.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
define ("mod_forum/selectors",[],function(){return{subscription:{toggle:"[data-type='subscription-toggle'][data-action='toggle']",toggleSwitch:"[data-type='subscription-toggle-switch'][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']",toggleSwitch:"[data-action='toggle'][data-type='lock-toggle-switch']",icon:"[data-region='locked-icon']"},favourite:{toggle:"[data-type='favorite-toggle'][data-action='toggle']",toggleSwitch:"[data-type='favorite-toggle-switch'][data-action='toggle']"},pin:{toggle:"[data-type='pin-toggle'][data-action='toggle']",toggleSwitch:"[data-type='pin-toggle-switch'][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']"}}});
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

File diff suppressed because one or more lines are too long

View File

@ -1,2 +0,0 @@
define ("mod_forum/settings_drawer",["exports","jquery","core/pubsub","core/drawer","mod_forum/forum_events"],function(a,b,c,d,e){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=f(b);c=function(a){if(a&&a.__esModule){return a}else{var b={};if(null!=a){for(var c in a){if(Object.prototype.hasOwnProperty.call(a,c)){var d=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(a,c):{};if(d.get||d.set){Object.defineProperty(b,c,d)}else{b[c]=a[c]}}}}b.default=a;return b}}(c);d=f(d);e=f(e);function f(a){return a&&a.__esModule?a:{default:a}}var g=function(a){c.subscribe(e.default.TOGGLE_SETTINGS_DRAWER,function(){var b=d.default.getDrawerRoot(a);if(d.default.isVisible(b)){d.default.hide(b)}else{d.default.show(b)}})},h=function(a){a=(0,b.default)(a);g(a)};a.init=h});
//# sourceMappingURL=settings_drawer.min.js.map

View File

@ -1 +0,0 @@
{"version":3,"sources":["../src/settings_drawer.js"],"names":["registerEventListeners","root","PubSub","subscribe","Events","TOGGLE_SETTINGS_DRAWER","drawerRoot","Drawer","getDrawerRoot","isVisible","hide","show","init"],"mappings":"8MAsBA,OACA,kUACA,OACA,O,sDAEMA,CAAAA,CAAsB,CAAG,SAACC,CAAD,CAAU,CACrCC,CAAM,CAACC,SAAP,CAAiBC,UAAOC,sBAAxB,CAAgD,UAAW,CACvD,GAAMC,CAAAA,CAAU,CAAGC,UAAOC,aAAP,CAAqBP,CAArB,CAAnB,CACA,GAAIM,UAAOE,SAAP,CAAiBH,CAAjB,CAAJ,CAAkC,CAC9BC,UAAOG,IAAP,CAAYJ,CAAZ,CACH,CAFD,IAEO,CACHC,UAAOI,IAAP,CAAYL,CAAZ,CACH,CACJ,CAPD,CAQH,C,CAOYM,CAAI,CAAG,SAACX,CAAD,CAAU,CAC1BA,CAAI,CAAG,cAAEA,CAAF,CAAP,CACAD,CAAsB,CAACC,CAAD,CACzB,C","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Controls the forum/discussion settings drawer.\n *\n * @module mod_forum/settings_drawer\n * @copyright 2019 Jun Pataleta <jun@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nimport $ from 'jquery';\nimport * as PubSub from 'core/pubsub';\nimport Drawer from 'core/drawer';\nimport Events from 'mod_forum/forum_events';\n\nconst registerEventListeners = (root) => {\n PubSub.subscribe(Events.TOGGLE_SETTINGS_DRAWER, function() {\n const drawerRoot = Drawer.getDrawerRoot(root);\n if (Drawer.isVisible(drawerRoot)) {\n Drawer.hide(drawerRoot);\n } else {\n Drawer.show(drawerRoot);\n }\n });\n};\n\n/**\n * Initialise the settings drawer.\n *\n * @param {Object} root The settings drawer container.\n */\nexport const init = (root) => {\n root = $(root);\n registerEventListeners(root);\n};\n"],"file":"settings_drawer.min.js"}

View File

@ -1,2 +1,2 @@
define ("mod_forum/subscription_toggle",["jquery","core/templates","core/notification","mod_forum/repository","mod_forum/selectors","core/pubsub","mod_forum/forum_events","core/custom_interaction_events"],function(a,b,c,d,e,f,g,h){var i=function(i){i.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()});i.on(h.events.activate,e.subscription.toggleSwitch,function(b){var e=a(this),h=e.data("forumid"),i=e.data("discussionid"),j=e.data("targetstate");d.setDiscussionSubscriptionState(h,i,j).then(function(a){var b=a.userstate.subscribed?0:1;e.data("targetstate",b);return f.publish(g.SUBSCRIPTION_TOGGLED,{discussionId:i,subscriptionState:a.userstate.subscribed})}).catch(c.exception);b.preventDefault()})};return{init:function init(a){i(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){return{init:function registerEventListeners(b,h,i){b.on("click",e.subscription.toggle,function(b){var e=a(this),j=e.data("forumid"),k=e.data("discussionid"),l=e.data("targetstate");d.setDiscussionSubscriptionState(j,k,l).then(function(a){f.publish(g.SUBSCRIPTION_TOGGLED,{discussionId:k,subscriptionState:l});return i(e,a)}).catch(c.exception);if(h){b.preventDefault()}})}}});
//# sourceMappingURL=subscription_toggle.min.js.map

File diff suppressed because one or more lines are too long

View File

@ -123,7 +123,12 @@ define([
return {
init: function(root) {
SubscriptionToggle.init(root);
SubscriptionToggle.init(root, true, function(toggleElement, context) {
return Templates.render('mod_forum/discussion_subscription_toggle', context)
.then(function(html, js) {
return Templates.replaceNode(toggleElement, html, js);
});
});
registerEventListeners(root);
}
};

View File

@ -410,8 +410,17 @@ export const init = (root, context) => {
// Initialise the settings menu javascript.
const discussionToolsContainer = root.find(Selectors.discussion.tools);
LockToggle.init(discussionToolsContainer);
FavouriteToggle.init(discussionToolsContainer);
Pin.init(discussionToolsContainer);
Subscribe.init(discussionToolsContainer);
LockToggle.init(discussionToolsContainer, false);
FavouriteToggle.init(discussionToolsContainer, false, (toggleElement, response) => {
const newTargetState = response.userstate.favourited ? 0 : 1;
return toggleElement.data('targetstate', newTargetState);
});
Pin.init(discussionToolsContainer, false, (toggleElement, response) => {
const newTargetState = response.pinned ? 0 : 1;
return toggleElement.data('targetstate', newTargetState);
});
Subscribe.init(discussionToolsContainer, false, (toggleElement, response) => {
const newTargetState = response.userstate.subscribed ? 0 : 1;
toggleElement.data('targetstate', newTargetState);
});
};

View File

@ -29,23 +29,23 @@ define([
'mod_forum/repository',
'mod_forum/selectors',
'core/str',
'core/custom_interaction_events',
], function(
$,
Templates,
Notification,
Repository,
Selectors,
String,
CustomEvents
String
) {
/**
* Register event listeners for the subscription toggle.
*
* @param {object} root The discussion list root element
* @param {boolean} preventDefault Should the default action of the event be prevented
* @param {function} callback Success callback
*/
var registerEventListeners = function(root) {
var registerEventListeners = function(root, preventDefault, callback) {
root.on('click', Selectors.favourite.toggle, function(e) {
var toggleElement = $(this);
var forumId = toggleElement.data('forumid');
@ -54,10 +54,7 @@ define([
Repository.setFavouriteDiscussionState(forumId, discussionId, subscriptionState)
.then(function(context) {
return Templates.render('mod_forum/discussion_favourite_toggle', context);
})
.then(function(html, js) {
return Templates.replaceNode(toggleElement, html, js);
return callback(toggleElement, context);
})
.then(function() {
return String.get_string("favouriteupdated", "forum")
@ -70,35 +67,13 @@ define([
})
.catch(Notification.exception);
e.preventDefault();
});
root.on(CustomEvents.events.activate, Selectors.favourite.toggleSwitch, function(e) {
var toggleElement = $(this);
var forumId = toggleElement.data('forumid');
var discussionId = toggleElement.data('discussionid');
var subscriptionState = toggleElement.data('targetstate');
Repository.setFavouriteDiscussionState(forumId, discussionId, subscriptionState)
.then(function(context) {
var newTargetState = context.userstate.favourited ? 0 : 1;
return toggleElement.data('targetstate', newTargetState);
}).then(function() {
return String.get_string("favouriteupdated", "forum");
}).then(function(s) {
return Notification.addNotification({
message: s,
type: "info"
});
}).catch(Notification.exception);
e.preventDefault();
if (preventDefault) {
e.preventDefault();
}
});
};
return {
init: function(root) {
registerEventListeners(root);
}
init: registerEventListeners
};
});

View File

@ -21,7 +21,8 @@
* @copyright 2019 Jun Pataleta <jun@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
export default {
SUBSCRIPTION_TOGGLED: 'mod_forum/subscription_toggle:subscriptionToggled',
TOGGLE_SETTINGS_DRAWER: 'mod_forum/toggle:settings_drawer'
};
define([], function() {
return {
SUBSCRIPTION_TOGGLED: 'mod_forum/subscription_toggle:subscriptionToggled',
};
});

View File

@ -27,56 +27,40 @@ define([
'core/notification',
'mod_forum/repository',
'mod_forum/selectors',
'core/custom_interaction_events',
], function(
$,
Templates,
Notification,
Repository,
Selectors,
CustomEvents
Selectors
) {
/**
* Toggles the locked state of a discussion and refreshes the page.
*
* @param {Object} toggleElement
*/
var toggleLockState = function(toggleElement) {
var toggleElement = $(toggleElement);
var forumId = toggleElement.data('forumid');
var discussionId = toggleElement.data('discussionid');
var state = toggleElement.data('state');
Repository.setDiscussionLockState(forumId, discussionId, state)
.then(function() {
return location.reload();
})
.catch(Notification.exception);
};
/**
* Register event listeners for the subscription toggle.
*
* @param {object} root The discussion list root element
* @param {boolean} preventDefault Should the default action of the event be prevented
*/
var registerEventListeners = function(root) {
var registerEventListeners = function(root, preventDefault) {
root.on('click', Selectors.lock.toggle, function(e) {
toggleLockState(this);
var toggleElement = $(this);
var forumId = toggleElement.data('forumid');
var discussionId = toggleElement.data('discussionid');
var state = toggleElement.data('state');
e.preventDefault();
});
Repository.setDiscussionLockState(forumId, discussionId, state)
.then(function() {
return location.reload();
})
.catch(Notification.exception);
root.on(CustomEvents.events.activate, Selectors.lock.toggleSwitch, function(e) {
toggleLockState(this);
e.preventDefault();
if (preventDefault) {
e.preventDefault();
}
});
};
return {
init: function(root) {
registerEventListeners(root);
}
init: registerEventListeners
};
});

View File

@ -34,7 +34,6 @@ define([
'mod_forum/repository',
'mod_forum/selectors',
'core/str',
'core/custom_interaction_events',
], function(
$,
Ajax,
@ -43,16 +42,17 @@ define([
Notification,
Repository,
Selectors,
String,
CustomEvents
String
) {
/**
* Registery event listeners for the pin toggle.
*
* @param {object} root The calendar root element
* @param {boolean} preventDefault Should the default action of the event be prevented
* @param {function} callback Success callback
*/
var registerEventListeners = function(root) {
var registerEventListeners = function(root, preventDefault, callback) {
root.on('click', Selectors.pin.toggle, function(e) {
var toggleElement = $(this);
var forumid = toggleElement.data('forumid');
@ -60,10 +60,7 @@ define([
var pinstate = toggleElement.data('targetstate');
Repository.setPinDiscussionState(forumid, discussionid, pinstate)
.then(function(context) {
return Templates.render('mod_forum/discussion_pin_toggle', context);
})
.then(function(html, js) {
return Templates.replaceNode(toggleElement, html, js);
return callback(toggleElement, context);
})
.then(function() {
return String.get_string("pinupdated", "forum")
@ -76,37 +73,13 @@ define([
})
.fail(Notification.exception);
e.preventDefault();
});
root.on(CustomEvents.events.activate, Selectors.pin.toggleSwitch, function(e) {
var toggleElement = $(this);
var forumid = toggleElement.data('forumid');
var discussionid = toggleElement.data('discussionid');
var pinstate = toggleElement.data('targetstate');
Repository.setPinDiscussionState(forumid, discussionid, pinstate)
.then(function(context) {
var newTargetState = context.pinned ? 0 : 1;
return toggleElement.data('targetstate', newTargetState);
})
.then(function() {
return String.get_string("pinupdated", "forum");
})
.then(function(s) {
return Notification.addNotification({
message: s,
type: "info"
});
})
.fail(Notification.exception);
e.preventDefault();
if (preventDefault) {
e.preventDefault();
}
});
};
return {
init: function(root) {
registerEventListeners(root);
}
init: registerEventListeners
};
});

View File

@ -25,7 +25,6 @@ define([], function() {
return {
subscription: {
toggle: "[data-type='subscription-toggle'][data-action='toggle']",
toggleSwitch: "[data-type='subscription-toggle-switch'][data-action='toggle']",
},
summary: {
actions: "[data-container='discussion-summary-actions']"
@ -57,16 +56,13 @@ define([], function() {
},
lock: {
toggle: "[data-action='toggle'][data-type='lock-toggle']",
toggleSwitch: "[data-action='toggle'][data-type='lock-toggle-switch']",
icon: "[data-region='locked-icon']"
},
favourite: {
toggle: "[data-type='favorite-toggle'][data-action='toggle']",
toggleSwitch: "[data-type='favorite-toggle-switch'][data-action='toggle']",
},
pin: {
toggle: "[data-type='pin-toggle'][data-action='toggle']",
toggleSwitch: "[data-type='pin-toggle-switch'][data-action='toggle']",
},
discussion: {
tools: '[data-container="discussion-tools"]',

View File

@ -1,47 +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 <http://www.gnu.org/licenses/>.
/**
* Controls the forum/discussion settings drawer.
*
* @module mod_forum/settings_drawer
* @copyright 2019 Jun Pataleta <jun@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
import $ from 'jquery';
import * as PubSub from 'core/pubsub';
import Drawer from 'core/drawer';
import Events from 'mod_forum/forum_events';
const registerEventListeners = (root) => {
PubSub.subscribe(Events.TOGGLE_SETTINGS_DRAWER, function() {
const drawerRoot = Drawer.getDrawerRoot(root);
if (Drawer.isVisible(drawerRoot)) {
Drawer.hide(drawerRoot);
} else {
Drawer.show(drawerRoot);
}
});
};
/**
* Initialise the settings drawer.
*
* @param {Object} root The settings drawer container.
*/
export const init = (root) => {
root = $(root);
registerEventListeners(root);
};

View File

@ -30,7 +30,6 @@ define([
'mod_forum/selectors',
'core/pubsub',
'mod_forum/forum_events',
'core/custom_interaction_events',
], function(
$,
Templates,
@ -38,16 +37,17 @@ define([
Repository,
Selectors,
PubSub,
ForumEvents,
CustomEvents
ForumEvents
) {
/**
* Register event listeners for the subscription toggle.
*
* @param {object} root The discussion list root element
* @param {boolean} preventDefault Should the default action of the event be prevented
* @param {function} callback Success callback
*/
var registerEventListeners = function(root) {
var registerEventListeners = function(root, preventDefault, callback) {
root.on('click', Selectors.subscription.toggle, function(e) {
var toggleElement = $(this);
var forumId = toggleElement.data('forumid');
@ -60,40 +60,17 @@ define([
discussionId: discussionId,
subscriptionState: subscriptionState
});
return Templates.render('mod_forum/discussion_subscription_toggle', context);
})
.then(function(html, js) {
return Templates.replaceNode(toggleElement, html, js);
return callback(toggleElement, context);
})
.catch(Notification.exception);
e.preventDefault();
});
root.on(CustomEvents.events.activate, Selectors.subscription.toggleSwitch, function(e) {
var toggleElement = $(this);
var forumId = toggleElement.data('forumid');
var discussionId = toggleElement.data('discussionid');
var subscriptionState = toggleElement.data('targetstate');
Repository.setDiscussionSubscriptionState(forumId, discussionId, subscriptionState)
.then(function(context) {
var newTargetState = context.userstate.subscribed ? 0 : 1;
toggleElement.data('targetstate', newTargetState);
return PubSub.publish(ForumEvents.SUBSCRIPTION_TOGGLED, {
discussionId: discussionId,
subscriptionState: context.userstate.subscribed
});
})
.catch(Notification.exception);
e.preventDefault();
if (preventDefault) {
e.preventDefault();
}
});
};
return {
init: function(root) {
registerEventListeners(root);
}
init: registerEventListeners
};
});

View File

@ -34,67 +34,61 @@
}}
<div data-region="settings" class="p-3 discussion-settings-container" data-container="discussion-tools">
<div class="p-2 discussion-settings-container" data-container="discussion-tools">
<h3 class="mb-2 mt-2 h6 font-weight-bold">{{#str}} general, core {{/str}}</h3>
{{#capabilities.subscribe}}
<div data-region="subscribe">
{{< mod_forum/setting_switch}}
{{$switchid}}subscription-toggle-{{uniqid}}{{/switchid}}
{{$type}}subscription-toggle-switch{{/type}}
{{$otherattributes}}
data-discussionid="{{id}}"
data-forumid="{{forumid}}"
{{#userstate.subscribed}}data-targetstate="0" checked{{/userstate.subscribed}}
{{^userstate.subscribed}}data-targetstate="1"{{/userstate.subscribed}}
{{/otherattributes}}
{{$labeltext}}
{{#str}} subscribediscussion, mod_forum {{/str}}
{{/labeltext}}
{{/mod_forum/setting_switch}}
</div>
{{< mod_forum/setting_switch}}
{{$switchid}}subscription-toggle-{{uniqid}}{{/switchid}}
{{$type}}subscription-toggle{{/type}}
{{$otherattributes}}
data-discussionid="{{id}}"
data-forumid="{{forumid}}"
{{#userstate.subscribed}}data-targetstate="0" checked{{/userstate.subscribed}}
{{^userstate.subscribed}}data-targetstate="1"{{/userstate.subscribed}}
{{/otherattributes}}
{{$labeltext}}
{{#str}} subscribediscussion, mod_forum {{/str}}
{{/labeltext}}
{{/mod_forum/setting_switch}}
{{/capabilities.subscribe}}
{{#capabilities.favourite}}
<div data-region="favourite">
{{< mod_forum/setting_switch}}
{{$switchid}}favorite-toggle-{{uniqid}}{{/switchid}}
{{$type}}favorite-toggle-switch{{/type}}
{{$otherattributes}}
data-discussionid="{{id}}"
data-forumid="{{forumid}}"
{{#userstate.favourited}}data-targetstate="0" checked{{/userstate.favourited}}
{{^userstate.favourited}}data-targetstate="1"{{/userstate.favourited}}
{{/otherattributes}}
{{$labeltext}}
{{#str}} addtofavourites, mod_forum {{/str}}
{{/labeltext}}
{{/mod_forum/setting_switch}}
</div>
{{< mod_forum/setting_switch}}
{{$switchid}}favorite-toggle-{{uniqid}}{{/switchid}}
{{$type}}favorite-toggle{{/type}}
{{$otherattributes}}
data-discussionid="{{id}}"
data-forumid="{{forumid}}"
{{#userstate.favourited}}data-targetstate="0" checked{{/userstate.favourited}}
{{^userstate.favourited}}data-targetstate="1"{{/userstate.favourited}}
{{/otherattributes}}
{{$labeltext}}
{{#str}} addtofavourites, mod_forum {{/str}}
{{/labeltext}}
{{/mod_forum/setting_switch}}
{{/capabilities.favourite}}
{{#capabilities.pin}}
<div data-region="pin">
{{< mod_forum/setting_switch}}
{{$switchid}}pin-toggle-{{uniqid}}{{/switchid}}
{{$type}}pin-toggle-switch{{/type}}
{{$otherattributes}}
data-discussionid="{{id}}"
data-forumid="{{forumid}}"
{{#pinned}}data-targetstate="0" checked{{/pinned}}
{{^pinned}}data-targetstate="1"{{/pinned}}
{{/otherattributes}}
{{$labeltext}}
{{#str}} pindiscussion, mod_forum {{/str}}
{{/labeltext}}
{{/mod_forum/setting_switch}}
</div>
{{< mod_forum/setting_switch}}
{{$switchid}}pin-toggle-{{uniqid}}{{/switchid}}
{{$type}}pin-toggle{{/type}}
{{$otherattributes}}
data-discussionid="{{id}}"
data-forumid="{{forumid}}"
{{#pinned}}data-targetstate="0" checked{{/pinned}}
{{^pinned}}data-targetstate="1"{{/pinned}}
{{/otherattributes}}
{{$labeltext}}
{{#str}} pindiscussion, mod_forum {{/str}}
{{/labeltext}}
{{/mod_forum/setting_switch}}
{{/capabilities.pin}}
{{#capabilities.manage}}
{{^istimelocked}}
{{< mod_forum/setting_switch}}
{{$switchid}}lock-toggle-{{uniqid}}{{/switchid}}
{{$type}}lock-toggle-switch{{/type}}
{{$type}}lock-toggle{{/type}}
{{$otherattributes}}
data-discussionid="{{id}}"
data-forumid="{{forumid}}"
@ -109,23 +103,17 @@
{{/capabilities.manage}}
{{#modeselectorform}}
<h3 class="h6 mt-2 font-weight-bold">{{#str}} view, core {{/str}}</h3>
<div data-region="view" class="mb-3">
{{{.}}}
</div>
<h3 class="h6 mt-4 font-weight-bold">{{#str}} view, core {{/str}}</h3>
{{{.}}}
{{/modeselectorform}}
{{#movediscussion}}
<h3 class="h6 mt-2 font-weight-bold">{{#str}} move, core {{/str}}</h3>
<div data-region="move" class="mb-3">
{{{.}}}
</div>
<h3 class="h6 mt-4 font-weight-bold">{{#str}} move, core {{/str}}</h3>
{{{.}}}
{{/movediscussion}}
{{#exportdiscussion}}
<h3 class="h6 mt-2 font-weight-bold">{{#str}} portfolio, portfolio {{/str}}</h3>
<div data-region="export" class="mb-3">
{{{.}}}
</div>
<h3 class="h6 mt-4 font-weight-bold">{{#str}} portfolio, portfolio {{/str}}</h3>
{{{.}}}
{{/exportdiscussion}}
</div>

View File

@ -34,21 +34,13 @@
}}
{{<core/drawer}}
{{$drawerid}}discussion-settings-drawer{{/drawerid}}
{{$drawercontent}}
<div id="discussion-settings-drawer-{{uniqid}}" data-region="message-drawer" role="region">
<div class="header-container position-relative" data-region="header-container">
{{> mod_forum/settings_header}}
</div>
<div class="h-100 w-100 bg-white d-flex flex-column p-2">
{{> mod_forum/settings_header}}
<div class="body-container position-relative" data-region="body-container">
{{> mod_forum/discussion_settings_body_content}}
</div>
</div>
{{/drawercontent}}
{{/core/drawer}}
{{#js}}
require(['jquery', 'mod_forum/settings_drawer'], function($, SettingsDrawer) {
var root = $('#discussion-settings-drawer-{{uniqid}}');
SettingsDrawer.init(root);
});
{{/js}}

View File

@ -59,16 +59,49 @@
{{#html.neighbourlinks}}{{{.}}}{{/html.neighbourlinks}}
</div>
{{#js}}
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);
root = $('[data-container="discussion-tools"]');
LockToggle.init(root);
FavouriteToggle.init(root);
Pin.init(root);
SubscribeToggle.init(root);
require(
[
'jquery',
'core/templates',
'mod_forum/discussion',
'mod_forum/posts_list',
'mod_forum/lock_toggle',
'mod_forum/favourite_toggle',
'mod_forum/pin_toggle',
'mod_forum/subscription_toggle'
],
function(
$,
Templates,
Discussion,
PostsList,
LockToggle,
FavouriteToggle,
Pin,
SubscribeToggle
) {
var root = $("[data-content='forum-discussion']");
Discussion.init(root);
PostsList.init(root);
root = $('[data-container="discussion-tools"]');
LockToggle.init(root, true);
FavouriteToggle.init(root, true, function(toggleElement, context) {
return Templates.render('mod_forum/discussion_favourite_toggle', context)
.then(function(html, js) {
return Templates.replaceNode(toggleElement, html, js);
});
});
Pin.init(root, true, function(toggleElement, context) {
return Templates.render('mod_forum/discussion_pin_toggle', context)
.then(function(html, js) {
return Templates.replaceNode(toggleElement, html, js);
});
});
SubscribeToggle.init(root, true, function(toggleElement, context) {
return Templates.render('mod_forum/discussion_subscription_toggle', context)
.then(function(html, js) {
return Templates.replaceNode(toggleElement, html, js);
});
});
});
{{/js}}

View File

@ -30,7 +30,7 @@
}
}}
<div id="discussion-container-{{uniqid}}" data-content="forum-discussion">
<div id="discussion-container-{{uniqid}}" data-content="forum-discussion" class="mt-4">
{{#html}}
{{> mod_forum/discussion_settings_drawer}}
{{/html}}

View File

@ -37,7 +37,7 @@
data-type="{{$type}}toggle-switch{{/type}}"
data-action="toggle"
{{$otherattributes}}{{/otherattributes}}/>
<label for="{{$switchid}}{{uniqid}}{{/switchid}}">
<label for="{{$switchid}}{{uniqid}}{{/switchid}}" class="line-height-4">
{{$labeltext}}{{/labeltext}}
</label>
</span>

View File

@ -32,24 +32,21 @@
{}
}}
<div class="float-right">
<button id="discussion-settings-drawer-trigger-{{uniqid}}"
class="btn btn-link btn-lg discussion-settings-trigger icon-no-margin position-relative"
data-toggle="discussion-settings">
{{#pix}} i/settings, core, {{#str}} togglesettingsdrawer, mod_forum {{/str}} {{/pix}}
</button>
</div>
<button
id="toggle-discussion-settings-drawer-{{uniqid}}"
class="btn btn-icon icon-size-4 icon-no-margin colour-inherit"
aria-controls="discussion-settings-drawer"
aria-expanded="false"
title="{{#str}} togglesettingsdrawer, mod_forum {{/str}}"
>
{{#pix}} i/settings, core, {{#str}} togglesettingsdrawer, mod_forum {{/str}} {{/pix}}
</button>
{{#js}}
require(
['jquery', 'mod_forum/forum_events', 'core/custom_interaction_events', 'core/pubsub'],
function($, ForumEvents, CustomEvents, PubSub) {
var root = $('#discussion-settings-drawer-trigger-{{uniqid}}');
CustomEvents.define(root, [CustomEvents.events.activate]);
root.on(CustomEvents.events.activate, function(e) {
PubSub.publish(ForumEvents.TOGGLE_SETTINGS_DRAWER);
});
}
);
require(['jquery', 'core/drawer'], function($, Drawer) {
var drawer = $('#discussion-settings-drawer');
var toggles = drawer.find('[data-action="toggle-settings-drawer"]');
toggles = toggles.add('#toggle-discussion-settings-drawer-{{uniqid}}');
Drawer.registerToggles(drawer, toggles);
});
{{/js}}

View File

@ -33,30 +33,18 @@
}}
<div class="border-bottom px-2 py-3" aria-hidden="true" data-region="view-settings">
<div class="d-flex align-items-center">
<div class="align-self-stretch" >
<button id="settings-drawer-close-{{uniqid}}" class="h-100 d-flex mr-2 align-items-center btn btn-icon"
data-toggle="discussion-settings">
<span class="dir-ltr-hide">{{#pix}} t/left, core {{/pix}}</span>
<span class="dir-rtl-hide">{{#pix}} t/right, core {{/pix}}</span>
</button>
</div>
<div class="lead font-weight-bolder">
{{#str}} settings, core {{/str}}
</div>
</div>
<div class="d-flex align-items-center mb-2">
<button
class="btn btn-icon icon-size-3 icon-no-margin mr-1 colour-inherit"
data-action="toggle-settings-drawer"
aria-controls="discussion-settings-drawer"
aria-expanded="false"
title="{{#str}} closebuttontitle, core {{/str}}"
>
<span class="dir-ltr-hide">{{#pix}} t/left, core {{/pix}}</span>
<span class="dir-rtl-hide">{{#pix}} t/right, core {{/pix}}</span>
</button>
<h2 class="font-weight-bold h3 mb-0">
{{#str}} settings, core {{/str}}
</h2>
</div>
{{#js}}
require(
['jquery', 'mod_forum/forum_events', 'core/custom_interaction_events', 'core/pubsub'],
function($, ForumEvents, CustomEvents, PubSub) {
var root = $('#settings-drawer-close-{{uniqid}}');
CustomEvents.define(root, [CustomEvents.events.activate]);
root.on(CustomEvents.events.activate, function(e) {
PubSub.publish(ForumEvents.TOGGLE_SETTINGS_DRAWER);
});
}
);
{{/js}}

View File

@ -109,14 +109,11 @@ select {
}
}
.discussion-settings-trigger .icon {
height: $icon-height * 2;
font-size: $icon-height * 2;
width: auto;
}
.discussion-settings-container {
.custom-select,
.custom-select {
width: 100%;
}
input {
max-width: 100%;
}

View File

@ -16117,12 +16117,9 @@ select {
color: #373a3c;
font-weight: bold; }
.discussion-settings-trigger .icon {
height: 32px;
font-size: 32px;
width: auto; }
.discussion-settings-container .custom-select {
width: 100%; }
.discussion-settings-container .custom-select,
.discussion-settings-container input {
max-width: 100%; }

View File

@ -16389,12 +16389,9 @@ select {
color: #373a3c;
font-weight: bold; }
.discussion-settings-trigger .icon {
height: 32px;
font-size: 32px;
width: auto; }
.discussion-settings-container .custom-select {
width: 100%; }
.discussion-settings-container .custom-select,
.discussion-settings-container input {
max-width: 100%; }