AutorÃa | Ultima modificación | Ver Log |
{"version":3,"file":"favourite_toggle.min.js","sources":["../src/favourite_toggle.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Handle discussion subscription toggling on a discussion list in\n * the forum view.\n *\n * @module mod_forum/favourite_toggle\n * @copyright 2019 Peter Dias <peter@moodle.com>\n * @license http://www.g
nu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/templates',\n 'core/notification',\n 'mod_forum/repository',\n 'mod_forum/selectors',\n 'core/str',\n ], function(\n $,\n Templates,\n Notification,\n Repository,\n Selectors,\n String\n ) {\n\n /**\n * Register event listeners for the subscription toggle.\n *\n * @param {object} root The discussion list root element\n * @param {boolean} preventDefault Should the default action of the event be prevented\n * @param {function} callback Success callback\n */\n var registerEventListeners = function(root, preventDefault, callback) {\n root.on('click', Selectors.favourite.toggle, function(e) {\n var toggleElement = $(this);\n var forumId = toggleElement.data('forumid');\n var discussionId = toggleElement.data('discussionid');\n var subscriptionState = toggleElement.da
ta('targetstate');\n\n Repository.setFavouriteDiscussionState(forumId, discussionId, subscriptionState)\n .then(function(context) {\n return callback(toggleElement, context);\n })\n .then(function() {\n return String.get_string(\"favouriteupdated\", \"forum\")\n .done(function(s) {\n return Notification.addNotification({\n message: s,\n type: \"info\"\n });\n });\n })\n .catch(Notification.exception);\n\n if (preventDefault) {\n e.preventDefault();\n }\n });\n };\n\n return {\n init: registerEventListeners\n };\n});\n"],"names":["define","$","Templates","Notification","Repository","Selectors","String","init","root","preventDefault","callback","on","favourite","toggle",
"e","toggleElement","this","forumId","data","discussionId","subscriptionState","setFavouriteDiscussionState","then","context","get_string","done","s","addNotification","message","type","catch","exception"],"mappings":";;;;;;;;AAuBAA,oCAAO,CACC,SACA,iBACA,oBACA,uBACA,sBACA,aACD,SACCC,EACAC,UACAC,aACAC,WACAC,UACAC,cAsCG,CACHC,KA7ByB,SAASC,KAAMC,eAAgBC,UACxDF,KAAKG,GAAG,QAASN,UAAUO,UAAUC,QAAQ,SAASC,OAC9CC,cAAgBd,EAAEe,MAClBC,QAAUF,cAAcG,KAAK,WAC7BC,aAAeJ,cAAcG,KAAK,gBAClCE,kBAAoBL,cAAcG,KAAK,eAE3Cd,WAAWiB,4BAA4BJ,QAASE,aAAcC,mBACzDE,MAAK,SAASC,gBACJb,SAASK,cAAeQ,YAElCD,MAAK,kBACKhB,OAAOkB,WAAW,mBAAoB,SACxCC,MAAK,SAASC,UACJvB,aAAawB,gBAAgB,CAChCC,QAASF,EACTG,KAAM,eAIrBC,MAAM3B,aAAa4B,WAEpBtB,gBACAK,EAAEL"}