IDEMPIERE-413 zk6: Calculator not working

This commit is contained in:
Elaine Tan 2012-09-04 17:27:04 +08:00
parent 078684b68d
commit bcf0b47bc7
2 changed files with 29 additions and 10 deletions

View File

@ -22,12 +22,12 @@ import java.text.NumberFormat;
import java.text.ParseException;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.apps.AEnv;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.zkoss.zhtml.Table;
import org.zkoss.zhtml.Td;
import org.zkoss.zhtml.Tr;
import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Decimalbox;
@ -106,10 +106,10 @@ public class NumberBox extends Div
btnColumn.appendChild(btn);
popup = getCalculatorPopup();
appendChild(popup);
LayoutUtils.addSclass("editor-button", btn);
btn.setPopup(popup);
btn.setStyle("text-align: center;");
appendChild(popup);
LayoutUtils.addSclass(".number-box", this);
}
@ -190,13 +190,27 @@ public class NumberBox extends Div
private Popup getCalculatorPopup()
{
Popup popup = new Popup();
Popup popup = new Popup() {
@Override
public void onPageAttached(Page newpage, Page oldpage) {
super.onPageAttached(newpage, oldpage);
if (newpage != null) {
if (btn.getPopup() != null) {
btn.setPopup(this);
}
}
}
};
Vbox vbox = new Vbox();
char separatorChar = DisplayType.getNumberFormat(DisplayType.Number, Env.getLanguage(Env.getCtx())).getDecimalFormatSymbols().getDecimalSeparator();
txtCalc = new Textbox();
decimalBox.setId(decimalBox.getUuid());
txtCalc.setId(txtCalc.getUuid());
txtCalc.setWidgetListener("onKeyPress", "return calc.validate('" +
decimalBox.getId() + "','" + txtCalc.getId()
+ "'," + integral + "," + (int)separatorChar + ", event);");

View File

@ -59,7 +59,8 @@ function Calc()
{
try
{
var calcText = document.getElementById(calcTextId);
var id = "$".concat(calcTextId);
var calcText = jq(id)[0];
calcText.value = "";
}
catch (err)
@ -71,7 +72,8 @@ function Calc()
{
try
{
var calcText = document.getElementById(calcTextId);
var id = "$".concat(calcTextId);
var calcText = jq(id)[0];
var val = calcText.value;
if (val != "")
{
@ -89,7 +91,8 @@ function Calc()
{
try
{
var calcText = document.getElementById(calcTextId);
var id = "$".concat(calcTextId);
var calcText = jq(id)[0];
var value = calcText.value;
if (separator != '.')
{
@ -103,12 +106,13 @@ function Calc()
}
calcText.value = result;
var displayText = document.getElementById(displayTextId);
id = "$".concat(displayTextId);
var displayText = jq(id)[0];
if (!displayText.readOnly && calcText.value != 'undefined')
{
displayText.value = calcText.value;
setTimeout("document.getElementById('" + displayTextId + "').focus()", 100);
setTimeout("jq('$" + displayTextId + "')[0].focus()", 100);
}
}
catch (err)
@ -118,7 +122,8 @@ function Calc()
function append(calcTextId, val)
{
var calcText = document.getElementById(calcTextId);
var id = "$".concat(calcTextId);
var calcText = jq(id)[0];
calcText.value += val;
}
}