timeline/js/timeline.js
changeset 103 b9a417017e19
parent 102 2f1ef2ded30c
child 104 3fef455d214a
--- a/timeline/js/timeline.js	Fri Oct 04 15:39:08 2013 +0200
+++ b/timeline/js/timeline.js	Fri Oct 04 16:01:38 2013 +0200
@@ -621,6 +621,13 @@
                 });
                 _this.editing_occurrence.editing = true;
                 _this.$.find(".Tl-Details").html(Mustache.to_html(Tlns.Templates.OccurrenceDetails, _this.editing_occurrence));
+                _this.$.find(".Tl-Detail-Favorite").click(function() {
+                    _this.editing_occurrence.toggleFavorite();
+                }).hover(function() {
+                    $(this)[_this.editing_occurrence.isFavorite ? "removeClass" : "addClass" ]("Tl-Detail-isFavorite");
+                }, function() {
+                    $(this)[_this.editing_occurrence.isFavorite ? "addClass" : "removeClass"]("Tl-Detail-isFavorite");
+                });
             }
             _this.throttledDrawGrid();
         }
@@ -731,3 +738,12 @@
 Tlns.Classes.Occurrence.prototype.toString = function() {
     return "Occurrence " + this.type + ': "' + this.title + '"';
 };
+
+Tlns.Classes.Occurrence.prototype.toggleFavorite = function() {
+    var newFavStatus = !this.isFavorite;
+    /* Add API Call HERE */
+    
+    /* The Following status update should be moved to the SUCCESS callback of the API call */
+    this.isFavorite = newFavStatus;
+    this.timeline.throttledDrawGrid();
+};