mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-25 23:04:51 +02:00
js: Drop function events.handleAnchor() and ui.scrollContainerToAnchor()
There is ui.focusElement() now which handles ids as well. refs #8615
This commit is contained in:
parent
bdc61a5f62
commit
153f3ba2f9
@ -322,28 +322,6 @@
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle anchor, i.e. focus the element which is referenced by the anchor
|
|
||||||
*
|
|
||||||
* @param {string} element The name or id of the element to focus
|
|
||||||
*/
|
|
||||||
handleAnchor: function(element) {
|
|
||||||
var $element = $('#' + element);
|
|
||||||
if (! $element.length) {
|
|
||||||
// The name attribute is actually deprecated, on anchor tags,
|
|
||||||
// but we'll possibly handle links from another source
|
|
||||||
// (module etc) so that's used as a fallback
|
|
||||||
$element = $('[name="' + element + '"]');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($element.length) {
|
|
||||||
if (typeof $element.attr('tabindex') === 'undefined') {
|
|
||||||
$element.attr('tabindex', -1);
|
|
||||||
}
|
|
||||||
$element.focus();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Someone clicked a link or tr[href]
|
* Someone clicked a link or tr[href]
|
||||||
*/
|
*/
|
||||||
@ -411,7 +389,7 @@
|
|||||||
// This is an anchor only
|
// This is an anchor only
|
||||||
if (href.substr(0, 1) === '#' && href.length > 1
|
if (href.substr(0, 1) === '#' && href.length > 1
|
||||||
&& href.substr(1, 1) !== '!') {
|
&& href.substr(1, 1) !== '!') {
|
||||||
self.handleAnchor(href.substr(1));
|
icinga.ui.focusElement(href.substr(1));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -441,7 +419,7 @@
|
|||||||
|
|
||||||
formerUrl = $target.data('icingaUrl');
|
formerUrl = $target.data('icingaUrl');
|
||||||
if (typeof formerUrl !== 'undefined' && formerUrl.split(/#/)[0] === href.split(/#/)[0]) {
|
if (typeof formerUrl !== 'undefined' && formerUrl.split(/#/)[0] === href.split(/#/)[0]) {
|
||||||
icinga.ui.scrollContainerToAnchor($target, href.split(/#/)[1]);
|
icinga.ui.focusElement(href.split(/#/)[1], $target);
|
||||||
$target.data('icingaUrl', href);
|
$target.data('icingaUrl', href);
|
||||||
if (formerUrl !== href) {
|
if (formerUrl !== href) {
|
||||||
icinga.history.pushCurrentState();
|
icinga.history.pushCurrentState();
|
||||||
|
@ -560,7 +560,7 @@
|
|||||||
oldNotifications.appendTo($('#notifications'));
|
oldNotifications.appendTo($('#notifications'));
|
||||||
}
|
}
|
||||||
if (url.match(/#/)) {
|
if (url.match(/#/)) {
|
||||||
this.icinga.ui.scrollContainerToAnchor(req.$target, url.split(/#/)[1]);
|
this.icinga.ui.focusElement(url.split(/#/)[1], req.$target);
|
||||||
}
|
}
|
||||||
if (newBody) {
|
if (newBody) {
|
||||||
this.icinga.ui.fixDebugVisibility().triggerWindowResize();
|
this.icinga.ui.fixDebugVisibility().triggerWindowResize();
|
||||||
|
@ -193,18 +193,6 @@
|
|||||||
$col.data('icingaModule', backup['data']['data-icinga-module']);
|
$col.data('icingaModule', backup['data']['data-icinga-module']);
|
||||||
},
|
},
|
||||||
|
|
||||||
scrollContainerToAnchor: function ($container, anchorName) {
|
|
||||||
// TODO: Generic issue -> we probably should escape attribute value selectors!?
|
|
||||||
var $anchor = $("a[name='" + anchorName.replace(/'/, '\\\'') + "']", $container);
|
|
||||||
if ($anchor.length) {
|
|
||||||
$container.scrollTop(0);
|
|
||||||
$container.scrollTop($anchor.first().position().top);
|
|
||||||
this.icinga.logger.debug('Scrolling ', $container, ' to ', anchorName);
|
|
||||||
} else {
|
|
||||||
this.icinga.logger.info('Anchor "' + anchorName + '" not found in ', $container);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
triggerWindowResize: function () {
|
triggerWindowResize: function () {
|
||||||
this.onWindowResize({data: {self: this}});
|
this.onWindowResize({data: {self: this}});
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user