# HG changeset patch # User hamidouk # Date 1323080923 -3600 # Node ID d1883378b822da8af15a4ef0953cf74f3c4a45a3 # Parent eb54152c2cfaa0ae784cbc43b47aaa1ebc4b8447 renamed search signal. diff -r eb54152c2cfa -r d1883378b822 src/js/widgets/playerWidget.js --- a/src/js/widgets/playerWidget.js Mon Dec 05 10:49:52 2011 +0100 +++ b/src/js/widgets/playerWidget.js Mon Dec 05 11:28:43 2011 +0100 @@ -24,8 +24,8 @@ this._Popcorn.listen("play", IriSP.wrap(this, this.playButtonUpdater)); this._Popcorn.listen("pause", IriSP.wrap(this, this.playButtonUpdater)); this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.timeDisplayUpdater)); - this._Popcorn.listen("IriSP.SegmentsWidget.matchFound", IriSP.wrap(this, this.searchMatch)); - this._Popcorn.listen("IriSP.SegmentsWidget.noMatchFound", IriSP.wrap(this, this.searchNoMatch)); + this._Popcorn.listen("IriSP.search.matchFound", IriSP.wrap(this, this.searchMatch)); + this._Popcorn.listen("IriSP.search.noMatchFound", IriSP.wrap(this, this.searchNoMatch)); this.selector.find(".Ldt-CtrlPlay").click(function() { self.playHandler.call(self); }); @@ -124,6 +124,12 @@ this._searchBlockOpen = true; this.selector.find(".LdtSearchInput").bind('keyup', null, function() { self.searchHandler.call(self); } ); + // we need this variable because some widget can find a match in + // their data while at the same time other's don't. As we want the + // search field to become green when there's a match, we need a + // variable to remember that we had one. + this._positiveMatch = false; + // tell the world the field is open this._Popcorn.trigger("IriSP.search.open"); @@ -136,6 +142,8 @@ // unbind the watcher event. this.selector.find(".LdtSearchInput").unbind('keypress set'); this._searchBlockOpen = false; + + this._positiveMatch = false; this._Popcorn.trigger("IriSP.search.closed"); } @@ -145,6 +153,7 @@ field changes */ IriSP.PlayerWidget.prototype.searchHandler = function() { this._searchLastValue = this.selector.find(".LdtSearchInput").attr('value'); + this._positiveMatch = false; // do nothing if the search field is empty, instead of highlighting everything. if (this._searchLastValue == "") { @@ -160,11 +169,13 @@ highlight a match. */ IriSP.PlayerWidget.prototype.searchMatch = function() { + this._positiveMatch = true; this.selector.find(".LdtSearchInput").css('background-color','#e1ffe1'); } /* the same, except that no value could be found */ IriSP.PlayerWidget.prototype.searchNoMatch = function() { - this.selector.find(".LdtSearchInput").css('background-color', "#d62e3a"); + if (this._positiveMatch !== true) + this.selector.find(".LdtSearchInput").css('background-color', "#d62e3a"); } diff -r eb54152c2cfa -r d1883378b822 src/js/widgets/polemicWidget.js --- a/src/js/widgets/polemicWidget.js Mon Dec 05 10:49:52 2011 +0100 +++ b/src/js/widgets/polemicWidget.js Mon Dec 05 11:28:43 2011 +0100 @@ -359,9 +359,9 @@ var matches = this._serializer.searchTweetsOccurences(searchString); if (IriSP.countProperties(matches) > 0) { - this._Popcorn.trigger("IriSP.PolemicWidget.matchFound"); + this._Popcorn.trigger("IriSP.search.matchFound"); } else { - this._Popcorn.trigger("IriSP.PolemicWidget.noMatchFound"); + this._Popcorn.trigger("IriSP.search.noMatchFound"); } for (var id in matches) { diff -r eb54152c2cfa -r d1883378b822 src/js/widgets/segmentsWidget.js --- a/src/js/widgets/segmentsWidget.js Mon Dec 05 10:49:52 2011 +0100 +++ b/src/js/widgets/segmentsWidget.js Mon Dec 05 11:28:43 2011 +0100 @@ -134,9 +134,9 @@ var matches = this._serializer.searchOccurences(searchString); if (IriSP.countProperties(matches) > 0) { - this._Popcorn.trigger("IriSP.SegmentsWidget.matchFound"); + this._Popcorn.trigger("IriSP.search.matchFound"); } else { - this._Popcorn.trigger("IriSP.SegmentsWidget.noMatchFound"); + this._Popcorn.trigger("IriSP.search.noMatchFound"); } // un-highlight all the blocks