A "different" Checkbox Template
It's size and fuctionality could be usefull, (I hope so)
// ****************************************************************
// BigCheckbox Template.
// ****************************************************************
My.Templates.BigCheckbox = Active.Templates.Text.subclass();
My.Templates.BigCheckbox.create = function()
{
var obj = this.prototype;
// editor is not part of the template,
// there is only one single instance of editor object.
var Acheckbox = new Active.HTML.INPUT;
Acheckbox.setClass("templates", "bigcheckbox");
Acheckbox.setStyle("width", "27");
Acheckbox.setStyle("height", "20");
Acheckbox.setAttribute("hidden", "true");
Acheckbox.setAttribute("readonly", "true");
Acheckbox.setAttribute("value", "Yes");
var Bcheckbox = new Active.HTML.INPUT;
Bcheckbox.setClass("templates", "bigcheckbox");
Bcheckbox.setAttribute("type", "text");
Bcheckbox.setStyle("width", "27");
Bcheckbox.setStyle("height", "20");
Bcheckbox.setAttribute("readonly", "true");
Bcheckbox.setAttribute("value", "No");
// EVENTS
Acheckbox.setEvent("onblur", switchToTextMode);
Acheckbox.setEvent("onclick", function(){
template.element().innerHTML = Bcheckbox;
template.setItemProperty("text", "No")
switchToTextMode(); } );
Bcheckbox.setEvent("onblur", switchToTextMode);
Bcheckbox.setEvent("onclick", function(){
template.element().innerHTML = Acheckbox;
template.setItemProperty("text", "Yes");
switchToTextMode(); } );
obj.setEvent("ondblclick", switchToEditMode);
// FUNCTIONS
// template variable provides temporary reference
// to the parent template during edit mode.
var template;
function switchToEditMode(){
if (template) {
switchToTextMode()
}
template = this;
template.element().style.padding = 0;
if(template.getItemProperty("text")=="Yes"){
template.element().innerHTML = Acheckbox;
Acheckbox.element().focus(); }
else{ template.element().innerHTML = Bcheckbox;
Bcheckbox.element().focus(); }
}
function switchToTextMode(){
template.element().innerHTML = "";
template.refresh();
template = null;
}
};
My.Templates.BigCheckbox.create();
//**********************************
And it's CSS .......
.active-templates-bigcheckbox {
width: 100%;
height: 100%;
padding: 0px 5px;
margin: -1px 0px;
border: 1px solid #666;
vertical-align: top;
font: menu;
line-height: 1.4em;
}
.active-templates-bigcheckbox.gecko {
display: block;
margin: 0px;
}
// ****************************************************************
// BigCheckbox Template.
// ****************************************************************
My.Templates.BigCheckbox = Active.Templates.Text.subclass();
My.Templates.BigCheckbox.create = function()
{
var obj = this.prototype;
// editor is not part of the template,
// there is only one single instance of editor object.
var Acheckbox = new Active.HTML.INPUT;
Acheckbox.setClass("templates", "bigcheckbox");
Acheckbox.setStyle("width", "27");
Acheckbox.setStyle("height", "20");
Acheckbox.setAttribute("hidden", "true");
Acheckbox.setAttribute("readonly", "true");
Acheckbox.setAttribute("value", "Yes");
var Bcheckbox = new Active.HTML.INPUT;
Bcheckbox.setClass("templates", "bigcheckbox");
Bcheckbox.setAttribute("type", "text");
Bcheckbox.setStyle("width", "27");
Bcheckbox.setStyle("height", "20");
Bcheckbox.setAttribute("readonly", "true");
Bcheckbox.setAttribute("value", "No");
// EVENTS
Acheckbox.setEvent("onblur", switchToTextMode);
Acheckbox.setEvent("onclick", function(){
template.element().innerHTML = Bcheckbox;
template.setItemProperty("text", "No")
switchToTextMode(); } );
Bcheckbox.setEvent("onblur", switchToTextMode);
Bcheckbox.setEvent("onclick", function(){
template.element().innerHTML = Acheckbox;
template.setItemProperty("text", "Yes");
switchToTextMode(); } );
obj.setEvent("ondblclick", switchToEditMode);
// FUNCTIONS
// template variable provides temporary reference
// to the parent template during edit mode.
var template;
function switchToEditMode(){
if (template) {
switchToTextMode()
}
template = this;
template.element().style.padding = 0;
if(template.getItemProperty("text")=="Yes"){
template.element().innerHTML = Acheckbox;
Acheckbox.element().focus(); }
else{ template.element().innerHTML = Bcheckbox;
Bcheckbox.element().focus(); }
}
function switchToTextMode(){
template.element().innerHTML = "";
template.refresh();
template = null;
}
};
My.Templates.BigCheckbox.create();
//**********************************
And it's CSS .......
.active-templates-bigcheckbox {
width: 100%;
height: 100%;
padding: 0px 5px;
margin: -1px 0px;
border: 1px solid #666;
vertical-align: top;
font: menu;
line-height: 1.4em;
}
.active-templates-bigcheckbox.gecko {
display: block;
margin: 0px;
}
Carlos
January 25,