var ItemA = function() {
this.itemName = "新增系统选项A";
this.dbKey = "NEW_SYSTEM_CONFIG_ITEM_A";
};
lang.extend(ItemA, 'freequery.config.configitem.AbstractSystemConfigItem');
// 进行初始化化动作并返回一个 tr 元素
ItemA.prototype.init = function() {
this.tr = document.createElement("tr");
this.tr.height = "30";
this.td1 = document.createElement("td");
this.td1.align = "left";
this.td1.width = "200px";
this.td1.innerHTML = this.itemName + ":";
this.tr.appendChild(this.td1);
this.td2 = document.createElement("td");
this.td2.innerHTML = "<input type='radio' name='newConfigItemA' id='yes' class='_yes' checked />"
+ "<label >是</label>"
+ "<input type='radio' name='newConfigItemA' id='no' class='_no' />"
+ "<label >否</label>";
this.tr.appendChild(this.td2);
this.td3 = document.createElement("td");
this.td3.innerHTML = "初始值( 是 )";
this.tr.appendChild(this.td3);
this.td4 = document.createElement("td");
this.td4.innerHTML = "<input class='button-buttonbar-noimage _defBtn ' value='恢复初始值' "
+ "type='button' style='width:100%;' />";
this.tr.appendChild(this.td4);
this.radioyes = domutils.findElementByClassName( [ this.tr ], "_yes");
this.radiono = domutils.findElementByClassName( [ this.tr ], "_no");
this.resetBtn = domutils.findElementByClassName( [ this.tr ], "_defBtn");
var that = this;
this.addListener(this.resetBtn, "click", function() {
that.radioyes.checked = true;
that.radiono.checked = false;
}, this);
return this.tr;
}
// 检查配置信息是否合法
ItemA.prototype.validate = function() {
return true;
}
// 保存配置并返回是否保存成功,对于从系统配置表里的获取数据的配置项来说,返回一个对象
ItemA.prototype.save = function() {
if (!this.validate())
return false;
var obj = {
key : this.dbKey,
value : '' + this.radioyes.checked
};
return obj;
}
// 对于从系统配置表里的获取数据的配置项来说,需要在初始化后根据配置信息来显示
ItemA.prototype.handleConfig = function(systemConfig) {
for ( var i in systemConfig) {
var config = systemConfig[i];
if (config && config.key == this.dbKey) {
var v = (config.value == 'true');
this.radioyes.setAttribute("__checked", v);
this.radiono.setAttribute("__checked", !v);
break;
}
}
};