src/widgets/Polemic.js
author veltr
Thu, 26 Apr 2012 19:18:57 +0200
branchnew-model
changeset 880 4c7b33bf2795
parent 876 03967b6ada7c
child 881 f11b234497f7
permissions -rw-r--r--
Started work on CreateAnnotation and Mediafragment
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",
880
4c7b33bf2795 Started work on CreateAnnotation and Mediafragment
veltr
parents: 876
diff changeset
    13
    polemics : [
875
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
876
03967b6ada7c ArrowWidget, AnnotationWidget
veltr
parents: 875
diff changeset
    42
IriSP.Widgets.Polemic.prototype.onSearch = 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,
876
03967b6ada7c ArrowWidget, AnnotationWidget
veltr
parents: 875
diff changeset
    45
        _re = IriSP.Model.regexpFromTextOrArray(searchString),
874
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
    
876
03967b6ada7c ArrowWidget, AnnotationWidget
veltr
parents: 875
diff changeset
    80
    this.bindPopcorn("IriSP.search", "onSearch");
03967b6ada7c ArrowWidget, AnnotationWidget
veltr
parents: 875
diff changeset
    81
    this.bindPopcorn("IriSP.search.closed", "onSearch");
03967b6ada7c ArrowWidget, AnnotationWidget
veltr
parents: 875
diff changeset
    82
    this.bindPopcorn("IriSP.search.cleared", "onSearch");
875
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,
876
03967b6ada7c ArrowWidget, AnnotationWidget
veltr
parents: 875
diff changeset
    91
        _list = this.getWidgetAnnotations();
874
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
            
880
4c7b33bf2795 Started work on CreateAnnotation and Mediafragment
veltr
parents: 876
diff changeset
   104
        for (var _j = 0; _j < this.polemics.length; _j++) {
4c7b33bf2795 Started work on CreateAnnotation and Mediafragment
veltr
parents: 876
diff changeset
   105
            var _polemic = _res.annotations.searchByDescription(this.polemics[_j].keywords);
874
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
        }
880
4c7b33bf2795 Started work on CreateAnnotation and Mediafragment
veltr
parents: 876
diff changeset
   109
        for (var _j = 0; _j < this.polemics.length; _j++) {
874
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,
876
03967b6ada7c ArrowWidget, AnnotationWidget
veltr
parents: 875
diff changeset
   136
        _this = this,
03967b6ada7c ArrowWidget, AnnotationWidget
veltr
parents: 875
diff changeset
   137
        _html = '';
874
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   138
    
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   139
    function displayElement(_x, _y, _color, _id, _title) {
876
03967b6ada7c ArrowWidget, AnnotationWidget
veltr
parents: 875
diff changeset
   140
        _html += Mustache.to_html(
03967b6ada7c ArrowWidget, AnnotationWidget
veltr
parents: 875
diff changeset
   141
            '<div class="Ldt-Polemic-TweetDiv" annotation-id="{{id}}" tweet-title="{{title}}" pos-x="{{posx}}" pos-y="{{top}}" polemic-color="{{color}}"'
03967b6ada7c ArrowWidget, AnnotationWidget
veltr
parents: 875
diff changeset
   142
            + ' style="width: {{width}}px; height: {{height}}px; top: {{top}}px; left: {{left}}px; background: {{color}}"></div>',
03967b6ada7c ArrowWidget, AnnotationWidget
veltr
parents: 875
diff changeset
   143
        {
03967b6ada7c ArrowWidget, AnnotationWidget
veltr
parents: 875
diff changeset
   144
            id: _id,
03967b6ada7c ArrowWidget, AnnotationWidget
veltr
parents: 875
diff changeset
   145
            title: _title,
03967b6ada7c ArrowWidget, AnnotationWidget
veltr
parents: 875
diff changeset
   146
            posx: Math.floor(_x + (_this.element_width - 1) / 2),
03967b6ada7c ArrowWidget, AnnotationWidget
veltr
parents: 875
diff changeset
   147
            left: _x,
03967b6ada7c ArrowWidget, AnnotationWidget
veltr
parents: 875
diff changeset
   148
            top: _y,
03967b6ada7c ArrowWidget, AnnotationWidget
veltr
parents: 875
diff changeset
   149
            color: _color,
03967b6ada7c ArrowWidget, AnnotationWidget
veltr
parents: 875
diff changeset
   150
            width: (_this.element_width-1),
03967b6ada7c ArrowWidget, AnnotationWidget
veltr
parents: 875
diff changeset
   151
            height: _this.element_height
03967b6ada7c ArrowWidget, AnnotationWidget
veltr
parents: 875
diff changeset
   152
        });
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   153
    }
194
f5d86e5c4a56 some cleaning. Also added a progression indicator.
hamidouk
parents: 192
diff changeset
   154
    
874
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   155
    IriSP._(_slices).forEach(function(_slice) {
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   156
        var _y = _this.height;
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   157
        _slice.annotations.forEach(function(_annotation) {
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   158
            _y -= _this.element_height;
880
4c7b33bf2795 Started work on CreateAnnotation and Mediafragment
veltr
parents: 876
diff changeset
   159
            displayElement(_x, _y, _this.defaultcolor, _annotation.id, _annotation.title);
874
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   160
        });
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   161
        IriSP._(_slice.polemicStacks).forEach(function(_annotations, _j) {
880
4c7b33bf2795 Started work on CreateAnnotation and Mediafragment
veltr
parents: 876
diff changeset
   162
            var _color = _this.polemics[_j].color;
874
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   163
            _annotations.forEach(function(_annotation) {
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   164
                _y -= _this.element_height;
880
4c7b33bf2795 Started work on CreateAnnotation and Mediafragment
veltr
parents: 876
diff changeset
   165
                displayElement(_x, _y, _color, _annotation.id, _annotation.title);
874
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   166
            });
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   167
        });
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   168
        _x += _this.element_width;
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   169
    });
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   170
    
876
03967b6ada7c ArrowWidget, AnnotationWidget
veltr
parents: 875
diff changeset
   171
    this.$zone.append(_html);
03967b6ada7c ArrowWidget, AnnotationWidget
veltr
parents: 875
diff changeset
   172
    
874
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   173
    this.$tweets = this.$.find(".Ldt-Polemic-TweetDiv");
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   174
    
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   175
    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
   176
        
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   177
    this.$zone.append(this.$position);
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   178
    
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   179
    this.$tweets
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   180
        .mouseover(function() {
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   181
            var _el = IriSP.jQuery(this);
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   182
            _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
   183
        })
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   184
        .mouseout(function() {
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   185
            _this.tooltip.hide();
880
4c7b33bf2795 Started work on CreateAnnotation and Mediafragment
veltr
parents: 876
diff changeset
   186
        })
4c7b33bf2795 Started work on CreateAnnotation and Mediafragment
veltr
parents: 876
diff changeset
   187
        .click(function() {
4c7b33bf2795 Started work on CreateAnnotation and Mediafragment
veltr
parents: 876
diff changeset
   188
            _this.player.popcorn.trigger("IriSP.Tweet.show", IriSP.jQuery(this).attr("annotation-id"));
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
    this.$zone.click(function(_e) {
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   192
        var _x = _e.pageX - _this.$zone.offset().left;
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   193
        _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
   194
    });
194
f5d86e5c4a56 some cleaning. Also added a progression indicator.
hamidouk
parents: 192
diff changeset
   195
}
f5d86e5c4a56 some cleaning. Also added a progression indicator.
hamidouk
parents: 192
diff changeset
   196
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   197
IriSP.Widgets.Polemic.prototype.onTimeupdate = function() {
874
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   198
    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
   199
    this.$elapsed.css({
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   200
        width:  _x + "px"
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   201
    });
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   202
    this.$position.css({
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   203
        left: _x + "px"
874
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   204
    })
38b65761a7d5 TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents: 842
diff changeset
   205
}