src/js/widgets/polemicWidget.js
branchpopcorn-port
changeset 528 a5894f09825a
parent 490 2a7fca4f0cc4
child 565 903435828e6c
equal deleted inserted replaced
527:90d77cc01ec0 528:a5894f09825a
    16  *  The fact that you are presently reading this means that you have had
    16  *  The fact that you are presently reading this means that you have had
    17  *  knowledge of the CeCILL-C license and that you accept its terms.
    17  *  knowledge of the CeCILL-C license and that you accept its terms.
    18 */
    18 */
    19 // CHART TIMELINE / VERSION PROTOTYPE  ::
    19 // CHART TIMELINE / VERSION PROTOTYPE  ::
    20 
    20 
       
    21 /** the polemic widget */
    21 IriSP.PolemicWidget = function(Popcorn, config, Serializer) {
    22 IriSP.PolemicWidget = function(Popcorn, config, Serializer) {
    22   IriSP.Widget.call(this, Popcorn, config, Serializer);
    23   IriSP.Widget.call(this, Popcorn, config, Serializer);
    23  
    24  
    24   this.userPol    = new Array();
    25   this.userPol    = new Array();
    25   this.userNoPol  = new Array();
    26   this.userNoPol  = new Array();
   352     
   353     
   353     this.selector.mouseleave(IriSP.wrap(this, function() { self.TooltipWidget.hide.call(self.TooltipWidget); }));
   354     this.selector.mouseleave(IriSP.wrap(this, function() { self.TooltipWidget.hide.call(self.TooltipWidget); }));
   354     this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.sliderUpdater));
   355     this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.sliderUpdater));
   355 }
   356 }
   356 
   357 
       
   358 /** update the positionMarker as time passes */
   357 IriSP.PolemicWidget.prototype.sliderUpdater = function() {
   359 IriSP.PolemicWidget.prototype.sliderUpdater = function() {
   358 
   360 
   359     var time = +this._Popcorn.currentTime();
   361     var time = +this._Popcorn.currentTime();
   360     var duration = +this._serializer.currentMedia().meta["dc:duration"];
   362     var duration = +this._serializer.currentMedia().meta["dc:duration"];
   361     
   363     
   362     this.paperSlider.attr("width", time * (this.width / (duration / 1000)));
   364     this.paperSlider.attr("width", time * (this.width / (duration / 1000)));
   363         
   365         
   364     this.sliderTip.attr("x", time * (this.width / (duration / 1000)));
   366     this.sliderTip.attr("x", time * (this.width / (duration / 1000)));
   365 };
   367 };
   366     
   368 
       
   369 /** reacts to IriSP.search events */    
   367 IriSP.PolemicWidget.prototype.searchHandler = function(searchString) {
   370 IriSP.PolemicWidget.prototype.searchHandler = function(searchString) {
   368   if (searchString == "")
   371   if (searchString == "")
   369     return;
   372     return;
   370 
   373 
   371   var matches = this._serializer.searchTweetsOccurences(searchString);
   374   var matches = this._serializer.searchTweetsOccurences(searchString);
   393   }
   396   }
   394   
   397   
   395   this.oldSearchMatches = matches;
   398   this.oldSearchMatches = matches;
   396 };
   399 };
   397 
   400 
       
   401 /** reacts to IriSP.search.cleared messages */
   398 IriSP.PolemicWidget.prototype.searchFieldClearedHandler = function() {
   402 IriSP.PolemicWidget.prototype.searchFieldClearedHandler = function() {
   399   // clean up the blocks that were in the previous search
   403   // clean up the blocks that were in the previous search
   400   // but who aren't in the current one.
   404   // but who aren't in the current one.
   401   for (var id in this.oldSearchMatches) {
   405   for (var id in this.oldSearchMatches) {
   402       var e = this.svgElements[id];
   406       var e = this.svgElements[id];
   403       e.attr({fill: e.color});
   407       e.attr({fill: e.color});
   404   }
   408   }
   405  
   409  
   406 };
   410 };
   407 
   411 
       
   412 /** reacts to IriSP.search.closed messages by clearing the highlighted elements */
   408 IriSP.PolemicWidget.prototype.searchFieldClosedHandler = function() {
   413 IriSP.PolemicWidget.prototype.searchFieldClosedHandler = function() {
   409   // clean up the blocks that were in the previous search
   414   // clean up the blocks that were in the previous search
   410   // but who aren't in the current one.
   415   // but who aren't in the current one.
   411   for (var id in this.oldSearchMatches) {
   416   for (var id in this.oldSearchMatches) {
   412       var e = this.svgElements[id];
   417       var e = this.svgElements[id];