src/js/widgets/sparklineWidget.js
branchpopcorn-port
changeset 842 4ae2247a59f4
parent 840 ac66e2240e1e
child 857 fa614dc66b0b
equal deleted inserted replaced
841:8da49ff273e0 842:4ae2247a59f4
     3   IriSP.Widget.call(this, Popcorn, config, Serializer);
     3   IriSP.Widget.call(this, Popcorn, config, Serializer);
     4 
     4 
     5   this._oldAnnotation = null;
     5   this._oldAnnotation = null;
     6   this._results = [];
     6   this._results = [];
     7   
     7   
     8   this.lineColor = this._config.lineColor || "#7492b4";
       
     9   this.fillColor = this._config.fillColor || "#aeaeb8";
       
    10   this.lineWidth = this._config.lineWidth || 2;
       
    11   this.slices = this._config.slices || Math.floor(this.width/20);
     8   this.slices = this._config.slices || Math.floor(this.width/20);
    12   if (!this.width) {
     9   if (!this.width) {
    13       this.width = this.selector.width();
    10       this.width = this.selector.width();
    14   }
    11   }
    15   if (!this.height) {
    12   if (!this.height) {
    17   }
    14   }
    18   this.selector.css("height", this.height + "px");
    15   this.selector.css("height", this.height + "px");
    19   if (this._config.background) {
    16   if (this._config.background) {
    20       this.selector.css("background", this._config.background);
    17       this.selector.css("background", this._config.background);
    21   }
    18   }
    22   this.checkOption('cinecast_version');
       
    23 };
    19 };
    24 
    20 
    25 
    21 
    26 IriSP.SparklineWidget.prototype = new IriSP.Widget();
    22 IriSP.SparklineWidget.prototype = new IriSP.Widget();
    27 
    23 
    29 
    25 
    30 };
    26 };
    31 
    27 
    32 /** draw the sparkline using jquery sparkline */
    28 /** draw the sparkline using jquery sparkline */
    33 IriSP.SparklineWidget.prototype.draw = function() {
    29 IriSP.SparklineWidget.prototype.draw = function() {
    34     this.duration = this._serializer.getDuration();
    30     this.duration = this.getDuration();
    35     this.paper = new Raphael(this.selector[0], this.width, this.height);
    31     this.paper = new Raphael(this.selector[0], this.width, this.height);
    36     var _this = this;
    32     var _this = this;
    37   
    33   
    38   var views = this._serializer._data.views;
    34   var views = this._serializer._data.views;
    39   var stat_view;
    35   var stat_view;
    56     } else {
    52     } else {
    57         var _annotations = this._serializer._data.annotations,
    53         var _annotations = this._serializer._data.annotations,
    58             _sliceDuration = Math.floor( this.duration / this.slices),
    54             _sliceDuration = Math.floor( this.duration / this.slices),
    59             _results = _(_.range(this.slices)).map(function(_i) {
    55             _results = _(_.range(this.slices)).map(function(_i) {
    60                 return _(_annotations).filter(function(_a){
    56                 return _(_annotations).filter(function(_a){
    61                     return (_a.begin <= (1 + _i) * _sliceDuration) && (_a.end >= _i * _sliceDuration) && (!_this.cinecast_version || _a.type == "cinecast:UserAnnotation")
    57                     return (_a.begin <= (1 + _i) * _sliceDuration) && (_a.end >= _i * _sliceDuration)
    62                 }).length;
    58                 }).length;
    63             });
    59             });
    64     }
    60     }
    65     var _max = Math.max(1, _(_results).max()),
    61     var _max = Math.max(1, _(_results).max()),
    66         _h = this.height,
    62         _h = this.height,