Commits

Anonymous committed e18f350

imrpoved tag cloud click interface.

Comments (0)

Files changed (3)

src/django_website/templates/aggregator/feeditem_list.html

     {% load tagging_tags %}
     {% tag_cloud_for_model aggregator.FeedItem as items_tags %}
     {% for tag in items_tags %}
-        <a href="javascript:items.get('{{tag.name}}');" class="cloud-size-{{tag.font_size}}">{{tag.name}}</a>&nbsp;
+        <a href="javascript:items.get('{{tag.name}}');" class="cloud-size-{{tag.font_size}}" id="tag-{{tag.name}}">{{tag.name}}</a>&nbsp;
     {% endfor %}
 </div>
 <h2 class="deck">This page, updated every hour, aggregates blog entries by people who are
-writing about Django.</h2>
+writing about Django.</h2> 
 <div id="items">
-{% include "aggregator/just_list.html" %}
 </div>
+<script type="text/javascript">
+    items.get();
+</script>
 {% endblock %}
 #content-main a:link, #content-main a:visited { color:#ab5603; text-decoration:underline; }
 #content-secondary a:link, #content-secondary a:visited { color:#ffc757; text-decoration:none; }
 a:hover { color:#ffe761; }
-#content-main a:hover { background-color:#E0FFB8; color:#234f32; text-decoration:none; }
+#content-main a:hover, .selected-tag { background-color:#E0FFB8; color:#234f32; text-decoration:none; }
 #content-secondary a:hover { color:#ffe761; background:none; }
 #content-main h2 a, #content-main h3 a { text-decoration:none !important; }
 
     items.headline - e.g. "Community Articles"
     items.url - the url that returns a list of item. In django use "{% url foo_items_list %}"
 */
-var items = {
+var items = 
+{
     page: 1,
-
+    
     pull: function () {
         context = {page:this.page}
         if (typeof this.tag != 'undefined')
         this.page++;
         this.pull();
     },
-        
+    tagExists: function () {
+        return (typeof this.tag != 'undefined') ;
+    },
+         
     get: function (tag) {
-        this.page = 1;
-        if (typeof tag != 'undefined') 
+        this.page = 1;        
+        /* 
+        ** #tags 
+        ** if given 
+        **   if exist
+        **     if caurent
+        **       remove tag
+        **     else
+        **       set tag and show selection
+        **   else
+        **       set tag and show slection  
+        */
+        if (this.tagExists())
         {
-            this.tag = tag;
-            $("#content-main h1").html(this.headline + " on " + tag + " (<a href='javascript:items.get()'>All</a>)");
+            if (this.tag == tag)
+            {
+                $("#tag-" + this.tag).removeClass("selected-tag");
+                delete this.tag;
+            }
+            else 
+            {
+                $("#tag-" + this.tag).removeClass("selected-tag");
+                this.tag = tag;
+                $("#tag-" + tag).addClass("selected-tag");
+            }
         }
         else 
         {
-            delete this.tag;
-            $("#content-main h1").html(this.headline);
+            this.tag = tag;
+            $("#tag-" + tag).addClass("selected-tag");
         }
         this.pull();
-    },
+    }
 }