src/widgets/Slice.js
branchnew-model
changeset 904 510ebab76fa3
parent 880 4c7b33bf2795
child 923 b3ee7d1b472a
equal deleted inserted replaced
903:d9da52e20f7f 904:510ebab76fa3
    18         .addClass("Ldt-Slice")
    18         .addClass("Ldt-Slice")
    19     
    19     
    20     this.$.append(this.$slider);
    20     this.$.append(this.$slider);
    21     
    21     
    22     this.min = 0;
    22     this.min = 0;
    23     this.max = this.source.getDuration().getSeconds();
    23     this.max = this.source.getDuration().valueOf();
    24     
    24     
    25     var _this = this;
    25     var _this = this;
    26     
    26     
    27     this.$slider.slider({
    27     this.$slider.slider({
    28         range: true,
    28         range: true,
    30         min: 0,
    30         min: 0,
    31         max: this.max,
    31         max: this.max,
    32         change: function(event, ui) {
    32         change: function(event, ui) {
    33             _this.player.popcorn.trigger("IriSP.Arrow.updatePosition",{
    33             _this.player.popcorn.trigger("IriSP.Arrow.updatePosition",{
    34                 widget:_this.type,
    34                 widget:_this.type,
    35                 time:Math.floor((ui.values[0]+ui.values[1])*500)
    35                 time:Math.floor((ui.values[0]+ui.values[1])/2)
    36             });
    36             });
    37             _this.player.popcorn.trigger("IriSP.Slice.valuesChanged",[ui.values[0]*1000, ui.values[1]*1000]);
    37             _this.player.popcorn.trigger("IriSP.Slice.boundsChanged",[ui.values[0], ui.values[1]]);
    38         }
    38         }
    39     });
    39     });
    40     this.$slider.find(".ui-slider-handle:first").addClass("Ldt-Slice-left-handle");
    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");
    41     this.$slider.find(".ui-slider-handle:last").addClass("Ldt-Slice-right-handle");
    42     if (this.start_visible) {
    42     if (this.start_visible) {
    44     } else {
    44     } else {
    45         this.hide();
    45         this.hide();
    46     }
    46     }
    47     this.bindPopcorn("IriSP.Slice.show","show");
    47     this.bindPopcorn("IriSP.Slice.show","show");
    48     this.bindPopcorn("IriSP.Slice.hide","hide");
    48     this.bindPopcorn("IriSP.Slice.hide","hide");
    49     this.bindPopcorn("IriSP.Annotation.boundsChanged","storeBounds")
    49     this.bindPopcorn("IriSP.Annotation.boundsChanged","storeBounds");
    50 };
    50 };
    51 
    51 
    52 IriSP.Widgets.Slice.prototype.show = function() {
    52 IriSP.Widgets.Slice.prototype.show = function() {
    53     this.$slider.show();
    53     this.$slider.show();
    54     this.player.popcorn.trigger("IriSP.Arrow.takeover",this.type);
    54     this.player.popcorn.trigger("IriSP.Arrow.takeover",this.type);
    59     this.$slider.hide();
    59     this.$slider.hide();
    60     this.player.popcorn.trigger("IriSP.Arrow.release");
    60     this.player.popcorn.trigger("IriSP.Arrow.release");
    61 }
    61 }
    62 
    62 
    63 IriSP.Widgets.Slice.prototype.storeBounds = function(_values) {
    63 IriSP.Widgets.Slice.prototype.storeBounds = function(_values) {
    64     this.min = Math.floor(_values[0]/1000);
    64     this.min = _values[0];
    65     this.max = Math.floor(_values[1]/1000);
    65     this.max = _values[1];
    66 }
    66 }