Sha256: 089896d093a36318375e87392419c1504551f39dbbce4286d794a4eb92554db2

Contents?: true

Size: 1.96 KB

Versions: 67

Compression:

Stored size: 1.96 KB

Contents

(function($) {
  $.widget('pageflow.volumeSlider', {
    _create: function() {
      var element = this.element;
      var orientation = this.options.orientation;
      var slider = $('.volume-slider', element);
      var handlingVolume = false;

      element.on('mousedown', function(event) {
        var parent = $('body');

        parent.on('mousemove.volumeSlider', changeVolume);
        element.addClass('lock_showing');

        parent.on('mouseup.volumeSlider', function() {
          parent.off('mousemove.volumeSlider mouseup.volumeSlider');
          element.removeClass('lock_showing');
        });

        changeVolume(event);

        function changeVolume(event) {
          var volume;

          if (orientation === 'v') {
            volume = 1 - (event.pageY - slider.offset().top) / slider.height();
          }
          else {
            volume = (event.pageX - slider.offset().left) / slider.width();
          }

          pageflow.settings.set('volume', Math.min(1, Math.max(0, volume)));
        }
      });

      pageflow.settings.on('change:volume', this.update, this);
      this.update();
    },

    _destroy: function() {
      pageflow.settings.off('change:volume', this.update);
    },

    update: function() {
      var volume = pageflow.settings.get('volume');

      if (this.options.orientation === 'v') {
        $('.volume-level', this.element).css({height: volume * 100 + '%'});
        $('.volume-handle', this.element).css({bottom: volume * 100 + '%', top: 'initial'});
      }
      else {
        $('.volume-level', this.element).css({width: volume * 100 + '%'});
        $('.volume-handle', this.element).css({left: volume * 100 + '%'});
      }

      this.element.toggleClass('volume-high', volume > 2 / 3);
      this.element.toggleClass('volume-medium', volume >= 1 / 3 && volume <= 2 / 3 );
      this.element.toggleClass('volume-low', volume < 1 / 3 && volume > 0);
      this.element.toggleClass('volume-mute', volume === 0);
    }
  });
}(jQuery));

Version data entries

67 entries across 67 versions & 1 rubygems

Version Path
pageflow-14.5.2 app/assets/javascripts/pageflow/widgets/volume_slider.js
pageflow-15.0.2 app/assets/javascripts/pageflow/widgets/volume_slider.js
pageflow-15.0.1 app/assets/javascripts/pageflow/widgets/volume_slider.js
pageflow-15.0.0 app/assets/javascripts/pageflow/widgets/volume_slider.js
pageflow-14.5.1 app/assets/javascripts/pageflow/widgets/volume_slider.js
pageflow-14.5.0 app/assets/javascripts/pageflow/widgets/volume_slider.js
pageflow-15.0.0.rc2 app/assets/javascripts/pageflow/widgets/volume_slider.js
pageflow-15.0.0.rc1 app/assets/javascripts/pageflow/widgets/volume_slider.js
pageflow-15.0.0.beta4 app/assets/javascripts/pageflow/widgets/volume_slider.js
pageflow-15.0.0.beta3 app/assets/javascripts/pageflow/widgets/volume_slider.js
pageflow-14.4.0 app/assets/javascripts/pageflow/widgets/volume_slider.js
pageflow-15.0.0.beta2 app/assets/javascripts/pageflow/widgets/volume_slider.js
pageflow-15.0.0.beta1 app/assets/javascripts/pageflow/widgets/volume_slider.js
pageflow-14.3.0 app/assets/javascripts/pageflow/widgets/volume_slider.js
pageflow-14.2.1 app/assets/javascripts/pageflow/widgets/volume_slider.js
pageflow-14.2.0 app/assets/javascripts/pageflow/widgets/volume_slider.js
pageflow-14.1.1 app/assets/javascripts/pageflow/widgets/volume_slider.js
pageflow-14.1.0 app/assets/javascripts/pageflow/widgets/volume_slider.js
pageflow-14.0.0 app/assets/javascripts/pageflow/widgets/volume_slider.js
pageflow-14.0.0.rc2 app/assets/javascripts/pageflow/widgets/volume_slider.js