From 23157be9c3bcea5766729face92e68d11b5bfe85 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Thu, 28 Oct 2010 17:32:01 +0200 Subject: Spinner: Refactored reading htlm5 attributes option init --- ui/jquery.ui.spinner.js | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'ui') diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js index 349dc73c9..87e611ede 100644 --- a/ui/jquery.ui.spinner.js +++ b/ui/jquery.ui.spinner.js @@ -19,10 +19,10 @@ var pageModifier = 10; $.widget('ui.spinner', { options: { incremental: true, - max: Number.MAX_VALUE, - min: -Number.MAX_VALUE, + max: null, + min: null, numberformat: null, - step: 1, + step: null, value: null }, @@ -34,19 +34,17 @@ $.widget('ui.spinner', { }, _markupOptions: function() { - // TODO refactor and read only when the related option is null (set default to null, init Number.MAX_VALUE only when nothing is specified) - var min = this.element.attr("min"); - if (typeof min == "string" && min.length > 0) { - this.options.min = this._parse(min); - } - var max = this.element.attr("max"); - if (typeof max == "string" && max.length > 0) { - this.options.max = this._parse(max); - } - var step = this.element.attr("step"); - if (typeof step == "string" && step.length > 0) { - this.options.step = this._parse(step); - } + var _this = this; + $.each({ + min: -Number.MAX_VALUE, + max: Number.MAX_VALUE, + step: 1 + }, function(attr, defaultValue) { + if (_this.options[attr] === null) { + var value = _this.element.attr(attr); + _this.options[attr] = typeof value == "string" && value.length > 0 ? _this._parse(value) : defaultValue; + } + }); this.value(this.options.value !== null ? this.options.value : this.element.val() || 0); }, -- cgit v1.2.3