src/widgets/AnnotationsList.js
changeset 969 353b0881a0b9
parent 967 b4c6e64acb2d
child 983 97fef7a4b189
equal deleted inserted replaced
968:03c88ba5de2c 969:353b0881a0b9
   221                 tags : _annotation.getTagTexts(),
   221                 tags : _annotation.getTagTexts(),
   222                 specific_style : (typeof _bgcolor !== "undefined" ? "background-color: " + _bgcolor : ""),
   222                 specific_style : (typeof _bgcolor !== "undefined" ? "background-color: " + _bgcolor : ""),
   223                 audio : (_this.show_audio && _annotation.audio && _annotation.audio.href && _annotation.audio.href != "null" ? _annotation.audio.href : undefined),
   223                 audio : (_this.show_audio && _annotation.audio && _annotation.audio.href && _annotation.audio.href != "null" ? _annotation.audio.href : undefined),
   224                 l10n: _this.l10n
   224                 l10n: _this.l10n
   225             };
   225             };
   226             var _html = Mustache.to_html(_this.annotationTemplate, _data);
   226             var _html = Mustache.to_html(_this.annotationTemplate, _data),
   227             var _el = IriSP.jQuery(_html);
   227                 _el = IriSP.jQuery(_html),
       
   228                 _onselect = function() {
       
   229                     _this.annotations_$.removeClass("selected");
       
   230                     _el.addClass("selected");
       
   231                 },
       
   232                 _onunselect = function() {
       
   233                     _this.annotations_$.removeClass("selected");
       
   234                 };
   228             _el.mouseover(function() {
   235             _el.mouseover(function() {
   229                     _annotation.trigger("select");
   236                     _annotation.trigger("select");
   230                 })
   237                 })
   231                 .mouseout(function() {
   238                 .mouseout(function() {
   232                     _annotation.trigger("unselect");
   239                     _annotation.trigger("unselect");
   233                 })
   240                 })
   234                 .appendTo(_this.list_$);
   241                 .appendTo(_this.list_$);
   235             _annotation.on("select", function() {
   242             _el.on("remove", function() {
   236                 _this.annotations_$.removeClass("selected");
   243                 _annotation.off("select", _onselect);
   237                 _el.addClass("selected");
   244                 _annotation.off("unselect", _onunselect);
   238             });
   245             });
   239             _annotation.on("unselect", function() {
   246             _annotation.on("select", _onselect);
   240                 _this.annotations_$.removeClass("selected");
   247             _annotation.on("unselect", _onunselect);
   241             });;
       
   242         });
   248         });
   243         
   249         
   244         this.annotations_$ = this.$.find('.Ldt-AnnotationsList-li');
   250         this.annotations_$ = this.$.find('.Ldt-AnnotationsList-li');
   245         
   251         
   246         /* Correct the empty tag bug */
   252         /* Correct the empty tag bug */
   247         this.$.find('.Ldt-AnnotationsList-Tag-Li').each(function() {
   253         this.$.find('.Ldt-AnnotationsList-Tag-Li').each(function() {
   248             var _el = IriSP.jQuery(this);
   254             var _el = IriSP.jQuery(this);
   249             if (!_el.text().replace(/(^\s+|\s+$)/g,'')) {
   255             if (!_el.text().replace(/(^\s+|\s+$)/g,'')) {
   250                 _el.detach();
   256                 _el.remove();
   251             }
   257             }
   252         });
   258         });
   253     
   259     
   254         this.$.find('.Ldt-AnnotationsList-Tag-Li').click(function() {
   260         this.$.find('.Ldt-AnnotationsList-Tag-Li').click(function() {
   255             _this.player.trigger("search.triggeredSearch", IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,''));
   261             _this.player.trigger("search.triggeredSearch", IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,''));