mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Implementing a more versatile approach to unsafe links.
This update enables you to configure anchor elements with a data-unsafe-url="Are you sure?" attribute, allowing the customization of the confirmation message.
This commit is contained in:
@@ -210,7 +210,7 @@
|
||||
$(function () {
|
||||
var magicToken = $("input[name=__RequestVerificationToken]").first();
|
||||
if (!magicToken) { return; } // no sense in continuing if form POSTS will fail
|
||||
$("body").on("click", "a[itemprop~=UnsafeUrl]", function() {
|
||||
$("body").on("click", "a[itemprop~=UnsafeUrl], a[data-unsafe-url]", function() {
|
||||
var _this = $(this);
|
||||
var hrefParts = _this.attr("href").split("?");
|
||||
var form = $("<form action=\"" + hrefParts[0] + "\" method=\"POST\" />");
|
||||
@@ -226,6 +226,14 @@
|
||||
form.css({ "position": "absolute", "left": "-9999em" });
|
||||
$("body").append(form);
|
||||
|
||||
var unsafeUrlPrompt = _this.data("unsafe-url");
|
||||
|
||||
if (unsafeUrlPrompt && unsafeUrlPrompt.length > 0) {
|
||||
if (!confirm(unsafeUrlPrompt)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (_this.filter("[itemprop~='RemoveUrl']").length == 1) {
|
||||
if (!confirm(confirmRemoveMessage)) {
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user