' +
+ //TODO: Remove more of the binding from this template and move the DOM manipulation to be manually done in the link function,
+ // this will greatly improve performance since there's potentially a lot of nodes being rendered = a LOT of watches!
+
+ template: '
' +
+ '' +
//NOTE: This ins element is used to display the search icon if the node is a container/listview and the tree is currently in dialog
- '
' +
- '
' +
- '
' +
+ //'
' +
+ '
' +
+ '
' +
//NOTE: If the tree supports check boxes, render different markup
- '
' +
- '
' +
- '
' +
- '
' +
+ '
' +
+ '
' +
+ '
' +
+ //NOTE: These are the 'option' elipses
+ '
' +
'
' +
'
' +
'',
-
+
link: function (scope, element, attrs) {
localizationService.localize("general_search").then(function (value) {
@@ -61,12 +66,44 @@ angular.module("umbraco.directives")
}
}
- /** updates the node's styles */
- function styleNode(node) {
- node.stateCssClass = (node.cssClasses || []).join(" ");
+ /** updates the node's DOM/styles */
+ function setupNodeDom(node, tree) {
+
+ //get the first div element
+ element.children(":first")
+ //set the padding
+ .css("padding-left", (node.level * 20) + "px")
+ //set the class
+ .addClass((node.cssClasses || []).join(" "));
+
+ //remove first 'ins' if there is no children
+ //show/hide last 'ins' depending on children
+ if (!node.hasChildren) {
+ element.find("ins:first").remove();
+ element.find("ins").last().hide();
+ }
+ else {
+ element.find("ins").last().show();
+ }
+
+ //add/remove 'i' depending on enablecheckboxes
+ if (tree.enablecheckboxes === "true") {
+ element.find("i").eq(1).remove();
+ element.find("i:first").attr("title", node.routePath);
+ }
+ else if (!tree.enablecheckboxes || tree.enablecheckboxes === 'false') {
+ element.find("i:first").remove();
+ element.find("i").eq(1).attr("title", node.routePath);
+ }
+
+ element.find("a:first").html(node.name);
+
+ if (!node.menuUrl) {
+ element.find("a:last").remove();
+ }
if (node.style) {
- $(element).find("i:first").attr("style", node.style);
+ element.find("i:first").attr("style", node.style);
}
}
@@ -93,7 +130,7 @@ angular.module("umbraco.directives")
scope.node.updateNodeData = function (newNode) {
_.extend(scope.node, newNode);
//now update the styles
- styleNode(scope.node);
+ setupNodeDom(scope.node, scope.tree);
};
/**
@@ -126,10 +163,6 @@ angular.module("umbraco.directives")
emitEvent("treeNodeAltSelect", { element: element, tree: scope.tree, node: n, event: ev });
};
- scope.searchNode = function (n, ev) {
- emitEvent("treeNodeSearch", { element: element, tree: scope.tree, node: n, event: ev });
- };
-
/** method to set the current animation for the node.
* This changes dynamically based on if we are changing sections or just loading normal tree data.
* When changing sections we don't want all of the tree-ndoes to do their 'leave' animations.
@@ -178,20 +211,11 @@ angular.module("umbraco.directives")
node.expanded = true;
enableDeleteAnimations();
}
- };
-
- /**
- Helper method for setting correct element padding on tree DOM elements
- Since elements are not children of eachother, we need this indenting done
- manually
- */
- scope.setTreePadding = function (node) {
- return { 'padding-left': (node.level * 20) + "px" };
- };
+ };
//if the current path contains the node id, we will auto-expand the tree item children
- styleNode(scope.node);
+ setupNodeDom(scope.node, scope.tree);
var template = '
';
var newElement = angular.element(template);