src/widgets/Polemic.js
changeset 1017 b6e39f6fd24f
parent 1012 7e18d953a1f8
child 1021 7253d4d06f0d
equal deleted inserted replaced
1016:e1752b696a07 1017:b6e39f6fd24f
    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,
    25     defaultcolor : "#585858",
    26     defaultcolor : "#585858",
    26     foundcolor : "#fc00ff",
    27     foundcolor : "#fc00ff",
    27     polemics : [
    28     polemics : [
    28         {
    29         {
    29             "name" : "OK",
    30             "name" : "OK",
    69     
    70     
    70     var _slices = [],
    71     var _slices = [],
    71         _slice_count = Math.floor( this.width / this.element_width ),
    72         _slice_count = Math.floor( this.width / this.element_width ),
    72         _duration = this.source.getDuration(),
    73         _duration = this.source.getDuration(),
    73         _max = 0,
    74         _max = 0,
    74         _list = this.getWidgetAnnotations().filter(function(_a) {
    75         _this = this,
       
    76         _list = this.getWidgetAnnotations();
       
    77     
       
    78     if (this.only_allow_zero_duration_annotations) {
       
    79         _list = _list.filter(function(_a) {
    75             return !_a.getDuration().milliseconds;
    80             return !_a.getDuration().milliseconds;
    76         }),
    81         });
    77         _this = this;
    82     }
    78     
    83     
    79     for (var _i = 0; _i < _slice_count; _i++) {
    84     for (var _i = 0; _i < _slice_count; _i++) {
    80         var _begin = new IriSP.Model.Time( _i * _duration / _slice_count ),
    85         var _begin = new IriSP.Model.Time( _i * _duration / _slice_count ),
    81             _end = new IriSP.Model.Time( ( _i + 1 ) * _duration / _slice_count ),
    86             _end = new IriSP.Model.Time( ( _i + 1 ) * _duration / _slice_count ),
    82             _count = 0,
    87             _count = 0,
   138                 }).click(function() {
   143                 }).click(function() {
   139                     _annotation.trigger("click");
   144                     _annotation.trigger("click");
   140                     return false;
   145                     return false;
   141                 });
   146                 });
   142                 IriSP.attachDndData(_el, {
   147                 IriSP.attachDndData(_el, {
   143                 	title: _annotation.title,
   148                     title: _annotation.title,
   144                 	description: _annotation.description,
   149                     description: _annotation.description,
   145                 	image: _annotation.thumbnail,
   150                     image: _annotation.thumbnail,
   146                 	uri: (typeof _annotation.url !== "undefined" 
   151                     uri: (typeof _annotation.url !== "undefined" 
   147 		                ? _annotation.url
   152                         ? _annotation.url
   148 		                : (document.location.href.replace(/#.*$/,'') + '#id='  + _annotation.id))
   153                         : (document.location.href.replace(/#.*$/,'') + '#id='  + _annotation.id))
   149                 });
   154                 });
   150                 _annotation.on("select", function() {
   155                 _annotation.on("select", function() {
   151                     if (_this.tooltip) {
   156                     if (_this.tooltip) {
   152                         _this.tooltip.show(
   157                         _this.tooltip.show(
   153                             + Math.floor(_elx + (_this.element_width - 1) / 2),
   158                             + Math.floor(_elx + (_this.element_width - 1) / 2),