1 |
efrain |
1 |
{"version":3,"file":"summary_modal.min.js","sources":["../src/summary_modal.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 <http://www.gnu.org/licenses/>.\n\n/**\n * A javascript module to handle summary modal.\n *\n * @module core_calendar/summary_modal\n * @copyright 2017 Simey Lameze <simey@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\nimport * as CustomEvents from 'core/custom_interaction_events';\nimport Modal from 'core/modal';\nimport CalendarEvents from './events';\nimport * as CalendarCrud from 'core_calendar/crud';\nimport * as ModalEvents from 'core/modal_events';\n\nconst SELECTORS = {\n ROOT: \"[data-region='summary-modal-container']\",\n EDIT_BUTTON: '[data-action=\"edit\"]',\n DELETE_BUTTON: '[data-action=\"delete\"]',\n};\n\nexport default class ModalEventSummary extends Modal {\n static TEMPLATE = 'core_calendar/event_summary_modal';\n static TYPE = 'core_calendar-event_summary';\n\n /**\n * Get the edit button element from the footer. The button is cached\n * as it's not expected to change.\n *\n * @method getEditButton\n * @return {object} button element\n */\n getEditButton() {\n if (typeof this.editButton == 'undefined') {\n this.editButton = this.getFooter().find(SELECTORS.EDIT_BUTTON);\n }\n\n return this.editButton;\n }\n\n /**\n * Get the delete button element from the footer. The button is cached\n * as it's not expected to change.\n *\n * @method getDeleteButton\n * @return {object} button element\n */\n getDeleteButton() {\n if (typeof this.deleteButton == 'undefined') {\n this.deleteButton = this.getFooter().find(SELECTORS.DELETE_BUTTON);\n }\n\n return this.deleteButton;\n }\n\n /**\n * Get the id for the event being shown in this modal. This value is\n * not cached because it will change depending on which event is\n * being displayed.\n *\n * @method getEventId\n * @return {int}\n */\n getEventId() {\n return this.getBody().find(SELECTORS.ROOT).attr('data-event-id');\n }\n\n /**\n * Get the title for the event being shown in this modal. This value is\n * not cached because it will change depending on which event is\n * being displayed.\n *\n * @method getEventTitle\n * @return {String}\n */\n getEventTitle() {\n return this.getBody().find(SELECTORS.ROOT).attr('data-event-title');\n }\n\n /**\n * Get the number of events in the series for the event being shown in\n * this modal. This value is not cached because it will change\n * depending on which event is being displayed.\n *\n * @method getEventCount\n * @return {int}\n */\n getEventCount() {\n return this.getBody().find(SELECTORS.ROOT).attr('data-event-count');\n }\n\n /**\n * Get the url for the event being shown in this modal.\n *\n * @method getEventUrl\n * @return {String}\n */\n getEditUrl() {\n return this.getBody().find(SELECTORS.ROOT).attr('data-edit-url');\n }\n\n /**\n * Is this an action event.\n *\n * @method getEventUrl\n * @return {String}\n */\n isActionEvent() {\n return (this.getBody().find(SELECTORS.ROOT).attr('data-action-event') == 'true');\n }\n\n /**\n * Set up all of the event handling for the modal.\n *\n * @method registerEventListeners\n */\n registerEventListeners() {\n // Apply parent event listeners.\n super.registerEventListeners(this);\n\n // We have to wait for the modal to finish rendering in order to ensure that\n // the data-event-title property is available to use as the modal title.\n M.util.js_pending('core_calendar/summary_modal:registerEventListeners:bodyRendered');\n this.getRoot().on(ModalEvents.bodyRendered, function() {\n this.getModal().data({\n eventTitle: this.getEventTitle(),\n eventId: this.getEventId(),\n eventCount: this.getEventCount(),\n })\n .attr('data-type', 'event');\n CalendarCrud.registerRemove(this.getModal());\n M.util.js_complete('core_calendar/summary_modal:registerEventListeners:bodyRendered');\n }.bind(this));\n\n $('body').on(CalendarEvents.deleted, function() {\n // Close the dialogue on delete.\n this.hide();\n }.bind(this));\n\n CustomEvents.define(this.getEditButton(), [\n CustomEvents.events.activate\n ]);\n\n this.getEditButton().on(CustomEvents.events.activate, function(e, data) {\n if (this.isActionEvent()) {\n // Action events cannot be edited on the event form and must be redirected to the module UI.\n $('body').trigger(CalendarEvents.editActionEvent, [this.getEditUrl()]);\n } else {\n // When the edit button is clicked we fire an event for the calendar UI to handle.\n // We don't care how the UI chooses to handle it.\n $('body').trigger(CalendarEvents.editEvent, [this.getEventId()]);\n }\n\n // There is nothing else for us to do so let's hide.\n this.hide();\n\n // We've handled this event so no need to propagate it.\n e.preventDefault();\n e.stopPropagation();\n data.originalEvent.preventDefault();\n data.originalEvent.stopPropagation();\n }.bind(this));\n }\n}\n\nModalEventSummary.registerModalType();\n"],"names":["SELECTORS","ModalEventSummary","Modal","getEditButton","this","editButton","getFooter","find","getDeleteButton","deleteButton","getEventId","getBody","attr","getEventTitle","getEventCount","getEditUrl","isActionEvent","registerEventListeners","M","util","js_pending","getRoot","on","ModalEvents","bodyRendered","getModal","data","eventTitle","eventId","eventCount","CalendarCrud","registerRemove","js_complete","bind","CalendarEvents","deleted","hide","CustomEvents","define","events","activate","e","trigger","editActionEvent","editEvent","preventDefault","stopPropagation","originalEvent","registerModalType"],"mappings":"6vDA8BMA,eACI,0CADJA,sBAEW,uBAFXA,wBAGa,+BAGEC,0BAA0BC,eAW3CC,4BACkC,IAAnBC,KAAKC,kBACPA,WAAaD,KAAKE,YAAYC,KAAKP,wBAGrCI,KAAKC,WAUhBG,8BACoC,IAArBJ,KAAKK,oBACPA,aAAeL,KAAKE,YAAYC,KAAKP,0BAGvCI,KAAKK,aAWhBC,oBACWN,KAAKO,UAAUJ,KAAKP,gBAAgBY,KAAK,iBAWpDC,uBACWT,KAAKO,UAAUJ,KAAKP,gBAAgBY,KAAK,oBAWpDE,uBACWV,KAAKO,UAAUJ,KAAKP,gBAAgBY,KAAK,oBASpDG,oBACWX,KAAKO,UAAUJ,KAAKP,gBAAgBY,KAAK,iBASpDI,sBAC6E,QAAjEZ,KAAKO,UAAUJ,KAAKP,gBAAgBY,KAAK,qBAQrDK,+BAEUA,uBAAuBb,MAI7Bc,EAAEC,KAAKC,WAAW,wEACbC,UAA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