Skip to content
Snippets Groups Projects
Commit ecd84cc2 authored by Rafael Ostertag's avatar Rafael Ostertag
Browse files

Alert.js: buttons on alerts are now really `<button>`. Buttons can now have...

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.
parent 0ceedc06
No related branches found
No related tags found
No related merge requests found
...@@ -39,6 +39,7 @@ var QfqNS = QfqNS || {}; ...@@ -39,6 +39,7 @@ var QfqNS = QfqNS || {};
* *
* { * {
* label: <button label>, * label: <button label>,
* focus: true | false,
* eventName: <eventname> * eventName: <eventname>
* } * }
* *
...@@ -139,8 +140,11 @@ var QfqNS = QfqNS || {}; ...@@ -139,8 +140,11 @@ var QfqNS = QfqNS || {};
$buttons = $("<div>").addClass("alert-buttons"); $buttons = $("<div>").addClass("alert-buttons");
} }
$buttons.append($("<a>").append(buttonConfiguration.label) var focus = buttonConfiguration.focus ? buttonConfiguration.focus : false;
.addClass("btn btn-default")
$buttons.append($("<button>").append(buttonConfiguration.label)
.attr('type', 'button')
.addClass("btn btn-default" + (focus ? " wants-focus" : ""))
.click(buttonConfiguration, this.buttonHandler.bind(this))); .click(buttonConfiguration, this.buttonHandler.bind(this)));
} }
...@@ -173,6 +177,7 @@ var QfqNS = QfqNS || {}; ...@@ -173,6 +177,7 @@ var QfqNS = QfqNS || {};
$alertContainer.append(this.$alertDiv); $alertContainer.append(this.$alertDiv);
this.$alertDiv.slideDown(this.fadeInDuration, this.afterFadeIn.bind(this)); this.$alertDiv.slideDown(this.fadeInDuration, this.afterFadeIn.bind(this));
this.$alertDiv.find(".wants-focus").focus();
this.shown = true; this.shown = true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment