PageSourceSearch

https://cdn1.kdt.kz/modules/bootstrap-spinedit/bootstrap-spinedit.js?_=100

js kdt.kz collected 2026-10-01 16:29:57 UTC 5,796 bytes, 193 lines download raw bytes

1jQuery.fn.mousehold = function (f) {
2    var timeout = 100;
3    if (f && typeof f == 'function') {
4        var intervalId = 0;
5        var firstStep = false;
6        var clearMousehold = undefined;
7        return this.each(function () {
8            $(this).mousedown(function () {
9                firstStep = true;
10                var ctr = 0;
11                var t = this;
12                intervalId = setInterval(function () {
13                    ctr++;
14                    f.call(t, ctr);
15                    firstStep = false;
16                }, timeout);
17            });
18
19            clearMousehold = function () {
20                clearInterval(intervalId);
21                if (firstStep) f.call(this, 1);
22                firstStep = false;
23            };
24
25            $(this).mouseout(clearMousehold);
26            $(this).mouseup(clearMousehold);
27        });
28    }
29};
30
31$(function () {
32    $.extend($.fn.disableTextSelect = function () {
33        return this.each(function () {
34            $(this).bind('selectstart click mousedown', function () { return false; });
35        });
36    });
37});
38
39!function ($) {
40
41    var SpinEdit = function (element, options) {
42        this.element = $(element);
43        this.element.addClass("spinedit");
44        this.element.addClass("noSelect");
45        this.intervalId = undefined;
46
47        var hasOptions = typeof options == 'object';
48
49        this.minimum = $.fn.spinedit.defaults.minimum;
50        if (hasOptions && typeof options.minimum == 'number') {
51            this.setMinimum(options.minimum);
52        }
53
54        this.maximum = $.fn.spinedit.defaults.maximum;
55        if (hasOptions && typeof options.maximum == 'number') {
56            this.setMaximum(options.maximum);
57        }
58
59        this.numberOfDecimals = $.fn.spinedit.defaults.numberOfDecimals;
60        if (hasOptions && typeof options.numberOfDecimals == 'number') {
61            this.setNumberOfDecimals(options.numberOfDecimals);
62        }
63
64        var value = $.fn.spinedit.defaults.value;
65        if (hasOptions && typeof options.value == 'number') {
66            value = options.value;
67        }
68        this.setValue(value);
69
70        this.step = $.fn.spinedit.defaults.step;
71        if (hasOptions && typeof options.step == 'number') {
72            this.setStep(options.step);
73        }
74
75        var template = $(DRPGlobal.template);
76        this.element.after(template);
77        template.disableTextSelect();
78
79        template.find('.icon-chevron-up').mousehold($.proxy(this.increase, this));
80        template.find('.icon-chevron-down').mousehold($.proxy(this.decrease, this));
81        this.element.on('keypress', $.proxy(this._keypress, this));
82        this.element.on('blur', $.proxy(this._checkConstraints, this));
83    };
84
85    SpinEdit.prototype = {
86        constructor: SpinEdit,
87
88        setMinimum: function (value) {
89            this.minimum = parseFloat(value);
90        },
91
92        setMaximum: function (value) {
93            this.maximum = parseFloat(value);
94        },
95
96        setStep: function (value) {
97            this.step = parseFloat(value);
98        },
99
100        setNumberOfDecimals: function (value) {
101            this.numberOfDecimals = parseInt(value);
102        },
103
104        setValue: function (value) {
105            value = parseFloat(value);
106            if (isNaN(value))
107                value = this.minimum;
108            if (this.value == value)
109                return;
110            if (value < this.minimum)
111                value = this.minimum;
112            if (value > this.maximum)
113                value = this.maximum;
114            this.value = value;
115            this.element.val(this.value.toFixed(this.numberOfDecimals));
116            this.element.change();
117
118            this.element.trigger({
119                type: "valueChanged",
120                value: parseFloat(this.value.toFixed(this.numberOfDecimals))
121            });
122        },
123
124        increase: function () {
125            var newValue = this.value + this.step;
126            this.setValue(newValue);
127        },
128
129        decrease: function () {
130            var newValue = this.value - this.step;
131            this.setValue(newValue);
132        },
133
134        _keypress: function (event) {
135            // Allow: -
136            if (event.keyCode == 45) {
137                return;
138            }
139            // Allow decimal separator (.)
140            if (this.numberOfDecimals > 0 && event.keyCode == 46) {
141                return;
142            }
143            // Ensure that it is a number and stop the keypress
144            var a = [];
145            for (var i = 48; i < 58; i++)
146                a.push(i);
147            var k = event.keyCode;
148            if (!(a.indexOf(k) >= 0))
149                event.preventDefault();
150        },
151
152        _checkConstraints: function (e) {
153            var target = $(e.target);
154            this.setValue(target.val());
155        }
156    };
157
158    $.fn.spinedit = function (option) {
159        var args = Array.apply(null, arguments);
160        args.shift();
161        return this.each(function () {
162            var $this = $(this),
163				data = $this.data('spinedit'),
164				options = typeof option == 'object' && option;
165
166            if (!data) {
167                $this.data('spinedit', new SpinEdit(this, $.extend({}, $.fn.spinedit().defaults, options)));
168            }
169            if (typeof option == 'string' && typeof data[option] == 'function') {
170                data[option].apply(data, args);
171            }
172        });
173    };
174
175    $.fn.spinedit.defaults = {
176        value: 0,
177        minimum: 0,
178        maximum: 100,
179        step: 1,
180        numberOfDecimals: 0
181    };
182
183    $.fn.spinedit.Constructor = SpinEdit;
184
185    var DRPGlobal = {};
186
187    DRPGlobal.template =
188	'<div class="spinedit">' +
189	'<i class="icon-chevron-up"></i>' +
190	'<i class="icon-chevron-down"></i>' +
191	'</div>';
192
193}(window.jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.