{"version":3,"sources":["https:\/\/vlm2.ub.ac.id\/mod\/forum\/amd\/src\/subscription_toggle.js"],"names":["define","$","Templates","Notification","Repository","Selectors","PubSub","ForumEvents","init","registerEventListeners","root","preventDefault","callback","on","subscription","toggle","e","toggleElement","forumId","data","discussionId","subscriptionState","setDiscussionSubscriptionState","then","context","publish","SUBSCRIPTION_TOGGLED","catch","exception"],"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,CAgCF,MAAO,CACHC,IAAI,CAxBqB,QAAzBC,CAAAA,sBAAyB,CAASC,CAAT,CAAeC,CAAf,CAA+BC,CAA\/B,CAAyC,CAClEF,CAAI,CAACG,EAAL,CAAQ,OAAR,CAAiBR,CAAS,CAACS,YAAV,CAAuBC,MAAxC,CAAgD,SAASC,CAAT,CAAY,IACpDC,CAAAA,CAAa,CAAGhB,CAAC,CAAC,IAAD,CADmC,CAEpDiB,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,CAMxDf,CAAU,CAACkB,8BAAX,CAA0CJ,CAA1C,CAAmDE,CAAnD,CAAiEC,CAAjE,EACKE,IADL,CACU,SAASC,CAAT,CAAkB,CACpBlB,CAAM,CAACmB,OAAP,CAAelB,CAAW,CAACmB,oBAA3B,CAAiD,CAC7CN,YAAY,CAAEA,CAD+B,CAE7CC,iBAAiB,CAAEA,CAF0B,CAAjD,EAIA,MAAOT,CAAAA,CAAQ,CAACK,CAAD,CAAgBO,CAAhB,CAClB,CAPL,EAQKG,KARL,CAQWxB,CAAY,CAACyB,SARxB,EAUA,GAAIjB,CAAJ,CAAoB,CAChBK,CAAC,CAACL,cAAF,EACH,CACJ,CAnBD,CAoBH,CAEM,CAGV,CAnDK,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 * @param {boolean} preventDefault Should the default action of the event be prevented\n * @param {function} callback Success callback\n *\/\n var registerEventListeners = function(root, preventDefault, callback) {\n root.on('click', Selectors.subscription.toggle, function(e) {\n var toggleElement = $(this);\n var forumId = toggleElement.data('forumid');\n var discussionId = toggleElement.data('discussionid');\n var subscriptionState = toggleElement.data('targetstate');\n\n Repository.setDiscussionSubscriptionState(forumId, discussionId, subscriptionState)\n .then(function(context) {\n PubSub.publish(ForumEvents.SUBSCRIPTION_TOGGLED, {\n discussionId: discussionId,\n subscriptionState: subscriptionState\n });\n return callback(toggleElement, context);\n })\n .catch(Notification.exception);\n\n if (preventDefault) {\n e.preventDefault();\n }\n });\n };\n\n return {\n init: registerEventListeners\n };\n});\n"],"file":"subscription_toggle.min.js"}