src/js/widgets/segmentsWidget.js
branchpopcorn-port
changeset 223 f14172bdea28
parent 222 0f86664b470d
child 229 808768eb5930
equal deleted inserted replaced
222:0f86664b470d 223:f14172bdea28
    49     if (i == 0) {
    49     if (i == 0) {
    50 
    50 
    51       endPourcent -= onePxPercent;
    51       endPourcent -= onePxPercent;
    52     }
    52     }
    53     
    53     
    54     var divTitle		= annotation.content.title.substr(0,55);
    54     var divTitle = annotation.content.title.substr(0,55);
    55     var color = annotation.content.color
    55     var color = annotation.content.color
    56 
    56 
    57 
    57 
    58     var annotationTemplate = Mustache.to_html(IriSP.annotation_template,
    58     var annotationTemplate = Mustache.to_html(IriSP.annotation_template,
    59         {"divTitle" : divTitle, "id" : id, "startPourcent" : startPourcent,
    59         {"divTitle" : divTitle, "id" : id, "startPourcent" : startPourcent,
    87 IriSP.SegmentsWidget.prototype.clear = function() {
    87 IriSP.SegmentsWidget.prototype.clear = function() {
    88   // reinit the fields
    88   // reinit the fields
    89   for (var id in this.oldSearchMatches) {
    89   for (var id in this.oldSearchMatches) {
    90 
    90 
    91       IriSP.jQuery("#"+id).dequeue();
    91       IriSP.jQuery("#"+id).dequeue();
    92 			IriSP.jQuery("#"+id).animate({height:0},100);
    92 			IriSP.jQuery("#"+id).animate({height:0}, 100);
    93 			IriSP.jQuery("#"+id).css('border','0px');
    93 			IriSP.jQuery("#"+id).css('border-color','lightgray');
    94 			IriSP.jQuery("#"+id).css('border-color','red');
    94 			IriSP.jQuery("#"+id).animate({opacity:0.3}, 100);
    95 			IriSP.jQuery("#"+id).animate({opacity:0.3},100);
       
    96   }
    95   }
    97 };
    96 };
    98 
    97 
    99 IriSP.SegmentsWidget.prototype.clickHandler = function(annotation) {
    98 IriSP.SegmentsWidget.prototype.clickHandler = function(annotation) {
   100   var begin = Math.round((+ annotation.begin) / 1000);
    99   var begin = Math.round((+ annotation.begin) / 1000);
   104 IriSP.SegmentsWidget.prototype.searchHandler = function(searchString) {
   103 IriSP.SegmentsWidget.prototype.searchHandler = function(searchString) {
   105 
   104 
   106   if (searchString == "")
   105   if (searchString == "")
   107     return;
   106     return;
   108 
   107 
   109   console.log(searchString);
       
   110   var matches = this._serializer.searchOccurences(searchString);
   108   var matches = this._serializer.searchOccurences(searchString);
   111 
   109 
   112   for (var id in matches) {
   110   for (var id in matches) {
   113     var factor = matches[id] * 8;
   111     var factor = matches[id] * 8;
   114     IriSP.jQuery("#"+id).dequeue();
   112     this.selector.find("#"+id).dequeue();
   115     IriSP.jQuery("#"+id).animate({height: factor}, 200);
   113     this.selector.find("#"+id).animate({height: factor}, 200);    
   116     IriSP.jQuery("#"+id).css('border','2px');
   114     this.selector.find("#"+id).css('border-color','red');
   117     IriSP.jQuery("#"+id).css('border-color','red');
   115     this.selector.find("#"+id).animate({opacity:0.6}, 200);
   118     IriSP.jQuery("#"+id).animate({opacity:0.6}, 200);
       
   119 
   116 
   120     //IriSP.jQuery("#LdtSearchInput").css('background-color','#e1ffe1');
   117     IriSP.jQuery("#LdtSearchInput").css('background-color','#e1ffe1');
   121   }
   118   }
   122 
   119 
   123   // clean up the blocks that were in the previous search
   120   // clean up the blocks that were in the previous search
   124   // but who aren't in the current one.
   121   // but who aren't in the current one.
   125   for (var id in this.oldSearchMatches) {
   122   for (var id in this.oldSearchMatches) {
   126     if (!matches.hasOwnProperty(id)) {
   123     if (!matches.hasOwnProperty(id)) {
   127         IriSP.jQuery("#"+id).dequeue();
   124         IriSP.jQuery("#"+id).dequeue();
   128 				IriSP.jQuery("#"+id).animate({height:0},250);
   125 				IriSP.jQuery("#"+id).animate({height:0}, 250);				
   129 				IriSP.jQuery("#"+id).animate({opacity:0.3},200);
   126 				IriSP.jQuery("#"+id).animate({opacity:0.3}, 200);
       
   127         this.selector.find("#"+id).css('border','solid 1px #aaaaaa');
   130     }
   128     }
   131   }
   129   }
       
   130   
   132   this.oldSearchMatches = matches;
   131   this.oldSearchMatches = matches;
   133 };
   132 };
   134 
   133 
   135 IriSP.SegmentsWidget.prototype.searchFieldClearedHandler = function() {
   134 IriSP.SegmentsWidget.prototype.searchFieldClearedHandler = function() {
   136   this.clear();
   135   this.clear();