js: Add method `identifyLinkTarget()` to the loader
This commit is contained in:
parent
4f57aa68cd
commit
6e8ca9cdda
|
@ -1076,8 +1076,7 @@
|
|||
}
|
||||
|
||||
// If everything else fails, our target is the first column...
|
||||
var $col1 = $('#col1');
|
||||
var $target = $col1;
|
||||
var $target = $('#col1');
|
||||
|
||||
// ...but usually we will use our own container...
|
||||
var $container = $el.closest('.container');
|
||||
|
@ -1089,25 +1088,11 @@
|
|||
if ($el.closest('[data-base-target]').length) {
|
||||
var targetId = $el.closest('[data-base-target]').data('baseTarget');
|
||||
|
||||
// Simulate _next to prepare migration to dynamic column layout
|
||||
// YES, there are duplicate lines right now.
|
||||
if (targetId === '_next') {
|
||||
if (this.icinga.ui.hasOnlyOneColumn()) {
|
||||
$target = $col1;
|
||||
} else {
|
||||
$target = $('#col2');
|
||||
}
|
||||
} else if (targetId === '_self') {
|
||||
$target = $el.closest('.container');
|
||||
} else if (targetId === '_main') {
|
||||
$target = $col1;
|
||||
} else {
|
||||
$target = $('#' + targetId);
|
||||
$target = this.identifyLinkTarget(targetId, $el);
|
||||
if (! $target.length) {
|
||||
this.icinga.logger.warn('Link target "#' + targetId + '" does not exist in DOM.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (prepare) {
|
||||
this.icinga.ui.prepareColumnFor($el, $target);
|
||||
|
@ -1116,6 +1101,35 @@
|
|||
return $target;
|
||||
},
|
||||
|
||||
/**
|
||||
* Identify link target by the given id
|
||||
*
|
||||
* The id may also be one of the column aliases: `_next`, `_self` and `_main`
|
||||
*
|
||||
* @param {string} id
|
||||
* @param {object} $of
|
||||
* @return {object}
|
||||
*/
|
||||
identifyLinkTarget: function (id, $of) {
|
||||
var $target;
|
||||
|
||||
if (id === '_next') {
|
||||
if (this.icinga.ui.hasOnlyOneColumn()) {
|
||||
$target = $('#col1');
|
||||
} else {
|
||||
$target = $('#col2');
|
||||
}
|
||||
} else if (id === '_self') {
|
||||
$target = $of.closest('.container');
|
||||
} else if (id === '_main') {
|
||||
$target = $('#col1');
|
||||
} else {
|
||||
$target = $('#' + id);
|
||||
}
|
||||
|
||||
return $target;
|
||||
},
|
||||
|
||||
/**
|
||||
* Smoothly render given HTML to given container
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue