web/res/metadataplayer/Polemic.js
author Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
Fri, 01 Jan 2016 01:11:05 +0100
changeset 1308 ef42d4f12cfc
parent 1304 10974bff4dae
permissions -rw-r--r--
add grammar version if on annotation + upgrade metadataplayer to take it into account
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
598
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     1
IriSP.Widgets.Polemic = function(player, config) {
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     2
    IriSP.Widgets.Widget.call(this, player, config);
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     3
};
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     4
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     5
IriSP.Widgets.Polemic.prototype = new IriSP.Widgets.Widget();
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     6
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     7
IriSP.Widgets.Polemic.prototype.messages = {
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     8
    fr: {
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     9
        from_: "de ",
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    10
        _to_: " à ",
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    11
        _annotations: " annotation(s)"
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    12
    },
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    13
    en: {
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    14
        from_: "from ",
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    15
        _to_: " to ",
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    16
        _annotations: " annotation(s)"
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    17
    }
955
5171f8825985 Updated Metadataplayer
Raphael Velt <raph.velt@gmail.com>
parents: 940
diff changeset
    18
};
5171f8825985 Updated Metadataplayer
Raphael Velt <raph.velt@gmail.com>
parents: 940
diff changeset
    19
598
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    20
IriSP.Widgets.Polemic.prototype.defaults = {
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    21
    element_width : 5,
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    22
    element_height : 5,
765
8cde4d15a173 Update Metadataplayer
Raphael Velt <raph.velt@gmail.com>
parents: 755
diff changeset
    23
    max_elements: 20,
598
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    24
    annotation_type : "tweet",
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    25
    defaultcolor : "#585858",
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    26
    foundcolor : "#fc00ff",
1304
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    27
    default_version : "1",
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    28
    polemics : {
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    29
        "1" : [
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    30
            {
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    31
                "name" : "OK",
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    32
                "keywords" : [ "++" ],
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    33
                "color" : "#1D973D"
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    34
            },
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    35
            {
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    36
                "name" : "KO",
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    37
                "keywords" : [ "--" ],
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    38
                "color" : "#CE0A15"
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    39
            },
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    40
            {
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    41
                "name" : "REF",
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    42
                "keywords" : [ "==", "http://" ],
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    43
                "color" : "#C5A62D"
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    44
            },
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    45
            {
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    46
                "name" : "Q",
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    47
                "keywords" : [ "?" ],
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    48
                "color" : "#036AAE"
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    49
            }
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    50
        ],
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    51
        "2" : [
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    52
            {
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    53
                "name" : "OK",
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    54
                "keywords" : [ "++" ],
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    55
                "color" : "#1D973D"
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    56
            },
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    57
            {
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    58
                "name" : "KO",
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    59
                "keywords" : [ "!!" ],
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    60
                "color" : "#CE0A15"
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    61
            },
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    62
            {
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    63
                "name" : "REF",
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    64
                "keywords" : [ "==", "http://" ],
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    65
                "color" : "#C5A62D"
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    66
            },
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    67
            {
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    68
                "name" : "Q",
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    69
                "keywords" : [ "?" ],
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    70
                "color" : "#036AAE"
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    71
            }
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    72
        ]
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    73
    }
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    74
};
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    75
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    76
IriSP.Widgets.Polemic.prototype.getPolemics = function(version) {
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    77
    if(typeof(version) === "undefined" || !version) {
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    78
        version = this.default_version;
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    79
    }
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    80
    if(this.polemics.constructor === Array) {
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    81
        return this.polemics;
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    82
    } else {
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    83
        return this.polemics[version];
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
    84
    }
598
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    85
};
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    86
1308
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
    87
IriSP.Widgets.Polemic.prototype.drawNoStackgraph = function(_max, _slices) {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
    88
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
    89
    var _this = this;
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
    90
    this.is_stackgraph = false;
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
    91
    if (_max) {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
    92
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
    93
        this.height = (2 + _max) * this.element_height;
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
    94
        this.$zone.css({
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
    95
            width: this.width + "px",
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
    96
            height: this.height + "px",
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
    97
            position: "relative"
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
    98
        });
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
    99
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   100
        var _x = 0;
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   101
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   102
        function displayAnnotation(_elx, _ely, _pol, _col, _annotation) {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   103
            var _htmlAnnot = Mustache.to_html(
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   104
                '<div class="Ldt-Polemic-TweetDiv Ldt-TraceMe" trace-info="annotation-id:{{id}}, media-id:{{media_id}}, polemic:{{polemic}}, time:{{time}}" polemic-color="{{color}}"'
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   105
                + ' tweet-title="{{title}}" annotation-id="{{id}}" style="width: {{width}}px; height: {{height}}px; top: {{top}}px; left: {{left}}px; background: {{color}}"></div>',
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   106
            {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   107
                id: _annotation.id,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   108
                media_id: _this.source.currentMedia.id,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   109
                polemic: _pol,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   110
                left: _elx,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   111
                top: _ely,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   112
                color: _col,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   113
                width: (_this.element_width-1),
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   114
                height: _this.element_height,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   115
                title: _annotation.title,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   116
                time: _annotation.begin.toString()
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   117
            });
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   118
            var _el = IriSP.jQuery(_htmlAnnot);
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   119
            _el.mouseover(function() {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   120
                _annotation.trigger("select");
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   121
            }).mouseout(function() {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   122
                _annotation.trigger("unselect");
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   123
            }).click(function() {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   124
                _annotation.trigger("click");
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   125
                return false;
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   126
            });
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   127
            IriSP.attachDndData(_el, {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   128
                title: _annotation.title,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   129
                description: _annotation.description,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   130
                image: _annotation.thumbnail,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   131
                uri: (typeof _annotation.url !== "undefined"
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   132
                    ? _annotation.url
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   133
                    : (document.location.href.replace(/#.*$/,'') + '#id='  + _annotation.id)),
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   134
            text: '[' + _annotation.begin.toString() + '] ' + _annotation.title
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   135
            });
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   136
            // test if annotation has several colors.
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   137
            var colAr = [];
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   138
            var _polemicVersion = (_annotation.content && _annotation.content.polemic_version) || _this.default_version,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   139
                _polemics = _this.getPolemics(_polemicVersion) || [],
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   140
                _pol,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   141
                _polKey,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   142
                _polDef,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   143
                _rgxp;
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   144
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   145
            for(var _j = 0; _j < _polemics.length; _j++) {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   146
                _pol = _polemics[_j];
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   147
                _rgxp = IriSP.Model.regexpFromTextOrArray(_pol.keywords);
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   148
                if(_rgxp.test(_annotation.description)) {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   149
                    colAr.push(_pol.color);
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   150
                }
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   151
            }
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   152
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   153
            // display annotation
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   154
            _annotation.on("select", function() {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   155
                if (_this.tooltip) {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   156
                    _this.tooltip.show(
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   157
                        + Math.floor(_elx + (_this.element_width - 1) / 2),
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   158
                        + _ely,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   159
                        _annotation.title,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   160
                        ( (colAr.length>1) ? colAr : _col )
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   161
                    );
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   162
                }
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   163
                _this.$tweets.each(function() {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   164
                    var _e = IriSP.jQuery(this);
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   165
                    _e.css(
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   166
                        "opacity",
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   167
                        ( _e.attr("annotation-id") == _annotation.id ? 1 : .3 )
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   168
                    );
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   169
                });
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   170
            });
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   171
            _annotation.on("unselect", function() {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   172
                if (_this.tooltip) {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   173
                    _this.tooltip.hide();
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   174
                }
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   175
                _this.$tweets.css("opacity",1);
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   176
            });
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   177
            _annotation.on("found", function() {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   178
                _el.css({
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   179
                    "background" : _this.foundcolor,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   180
                    "opacity" : 1
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   181
                });
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   182
            });
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   183
            _annotation.on("not-found", function() {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   184
                _el.css({
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   185
                    "background" : _col,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   186
                    "opacity" : .3
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   187
                });
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   188
            });
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   189
            _this.$zone.append(_el);
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   190
        };
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   191
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   192
        IriSP._(_slices).forEach(function(_slice) {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   193
            var _y = _this.height;
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   194
            _slice.annotations.forEach(function(_annotation) {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   195
                _y -= _this.element_height;
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   196
                displayAnnotation(_x, _y, "none", _this.defaultcolor, _annotation);
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   197
            });
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   198
            IriSP._(_slice.polemicStacks).forEach(function(_annotations) {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   199
                var _color = _annotations.polemicDef.color,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   200
                    _polemic = _annotations.polemicDef.name;
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   201
                _annotations.annotations.forEach(function(_annotation) {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   202
                    _y -= _this.element_height;
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   203
                    displayAnnotation(_x, _y, _polemic, _color, _annotation);
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   204
                });
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   205
            });
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   206
            _x += _this.element_width;
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   207
        });
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   208
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   209
        this.$tweets = this.$.find(".Ldt-Polemic-TweetDiv");
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   210
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   211
        this.source.getAnnotations().on("search-cleared", function() {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   212
            _this.$tweets.each(function() {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   213
                var _el = IriSP.jQuery(this);
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   214
                _el.css({
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   215
                    "background" : _el.attr("polemic-color"),
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   216
                    "opacity" : 1
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   217
                });
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   218
            });
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   219
        });
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   220
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   221
    } else {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   222
        this.$zone.hide();
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   223
    }
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   224
}
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   225
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   226
IriSP.Widgets.Polemic.prototype.drawStackgraph = function(_max, _slices) {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   227
    this.is_stackgraph = true;
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   228
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   229
    var _this = this;
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   230
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   231
    this.height = (2 + this.max_elements) * this.element_height;
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   232
    this.$zone.css({
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   233
        width: this.width + "px",
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   234
        height: this.height + "px",
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   235
        position: "relative"
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   236
    });
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   237
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   238
    var _x = 0,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   239
        _html = '',
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   240
        _scale = this.max_elements * this.element_height / _max;
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   241
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   242
    function displayStackElement(_x, _y, _h, _color, _nums, _begin, _end, _polemic) {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   243
        _html += Mustache.to_html(
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   244
            '<div class="Ldt-Polemic-TweetDiv Ldt-TraceMe" trace-info="annotation-block, media-id={{media_id}}, polemic={{polemic}}, time:{{begin}}" pos-x="{{posx}}" pos-y="{{top}}" annotation-counts="{{nums}}" begin-time="{{begin}}" end-time="{{end}}"'
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   245
            + ' style="width: {{width}}px; height: {{height}}px; top: {{top}}px; left: {{left}}px; background: {{color}}"></div>',
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   246
        {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   247
            nums: _nums,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   248
            posx: Math.floor(_x + (_this.element_width - 1) / 2),
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   249
            media_id: _this.source.currentMedia.id,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   250
            polemic: _polemic,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   251
            left: _x,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   252
            top: _y,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   253
            color: _color,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   254
            width: (_this.element_width-1),
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   255
            height: _h,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   256
            begin: _begin,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   257
            end: _end
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   258
        });
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   259
    }
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   260
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   261
    IriSP._(_slices).forEach(function(_slice) {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   262
        var _y = _this.height,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   263
            _nums = _slice.annotations.length + "|" + _this.defaultcolor + "," + IriSP._(_slice.polemicStacks).map(function(_annotations) {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   264
                return _annotations.annotations.length + "|" + _annotations.polemicDef.color;
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   265
            }).join(",");
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   266
        if (_slice.annotations.length) {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   267
            var _h = Math.ceil(_scale * _slice.annotations.length);
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   268
            _y -= _h;
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   269
            displayStackElement(_x, _y, _h, _this.defaultcolor, _nums, _slice.begin, _slice.end, "none");
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   270
        }
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   271
        IriSP._(_slice.polemicStacks).forEach(function(_annotations) {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   272
            if (_annotations.annotations.length) {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   273
                var _color = _annotations.polemicDef.color,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   274
                    _polemic = _annotations.polemicDef.name,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   275
                    _h = Math.ceil(_scale * _annotations.annotations.length);
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   276
                _y -= _h;
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   277
                displayStackElement(_x, _y, _h, _color, _nums, _slice.begin, _slice.end, _polemic);
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   278
            }
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   279
        });
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   280
        _x += _this.element_width;
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   281
    });
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   282
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   283
    this.$zone.append(_html);
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   284
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   285
    this.$tweets = this.$.find(".Ldt-Polemic-TweetDiv");
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   286
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   287
    this.$tweets
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   288
        .mouseover(function() {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   289
            var _el = IriSP.jQuery(this),
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   290
                _nums = _el.attr("annotation-counts").split(","),
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   291
                _html = '<p>' + _this.l10n.from_ + _el.attr("begin-time") + _this.l10n._to_ + _el.attr("end-time") + '</p>';
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   292
            _html = IriSP._.reduce(_nums, function(_htmlStr, _countStr) {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   293
                var _components = _countStr.split("|");
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   294
                _htmlStr += '<div class="Ldt-Tooltip-AltColor" style="background: ' + _components[1] + '"></div><p>' + _components[0] + _this.l10n._annotations + '</p>';
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   295
                return _htmlStr;
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   296
            }, _html);
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   297
            if (_this.tooltip) {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   298
                _this.tooltip.show(+ _el.attr("pos-x"), + _el.attr("pos-y"), _html);
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   299
            }
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   300
        })
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   301
        .mouseout(function() {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   302
            if (_this.tooltip) {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   303
                _this.tooltip.hide();
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   304
            }
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   305
        });
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   306
}
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   307
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   308
598
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   309
IriSP.Widgets.Polemic.prototype.draw = function() {
1304
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
   310
694
e9400c80e1e4 Updated Metadataplayer
Raphael Velt <raph.velt@gmail.com>
parents: 668
diff changeset
   311
    this.onMediaEvent("timeupdate", "onTimeupdate");
598
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   312
    this.$zone = IriSP.jQuery('<div>');
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   313
    this.$zone.addClass("Ldt-Polemic");
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   314
    this.$.append(this.$zone);
1304
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
   315
598
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   316
    this.$elapsed = IriSP.jQuery('<div>')
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   317
        .css({
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   318
            background: '#cccccc',
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   319
            position: "absolute",
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   320
            top: 0,
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   321
            left: 0,
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   322
            width: 0,
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   323
            height: "100%"
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   324
        });
1304
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
   325
598
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   326
    this.$zone.append(this.$elapsed);
1304
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
   327
1198
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 955
diff changeset
   328
    // we don't filter with null duration anymore
598
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   329
    var _slices = [],
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   330
        _slice_count = Math.floor( this.width / this.element_width ),
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   331
        _duration = this.source.getDuration(),
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   332
        _max = 0,
1198
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 955
diff changeset
   333
        _list = this.getWidgetAnnotations(),
598
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   334
        _this = this;
1304
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
   335
598
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   336
    for (var _i = 0; _i < _slice_count; _i++) {
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   337
        var _begin = new IriSP.Model.Time( _i * _duration / _slice_count ),
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   338
            _end = new IriSP.Model.Time( ( _i + 1 ) * _duration / _slice_count ),
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   339
            _count = 0,
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   340
            _res = {
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   341
                begin : _begin.toString(),
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   342
                end : _end.toString(),
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   343
                annotations : _list.filter(function(_annotation) {
940
843f96e4eebd JwPlayer upgrade
Raphael Velt <raph.velt@gmail.com>
parents: 828
diff changeset
   344
                    return _annotation.begin >= _begin && _annotation.begin < _end;
598
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   345
                }),
1308
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   346
                polemicStacks : {}
955
5171f8825985 Updated Metadataplayer
Raphael Velt <raph.velt@gmail.com>
parents: 940
diff changeset
   347
            };
1304
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
   348
1308
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   349
        _res.annotations = _res.annotations.filter(function(_annotation) {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   350
            var _polemicVersion = (_annotation.content && _annotation.content.polemic_version) || _this.default_version,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   351
                _polemics = _this.getPolemics(_polemicVersion) || [],
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   352
                _pol,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   353
                _polKey,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   354
                _polDef,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   355
                _rgxp,
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   356
                _notMatched = true;
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   357
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   358
            for(var _j = 0; _j < _polemics.length; _j++) {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   359
                _pol = _polemics[_j];
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   360
                _rgxp = IriSP.Model.regexpFromTextOrArray(_pol.keywords);
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   361
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   362
                if(_rgxp.test(_annotation.description)) {
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   363
                    _polKey = _polemicVersion + "_" + _pol.name;
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   364
                    _polDef = _res.polemicStacks[_polKey] || (_res.polemicStacks[_polKey] = { 'polemicDef' : _pol, 'annotations': []});
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   365
                    _polDef.annotations.push(_annotation);
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   366
                    _notMatched = false;
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   367
                    _count++;
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   368
                }
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   369
            }
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   370
            return _notMatched;
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   371
        });
598
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   372
        _count += _res.annotations.length;
1308
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   373
598
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   374
        _max = Math.max(_max, _count);
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   375
        _slices.push(_res);
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   376
    }
1308
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   377
598
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   378
    if (_max < this.max_elements) {
1308
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   379
        this.drawNoStackgraph(_max, _slices);
598
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   380
    } else {
1308
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   381
        this.drawStackgraph(_max, _slices);
ef42d4f12cfc add grammar version if on annotation + upgrade metadataplayer to take it into account
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1304
diff changeset
   382
    }
1304
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
   383
598
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   384
    this.$position = IriSP.jQuery('<div>').addClass("Ldt-Polemic-Position");
1304
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
   385
598
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   386
    this.$zone.append(this.$position);
1304
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
   387
598
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   388
    this.$zone.click(function(_e) {
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   389
        var _x = _e.pageX - _this.$zone.offset().left;
694
e9400c80e1e4 Updated Metadataplayer
Raphael Velt <raph.velt@gmail.com>
parents: 668
diff changeset
   390
        _this.media.setCurrentTime(_this.media.duration * _x / _this.width);
598
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   391
    });
1304
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
   392
654
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents: 638
diff changeset
   393
    this.$.append('<div class="Ldt-Polemic-Tooltip"></div>');
1304
10974bff4dae upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 1198
diff changeset
   394
755
d50aeed9a54b Update Tooltip
Raphael Velt <raph.velt@gmail.com>
parents: 719
diff changeset
   395
    this.insertSubwidget(
d50aeed9a54b Update Tooltip
Raphael Velt <raph.velt@gmail.com>
parents: 719
diff changeset
   396
        this.$.find(".Ldt-Polemic-Tooltip"),
d50aeed9a54b Update Tooltip
Raphael Velt <raph.velt@gmail.com>
parents: 719
diff changeset
   397
        {
d50aeed9a54b Update Tooltip
Raphael Velt <raph.velt@gmail.com>
parents: 719
diff changeset
   398
            type: "Tooltip",
d50aeed9a54b Update Tooltip
Raphael Velt <raph.velt@gmail.com>
parents: 719
diff changeset
   399
            min_x: 0,
d50aeed9a54b Update Tooltip
Raphael Velt <raph.velt@gmail.com>
parents: 719
diff changeset
   400
            max_x: this.width
d50aeed9a54b Update Tooltip
Raphael Velt <raph.velt@gmail.com>
parents: 719
diff changeset
   401
        },
d50aeed9a54b Update Tooltip
Raphael Velt <raph.velt@gmail.com>
parents: 719
diff changeset
   402
        "tooltip"
d50aeed9a54b Update Tooltip
Raphael Velt <raph.velt@gmail.com>
parents: 719
diff changeset
   403
    );
955
5171f8825985 Updated Metadataplayer
Raphael Velt <raph.velt@gmail.com>
parents: 940
diff changeset
   404
};
598
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   405
694
e9400c80e1e4 Updated Metadataplayer
Raphael Velt <raph.velt@gmail.com>
parents: 668
diff changeset
   406
IriSP.Widgets.Polemic.prototype.onTimeupdate = function(_time) {
e9400c80e1e4 Updated Metadataplayer
Raphael Velt <raph.velt@gmail.com>
parents: 668
diff changeset
   407
    var _x = Math.floor( this.width * _time / this.media.duration);
598
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   408
    this.$elapsed.css({
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   409
        width:  _x + "px"
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   410
    });
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   411
    this.$position.css({
d366aa22bd79 New Metadataplayer version
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
   412
        left: _x + "px"
955
5171f8825985 Updated Metadataplayer
Raphael Velt <raph.velt@gmail.com>
parents: 940
diff changeset
   413
    });
5171f8825985 Updated Metadataplayer
Raphael Velt <raph.velt@gmail.com>
parents: 940
diff changeset
   414
};