mirror of
https://github.com/janeczku/calibre-web
synced 2025-10-26 12:57:40 +00:00
New delete user button
refactored confirm dialogs
This commit is contained in:
@@ -110,6 +110,34 @@ $(document).ready(function() {
|
||||
}
|
||||
});
|
||||
|
||||
function ConfirmDialog(id, dataValue, yesFn, noFn) {
|
||||
var pathname = document.getElementsByTagName("script"), src = pathname[pathname.length - 1].src;
|
||||
var path = src.substring(0, src.lastIndexOf("/"));
|
||||
var $confirm = $("#GeneralDeleteModal");
|
||||
// var dataValue= e.data('value'); // target.data('value');
|
||||
$confirm.modal('show');
|
||||
$.ajax({
|
||||
method:"get",
|
||||
dataType: "json",
|
||||
url: path + "/../../ajax/loaddialogtexts/" + id,
|
||||
success: function success(data) {
|
||||
$("#header").html(data.header);
|
||||
$("#text").html(data.main);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$("#btnConfirmYes").off('click').click(function () {
|
||||
yesFn(dataValue);
|
||||
$confirm.modal("hide");
|
||||
});
|
||||
$("#btnConfirmNo").off('click').click(function () {
|
||||
if (typeof noFn !== 'undefined') {
|
||||
noFn(dataValue);
|
||||
}
|
||||
$confirm.modal("hide");
|
||||
});
|
||||
}
|
||||
|
||||
$("#delete_confirm").click(function() {
|
||||
//get data-id attribute of the clicked element
|
||||
@@ -452,6 +480,52 @@ $(function() {
|
||||
$("#config_delete_kobo_token").show();
|
||||
});
|
||||
|
||||
$("#config_delete_kobo_token").click(function() {
|
||||
ConfirmDialog(
|
||||
$(this).attr('id'),
|
||||
$(this).data('value'),
|
||||
function (value) {
|
||||
var pathname = document.getElementsByTagName("script");
|
||||
var src = pathname[pathname.length - 1].src;
|
||||
var path = src.substring(0, src.lastIndexOf("/"));
|
||||
$.ajax({
|
||||
method: "get",
|
||||
url: path + "/../../kobo_auth/deleteauthtoken/" + value,
|
||||
});
|
||||
$("#config_delete_kobo_token").hide();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
$("#btndeluser").click(function() {
|
||||
ConfirmDialog(
|
||||
$(this).attr('id'),
|
||||
$(this).data('value'),
|
||||
function(value){
|
||||
var subform = $('#user_submit').closest("form");
|
||||
subform.submit(function(eventObj) {
|
||||
$(this).append('<input type="hidden" name="delete" value="True" />');
|
||||
return true;
|
||||
});
|
||||
subform.submit();
|
||||
}
|
||||
);
|
||||
});
|
||||
$("#user_submit").click(function() {
|
||||
this.closest("form").submit();
|
||||
});
|
||||
|
||||
$("#delete_shelf").click(function() {
|
||||
ConfirmDialog(
|
||||
$(this).attr('id'),
|
||||
$(this).data('value'),
|
||||
function(value){
|
||||
window.location.href = window.location.pathname + "/../../shelf/delete/" + value
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
|
||||
$("#fileModal").on("show.bs.modal", function(e) {
|
||||
@@ -487,19 +561,6 @@ $(function() {
|
||||
}
|
||||
});
|
||||
|
||||
$("#btndeletetoken").click(function() {
|
||||
//get data-id attribute of the clicked element
|
||||
var pathname = document.getElementsByTagName("script"), src = pathname[pathname.length - 1].src;
|
||||
var path = src.substring(0, src.lastIndexOf("/"));
|
||||
$.ajax({
|
||||
method:"get",
|
||||
url: path + "/../../kobo_auth/deleteauthtoken/" + this.value,
|
||||
});
|
||||
$("#modalDeleteToken").modal("hide");
|
||||
$("#config_delete_kobo_token").hide();
|
||||
|
||||
});
|
||||
|
||||
$(window).resize(function() {
|
||||
$(".discover .row").isotope("layout");
|
||||
});
|
||||
|
||||
@@ -208,15 +208,13 @@ $(function() {
|
||||
},
|
||||
striped: false
|
||||
});
|
||||
$("#btndeletedomain").click(function() {
|
||||
//get data-id attribute of the clicked element
|
||||
var domainId = $(this).data("domainId");
|
||||
|
||||
function domain_handle(domainId) {
|
||||
$.ajax({
|
||||
method:"post",
|
||||
url: window.location.pathname + "/../../ajax/deletedomain",
|
||||
data: {"domainid":domainId}
|
||||
});
|
||||
$("#DeleteDomain").modal("hide");
|
||||
$.ajax({
|
||||
method:"get",
|
||||
url: window.location.pathname + "/../../ajax/domainlist/1",
|
||||
@@ -235,12 +233,16 @@ $(function() {
|
||||
$("#domain-deny-table").bootstrapTable("load", data);
|
||||
}
|
||||
});
|
||||
}
|
||||
$("#domain-allow-table").on("click-cell.bs.table", function (field, value, row, $element) {
|
||||
if (value === 2) {
|
||||
ConfirmDialog("btndeletedomain", $element.id, domain_handle);
|
||||
}
|
||||
});
|
||||
//triggered when modal is about to be shown
|
||||
$("#DeleteDomain").on("show.bs.modal", function(e) {
|
||||
//get data-id attribute of the clicked element and store in button
|
||||
var domainId = $(e.relatedTarget).data("domain-id");
|
||||
$(e.currentTarget).find("#btndeletedomain").data("domainId", domainId);
|
||||
$("#domain-deny-table").on("click-cell.bs.table", function (field, value, row, $element) {
|
||||
if (value === 2) {
|
||||
ConfirmDialog("btndeletedomain", $element.id, domain_handle);
|
||||
}
|
||||
});
|
||||
|
||||
$("#restrictModal").on("hidden.bs.modal", function () {
|
||||
@@ -347,7 +349,7 @@ $(function() {
|
||||
/* Function for deleting domain restrictions */
|
||||
function TableActions (value, row) {
|
||||
return [
|
||||
"<a class=\"danger remove\" data-toggle=\"modal\" data-target=\"#DeleteDomain\" data-domain-id=\"" + row.id
|
||||
"<a class=\"danger remove\" data-value=\"" + row.id
|
||||
+ "\" title=\"Remove\">",
|
||||
"<i class=\"glyphicon glyphicon-trash\"></i>",
|
||||
"</a>"
|
||||
|
||||
Reference in New Issue
Block a user