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/modal_event_form.min.js.map

{"version":3,"sources":["../src/modal_event_form.js"],"names":["define","$","Event","Str","Notification","Templates","CustomEvents","Modal","ModalRegistry","Fragment","CalendarEvents","Repository","registered","SELECTORS","SAVE_BUTTON","LOADING_ICON_CONTAINER","ModalEventForm","root","call","eventId","startTime","courseId","categoryId","contextId","reloadingBody","reloadingTitle","saveButton","getFooter","find","TYPE","prototype","Object","create","constructor","setContextId","id","getContextId","setCourseId","getCourseId","setCategoryId","getCategoryId","hasCourseId","hasCategoryId","setEventId","getEventId","hasEventId","setStartTime","time","getStartTime","hasStartTime","getForm","getBody","disableButtons","prop","enableButtons","reloadTitleContent","titlePromise","get_string","then","string","setTitle","bind","always","fail","exception","reloadBodyContent","formData","bodyPromise","args","eventid","starttime","courseid","categoryid","formdata","loadFragment","setBody","reloadAllContent","when","show","hide","getFormData","serialize","save","invalid","loadingContainer","length","first","focus","removeClass","submitCreateUpdateForm","response","validationerror","isExisting","trigger","updated","event","created","addClass","registerEventListeners","getModal","on","events","activate","e","data","submit","originalEvent","preventDefault","stopPropagation","notifyFormSubmitAjax","register"],"mappings":"AAwBAA,OAAM,kCAAC,CACK,QADL,CAEK,YAFL,CAGK,UAHL,CAIK,mBAJL,CAKK,gBALL,CAMK,gCANL,CAOK,YAPL,CAQK,qBARL,CASK,eATL,CAUK,sBAVL,CAWK,0BAXL,CAAD,CAaE,SACIC,CADJ,CAEIC,CAFJ,CAGIC,CAHJ,CAIIC,CAJJ,CAKIC,CALJ,CAMIC,CANJ,CAOIC,CAPJ,CAQIC,CARJ,CASIC,CATJ,CAUIC,CAVJ,CAWIC,CAXJ,CAYE,IAEFC,CAAAA,CAAU,GAFR,CAGFC,CAAS,CAAG,CACZC,WAAW,CAAE,wBADD,CAEZC,sBAAsB,CAAE,0CAFZ,CAHV,CAaFC,CAAc,CAAG,SAASC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A5C,EAKA,KAAKiF,QAAL,GAAgBC,EAAhB,CAAmB9F,CAAY,CAAC+F,MAAb,CAAoBC,QAAvC,CAAiDzF,CAAS,CAACC,WAA3D,CAAwE,SAASyF,CAAT,CAAYC,CAAZ,CAAkB,CACtF,KAAKtD,OAAL,GAAeuD,MAAf,GACAD,CAAI,CAACE,aAAL,CAAmBC,cAAnB,GACAJ,CAAC,CAACK,eAAF,EACH,CAJuE,CAItE/C,IAJsE,CAIjE,IAJiE,CAAxE,EAQA,KAAKsC,QAAL,GAAgBC,EAAhB,CAAmB,QAAnB,CAA6B,SAASG,CAAT,CAAY,CACrCrG,CAAK,CAAC2G,oBAAN,CAA2B,KAAK3D,OAAL,GAAe,CAAf,CAA3B,EAEA,KAAKgC,IAAL,GAIAqB,CAAC,CAACI,cAAF,GACAJ,CAAC,CAACK,eAAF,EACH,CAT4B,CAS3B/C,IAT2B,CAStB,IATsB,CAA7B,CAUH,CAzBD,CA6BA,GAAI,CAACjD,CAAL,CAAiB,CACbJ,CAAa,CAACsG,QAAd,CAAuB9F,CAAc,CAACa,IAAtC,CAA4Cb,CAA5C,CAA4D,2BAA5D,EACAJ,CAAU,GACb,CAED,MAAOI,CAAAA,CACV,CA/dK,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 * Contain the logic for the quick add or update event modal.\n *\n * @module     calendar/modal_quick_add_event\n * @class      modal_quick_add_event\n * @package    core\n * @copyright  2017 Ryan Wyllie <ryan@moodle.com>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n            'jquery',\n            'core/event',\n            'core/str',\n            'core/notification',\n            'core/templates',\n            'core/custom_interaction_events',\n            'core/modal',\n            'core/modal_registry',\n            'core/fragment',\n            'core_calendar/events',\n            'core_calendar/repository'\n        ],\n        function(\n            $,\n            Event,\n            Str,\n            Notification,\n            Templates,\n            CustomEvents,\n            Modal,\n            ModalRegistry,\n            Fragment,\n            CalendarEvents,\n            Repository\n        ) {\n\n    var registered = false;\n    var SELECTORS = {\n        SAVE_BUTTON: '[data-action=\"save\"]',\n        LOADING_ICON_CONTAINER: '[data-region=\"loading-icon-container\"]',\n    };\n\n    /**\n     * Constructor for the Modal.\n     *\n     * @param {object} root The root jQuery element for the modal\n     */\n    var ModalEventForm = function(root) {\n        Modal.call(this, root);\n        this.eventId = null;\n        this.startTime = null;\n        this.courseId = null;\n        this.categoryId = null;\n        this.contextId = null;\n        this.reloadingBody = false;\n        this.reloadingTitle = false;\n        this.saveButton = this.getFooter().find(SELECTORS.SAVE_BUTTON);\n    };\n\n    ModalEventForm.TYPE = 'core_calendar-modal_event_form';\n    ModalEventForm.prototype = Object.create(Modal.prototype);\n    ModalEventForm.prototype.constructor = ModalEventForm;\n\n    /**\n     * Set the context id to the given value.\n     *\n     * @method setContextId\n     * @param {Number} id The event id\n     */\n    ModalEventForm.prototype.setContextId = function(id) {\n        this.contextId = id;\n    };\n\n    /**\n     * Retrieve the current context id, if any.\n     *\n     * @method getContextId\n     * @return {Number|null} The event id\n     */\n    ModalEventForm.prototype.getContextId = function() {\n        return this.contextId;\n    };\n\n    /**\n     * Set the course id to the given value.\n     *\n     * @method setCourseId\n     * @param {int} id The event id\n     */\n    ModalEventForm.prototype.setCourseId = function(id) {\n        this.courseId = id;\n    };\n\n    /**\n     * Retrieve the current course id, if any.\n     *\n     * @method getCourseId\n     * @return {int|null} The event id\n     */\n    ModalEventForm.prototype.getCourseId = function() {\n        return this.courseId;\n    };\n\n    /**\n     * Set the category id to the given value.\n     *\n     * @method setCategoryId\n     * @param {int} id The event id\n     */\n    ModalEventForm.prototype.setCategoryId = function(id) {\n        this.categoryId = id;\n    };\n\n    /**\n     * Retrieve the current category id, if any.\n     *\n     * @method getCategoryId\n     * @return {int|null} The event id\n     */\n    ModalEventForm.prototype.getCategoryId = function() {\n        return this.categoryId;\n    };\n\n    /**\n     * Check if the modal has an course id.\n     *\n     * @method hasCourseId\n     * @return {bool}\n     */\n    ModalEventForm.prototype.hasCourseId = function() {\n        return this.courseId !== null;\n    };\n\n    /**\n     * Check if the modal has an category id.\n     *\n     * @method hasCategoryId\n     * @return {bool}\n     */\n    ModalEventForm.prototype.hasCategoryId = function() {\n        return this.categoryId !== null;\n    };\n\n    /**\n     * Set the event id to the given value.\n     *\n     * @method setEventId\n     * @param {int} id The event id\n     */\n    ModalEventForm.prototype.setEventId = function(id) {\n        this.eventId = id;\n    };\n\n    /**\n     * Retrieve the current event id, if any.\n     *\n     * @method getEventId\n     * @return {int|null} The event id\n     */\n    ModalEventForm.prototype.getEventId = function() {\n        return this.eventId;\n    };\n\n    /**\n     * Check if the modal has an event id.\n     *\n     * @method hasEventId\n     * @return {bool}\n     */\n    ModalEventForm.prototype.hasEventId = function() {\n        return this.eventId !== null;\n    };\n\n    /**\n     * Set the start time to the given value.\n     *\n     * @method setStartTime\n     * @param {int} time The start time\n     */\n    ModalEventForm.prototype.setStartTime = function(time) {\n        this.startTime = time;\n    };\n\n    /**\n     * Retrieve the current start time, if any.\n     *\n     * @method getStartTime\n     * @return {int|null} The start time\n     */\n    ModalEventForm.prototype.getStartTime = function() {\n        return this.startTime;\n    };\n\n    /**\n     * Check if the modal has start time.\n     *\n     * @method hasStartTime\n     * @return {bool}\n     */\n    ModalEventForm.prototype.hasStartTime = function() {\n        return this.startTime !== null;\n    };\n\n    /**\n     * Get the form element from the modal.\n     *\n     * @method getForm\n     * @return {object}\n     */\n    ModalEventForm.prototype.getForm = function() {\n        return this.getBody().find('form');\n    };\n\n    /**\n     * Disable the buttons in the footer.\n     *\n     * @method disableButtons\n     */\n    ModalEventForm.prototype.disableButtons = function() {\n        this.saveButton.prop('disabled', true);\n    };\n\n    /**\n     * Enable the buttons in the footer.\n     *\n     * @method enableButtons\n     */\n    ModalEventForm.prototype.enableButtons = function() {\n        this.saveButton.prop('disabled', false);\n    };\n\n    /**\n     * Reload the title for the modal to the appropriate value\n     * depending on whether we are creating a new event or\n     * editing an existing event.\n     *\n     * @method reloadTitleContent\n     * @return {object} A promise resolved with the new title text\n     */\n    ModalEventForm.prototype.reloadTitleContent = function() {\n        if (this.reloadingTitle) {\n            return this.titlePromise;\n        }\n\n        this.reloadingTitle = true;\n\n        if (this.hasEventId()) {\n            this.titlePromise = Str.get_string('editevent', 'calendar');\n        } else {\n            this.titlePromise = Str.get_string('newevent', 'calendar');\n        }\n\n        this.titlePromise.then(function(string) {\n            this.setTitle(string);\n            return string;\n        }.bind(this))\n        .always(function() {\n            this.reloadingTitle = false;\n            return;\n        }.bind(this))\n        .fail(Notification.exception);\n\n        return this.titlePromise;\n    };\n\n    /**\n     * Send a request to the server to get the event_form in a fragment\n     * and render the result in the body of the modal.\n     *\n     * If serialised form data is provided then it will be sent in the\n     * request to the server to have the form rendered with the data. This\n     * is used when the form had a server side error and we need the server\n     * to re-render it for us to display the error to the user.\n     *\n     * @method reloadBodyContent\n     * @param {string} formData The serialised form data\n     * @return {object} A promise resolved with the fragment html and js from\n     */\n    ModalEventForm.prototype.reloadBodyContent = function(formData) {\n        if (this.reloadingBody) {\n            return this.bodyPromise;\n        }\n\n        this.reloadingBody = true;\n        this.disableButtons();\n\n        var args = {};\n\n        if (this.hasEventId()) {\n            args.eventid = this.getEventId();\n        }\n\n        if (this.hasStartTime()) {\n            args.starttime = this.getStartTime();\n        }\n\n        if (this.hasCourseId()) {\n            args.courseid = this.getCourseId();\n        }\n\n        if (this.hasCategoryId()) {\n            args.categoryid = this.getCategoryId();\n        }\n\n        if (typeof formData !== 'undefined') {\n            args.formdata = formData;\n        }\n\n        this.bodyPromise = Fragment.loadFragment('calendar', 'event_form', this.getContextId(), args);\n\n        this.setBody(this.bodyPromise);\n\n        this.bodyPromise.then(function() {\n            this.enableButtons();\n            return;\n        }.bind(this))\n        .fail(Notification.exception)\n        .always(function() {\n            this.reloadingBody = false;\n            return;\n        }.bind(this))\n        .fail(Notification.exception);\n\n        return this.bodyPromise;\n    };\n\n    /**\n     * Reload both the title and body content.\n     *\n     * @method reloadAllContent\n     * @return {object} promise\n     */\n    ModalEventForm.prototype.reloadAllContent = function() {\n        return $.when(this.reloadTitleContent(), this.reloadBodyContent());\n    };\n\n    /**\n     * Kick off a reload the modal content before showing it. This\n     * is to allow us to re-use the same modal for creating and\n     * editing different events within the page.\n     *\n     * We do the reload when showing the modal rather than hiding it\n     * to save a request to the server if the user closes the modal\n     * and never re-opens it.\n     *\n     * @method show\n     */\n    ModalEventForm.prototype.show = function() {\n        this.reloadAllContent();\n        Modal.prototype.show.call(this);\n    };\n\n    /**\n     * Clear the event id from the modal when it's closed so\n     * that it is loaded fresh next time it's displayed.\n     *\n     * The event id will be set by the calling code if it wants\n     * to edit a specific event.\n     *\n     * @method hide\n     */\n    ModalEventForm.prototype.hide = function() {\n        Modal.prototype.hide.call(this);\n        this.setEventId(null);\n        this.setStartTime(null);\n        this.setCourseId(null);\n        this.setCategoryId(null);\n    };\n\n    /**\n     * Get the serialised form data.\n     *\n     * @method getFormData\n     * @return {string} serialised form data\n     */\n    ModalEventForm.prototype.getFormData = function() {\n        return this.getForm().serialize();\n    };\n\n    /**\n     * Send the form data to the server to create or update\n     * an event.\n     *\n     * If there is a server side validation error then we re-request the\n     * rendered form (with the data) from the server in order to get the\n     * server side errors to display.\n     *\n     * On success the modal is hidden and the page is reloaded so that the\n     * new event will display.\n     *\n     * @method save\n     * @return {object} A promise\n     */\n    ModalEventForm.prototype.save = function() {\n        var invalid,\n            loadingContainer = this.saveButton.find(SELECTORS.LOADING_ICON_CONTAINER);\n\n        // Now the change events have run, see if there are any \"invalid\" form fields.\n        invalid = this.getForm().find('[aria-invalid=\"true\"]');\n\n        // If we found invalid fields, focus on the first one and do not submit via ajax.\n        if (invalid.length) {\n            invalid.first().focus();\n            return;\n        }\n\n        loadingContainer.removeClass('hidden');\n        this.disableButtons();\n\n        var formData = this.getFormData();\n        // Send the form data to the server for processing.\n        return Repository.submitCreateUpdateForm(formData)\n            .then(function(response) {\n                if (response.validationerror) {\n                    // If there was a server side validation error then\n                    // we need to re-request the rendered form from the server\n                    // in order to display the error for the user.\n                    this.reloadBodyContent(formData);\n                    return;\n                } else {\n                    // Check whether this was a new event or not.\n                    // The hide function unsets the form data so grab this before the hide.\n                    var isExisting = this.hasEventId();\n\n                    // No problemo! Our work here is done.\n                    this.hide();\n\n                    // Trigger the appropriate calendar event so that the view can be updated.\n                    if (isExisting) {\n                        $('body').trigger(CalendarEvents.updated, [response.event]);\n                    } else {\n                        $('body').trigger(CalendarEvents.created, [response.event]);\n                    }\n                }\n\n                return;\n            }.bind(this))\n            .always(function() {\n                // Regardless of success or error we should always stop\n                // the loading icon and re-enable the buttons.\n                loadingContainer.addClass('hidden');\n                this.enableButtons();\n\n                return;\n            }.bind(this))\n            .fail(Notification.exception);\n    };\n\n    /**\n     * Set up all of the event handling for the modal.\n     *\n     * @method registerEventListeners\n     */\n    ModalEventForm.prototype.registerEventListeners = function() {\n        // Apply parent event listeners.\n        Modal.prototype.registerEventListeners.call(this);\n\n        // When the user clicks the save button we trigger the form submission. We need to\n        // trigger an actual submission because there is some JS code in the form that is\n        // listening for this event and doing some stuff (e.g. saving draft areas etc).\n        this.getModal().on(CustomEvents.events.activate, SELECTORS.SAVE_BUTTON, function(e, data) {\n            this.getForm().submit();\n            data.originalEvent.preventDefault();\n            e.stopPropagation();\n        }.bind(this));\n\n        // Catch the submit event before it is actually processed by the browser and\n        // prevent the submission. We'll take it from here.\n        this.getModal().on('submit', function(e) {\n            Event.notifyFormSubmitAjax(this.getForm()[0]);\n\n            this.save();\n\n            // Stop the form from actually submitting and prevent it's\n            // propagation because we have already handled the event.\n            e.preventDefault();\n            e.stopPropagation();\n        }.bind(this));\n    };\n\n    // Automatically register with the modal registry the first time this module is imported so that you can create modals\n    // of this type using the modal factory.\n    if (!registered) {\n        ModalRegistry.register(ModalEventForm.TYPE, ModalEventForm, 'calendar/modal_event_form');\n        registered = true;\n    }\n\n    return ModalEventForm;\n});\n"],"file":"modal_event_form.min.js"}