config.html: Possible to add items in the UI, for options of type

<short_text_multiple> and <long_text_multiple>
This commit is contained in:
Anders Betnér 2006-05-12 11:01:54 +00:00
parent b150896921
commit a1d5de6b54
3 changed files with 43 additions and 3 deletions

View File

@ -20,6 +20,13 @@ select {
padding-top: .3em;
padding-left: 1em;
}
.addItemHref {
float: left;
margin-left: 11em;
font: icon;
padding-left: 1.5em;
margin-bottom: .5em;
}
</style>
<h1>Configuration</h1>

View File

@ -69,9 +69,10 @@ var Config = {
}
},
_buildItem: function(item) {
var ret;
var itemId = item.getAttribute('id');
var href;
var span;
switch(Element.textContent(item.getElementsByTagName('type')[0])) {
case 'short_text':
ret = BuildElement.input(itemId,
@ -90,23 +91,37 @@ var Config = {
case 'short_text_multiple':
ret = document.createDocumentFragment();
Config._getConfigOptionValue(itemId,true).each(function (value,i) {
ret.appendChild(BuildElement.input(itemId+i,
var span = document.createElement('span');
span.appendChild(BuildElement.input(itemId+i,
Element.textContent(item.getElementsByTagName('name')[0]),
value,20,
Element.textContent(item.getElementsByTagName('short_description')[0])
));
ret.appendChild(span);
});
href = Builder.node('a',{href:'javascript://',className:'addItemHref'},
Element.textContent(item.getElementsByTagName('add_item_text')[0]));
ret.appendChild(href);
Event.observe(href,'click',Config._addItem);
ret.appendChild(Builder.node('div',{style:'clear: both'}));
break;
case 'long_text_multiple':
//###TODO Do something smart instead of just copying
ret = document.createDocumentFragment();
Config._getConfigOptionValue(itemId,true).each(function (value,i) {
ret.appendChild(BuildElement.input(itemId+i,
var span = document.createElement('span');
span.appendChild(BuildElement.input(itemId+i,
Element.textContent(item.getElementsByTagName('name')[0]),
value,80,
Element.textContent(item.getElementsByTagName('short_description')[0])
));
ret.appendChild(span);
});
href = Builder.node('a',{href:'javascript://',className:'addItemHref'},
Element.textContent(item.getElementsByTagName('add_item_text')[0]));
ret.appendChild(href);
Event.observe(href,'click',Config._addItem);
ret.appendChild(Builder.node('div',{style:'clear: both'}));
break;
case 'select':
var value = Config._getConfigOptionValue(itemId);
@ -122,6 +137,21 @@ var Config = {
break;
}
return ret;
},
_addItem: function(e) {
var span = Event.element(e);
while (span.nodeName.toLowerCase() != 'span') {
span = span.previousSibling;
}
var frag = document.createDocumentFragment();
span = span.cloneNode(true);
span.getElementsByTagName('label')[0].setAttribute('for','hej');
span.getElementsByTagName('input')[0].id = 'hej';
span.getElementsByTagName('input')[0].value = '';
var src = Event.element(e);
src.parentNode.insertBefore(span,src);
}
}
var BuildElement = {

View File

@ -84,6 +84,7 @@
<name>MP3 Directory</name>
<short_description></short_description>
<type>long_text_multiple</type>
<add_item_text>Add Directory</add_item_text>
</item>
<item id="extensions">
<name>Extensions</name>
@ -109,6 +110,7 @@
<name>Compilation Directories</name>
<short_description></short_description>
<type>long_text_multiple</type>
<add_item_text>Add Directory</add_item_text>
</item>
<item id="art_filename">
<name>Art Filename</name>
@ -167,6 +169,7 @@
<name>Plugins</name>
<short_description></short_description>
<type>short_text_multiple</type>
<add_item_text>Add Plugin</add_item_text>
</item>
</section>