Sha256: a396323dc694d2e9261eff70823b00575a752113630cceee6f1b944dd25a7589

Contents?: true

Size: 1.51 KB

Versions: 22

Compression:

Stored size: 1.51 KB

Contents

(function($) {
  $.widget('pageflow.linkmapAudioPlayersController', {
    _create: function() {
      var player = this.options.player;
      var element = this.element;

      this.delegatePlayerEvent('play', 'playing');
      this.delegatePlayerEvent('pause ended', 'notPlaying');
      this.delegatePlayerEvent('timeupdate', 'updateProgress');

      player.on('play', function(options) {
        var playerElements = element.find('[data-target-type="audio_file"]');

        playerElements.each(function() {
          var playerElement = $(this);

          if (playerElement.data('audioFile') !== options.audioFileId) {
            playerElement.linkmapAudioPlayerControls('cancelLoading');
          }
        });
      });

      this.element.on('linkmapaudioplayercontrolsplay', function(event, options) {
        player.play(options.audioFileId);
      });

      this.element.on('linkmapaudioplayercontrolspause', function(event, options) {
        player.pause();
      });

      this.element.on('linkmapaudioplayercontrolsseek', function(event, options) {
        player.seek(player.duration() * options.positionInPercent);
      });
    },

    delegatePlayerEvent: function (event, method) {
      var element = this.element;
      var player = this.options.player;

      player.on(event, function(options) {
        var selector = '[data-audio-file="' + options.audioFileId + '"]';
        var playerElement = element.find(selector);

        playerElement.linkmapAudioPlayerControls(method, player);
      });
    }
  });
}(jQuery));

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
pageflow-linkmap-page-2.10.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_audio_players_controller.js
pageflow-linkmap-page-2.9.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_audio_players_controller.js
pageflow-linkmap-page-2.8.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_audio_players_controller.js
pageflow-linkmap-page-2.7.1 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_audio_players_controller.js
pageflow-linkmap-page-2.7.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_audio_players_controller.js
pageflow-linkmap-page-2.6.1 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_audio_players_controller.js
pageflow-linkmap-page-2.6.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_audio_players_controller.js
pageflow-linkmap-page-2.5.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_audio_players_controller.js
pageflow-linkmap-page-2.4.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_audio_players_controller.js
pageflow-linkmap-page-2.3.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_audio_players_controller.js
pageflow-linkmap-page-2.2.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_audio_players_controller.js
pageflow-linkmap-page-1.5.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_audio_players_controller.js
pageflow-linkmap-page-2.1.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_audio_players_controller.js
pageflow-linkmap-page-1.4.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_audio_players_controller.js
pageflow-linkmap-page-2.0.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_audio_players_controller.js
pageflow-linkmap-page-1.3.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_audio_players_controller.js
pageflow-linkmap-page-1.2.1 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_audio_players_controller.js
pageflow-linkmap-page-1.2.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_audio_players_controller.js
pageflow-linkmap-page-1.1.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_audio_players_controller.js
pageflow-linkmap-page-1.0.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_audio_players_controller.js