Add "empty" class if group is empty.

This commit is contained in:
Michael Jumper
2013-08-15 03:07:35 -07:00
parent 9de0d7a299
commit 5ecf224e09
2 changed files with 23 additions and 6 deletions

View File

@@ -832,7 +832,7 @@ GuacUI.Download = function(filename) {
* A grouping component. Child elements can be added via the addElement()
* function. By default, groups display as collapsed.
*/
GuacUI.ListGroup = function(caption) {
GuacUI.ListGroup = function(caption, icon) {
/**
* Reference to this group.
@@ -840,14 +840,21 @@ GuacUI.ListGroup = function(caption) {
*/
var guac_group = this;
/**
* Whether this group is empty.
* @private
*/
var empty = true;
/**
* A container for for the list group itself.
*/
var element = GuacUI.createElement("div", "group");
var element = GuacUI.createElement("div", "group empty");
// Create connection display elements
var caption_element = GuacUI.createChildElement(element, "div", "caption");
var caption_icon = GuacUI.createChildElement(caption_element, "div", "icon group");
if (icon) GuacUI.createChildElement(caption_element, "div", "icon " + icon);
GuacUI.createChildElement(caption_element, "span", "name").textContent = caption;
/**
@@ -877,11 +884,17 @@ GuacUI.ListGroup = function(caption) {
/**
* Adds an element as a child of this group.
*
* @param {
*/
this.addElement = function(element) {
elements.appendChild(element);
this.addElement = function(child) {
// Mark as non-empty
if (empty) {
GuacUI.removeClass(element, "empty");
empty = false;
}
elements.appendChild(child);
};
/**

View File

@@ -438,6 +438,10 @@ div.section {
background-image: url('../images/group-icons/guac-open.png');
}
.group.empty > .caption .icon.group {
visibility: hidden;
}
/*
* Settings formatting
*/