PageSourceSearch

https://www.roncerecords.net/Ext/Resources?a=CLe5H_Yo_xKcOYsdCuvob…Le5H_Yo_xKcOYsdCuvobo84YPk_zD31lLGeXIXR_uU,

js roncerecords.net collected 2026-09-27 07:29:10 UTC 10,763 bytes, 325 lines download raw bytes

1
2WS.Namespace.Create('NovAxis.Numeric', (function ()
3{
4    var MaxNum = 999999999;
5
6    /**
7    @class Numeric
8    @namespace NovAxis
9    @constructor
10    @param {jQuery} element A jQuery object to be replaced by the numeric control.
11    @param {number} minimum The minimum value.
12    @param {number} maximum The maximum value.
13    @param {number} [value] The original value. The minimum value if omitted.
14    @param {Object} [options] Options object.
15    @param {Array<String>} [options.classes] Array of class names to apply to the control.
16    @param {number} [options.nbdecimal] The number of decimal. 2 if omitted.
17    @param {boolean} [options.upDownArrows] Whether or not to include Up/Down arrows to change the value. Default false.
18    @param {number} [options.upDownIncrement] Increment/Decrement to use when UpDownArrows are clicked. Default to 1.
19    @param {boolean} [options.focus] if the control has focus. Default = false
20    **/
21    var Class = function (element, minimum, maximum, value, options)
22    {
23        if (!element || element.length == 0) throw "Element cannot be null.";
24        if (isNaN(parseInt(minimum))) { minimum = -MaxNum; }
25        if (isNaN(parseInt(maximum))) maximum = MaxNum;
26
27        options = options || {};
28        options.classes = options.classes || null;
29        options.nbdecimal = (options.nbdecimal != null && typeof options.nbdecimal === "number" && options.nbdecimal >= 0) ? options.nbdecimal : 2;
30        options.nullable = (options.nullable != undefined) ? options.nullable : false;
31        options.placeholder = options.placeholder || null;
32        options.upDownArrows = (options.upDownArrows === undefined ? false : options.upDownArrows === true);
33        options.upDownIncrement = (options.upDownIncrement != null && typeof options.upDownIncrement === "number" && options.upDownIncrement > 0) ? options.upDownIncrement : 1;
34        options.focus = (options.focus != undefined) ? options.focus : false;
35
36        if (!options.nullable && isNaN(parseInt(value)))
37        {
38            value = minimum;
39            if (minimum == -MaxNum) value = 0;
40        }
41
42        /**
43        Fired when the value is changed.
44
45        @event change
46        **/
47        WS.EventObject.call(this, ['change']);
48
49        if (options.classes && options.classes.length > 0) this.element.addClass(options.classes.join(" "));
50
51        this._internal = {};
52        this._internal.minimum = minimum;
53        this._internal.maximum = maximum;
54        this._internal.value = value;
55        this._internal.disabled = false;
56        this._internal.originalElement = element;
57        this._internal.nbdecimal = options.nbdecimal;
58        this._internal.nullable = options.nullable;
59        this._internal.Arrows = null;
60
61        if (options.upDownArrows) this._internal.Arrows = { Increment: options.upDownIncrement };
62
63        this.element = CreateControl.call(this);
64        this._input = (this._internal.Arrows ? this.element.find(".naNumeric") : this.element);
65        if (options.placeholder) this._input.attr("placeholder", options.placeholder);
66
67        AddEventHandler.apply(this);
68        element.after(this.element);
69        element.detach();
70
71        if (options.focus) this._input.focus();
72    };
73
74    WS.Exts.Inherits(Class, WS.EventObject);
75
76    // Private Method(s)
77    var CreateControl = function ()
78    {
79        var Html = [];
80
81        if (this._internal.Arrows)
82        {
83            Html.push("<div class=\"naNumericWrapper\">");
84        }
85
86        Html.push("<input class=\"naNumeric\" type=\"number\" />")
87
88        if (this._internal.Arrows)
89        {
90            Html.push("<span name=\"Up\"></span>");
91            Html.push("<span name=\"Down\"></span>");
92            Html.push("</div>");
93        }
94
95        return $(Html.join(""));
96    };
97
98    var AddEventHandler = function ()
99    {
100        var me = this;
101
102        if (this._internal.Arrows)
103        {
104            this.element.find("[name=Up]").on("click", function ()
105            {
106                var CurrentNumber = Number(me._input.val());
107                CurrentNumber += me._internal.Arrows.Increment;
108                ChangeValue.call(me, CurrentNumber);
109            });
110            this.element.find("[name=Down]").on("click", function ()
111            {
112                var CurrentNumber = Number(me._input.val());
113                CurrentNumber -= me._internal.Arrows.Increment;
114                ChangeValue.call(me, CurrentNumber);
115            });
116        }
117
118        var ManageInput = function (e, sender)
119        {
120            var Code = e.keyCode ? e.keyCode : e.which;
121            var currentChar = String.fromCharCode(Code);
122
123            // Special chars (backspace, delete, end, left, right) FireFox, ...
124            if (Code == 8 || Code == 127 || Code == 37 || Code == 39 || Code == 35) e.preventDefault();
125
126            var currentvalue = $(sender).val();
127            var priceMinus = Code == 45 && sender.selectionStart == 0;
128            var priceDecimal = (Code == 44 || Code == 46);
129            if (priceDecimal && currentvalue.contains("-") && sender.selectionStart == 1) priceDecimal = false;
130
131            if ((currentvalue.contains(",") || currentvalue.contains(".")) && priceDecimal) e.preventDefault();
132            if (!(Code >= 48 && Code <= 57 || priceDecimal || priceMinus)) e.preventDefault();
133
134            var cutLen = sender.selectionEnd - sender.selectionStart;
135            var selectremove = currentvalue.substr(sender.selectionStart, cutLen);
136            var lastpart = currentvalue.substr(sender.selectionEnd);
137            var Tmp = currentvalue.substr(0, sender.selectionStart) + currentChar + lastpart.replace(selectremove, "");
138            var currentvalueNum = Math.abs(Tmp.replace(",", "."));
139            if (currentvalueNum > MaxNum) e.preventDefault();
140        };
141
142        this._input.on("cut", function (e) { e.preventDefault(); });
143
144        this._input.on("paste", function (e)
145        {
146            e.preventDefault();
147
148            var text = (e.originalEvent || e).clipboardData.getData("Text") || "";
149            text = text.replace(",", ".").trim();
150            if (!isNaN(parseFloat(text))) { ChangeValue.call(me, text); }
151        });
152
153        this._input.on("keypress", function (e) { ManageInput(e, this); });
154
155        this._input.on("blur", function (e) { ChangeValue.call(me, $(this).val()); });
156
157        this._input.on("focus", function () { $(this).select(); });
158
159        this._input.val((this._internal.nullable) ? this._internal.value : this._internal.value.toFixed(this._internal.nbdecimal));
160    };
161
162    var ChangeValue = function (value)
163    {
164        if (!this._internal.disabled)
165        {
166            if (this._internal.nullable && value.trim() == "") { value = null; }
167            else
168            {
169                if (isNaN(parseFloat(value))) value = this._internal.minimum.toFixed(this._internal.nbdecimal);
170
171                value = Number.round(value, this._internal.nbdecimal);
172                if (value < this._internal.minimum) value = this._internal.minimum;
173                else if (value > this._internal.maximum) value = this._internal.maximum;
174
175                this._internal.disabled = true;
176                this._input.val(value.toFixed(this._internal.nbdecimal));
177                this._internal.disabled = false;
178            }
179
180            if (value != this._internal.value)
181            {
182                this._internal.value = value;
183                this.RaiseEvent("change", value);
184            }
185        }
186    };
187
188    // Public Method(s)
189    (function (Methods)
190    {
191        /**
192        Get the selected value.
193    
194        @method GetValue
195        **/
196        Methods.GetValue = function ()
197        {
198            return this._internal.value;
199        };
200
201        /**
202        Set the selected value.
203    
204        @method SetValue
205        **/
206        Methods.SetValue = function (value)
207        {
208            ChangeValue.call(this, value);
209        };
210
211        /**
212        Set the minimum value
213   
214        @method SetMinimum
215        **/
216        Methods.SetMinimum = function (value)
217        {
218            if (isNaN(parseInt(value))) { value = -MaxNum; }
219            this._internal.minimum = value;
220        };
221
222        /**
223        Set the maximum value
224  
225        @method SetMaximum
226        **/
227        Methods.SetMaximum = function (value)
228        {
229            if (isNaN(parseInt(value))) value = MaxNum;
230            this._internal.maximum = value;
231        };
232
233        /**
234        Check if the control is nullable.
235
236        @method IsNullable
237        **/
238        Methods.IsNullable = function ()
239        {
240            return this._internal.nullable;
241        };
242
243        /**
244        Select the input
245
246        @method Select
247        **/
248        Methods.Select = function ()
249        {
250            this._input.select();
251        };
252
253        /**
254        Disable the control.
255   
256        @method Disable
257        **/
258        Methods.Disable = function ()
259        {
260            this._input.addClass("Disabled");
261            this._input.css({ "pointer-events": "none", "color": "#5c5c5c" });
262            this._internal.disabled = true;
263        };
264
265        /**
266        Readonly mode
267   
268        @method ReadOnly
269        **/
270        Methods.ReadOnly = function ()
271        {
272            this._input.addClass("ReadOnly");
273            this._input.css({ "pointer-events": "none" });
274        };
275
276        /**
277        Disable Readonly mode
278  
279        @method DisableReadOnly
280        **/
281        Methods.DisableReadOnly = function ()
282        {
283            this._input.removeClass("ReadOnly");
284            this._input.css({ "pointer-events": "" });
285        };
286
287        /**
288        Enable the control.
289  
290        @method Enable
291        **/
292        Methods.Enable = function ()
293        {
294            this._input.removeClass("Disabled");
295            this._input.css({ "pointer-events": "", "color": "" });
296            this._internal.disabled = false;
297        };
298
299        /**
300        Give focus
301  
302        @method Focus
303        **/
304        Methods.Focus = function ()
305        {
306            this._input.focus();
307        };
308
309        /**
310        Destroy the control.
311 
312        @method Destroy
313        **/
314        Methods.Destroy = function ()
315        {
316            this.element.after(this._internal.originalElement);
317            this.element.remove();
318            this.element = null;
319            this._internal = null;
320        };
321
322    })(Class.prototype);
323
324    return Class;
325})());

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.