Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* Use a native dialog on macOS
*/
dialog.showMessageBox(win, {
buttons: [confirmButtonText, "Cancel"],
defaultId: 0,
message: messageText
//TODO: Set an appropriate icon
}, function (response) {
if (response == 0) {
handleFlashButton();
}
})
} else {
/* Use Bootbox on all other platforms.
*/
const hexChangedModal = bootbox.confirm({
message: messageText,
buttons: {
confirm: {
label: confirmButtonText,
className: 'btn-success'
},
cancel: {
label: 'Cancel'
}
},
callback: function (result) {
if (result) {
handleFlashButton();
}
}
});
$('.confirm').on("submit", function(e) {
var currentForm = this;
e.preventDefault();
bootbox.confirm('Are you sure?', function(result) {
if(result === true) {
currentForm.submit();
}
})
});
channelAction: function(e) {
e.preventDefault();
e.stopPropagation();
var action = $(e.currentTarget).data('action');
var txt = 'Are you sure you want to <strong>' +
action + '</strong> <em>' + this.model.get('topic') +
'/' + this.model.get('name') + '</em>?';
bootbox.confirm(txt, function(result) {
if (result !== true) {
return;
}
if (action === 'delete') {
var topic = this.model.get('topic');
$.ajax(this.model.url(), {'method': 'DELETE'})
.done(function() {
window.location = AppState.basePath('/topics/' +
encodeURIComponent(topic));
})
.fail(this.handleAJAXError.bind(this));
} else {
$.post(this.model.url(), JSON.stringify({'action': action}))
.done(function() { window.location.reload(true); })
.fail(this.handleAJAXError.bind(this));
}
topicAction: function(e) {
e.preventDefault();
e.stopPropagation();
var action = $(e.currentTarget).data('action');
var txt = 'Are you sure you want to <strong>' +
action + '</strong> <em>' + this.model.get('name') + '</em>?';
bootbox.confirm(txt, function(result) {
if (result !== true) {
return;
}
if (action === 'delete') {
$.ajax(this.model.url(), {'method': 'DELETE'})
.done(function() { window.location = AppState.basePath('/'); });
} else {
$.post(this.model.url(), JSON.stringify({'action': action}))
.done(function() { window.location.reload(true); })
.fail(this.handleAJAXError.bind(this));
}
}.bind(this));
}
});
onTombstoneClick: function(e) {
e.preventDefault();
e.stopPropagation();
var nodeName = $(e.target).data('node');
var topicName = $(e.target).data('topic');
var txt = 'Are you sure you want to <strong>tombstone</strong> <em>' + nodeName + '</em>?';
bootbox.confirm(txt, function(result) {
if (result !== true) {
return;
}
var node = new Node({
'name': nodeName
});
node.tombstoneTopic(topicName)
.done(function() { window.location.reload(true); })
.fail(this.handleAJAXError.bind(this));
}.bind(this));
}
});
onDeleteStory: function (story, e) {
this.prevent(e);
bootbox.confirm('You are going to delete story "' + story.title + '"?',
this.deleteStoryCallback.bind(this, story));
},
function safe_confirm(message, cb) {
bootbox.confirm({
message: message,
buttons: {
cancel: {
label: "No",
className: "btn-default btn-primary pull-left",
},
confirm: {
label: "Yes",
className: "btn-danger pull-right",
},
},
callback: cb,
});
}
handleDelete(event) {
if (!this.props.disableDelete) {
if (this.props.confirm_delete) {
bootbox.confirm("Really delete?", (ok) => {
if (ok) this.props.onFormDelete();
});
} else {
this.props.onFormDelete();
}
}
}
deleteAlias: function (alias, e) {
e.preventDefault();
bootbox.confirm('Confirm delete alias "' + alias.alias +'"', function (yes) {
if (yes) {
SessionAliasAPI.deleteAlias(alias);
}
});
},
onCancelClick: function (allegation, e) {
e.preventDefault();
e.stopPropagation();
bootbox.confirm('Do you want to cancel document request for #' + allegation.crid, function (yes) {
if (yes) {
DocumentRequestAPI.cancelRequest(allegation);
}
});
},