1{"version":3,"sources":["../src/calendar_view.js"],"names":["define","$","Str","Notification","CalendarSelectors","CalendarEvents","CalendarViewManager","CalendarRepository","ModalFactory","ModalEventForm","ModalEvents","CalendarCrud","registerEventListeners","root","type","body","registerRemove","reloadFunction","charAt","toUpperCase","slice","on","created","deleted","updated","courseSelector","selectElement","courseId","val","then","find","window","history","pushState","fail","exception","filterChanged","e","data","daysWithEvent","eventType","hidden","addClass","removeClass","eventFormPromise","registerEventFormModal","registerEditListeners","init"],"mappings":"AAsBAA,OAAM,+BAAC,CACC,QADD,CAEC,UAFD,CAGC,mBAHD,CAIC,yBAJD,CAKC,sBALD,CAMC,4BAND,CAOC,0BAPD,CAQC,oBARD,CASC,gCATD,CAUC,mBAVD,CAWC,oBAXD,CAAD,CAaF,SACIC,CADJ,CAEIC,CAFJ,CAGIC,CAHJ,CAIIC,CAJJ,CAKIC,CALJ,CAMIC,CANJ,CAOIC,CAPJ,CAQIC,CARJ,CASIC,CATJ,CAUIC,CAVJ,CAWIC,CAXJ,CAYE,CAEE,GAAIC,CAAAA,CAAsB,CAAG,SAASC,CAAT,CAAeC,CAAf,CAAqB,CAC9C,GAAIC,CAAAA,CAAI,CAAGd,CAAC,CAAC,MAAD,CAAZ,CAEAU,CAAY,CAACK,cAAb,CAA4BH,CAA5B,EAEA,GAAII,CAAAA,CAAc,CAAG,gBAAkBH,CAAI,CAACI,MAAL,CAAY,CAAZ,EAAeC,WAAf,EAAlB,CAAiDL,CAAI,CAACM,KAAL,CAAW,CAAX,CAAtE,CAEAL,CAAI,CAACM,EAAL,CAAQhB,CAAc,CAACiB,OAAvB,CAAgC,UAAW,CACvChB,CAAmB,CAACW,CAAD,CAAnB,CAAoCJ,CAApC,CACH,CAFD,EAGAE,CAAI,CAACM,EAAL,CAAQhB,CAAc,CAACkB,OAAvB,CAAgC,UAAW,CACvCjB,CAAmB,CAACW,CAAD,CAAnB,CAAoCJ,CAApC,CACH,CAFD,EAGAE,CAAI,CAACM,EAAL,CAAQhB,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E,cAASlC,CAAT,CAAeC,CAAf,CAAqB,CACvBD,CAAI,CAAGZ,CAAC,CAACY,CAAD,CAAR,CAEAP,CAAmB,CAACyC,IAApB,CAAyBlC,CAAzB,CAA+BC,CAA/B,EACAF,CAAsB,CAACC,CAAD,CAAOC,CAAP,CACzB,CANE,CAQV,CAjFC,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 * This module is responsible for handle calendar day and upcoming view.\n *\n * @module     core_calendar/calendar\n * @copyright  2017 Simey Lameze <simey@moodle.com>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n        'jquery',\n        'core/str',\n        'core/notification',\n        'core_calendar/selectors',\n        'core_calendar/events',\n        'core_calendar/view_manager',\n        'core_calendar/repository',\n        'core/modal_factory',\n        'core_calendar/modal_event_form',\n        'core/modal_events',\n        'core_calendar/crud'\n    ],\n    function(\n        $,\n        Str,\n        Notification,\n        CalendarSelectors,\n        CalendarEvents,\n        CalendarViewManager,\n        CalendarRepository,\n        ModalFactory,\n        ModalEventForm,\n        ModalEvents,\n        CalendarCrud\n    ) {\n\n        var registerEventListeners = function(root, type) {\n            var body = $('body');\n\n            CalendarCrud.registerRemove(root);\n\n            var reloadFunction = 'reloadCurrent' + type.charAt(0).toUpperCase() + type.slice(1);\n\n            body.on(CalendarEvents.created, function() {\n                CalendarViewManager[reloadFunction](root);\n            });\n            body.on(CalendarEvents.deleted, function() {\n                CalendarViewManager[reloadFunction](root);\n            });\n            body.on(CalendarEvents.updated, function() {\n                CalendarViewManager[reloadFunction](root);\n            });\n\n            root.on('change', CalendarSelectors.courseSelector, function() {\n                var selectElement = $(this);\n                var courseId = selectElement.val();\n                CalendarViewManager[reloadFunction](root, courseId, null)\n                    .then(function() {\n                        // We need to get the selector again because the content has changed.\n                        return root.find(CalendarSelectors.courseSelector).val(courseId);\n                    })\n                    .then(function() {\n                        window.history.pushState({}, '', '?view=upcoming&course=' + courseId);\n\n                        return;\n                    })\n                    .fail(Notification.exception);\n            });\n\n            body.on(CalendarEvents.filterChanged, function(e, data) {\n                var daysWithEvent = root.find(CalendarSelectors.eventType[data.type]);\n                if (data.hidden == true) {\n                    daysWithEvent.addClass('hidden');\n                } else {\n                    daysWithEvent.removeClass('hidden');\n                }\n            });\n\n            var eventFormPromise = CalendarCrud.registerEventFormModal(root);\n            CalendarCrud.registerEditListeners(root, eventFormPromise);\n        };\n\n        return {\n            init: function(root, type) {\n                root = $(root);\n\n                CalendarViewManager.init(root, type);\n                registerEventListeners(root, type);\n            }\n        };\n    });\n"],"file":"calendar_view.min.js"}