Browse Source

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

tags/3.0.0^2
Teknikode 10 months ago
parent
commit
21b74411b3

+ 1
- 0
Teknik/Scripts/.eslintrc View File

@@ -24,6 +24,7 @@
"Uint8Array": false,

// Common.js Functions
"deleteConfirm": false,
"disableButton": false,
"enableButton": false,
"removeAmp": false,

+ 1
- 1
Teknik/Scripts/Admin/UploadSearch.js 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');

+ 1
- 1
Teknik/Scripts/Admin/UserInfo.js 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",

+ 2
- 2
Teknik/Scripts/Blog/Blog.js 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",

+ 1
- 1
Teknik/Scripts/Paste/ViewPaste.js 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",

+ 1
- 1
Teknik/Scripts/User/AccountSettings.js 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",

+ 33
- 20
Teknik/Scripts/User/DeveloperSettings.js 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');
}
}
});
}

+ 2
- 0
Teknik/Scripts/User/SecuritySettings.js 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: {

+ 1
- 1
Teknik/Scripts/User/ViewServiceData.js 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",

+ 1
- 1
Teknik/Scripts/Vault/Vault.js 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",

+ 18
- 1
Teknik/Scripts/common.js 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);

+ 1
- 13
Teknik/bundleconfig.json 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"
]
},

Loading…
Cancel
Save