43 |
43 |
44 IriSP.Widgets.Annotation.prototype.defaults = { |
44 IriSP.Widgets.Annotation.prototype.defaults = { |
45 annotation_type : "chap", |
45 annotation_type : "chap", |
46 start_minimized: true, |
46 start_minimized: true, |
47 show_top_border : false, |
47 show_top_border : false, |
48 site_name : "Lignes de Temps" |
48 site_name : "Lignes de Temps", |
|
49 search_on_tag_click: true |
49 } |
50 } |
50 |
51 |
51 IriSP.Widgets.Annotation.prototype.draw = function() { |
52 IriSP.Widgets.Annotation.prototype.draw = function() { |
52 this.renderTemplate(); |
53 this.renderTemplate(); |
53 this.insertSubwidget(this.$.find(".Ldt-Annotation-Social"), { type: "Social" }, "socialWidget"); |
54 this.insertSubwidget(this.$.find(".Ldt-Annotation-Social"), { type: "Social" }, "socialWidget"); |
85 |
86 |
86 IriSP.Widgets.Annotation.prototype.drawAnnotation = function(_annotation) { |
87 IriSP.Widgets.Annotation.prototype.drawAnnotation = function(_annotation) { |
87 this.lastAnnotation = _annotation.id; |
88 this.lastAnnotation = _annotation.id; |
88 var _url = (typeof _annotation.url !== "undefined" |
89 var _url = (typeof _annotation.url !== "undefined" |
89 ? _annotation.url |
90 ? _annotation.url |
90 : (document.location.href.replace(/#.*$/,'') + '#id=' + _annotation.id)); |
91 : (document.location.href.replace(/#.*$/,'') + '#id=' + _annotation.id)), |
91 var _text = this.l10n.watching + _annotation.title + (this.site_name ? this.l10n.on_site + this.site_name : ''); |
92 _text = this.l10n.watching + _annotation.title + (this.site_name ? this.l10n.on_site + this.site_name : ''), |
92 var _tags = _annotation.getTagTexts(); |
93 _tags = _annotation.getTags(), |
|
94 _tagblock = this.$.find(".Ldt-Annotation-Tags"), |
|
95 _this = this; |
|
96 _tagblock.empty(); |
93 if (_tags.length) { |
97 if (_tags.length) { |
94 var _html = IriSP._(_tags).map(function(_tag) { |
|
95 return '<li class="Ldt-Annotation-TagLabel"><span>' + _tag + '</span></li>'; |
|
96 }).join(""); |
|
97 this.$.find(".Ldt-Annotation-Tags").html(_html); |
|
98 this.$.find(".Ldt-Annotation-Tags-Block").removeClass("Ldt-Annotation-EmptyBlock"); |
98 this.$.find(".Ldt-Annotation-Tags-Block").removeClass("Ldt-Annotation-EmptyBlock"); |
99 |
99 _tags.forEach(function(_tag) { |
100 /* Correct the empty tag bug */ |
100 var _trimmedTitle = _tag.title.replace(/(^\s+|\s+$)/g,''); |
101 this.$.find('.Ldt-Annotation-TagLabel').each(function() { |
101 if (_trimmedTitle) { |
102 var _el = IriSP.jQuery(this); |
102 var _el = IriSP.jQuery('<li class="Ldt-Annotation-TagLabel"></li>').append(IriSP.jQuery('<span>').text(_trimmedTitle)); |
103 if (!_el.text().replace(/(^\s+|\s+$)/g,'')) { |
103 _el.click(function() { |
104 _el.detach(); |
104 if (_this.search_on_tag_click) { |
|
105 _this.player.trigger("search.triggeredSearch",_trimmedTitle); |
|
106 } |
|
107 _tag.trigger("click"); |
|
108 }); |
|
109 _tagblock.append(_el); |
105 } |
110 } |
106 }); |
|
107 |
|
108 this.$.find('.Ldt-Annotation-TagLabel').click(function() { |
|
109 _this.player.trigger("search.triggeredSearch", IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,'')); |
|
110 }); |
111 }); |
111 } else { |
112 } else { |
112 this.$.find(".Ldt-Annotation-Tags-Block").addClass("Ldt-Annotation-EmptyBlock"); |
113 this.$.find(".Ldt-Annotation-Tags-Block").addClass("Ldt-Annotation-EmptyBlock"); |
113 } |
114 } |
114 this.$.find(".Ldt-Annotation-Title").html(_annotation.title); |
115 this.$.find(".Ldt-Annotation-Title").html(_annotation.title); |
130 this.$.find('.Ldt-Annotation-Inner').removeClass("Ldt-Annotation-isMashup"); |
131 this.$.find('.Ldt-Annotation-Inner').removeClass("Ldt-Annotation-isMashup"); |
131 } |
132 } |
132 if (typeof this.socialWidget !== "undefined") { |
133 if (typeof this.socialWidget !== "undefined") { |
133 this.socialWidget.updateUrls(_url, _text); |
134 this.socialWidget.updateUrls(_url, _text); |
134 } else { |
135 } else { |
135 var _this = this; |
|
136 setTimeout(function() { |
136 setTimeout(function() { |
137 if (typeof _this.socialWidget !== "undefined") { |
137 if (typeof _this.socialWidget !== "undefined") { |
138 _this.socialWidget.updateUrls(_url, _text); |
138 _this.socialWidget.updateUrls(_url, _text); |
139 } |
139 } |
140 },800); |
140 },800); |