diff -r 7623f9af9272 -r 2409cb4cebaf src/widgets/Polemic.js --- a/src/widgets/Polemic.js Fri Oct 02 11:27:17 2015 +0200 +++ b/src/widgets/Polemic.js Mon Dec 28 15:50:04 2015 +0100 @@ -24,37 +24,73 @@ annotation_type : "tweet", defaultcolor : "#585858", foundcolor : "#fc00ff", - polemics : [ - { - "name" : "OK", - "keywords" : [ "++" ], - "color" : "#1D973D" - }, - { - "name" : "KO", - "keywords" : [ "--" ], - "color" : "#CE0A15" - }, - { - "name" : "REF", - "keywords" : [ "==", "http://" ], - "color" : "#C5A62D" - }, - { - "name" : "Q", - "keywords" : [ "?" ], - "color" : "#036AAE" - } - ] + default_version : "1", + polemics : { + "1" : [ + { + "name" : "OK", + "keywords" : [ "++" ], + "color" : "#1D973D" + }, + { + "name" : "KO", + "keywords" : [ "--" ], + "color" : "#CE0A15" + }, + { + "name" : "REF", + "keywords" : [ "==", "http://" ], + "color" : "#C5A62D" + }, + { + "name" : "Q", + "keywords" : [ "?" ], + "color" : "#036AAE" + } + ], + "2" : [ + { + "name" : "OK", + "keywords" : [ "++" ], + "color" : "#1D973D" + }, + { + "name" : "KO", + "keywords" : [ "!!" ], + "color" : "#CE0A15" + }, + { + "name" : "REF", + "keywords" : [ "==", "http://" ], + "color" : "#C5A62D" + }, + { + "name" : "Q", + "keywords" : [ "?" ], + "color" : "#036AAE" + } + ] + } +}; + +IriSP.Widgets.Polemic.prototype.getPolemics = function(version) { + if(typeof(version) === "undefined" || !version) { + version = this.default_version; + } + if(this.polemics.constructor === Array) { + return this.polemics; + } else { + return this.polemics[version]; + } }; IriSP.Widgets.Polemic.prototype.draw = function() { - + this.onMediaEvent("timeupdate", "onTimeupdate"); this.$zone = IriSP.jQuery('
'); this.$zone.addClass("Ldt-Polemic"); this.$.append(this.$zone); - + this.$elapsed = IriSP.jQuery('
') .css({ background: '#cccccc', @@ -64,9 +100,9 @@ width: 0, height: "100%" }); - + this.$zone.append(this.$elapsed); - + // we don't filter with null duration anymore var _slices = [], _slice_count = Math.floor( this.width / this.element_width ), @@ -74,7 +110,7 @@ _max = 0, _list = this.getWidgetAnnotations(), _this = this; - + for (var _i = 0; _i < _slice_count; _i++) { var _begin = new IriSP.Model.Time( _i * _duration / _slice_count ), _end = new IriSP.Model.Time( ( _i + 1 ) * _duration / _slice_count ), @@ -87,13 +123,13 @@ }), polemicStacks : [] }; - - for (var _j = 0; _j < this.polemics.length; _j++) { - var _polemic = _res.annotations.searchByDescription(this.polemics[_j].keywords); + + for (var _j = 0; _j < this.getPolemics().length; _j++) { + var _polemic = _res.annotations.searchByDescription(this.getPolemics()[_j].keywords); _count += _polemic.length; _res.polemicStacks.push(_polemic); } - for (var _j = 0; _j < this.polemics.length; _j++) { + for (var _j = 0; _j < this.getPolemics().length; _j++) { _res.annotations.removeElements(_res.polemicStacks[_j]); } _count += _res.annotations.length; @@ -103,16 +139,16 @@ if (_max < this.max_elements) { this.is_stackgraph = false; if (_max) { - + this.height = (2 + _max) * this.element_height; this.$zone.css({ width: this.width + "px", height: this.height + "px", position: "relative" }); - + var _x = 0; - + function displayAnnotation(_elx, _ely, _pol, _col, _annotation) { var _html = Mustache.to_html( '
'; - for (var _i = 0; _i <= _this.polemics.length; _i++) { - var _color = _i ? _this.polemics[_i - 1].color : _this.defaultcolor; + for (var _i = 0; _i <= _this.getPolemics().length; _i++) { + var _color = _i ? _this.getPolemics()[_i - 1].color : _this.defaultcolor; _html += '

' + _nums[_i] + _this.l10n._annotations + '

'; } if (_this.tooltip) { @@ -304,20 +340,20 @@ _this.tooltip.hide(); } }); - + }; - + this.$position = IriSP.jQuery('
').addClass("Ldt-Polemic-Position"); - + this.$zone.append(this.$position); - + this.$zone.click(function(_e) { var _x = _e.pageX - _this.$zone.offset().left; _this.media.setCurrentTime(_this.media.duration * _x / _this.width); }); - + this.$.append('
'); - + this.insertSubwidget( this.$.find(".Ldt-Polemic-Tooltip"), {