Disable form submit button up on submit

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2021-04-06 17:50:26 +02:00
parent 7aa24e956d
commit 0cf04c3c3c
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
11 changed files with 40 additions and 28 deletions

View File

@ -1,5 +1,8 @@
module.exports = { module.exports = {
extends: [ extends: [
'@nextcloud' '@nextcloud'
] ],
globals: {
'$': true
}
}; };

View File

@ -1,14 +0,0 @@
// var instead of let/const for better older browsers compatibility
var passwordTextField;
function togglePasswordTextFieldVisibility() {
if (passwordTextField.attr('type') == "password") {
passwordTextField.attr('type', 'text');
} else {
passwordTextField.attr('type', 'password');
}
}
$(document).ready(function() {
passwordTextField = $("#password");
$("#showadminpass").click(togglePasswordTextFieldVisibility);
});

2
js/registration-form.js Normal file
View File

@ -0,0 +1,2 @@
!function(){"use strict";document.addEventListener("DOMContentLoaded",(function(){var t=this;$("#showadminpass").click((function(){var t=$("#password");"password"===t.attr("type")?t.attr("type","text"):t.attr("type","password")})),$("form").submit((function(){$(t).find(":submit").attr("disabled","disabled")}))}))}();
//# sourceMappingURL=registration-form.js.map?v=b4e5899c354021f3c609

View File

@ -0,0 +1 @@
{"version":3,"sources":["webpack://registration/./src/form.js"],"names":["document","addEventListener","$","click","passwordTextField","attr","submit","find"],"mappings":"yBAAAA,SAASC,iBAAiB,oBAAoB,WAAW,WAExDC,EAAE,kBAAkBC,OAAM,WACzB,IAAMC,EAAoBF,EAAE,aACW,aAAnCE,EAAkBC,KAAK,QAC1BD,EAAkBC,KAAK,OAAQ,QAE/BD,EAAkBC,KAAK,OAAQ,eAKjCH,EAAE,QAAQI,QAAO,WAEhBJ,EAAE,GAAMK,KAAK,WAAWF,KAAK,WAAY,kB","file":"registration-form.js?v=b4e5899c354021f3c609","sourcesContent":["document.addEventListener('DOMContentLoaded', function() {\n\t// Password toggle\n\t$('#showadminpass').click(() => {\n\t\tconst passwordTextField = $('#password')\n\t\tif (passwordTextField.attr('type') === 'password') {\n\t\t\tpasswordTextField.attr('type', 'text')\n\t\t} else {\n\t\t\tpasswordTextField.attr('type', 'password')\n\t\t}\n\t})\n\n\t// Disable submit after first click\n\t$('form').submit(() => {\n\t\t// prevent duplicate form submissions\n\t\t$(this).find(':submit').attr('disabled', 'disabled')\n\t})\n})\n"],"sourceRoot":""}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

17
src/form.js Normal file
View File

@ -0,0 +1,17 @@
document.addEventListener('DOMContentLoaded', function() {
// Password toggle
$('#showadminpass').click(() => {
const passwordTextField = $('#password')
if (passwordTextField.attr('type') === 'password') {
passwordTextField.attr('type', 'text')
} else {
passwordTextField.attr('type', 'password')
}
})
// Disable submit after first click
$('form').submit(() => {
// prevent duplicate form submissions
$(this).find(':submit').attr('disabled', 'disabled')
})
})

View File

@ -2,6 +2,7 @@
/** @var array $_ */ /** @var array $_ */
/** @var \OCP\IL10N $l */ /** @var \OCP\IL10N $l */
style('registration', 'style'); style('registration', 'style');
script('registration', 'registration-form');
?> ?>
<form action="" method="post"> <form action="" method="post">
<fieldset> <fieldset>

View File

@ -2,7 +2,7 @@
/** @var array $_ */ /** @var array $_ */
/** @var \OCP\IL10N $l */ /** @var \OCP\IL10N $l */
style('registration', 'style'); style('registration', 'style');
script('registration', 'form'); script('registration', 'registration-form');
?><form action="" method="post"> ?><form action="" method="post">
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>" /> <input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>" />
<fieldset> <fieldset>

View File

@ -2,6 +2,7 @@
/** @var array $_ */ /** @var array $_ */
/** @var \OCP\IL10N $l */ /** @var \OCP\IL10N $l */
style('registration', 'style'); style('registration', 'style');
script('registration', 'registration-form');
?> ?>
<form action="" method="post"> <form action="" method="post">
<fieldset> <fieldset>

View File

@ -3,6 +3,7 @@ const webpackConfig = require('@nextcloud/webpack-vue-config')
webpackConfig.entry = { webpackConfig.entry = {
settings: path.join(__dirname, 'src', 'settings'), settings: path.join(__dirname, 'src', 'settings'),
form: path.join(__dirname, 'src', 'form'),
} }
module.exports = webpackConfig module.exports = webpackConfig