add SeedDMSBox.callback()

This commit is contained in:
Uwe Steinmann 2023-10-14 12:54:29 +02:00
parent 3dd304eb98
commit f0ffe1173e
2 changed files with 49 additions and 1 deletions

View File

@ -1544,6 +1544,9 @@ $(document).ready(function() { /* {{{ */
}( window.SeedDMSAjax = window.SeedDMSAjax || {}, jQuery )); /* }}} */
(function( SeedDMSBox, $, undefined ) { /* {{{ */
/* Open dialog box and
* redirect to the given url if confirm was pressed
*/
SeedDMSBox.redirect = function(url, boxparams) {
bootbox.dialog(boxparams.message, [{
"label" : boxparams.confirmLabel,
@ -1558,4 +1561,22 @@ $(document).ready(function() { /* {{{ */
}
}]);
}
/* Open confirm box and
* calls the callback if the confirm button was pressed
*/
SeedDMSBox.callback = function(callback, boxparams) {
bootbox.dialog(boxparams.message, [{
"label" : boxparams.confirmLabel,
"class" : "btn-danger",
"callback": function() {
callback();
}
}, {
"label" : boxparams.cancelLabel,
"class" : "btn-cancel",
"callback": function() {
}
}]);
}
}( window.SeedDMSBox = window.SeedDMSBox || {}, jQuery )); /* }}} */

View File

@ -1600,6 +1600,9 @@ $(document).ready(function() { /* {{{ */
}( window.SeedDMSAjax = window.SeedDMSAjax || {}, jQuery )); /* }}} */
(function( SeedDMSBox, $, undefined ) { /* {{{ */
/* Open confirm box (which has just one callback) and
* redirect to the given url if confirm was pressed
*/
SeedDMSBox.redirect = function(url, boxparams) {
bootbox.confirm({
"message": boxparams.message,
@ -1609,7 +1612,7 @@ $(document).ready(function() { /* {{{ */
"className" : "btn-danger",
},
"cancel": {
"label" : boxparams.cancelLabel,
"label" : boxparams.cancelLabel,
"className" : "btn-secondary",
}
},
@ -1620,4 +1623,28 @@ $(document).ready(function() { /* {{{ */
}
});
}
/* Open confirm box (which has just one callback) and
* calls the callback if the confirm button was pressed
*/
SeedDMSBox.callback = function(callback, boxparams) {
bootbox.confirm({
"message": boxparams.message,
"buttons": {
"confirm": {
"label" : boxparams.confirmLabel,
"className" : "btn-danger",
},
"cancel": {
"label" : boxparams.cancelLabel,
"className" : "btn-secondary",
}
},
"callback": function(result) {
if(result) {
callback();
}
}
});
}
}( window.SeedDMSBox = window.SeedDMSBox || {}, jQuery )); /* }}} */