More fixes

This commit is contained in:
Alejandro Gallardo Escobar 2014-12-17 20:12:21 +01:00
parent 8b43643fa1
commit 2828c76ffa
2 changed files with 25 additions and 20 deletions

View File

@ -36,7 +36,7 @@ TreeController = {
} }
// Load branch // Load branch
function _processGroup (container, detailContainer, elements, baseURL, rootGroup) { function _processGroup (container, elements, rootGroup) {
var $group = $("<ul></ul>"); var $group = $("<ul></ul>");
// First group // First group
@ -44,7 +44,7 @@ TreeController = {
$group $group
.addClass("tree-root") .addClass("tree-root")
.hide() .hide()
.prepend('<img src="'+(baseURL.length > 0 ? baseURL : '')+'images/pandora.ico.gif" />'); .prepend('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')+'images/pandora.ico.gif" />');
} }
// Normal group // Normal group
else { else {
@ -61,13 +61,13 @@ TreeController = {
elements.forEach(function(element, index) { elements.forEach(function(element, index) {
lastNode = index == elements.length - 1 ? true : false; lastNode = index == elements.length - 1 ? true : false;
firstNode = rootGroup && index == 0 ? true : false; firstNode = rootGroup && index == 0 ? true : false;
element.jqObject = _processNode($group, detailContainer, element, lastNode, firstNode); element.jqObject = _processNode($group, element, lastNode, firstNode);
}, $group); }, $group);
return $group; return $group;
} }
// Load leaf // Load leaf
function _processNode (container, detailContainer, element, lastNode, firstNode) { 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>");
@ -89,7 +89,7 @@ TreeController = {
break; break;
} }
// If exist the detail container, show the data // If exist the detail container, show the data
if (typeof detailContainer != 'undefined' && detailContainer.length > 0) { if (typeof controller.detailRecipient != 'undefined' && controller.detailRecipient.length > 0) {
$content.click(function (e) { $content.click(function (e) {
TreeNodeDetailController.getController().init({ TreeNodeDetailController.getController().init({
recipient: controller.detailRecipient, recipient: controller.detailRecipient,
@ -120,7 +120,7 @@ TreeController = {
$node.addClass("leaf-closed"); $node.addClass("leaf-closed");
// Add children // Add children
var $children = _processGroup($node, detailContainer, element.children, this.baseURL); var $children = _processGroup($node, element.children);
$node.data('children', $children); $node.data('children', $children);
$leafIcon.click(function () { $leafIcon.click(function () {
@ -171,7 +171,7 @@ TreeController = {
if (data.success) { if (data.success) {
$node.addClass("leaf-open"); $node.addClass("leaf-open");
var $children = _processGroup($node, detailContainer, data.tree, controller.baseURL); var $children = _processGroup($node, data.tree);
$children.slideDown(); $children.slideDown();
$node.data('children', $children); $node.data('children', $children);
@ -210,20 +210,20 @@ TreeController = {
return $node; return $node;
} }
if (this.recipient.length == 0) { if (controller.recipient.length == 0) {
return; return;
} }
else if (this.tree.length == 0) { else if (controller.tree.length == 0) {
this.recipient.html("<div>" + this.emptyMessage + "</div>"); controller.recipient.html("<div>" + controller.emptyMessage + "</div>");
return; return;
} }
this.recipient.empty(); controller.recipient.empty();
var $children = _processGroup(this.recipient, this.detailContainer, this.tree, this.baseURL, true); var $children = _processGroup(this.recipient, this.tree, true);
$children.show(); $children.show();
this.recipient.data('children', $children); controller.recipient.data('children', $children);
}, },
load: function () { load: function () {
this.reload(); this.reload();
@ -257,7 +257,7 @@ TreeController = {
if (typeof data.ajaxPage != 'undefined' && data.ajaxPage.length > 0) { if (typeof data.ajaxPage != 'undefined' && data.ajaxPage.length > 0) {
this.ajaxPage = data.ajaxPage; this.ajaxPage = data.ajaxPage;
} }
if (typeof data.filter != 'undefined' && data.filter.length > 0) { if (typeof data.filter != 'undefined') {
this.filter = data.filter; this.filter = data.filter;
} }
@ -328,7 +328,7 @@ TreeNodeDetailController = {
type: 'POST', type: 'POST',
dataType: 'json', dataType: 'json',
data: { data: {
page: this.ajaxURL, page: this.ajaxPage,
getDetail: 1, getDetail: 1,
type: this.type, type: this.type,
id: this.id id: this.id
@ -440,6 +440,8 @@ TreeNodeDetailController = {
this.ajaxPage = data.ajaxPage; this.ajaxPage = data.ajaxPage;
} }
if (typeof TreeNodeDetailController.controllers[this.type] == 'undefined')
TreeNodeDetailController.controllers[this.type] = {};
TreeNodeDetailController.controllers[this.type][this.id] = this; TreeNodeDetailController.controllers[this.type][this.id] = this;
this.load(); this.load();
}, },

View File

@ -124,6 +124,8 @@ ui_require_javascript_file("TreeController", "include/javascript/tree/");
html_print_image('images/spinner.gif', false, array('class' => "loading_tree")); html_print_image('images/spinner.gif', false, array('class' => "loading_tree"));
echo "<div id='tree-controller-recipient'>"; echo "<div id='tree-controller-recipient'>";
echo "</div>"; echo "</div>";
echo "<div id='tree-controller-detail-recipient'>";
echo "</div>";
?> ?>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
@ -147,18 +149,19 @@ echo "</div>";
treeController.init({ treeController.init({
recipient: $("div#tree-controller-recipient"), recipient: $("div#tree-controller-recipient"),
detailRecipient: $("div#tree-controller-detail-recipient"),
page: page, page: page,
tree: data.tree, tree: data.tree,
baseURL: "<?php echo $config['homeurl']; ?>/", baseURL: "<?php echo $config['homeurl']; ?>/",
ajaxURL: "<?php echo $config['homeurl']; ?>/ajax.php" ajaxURL: "<?php echo $config['homeurl']; ?>/ajax.php",
filter: {
search: "<?php echo $tab; ?>",
status: "<?php echo $status; ?>"
}
}); });
} }
}, },
dataType: "json" dataType: "json"
}); });
}); });
</script> </script>