feat: custom js untuk mendisable button saat di klik,konfirmasi sweetalert saat penghapusan dan me-reset kata sandi dan format rupaih
This commit is contained in:
parent
9c28ff05ba
commit
5efe17bd1c
8
public/assets/js/forms/button-disable.js
Normal file
8
public/assets/js/forms/button-disable.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
$(document).ready(function () {
|
||||||
|
$(".button-disable").click(function () {
|
||||||
|
$(this).prop('disabled', true);
|
||||||
|
$(this).text('Proses...');
|
||||||
|
$(this).closest('form').submit();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
});
|
||||||
24
public/assets/js/forms/rupiah-format.js
Normal file
24
public/assets/js/forms/rupiah-format.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
$(document).ready(function () {
|
||||||
|
$(".rupiah-format").on("keyup", function (e) {
|
||||||
|
$(this).val(formatRupiah($(this).val(), "Rp"));
|
||||||
|
});
|
||||||
|
|
||||||
|
function formatRupiah(number, prefix) {
|
||||||
|
var numberString = number.replace(/[^,\d]/g, "").toString(),
|
||||||
|
split = numberString.split(","),
|
||||||
|
remainder = split[0].length % 3,
|
||||||
|
rupiah = split[0].substr(0, remainder),
|
||||||
|
thousands = split[0].substr(remainder).match(/\d{3}/gi);
|
||||||
|
|
||||||
|
if (thousands) {
|
||||||
|
separator = remainder ? "." : "";
|
||||||
|
rupiah += separator + thousands.join(".");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (split[1] != undefined) {
|
||||||
|
rupiah = rupiah + "," + split[1].substr(0, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return prefix == undefined ? rupiah : rupiah ? prefix + rupiah : "";
|
||||||
|
}
|
||||||
|
});
|
||||||
37
public/assets/js/interactions/confirmation.js
Normal file
37
public/assets/js/interactions/confirmation.js
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
$(document).ready(function () {
|
||||||
|
$(document).on("click", ".delete-data", function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
const form = $(this).closest("form");
|
||||||
|
|
||||||
|
Swal.fire({
|
||||||
|
title: 'Apakah Anda yakin?',
|
||||||
|
text: "Anda tidak akan dapat mengembalikannya!",
|
||||||
|
icon: 'warning',
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonText: 'Ya, hapus!',
|
||||||
|
cancelButtonText: 'Batal'
|
||||||
|
}).then(function (result) {
|
||||||
|
if (result.isConfirmed) {
|
||||||
|
form[0].submit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on("click", ".reset-password", function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
const url = $(this).attr('href');
|
||||||
|
|
||||||
|
Swal.fire({
|
||||||
|
title: 'Permohonan Reset Kata Sandi',
|
||||||
|
text: "Apakah Anda yakin ingin mereset kata sandi? Kata sandi baru akan diatur menjadi 'Minimal8'",
|
||||||
|
icon: 'warning',
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonText: 'Ya, reset kata sandi',
|
||||||
|
cancelButtonText: 'Batal'
|
||||||
|
}).then(function (result) {
|
||||||
|
if (result.isConfirmed) {
|
||||||
|
window.location.href = url;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue
Block a user