1
0
mirror of https://git.teknik.io/Teknikode/Teknik.git synced 2023-08-02 14:16:22 +02:00

Made deletion confirmation box a common function and moved bootbox to common bundle.

This commit is contained in:
Uncled1023 2019-01-24 21:52:24 -08:00
parent a4365b2671
commit 21b74411b3
12 changed files with 63 additions and 42 deletions

View File

@ -24,6 +24,7 @@
"Uint8Array": false,
// Common.js Functions
"deleteConfirm": false,
"disableButton": false,
"enableButton": false,
"removeAmp": false,

View File

@ -33,7 +33,7 @@ function LinkUploadDelete(selector) {
$(selector).click(function () {
var deleteUrl = $(this).attr('id');
var uploadID = $(this).data('upload-id');
bootbox.confirm("Are you sure you want to delete this upload?", function (result) {
deleteConfirm("Are you sure you want to delete this upload?", function (result) {
if (result) {
if (deleteUrl !== '') {
window.open(deleteUrl, '_blank');

View File

@ -67,7 +67,7 @@ $(function () {
});
$('#delete_account').click(function () {
bootbox.confirm("Are you sure you want to delete this account?", function (result) {
deleteConfirm("Are you sure you want to delete this account?", function (result) {
if (result) {
$.ajax({
type: "POST",

View File

@ -170,7 +170,7 @@ function linkPostDelete(selector) {
$(selector).click(function () {
var object = $(this);
var post_id = object.attr("id");
bootbox.confirm("Are you sure you want to delete your post?", function (result) {
deleteConfirm("Are you sure you want to delete your post?", function (result) {
if (result) {
$.ajax({
type: "POST",
@ -195,7 +195,7 @@ function linkCommentDelete(selector) {
$(selector).click(function () {
var object = $(this);
var post_id = object.attr("id");
bootbox.confirm("Are you sure you want to delete your comment?", function (result) {
deleteConfirm("Are you sure you want to delete your comment?", function (result) {
if (result) {
$.ajax({
type: "POST",

View File

@ -9,7 +9,7 @@ $(document).ready(function () {
$('#delete-paste').click(function () {
var id = $(this).data('paste-url');
bootbox.confirm("Are you sure you want to delete this paste?", function (result) {
deleteConfirm("Are you sure you want to delete this paste?", function (result) {
if (result) {
$.ajax({
type: "POST",

View File

@ -38,7 +38,7 @@ $(document).ready(function () {
$('#delete_account').click(function () {
disableButton('#delete_account', 'Deleting Account...');
bootbox.confirm("Are you sure you want to delete your account?", function (result) {
deleteConfirm("Are you sure you want to delete your account?", function (result) {
if (result) {
$.ajax({
type: "POST",

View File

@ -127,29 +127,42 @@ function editClientSave() {
function deleteClient(clientId) {
disableButton('.deleteClient[data-clientId="' + clientId + '"]', 'Deleting...');
bootbox.confirm("<h2>Are you sure you want to delete this client?</h2><br /><br />This is <b>irreversable</b> and all applications using these client credentials will stop working.", function (result) {
if (result) {
$.ajax({
type: "POST",
url: deleteClientURL,
data: AddAntiForgeryToken({ clientId: clientId }),
success: function (response) {
if (response.result) {
$('#client_' + clientId).remove();
if ($('#clientList li').length <= 0) {
$('#clientList').html('<li class="list-group-item text-center" id="noClients">No Clients</li>');
bootbox.confirm({
message: "<h2>Are you sure you want to delete this client?</h2><br /><br />This is <b>irreversable</b> and all applications using these client credentials will stop working.",
buttons: {
confirm: {
label: 'Delete',
className: 'btn-danger'
},
cancel: {
label: 'Cancel',
className: 'btn-default'
}
},
callback: function (result) {
if (result) {
$.ajax({
type: "POST",
url: deleteClientURL,
data: AddAntiForgeryToken({ clientId: clientId }),
success: function (response) {
if (response.result) {
$('#client_' + clientId).remove();
if ($('#clientList li').length <= 0) {
$('#clientList').html('<li class="list-group-item text-center" id="noClients">No Clients</li>');
}
}
else {
$("#top_msg").css('display', 'inline', 'important');
$("#top_msg").html('<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>' + parseErrorMessage(response) + '</div>');
}
}
else {
$("#top_msg").css('display', 'inline', 'important');
$("#top_msg").html('<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>' + parseErrorMessage(response) + '</div>');
}
}
}).always(function () {
}).always(function () {
enableButton('.deleteClient[data-clientId="' + clientId + '"]', 'Delete');
});
} else {
enableButton('.deleteClient[data-clientId="' + clientId + '"]', 'Delete');
});
} else {
enableButton('.deleteClient[data-clientId="' + clientId + '"]', 'Delete');
}
}
});
}

View File

@ -24,6 +24,7 @@ $(document).ready(function () {
$('#disable_2fa_button').click(function () {
bootbox.confirm({
size: "small",
message: "Are you sure you want to disable Two-Factor Authentication? This will also invalidate all current recovery codes.",
buttons: {
confirm: {
@ -89,6 +90,7 @@ $(document).ready(function () {
$('#resetRecoveryCodes').click(function () {
bootbox.confirm({
size: "small",
message: "Are you sure you want to reset your recovery codes? This will invalidate all current recovery codes.",
buttons: {
confirm: {

View File

@ -37,7 +37,7 @@ $(document).ready(function () {
});
function deleteItem(url, id, element, confirmationMsg) {
bootbox.confirm(confirmationMsg, function (result) {
deleteConfirm(confirmationMsg, function (result) {
if (result) {
$.ajax({
type: "POST",

View File

@ -192,7 +192,7 @@ $(document).ready(function () {
$('.delete-vault-button').click(function () {
var vaultUrl = $(this).data('vault-url');
bootbox.confirm("Are you sure you want to delete this vault?", function (result) {
deleteConfirm("Are you sure you want to delete this vault?", function (result) {
if (result) {
$.ajax({
type: "POST",

View File

@ -1,4 +1,4 @@
/* exported disableButton, enableButton, removeAmp, clearInputs, randomString, getFileExtension, SelectAll, getAnchor, GenerateBlobURL, AddAntiForgeryToken,
/* exported deleteConfirm, disableButton, enableButton, removeAmp, clearInputs, randomString, getFileExtension, SelectAll, getAnchor, GenerateBlobURL, AddAntiForgeryToken,
copyTextToClipboard, getReadableBandwidthString, getReadableFileSizeString, moveUp, moveDown, addParamsToUrl, sleep, parseErrorMessage, isValidURL,
pageloadTimerCount, pageloadDoTimer, pageloadStopTimer */
$(document).ready(function () {
@ -111,6 +111,23 @@ $(function () {
};
});
function deleteConfirm(message, callback) {
bootbox.confirm({
message: "<h3>" + message + "</h3>",
buttons: {
confirm: {
label: 'Delete',
className: 'btn-danger'
},
cancel: {
label: 'Cancel',
className: 'btn-default'
}
},
callback: callback
});
}
function disableButton(btn, text) {
$(btn).addClass('disabled');
$(btn).text(text);

View File

@ -2,21 +2,18 @@
{
"outputFileName": "./wwwroot/js/admin.min.js",
"inputFiles": [
"./wwwroot/lib/bootbox/js/bootbox.js",
"./wwwroot/js/app/Admin/Admin.js"
]
},
{
"outputFileName": "./wwwroot/js/uploadSearch.min.js",
"inputFiles": [
"./wwwroot/lib/bootbox/js/bootbox.js",
"./wwwroot/js/App/Admin/UploadSearch.js"
]
},
{
"outputFileName": "./wwwroot/js/userInfo.min.js",
"inputFiles": [
"./wwwroot/lib/bootbox/js/bootbox.js",
"./wwwroot/js/app/Admin/UserInfo.js"
]
},
@ -29,7 +26,6 @@
{
"outputFileName": "./wwwroot/js/blog.min.js",
"inputFiles": [
"./wwwroot/lib/bootbox/js/bootbox.js",
"./wwwroot/lib/marked/js/marked.js",
"./wwwroot/lib/sanitize-html/js/sanitize-html.js",
"./wwwroot/js/app/Blog/Blog.js"
@ -50,7 +46,6 @@
{
"outputFileName": "./wwwroot/js/error.min.js",
"inputFiles": [
"./wwwroot/lib/bootbox/js/bootbox.js",
"./wwwroot/js/app/Error/Error.js"
]
},
@ -99,7 +94,6 @@
{
"outputFileName": "./wwwroot/js/paste.view.min.js",
"inputFiles": [
"./wwwroot/lib/bootbox/js/bootbox.js",
"./wwwroot/js/app/lib/Prism/prism.js",
"./wwwroot/js/app/lib/Prism/prism-line-numbers.js",
"./wwwroot/js/app/lib/Prism/prism-line-highlight.js",
@ -135,7 +129,6 @@
{
"outputFileName": "./wwwroot/js/podcast.min.js",
"inputFiles": [
"./wwwroot/lib/bootbox/js/bootbox.js",
"./wwwroot/lib/jquery/js/jquery.BlockUI.js",
"./wwwroot/js/app/Podcast/Podcast.js"
]
@ -165,7 +158,6 @@
"inputFiles": [
"./wwwroot/js/app/lib/Blob.js",
"./wwwroot/lib/file-saver/js/FileSaver.js",
"./wwwroot/lib/bootbox/js/bootbox.js",
"./wwwroot/js/app/Upload/Download.js"
]
},
@ -194,7 +186,6 @@
"inputFiles": [
"./wwwroot/lib/dropzone/js/dropzone.js",
"./wwwroot/lib/bootstrap/js/bootstrap-switch.js",
"./wwwroot/lib/bootbox/js/bootbox.js",
"./wwwroot/js/app/Upload/Upload.js"
]
},
@ -214,14 +205,12 @@
{
"outputFileName": "./wwwroot/js/user.profile.min.js",
"inputFiles": [
"./wwwroot/lib/bootbox/js/bootbox.js",
"./wwwroot/js/app/User/Profile.js"
]
},
{
"outputFileName": "./wwwroot/js/user.serviceData.min.js",
"inputFiles": [
"./wwwroot/lib/bootbox/js/bootbox.js",
"./wwwroot/js/app/User/ViewServiceData.js"
]
},
@ -234,7 +223,6 @@
{
"outputFileName": "./wwwroot/js/user.settings.min.js",
"inputFiles": [
"./wwwroot/lib/bootbox/js/bootbox.js",
"./wwwroot/js/app/User/Settings.js"
]
},
@ -290,7 +278,6 @@
{
"outputFileName": "./wwwroot/js/vault.min.js",
"inputFiles": [
"./wwwroot/lib/bootbox/js/bootbox.js",
"./wwwroot/lib/jquery/js/jquery.BlockUI.js",
"./wwwroot/lib/marked/js/marked.js",
"./wwwroot/lib/sanitize-html/js/sanitize-html.js",
@ -317,6 +304,7 @@
"./wwwroot/lib/bootstrap/js/bootstrap.js",
"./wwwroot/lib/bootstrap/js/bootstrap-select.js",
"./wwwroot/lib/underscore/js/underscore.js",
"./wwwroot/lib/bootbox/js/bootbox.js",
"./wwwroot/js/app/common.js"
]
},