src/widgets/Polemic.js
branchplayers-as-widgets
changeset 957 4da0a5740b6c
parent 937 eb3c442cec50
child 959 ee11ed1b739e
equal deleted inserted replaced
956:7c1d08cf6956 957:4da0a5740b6c
    74             });
    74             });
    75         }
    75         }
    76     });
    76     });
    77     if (this.searchString) {
    77     if (this.searchString) {
    78         if (_found) {
    78         if (_found) {
    79             this.player.popcorn.trigger("IriSP.search.matchFound");
    79             this.player.trigger("search.matchFound");
    80         } else {
    80         } else {
    81             this.player.popcorn.trigger("IriSP.search.noMatchFound");
    81             this.player.trigger("search.noMatchFound");
    82         }
    82         }
    83     }
    83     }
    84 }
    84 }
    85 
    85 
    86 IriSP.Widgets.Polemic.prototype.draw = function() {
    86 IriSP.Widgets.Polemic.prototype.draw = function() {
    87     
    87     
    88     this.bindPopcorn("timeupdate", "onTimeupdate");
    88     this.onMediaEvent("timeupdate", "onTimeupdate");
    89     this.$zone = IriSP.jQuery('<div>');
    89     this.$zone = IriSP.jQuery('<div>');
    90     this.$zone.addClass("Ldt-Polemic");
    90     this.$zone.addClass("Ldt-Polemic");
    91     this.$.append(this.$zone);
    91     this.$.append(this.$zone);
    92     
    92     
    93     this.$elapsed = IriSP.jQuery('<div>')
    93     this.$elapsed = IriSP.jQuery('<div>')
   166                 _el.mouseover(function() {
   166                 _el.mouseover(function() {
   167                     _annotation.trigger("select");
   167                     _annotation.trigger("select");
   168                 }).mouseout(function() {
   168                 }).mouseout(function() {
   169                     _annotation.trigger("unselect");
   169                     _annotation.trigger("unselect");
   170                 }).click(function() {
   170                 }).click(function() {
   171                     _this.player.popcorn.trigger("IriSP.Mediafragment.setHashToAnnotation", _annotation.id);
   171                     _this.player.trigger("Mediafragment.setHashToAnnotation", _annotation.id);
   172                     _this.player.popcorn.trigger("IriSP.Tweet.show", _annotation.id);
   172                     _this.player.trigger("Tweet.show", _annotation.id);
   173                 });
   173                 });
   174                 _annotation.on("select", function() {
   174                 _annotation.on("select", function() {
   175                     _this.tooltip.show(
   175                     _this.tooltip.show(
   176                         Math.floor(_elx + (_this.element_width - 1) / 2),
   176                         Math.floor(_elx + (_this.element_width - 1) / 2),
   177                         _ely,
   177                         _ely,
   212             
   212             
   213             this.$zone.append(_html);
   213             this.$zone.append(_html);
   214             
   214             
   215             this.$tweets = this.$.find(".Ldt-Polemic-TweetDiv");
   215             this.$tweets = this.$.find(".Ldt-Polemic-TweetDiv");
   216             
   216             
   217             this.bindPopcorn("IriSP.search", "onSearch");
   217             this.onMdpEvent("search", "onSearch");
   218             this.bindPopcorn("IriSP.search.closed", "onSearch");
   218             this.onMdpEvent("search.closed", "onSearch");
   219             this.bindPopcorn("IriSP.search.cleared", "onSearch");
   219             this.onMdpEvent("search.cleared", "onSearch");
   220             
   220             
   221         } else {
   221         } else {
   222             this.$zone.hide();
   222             this.$zone.hide();
   223         }
   223         }
   224     } else {
   224     } else {
   301         
   301         
   302     this.$zone.append(this.$position);
   302     this.$zone.append(this.$position);
   303     
   303     
   304     this.$zone.click(function(_e) {
   304     this.$zone.click(function(_e) {
   305         var _x = _e.pageX - _this.$zone.offset().left;
   305         var _x = _e.pageX - _this.$zone.offset().left;
   306         _this.player.popcorn.currentTime(_this.source.getDuration().getSeconds() * _x / _this.width);
   306         _this.media.setCurrentTime(_this.media.duration * _x / _this.width);
   307     });
   307     });
   308     
   308     
   309     this.$.append('<div class="Ldt-Polemic-Tooltip"></div>');
   309     this.$.append('<div class="Ldt-Polemic-Tooltip"></div>');
   310     
   310     
   311     this.insertSubwidget(this.$.find(".Ldt-Polemic-Tooltip"), "tooltip", { type: "Tooltip" });
   311     this.insertSubwidget(this.$.find(".Ldt-Polemic-Tooltip"), "tooltip", { type: "Tooltip" });
   312 }
   312 }
   313 
   313 
   314 IriSP.Widgets.Polemic.prototype.onTimeupdate = function() {
   314 IriSP.Widgets.Polemic.prototype.onTimeupdate = function(_time) {
   315     var _x = Math.floor( this.width * this.player.popcorn.currentTime() / this.source.getDuration().getSeconds());
   315     var _x = Math.floor( this.width * _time / this.media.duration);
   316     this.$elapsed.css({
   316     this.$elapsed.css({
   317         width:  _x + "px"
   317         width:  _x + "px"
   318     });
   318     });
   319     this.$position.css({
   319     this.$position.css({
   320         left: _x + "px"
   320         left: _x + "px"