js: Move function events.getLinkTargetFor to loader.js
This commit is contained in:
parent
57f966734a
commit
50bf126d36
|
@ -414,9 +414,9 @@
|
|||
var count = table.selections().length;
|
||||
if (count > 0) {
|
||||
var query = table.toQuery();
|
||||
_this.icinga.loader.loadUrl(query, _this.icinga.events.getLinkTargetFor($tr));
|
||||
_this.icinga.loader.loadUrl(query, _this.icinga.loader.getLinkTargetFor($tr));
|
||||
} else {
|
||||
if (_this.icinga.events.getLinkTargetFor($tr).attr('id') === 'col2') {
|
||||
if (_this.icinga.loader.getLinkTargetFor($tr).attr('id') === 'col2') {
|
||||
_this.icinga.ui.layout1col();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -298,9 +298,9 @@
|
|||
$button.addClass('active');
|
||||
}
|
||||
|
||||
$target = _this.getLinkTargetFor($button);
|
||||
$target = icinga.loader.getLinkTargetFor($button);
|
||||
} else {
|
||||
$target = _this.getLinkTargetFor($form);
|
||||
$target = icinga.loader.getLinkTargetFor($form);
|
||||
}
|
||||
|
||||
if (! url) {
|
||||
|
@ -516,7 +516,7 @@
|
|||
}
|
||||
return false;
|
||||
}
|
||||
$target = _this.getLinkTargetFor($a);
|
||||
$target = icinga.loader.getLinkTargetFor($a);
|
||||
|
||||
formerUrl = $target.data('icingaUrl');
|
||||
if (typeof formerUrl !== 'undefined' && formerUrl.split(/#/)[0] === href.split(/#/)[0]) {
|
||||
|
@ -528,7 +528,7 @@
|
|||
return false;
|
||||
}
|
||||
} else {
|
||||
$target = _this.getLinkTargetFor($a);
|
||||
$target = icinga.loader.getLinkTargetFor($a);
|
||||
}
|
||||
|
||||
// Load link URL
|
||||
|
@ -542,63 +542,6 @@
|
|||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Detect the link/form target for a given element (link, form, whatever)
|
||||
*/
|
||||
getLinkTargetFor: function($el)
|
||||
{
|
||||
var targetId;
|
||||
|
||||
// If everything else fails, our target is the first column...
|
||||
var $target = $('#col1');
|
||||
|
||||
// ...but usually we will use our own container...
|
||||
var $container = $el.closest('.container');
|
||||
if ($container.length) {
|
||||
$target = $container;
|
||||
}
|
||||
|
||||
// You can of course override the default behaviour:
|
||||
if ($el.closest('[data-base-target]').length) {
|
||||
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()) {
|
||||
targetId = 'col1';
|
||||
$target = $('#' + targetId);
|
||||
} else {
|
||||
if ($el.closest('#col2').length) {
|
||||
this.icinga.ui.moveToLeft();
|
||||
}
|
||||
targetId = 'col2';
|
||||
$target = $('#' + targetId);
|
||||
}
|
||||
} else if (targetId === '_self') {
|
||||
$target = $el.closest('.container');
|
||||
targetId = $target.attr('id');
|
||||
} else if (targetId === '_main') {
|
||||
targetId = 'col1';
|
||||
$target = $('#' + targetId);
|
||||
this.icinga.ui.layout1col();
|
||||
} else {
|
||||
$target = $('#' + targetId);
|
||||
if (! $target.length) {
|
||||
this.icinga.logger.warn('Link target "#' + targetId + '" does not exist in DOM.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Hardcoded layout switch unless columns are dynamic
|
||||
if ($target.attr('id') === 'col2') {
|
||||
this.icinga.ui.layout2col();
|
||||
}
|
||||
|
||||
return $target;
|
||||
},
|
||||
|
||||
clearSearch: function (event) {
|
||||
$(event.target).parent().find('#search').attr('value', '');
|
||||
},
|
||||
|
|
|
@ -772,6 +772,58 @@
|
|||
return $notice;
|
||||
},
|
||||
|
||||
/**
|
||||
* Detect the link/form target for a given element (link, form, whatever)
|
||||
*/
|
||||
getLinkTargetFor: function($el)
|
||||
{
|
||||
// If everything else fails, our target is the first column...
|
||||
var $col1 = $('#col1');
|
||||
var $target = $col1;
|
||||
|
||||
// ...but usually we will use our own container...
|
||||
var $container = $el.closest('.container');
|
||||
if ($container.length) {
|
||||
$target = $container;
|
||||
}
|
||||
|
||||
// You can of course override the default behaviour:
|
||||
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 {
|
||||
if ($el.closest('#col2').length) {
|
||||
this.icinga.ui.moveToLeft();
|
||||
}
|
||||
|
||||
$target = $('#col2');
|
||||
}
|
||||
} else if (targetId === '_self') {
|
||||
$target = $el.closest('.container');
|
||||
} else if (targetId === '_main') {
|
||||
$target = $col1;
|
||||
this.icinga.ui.layout1col();
|
||||
} else {
|
||||
$target = $('#' + targetId);
|
||||
if (! $target.length) {
|
||||
this.icinga.logger.warn('Link target "#' + targetId + '" does not exist in DOM.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hardcoded layout switch unless columns are dynamic
|
||||
if ($target.attr('id') === 'col2') {
|
||||
this.icinga.ui.layout2col();
|
||||
}
|
||||
|
||||
return $target;
|
||||
},
|
||||
|
||||
/**
|
||||
* Smoothly render given HTML to given container
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue