From ecd84cc2fabefe769c1ae8a5f20ee50b97dc39d6 Mon Sep 17 00:00:00 2001 From: Rafael Ostertag <rafael.ostertag@math.uzh.ch> Date: Wed, 11 May 2016 08:25:19 +0200 Subject: [PATCH] Alert.js: buttons on alerts are now really `<button>`. Buttons can now have the default focus, as specified by the `focus` attribue in the button configuration. --- javascript/src/Alert.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/javascript/src/Alert.js b/javascript/src/Alert.js index 1168877f0..10f48e736 100644 --- a/javascript/src/Alert.js +++ b/javascript/src/Alert.js @@ -39,6 +39,7 @@ var QfqNS = QfqNS || {}; * * { * label: <button label>, + * focus: true | false, * eventName: <eventname> * } * @@ -139,8 +140,11 @@ var QfqNS = QfqNS || {}; $buttons = $("<div>").addClass("alert-buttons"); } - $buttons.append($("<a>").append(buttonConfiguration.label) - .addClass("btn btn-default") + var focus = buttonConfiguration.focus ? buttonConfiguration.focus : false; + + $buttons.append($("<button>").append(buttonConfiguration.label) + .attr('type', 'button') + .addClass("btn btn-default" + (focus ? " wants-focus" : "")) .click(buttonConfiguration, this.buttonHandler.bind(this))); } @@ -173,6 +177,7 @@ var QfqNS = QfqNS || {}; $alertContainer.append(this.$alertDiv); this.$alertDiv.slideDown(this.fadeInDuration, this.afterFadeIn.bind(this)); + this.$alertDiv.find(".wants-focus").focus(); this.shown = true; -- GitLab