{"version":3,"file":"schedule.min.js","sources":["https:\/\/learn.greencultured.co\/local\/learningtools\/ltool\/schedule\/amd\/src\/schedule.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 .\n\n\/**\n * Schedule ltool define js.\n * @module ltool_schedule\n * @copyright 2021, bdecent gmbh bdecent.de\n * @license http:\/\/www.gnu.org\/copyleft\/gpl.html GNU GPL v3 or later\n *\/\n\n define(['jquery', 'core\/fragment', 'core\/modal_factory', 'core\/str', 'core\/modal_events', 'core\/notification'],\n function($, Fragment, ModalFactory, String, ModalEvents, Notification) {\n\n \/* global ltools *\/\n\n \/**\n * Controls Schedule tool action.\n * @param {object} params\n *\/\n var LearningToolSchedule = function(params) {\n var self = this;\n var scheduleInfo = document.querySelector(\".ltoolschedule-info #ltoolschedule-action\");\n if (scheduleInfo) {\n \/\/ Hover color.\n var schedulehovercolor = scheduleInfo.getAttribute(\"data-hovercolor\");\n var schedulefontcolor = scheduleInfo.getAttribute(\"data-fontcolor\");\n if (schedulehovercolor && schedulefontcolor) {\n scheduleInfo.addEventListener(\"mouseover\", function() {\n document.querySelector('#ltoolschedule-info p').style.background = schedulehovercolor;\n document.querySelector('#ltoolschedule-info p').style.color = schedulefontcolor;\n });\n }\n scheduleInfo.addEventListener('click', function() {\n self.displaySchedulebox(params);\n });\n }\n\n };\n\n LearningToolSchedule.prototype.displaySchedulebox = function(params) {\n var self = this;\n var strschedule = String.get_string('schedule', 'local_learningtools');\n return ModalFactory.create({\n title: strschedule,\n type: ModalFactory.types.SAVE_CANCEL,\n body: self.getScheduleAction(params),\n large: true\n }).then(function(modal) {\n modal.getRoot().on(ModalEvents.save, e => {\n \/\/ Trigger a form submission, so that any mform elements can do final tricks before the form submission\n \/\/ is processed.\n \/\/ The actual submit even tis captured in the next handler.\n e.preventDefault();\n $(e.target).find(\"button[data-action=save]\").attr(\"disabled\", true);\n modal.getRoot().find('form').submit();\n });\n\n modal.getRoot().on('submit', 'form', e => {\n e.preventDefault();\n var schedulenameinfo = document.querySelectorAll(\"#ltoolschedule-editorbox input[name='schedulename']\")[0];\n if (schedulenameinfo.value) {\n self.submitFormData(params.contextid);\n var successinfo = String.get_string('successtoolschedule', 'local_learningtools');\n $.when(successinfo).done(function(localizedEditString) {\n Notification.addNotification({\n message: localizedEditString,\n type: \"success\"\n });\n });\n if (ltools.disappertimenotify != 0) {\n setTimeout(function() {\n document.querySelector(\"span.notifications\").innerHTML = \"\";\n }, ltools.disappertimenotify);\n }\n }\n modal.hide();\n });\n\n modal.getRoot().on(ModalEvents.hidden, function() {\n modal.destroy();\n });\n modal.show();\n return modal;\n }).fail(Notification.exception);\n\n };\n\n LearningToolSchedule.prototype.submitFormData = function(contextid) {\n var modalform = document.querySelectorAll('#ltoolschedule-editorbox form')[0];\n var formData = new URLSearchParams(new FormData(modalform)).toString();\n Fragment.loadFragment('ltool_schedule', 'set_calendar_event', contextid, {'formdata': formData});\n return true;\n };\n\n LearningToolSchedule.prototype.getScheduleAction = function(params) {\n return Fragment.loadFragment('ltool_schedule', 'get_schedule_form', params.contextid, params);\n };\n\n return {\n init: function(params) {\n return new LearningToolSchedule(params);\n }\n };\n });"],"names":["define","$","Fragment","ModalFactory","String","ModalEvents","Notification","LearningToolSchedule","params","self","this","scheduleInfo","document","querySelector","schedulehovercolor","getAttribute","schedulefontcolor","addEventListener","style","background","color","displaySchedulebox","prototype","strschedule","get_string","create","title","type","types","SAVE_CANCEL","body","getScheduleAction","large","then","modal","getRoot","on","save","e","preventDefault","target","find","attr","submit","querySelectorAll","value","submitFormData","contextid","successinfo","when","done","localizedEditString","addNotification","message","ltools","disappertimenotify","setTimeout","innerHTML","hide","hidden","destroy","show","fail","exception","modalform","formData","URLSearchParams","FormData","toString","loadFragment","init"],"mappings":";;;;;;AAsBCA,iCAAO,CAAC,SAAU,gBAAiB,qBAAsB,WAAY,oBAAqB,sBAC1F,SAASC,EAAGC,SAAUC,aAAcC,OAAQC,YAAaC,kBAQlDC,qBAAuB,SAASC,YAC5BC,KAAOC,KACPC,aAAeC,SAASC,cAAc,gDACtCF,aAAc,KAEVG,mBAAqBH,aAAaI,aAAa,mBAC\/CC,kBAAoBL,aAAaI,aAAa,kBAC9CD,oBAAsBE,mBACtBL,aAAaM,iBAAiB,aAAa,WACvCL,SAASC,cAAc,yBAAyBK,MAAMC,WAAaL,mBACnEF,SAASC,cAAc,yBAAyBK,MAAME,MAAQJ,qBAGtEL,aAAaM,iBAAiB,SAAS,WACnCR,KAAKY,mBAAmBb,oBAMpCD,qBAAqBe,UAAUD,mBAAqB,SAASb,YACrDC,KAAOC,KACPa,YAAcnB,OAAOoB,WAAW,WAAY,8BACzCrB,aAAasB,OAAO,CACvBC,MAAOH,YACPI,KAAMxB,aAAayB,MAAMC,YACzBC,KAAMrB,KAAKsB,kBAAkBvB,QAC7BwB,OAAO,IACRC,MAAK,SAASC,cACbA,MAAMC,UAAUC,GAAG\/B,YAAYgC,MAAMC,IAIjCA,EAAEC,iBACFtC,EAAEqC,EAAEE,QAAQC,KAAK,4BAA4BC,KAAK,YAAY,GAC9DR,MAAMC,UAAUM,KAAK,QAAQE,YAGjCT,MAAMC,UAAUC,GAAG,SAAU,QAAQE,OACjCA,EAAEC,iBACqB3B,SAASgC,iBAAiB,uDAAuD,GACnFC,MAAO,CACxBpC,KAAKqC,eAAetC,OAAOuC,eACvBC,YAAc5C,OAAOoB,WAAW,sBAAuB,uBAC3DvB,EAAEgD,KAAKD,aAAaE,MAAK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