From 0d0ec376e35f1eaaba8199c2abc83a17d5c655a8 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Wed, 1 Dec 2010 23:28:05 +0100 Subject: [PATCH] Spinner: Introduce page option to configure page size. Use that for timespinner demo to spin minutes on cursor up/down, hours on page up/down. --- demos/spinner/time.html | 36 ++++++++++++++++++++++++------------ ui/jquery.ui.spinner.js | 12 +++++------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/demos/spinner/time.html b/demos/spinner/time.html index 2f55d0f09..4913a6307 100644 --- a/demos/spinner/time.html +++ b/demos/spinner/time.html @@ -8,7 +8,6 @@ - @@ -16,25 +15,31 @@ @@ -44,7 +49,14 @@

- + +

+

+ +

diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js index 7f32adbd8..39a498359 100644 --- a/ui/jquery.ui.spinner.js +++ b/ui/jquery.ui.spinner.js @@ -13,15 +13,13 @@ */ (function($) { -// shortcut constants -var pageModifier = 10; - $.widget('ui.spinner', { options: { incremental: true, max: null, min: null, numberformat: null, + page: 10, step: null, value: null }, @@ -161,10 +159,10 @@ $.widget('ui.spinner', { this._repeat(null, -1, event); return false; case KEYS.PAGE_UP: - this._repeat(null, pageModifier, event); + this._repeat(null, this.options.page, event); return false; case KEYS.PAGE_DOWN: - this._repeat(null, -pageModifier, event); + this._repeat(null, -this.options.page, event); return false; case KEYS.ENTER: @@ -340,11 +338,11 @@ $.widget('ui.spinner', { }, pageUp: function(pages) { - this.stepUp((pages || 1) * pageModifier); + this.stepUp((pages || 1) * this.options.page); }, pageDown: function(pages) { - this.stepDown((pages || 1) * pageModifier); + this.stepDown((pages || 1) * this.options.page); }, value: function(newVal) { -- 2.39.5