mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
js: Don't navigate right when opening a modal
Isn't the prettiest fix. I would have liked to completely remove the target preparation from `getLinkTargetFor`. But this is the easiest fix since it's only for modals that preparation is not desired. It's also the most compatible change.
This commit is contained in:
parent
712e74b3ce
commit
57b4a31bc3
@ -40,7 +40,7 @@
|
|||||||
var $a = $(event.currentTarget);
|
var $a = $(event.currentTarget);
|
||||||
var url = $a.attr('href');
|
var url = $a.attr('href');
|
||||||
var $modal = _this.$ghost.clone();
|
var $modal = _this.$ghost.clone();
|
||||||
var $urlTarget = _this.icinga.loader.getLinkTargetFor($a);
|
var $urlTarget = _this.icinga.loader.getLinkTargetFor($a, false);
|
||||||
|
|
||||||
// Add showCompact, we don't want controls in a modal
|
// Add showCompact, we don't want controls in a modal
|
||||||
url = _this.icinga.utils.addUrlFlag(url, 'showCompact');
|
url = _this.icinga.utils.addUrlFlag(url, 'showCompact');
|
||||||
|
@ -1060,9 +1060,16 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Detect the link/form target for a given element (link, form, whatever)
|
* Detect the link/form target for a given element (link, form, whatever)
|
||||||
|
*
|
||||||
|
* @param {object} $el jQuery set with the element
|
||||||
|
* @param {boolean} prepare Pass `false` to disable column preparation
|
||||||
*/
|
*/
|
||||||
getLinkTargetFor: function($el)
|
getLinkTargetFor: function($el, prepare)
|
||||||
{
|
{
|
||||||
|
if (typeof prepare === 'undefined') {
|
||||||
|
prepare = true;
|
||||||
|
}
|
||||||
|
|
||||||
// If everything else fails, our target is the first column...
|
// If everything else fails, our target is the first column...
|
||||||
var $col1 = $('#col1');
|
var $col1 = $('#col1');
|
||||||
var $target = $col1;
|
var $target = $col1;
|
||||||
@ -1083,17 +1090,12 @@
|
|||||||
if (this.icinga.ui.hasOnlyOneColumn()) {
|
if (this.icinga.ui.hasOnlyOneColumn()) {
|
||||||
$target = $col1;
|
$target = $col1;
|
||||||
} else {
|
} else {
|
||||||
if ($el.closest('#col2').length) {
|
|
||||||
this.icinga.ui.moveToLeft();
|
|
||||||
}
|
|
||||||
|
|
||||||
$target = $('#col2');
|
$target = $('#col2');
|
||||||
}
|
}
|
||||||
} else if (targetId === '_self') {
|
} else if (targetId === '_self') {
|
||||||
$target = $el.closest('.container');
|
$target = $el.closest('.container');
|
||||||
} else if (targetId === '_main') {
|
} else if (targetId === '_main') {
|
||||||
$target = $col1;
|
$target = $col1;
|
||||||
this.icinga.ui.layout1col();
|
|
||||||
} else {
|
} else {
|
||||||
$target = $('#' + targetId);
|
$target = $('#' + targetId);
|
||||||
if (! $target.length) {
|
if (! $target.length) {
|
||||||
@ -1102,9 +1104,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hardcoded layout switch unless columns are dynamic
|
if (prepare) {
|
||||||
if ($target.attr('id') === 'col2') {
|
this.icinga.ui.prepareColumnFor($el, $target);
|
||||||
this.icinga.ui.layout2col();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $target;
|
return $target;
|
||||||
|
@ -340,6 +340,26 @@
|
|||||||
$('#layout').trigger('layout-change');
|
$('#layout').trigger('layout-change');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
prepareColumnFor: function ($el, $target) {
|
||||||
|
var explicitTarget;
|
||||||
|
|
||||||
|
if ($target.attr('id') === 'col2') {
|
||||||
|
if ($el.closest('#col2').length) {
|
||||||
|
explicitTarget = $el.closest('[data-base-target]').data('baseTarget');
|
||||||
|
if (typeof explicitTarget !== 'undefined' && explicitTarget === '_next') {
|
||||||
|
this.moveToLeft();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.layout2col();
|
||||||
|
}
|
||||||
|
} else { // if ($target.attr('id') === 'col1')
|
||||||
|
explicitTarget = $el.closest('[data-base-target]').data('baseTarget');
|
||||||
|
if (typeof explicitTarget !== 'undefined' && explicitTarget === '_main') {
|
||||||
|
this.layout1col();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
getAvailableColumnSpace: function () {
|
getAvailableColumnSpace: function () {
|
||||||
return $('#main').width() / this.getDefaultFontSize();
|
return $('#main').width() / this.getDefaultFontSize();
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user