(function ($, undefined) {
  'use strict';

  var OFFSET = 5;

  $.fn.rating = function (options) {
    var fillUntilRate = function ($rating, value, opts) {
      var $rates = $rating.children();
      // Empty all the rating symbols.
      $rates.removeClass(opts.filled).addClass(opts.empty);

      // Check the value is a valid rate according to the step.
      var rate = parseInt(value, 10);
      if (!isNaN(rate) && rate % opts.step === 0) {
        // Calculate the index according to the configured step.
        var index = Math.max(Math.ceil((rate - opts.start) / opts.step), 0);
        // Check the index is between the proper range [0..length).
        if (0 <= index && index < $rates.length) {
          // Fill all the symbols up to the selected one.
          $rates.eq(index).prevAll('.rating-symbol').addBack()
            .removeClass(opts.empty).addClass(opts.filled);
        }
      }
    };

    this.each(function () {
      var $input = $(this);
      // Merge data and parameter options.
      // Those provided as parameter prevail over the data ones.
      var opts = $.extend({}, $input.data(), options);
      // Sanitize start, stop, and step.
      // All of them start, stop, and step must be integers.
      // In case we don't have a valid stop rate try to get a reasonable
      // one based on the existence of a valid start rate.
      opts.start = parseInt(opts.start, 10) || undefined;
      opts.stop = parseInt(opts.stop, 10) ||
                     opts.start + OFFSET ||
                     undefined;
      opts.step = parseInt(opts.step, 10) || undefined;

      // Extend/Override the default options with those provided either as
      // data attributes or function parameters.
      opts = $.extend({}, $.fn.rating.defaults, opts);

      // Calculate the rate of an index according the the start and step.
      var indexToRate = function (index) {
        return opts.start + index * opts.step;
      };

      // Build the rating control.
      var $rating = $('<div></div>').insertBefore($input);
      var length = Math.max(Math.ceil((opts.stop - opts.start) / opts.step), 0);
      for (var i = 0; i < length; i++) {
        $rating.append('<div class="rating-symbol glyphicon ' + opts.empty + '"></div>');
      }
      // Initialize the rating control with the associated input value.
      fillUntilRate($rating, $input.val(), opts);

      // Keep rating control and its associated input in sync.
      $input
        .on('change', function () {
          fillUntilRate($rating, $(this).val(), opts);
        });

      $rating
        .on('click', '.rating-symbol', function () {
          if (!$input.prop('disabled') && !$input.prop('readonly')) {
            // Set input to the current value and 'trigger' the change handler.
            $input.val(indexToRate($(this).index())).change();
          }
        })
        .on('mouseenter', '.rating-symbol', function () {
          if (!$input.prop('disabled') && !$input.prop('readonly')) {
            // Emphasize on hover in.
            fillUntilRate($rating, indexToRate($(this).index()), opts);
          }
        })
        .on('mouseleave', '.rating-symbol', function () {
          if (!$input.prop('disabled') && !$input.prop('readonly')) {
            // Restore on hover out.
            fillUntilRate($rating, $input.val(), opts);
          }
        });
    });
  };

  // Plugin defaults.
  $.fn.rating.defaults = {
    filled: 'glyphicon-star',
    empty: 'glyphicon-star-empty',
    start: 0,
    stop: OFFSET,
    step: 1
  };

  $(function () {
    $('input.rating').rating();
  });
}(jQuery));

@@ -1951,24 +1951,264 @@
 ;%0A      %7D;%0A%0A
+      // Call f only if the input is enabled.%0A      var ifEnabled = function (f) %7B%0A        return function () %7B%0A          if (!$input.prop('disabled') && !$input.prop('readonly')) %7B%0A            f.call(this);%0A          %7D%0A        %7D%0A      %7D;%0A%0A
       // Bui
@@ -2230,16 +2230,16 @@
 ontrol.%0A
-
       va
@@ -2857,32 +2857,42 @@
 rating-symbol', 
+ifEnabled(
 function () %7B%0A  
@@ -2889,84 +2889,12 @@
 on (
-) %7B%0A          if (!$input.prop('disabled') && !$input.prop('readonly')
 ) %7B%0A
-  
     
@@ -2973,26 +2973,24 @@
 .%0A          
-  
 $input.val(i
@@ -3032,37 +3032,26 @@
 ();%0A        
-  %7D%0A        
 %7D
+)
 )%0A        .o
@@ -3076,32 +3076,42 @@
 rating-symbol', 
+ifEnabled(
 function () %7B%0A  
@@ -3108,84 +3108,12 @@
 on (
-) %7B%0A          if (!$input.prop('disabled') && !$input.prop('readonly')
 ) %7B%0A
-  
     
@@ -3144,18 +3144,16 @@
 ver in.%0A
-  
         
@@ -3206,34 +3206,32 @@
 ndex()), opts);%0A
-  
         %7D%0A      
@@ -3223,26 +3223,17 @@
        %7D
-%0A        %7D
+)
 )%0A      
@@ -3270,16 +3270,26 @@
 ymbol', 
+ifEnabled(
 function
@@ -3294,78 +3294,8 @@
 on (
-) %7B%0A          if (!$input.prop('disabled') && !$input.prop('readonly')
 ) %7B%0A
@@ -3304,18 +3304,16 @@
         
-  
 // Resto
@@ -3329,18 +3329,16 @@
 er out.%0A
-  
         
@@ -3391,29 +3391,18 @@
         
-  %7D%0A        
 %7D
+)
 );%0A    %7D

Refactor input enabled check into a function