MDL-46116 mod_imscp: List children if no content in item.
authorDavid Balch <david.balch@conted.ox.ac.uk>
Tue, 11 Nov 2014 18:34:31 +0000 (18:34 +0000)
committerDavid Balch <david.balch@conted.ox.ac.uk>
Tue, 11 Nov 2014 18:34:31 +0000 (18:34 +0000)
mod/imscp/module.js
mod/imscp/styles.css

index a3ee2d1..e5a482f 100644 (file)
@@ -56,6 +56,30 @@ M.mod_imscp.init = function(Y) {
                     obj.setAttribute('type', 'text/html');
                     obj.setAttribute('data', node.href);
                 }
+            } else {
+                // No href, so create links to children.
+                var obj = document.createElement('div');
+                obj.setAttribute('id', 'imscp_child_list');
+
+                var title = document.createElement('h2');
+                title.appendChild(document.createTextNode(node.label));
+                title.setAttribute('class', 'sectionname');
+                obj.appendChild(title);
+
+                var ul = document.createElement('ul');
+                obj.appendChild(ul);
+                for (var i = 0; i < node.children.length; i++) {
+                    var childnode = node.children[i];
+                    var li = document.createElement('li');
+                    var a = document.createElement('a');
+                    a.appendChild(document.createTextNode(childnode.label));
+                    a.setAttribute('id', 'ref_' + childnode.index);
+                    Y.YUI2.util.Event.addListener(a, "click", function () {
+                        imscp_activate_item_by_index(this.id.substr(4));
+                    });
+                    ul.appendChild(li);
+                    li.appendChild(a);
+                }
             }
             var old = Y.YUI2.util.Dom.get('imscp_object');
             if (old) {
index 7fbb568..7f8b24a 100644 (file)
 
 #page-mod-imscp-view .yui-layout-hd h2 {
  color: black;
-}
\ No newline at end of file
+}
+
+.path-mod-imscp #imscp_child_list {
+ margin-left: 1em;
+ width: auto;
+ height: auto;
+}