source: Dev/branches/rest-dojo-ui/client/dojox/form/TimeSpinner.js @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

File size: 1.7 KB
Line 
1define([
2        "dojo/_base/lang",
3        "dojo/_base/event",
4        "dijit/form/_Spinner",
5        "dojo/keys",
6        "dojo/date",
7        "dojo/date/locale",
8        "dojo/date/stamp",
9        "dojo/_base/declare"
10], function(lang, event, Spinner, keys, dateUtil, dateLocale, dateStamp, declare){
11        /*=====
12                Spinner = dijit.form._Spinner;
13        =====*/
14return declare( "dojox.form.TimeSpinner", Spinner,
15{
16        // summary: Time Spinner
17        // description: This widget is the same as a normal NumberSpinner, but for the time component of a date object instead
18
19        required: false,
20
21        adjust: function(/* Object */ val, /*Number*/ delta){
22                return dateUtil.add(val, "minute", delta)
23        },
24
25        //FIXME should we allow for constraints in this widget?
26        isValid: function(){return true;},
27
28        smallDelta: 5,
29
30        largeDelta: 30,
31
32        timeoutChangeRate: 0.50,
33
34        parse: function(time, locale){
35                return dateLocale.parse(time, {selector:"time", formatLength:"short"});
36        },
37
38        format: function(time, locale){
39                if(lang.isString(time)){ return time; }
40                return dateLocale.format(time, {selector:"time", formatLength:"short"});
41        },
42
43        serialize: dateStamp.toISOString,
44
45        value: "12:00 AM",
46
47       _onKeyPress: function(e){
48                if((e.charOrCode == keys.HOME || e.charOrCode == keys.END) && !(e.ctrlKey || e.altKey || e.metaKey)
49                && typeof this.get('value') != 'undefined' /* gibberish, so HOME and END are default editing keys*/){
50                        var value = this.constraints[(e.charOrCode == keys.HOME ? "min" : "max")];
51                        if(value){
52                                this._setValueAttr(value,true);
53                        }
54                        // eat home or end key whether we change the value or not
55                        event.stop(e);
56                }
57        }
58
59
60});
61});
Note: See TracBrowser for help on using the repository browser.