[mb-commits] branch, beta, updated. Merge remote-tracking branch 'mwiencek/mbs-5761' into beta MBS-5761: Can' t us...
MusicBrainz Git Server <[email protected]> Fri, 01 Feb 2013 12:11:59 +0000
| Newsgroups | gmane.comp.audio.musicbrainz.cvs |
|---|---|
| Message-ID | <E1U1FTL-0004lS-Oa@wiley> |
The branch, beta has been updated
via http://git.musicbrainz.org/gitweb/?p=musicbrainz-server/core.git;a=commit;h=2308cebd46a6d4ba295796300ce87f161b6b1ce9 (commit)
via http://git.musicbrainz.org/gitweb/?p=musicbrainz-server/core.git;a=commit;h=4c1dd6b443e3e3f77071710eb3a037004de9327a (commit)
from http://git.musicbrainz.org/gitweb/?p=musicbrainz-server/core.git;a=commit;h=09498db8e36ff461e9634a292e1764fe3f19f566 (commit)
Summary of changes:
root/release/edit_relationships.tt | 6 ++-
root/static/scripts/relationship-editor/Dialog.js | 43 +++++++++++++++------
2 files changed, 36 insertions(+), 13 deletions(-)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 2308cebd46a6d4ba295796300ce87f161b6b1ce9
Merge: 09498db 4c1dd6b
Author: warp <[email protected]>
Date: Fri Feb 1 14:43:05 2013 +0100
Merge remote-tracking branch 'mwiencek/mbs-5761' into beta
* mwiencek/mbs-5761:
MBS-5761: Can't use keyboard shortcuts to create a new work in the relationship editor
commit 4c1dd6b443e3e3f77071710eb3a037004de9327a
Author: Michael Wiencek <[email protected]>
Date: Tue Jan 22 00:04:45 2013 +0000
MBS-5761: Can't use keyboard shortcuts to create a new work in the relationship editor
diff --git a/root/release/edit_relationships.tt b/root/release/edit_relationships.tt
index 827335f..0635c23 100644
--- a/root/release/edit_relationships.tt
+++ b/root/release/edit_relationships.tt
@@ -90,7 +90,11 @@
<!-- ko if: showCreateWorkLink -->
<tr>
<td></td>
- <td><a href="#" data-bind="click: createWork">[% l('Create a new work') %]</a></td>
+ <td>
+ <button id="create-work-btn" data-bind="click: createWork, clickBubble: false">
+ [% l('Create a new work') %]
+ </button>
+ </td>
</tr>
<!-- /ko -->
<!-- ko template: {"if": mode() == "batch.create.works", afterRender: batchWorksMode} -->
diff --git a/root/static/scripts/relationship-editor/Dialog.js b/root/static/scripts/relationship-editor/Dialog.js
index 2d99f55..154594a 100644
--- a/root/static/scripts/relationship-editor/Dialog.js
+++ b/root/static/scripts/relationship-editor/Dialog.js
@@ -247,12 +247,17 @@ ko.bindingHandlers.autocomplete = (function() {
}
}
- // In Opera 10, when the keydown event on the autocomplete bubbles up to the
- // dialog, isDefaultPrevented returns false even though here it returns true.
- // Other browsers work fine.
- function stopEnter(event) {
- if (event.keyCode == 13 && event.isDefaultPrevented())
+ function fixAutocompleteKeys(event) {
+ // In Opera 10, when the keydown event on the autocomplete bubbles up to the
+ // dialog, isDefaultPrevented returns false even though here it returns true.
+ // Other browsers work fine.
+ if ((event.keyCode == 13 && event.isDefaultPrevented()) || event.keyCode == 27)
event.stopPropagation();
+
+ // Opera doesn't return focus to the autocomplete after pressing esc.
+ // without preventDefault.
+ if (event.keyCode == 27)
+ event.preventDefault();
}
return {
@@ -268,7 +273,7 @@ ko.bindingHandlers.autocomplete = (function() {
$autocomplete
.on("lookup-performed", changeTarget)
.find("input.name")
- .on("keydown", stopEnter)
+ .on("keydown keypress", fixAutocompleteKeys)
.on("keyup focus click", showRecentEntities);
setAutocompleteEntity(Dialog.target, Dialog.mode() != "edit");
@@ -284,10 +289,14 @@ ko.bindingHandlers.autocomplete = (function() {
var BaseDialog = (function() {
var inputRegex = /^input|button|select$/;
- function submit(event) {
- if (event.keyCode == 13 && this.canSubmit() && !event.isDefaultPrevented() &&
- inputRegex.test(event.target.nodeName.toLowerCase()))
- this.accept();
+ function dialogKeydown(event) {
+ if (!event.isDefaultPrevented()) {
+ if (event.keyCode == 13 && this.canSubmit() &&
+ inputRegex.test(event.target.nodeName.toLowerCase()))
+ this.accept();
+ else if (event.keyCode == 27)
+ this.hide();
+ }
}
function cancel(event) {
@@ -298,7 +307,7 @@ var BaseDialog = (function() {
}
return function(options) {
- options.$dialog.on("keydown", _.bind(submit, options))
+ options.$dialog.on("keydown", _.bind(dialogKeydown, options))
.find("button.negative").on("keydown", _.bind(cancel, options));
};
}());
@@ -380,6 +389,13 @@ var Dialog = UI.Dialog = {
dlg.showAutocomplete(notBatchWorks);
dlg.showCreateWorkLink(options.relationship.type == "recording-work" && notBatchWorks);
+ // prevent pressing enter on the create-work button from accepting the dialog.
+ if (dlg.showCreateWorkLink.peek())
+ $("#create-work-btn").on("keydown", function(event) {
+ if (event.keyCode == 13)
+ event.stopPropagation();
+ });
+
dlg.$overlay.show();
// prevents the page from jumping. these will be adjusted in positionDialog.
dlg.$dialog.css({top: $w.scrollTop(), left: $w.scrollLeft()}).show();
@@ -745,7 +761,10 @@ var WorkDialog = UI.WorkDialog = {
$("#new-work-dialog").hide();
WorkDialog.type("");
WorkDialog.language("");
- $("#link-type").focus();
+
+ _.defer(function() {
+ $("#create-work-btn").focus();
+ });
},
successCallback: function(data) {
-----------------------------------------------------------------------
hooks/post-receive
--
mb_server