116 } |
116 } |
117 }; |
117 }; |
118 |
118 |
119 /* restores the view after a search */ |
119 /* restores the view after a search */ |
120 IriSP.SegmentsWidget.prototype.clear = function() { |
120 IriSP.SegmentsWidget.prototype.clear = function() { |
121 // reinit the fields |
121 this.selector.children(".Ldt-iri-chapter").css('border','none').animate({opacity:0.3}, 100); |
122 for (var id in this.oldSearchMatches) { |
|
123 |
|
124 IriSP.jQuery("#"+id).dequeue(); |
|
125 IriSP.jQuery("#"+id).css('border','none'); |
|
126 IriSP.jQuery("#"+id).animate({opacity:0.3}, 100); |
|
127 } |
|
128 }; |
122 }; |
129 |
123 |
130 IriSP.SegmentsWidget.prototype.clickHandler = function(annotation) { |
124 IriSP.SegmentsWidget.prototype.clickHandler = function(annotation) { |
131 var begin = (+ annotation.begin) / 1000; |
125 var begin = (+ annotation.begin) / 1000; |
132 this._Popcorn.currentTime(Math.floor(begin)); |
126 this._Popcorn.currentTime(Math.floor(begin)); |
143 this._Popcorn.trigger("IriSP.SegmentsWidget.matchFound"); |
137 this._Popcorn.trigger("IriSP.SegmentsWidget.matchFound"); |
144 } else { |
138 } else { |
145 this._Popcorn.trigger("IriSP.SegmentsWidget.noMatchFound"); |
139 this._Popcorn.trigger("IriSP.SegmentsWidget.noMatchFound"); |
146 } |
140 } |
147 |
141 |
|
142 // un-highlight all the blocks |
|
143 this.selector.children(".Ldt-iri-chapter").css("opacity", 0.1); |
|
144 |
|
145 // then highlight the ones with matches. |
148 for (var id in matches) { |
146 for (var id in matches) { |
149 var factor = 0.5 + matches[id] * 0.2; |
147 var factor = 0.5 + matches[id] * 0.2; |
150 this.selector.find("#"+id).dequeue(); |
148 this.selector.find("#"+id).dequeue(); |
151 this.selector.find("#"+id).css('border','1px red'); |
149 this.selector.find("#"+id).css('border','1px red'); |
152 this.selector.find("#"+id).animate({opacity:factor}, 200); |
150 this.selector.find("#"+id).animate({opacity:factor}, 200); |
153 } |
151 } |
154 |
152 |
155 // clean up the blocks that were in the previous search |
153 |
156 // but who aren't in the current one. |
|
157 for (var id in this.oldSearchMatches) { |
|
158 if (!matches.hasOwnProperty(id)) { |
|
159 IriSP.jQuery("#"+id).dequeue(); |
|
160 IriSP.jQuery("#"+id).animate({opacity:0.3}, 200); |
|
161 } |
|
162 } |
|
163 |
|
164 this.oldSearchMatches = matches; |
154 this.oldSearchMatches = matches; |
165 }; |
155 }; |
166 |
156 |
167 IriSP.SegmentsWidget.prototype.searchFieldClearedHandler = function() { |
157 IriSP.SegmentsWidget.prototype.searchFieldClearedHandler = function() { |
168 this.clear(); |
158 this.clear(); |