{"version":3,"sources":["https:\/\/vlm2.ub.ac.id\/mod\/forum\/amd\/src\/pin_toggle.js"],"names":["define","$","Ajax","Str","Templates","Notification","Repository","Selectors","String","init","registerEventListeners","root","preventDefault","callback","on","pin","toggle","e","toggleElement","forumid","data","discussionid","pinstate","setPinDiscussionState","then","context","get_string","done","s","addNotification","message","type","fail","exception"],"mappings":"AA2BAA,OAAM,wBAAC,CACH,QADG,CAEH,WAFG,CAGH,UAHG,CAIH,gBAJG,CAKH,mBALG,CAMH,sBANG,CAOH,qBAPG,CAQH,UARG,CAAD,CASH,SACCC,CADD,CAECC,CAFD,CAGCC,CAHD,CAICC,CAJD,CAKCC,CALD,CAMCC,CAND,CAOCC,CAPD,CAQCC,CARD,CASD,CAoCE,MAAO,CACHC,IAAI,CA5BqB,QAAzBC,CAAAA,sBAAyB,CAASC,CAAT,CAAeC,CAAf,CAA+BC,CAA\/B,CAAyC,CAClEF,CAAI,CAACG,EAAL,CAAQ,OAAR,CAAiBP,CAAS,CAACQ,GAAV,CAAcC,MAA\/B,CAAuC,SAASC,CAAT,CAAY,IAC3CC,CAAAA,CAAa,CAAGjB,CAAC,CAAC,IAAD,CAD0B,CAE3CkB,CAAO,CAAGD,CAAa,CAACE,IAAd,CAAmB,SAAnB,CAFiC,CAG3CC,CAAY,CAAGH,CAAa,CAACE,IAAd,CAAmB,cAAnB,CAH4B,CAI3CE,CAAQ,CAAGJ,CAAa,CAACE,IAAd,CAAmB,aAAnB,CAJgC,CAK\/Cd,CAAU,CAACiB,qBAAX,CAAiCJ,CAAjC,CAA0CE,CAA1C,CAAwDC,CAAxD,EACKE,IADL,CACU,SAASC,CAAT,CAAkB,CACpB,MAAOZ,CAAAA,CAAQ,CAACK,CAAD,CAAgBO,CAAhB,CAClB,CAHL,EAIKD,IAJL,CAIU,UAAW,CACb,MAAOhB,CAAAA,CAAM,CAACkB,UAAP,CAAkB,YAAlB,CAAgC,OAAhC,EACFC,IADE,CACG,SAASC,CAAT,CAAY,CACd,MAAOvB,CAAAA,CAAY,CAACwB,eAAb,CAA6B,CAChCC,OAAO,CAAEF,CADuB,CAEhCG,IAAI,CAAE,MAF0B,CAA7B,CAIV,CANE,CAOV,CAZL,EAaKC,IAbL,CAaU3B,CAAY,CAAC4B,SAbvB,EAeA,GAAIrB,CAAJ,CAAoB,CAChBK,CAAC,CAACL,cAAF,EACH,CACJ,CAvBD,CAwBH,CAEM,CAGV,CAzDK,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 * This module is the highest level module for the calendar. It is\n * responsible for initialising all of the components required for\n * the calendar to run. It also coordinates the interaction between\n * components by listening for and responding to different events\n * triggered within the calendar UI.\n *\n * @module mod_forum\/pin_toggle\n * @package mod_forum\n * @copyright 2018 Andrew Nicols \n * @license http:\/\/www.gnu.org\/copyleft\/gpl.html GNU GPL v3 or later\n *\/\ndefine([\n 'jquery',\n 'core\/ajax',\n 'core\/str',\n 'core\/templates',\n 'core\/notification',\n 'mod_forum\/repository',\n 'mod_forum\/selectors',\n 'core\/str',\n], function(\n $,\n Ajax,\n Str,\n Templates,\n Notification,\n Repository,\n Selectors,\n String\n) {\n\n \/**\n * Registery event listeners for the pin toggle.\n *\n * @param {object} root The calendar 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.pin.toggle, function(e) {\n var toggleElement = $(this);\n var forumid = toggleElement.data('forumid');\n var discussionid = toggleElement.data('discussionid');\n var pinstate = toggleElement.data('targetstate');\n Repository.setPinDiscussionState(forumid, discussionid, pinstate)\n .then(function(context) {\n return callback(toggleElement, context);\n })\n .then(function() {\n return String.get_string(\"pinupdated\", \"forum\")\n .done(function(s) {\n return Notification.addNotification({\n message: s,\n type: \"info\"\n });\n });\n })\n .fail(Notification.exception);\n\n if (preventDefault) {\n e.preventDefault();\n }\n });\n };\n\n return {\n init: registerEventListeners\n };\n});"],"file":"pin_toggle.min.js"}