JS: Add code documentation
This commit is contained in:
parent
168cc33a69
commit
d3e4fb6552
|
@ -1,4 +1,4 @@
|
|||
/*! Icinga Web 2 | (c) 2016 Icinga Development Team | GPLv2+ */
|
||||
/*! Icinga Web 2 | (c) 2018 Icinga Development Team | GPLv2+ */
|
||||
|
||||
;(function(Icinga, $) {
|
||||
|
||||
|
@ -9,6 +9,13 @@
|
|||
var defaultNumOfRows = 2;
|
||||
var defaultHeight = 36;
|
||||
|
||||
/**
|
||||
* Behavior for collapsible containers. Creates collapsible containers from `<div class="collapsible-container">…</div>`
|
||||
* or <div class="collapsible-container"><div class="collapsible">…</div></div>`
|
||||
*
|
||||
* @param icinga Icinga The current Icinga Object
|
||||
*/
|
||||
|
||||
function CollapsibleContainer(icinga) {
|
||||
Icinga.EventListener.call(this, icinga);
|
||||
|
||||
|
@ -18,6 +25,11 @@
|
|||
|
||||
CollapsibleContainer.prototype = new Icinga.EventListener();
|
||||
|
||||
/**
|
||||
* Initializes all collapsible-container elements. Triggered on rendering of a container.
|
||||
*
|
||||
* @param event Event The `onRender` event triggered by the rendered container
|
||||
*/
|
||||
CollapsibleContainer.prototype.onRendered = function(event) {
|
||||
$(event.target).find('.collapsible-container').each(function() {
|
||||
var $this = $(this);
|
||||
|
@ -56,6 +68,11 @@
|
|||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Event handler for clocking collapsible control. Toggles the collapsed state of the respective container.
|
||||
*
|
||||
* @param event Event The `onClick` event triggered by the clicked collapsible-control element
|
||||
*/
|
||||
CollapsibleContainer.prototype.onControlClicked = function(event) {
|
||||
var $target = $(event.target);
|
||||
var $c = $target.closest('.collapsible-container, .collapsible-table-container');
|
||||
|
@ -72,7 +89,13 @@
|
|||
updateCollapsedState($c);
|
||||
};
|
||||
|
||||
function updateCollapsedState($container, listener) {
|
||||
/**
|
||||
* Renders the collapse state of the given container. Adds or removes class `collapsible` to containers and sets the
|
||||
* height.
|
||||
*
|
||||
* @param $container jQuery The given collapsible container element
|
||||
*/
|
||||
function updateCollapsedState($container) {
|
||||
var $collapsible;
|
||||
if ($container.hasClass('has-collapsible')) {
|
||||
$collapsible = $container.find('.collapsible');
|
||||
|
|
Loading…
Reference in New Issue