20 IriSP.Widgets.Polemic.prototype.defaults = { |
20 IriSP.Widgets.Polemic.prototype.defaults = { |
21 element_width : 5, |
21 element_width : 5, |
22 element_height : 5, |
22 element_height : 5, |
23 max_elements: 20, |
23 max_elements: 20, |
24 annotation_type : "tweet", |
24 annotation_type : "tweet", |
25 only_allow_zero_duration_annotations: true, |
|
26 defaultcolor : "#585858", |
25 defaultcolor : "#585858", |
27 foundcolor : "#fc00ff", |
26 foundcolor : "#fc00ff", |
28 polemics : [ |
27 polemics : [ |
29 { |
28 { |
30 "name" : "OK", |
29 "name" : "OK", |
66 height: "100%" |
65 height: "100%" |
67 }); |
66 }); |
68 |
67 |
69 this.$zone.append(this.$elapsed); |
68 this.$zone.append(this.$elapsed); |
70 |
69 |
|
70 // we don't filter with null duration anymore |
71 var _slices = [], |
71 var _slices = [], |
72 _slice_count = Math.floor( this.width / this.element_width ), |
72 _slice_count = Math.floor( this.width / this.element_width ), |
73 _duration = this.source.getDuration(), |
73 _duration = this.source.getDuration(), |
74 _max = 0, |
74 _max = 0, |
75 _this = this, |
75 _list = this.getWidgetAnnotations(), |
76 _list = this.getWidgetAnnotations(); |
76 _this = this; |
77 |
|
78 if (this.only_allow_zero_duration_annotations) { |
|
79 _list = _list.filter(function(_a) { |
|
80 return !_a.getDuration().milliseconds; |
|
81 }); |
|
82 } |
|
83 |
77 |
84 for (var _i = 0; _i < _slice_count; _i++) { |
78 for (var _i = 0; _i < _slice_count; _i++) { |
85 var _begin = new IriSP.Model.Time( _i * _duration / _slice_count ), |
79 var _begin = new IriSP.Model.Time( _i * _duration / _slice_count ), |
86 _end = new IriSP.Model.Time( ( _i + 1 ) * _duration / _slice_count ), |
80 _end = new IriSP.Model.Time( ( _i + 1 ) * _duration / _slice_count ), |
87 _count = 0, |
81 _count = 0, |
143 }).click(function() { |
137 }).click(function() { |
144 _annotation.trigger("click"); |
138 _annotation.trigger("click"); |
145 return false; |
139 return false; |
146 }); |
140 }); |
147 IriSP.attachDndData(_el, { |
141 IriSP.attachDndData(_el, { |
148 title: _annotation.title, |
142 title: _annotation.title, |
149 description: _annotation.description, |
143 description: _annotation.description, |
150 image: _annotation.thumbnail, |
144 image: _annotation.thumbnail, |
151 uri: (typeof _annotation.url !== "undefined" |
145 uri: (typeof _annotation.url !== "undefined" |
152 ? _annotation.url |
146 ? _annotation.url |
153 : (document.location.href.replace(/#.*$/,'') + '#id=' + _annotation.id)) |
147 : (document.location.href.replace(/#.*$/,'') + '#id=' + _annotation.id)) |
154 }); |
148 }); |
|
149 // test if annotation has several colors. |
|
150 var colAr = []; |
|
151 for (var _j = 0; _j < _this.polemics.length; _j++) { |
|
152 if( IriSP.Model.regexpFromTextOrArray( _this.polemics[_j].keywords ).test( _annotation.title ) ){ |
|
153 colAr.push(_this.polemics[_j].color); |
|
154 } |
|
155 } |
|
156 // display annotation |
155 _annotation.on("select", function() { |
157 _annotation.on("select", function() { |
156 if (_this.tooltip) { |
158 if (_this.tooltip) { |
157 _this.tooltip.show( |
159 _this.tooltip.show( |
158 + Math.floor(_elx + (_this.element_width - 1) / 2), |
160 + Math.floor(_elx + (_this.element_width - 1) / 2), |
159 + _ely, |
161 + _ely, |
160 _annotation.title, |
162 _annotation.title, |
161 _col |
163 ( (colAr.length>1) ? colAr : _col ) |
162 ); |
164 ); |
163 } |
165 } |
164 _this.$tweets.each(function() { |
166 _this.$tweets.each(function() { |
165 var _e = IriSP.jQuery(this); |
167 var _e = IriSP.jQuery(this); |
166 _e.css( |
168 _e.css( |