Quellcode durchsuchen

focus on first element when dialog opens and enter on text triggers submit

version-14
Rushabh Mehta vor 13 Jahren
Ursprung
Commit
ebea2c1d4c
2 geänderte Dateien mit 17 neuen und 3 gelöschten Zeilen
  1. +1
    -1
      js/legacy/wn/widgets/form/sidebar.js
  2. +16
    -2
      js/wn/ui/dialog.js

+ 1
- 1
js/legacy/wn/widgets/form/sidebar.js Datei anzeigen

@@ -43,7 +43,7 @@ wn.widgets.form.sidebar = { Sidebar: function(form) {
label: 'List',
icon: 'icon-list',
display: function() {
return !me.form.meta.issingle;
return !me.form.meta.issingle && !me.form.meta.read_only;
},
onclick: function() { window.location.href="#!List/" + me.form.doctype }
},


+ 16
- 2
js/wn/ui/dialog.js Datei anzeigen

@@ -49,6 +49,15 @@ wn.widgets.FieldGroup = function() {
}
}
this.catch_enter_as_submit = function() {
var me = this;
$(this.body).find(':input[type="text"], :input[type="password"]').keypress(function(e) {
if(e.which==13) {
$(me.body).find('.btn-info:first').click();
}
})
}
/* get values */
this.get_values = function() {
var ret = {};
@@ -119,8 +128,10 @@ wn.widgets.Dialog = function(opts) {

this.make_head();
this.body = $a(this.wrapper, 'div', 'dialog_body');
if(this.opts.fields)
if(this.opts.fields) {
this.make_fields(this.body, this.opts.fields);
this.catch_enter_as_submit();
}
}
this.make_head = function() {
@@ -156,7 +167,7 @@ wn.widgets.Dialog = function(opts) {

// show it
$ds(this.wrapper);
// hide background
freeze();

@@ -165,6 +176,9 @@ wn.widgets.Dialog = function(opts) {

// call onshow
if(this.onshow)this.onshow();
// focus on first input
$(this.wrapper).find(':input:first').focus();
}

this.hide = function() {


Laden…
Abbrechen
Speichern