Fixed some small errors in config.js
This commit is contained in:
parent
3876b65e1c
commit
5d611fe52a
|
@ -1,17 +1,13 @@
|
||||||
Event.observe(window,'load',init);
|
Event.observe(window,'load',init);
|
||||||
//###TODO
|
//###TODO
|
||||||
//Disable/enable save/cancel
|
// * Fix cancel for multiple, create a span holding all multiple elements
|
||||||
/* platform = window.navigator.platform.toLowerCase();
|
// * Disable/enable save/cancel, Add key and onchange listeners keep a note on changed items
|
||||||
if (platform.indexOf('win') != -1)
|
// * create the path/file browser
|
||||||
navigator.OS = 'win';
|
// * Inform user if server restart needed, ask Ron which options
|
||||||
else if (platform.indexOf('mac') != -1)
|
// * Show required options in UI check with Ron if conf.c is correct
|
||||||
navigator.OS = 'mac';
|
// * better errormessage for not writable config
|
||||||
else if (platform.indexOf('unix') != -1 || platform.indexOf('linux') != -1 || platform.indexOf('sun') != -1)
|
// * make tabs?
|
||||||
navigator.OS = 'nix';*/
|
// * add warning if leaving page without saving
|
||||||
//Inform user if server restart needed
|
|
||||||
//better errormessage for not writable config
|
|
||||||
//make tabs?
|
|
||||||
//create the path/file browser
|
|
||||||
|
|
||||||
// Config isn't defined until after the Event.observe above
|
// Config isn't defined until after the Event.observe above
|
||||||
// I could have put it below Config = ... but I want all window.load events
|
// I could have put it below Config = ... but I want all window.load events
|
||||||
|
@ -19,7 +15,6 @@ Event.observe(window,'load',init);
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
Config.init();
|
Config.init();
|
||||||
|
|
||||||
}
|
}
|
||||||
var ConfigXML = {
|
var ConfigXML = {
|
||||||
config: [],
|
config: [],
|
||||||
|
@ -47,8 +42,11 @@ var ConfigXML = {
|
||||||
var items = {};
|
var items = {};
|
||||||
$A(section.getElementsByTagName('item')).each(function (item) {
|
$A(section.getElementsByTagName('item')).each(function (item) {
|
||||||
var returnItem = {};
|
var returnItem = {};
|
||||||
returnItem['config_section'] = item.getAttribute('config_section');
|
if (item.hasAttributes()) {
|
||||||
returnItem['id'] = item.getAttribute('id');
|
$A(item.attributes).each(function (attr) {
|
||||||
|
returnItem[attr.name] = attr.value;
|
||||||
|
});
|
||||||
|
}
|
||||||
$A(item.childNodes).each(function (node) {
|
$A(item.childNodes).each(function (node) {
|
||||||
if (Element.textContent(node) == '') {
|
if (Element.textContent(node) == '') {
|
||||||
return;
|
return;
|
||||||
|
@ -63,7 +61,7 @@ var ConfigXML = {
|
||||||
} else {
|
} else {
|
||||||
returnItem[node.nodeName] = Element.textContent(node);
|
returnItem[node.nodeName] = Element.textContent(node);
|
||||||
}
|
}
|
||||||
if (node.hasAttributes) {
|
if (node.hasAttributes()) {
|
||||||
$A(node.attributes).each(function (attr) {
|
$A(node.attributes).each(function (attr) {
|
||||||
returnItem[attr.name] = attr.value;
|
returnItem[attr.name] = attr.value;
|
||||||
});
|
});
|
||||||
|
@ -182,8 +180,7 @@ var Config = {
|
||||||
if (item.multiple) {
|
if (item.multiple) {
|
||||||
var values = ConfigInitialValues.getValue(item.config_section,item.id);
|
var values = ConfigInitialValues.getValue(item.config_section,item.id);
|
||||||
if (!values || values.length == 0) {
|
if (!values || values.length == 0) {
|
||||||
values = [];
|
values = [''];
|
||||||
values.push('');
|
|
||||||
}
|
}
|
||||||
values.each(function (val,i) {
|
values.each(function (val,i) {
|
||||||
var span = document.createElement('span');
|
var span = document.createElement('span');
|
||||||
|
@ -324,8 +321,10 @@ var BuildElement = {
|
||||||
});
|
});
|
||||||
select.value = value;
|
select.value = value;
|
||||||
frag.appendChild(select);
|
frag.appendChild(select);
|
||||||
frag.appendChild(document.createTextNode('\u00a0'));
|
frag.appendChild(document.createTextNode('\u00a0'));
|
||||||
frag.appendChild(document.createTextNode(short_description));
|
if (short_description) {
|
||||||
|
frag.appendChild(document.createTextNode(short_description));
|
||||||
|
}
|
||||||
|
|
||||||
return frag;
|
return frag;
|
||||||
}
|
}
|
||||||
|
@ -352,7 +351,11 @@ function cancelForm() {
|
||||||
var item = ConfigXML.getOption(section,itemId);
|
var item = ConfigXML.getOption(section,itemId);
|
||||||
var itemConfigId = item.config_section + ':' + item.id;
|
var itemConfigId = item.config_section + ':' + item.id;
|
||||||
if (item.multiple) {
|
if (item.multiple) {
|
||||||
// do the multiple thing
|
var values = ConfigInitialValues.getValue(itemConfigId);
|
||||||
|
if (!values || values.length == 0) {
|
||||||
|
values = [''];
|
||||||
|
}
|
||||||
|
//###TODO do the multiple thing
|
||||||
} else {
|
} else {
|
||||||
//###TODO potential error a select without a default value
|
//###TODO potential error a select without a default value
|
||||||
$(itemConfigId).value = ConfigInitialValues.getValue(item.config_section,item.id) || item.default_value || '';
|
$(itemConfigId).value = ConfigInitialValues.getValue(item.config_section,item.id) || item.default_value || '';
|
||||||
|
|
Loading…
Reference in New Issue