another tweak to the searchBox : the visualization is cleared when the searchbox
is empty.
--- a/src/js/widgets/playerWidget.js Wed Oct 26 15:46:19 2011 +0200
+++ b/src/js/widgets/playerWidget.js Wed Oct 26 16:20:17 2011 +0200
@@ -177,9 +177,14 @@
/* this handler is called whenever the content of the search
field changes */
IriSP.PlayerWidget.prototype.searchHandler = function() {
-
this._searchLastValue = this.selector.find("#LdtSearchInput").attr('value');
- this._Popcorn.trigger("IriSP.search", this._searchLastValue);
+
+ // do nothing if the search field is empty, instead of highlighting everything.
+ if (this._searchLastValue == "") {
+ this._Popcorn.trigger("IriSP.search.cleared");
+ } else {
+ this._Popcorn.trigger("IriSP.search", this._searchLastValue);
+ }
};
/*
--- 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