src/js/widgets/segmentsWidget.js
branchpopcorn-port
changeset 154 6e115a094858
parent 152 5950ab2855a8
child 157 73bce42a3ed3
--- a/src/js/widgets/segmentsWidget.js	Wed Oct 26 15:46:19 2011 +0200
+++ b/src/js/widgets/segmentsWidget.js	Wed Oct 26 16:20:17 2011 +0200
@@ -7,6 +7,7 @@
   // event handlers
   this._Popcorn.listen("IriSP.search", function(searchString) { self.searchHandler.call(self, searchString); });
   this._Popcorn.listen("IriSP.search.closed", function() { self.searchFieldClosedHandler.call(self); });
+  this._Popcorn.listen("IriSP.search.cleared", function() { self.searchFieldClearedHandler.call(self); });
 };
 
 IriSP.SegmentsWidget.prototype = new IriSP.Widget();
@@ -72,6 +73,19 @@
   } 
 };
 
+/* restores the view after a search */
+IriSP.SegmentsWidget.prototype.clear = function() {
+  // reinit the fields
+  for (var id in this.oldSearchMatches) {     
+      
+      IriSP.jQuery("#"+id).dequeue();
+			IriSP.jQuery("#"+id).animate({height:0},100);	
+			IriSP.jQuery("#"+id).css('border','0px');
+			IriSP.jQuery("#"+id).css('border-color','red');
+			IriSP.jQuery("#"+id).animate({opacity:0.3},100);
+  }   
+};
+
 IriSP.SegmentsWidget.prototype.clickHandler = function(annotation) {
   var begin = Math.round((+ annotation.begin) / 1000);
   this._Popcorn.currentTime(begin)
@@ -108,16 +122,10 @@
   this.oldSearchMatches = matches;
 };
 
+IriSP.SegmentsWidget.prototype.searchFieldClearedHandler = function() {
+  this.clear();
+};
+
 IriSP.SegmentsWidget.prototype.searchFieldClosedHandler = function() {
-  // reinit the fields
-  for (var id in this.oldSearchMatches) {     
-      
-      IriSP.jQuery("#"+id).dequeue();
-			IriSP.jQuery("#"+id).animate({height:0},100);	
-			IriSP.jQuery("#"+id).css('border','0px');
-			IriSP.jQuery("#"+id).css('border-color','red');
-			IriSP.jQuery("#"+id).animate({opacity:0.3},100);
-  }
-  
-  
+  this.clear();
 };
\ No newline at end of file