src/widgets/Slice.js
branchnew-model
changeset 880 4c7b33bf2795
child 904 510ebab76fa3
equal deleted inserted replaced
876:03967b6ada7c 880:4c7b33bf2795
       
     1 /*
       
     2  The Slider Widget shows time position and allows seek
       
     3  */
       
     4 
       
     5 IriSP.Widgets.Slice = function(player, config) {
       
     6     IriSP.Widgets.Widget.call(this, player, config);
       
     7 };
       
     8 
       
     9 IriSP.Widgets.Slice.prototype = new IriSP.Widgets.Widget();
       
    10 
       
    11 IriSP.Widgets.Slice.prototype.defaults = {
       
    12     start_visible : false
       
    13 };
       
    14 
       
    15 IriSP.Widgets.Slice.prototype.draw = function() {
       
    16     
       
    17     this.$slider = IriSP.jQuery('<div>')
       
    18         .addClass("Ldt-Slice")
       
    19     
       
    20     this.$.append(this.$slider);
       
    21     
       
    22     this.min = 0;
       
    23     this.max = this.source.getDuration().getSeconds();
       
    24     
       
    25     var _this = this;
       
    26     
       
    27     this.$slider.slider({
       
    28         range: true,
       
    29         values: [0, 0],
       
    30         min: 0,
       
    31         max: this.max,
       
    32         change: function(event, ui) {
       
    33             _this.player.popcorn.trigger("IriSP.Arrow.updatePosition",{
       
    34                 widget:_this.type,
       
    35                 time:Math.floor((ui.values[0]+ui.values[1])*500)
       
    36             });
       
    37             _this.player.popcorn.trigger("IriSP.Slice.valuesChanged",[ui.values[0]*1000, ui.values[1]*1000]);
       
    38         }
       
    39     });
       
    40     this.$slider.find(".ui-slider-handle:first").addClass("Ldt-Slice-left-handle");
       
    41     this.$slider.find(".ui-slider-handle:last").addClass("Ldt-Slice-right-handle");
       
    42     if (this.start_visible) {
       
    43         this.show();
       
    44     } else {
       
    45         this.hide();
       
    46     }
       
    47     this.bindPopcorn("IriSP.Slice.show","show");
       
    48     this.bindPopcorn("IriSP.Slice.hide","hide");
       
    49     this.bindPopcorn("IriSP.Annotation.boundsChanged","storeBounds")
       
    50 };
       
    51 
       
    52 IriSP.Widgets.Slice.prototype.show = function() {
       
    53     this.$slider.show();
       
    54     this.player.popcorn.trigger("IriSP.Arrow.takeover",this.type);
       
    55     this.$slider.slider("values", [this.min, this.max]);
       
    56 }
       
    57 
       
    58 IriSP.Widgets.Slice.prototype.hide = function() {
       
    59     this.$slider.hide();
       
    60     this.player.popcorn.trigger("IriSP.Arrow.release");
       
    61 }
       
    62 
       
    63 IriSP.Widgets.Slice.prototype.storeBounds = function(_values) {
       
    64     this.min = Math.floor(_values[0]/1000);
       
    65     this.max = Math.floor(_values[1]/1000);
       
    66 }