From d6bc584831d334ff7743458dc1f446295c64af3a Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 17 May 2017 14:02:00 -0500 Subject: [PATCH] Add convenience `dialog_button()` JS function --- tailbone/static/js/tailbone.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tailbone/static/js/tailbone.js b/tailbone/static/js/tailbone.js index 52618f22..4d2a01f1 100644 --- a/tailbone/static/js/tailbone.js +++ b/tailbone/static/js/tailbone.js @@ -68,6 +68,24 @@ function get_uuid(obj) { } +/* + * Return a jQuery object containing a button from a dialog. This is a + * convenience function to help with browser differences. It is assumed + * that it is being called from within the relevant button click handler. + * @param {event} event - Click event object. + */ +function dialog_button(event) { + var button = $(event.target); + + // TODO: not sure why this workaround is needed for Chrome..? + if (! button.hasClass('ui-button')) { + button = button.parents('.ui-button:first'); + } + + return button; +} + + /* * reference to existing timeout warning dialog, if any */