src/widgets/Segments.js
author durandn
Tue, 01 Sep 2015 15:31:46 +0200
changeset 1046 eb77616c245f
parent 1044 d8339b45edc4
child 1058 ded3cd1312c1
permissions -rw-r--r--
Updated LatestAnnotation, CurrentSegmentInfobox, AnnotationController and AnnotationList widgets to use timerange to find the current segment when the corresponding option is used + CurrentSegmentInfobox now has an option for editing the current segment + LatestAnnotation now has a "Copy and edit" button that allows to use the text from the currently displayed annotation into the CreateAnnotation widget textarea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
     1
// TODO: Trigger IriSP.SegmentsWidget.click
876
03967b6ada7c ArrowWidget, AnnotationWidget
veltr
parents: 875
diff changeset
     2
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
diff changeset
     3
IriSP.Widgets.Segments = function(player, config) {
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
diff changeset
     4
    IriSP.Widgets.Widget.call(this, player, config);
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
diff changeset
     5
};
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
diff changeset
     6
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
diff changeset
     7
IriSP.Widgets.Segments.prototype = new IriSP.Widgets.Widget();
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
diff changeset
     8
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
diff changeset
     9
IriSP.Widgets.Segments.prototype.defaults = {
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
diff changeset
    10
    annotation_type : "chap",
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
diff changeset
    11
    colors: ["#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"],
982
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    12
    line_height: 8,
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    13
    background: "#e0e0e0",
983
97fef7a4b189 updated search
veltr
parents: 982
diff changeset
    14
    overlap: .25,
97fef7a4b189 updated search
veltr
parents: 982
diff changeset
    15
    found_color: "#FF00FC",
1033
c20df1c080e6 integrate changes from github
ymh <ymh.work@gmail.com>
parents: 1026
diff changeset
    16
    faded_found_color: "#ff80fc",
1044
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
    17
    selected_color: "#74d600",
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
    18
    faded_selected_color: "#baf9b5",
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
    19
    no_tooltip: false,
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
    20
    use_timerange: false,
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
diff changeset
    21
};
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
diff changeset
    22
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
diff changeset
    23
IriSP.Widgets.Segments.prototype.template =
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
    24
    '<div class="Ldt-Segments-List"></div>'
924
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 916
diff changeset
    25
    + '<div class="Ldt-Segments-Position"></div>'
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 916
diff changeset
    26
    + '<div class="Ldt-Segments-Tooltip"></div>';
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
diff changeset
    27
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
    28
IriSP.Widgets.Segments.prototype.annotationTemplate =
996
c472984db275 refactored drag-and-drop interface (IE Compatibility)
veltr
parents: 994
diff changeset
    29
    '<div class="Ldt-Segments-Segment Ldt-TraceMe" trace-info="segment-id:{{id}}, media-id:{{media_id}}, from:{{from}}, to:{{to}}" segment-text="{{text}}"'
1013
392ddcd212d7 Throwed in a bunch of semicolons
veltr
parents: 996
diff changeset
    30
    + 'style="top:{{top}}px; height:{{height}}px; left:{{left}}px; width:{{width}}px; background:{{medcolor}}" data-base-color="{{color}}" data-low-color="{{lowcolor}}" data-medium-color="{{medcolor}}"></div>';
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
    31
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
    32
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
diff changeset
    33
IriSP.Widgets.Segments.prototype.draw = function() {
957
4da0a5740b6c Starting 'players-as-widgets' branch
veltr
parents: 937
diff changeset
    34
    this.onMediaEvent("timeupdate", "onTimeupdate");
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
    35
    this.renderTemplate();
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
    36
    
982
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    37
    var _list = this.getWidgetAnnotations().filter(function(_ann) {
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    38
            return _ann.getDuration() > 0;
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    39
        }),
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
diff changeset
    40
        _this = this,
983
97fef7a4b189 updated search
veltr
parents: 982
diff changeset
    41
        _scale = this.width / this.source.getDuration(),
97fef7a4b189 updated search
veltr
parents: 982
diff changeset
    42
        list_$ = this.$.find('.Ldt-Segments-List'),
982
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    43
        lines = [],
983
97fef7a4b189 updated search
veltr
parents: 982
diff changeset
    44
        zindex = 1,
97fef7a4b189 updated search
veltr
parents: 982
diff changeset
    45
        searching = false;
982
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    46
    
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    47
    function saturate(r, g, b, s) {
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    48
        function satcomp(c) {
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    49
            return Math.floor(240 * (1 - s) + c * s);
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    50
        }
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    51
        var res = ( 0x10000 * satcomp(r) + 0x100 * satcomp(g) + satcomp(b)).toString(16);
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    52
        while (res.length < 6) {
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    53
            res = "0" + res;
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    54
        }
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    55
        return "#" + res;
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    56
    }
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    57
    
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
    58
    _list.forEach(function(_annotation, _k) {
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
    59
        var _left = _annotation.begin * _scale,
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
    60
            _width = ( _annotation.getDuration() ) * _scale,
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
    61
            _center = Math.floor( _left + _width / 2 ),
982
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    62
            _fulltext = _annotation.title + ( _annotation.description ? ( '<br/>' + _annotation.description ) : '' ),
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    63
            line = IriSP._(lines).find(function(line) {
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    64
                return !IriSP._(line.annotations).find(function(a) {
1013
392ddcd212d7 Throwed in a bunch of semicolons
veltr
parents: 996
diff changeset
    65
                    return a.begin < _annotation.end && a.end > _annotation.begin;
982
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    66
                });
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    67
            });
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    68
        if (!line) {
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    69
            line = { index: lines.length, annotations: []};
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    70
            lines.push(line); 
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    71
        }
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    72
        line.annotations.push(_annotation);
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    73
        var _top = ((1 - _this.overlap) * line.index) * _this.line_height,
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    74
            color = ( typeof _annotation.color !== "undefined" && _annotation.color ? _annotation.color : _this.colors[_k % _this.colors.length] ),
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    75
            r = parseInt(color.substr(1,2),16),
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    76
            g = parseInt(color.substr(3,2),16),
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    77
            b = parseInt(color.substr(5,2),16),
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    78
            medcolor = saturate(r, g, b, .5),
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    79
            lowcolor = saturate(r, g, b, .2);
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
    80
        var _data = {
982
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    81
            color : color,
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    82
            medcolor: medcolor,
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    83
            lowcolor: lowcolor,
1044
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
    84
            text: (_annotation.creator ? (_annotation.creator + " : ") : "" ) + _fulltext.replace(/(\n|\r|\r\n)/mg,' ').replace(/(^.{120,140})[\s].+$/m,'$1&hellip;'),
982
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    85
            left : _left,
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    86
            width : _width,
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    87
            top: _top,
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
    88
            height: _this.line_height - 1,
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
    89
            id : _annotation.id,
990
6a90c96f0b4c Improvements on traces
veltr
parents: 986
diff changeset
    90
            media_id : _annotation.getMedia().id,
6a90c96f0b4c Improvements on traces
veltr
parents: 986
diff changeset
    91
            from: _annotation.begin.toString(),
6a90c96f0b4c Improvements on traces
veltr
parents: 986
diff changeset
    92
            to: _annotation.end.toString()
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
    93
        };
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
    94
        var _html = Mustache.to_html(_this.annotationTemplate, _data),
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
    95
            _el = IriSP.jQuery(_html);
1044
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
    96
        _el.mouseover(function() {
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
    97
                _annotation.trigger("select");
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
    98
            })
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
    99
            .mouseout(function() {
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   100
                _annotation.trigger("unselect");
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   101
            })
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   102
            .click(function() {
1044
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   103
                if(_this.use_timerange){
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   104
                    if(!_this.media.getTimeRange()){
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   105
                        _this.media.setTimeRange(_annotation.begin, _annotation.end)              
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   106
                        _this.$segments.each(function(){
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   107
                            var _segment = IriSP.jQuery(this);
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   108
                            _segment.css("background", lowcolor).removeClass("selected");
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   109
                        })
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   110
                        _el.css("background", _this.selected_color).addClass("selected");
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   111
                    }
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   112
                    else if (_this.media.getTimeRange()[0]==_annotation.begin || _this.media.getTimeRange()[1]==_annotation.end){
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   113
                        _this.media.resetTimeRange();
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   114
                        _this.$segments.each(function(){
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   115
                            var _segment = IriSP.jQuery(this);
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   116
                            _segment.css("background", lowcolor).removeClass("selected");
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   117
                            _annotation.trigger("select");
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   118
                        })
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   119
                    }
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   120
                    else {
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   121
                        _this.media.setTimeRange(_annotation.begin, _annotation.end);
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   122
                        _this.$segments.each(function(){
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   123
                            var _segment = IriSP.jQuery(this);
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   124
                            _segment.css("background", lowcolor).removeClass("selected");
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   125
                        })
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   126
                        _el.css("background", _this.selected_color).addClass("selected");
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   127
                    }
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   128
                }
964
d7d56ea2d0a6 Adaptations for Knowledge Concierge
veltr
parents: 959
diff changeset
   129
                _annotation.trigger("click");
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   130
            })
996
c472984db275 refactored drag-and-drop interface (IE Compatibility)
veltr
parents: 994
diff changeset
   131
            .appendTo(list_$);
c472984db275 refactored drag-and-drop interface (IE Compatibility)
veltr
parents: 994
diff changeset
   132
        IriSP.attachDndData(_el, {
c472984db275 refactored drag-and-drop interface (IE Compatibility)
veltr
parents: 994
diff changeset
   133
        	title: _annotation.title,
c472984db275 refactored drag-and-drop interface (IE Compatibility)
veltr
parents: 994
diff changeset
   134
        	description: _annotation.description,
c472984db275 refactored drag-and-drop interface (IE Compatibility)
veltr
parents: 994
diff changeset
   135
        	uri: (typeof _annotation.url !== "undefined" 
c472984db275 refactored drag-and-drop interface (IE Compatibility)
veltr
parents: 994
diff changeset
   136
                ? _annotation.url
c472984db275 refactored drag-and-drop interface (IE Compatibility)
veltr
parents: 994
diff changeset
   137
                : (document.location.href.replace(/#.*$/,'') + '#id='  + _annotation.id)),
c472984db275 refactored drag-and-drop interface (IE Compatibility)
veltr
parents: 994
diff changeset
   138
            image: _annotation.thumbnail
c472984db275 refactored drag-and-drop interface (IE Compatibility)
veltr
parents: 994
diff changeset
   139
        });
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   140
        _annotation.on("select", function() {
982
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
   141
            _this.$segments.each(function() {
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
   142
                var _segment = IriSP.jQuery(this);
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
   143
                _segment.css({
983
97fef7a4b189 updated search
veltr
parents: 982
diff changeset
   144
                    background: _segment.hasClass("found") ? _this.faded_found_color : _segment.attr("data-low-color")
982
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
   145
                });
1044
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   146
                _segment.css({
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   147
                    background: _segment.hasClass("selected") ? _this.faded_selected_color : _segment.attr("data-low-color")
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   148
                })
982
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
   149
            });
983
97fef7a4b189 updated search
veltr
parents: 982
diff changeset
   150
            _el.css({
97fef7a4b189 updated search
veltr
parents: 982
diff changeset
   151
                background: _el.hasClass("found") ? _this.found_color: color,
1044
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   152
                background: _el.hasClass("selected") ? _this.selected_color: color,
983
97fef7a4b189 updated search
veltr
parents: 982
diff changeset
   153
                "z-index": ++zindex
97fef7a4b189 updated search
veltr
parents: 982
diff changeset
   154
            });
986
f9d51dd4a3fe Tooltip Improvements, Update Popcorn
veltr
parents: 983
diff changeset
   155
            if (_this.tooltip) {
f9d51dd4a3fe Tooltip Improvements, Update Popcorn
veltr
parents: 983
diff changeset
   156
                _this.tooltip.show( _center, _top, _data.text, _data.color );
f9d51dd4a3fe Tooltip Improvements, Update Popcorn
veltr
parents: 983
diff changeset
   157
            }
983
97fef7a4b189 updated search
veltr
parents: 982
diff changeset
   158
        });
97fef7a4b189 updated search
veltr
parents: 982
diff changeset
   159
        _annotation.on("unselect", function() {
986
f9d51dd4a3fe Tooltip Improvements, Update Popcorn
veltr
parents: 983
diff changeset
   160
            if (_this.tooltip) {
f9d51dd4a3fe Tooltip Improvements, Update Popcorn
veltr
parents: 983
diff changeset
   161
                _this.tooltip.hide();
f9d51dd4a3fe Tooltip Improvements, Update Popcorn
veltr
parents: 983
diff changeset
   162
            }
983
97fef7a4b189 updated search
veltr
parents: 982
diff changeset
   163
            _this.$segments.each(function() {
97fef7a4b189 updated search
veltr
parents: 982
diff changeset
   164
                var _segment = IriSP.jQuery(this);
97fef7a4b189 updated search
veltr
parents: 982
diff changeset
   165
                _segment.css("background", _segment.hasClass("found") ? _this.found_color : _segment.attr(searching ? "data-low-color" : "data-medium-color"));
1044
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   166
                _segment.css("background", _segment.hasClass("selected") ? _this.selected_color : _segment.attr(searching ? "data-low-color" : "data-medium-color"));
982
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
   167
            });
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   168
        });
983
97fef7a4b189 updated search
veltr
parents: 982
diff changeset
   169
        _annotation.on("found", function() {
97fef7a4b189 updated search
veltr
parents: 982
diff changeset
   170
            _el.css("background", _this.found_color).addClass("found");
97fef7a4b189 updated search
veltr
parents: 982
diff changeset
   171
        });
97fef7a4b189 updated search
veltr
parents: 982
diff changeset
   172
        _annotation.on("not-found", function() {
97fef7a4b189 updated search
veltr
parents: 982
diff changeset
   173
            _el.css("background", lowcolor).removeClass("found");
97fef7a4b189 updated search
veltr
parents: 982
diff changeset
   174
        });
982
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
   175
    });
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
   176
    
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
   177
    this.$.css({
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
   178
        width : this.width + "px",
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
   179
        height : (((1 - this.overlap) * lines.length + this.overlap) * this.line_height) + "px",
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
   180
        background : this.background,
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
   181
        margin: "1px 0"
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   182
    });
1044
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   183
    if (!this.no_tooltip){
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   184
        this.insertSubwidget(
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   185
            this.$.find(".Ldt-Segments-Tooltip"),
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   186
            {
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   187
                type: "Tooltip",
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   188
                min_x: 0,
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   189
                max_x: this.width
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   190
            },
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   191
            "tooltip"
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   192
        );
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   193
    }
876
03967b6ada7c ArrowWidget, AnnotationWidget
veltr
parents: 875
diff changeset
   194
    this.$segments = this.$.find('.Ldt-Segments-Segment');
983
97fef7a4b189 updated search
veltr
parents: 982
diff changeset
   195
    this.source.getAnnotations().on("search", function() {
97fef7a4b189 updated search
veltr
parents: 982
diff changeset
   196
        searching = true;
97fef7a4b189 updated search
veltr
parents: 982
diff changeset
   197
    });
97fef7a4b189 updated search
veltr
parents: 982
diff changeset
   198
    this.source.getAnnotations().on("search-cleared", function() {
97fef7a4b189 updated search
veltr
parents: 982
diff changeset
   199
        searching = false;
982
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
   200
        _this.$segments.each(function() {
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
   201
            var _segment = IriSP.jQuery(this);
983
97fef7a4b189 updated search
veltr
parents: 982
diff changeset
   202
            _segment.css("background", _segment.attr("data-medium-color")).removeClass("found");
982
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 964
diff changeset
   203
        });
983
97fef7a4b189 updated search
veltr
parents: 982
diff changeset
   204
    });
1013
392ddcd212d7 Throwed in a bunch of semicolons
veltr
parents: 996
diff changeset
   205
};
876
03967b6ada7c ArrowWidget, AnnotationWidget
veltr
parents: 875
diff changeset
   206
1044
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   207
IriSP.Widgets.Segments.prototype.onTimeupdate = function(_time) {    
957
4da0a5740b6c Starting 'players-as-widgets' branch
veltr
parents: 937
diff changeset
   208
    var _x = Math.floor( this.width * _time / this.media.duration);
876
03967b6ada7c ArrowWidget, AnnotationWidget
veltr
parents: 875
diff changeset
   209
    this.$.find('.Ldt-Segments-Position').css({
03967b6ada7c ArrowWidget, AnnotationWidget
veltr
parents: 875
diff changeset
   210
        left: _x + "px"
1013
392ddcd212d7 Throwed in a bunch of semicolons
veltr
parents: 996
diff changeset
   211
    });
1033
c20df1c080e6 integrate changes from github
ymh <ymh.work@gmail.com>
parents: 1026
diff changeset
   212
};
1044
d8339b45edc4 Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents: 1033
diff changeset
   213