forked from extern/egroupware
Set back focus to the first field in form
This commit is contained in:
parent
e4efa38d45
commit
02096632e6
@ -161,6 +161,8 @@ var et2_htmlarea = /** @class */ (function (_super) {
|
||||
if (jQuery('#dragover-tinymce').length < 1)
|
||||
jQuery("<style id='dragover-tinymce'>.dragover:after {height:calc(100% - " + jQuery(this).height() + "px) !important;}</style>").appendTo('head');
|
||||
});
|
||||
//set back focus to the first field in the form
|
||||
self.getInstanceManager().focusOnFirstInput();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -294,6 +294,8 @@ export class et2_htmlarea extends et2_editableWidget implements et2_IResizeable
|
||||
jQuery(self.editor.iframeElement.contentWindow.document).on('dragenter', function(){
|
||||
if (jQuery('#dragover-tinymce').length < 1) jQuery("<style id='dragover-tinymce'>.dragover:after {height:calc(100% - "+jQuery(this).height()+"px) !important;}</style>").appendTo('head');
|
||||
});
|
||||
//set back focus to the first field in the form
|
||||
self.getInstanceManager().focusOnFirstInput();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -483,18 +483,7 @@ var etemplate2 = /** @class */ (function () {
|
||||
this.resize();
|
||||
// Automatically set focus to first visible input for popups
|
||||
if (this._widgetContainer._egw.is_popup() && jQuery('[autofocus]', this._DOMContainer).focus().length == 0) {
|
||||
var $input = jQuery('input:visible', this._DOMContainer)
|
||||
// Date fields open the calendar popup on focus
|
||||
.not('.et2_date')
|
||||
.filter(function () {
|
||||
// Skip inputs that are out of tab ordering
|
||||
var $this = jQuery(this);
|
||||
return !$this.attr('tabindex') || parseInt($this.attr('tabIndex')) >= 0;
|
||||
}).first();
|
||||
// mobile device, focus only if the field is empty (usually means new entry)
|
||||
// should focus always for non-mobile one
|
||||
if (egwIsMobile() && $input.val() == "" || !egwIsMobile())
|
||||
$input.focus();
|
||||
this.focusOnFirstInput();
|
||||
}
|
||||
// Tell others about it
|
||||
if (typeof _callback == "function") {
|
||||
@ -571,6 +560,21 @@ var etemplate2 = /** @class */ (function () {
|
||||
this._widgetContainer.setArrayMgrs(this._createArrayManagers(_data));
|
||||
}, this);
|
||||
};
|
||||
etemplate2.prototype.focusOnFirstInput = function () {
|
||||
var $input = jQuery('input:visible', this.DOMContainer)
|
||||
// Date fields open the calendar popup on focus
|
||||
.not('.et2_date')
|
||||
.filter(function () {
|
||||
// Skip inputs that are out of tab ordering
|
||||
var $this = jQuery(this);
|
||||
return !$this.attr('tabindex') || parseInt($this.attr('tabIndex')) >= 0;
|
||||
}).first();
|
||||
// mobile device, focus only if the field is empty (usually means new entry)
|
||||
// should focus always for non-mobile one
|
||||
if (egwIsMobile() && $input.val() == "" || !egwIsMobile()) {
|
||||
$input.focus();
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Check if template contains any dirty (unsaved) content
|
||||
*
|
||||
|
@ -619,19 +619,7 @@ export class etemplate2
|
||||
// Automatically set focus to first visible input for popups
|
||||
if (this._widgetContainer._egw.is_popup() && jQuery('[autofocus]', this._DOMContainer).focus().length == 0)
|
||||
{
|
||||
const $input = jQuery('input:visible', this._DOMContainer)
|
||||
// Date fields open the calendar popup on focus
|
||||
.not('.et2_date')
|
||||
.filter(function ()
|
||||
{
|
||||
// Skip inputs that are out of tab ordering
|
||||
const $this = jQuery(this);
|
||||
return !$this.attr('tabindex') || parseInt($this.attr('tabIndex')) >= 0;
|
||||
}).first();
|
||||
|
||||
// mobile device, focus only if the field is empty (usually means new entry)
|
||||
// should focus always for non-mobile one
|
||||
if (egwIsMobile() && $input.val() == "" || !egwIsMobile()) $input.focus();
|
||||
this.focusOnFirstInput();
|
||||
}
|
||||
|
||||
// Tell others about it
|
||||
@ -728,6 +716,26 @@ export class etemplate2
|
||||
}, this);
|
||||
}
|
||||
|
||||
public focusOnFirstInput()
|
||||
{
|
||||
const $input = jQuery('input:visible', this.DOMContainer)
|
||||
// Date fields open the calendar popup on focus
|
||||
.not('.et2_date')
|
||||
.filter(function()
|
||||
{
|
||||
// Skip inputs that are out of tab ordering
|
||||
const $this = jQuery(this);
|
||||
return !$this.attr('tabindex') || parseInt($this.attr('tabIndex')) >= 0;
|
||||
}).first();
|
||||
|
||||
// mobile device, focus only if the field is empty (usually means new entry)
|
||||
// should focus always for non-mobile one
|
||||
if(egwIsMobile() && $input.val() == "" || !egwIsMobile())
|
||||
{
|
||||
$input.focus();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if template contains any dirty (unsaved) content
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user