Proyectos de Subversion Moodle

Rev

Autoría | Ultima modificación | Ver Log |

{"version":3,"file":"effective_retention_period.min.js","sources":["../src/effective_retention_period.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 * Module to update the displayed retention period.\n *\n * @module     tool_dataprivacy/effective_retention_period\n * @copyright  2018 David Monllao\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery'],\n    function($) {\n\n        var SELECTORS = {\n            PURPOSE_SELECT: '#id_purposeid',\n            RETENTION_FIELD: '#fitem_id_retention_current [data-fieldtype=static]',\n        };\n\n        /**\n         * Constructor for the retention period display.\n         *\n         * @param {Array} purposeRetentionPeriods Associative array of purposeids with effective retention period at this context\n         */\n        var EffectiveRetentionPeriod = function(purposeRetentionPeriods) {\n            this.purposeRetentionPeriods = purposeRetentionPeriods;\n            this.registerEventListeners();\n        };\n\n        /**\n         * Removes the current 'change' listeners.\n         *\n         * Useful when a new form is loaded.\n         */\n        var removeListeners = function() {\n            $(SELECTORS.PURPOSE_SELECT).off('change');\n        };\n\n        /**\n         * @var {Array} purposeRetentionPeriods\n         * @private\n         */\n        EffectiveRetentionPeriod.prototype.purposeRetentionPeriods = [];\n\n        /**\n         * Add purpose change listeners.\n         *\n         * @method registerEventListeners\n         */\n        EffectiveRetentionPeriod.prototype.registerEventListeners = function() {\n\n            $(SELECTORS.PURPOSE_SELECT).on('change', function(ev) {\n                var selected = $(ev.currentTarget).val();\n                var selectedPurpose = this.purposeRetentionPeriods[selected];\n                $(SELECTORS.RETENTION_FIELD).text(selectedPurpose);\n            }.bind(this));\n        };\n\n        return /** @alias module:tool_dataprivacy/effective_retention_period */ {\n            init: function(purposeRetentionPeriods) {\n                // Remove previously attached listeners.\n                removeListeners();\n                return new EffectiveRetentionPeriod(purposeRetentionPeriods);\n            }\n        };\n    }\n);\n\n"],"names":["define","$","SELECTORS","EffectiveRetentionPeriod","purposeRetentionPeriods","registerEventListeners","prototype","on","ev","selected","currentTarget","val","selectedPurpose","this","text","bind","init","off"],"mappings":";;;;;;;AAsBAA,qDAAO,CAAC,WACJ,SAASC,OAEDC,yBACgB,gBADhBA,0BAEiB,sDAQjBC,yBAA2B,SAASC,8BAC/BA,wBAA0BA,6BAC1BC,iCAgBTF,yBAAyBG,UAAUF,wBAA0B,GAO7DD,yBAAyBG,UAAUD,uBAAyB,WAExDJ,EAAEC,0BAA0BK,GAAG,SAAU,SAASC,QAC1CC,SAAWR,EAAEO,GAAGE,eAAeC,MAC/BC,gBAAkBC,KAAKT,wBAAwBK,UACnDR,EAAEC,2BAA2BY,KAAKF,kBACpCG,KAAKF,QAG6D,CACpEG,KAAM,SAASZ,gCAxBfH,EAAEC,0BAA0Be,IAAI,UA2BrB,IAAId,yBAAyBC"}