Skip to content
Browse files

WIP: Getting siblings

  • Loading branch information...
1 parent d5b3953 commit a5a0bab37d0997db859f94e0e2d39547da622ab4 Carlos Mantilla committed
Showing with 51 additions and 12 deletions.
  1. +36 −1 Gruntfile.js
  2. +15 −11 template/pageFull.html
View
37 Gruntfile.js
@@ -471,7 +471,8 @@ module.exports = function (grunt) {
nodesAttachments = [],
firstNode,
tree = {},
- brain;
+ brain,
+ siblings;
src.path = grunt.config.get('CDL.src');
dest.path = grunt.config.get('CDL.dest');
@@ -819,6 +820,34 @@ module.exports = function (grunt) {
return (node.type === 'chronological') ? node.chronologicalName : (node.type === 'bastard') ? node.bastardName : node.name;
}
+ /**
+ * From an array of nodes links we get the information of each sibling node.
+ *
+ * @param childs
+ * @returns {*}
+ */
+ function setSiblingsInfo(childs) {
+ var key,
+ siblings = [];
+
+ _.each(childs, function(child) {
+
+ if (child.dir === '1') {
+ key = child.idB;
+ }
+ else if (child.dir === '2') {
+ key = child.idA;
+ }
+ siblings.push(nodesIndexed[key]);
+
+ });
+
+
+
+
+ return siblings;
+ }
+
/**
* Reorder the childs properties according dir: (Brain direction), type: chronological, bastard and default.
@@ -832,6 +861,7 @@ module.exports = function (grunt) {
var childsOrdered = [],
chronologicalChilds;
+ siblings = setSiblingsInfo(childs);
// Parse child.
_.each(childs, function(child) {
@@ -856,6 +886,11 @@ module.exports = function (grunt) {
child.node.parent.name = getName(parent);
}
+ // Get the siblings nodes.
+ child.node.siblings = _.filter(siblings, function(sibling) {
+ return sibling.guid !== child.node.guid;
+ });
+
// Set parent guid.
child.node.hasChronologicalChildren = false;
View
26 template/pageFull.html
@@ -132,17 +132,7 @@
{% if page.siblings == empty %}
<div id="menu-nodes">
<div class="navigation-node">
- <div class="navigation-parent">
- {% if page.parent %}
- <div class="navigation-list">
- <ul class="nav nav-tabs">
- <li>
- <a href="{{ BASE_PATH }}/pages/{{ page.parent.guid }}">{{ page.parent.name | upcase }}</a><a class="node-link" href="{{ BASE_PATH }}/pages/{{ page.parent.guid }}"><img src="{{ BASE_PATH }}/images/link.png" alt="node-link"/></a>
- </li>
- </ul>
- </div>
- {% endif %}
- </div>
+
<div class="navigation-children">
{% if page.children != empty %}
<div class="navigation-list">
@@ -167,6 +157,20 @@
</div>
{% endif %}
</div>
+
+
+
+ <div class="navigation-parent">
+ {% if page.parent %}
+ <div class="navigation-list">
+ <ul class="nav nav-tabs">
+ <li>
+ <a href="{{ BASE_PATH }}/pages/{{ page.parent.guid }}">{{ page.parent.name | upcase }}</a><a class="node-link" href="{{ BASE_PATH }}/pages/{{ page.parent.guid }}"><img src="{{ BASE_PATH }}/images/link.png" alt="node-link"/></a>
+ </li>
+ </ul>
+ </div>
+ {% endif %}
+ </div>
</div>
</div>
{% endif %}

0 comments on commit a5a0bab

Please sign in to comment.
Something went wrong with that request. Please try again.