changeset 8:be339aa223bf

tag/filter autocompelte Ignore-this: f6235de879c1ce62a8fc41e890edd0d2
author Drew Perttula <drewp@bigasterisk.com>
date Wed, 06 Mar 2013 23:22:24 -0800
parents 93d94f327e82
children 7df920c18c83
files static/gui.js
diffstat 1 files changed, 20 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/static/gui.js	Wed Mar 06 23:18:39 2013 -0800
+++ b/static/gui.js	Wed Mar 06 23:22:24 2013 -0800
@@ -1,6 +1,10 @@
 
 $("#filterTag").focus();
 
+var model = {
+    filterTags: ko.observableArray(currentFilter())
+};
+
 function currentFilter() {
     var p = window.location.pathname;
     var comps = p.split("/");
@@ -19,7 +23,11 @@
     } else {
         selected.splice(selected.indexOf(tag), 1);
     }
+    setPageTags(selected);
+}
 
+function setPageTags(tags) {
+    
     var newPath = window.location.pathname;
     if (toRoot == ".") {
         newPath += "/";
@@ -28,8 +36,8 @@
                 /(.*\/)[^\/]*$/, "$1")
     }
     console.log("user root", newPath);
-    if (selected.length) {
-        newPath += selected.join("+")
+    if (tags.length) {
+        newPath += tags.join("+")
     } else {
         newPath = newPath.substr(0, newPath.length - 1);
     }
@@ -55,8 +63,8 @@
 });
 
 $("#filterTag").change(function () {
-    var tag = $(this).val();
-    toggleTag(tag);
+    var tags = $(this).val();
+    setPageTags(tags);
     return false;
 });
 
@@ -65,3 +73,11 @@
         backspaceLastTag();
     }
 });
+
+$("#filterTag").chosen({
+
+    });
+
+ko.applyBindings(model);
+$("#filterTag").trigger("liszt:updated");
+