Skip to content

Instantly share code, notes, and snippets.

@tominal
Created April 23, 2019 20:24
Show Gist options
  • Save tominal/1a62e7d9b232d02e304f67646626097f to your computer and use it in GitHub Desktop.
Save tominal/1a62e7d9b232d02e304f67646626097f to your computer and use it in GitHub Desktop.
btnPriceWindowClick function fix
var isZero = false;
function btnPriceWindowClick(btnClick) {
if (btnClick == 'CLR') {
$("#customPrice").data("kendoNumericTextBox").value(0);
}
else {
var priceText = $("#customPrice").val();
var priceLastText = priceText.slice(-2);
if (priceText == null) {
priceText = '0';
}
if (btnClick == '.') {
isZero = false;
if (priceText.includes(".")) {
priceText = priceText;
}
else {
priceText = priceText + '.0';
}
}
if (priceText == '0') {
priceText = btnClick;
}
else {
if (btnClick != '.') {
if (priceLastText == ".0" && btnClick != "0" && isZero == false) {
priceText = priceText.replace(priceLastText, "." + btnClick);
isZero = false;
}
else if (priceLastText == ".0" && btnClick == "0" && isZero == false) {
isZero = true;
priceText = priceText;
}
else if (priceLastText == ".0" && btnClick == "0" && isZero == true) {
priceText = priceText + btnClick;
}
else {
priceText = priceText + btnClick;
}
}
else {
priceText = priceText;
}
}
$("#customPrice").data("kendoNumericTextBox").value(priceText);
/**
* Quick fix.
* #customPrice's aria-valuenow attribute is not being changed when the button click is '.'
* even though .data("kendoNumericTextBox").value() is called.
*/
$("#customPrice").val(priceText);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment