Commit 63c60d22 authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

Proper form key presses handling

Handle enter/esc key presses in vm rename, private network rename and
metadata editing forms.
parent 98ef059e
......@@ -193,10 +193,10 @@
// give edit focus
this.$('input').focus();
// handle enter press
this.$('input').keypress(function(ev){
if (ev.charCode == 13) {
self.submit();
}
this.$('input').keydown(function(ev){
ev.keyCode = ev.keyCode || ev.which;
if (ev.keyCode == 13) { self.submit(); }
if (ev.keyCode == 27) { self.renaming = false; self.update_layout(); }
})
},
......
......@@ -165,6 +165,7 @@
this.$(".editor .create").removeClass('in-progress');
}, this));
} else {
this.editing = true;
this.editor.find(".form-field label").addClass("error");
}
......@@ -205,7 +206,9 @@
})
this.editor.find("input").keyup(_.bind(function(e){
e.keyCode = e.keyCode || e.which;
if (e.keyCode == 13) { this.submit_editor() };
if (e.keyCode == 27) { this.close_editor() };
}, this));
this.editor.find(".predefined-meta-key").click(function() {
......
......@@ -362,11 +362,10 @@
this.input.val(this.network.get("name"));
this.el.append(this.input);
this.input.focus();
this.input.bind("keypress", _.bind(function(ev){
if (ev.which == 13) {
this.submit();
}
if (ev.keyCode == 17) {this.editing = false; this.update_layout()};
this.input.bind("keydown", _.bind(function(ev){
ev.keyCode = ev.keyCode || ev.which;
if (ev.keyCode == 13) { this.submit(); };
if (ev.keyCode == 27) {this.editing = false; this.update_layout()};
}, this));
},
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment