summaryrefslogtreecommitdiffstats
path: root/deluge/ui/web/js/extjs/ext-extensions/form/SpinnerField.js
blob: d14f3204356cab4f11aebc46d9abbb96a193687c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
 * Ext JS Library 3.4.0
 * Copyright(c) 2006-2011 Sencha Inc.
 * licensing@sencha.com
 * http://www.sencha.com/license
 */
Ext.ns('Ext.ux.form');

/**
 * @class Ext.ux.form.SpinnerField
 * @extends Ext.form.NumberField
 * Creates a field utilizing Ext.ux.Spinner
 * @xtype spinnerfield
 */
Ext.ux.form.SpinnerField = Ext.extend(Ext.form.NumberField, {
    actionMode: 'wrap',
    deferHeight: true,
    autoSize: Ext.emptyFn,
    onBlur: Ext.emptyFn,
    adjustSize: Ext.BoxComponent.prototype.adjustSize,

    constructor: function(config) {
        var spinnerConfig = Ext.copyTo(
            {},
            config,
            'incrementValue,alternateIncrementValue,accelerate,defaultValue,triggerClass,splitterClass'
        );

        var spl = (this.spinner = new Ext.ux.Spinner(spinnerConfig));

        var plugins = config.plugins
            ? Ext.isArray(config.plugins)
                ? config.plugins.push(spl)
                : [config.plugins, spl]
            : spl;

        Ext.ux.form.SpinnerField.superclass.constructor.call(
            this,
            Ext.apply(config, { plugins: plugins })
        );
    },

    // private
    getResizeEl: function() {
        return this.wrap;
    },

    // private
    getPositionEl: function() {
        return this.wrap;
    },

    // private
    alignErrorIcon: function() {
        if (this.wrap) {
            this.errorIcon.alignTo(this.wrap, 'tl-tr', [2, 0]);
        }
    },

    validateBlur: function() {
        return true;
    },
});

Ext.reg('spinnerfield', Ext.ux.form.SpinnerField);

//backwards compat
Ext.form.SpinnerField = Ext.ux.form.SpinnerField;