js: add Director-related JavaScript helpers

This commit is contained in:
Thomas Gelf 2016-12-08 10:16:56 +01:00
parent 9712065a6b
commit 803b2aa34d

View file

@ -26,19 +26,22 @@
this.module.on('click', 'table.bp.process > tbody > tr:first-child > td > a:last-child', this.processTitleClick);
this.module.on('click', 'table.bp > tbody > tr:first-child > th', this.processOperatorClick);
this.module.on('focus', 'form input, form textarea, form select', this.formElementFocus);
this.module.on('mouseenter', 'table.bp > tbody > tr > td > a', this.procMouseOver);
this.module.on('mouseenter', 'table.bp > tbody > tr > th', this.procMouseOver);
this.module.on('mouseenter', 'table.node.missing > tbody > tr > td > span', this.procMouseOver);
this.module.on('mouseleave', 'div.bp', this.procMouseOut);
this.module.icinga.logger.debug('BP module loaded');
this.module.icinga.logger.debug('BP module initialized');
},
onRendered: function (event) {
var $container = $(event.currentTarget);
this.fixFullscreen($container);
this.fixOpenedBps($container);
this.highlightFormErrors($container);
this.hideInactiveFormDescriptions($container);
},
processTitleClick: function (event) {
@ -70,6 +73,10 @@
}
},
hideInactiveFormDescriptions: function($container) {
$container.find('dd').not('.active').find('p.description').hide();
},
/**
* Add 'hovered' class to hovered title elements
*
@ -202,7 +209,52 @@
}
this.idCache[$bpName] = ids;
},
/** BEGIN Form handling, borrowed from Director **/
formElementFocus: function(ev)
{
var $input = $(ev.currentTarget);
var $dd = $input.closest('dd');
$dd.find('p.description').show();
if ($dd.attr('id') && $dd.attr('id').match(/button/)) {
return;
}
var $li = $input.closest('li');
var $dt = $dd.prev();
var $form = $dd.closest('form');
$form.find('dt, dd, li').removeClass('active');
$li.addClass('active');
$dt.addClass('active');
$dd.addClass('active');
$dd.find('p.description.fading-out')
.stop(true)
.removeClass('fading-out')
.fadeIn('fast');
$form.find('dd').not($dd)
.find('p.description')
.not('.fading-out')
.addClass('fading-out')
.delay(2000)
.fadeOut('slow', function() {
$(this).removeClass('fading-out').hide()
});
},
highlightFormErrors: function($container)
{
$container.find('dd ul.errors').each(function(idx, ul) {
var $ul = $(ul);
var $dd = $ul.closest('dd');
var $dt = $dd.prev();
$dt.addClass('errors');
$dd.addClass('errors');
});
}
/** END Form handling **/
};
Icinga.availableModules.businessprocess = Bp;