Project

General

Profile

Bug #3952 ยป WSpinBox.js

includes fox for center scrolled spinner error - Jeremiah Jahn, 04/08/2015 06:56 PM

 
function(A, c, t, g, f, k, l, m, p, q) {
function n() {
return !!c.getAttribute("readonly")
}

function r() {
var a = e.data("lobj"),
b = "";
if (a !== undefined) {
b = a.getValue();
if (b === "") b = g + "0" + f
} else b = c.value;
if (b.substr(0, g.length) == g) {
b = b.substr(g.length);
if (b.length > f.length && b.substr(b.length - f.length, f.length) == f) {
b = b.substr(0, b.length - f.length);
if (q) b = b.split(q).join("");
b = b.replace(p, ".");
return Number(b)
}
}
return null
}

function u(a) {
var b = e.data("lobj");
if (a > l) a = l;
else if (a < k) a = k;
a = a.toFixed(t);
a = a.replace(".", p);
var i = a.indexOf(p),
h = "";
if (i !== -1) {
for (var j = 0; j < i; j++) {
h += a.charAt(j);
if (j < i - 1 && (i - j - 1) % 3 === 0) h += q
}
h += a.substr(i)
} else h = a;
if (b !== undefined) b.setValue(g + h + f);
else c.value = g + h + f;
s = true
}

function w() {
var a = r();
if (a !== null) {
a += m;
u(a)
}
}

function x() {
var a = r();
if (a !== null) {
a -= m;
u(a)
}
}
jQuery.data(c, "obj", this);
var d = A.WT,
e = $(c),
o = null,
y, s = false,
z = null,
v = false;
this.setIsDoubleSpinBox = function(a) {
v = a;
this.configure(t, g, f, k, l, m)
};
this.configure = function(a, b, i, h, j, B) {
t = a;
g = b;
f = i;
k = h;
l = j;
m = B;
z = new(v || typeof d.WIntValidator === "undefined" ? d.WDoubleValidator : d.WIntValidator)(true, k, l, "Must be a number", "Must be a number", "The number must be at least " + k, "The number may be at most " + l)
};
this.mouseOut = function() {
e.removeClass("dn").removeClass("up")
};
this.mouseMove = function(a, b) {
if (!n())
if (o) {
a = d.pageCoordinates(b).y - o.y;
b = y;
if (b !== null) {
b -= a * m;
u(b)
}
} else {
//GALEDIT
//a = d.widgetCoordinates(c, b);
a = { x: b.x - $(c).offset().left, y: b.y - $(c).offset().top };
//END GALEDIT
if (e.hasClass("dn") || e.hasClass("up")) e.removeClass("dn").removeClass("up");
if (a.x > c.offsetWidth - 16) {
b = c.offsetHeight / 2;
if (a.y >= b - 1 && a.y <= b + 1) c.style.cursor = "crosshair";
else {
c.style.cursor = "default";
a.y < b - 1 ? e.addClass("up") : e.addClass("dn")
}
} else if (c.style.cursor != "") c.style.cursor = ""
}
};
this.mouseDown = function(a, b) {
d.capture(null);
if (!n())
if (c.style.cursor == "crosshair") {
d.capture(null);
d.capture(c);
e.addClass("unselectable");
o = d.pageCoordinates(b);
y = r()
} else {
//GALEDIT
//a = d.widgetCoordinates(c, b);
a = { x: b.x - $(c).offset().left, y: b.y - $(c).offset().top };
//END GALEDIT
if (a.x > c.offsetWidth - 16) {
d.cancelEvent(b);
d.capture(c);
e.addClass("unselectable");
a.y < c.offsetHeight / 2 ? d.eventRepeat(function() {
w()
}) : d.eventRepeat(function() {
x()
})
}
}
};
this.mouseUp = function(a) {
e.removeClass("unselectable");
if (!n()) {
if (s || o != null) {
o = null;
a.onchange()
}
d.stopRepeat()
}
};
this.keyDown = function(a, b) {
if (!n())
if (b.keyCode == 40) d.eventRepeat(function() {
x()
});
else b.keyCode == 38 && d.eventRepeat(function() {
w()
})
};
this.keyUp = function(a) {
if (!n()) {
if (s) {
s = false;
a.onchange()
}
d.stopRepeat()
}
};
this.setLocale = function(a, b) {
p = a;
q = b
};
this.validate = function() {
var a = r();
if (a === null) a = "a";
return z.validate(a)
};
this.setIsDoubleSpinBox(v)
}
    (1-1/1)