Sha256: b9432946e7fc7742d812a3c4e32bcf3be7f85a85af7e6f2c4f1d71bb5a2f0983

Contents?: true

Size: 1.77 KB

Versions: 9

Compression:

Stored size: 1.77 KB

Contents

(function($) {
  $.widget('pageflow.linkmapHoverVideo', {
    activate: function() {
      var video = this.options.video;

      if (!this.hoverVideoParent) {
        this.hoverVideoParent = video.parent();
        video.appendTo(this.element);
      }
    },

    deactivate: function() {
      var video = this.options.video;

      if (this.hoverVideoParent) {
        video.prependTo(this.hoverVideoParent);
        this.hoverVideoParent = null;

        video.css({
          left: 'auto',
          top: 'auto',
          width: 'auto',
          height: 'auto'
        });
      }
    },

    schedulePlay: function(options) {
      if (this.currentArea !== options.area) {
        clearTimeout(this.playTimeout);

        this.currentArea = options.area;
        this.playTimeout = setTimeout(_.bind(function() {
          this.play(options);
        }, this), 500);
      }
    },

    play: function(options) {
      var video = this.options.video;
      var position = options.area.position();

      video
        .width(options.baseImage.width())
        .height(options.baseImage.height());

      this.element
        .css({
          left: position.left + 'px',
          top: position.top + 'px'
        })
        .width(options.area.width())
        .height(options.area.height());

      this.element.linkmapAreaClip(position);

      var videoPlayer = video.data('videoPlayer');
      videoPlayer.play();

      this.element.addClass('playing');
    },

    pause: function() {
      clearTimeout(this.playTimeout);
      this.currentArea = null;

      var videoPlayer = this.options.video.data('videoPlayer');

      setTimeout(function() {
        videoPlayer.currentTime(0);
        videoPlayer.pause();
      }, 300);

      this.element.removeClass('playing');
    }
  });
}(jQuery));

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
pageflow-linkmap-page-1.5.0 app/assets/javascript/pageflow/linkmap_page/widgets/hover_video.js
pageflow-linkmap-page-1.4.0 app/assets/javascript/pageflow/linkmap_page/widgets/hover_video.js
pageflow-linkmap-page-1.3.0 app/assets/javascript/pageflow/linkmap_page/widgets/hover_video.js
pageflow-linkmap-page-1.2.1 app/assets/javascript/pageflow/linkmap_page/widgets/hover_video.js
pageflow-linkmap-page-1.2.0 app/assets/javascript/pageflow/linkmap_page/widgets/hover_video.js
pageflow-linkmap-page-1.1.0 app/assets/javascript/pageflow/linkmap_page/widgets/hover_video.js
pageflow-linkmap-page-1.0.0 app/assets/javascript/pageflow/linkmap_page/widgets/hover_video.js
pageflow-linkmap-page-0.2.0 app/assets/javascript/pageflow/linkmap_page/widgets/hover_video.js
pageflow-linkmap-page-0.1.0 app/assets/javascript/pageflow/linkmap_page/widgets/hover_video.js