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;
|
||||
},
|
||||
|
||||
/**
|
||||
* 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]
|
||||
*/
|
||||
|
@ -411,7 +389,7 @@
|
|||
// This is an anchor only
|
||||
if (href.substr(0, 1) === '#' && href.length > 1
|
||||
&& href.substr(1, 1) !== '!') {
|
||||
self.handleAnchor(href.substr(1));
|
||||
icinga.ui.focusElement(href.substr(1));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -441,7 +419,7 @@
|
|||
|
||||
formerUrl = $target.data('icingaUrl');
|
||||
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);
|
||||
if (formerUrl !== href) {
|
||||
icinga.history.pushCurrentState();
|
||||
|
|
|
@ -560,7 +560,7 @@
|
|||
oldNotifications.appendTo($('#notifications'));
|
||||
}
|
||||
if (url.match(/#/)) {
|
||||
this.icinga.ui.scrollContainerToAnchor(req.$target, url.split(/#/)[1]);
|
||||
this.icinga.ui.focusElement(url.split(/#/)[1], req.$target);
|
||||
}
|
||||
if (newBody) {
|
||||
this.icinga.ui.fixDebugVisibility().triggerWindowResize();
|
||||
|
|
|
@ -193,18 +193,6 @@
|
|||
$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 () {
|
||||
this.onWindowResize({data: {self: this}});
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue