Permalink
Browse files

Add an explicit add button next to the text field of a SetEditor comp…

…onent
  • Loading branch information...
1 parent 42f7ebb commit f314e453c7205450bcb5d039baf0850a27e7291e @hlship committed Jun 17, 2011
@@ -33,6 +33,17 @@ SPAN.tx-seteditor-delete {
}
+SPAN.tx-seteditor-add {
+ width: 16px;
+ height: 16px;
+ margin-left: 2px;
+ float: right;
+ background-image: url(silk/add.png);
+ display: inline-block;
+ cursor: pointer;
+}
+
+
DIV.tx-tree-container
{
padding: 0;
@@ -107,8 +107,14 @@ Tapx.extendInitializer(function() {
value : state.values.toJSON()
});
+ var addButton = new Element("span", {
+ "class" : "tx-seteditor-add"
+ });
+
textField.insert({
after : hiddenField
+ }).insert({
+ after : addButton
});
var valuesColumn = textField.up(".tx-seteditor").down(
@@ -122,12 +128,7 @@ Tapx.extendInitializer(function() {
addItemToList(value, state, valueList, hiddenField);
});
- textField.observe("keypress", function(event) {
- if (event.keyCode != Event.KEY_RETURN)
- return;
-
- event.stop();
-
+ function addNewItem() {
var value = textField.value;
if (value == null || value.empty())
@@ -140,7 +141,18 @@ Tapx.extendInitializer(function() {
updateHiddenField(hiddenField, state);
textField.value = "";
+ }
+
+ textField.observe("keypress", function(event) {
+ if (event.keyCode != Event.KEY_RETURN)
+ return;
+
+ event.stop();
+
+ addNewItem();
});
+
+ addButton.observe("click", addNewItem);
}
return {

0 comments on commit f314e45

Please sign in to comment.