Your IP : 192.168.165.1


Current Path : C:/xampp/htdocs/moodle/calendar/amd/build/
Upload File :
Current File : C:/xampp/htdocs/moodle/calendar/amd/build/crud.min.js.map

{"version":3,"sources":["../src/crud.js"],"names":["define","$","Str","Notification","CustomEvents","Modal","ModalRegistry","ModalFactory","ModalEvents","ModalEventForm","CalendarRepository","CalendarEvents","ModalDelete","CalendarSelectors","Pending","confirmDeletion","eventId","eventTitle","eventCount","pendingPromise","deleteStrings","key","component","parseInt","deletePromise","isRepeatedEvent","push","param","name","count","create","type","TYPE","types","SAVE_CANCEL","stringsPromise","get_strings","finalPromise","when","then","strings","deleteModal","setRemoveOnClose","setTitle","setBody","setSaveButtonText","show","getRoot","on","save","deleteEvent","trigger","deleted","resolve","catch","exception","deleteAll","modal","registerRemove","root","actions","remove","e","eventSource","closest","eventItem","data","preventDefault","registerEditListeners","eventFormModalPromise","editEvent","calendarWrapper","find","wrapper","setEventId","setContextId","stopImmediatePropagation","registerEventFormModal","eventFormPromise","large","categoryId","setCategoryId","today","firstDay","day","length","setStartTime","setCourseId","fail","edit","target","currentTarget","eventWrapper"],"mappings":"AAuBAA,OAAM,sBAAC,CACH,QADG,CAEH,UAFG,CAGH,mBAHG,CAIH,gCAJG,CAKH,YALG,CAMH,qBANG,CAOH,oBAPG,CAQH,mBARG,CASH,gCATG,CAUH,0BAVG,CAWH,sBAXG,CAYH,4BAZG,CAaH,yBAbG,CAcH,cAdG,CAAD,CAgBN,SACIC,CADJ,CAEIC,CAFJ,CAGIC,CAHJ,CAIIC,CAJJ,CAKIC,CALJ,CAMIC,CANJ,CAOIC,CAPJ,CAQIC,CARJ,CASIC,CATJ,CAUIC,CAVJ,CAWIC,CAXJ,CAYIC,CAZJ,CAaIC,CAbJ,CAcIC,CAdJ,CAeE,CAUE,QAASC,CAAAA,CAAT,CAAyBC,CAAzB,CAAkCC,CAAlC,CAA8CC,CAA9C,CAA0D,IAClDC,CAAAA,CAAc,CAAG,GAAIL,CAAAA,CAAJ,CAAY,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ACH,CAzBD,EA2BAR,CAAI,CAACX,EAAL,CAAQ,OAAR,CAAiBnC,CAAiB,CAAC+C,OAAlB,CAA0B6B,IAA3C,CAAiD,SAAS3B,CAAT,CAAY,CACzDA,CAAC,CAACK,cAAF,GACA,GAAIuB,CAAAA,CAAM,CAAGzF,CAAC,CAAC6D,CAAC,CAAC6B,aAAH,CAAd,CACIpB,CAAe,CAAGmB,CAAM,CAAC1B,OAAP,CAAenD,CAAiB,CAAC4D,OAAjC,CADtB,CAEImB,CAAY,CAAGF,CAAM,CAAC1B,OAAP,CAAenD,CAAiB,CAACoD,SAAjC,CAFnB,CAIAa,CAAgB,CAACvC,IAAjB,CAAsB,SAASkB,CAAT,CAAgB,CAGlCA,CAAK,CAACiB,UAAN,CAAiBkB,CAAY,CAAC1B,IAAb,CAAkB,SAAlB,CAAjB,EAEAT,CAAK,CAACkB,YAAN,CAAmBJ,CAAe,CAACL,IAAhB,CAAqB,WAArB,CAAnB,EACAT,CAAK,CAACX,IAAN,GAEAgB,CAAC,CAACc,wBAAF,EAEH,CAVD,EAUGY,IAVH,CAUQrF,CAAY,CAACoD,SAVrB,CAWH,CAjBD,EAoBA,MAAOuB,CAAAA,CACV,CAmDM,CAKV,CAvPK,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 * A module to handle CRUD operations within the UI.\n *\n * @module     core_calendar/crud\n * @package    core_calendar\n * @copyright  2017 Andrew Nicols <andrew@nicols.co.uk>\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/custom_interaction_events',\n    'core/modal',\n    'core/modal_registry',\n    'core/modal_factory',\n    'core/modal_events',\n    'core_calendar/modal_event_form',\n    'core_calendar/repository',\n    'core_calendar/events',\n    'core_calendar/modal_delete',\n    'core_calendar/selectors',\n    'core/pending',\n],\nfunction(\n    $,\n    Str,\n    Notification,\n    CustomEvents,\n    Modal,\n    ModalRegistry,\n    ModalFactory,\n    ModalEvents,\n    ModalEventForm,\n    CalendarRepository,\n    CalendarEvents,\n    ModalDelete,\n    CalendarSelectors,\n    Pending\n) {\n\n    /**\n     * Prepares the action for the summary modal's delete action.\n     *\n     * @param {Number} eventId The ID of the event.\n     * @param {string} eventTitle The event title.\n     * @param {Number} eventCount The number of events in the series.\n     * @return {Promise}\n     */\n    function confirmDeletion(eventId, eventTitle, eventCount) {\n        var pendingPromise = new Pending('core_calendar/crud:confirmDeletion');\n        var deleteStrings = [\n            {\n                key: 'deleteevent',\n                component: 'calendar'\n            },\n        ];\n\n        eventCount = parseInt(eventCount, 10);\n        var deletePromise;\n        var isRepeatedEvent = eventCount > 1;\n        if (isRepeatedEvent) {\n            deleteStrings.push({\n                key: 'confirmeventseriesdelete',\n                component: 'calendar',\n                param: {\n                    name: eventTitle,\n                    count: eventCount,\n                },\n            });\n\n            deletePromise = ModalFactory.create(\n                {\n                    type: ModalDelete.TYPE\n                }\n            );\n        } else {\n            deleteStrings.push({\n                key: 'confirmeventdelete',\n                component: 'calendar',\n                param: eventTitle\n            });\n\n\n            deletePromise = ModalFactory.create({\n                type: ModalFactory.types.SAVE_CANCEL,\n            });\n        }\n\n        var stringsPromise = Str.get_strings(deleteStrings);\n\n        var finalPromise = $.when(stringsPromise, deletePromise)\n        .then(function(strings, deleteModal) {\n            deleteModal.setRemoveOnClose(true);\n            deleteModal.setTitle(strings[0]);\n            deleteModal.setBody(strings[1]);\n            if (!isRepeatedEvent) {\n                deleteModal.setSaveButtonText(strings[0]);\n            }\n\n            deleteModal.show();\n\n            deleteModal.getRoot().on(ModalEvents.save, function() {\n                var pendingPromise = new Pending('calendar/crud:initModal:deletedevent');\n                CalendarRepository.deleteEvent(eventId, false)\n                    .then(function() {\n                        $('body').trigger(CalendarEvents.deleted, [eventId, false]);\n                        return;\n                    })\n                    .then(pendingPromise.resolve)\n                    .catch(Notification.exception);\n            });\n\n            deleteModal.getRoot().on(CalendarEvents.deleteAll, function() {\n                var pendingPromise = new Pending('calendar/crud:initModal:deletedallevent');\n                CalendarRepository.deleteEvent(eventId, true)\n                    .then(function() {\n                        $('body').trigger(CalendarEvents.deleted, [eventId, true]);\n                        return;\n                    })\n                    .then(pendingPromise.resolve)\n                    .catch(Notification.exception);\n            });\n\n            return deleteModal;\n        })\n        .then(function(modal) {\n            pendingPromise.resolve();\n\n            return modal;\n        })\n        .catch(Notification.exception);\n\n        return finalPromise;\n    }\n\n    /**\n     * Create the event form modal for creating new events and\n     * editing existing events.\n     *\n     * @method registerEventFormModal\n     * @param {object} root The calendar root element\n     * @return {object} The create modal promise\n     */\n    var registerEventFormModal = function(root) {\n        var eventFormPromise = ModalFactory.create({\n            type: ModalEventForm.TYPE,\n            large: true\n        });\n\n        // Bind click event on the new event button.\n        root.on('click', CalendarSelectors.actions.create, function(e) {\n            eventFormPromise.then(function(modal) {\n                var wrapper = root.find(CalendarSelectors.wrapper);\n\n                var categoryId = wrapper.data('categoryid');\n                if (typeof categoryId !== 'undefined') {\n                    modal.setCategoryId(categoryId);\n                }\n\n                // Attempt to find the cell for today.\n                // If it can't be found, then use the start time of the first day on the calendar.\n                var today = root.find(CalendarSelectors.today);\n                var firstDay = root.find(CalendarSelectors.day);\n                if (!today.length && firstDay.length) {\n                    modal.setStartTime(firstDay.data('newEventTimestamp'));\n                }\n\n                modal.setContextId(wrapper.data('contextId'));\n                modal.setCourseId(wrapper.data('courseid'));\n                modal.show();\n                return;\n            })\n            .fail(Notification.exception);\n\n            e.preventDefault();\n        });\n\n        root.on('click', CalendarSelectors.actions.edit, function(e) {\n            e.preventDefault();\n            var target = $(e.currentTarget),\n                calendarWrapper = target.closest(CalendarSelectors.wrapper),\n                eventWrapper = target.closest(CalendarSelectors.eventItem);\n\n            eventFormPromise.then(function(modal) {\n                // When something within the calendar tells us the user wants\n                // to edit an event then show the event form modal.\n                modal.setEventId(eventWrapper.data('eventId'));\n\n                modal.setContextId(calendarWrapper.data('contextId'));\n                modal.show();\n\n                e.stopImmediatePropagation();\n                return;\n            }).fail(Notification.exception);\n        });\n\n\n        return eventFormPromise;\n    };\n    /**\n     * Register the listeners required to remove the event.\n     *\n     * @param   {jQuery} root\n     */\n    function registerRemove(root) {\n        root.on('click', CalendarSelectors.actions.remove, function(e) {\n            // Fetch the event title, count, and pass them into the new dialogue.\n            var eventSource = $(this).closest(CalendarSelectors.eventItem);\n            var eventId = eventSource.data('eventId'),\n                eventTitle = eventSource.data('eventTitle'),\n                eventCount = eventSource.data('eventCount');\n            confirmDeletion(eventId, eventTitle, eventCount);\n\n            e.preventDefault();\n        });\n    }\n\n    /**\n     * Register the listeners required to edit the event.\n     *\n     * @param   {jQuery} root\n     * @param   {Promise} eventFormModalPromise\n     * @returns {Promise}\n     */\n    function registerEditListeners(root, eventFormModalPromise) {\n        var pendingPromise = new Pending('core_calendar/crud:registerEditListeners');\n\n        return eventFormModalPromise\n        .then(function(modal) {\n            // When something within the calendar tells us the user wants\n            // to edit an event then show the event form modal.\n            $('body').on(CalendarEvents.editEvent, function(e, eventId) {\n                var calendarWrapper = root.find(CalendarSelectors.wrapper);\n                modal.setEventId(eventId);\n                modal.setContextId(calendarWrapper.data('contextId'));\n                modal.show();\n\n                e.stopImmediatePropagation();\n            });\n            return modal;\n        })\n        .then(function(modal) {\n            pendingPromise.resolve();\n\n            return modal;\n        })\n        .catch(Notification.exception);\n    }\n\n    return {\n        registerRemove: registerRemove,\n        registerEditListeners: registerEditListeners,\n        registerEventFormModal: registerEventFormModal\n    };\n});\n"],"file":"crud.min.js"}