Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

…onent
  • Loading branch information...
commit f314e453c7205450bcb5d039baf0850a27e7291e 1 parent 42f7ebb
Howard M. Lewis Ship authored
11 tapx-core/src/main/resources/com/howardlewisship/tapx/core/tapx-core.css
View
@@ -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;
24 tapx-core/src/main/resources/com/howardlewisship/tapx/core/tapx.js
View
@@ -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 {
Please sign in to comment.
Something went wrong with that request. Please try again.