AutorÃa | Ultima modificación | Ver Log |
{"version":3,"file":"encryptedpassword.min.js","sources":["../src/encryptedpassword.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 * Encrypted password functionality.\n *\n * @module core_form/encryptedpassword\n * @copyright 2019 The Open University\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * Cons
tructor for EncryptedPassword.\n *\n * @class core_form/encryptedpassword\n * @param {String} elementId The element to apply the encrypted password JS to\n */\nexport const EncryptedPassword = function(elementId) {\n const wrapper = document.querySelector('div[data-encryptedpasswordid=\"' + elementId + '\"]');\n this.spanOrLink = wrapper.querySelector('span, a');\n this.input = wrapper.querySelector('input');\n this.editButtonOrLink = wrapper.querySelector('button[data-editbutton], a');\n this.cancelButton = wrapper.querySelector('button[data-cancelbutton]');\n\n // Edit button action.\n var editHandler = (e) => {\n e.stopImmediatePropagation();\n e.preventDefault();\n this.startEditing(true);\n };\n this.editButtonOrLink.addEventListener('click', editHandler);\n\n // When it's a link, do some magic to make the label work as well.\n if (this.editButtonOrLink.nodeName === 'A') {\n wrapper.parentElement.previousElementSibling.querySelector('label').a
ddEventListener('click', editHandler);\n }\n\n // Cancel button action.\n this.cancelButton.addEventListener('click', (e) => {\n e.stopImmediatePropagation();\n e.preventDefault();\n this.cancelEditing();\n });\n\n // If the value is not set yet, start editing and remove the cancel option - so that\n // it saves something in the config table and doesn't keep repeat showing it as a new\n // admin setting...\n if (wrapper.dataset.novalue === 'y') {\n this.startEditing(false);\n this.cancelButton.style.display = 'none';\n }\n};\n\n/**\n * Starts editing.\n *\n * @param {Boolean} moveFocus If true, sets focus to the edit box\n */\nEncryptedPassword.prototype.startEditing = function(moveFocus) {\n this.input.style.display = 'inline';\n this.input.disabled = false;\n this.spanOrLink.style.display = 'none';\n this.editButtonOrLink.style.display = 'none';\n this.cancelButton.style.display = 'inline';\n\n // Move the id around, which chan
ges what happens when you click the label.\n const id = this.editButtonOrLink.id;\n this.editButtonOrLink.removeAttribute('id');\n this.input.id = id;\n\n if (moveFocus) {\n this.input.focus();\n }\n};\n\n/**\n * Cancels editing.\n */\nEncryptedPassword.prototype.cancelEditing = function() {\n this.input.style.display = 'none';\n this.input.value = '';\n this.input.disabled = true;\n this.spanOrLink.style.display = 'inline';\n this.editButtonOrLink.style.display = 'inline';\n this.cancelButton.style.display = 'none';\n\n // Move the id around, which changes what happens when you click the label.\n const id = this.input.id;\n this.input.removeAttribute('id');\n this.editButtonOrLink.id = id;\n};\n"],"names":["EncryptedPassword","elementId","wrapper","document","querySelector","spanOrLink","input","editButtonOrLink","cancelButton","editHandler","e","stopImmediatePropagation","preventDefault","startEditing","addEventListener","this","nodeName","parentElement",
"previousElementSibling","cancelEditing","dataset","novalue","style","display","prototype","moveFocus","disabled","id","removeAttribute","focus","value"],"mappings":";;;;;;;;MA6BaA,kBAAoB,SAASC,iBAChCC,QAAUC,SAASC,cAAc,iCAAmCH,UAAY,WACjFI,WAAaH,QAAQE,cAAc,gBACnCE,MAAQJ,QAAQE,cAAc,cAC9BG,iBAAmBL,QAAQE,cAAc,mCACzCI,aAAeN,QAAQE,cAAc,iCAGtCK,YAAeC,IACfA,EAAEC,2BACFD,EAAEE,sBACGC,cAAa,SAEjBN,iBAAiBO,iBAAiB,QAASL,aAGT,MAAnCM,KAAKR,iBAAiBS,UACtBd,QAAQe,cAAcC,uBAAuBd,cAAc,SAASU,iBAAiB,QAASL,kBAI7FD,aAAaM,iBAAiB,SAAUJ,IACzCA,EAAEC,2BACFD,EAAEE,sBACGO,mBAMuB,MAA5BjB,QAAQkB,QAAQC,eACXR,cAAa,QACbL,aAAac,MAAMC,QAAU,sDAS1CvB,kBAAkBwB,UAAUX,aAAe,SAASY,gBAC3CnB,MAAMgB,MAAMC,QAAU,cACtBjB,MAAMoB,UAAW,OACjBrB,WAAWiB,MAAMC,QAAU,YAC3BhB,iBAAiBe,MAAMC,QAAU,YACjCf,aAAac,MAAMC,QAAU,eAG5BI,GAAKZ,KAAKR,iBAAiBoB,QAC5BpB,iBAAiBqB,gBAAgB,WACjCtB,MAAMqB,GAAKA,GAEZF,gBACKnB,MAAMuB,SAOnB7B,kBAAkBwB,UAAUL,cAAgB,gBACnCb,MAAMgB,MAAMC,QAAU,YACtBjB,MAAMwB,MAAQ,QACdxB,MAAMoB,UAAW,OACjBrB,WAAWiB,MAAMC,QAAU,cAC3BhB,iBAAiBe,MAAMC,QAAU,cACjCf,aAAac,
MAAMC,QAAU,aAG5BI,GAAKZ,KAAKT,MAAMqB,QACjBrB,MAAMsB,gBAAgB,WACtBrB,iBAAiBoB,GAAKA"}