From a1d5de6b54425fdda3d61a5ebe8325b379a565cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Betn=C3=A9r?= Date: Fri, 12 May 2006 11:01:54 +0000 Subject: [PATCH] config.html: Possible to add items in the UI, for options of type and --- admin-root/config.html | 7 +++++++ admin-root/config.js | 36 +++++++++++++++++++++++++++++++++--- admin-root/config.xml | 3 +++ 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/admin-root/config.html b/admin-root/config.html index 1e36c96c..a7a103b5 100644 --- a/admin-root/config.html +++ b/admin-root/config.html @@ -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; +}

Configuration

diff --git a/admin-root/config.js b/admin-root/config.js index 99f684d1..2044b351 100644 --- a/admin-root/config.js +++ b/admin-root/config.js @@ -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 = { diff --git a/admin-root/config.xml b/admin-root/config.xml index 52cb3b0c..f344317d 100644 --- a/admin-root/config.xml +++ b/admin-root/config.xml @@ -84,6 +84,7 @@ MP3 Directory long_text_multiple + Add Directory Extensions @@ -109,6 +110,7 @@ Compilation Directories long_text_multiple + Add Directory Art Filename @@ -167,6 +169,7 @@ Plugins short_text_multiple + Add Plugin