front_idill/src/player/metadataplayer/Slice.js
author bastiena
Mon, 24 Sep 2012 15:19:49 +0200
changeset 123 57a65edde708
parent 31 2c7fc855eba8
permissions -rw-r--r--
Front IDILL: non tmpl config files removed.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
     1
/*
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
     2
 The Slider Widget shows time position and allows seek
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
     3
 */
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
     4
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
     5
IriSP.Widgets.Slice = function(player, config) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
     6
    IriSP.Widgets.Widget.call(this, player, config);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
     7
};
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
     8
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
     9
IriSP.Widgets.Slice.prototype = new IriSP.Widgets.Widget();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    10
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    11
IriSP.Widgets.Slice.prototype.defaults = {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    12
    start_visible : false
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    13
};
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    14
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    15
IriSP.Widgets.Slice.prototype.draw = function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    16
    
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    17
    this.$slider = IriSP.jQuery('<div>')
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    18
        .addClass("Ldt-Slice")
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    19
    
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    20
    this.$.append(this.$slider);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    21
    
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    22
    this.min = 0;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    23
    this.max = this.source.getDuration().getSeconds();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    24
    
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    25
    var _this = this;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    26
    
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    27
    this.$slider.slider({
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    28
        range: true,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    29
        values: [0, 0],
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    30
        min: 0,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    31
        max: this.max,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    32
        change: function(event, ui) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    33
            _this.player.popcorn.trigger("IriSP.Arrow.updatePosition",{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    34
                widget:_this.type,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    35
                time:Math.floor((ui.values[0]+ui.values[1])*500)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    36
            });
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    37
            _this.player.popcorn.trigger("IriSP.Slice.valuesChanged",[ui.values[0]*1000, ui.values[1]*1000]);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    38
        }
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    39
    });
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    40
    this.$slider.find(".ui-slider-handle:first").addClass("Ldt-Slice-left-handle");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    41
    this.$slider.find(".ui-slider-handle:last").addClass("Ldt-Slice-right-handle");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    42
    if (this.start_visible) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    43
        this.show();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    44
    } else {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    45
        this.hide();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    46
    }
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    47
    this.bindPopcorn("IriSP.Slice.show","show");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    48
    this.bindPopcorn("IriSP.Slice.hide","hide");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    49
    this.bindPopcorn("IriSP.Annotation.boundsChanged","storeBounds")
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    50
};
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    51
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    52
IriSP.Widgets.Slice.prototype.show = function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    53
    this.$slider.show();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    54
    this.player.popcorn.trigger("IriSP.Arrow.takeover",this.type);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    55
    this.$slider.slider("values", [this.min, this.max]);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    56
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    57
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    58
IriSP.Widgets.Slice.prototype.hide = function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    59
    this.$slider.hide();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    60
    this.player.popcorn.trigger("IriSP.Arrow.release");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    61
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    62
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    63
IriSP.Widgets.Slice.prototype.storeBounds = function(_values) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    64
    this.min = Math.floor(_values[0]/1000);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    65
    this.max = Math.floor(_values[1]/1000);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    66
}