(function ($) { $.fn.niceNumber = function (options) { var defaults = { autoSize: true, autoSizeBuffer: 1, buttonDecrement: '-', buttonIncrement: '+', buttonPosition: 'around', /** callbackFunction @param {$input} currentInput - the input running the callback @param {number} amount - the amount after increase/decrease @param {object} settings - the passed niceNumber settings **/ onDecrement: false, onIncrement: false, }; var settings = $.extend(defaults, options); return this.each(function () { var currentInput = this, $currentInput = $(currentInput), maxValue = $currentInput.attr('max'), minValue = $currentInput.attr('min'), attrMax = null, attrMin = null; // Skip already initialized input if ($currentInput.attr('data-nice-number-initialized')) return; // Handle max and min values if ( maxValue !== undefined && maxValue !== false ) { attrMax = parseFloat(maxValue); } if ( minValue !== undefined && minValue !== false ) { attrMin = parseFloat(minValue); } // Fix issue with initial value being < min if (attrMin && !currentInput.value) { $currentInput.val(attrMin); } // Generate container var $inputContainer = $('
', { class: 'nice-number', }).insertAfter(currentInput); // Generate interval (object so it is passed by reference) var interval = {}; // Generate buttons var $minusButton = $('