summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Beaver <sbeaver@netgate.com>2017-02-09 08:51:32 -0500
committerSteve Beaver <sbeaver@netgate.com>2017-02-09 08:52:31 -0500
commite04daed06563f5fb2d065d86931cd6b2684605c7 (patch)
tree72eabd154a995f95389cc142f00e5b4214a1ca74
parenta48a563d62d97da31569f1c015761eb49c8e020a (diff)
downloadpfsense-e04daed06563f5fb2d065d86931cd6b2684605c7.zip
pfsense-e04daed06563f5fb2d065d86931cd6b2684605c7.tar.gz
Allow GET-to-POST js to handle confirmation dialogs on delete (anything)
-rw-r--r--src/usr/local/www/js/pfSense.js23
-rw-r--r--src/usr/local/www/js/pfSenseHelpers.js23
2 files changed, 33 insertions, 13 deletions
diff --git a/src/usr/local/www/js/pfSense.js b/src/usr/local/www/js/pfSense.js
index 2a6bc16..7f4fa06 100644
--- a/src/usr/local/www/js/pfSense.js
+++ b/src/usr/local/www/js/pfSense.js
@@ -144,19 +144,24 @@ $(function() {
// the element value
$('.btn-danger, .fa-trash').on('click', function(e){
if (!($(this).hasClass('no-confirm')) && !($(this).hasClass('icon-embed-btn'))) {
- var msg = $.trim(this.textContent).toLowerCase();
+ // Anchors using the automatic get2post system (pfSenseHelpers.js) perform the confirmation dialog
+ // in those functions
+ var attr = $(this).attr('usepost');
+ if (typeof attr === typeof undefined || attr === false) {
+ var msg = $.trim(this.textContent).toLowerCase();
- if (!msg)
- var msg = $.trim(this.value).toLowerCase();
+ if (!msg)
+ var msg = $.trim(this.value).toLowerCase();
- var q = 'Are you sure you wish to '+ msg +'?';
+ var q = 'Are you sure you wish to '+ msg +'?';
- if ($(this).attr('title') != undefined)
- q = 'Are you sure you wish to '+ $(this).attr('title').toLowerCase() + '?';
+ if ($(this).attr('title') != undefined)
+ q = 'Are you sure you wish to '+ $(this).attr('title').toLowerCase() + '?';
- if (!confirm(q)) {
- e.preventDefault();
- e.stopPropagation(); // Don't leave ancestor(s) selected.
+ if (!confirm(q)) {
+ e.preventDefault();
+ e.stopPropagation(); // Don't leave ancestor(s) selected.
+ }
}
}
});
diff --git a/src/usr/local/www/js/pfSenseHelpers.js b/src/usr/local/www/js/pfSenseHelpers.js
index 73db900..54dc7aa 100644
--- a/src/usr/local/www/js/pfSenseHelpers.js
+++ b/src/usr/local/www/js/pfSenseHelpers.js
@@ -700,9 +700,7 @@ $('[id*=restartservice-], [id*=stopservice-], [id*=startservice-]').click(functi
// The scripts that follow are an EXPERIMENT in using jQuery/Javascript to automatically convert
// GET calls to POST calls
-// Any anchor with the attribute "usepost" usses these functions. In this file "Edit user", "Delete user" and "Add"
-// have that attribute
-// These function can be moved to an included file
+// Any anchor with the attribute "usepost" usses these functions.
// Any time an anchor is clicked and the "usepost" attibute is present, convert the href attribute
// to POST format, make a POST form and submit it
@@ -711,10 +709,27 @@ $('a').click(function(e) {
var attr = $(this).attr('usepost');
if (typeof attr !== typeof undefined && attr !== false) {
+ // Automatically apply a confirmation dialog to "Delete" icons
+ if (!($(this).hasClass('no-confirm')) && !($(this).hasClass('icon-embed-btn')) &&
+ ($(this).hasClass('fa-trash'))) {
+ var msg = $.trim(this.textContent).toLowerCase();
+
+ if (!msg)
+ var msg = $.trim(this.value).toLowerCase();
+
+ var q = 'Are you sure you wish to '+ msg +'?';
+
+ if ($(this).attr('title') != undefined)
+ q = 'Are you sure you wish to '+ $(this).attr('title').toLowerCase() + '?';
+
+ if (!confirm(q)) {
+ return false;
+ }
+ }
+
var href = $(this).attr("href");
postSubmit(get2post(href));
-
return false;
}
});
OpenPOWER on IntegriCloud