Linted and found some stuff to clean up

This commit is contained in:
Anders Betnér 2006-05-24 22:02:44 +00:00
parent d30bafbd50
commit 6ea05929ee
1 changed files with 10 additions and 21 deletions

View File

@ -168,7 +168,7 @@ var Config = {
case 'text': case 'text':
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 = [''];
} }
var parentSpan = Builder.node('span'); var parentSpan = Builder.node('span');
@ -222,6 +222,9 @@ var Config = {
item.short_description)); item.short_description));
frag.appendChild(Builder.node('br')); frag.appendChild(Builder.node('br'));
break; break;
default:
alert('This should not happen (1)');
break;
} }
return frag; return frag;
}, },
@ -234,7 +237,7 @@ var Config = {
var id = newSpan.getElementsByTagName('input')[0].id; var id = newSpan.getElementsByTagName('input')[0].id;
var num = parseInt(id.match(/\d+$/)); var num = parseInt(id.match(/\d+$/));
num++; num++;
var id = id.replace(/\d+$/,'') + num; id = id.replace(/\d+$/,'') + num;
newSpan.getElementsByTagName('label')[0].setAttribute('for',id); newSpan.getElementsByTagName('label')[0].setAttribute('for',id);
newSpan.getElementsByTagName('input')[0].id = id; newSpan.getElementsByTagName('input')[0].id = id;
@ -271,7 +274,7 @@ var Config = {
_browse: function(e) { _browse: function(e) {
alert('Browse'); alert('Browse');
} }
} };
var BuildElement = { var BuildElement = {
input: function(id,name,displayName,value,size,short_description,long_description) { input: function(id,name,displayName,value,size,short_description,long_description) {
@ -319,8 +322,8 @@ var BuildElement = {
return frag; return frag;
} }
};
}
function saved(req) { function saved(req) {
if ('200' == Element.textContent(req.responseXML.getElementsByTagName('status')[0])) { if ('200' == Element.textContent(req.responseXML.getElementsByTagName('status')[0])) {
alert('Saved'); alert('Saved');
@ -343,7 +346,7 @@ function saveForm() {
} }
} else { } else {
postVars.push(Form.Element.serialize(input.id)); postVars.push(Form.Element.serialize(input.id));
}; }
}); });
$H(multiple).each(function (item) { $H(multiple).each(function (item) {
postVars.push(item.key + '=' + item.value.join(',')); postVars.push(item.key + '=' + item.value.join(','));
@ -360,7 +363,7 @@ function cancelForm() {
var itemConfigId = item.config_section + ':' + item.id; var itemConfigId = item.config_section + ':' + item.id;
if (item.multiple) { if (item.multiple) {
var values = ConfigInitialValues.getValue(item.config_section,itemId); var values = ConfigInitialValues.getValue(item.config_section,itemId);
if (!values || values.length == 0) { if (!values || values.length === 0) {
values = ['']; values = [''];
} }
var initialValuesCount = values.length; var initialValuesCount = values.length;
@ -392,20 +395,6 @@ var i=0;
}); });
}); });
return; return;
ConfigInitialValues.getValues().each(function (option) {
if (typeof (option.value) == 'object') {
//###TODO what if user removed one of the multiplevalued options?
if (option.value != '') {
option.value.each(function (val,i) {
$(option.key + i).value = val;
});
}
}
var el = $(option.key);
if (el) {
el.value = option.value;
}
});
} }
Object.extend(Element, { Object.extend(Element, {
removeChildren: function(element) { removeChildren: function(element) {