Sha256: 11f055c818a86477a3a4bba62f38d9c8f95ed9d55a4689e0dafdda1f32b9948e

Contents?: true

Size: 1.75 KB

Versions: 24

Compression:

Stored size: 1.75 KB

Contents

(function($) {

  $.fn.radioSlider = function(options) {
    var settings = {
      'sliderImage'     : '/images/forge/slider-button.png',
      'activeClass'     : 'slider-active',
      'leftOffset'      : 0,
      'rightOffset'     : 19
    };

    if ( options ) { $.extend( settings, options ); }

    this.each(function() {
      var $this = this;
      var buttons = $('input:radio', this);
      var slideWidget = $('<div />').addClass('slider-widget').append($('<img />').attr('src', settings.sliderImage));

      //insert the widget
      $('label:first', this).after(slideWidget);

      // Set up the buttons
      buttons
        .css({ position: 'absolute', left: -9999 })
        .focus(function () {
          slideWidget.find('img').addClass('focus');
        })
        .blur(function () {
          slideWidget.find('img').removeClass('focus');
        });

      //charge the events
      buttons.bind('change.radioSlider', function() { updateSlider($this); });
      $('div.slider-widget', this).bind('click.radioSlider', function() { swapActive($this); });
      updateSlider(this);
    });

    function updateSlider(holder) {
      holder = $(holder);
      var checked = $('input[type=radio]:checked', holder);
      var slider = $('div.slider-widget img', holder);
      if (checked.index($('input[type=radio]', holder)) === 0) {
        slider.animate({left: settings.leftOffset}, 100);
      } else {
        slider.animate({left: settings.rightOffset}, 100);
      }
      $('label', holder).removeClass(settings.activeClass);
      $('input[type=radio]:checked', holder).closest('label').addClass(settings.activeClass);
    }

    function swapActive(holder) {
      $(holder).find('input[type=radio]').not(':checked').click().change();
    }

  };
})(jQuery);

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
forge-cli-0.1.10 lib/forge/vendor/assets/javascripts/jquery.radioSlider.js
forge-cli-0.1.9 lib/forge/vendor/assets/javascripts/jquery.radioSlider.js
forge-cli-0.1.8 lib/forge/vendor/assets/javascripts/jquery.radioSlider.js
forge-cli-0.1.7 lib/forge/vendor/assets/javascripts/jquery.radioSlider.js
forge-cli-0.1.6 lib/forge/vendor/assets/javascripts/jquery.radioSlider.js
forge-cli-0.1.5 lib/forge/vendor/assets/javascripts/jquery.radioSlider.js
forge-cli-0.1.4 lib/forge/vendor/assets/javascripts/jquery.radioSlider.js
forge-cli-0.1.3 lib/forge/vendor/assets/javascripts/jquery.radioSlider.js
forge-cli-0.1.2 lib/forge/vendor/assets/javascripts/jquery.radioSlider.js
forge-cli-0.1.1 lib/forge/vendor/assets/javascripts/jquery.radioSlider.js
forge-cli-0.1.0 lib/forge/vendor/assets/javascripts/jquery.radioSlider.js
forge-cli-0.0.18 lib/forge/vendor/assets/javascripts/jquery.radioSlider.js
forge-cli-0.0.17 lib/forge/vendor/assets/javascripts/jquery.radioSlider.js
forge-cli-0.0.16 lib/forge/vendor/assets/javascripts/jquery.radioSlider.js
forge-cli-0.0.15 lib/forge/vendor/assets/javascripts/jquery.radioSlider.js
forge-cli-0.0.14 lib/forge/vendor/assets/javascripts/jquery.radioSlider.js
forge-cli-0.0.13 lib/forge/vendor/assets/javascripts/jquery.radioSlider.js
forge-cli-0.0.12 lib/forge/vendor/assets/javascripts/jquery.radioSlider.js
forge-cli-0.0.11 lib/forge/vendor/assets/javascripts/jquery.radioSlider.js
forge-cli-0.0.10 lib/forge/vendor/assets/javascripts/jquery.radioSlider.js