Updated the tree style

This commit is contained in:
Alejandro Gallardo Escobar 2014-12-16 19:57:48 +01:00
parent a70df3c3e4
commit daca918ee6
2 changed files with 37 additions and 51 deletions

View File

@ -28,23 +28,34 @@ TreeController = {
return; return;
} }
function _processGroup (container, elements) { function _processGroup (container, elements, rootGroup) {
var $group = $("<ul></ul>"); var $group = $("<ul></ul>");
$group
.addClass("tree-group") if (typeof rootGroup != 'undefinded' && rootGroup == true) {
.hide(); $group
.addClass("tree-root")
.hide();
}
else {
rootGroup = false;
$group
.addClass("tree-group")
.hide();
}
container.append($group); container.append($group);
var last; var lastNode;
var firstNode;
elements.forEach(function(element, index) { elements.forEach(function(element, index) {
last = index == elements.length - 1 ? true : false; lastNode = index == elements.length - 1 ? true : false;
element.jqObject = _processNode($group, element, last); firstNode = rootGroup && index == 0 ? true : false;
element.jqObject = _processNode($group, element, lastNode, firstNode);
}, $group); }, $group);
return $group; return $group;
} }
function _processNode (container, element, last) { function _processNode (container, element, lastNode, firstNode) {
var $node = $("<li></li>"); var $node = $("<li></li>");
var $leafIcon = $("<div></div>"); var $leafIcon = $("<div></div>");
var $content = $("<div></div>"); var $content = $("<div></div>");
@ -68,9 +79,12 @@ TreeController = {
.append($leafIcon) .append($leafIcon)
.append($content); .append($content);
if (typeof last != 'undefinded' && last == true) { if (typeof lastNode != 'undefinded' && lastNode == true) {
$node.addClass("tree-last"); $node.addClass("tree-last");
} }
if (typeof firstNode != 'undefinded' && firstNode == true) {
$node.addClass("tree-first");
}
container.append($node); container.append($node);
@ -174,41 +188,10 @@ TreeController = {
this.recipient.empty(); this.recipient.empty();
var $loadingImage = $('<img src="images/spinner.gif" />'); var $children = _processGroup(this.recipient, this.tree, true);
var $children = _processGroup(this.recipient, this.tree);
$children.show(); $children.show();
this.recipient.data('children', $children); this.recipient.data('children', $children);
// $.ajax({
// url: this.ajaxURL,
// type: 'POST',
// dataType: 'json',
// data: {
// page: this.ajaxPage,
// getChildren: 1,
// type: element.type
// },
// complete: function(xhr, textStatus) {
// $loadingImage.remove();
// },
// success: function(data, textStatus, xhr) {
// if (data.success) {
// var $children = _processGroup(this.recipient, data.elements);
// $children.show();
// this.recipient.data('children', $children);
// }
// else {
// $loadingImage.remove();
// this.recipient.html("<div>" + this.errorMessage + "</div>");
// }
// },
// error: function(xhr, textStatus, errorThrown) {
// this.recipient.html("<div>" + this.errorMessage + "</div>");
// }
// });
}, },
load: function () { load: function () {
this.reload(); this.reload();
@ -217,16 +200,6 @@ TreeController = {
this.tree = tree; this.tree = tree;
this.reload(); this.reload();
}, },
addLeaf: function (leaf) {
// this.tree.unshift(leaf);
// this.reload();
},
removeLeaf: function (leafID) {
if (leafID != 0 && this.tree.length > 0) {
this.tree.splice(leafID, 1);
this.reload();
}
},
init: function (data) { init: function (data) {
if (typeof data.recipient != 'undefined' && data.recipient.length > 0) { if (typeof data.recipient != 'undefined' && data.recipient.length > 0) {
this.recipient = data.recipient; this.recipient = data.recipient;

View File

@ -2838,6 +2838,7 @@ table#policy_modules td * {
/* Tree view styles */ /* Tree view styles */
.tree-group { .tree-group {
margin-left: 16px; margin-left: 16px;
padding-top: 4px;
} }
.tree-node { .tree-node {
@ -2865,10 +2866,18 @@ table#policy_modules td * {
background-image: url(../../images/tree/last_expanded.png); background-image: url(../../images/tree/last_expanded.png);
} }
.tree-node.tree-first.leaf-open>.leaf-icon {
background-image: url(../../images/tree/first_expanded.png);
}
.tree-node.leaf-closed>.leaf-icon { .tree-node.leaf-closed>.leaf-icon {
background-image: url(../../images/tree/last_closed.png); background-image: url(../../images/tree/last_closed.png);
} }
.tree-node.tree-first.leaf-closed>.leaf-icon {
background-image: url(../../images/tree/first_closed.png);
}
.tree-node.leaf-loading>.leaf-icon { .tree-node.leaf-loading>.leaf-icon {
background-image: url(../../images/tree/last_expanded.png); background-image: url(../../images/tree/last_expanded.png);
} }
@ -2877,6 +2886,10 @@ table#policy_modules td * {
background-image: url(../../images/tree/last_leaf.png); background-image: url(../../images/tree/last_leaf.png);
} }
.tree-node.tree-first.leaf-empty>.leaf-icon {
background-image: url(../../images/tree/first_leaf.png);
}
.tree-node>.leaf-icon { .tree-node>.leaf-icon {
background-position: 0px 0px; background-position: 0px 0px;
background-repeat: no-repeat; background-repeat: no-repeat;