if (!window.Prima) Prima=[];
if (!Prima.Templates) Prima.Templates=[];
Prima.Templates.NumberInput = Active.Templates.Text.subclass();
Prima.Templates.NumberInput.create = function()
{
var obj = this.prototype;
// editor is not part of the template,
// there is only one single instance of editor object.
var editor = new Active.HTML.INPUT;
editor.setClass("templates", "input");
editor.setAttribute("type", "text");
editor.setAttribute("value", function()
{
return template.getItemProperty("text");
});
// template variable provides temporary reference
// to the parent template during edit mode.
var template;
function switchToEditMode()
{
template = this;
template.element().style.padding = 0;
template.element().innerHTML = editor;
editor.element().focus();
}
obj.setEvent("ondblclick", switchToEditMode);
function switchToTextMode()
{
var value = editor.element().value;
var intVal = value * 1;
if(!isNaN(intVal))
{
//alert(intVal);
template.setItemProperty("text", value); ---- (1)
}
template.refresh();
template = null;
}
editor.setEvent("onblur", switchToTextMode);
};
Prima.Templates.NumberInput.create();
obj.getText = function(i, j){
var node = this.getNode(i, j);
var data = node ? node.text : "";
var format = this._formats[j];
return format ? format.dataToText(data) : data;
};
template.setItemProperty("value", value);
This topic is archived.