mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-04-08 17:15:08 +02:00
ui.js: Allow to disable scrolling in method focusElement
This commit is contained in:
parent
1c9986be72
commit
f734d28060
@ -145,10 +145,15 @@
|
|||||||
*
|
*
|
||||||
* @param {string} element The name or id of the element to focus
|
* @param {string} element The name or id of the element to focus
|
||||||
* @param {object} [$container] The container containing the element
|
* @param {object} [$container] The container containing the element
|
||||||
|
* @param {boolean} [scroll] Whether the viewport should be scrolled to the focused element
|
||||||
*/
|
*/
|
||||||
focusElement: function(element, $container) {
|
focusElement: function(element, $container, scroll) {
|
||||||
var $element = element;
|
var $element = element;
|
||||||
|
|
||||||
|
if (typeof scroll === 'undefined') {
|
||||||
|
scroll = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof element === 'string') {
|
if (typeof element === 'string') {
|
||||||
if ($container && $container.length) {
|
if ($container && $container.length) {
|
||||||
$element = $container.find('#' + element);
|
$element = $container.find('#' + element);
|
||||||
@ -175,7 +180,7 @@
|
|||||||
|
|
||||||
$element[0].focus();
|
$element[0].focus();
|
||||||
|
|
||||||
if ($container && $container.length) {
|
if (scroll && $container && $container.length) {
|
||||||
if (! $container.is('.container')) {
|
if (! $container.is('.container')) {
|
||||||
$container = $container.closest('.container');
|
$container = $container.closest('.container');
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user