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 {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;
|
||||
|
||||
if (typeof scroll === 'undefined') {
|
||||
scroll = true;
|
||||
}
|
||||
|
||||
if (typeof element === 'string') {
|
||||
if ($container && $container.length) {
|
||||
$element = $container.find('#' + element);
|
||||
|
@ -175,7 +180,7 @@
|
|||
|
||||
$element[0].focus();
|
||||
|
||||
if ($container && $container.length) {
|
||||
if (scroll && $container && $container.length) {
|
||||
if (! $container.is('.container')) {
|
||||
$container = $container.closest('.container');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue