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...
|
// 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...
|
// ...but usually we will use our own container...
|
||||||
var $container = $el.closest('.container');
|
var $container = $el.closest('.container');
|
||||||
|
@ -1089,23 +1088,9 @@
|
||||||
if ($el.closest('[data-base-target]').length) {
|
if ($el.closest('[data-base-target]').length) {
|
||||||
var targetId = $el.closest('[data-base-target]').data('baseTarget');
|
var targetId = $el.closest('[data-base-target]').data('baseTarget');
|
||||||
|
|
||||||
// Simulate _next to prepare migration to dynamic column layout
|
$target = this.identifyLinkTarget(targetId, $el);
|
||||||
// YES, there are duplicate lines right now.
|
if (! $target.length) {
|
||||||
if (targetId === '_next') {
|
this.icinga.logger.warn('Link target "#' + targetId + '" does not exist in DOM.');
|
||||||
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);
|
|
||||||
if (! $target.length) {
|
|
||||||
this.icinga.logger.warn('Link target "#' + targetId + '" does not exist in DOM.');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1116,6 +1101,35 @@
|
||||||
return $target;
|
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
|
* Smoothly render given HTML to given container
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue