From 470944a65cca0a1fd67b0f13bfe4436820d7e145 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 9 Oct 2019 17:28:48 +0200 Subject: slx-fixes: Expose function for adding additional automatic confirm handlers --- script/slx-fixes.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/script/slx-fixes.js b/script/slx-fixes.js index e3b42812..992ca337 100644 --- a/script/slx-fixes.js +++ b/script/slx-fixes.js @@ -54,10 +54,12 @@ $('a.disabled').each(function() { $hax.append($this); }); +var slxModalConfirmHandler; + // Modern confirmation dialogs using bootstrap modal $(document).ready(function() { - var $title, $body, $button, $function, $modal = null, $cache = {}; - $function = function (e) { + var $title, $body, $button, $modal = null, $cache = {}; + slxModalConfirmHandler = function (e) { e.preventDefault(); var $this = $(this); if ($modal === null) { @@ -70,9 +72,9 @@ $(document).ready(function() { $button = $('#modal-autogen-button'); } $title.text($this.data('title') || $this.text()); - $button.html($this.html()).attr('class', $this.attr('class')).removeClass('btn-xs btn-sm btn-lg').off('click').click(function() { + $button.html($this.data('close') || $this.html()).attr('class', $this.attr('class')).removeClass('btn-xs btn-sm btn-lg').off('click').click(function() { // Click and reconnect click handler so pressing "back" on the next page works - $this.off('click').click().click($function); + $this.off('click').click().click(slxModalConfirmHandler); }); var $wat, str = $this.data('confirm'); if (str.substr(0, 9) === '#confirm-') { @@ -87,7 +89,7 @@ $(document).ready(function() { } $modal.modal(); }; - $('button[data-confirm]').click($function); + $('button[data-confirm]').click(slxModalConfirmHandler); }); // Taskmanager callbacks for running tasks -- cgit v1.2.3-55-g7522