src/widgets/Polemic.js
author veltr
Mon, 23 Apr 2012 19:11:08 +0200
branchnew-model
changeset 875 43629caa77bc
parent 874 src/js/widgets/polemicWidget.js@38b65761a7d5
child 876 03967b6ada7c
permissions -rw-r--r--
Big refactoring of widget files + started migration of segmentwidget
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
     1
IriSP.Widgets.Polemic = function(player, config) {
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
     2
    IriSP.Widgets.Widget.call(this, player, config);
169
427632a324d5 first import of the polemic tweet widget.
hamidouk
parents:
diff changeset
     3
};
427632a324d5 first import of the polemic tweet widget.
hamidouk
parents:
diff changeset
     4
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
     5
IriSP.Widgets.Polemic.prototype = new IriSP.Widgets.Widget();
187
6f1def85018a removed useless printfs.
hamidouk
parents: 176
diff changeset
     6
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
     7
IriSP.Widgets.Polemic.prototype.defaults = {
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
     8
    element_width : 5,
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
     9
    element_height : 5,
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    10
    annotation_type : "tweet",
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    11
    defaultcolor : "#585858",
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    12
    foundcolor : "#fc00ff",
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    13
    tags : [
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    14
        {
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    15
            "keywords" : [ "++" ],
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    16
            "description" : "positif",
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    17
            "color" : "#1D973D"
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    18
        },
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    19
        {
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    20
            "keywords" : [ "--" ],
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    21
            "description" : "negatif",
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    22
            "color" : "#CE0A15"
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    23
        },
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    24
        {
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    25
            "keywords" : [ "==" ],
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    26
            "description" : "reference",
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    27
            "color" : "#C5A62D"  
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    28
        },
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    29
        {
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    30
            "keywords" : [ "??" ],
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    31
            "description" : "question",
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    32
            "color" : "#036AAE"
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    33
        }
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    34
    ],
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    35
    requires : [
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    36
        {
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    37
            type: "Tooltip"
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    38
        }
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    39
    ]
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    40
};
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    41
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    42
IriSP.Widgets.Polemic.prototype.searchHandler = function(searchString) {
874
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    43
    this.searchString = typeof searchString !== "undefined" ? searchString : '';
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    44
    var _found = 0,
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    45
        _re = IriSP.Model.regexpFromTextOrArray(searchString)
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    46
        _this = this;
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    47
    this.$tweets.each(function() {
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    48
        var _el = IriSP.jQuery(this);
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    49
        if (_this.searchString) {
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    50
            if (_re.test(_el.attr("tweet-title"))) {
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    51
                _el.css({
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    52
                    "background" : _this.foundcolor,
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    53
                    "opacity" : 1
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    54
                });
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    55
                _found++;
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    56
            } else {
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    57
                _el.css({
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    58
                    "background" : _el.attr("polemic-color"),
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    59
                    "opacity" : .5
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    60
                });
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    61
            }
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    62
        } else {
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    63
            _el.css({
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    64
                "background" : _el.attr("polemic-color"),
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    65
                "opacity" : 1
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    66
            });
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    67
        }
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    68
    });
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    69
    if (this.searchString) {
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    70
        if (_found) {
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    71
            this.player.popcorn.trigger("IriSP.search.matchFound");
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    72
        } else {
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    73
            this.player.popcorn.trigger("IriSP.search.noMatchFound");
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    74
        }
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    75
    }
874
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    76
}
595
29d86e6c61a6 finished going through the widgets to add stricter line checking.
hamidouk
parents: 567
diff changeset
    77
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    78
IriSP.Widgets.Polemic.prototype.draw = function() {
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    79
    
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    80
    this.bindPopcorn("IriSP.search", "searchHandler");
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    81
    this.bindPopcorn("IriSP.search.closed", "searchHandler");
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    82
    this.bindPopcorn("IriSP.search.cleared", "searchHandler");
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    83
    this.bindPopcorn("timeupdate", "onTimeupdate");
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    84
    this.$zone = IriSP.jQuery('<div>');
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    85
    this.$.append(this.$zone);
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    86
    
874
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    87
    var _slices = [],
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    88
        _slice_count = Math.floor( this.width / this.element_width ),
874
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    89
        _duration = this.source.getDuration(),
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    90
        _max = 0,
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    91
        _list = this.annotation_type ? this.source.getAnnotationsByTypeTitle(this.annotation_type) : this.source.getAnnotations();
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    92
    
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    93
    for (var _i = 0; _i < _slice_count; _i++) {
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    94
        var _begin = new IriSP.Model.Time( _i * _duration / _slice_count ),
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    95
            _end = new IriSP.Model.Time( ( _i + 1 ) * _duration / _slice_count ),
874
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    96
            _count = 0,
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    97
            _res = {
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    98
                annotations : _list.filter(function(_annotation) {
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
    99
                    return _annotation.begin >= _begin && _annotation.end < _end;
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   100
                }),
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   101
                polemicStacks : []
566
098929cd2d62 made the polemicwidget adjust its size automatically and fixed a couple edgecases.
hamidouk
parents: 565
diff changeset
   102
            }
098929cd2d62 made the polemicwidget adjust its size automatically and fixed a couple edgecases.
hamidouk
parents: 565
diff changeset
   103
            
874
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   104
        for (var _j = 0; _j < this.tags.length; _j++) {
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   105
            var _polemic = _res.annotations.searchByDescription(this.tags[_j].keywords);
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   106
            _count += _polemic.length;
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   107
            _res.polemicStacks.push(_polemic);
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   108
        }
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   109
        for (var _j = 0; _j < this.tags.length; _j++) {
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   110
            _res.annotations.removeElements(_res.polemicStacks[_j]);
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   111
        }
874
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   112
        _count += _res.annotations.length;
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   113
        _max = Math.max(_max, _count);
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   114
        _slices.push(_res);
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   115
    }
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   116
    this.height = (_max ? (_max + 2) * this.element_height : 0);
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   117
    this.$zone.css({
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   118
        width: this.width + "px",
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   119
        height: this.height + "px",
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   120
        position: "relative"
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   121
    });
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   122
    
874
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   123
    this.$elapsed = IriSP.jQuery('<div>')
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   124
        .css({
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   125
            background: '#cccccc',
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   126
            position: "absolute",
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   127
            top: 0,
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   128
            left: 0,
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   129
            width: 0,
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   130
            height: "100%"
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   131
        });
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   132
        
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   133
    this.$zone.append(this.$elapsed);
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   134
    
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   135
    var _x = 0,
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   136
        _this = this;
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   137
    
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   138
    function displayElement(_x, _y, _color, _id, _title) {
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   139
        var _el = IriSP.jQuery('<div>')
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   140
            .attr({
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   141
                "tweet-title" : _title,
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   142
                "pos-x" : Math.floor(_x + (_this.element_width - 1) / 2),
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   143
                "pos-y" : _y,
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   144
                "polemic-color" : _color,
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   145
                "annotation-id" : _id
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   146
            })
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   147
            .css({
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   148
                position: "absolute",
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   149
                width: (_this.element_width-1) + "px",
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   150
                height: _this.element_height + "px",
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   151
                left: _x + "px",
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   152
                top: _y + "px",
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   153
                background: _color
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   154
            })
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   155
            .addClass("Ldt-Polemic-TweetDiv");
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   156
        _this.$zone.append(_el);
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   157
        return _el;
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   158
    }
194
f5d86e5c4a56 some cleaning. Also added a progression indicator.
hamidouk
parents: 192
diff changeset
   159
    
874
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   160
    IriSP._(_slices).forEach(function(_slice) {
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   161
        var _y = _this.height;
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   162
        _slice.annotations.forEach(function(_annotation) {
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   163
            _y -= _this.element_height;
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   164
            displayElement(_x, _y, _this.defaultcolor, _annotation.namespacedId.name, _annotation.title);
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   165
        });
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   166
        IriSP._(_slice.polemicStacks).forEach(function(_annotations, _j) {
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   167
            var _color = _this.tags[_j].color;
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   168
            _annotations.forEach(function(_annotation) {
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   169
                _y -= _this.element_height;
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   170
                displayElement(_x, _y, _color, _annotation.namespacedId.name, _annotation.title);
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   171
            });
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   172
        });
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   173
        _x += _this.element_width;
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   174
    });
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   175
    
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   176
    this.$tweets = this.$.find(".Ldt-Polemic-TweetDiv");
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   177
    
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   178
    this.$position = IriSP.jQuery('<div>').addClass("Ldt-Polemic-Position");
874
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   179
        
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   180
    this.$zone.append(this.$position);
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   181
    
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   182
    this.$tweets
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   183
        .mouseover(function() {
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   184
            var _el = IriSP.jQuery(this);
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   185
            _this.tooltip.show(_el.attr("pos-x"), _el.attr("pos-y"), _el.attr("tweet-title"), _el.attr("polemic-color"));
874
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   186
        })
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   187
        .mouseout(function() {
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   188
            _this.tooltip.hide();
874
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   189
        });
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   190
    
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   191
    //TODO: Display Tweet in Tweet Widget on click
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   192
    
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   193
    this.$zone.click(function(_e) {
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   194
        var _x = _e.pageX - _this.$zone.offset().left;
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   195
        _this.player.popcorn.currentTime(_this.source.getDuration().getSeconds() * _x / _this.width);
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   196
    });
194
f5d86e5c4a56 some cleaning. Also added a progression indicator.
hamidouk
parents: 192
diff changeset
   197
}
f5d86e5c4a56 some cleaning. Also added a progression indicator.
hamidouk
parents: 192
diff changeset
   198
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   199
IriSP.Widgets.Polemic.prototype.onTimeupdate = function() {
874
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   200
    var _x = Math.floor( this.width * this.player.popcorn.currentTime() / this.source.getDuration().getSeconds());
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   201
    this.$elapsed.css({
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   202
        width:  _x + "px"
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   203
    });
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   204
    this.$position.css({
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   205
        left: _x + "px"
874
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   206
    })
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   207
}