Treesearch and interface update.

These are the changes requested in the meeting.
+ Moved some of the pieces of the results navigation
+ Modified tree search behavior

Change-Id: I5adf6a0c23101a1f87d45a5824b7e4d17ba7ad8e
diff --git a/client/catalog-dev/js/catalog.js b/client/catalog-dev/js/catalog.js
index 5b953d8..1e4866c 100644
--- a/client/catalog-dev/js/catalog.js
+++ b/client/catalog-dev/js/catalog.js
@@ -170,9 +170,25 @@
       scope.autoComplete(path, function(data){
         var list = data.next;
         var last = (data.lastComponent === true);
+
+        if (last) {
+          console.log("Redirecting last element request to a search.");
+          scope.clearResults();
+          scope.query(scope.catalog, {'??': path},
+          function(interest, data){
+            console.log("Search response", interest, data);
+            scope.name = data.getContent().toString().replace(/[\n\0]+/g, '');
+            scope.getResults(0);
+          }, function(interest){
+            console.warn("Failed to retrieve final component.", interest, path);
+            scope.createAlert("Failed to request final component. " + path + " See console for details.");
+          });
+          return; //Don't call the callback
+        }
+
         console.log("Autocomplete response", list);
         callback(list.map(function(element){
-          return (path == "/"?"/":"") + element + (!last?"/":"");
+          return (path == "/"?"/":"") + element + "/";
         }));
       })
     });
@@ -184,7 +200,7 @@
 
       var path = t.parent().parent().attr('id');
 
-      console.log("Stringing tree search:", path);
+      console.log("Tree search:", path);
 
       scope.query(scope.catalog, {'??': path},
       function(interest, data){ //Success
diff --git a/client/catalog-dev/js/treeExplorer.js b/client/catalog-dev/js/treeExplorer.js
index c4bee42..58a6a69 100644
--- a/client/catalog-dev/js/treeExplorer.js
+++ b/client/catalog-dev/js/treeExplorer.js
@@ -38,8 +38,8 @@
           var el = $('<div class="treeExplorerNode"></div>');
           if (current.match(/\/$/)){
             el.attr('id', path + current);
-            el.append(['<div class="nodeContent"><a href="#', path, current, '">', current,
-              '</a>&nbsp;<button class="treeSearch btn btn-success btn-xs">Search from here</button></div>'].join(""));
+            el.append(['<div class="nodeContent"><a class="treeExplorerExpander"></a><a class="treeSearch" href="#', path, current, '">', current,
+              '</a></div>'].join(""));
           } else {
             el.addClass('file');
             el.text(current);
@@ -50,7 +50,7 @@
 
       var scope = this;
 
-      tree.on('click', '.treeExplorerNode > .nodeContent > a', function(e){
+      tree.on('click', '.treeExplorerExpander', function(e){
         if (!scope.settings.autoScroll){
           e.preventDefault();
         }