summaryrefslogtreecommitdiff
path: root/plugins/managesieve/managesieve.js
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-06-11 13:14:34 +0200
committerAleksander Machniak <alec@alec.pl>2013-06-11 13:14:34 +0200
commitbba7814efe68de9332e629df2de2f33c985819d1 (patch)
treeb0e0a7710d57102a54dccf6e9d4d3d100266a321 /plugins/managesieve/managesieve.js
parentc6f0755860b7a08b68375c534d1fae40dbaaf21d (diff)
Simplify list inputs (remove add button)
Diffstat (limited to 'plugins/managesieve/managesieve.js')
-rw-r--r--plugins/managesieve/managesieve.js27
1 files changed, 12 insertions, 15 deletions
diff --git a/plugins/managesieve/managesieve.js b/plugins/managesieve/managesieve.js
index 117097ef1..299d4c3c2 100644
--- a/plugins/managesieve/managesieve.js
+++ b/plugins/managesieve/managesieve.js
@@ -718,32 +718,29 @@ function smart_field_row(value, name, idx, size)
{
// build row element content
var input, content = '<span class="listelement">'
- + '<span class="actions"><span class="add"></span><span class="reset"></span></span>'
- + '<input type="text"></span>',
+ + '<span class="reset"></span><input type="text"></span>',
elem = $(content),
attrs = {value: value, name: name + '[]'};
if (size)
attrs.size = size;
- input = $('input', elem).attr(attrs)
- .keydown(function(e) { if (e.which == 13) $('span[class="add"]', elem).click(); });
+ input = $('input', elem).attr(attrs).keydown(function(e) {
+ var input = $(this);
+ // element creation event (on Enter)
+ if (e.which == 13) {
+ var name = input.attr('name').replace(/\[\]$/, ''),
+ dt = (new Date()).getTime(),
+ elem = smart_field_row('', name, dt, size);
- // element creation event
- $('span[class="add"]', elem).click(function() {
- var span = $(this.parentNode.parentNode),
- input = $('input', span),
- name = input.attr('name').replace(/\[\]$/, ''),
- dt = (new Date()).getTime(),
- elem = smart_field_row('', name, dt, size);
-
- span.after(elem);
- $('input', elem).focus();
+ input.parent().after(elem);
+ $('input', elem).focus();
+ }
});
// element deletion event
$('span[class="reset"]', elem).click(function() {
- var span = $(this.parentNode.parentNode);
+ var span = $(this.parentNode);
if (span.parent().children().length > 1)
span.remove();