summaryrefslogtreecommitdiff
path: root/public_html
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2012-03-16 18:57:22 (GMT)
committerAleksander Machniak <alec@alec.pl>2012-03-16 18:57:22 (GMT)
commit64725457a91cac1db5303f20ba0c62e46ab19632 (patch)
treedeac3f7fb33cd345ed2ea9b0dc017e8d2a499901 /public_html
parent1f0b3a7a7dac41932e425a0d27345e07be566e3e (diff)
downloadkolab-wap-64725457a91cac1db5303f20ba0c62e46ab19632.tar.gz
Fix listelement serialization (#637)
Diffstat (limited to 'public_html')
-rw-r--r--public_html/js/kolab_admin.js9
-rw-r--r--public_html/skins/default/ui.js11
2 files changed, 13 insertions, 7 deletions
diff --git a/public_html/js/kolab_admin.js b/public_html/js/kolab_admin.js
index 5bddf5d..bdcf1e2 100644
--- a/public_html/js/kolab_admin.js
+++ b/public_html/js/kolab_admin.js
@@ -437,7 +437,7 @@ function kolab_admin()
$('textarea[data-type="list"]', form).each(function() {
var name = this.name;
// maybe already converted by skin engine
- if (json[name] && !$.isArray(json[name]))
+ if (!json[name] || !$.isArray(json[name]))
json[name] = $(this).val().split("\n");
});
@@ -618,3 +618,10 @@ function kolab_admin()
};
var kadm = new kolab_admin();
+
+// Add escape() method to RegExp object
+// http://dev.rubyonrails.org/changeset/7271
+RegExp.escape = function(str)
+{
+ return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
+};
diff --git a/public_html/skins/default/ui.js b/public_html/skins/default/ui.js
index 5645f7e..850eb93 100644
--- a/public_html/skins/default/ui.js
+++ b/public_html/skins/default/ui.js
@@ -141,18 +141,17 @@ function form_serialize(data)
var form = $(data.id);
// replace some textarea fields with pretty/smart input lists
- $('textarea[data-type="list"]', form).not('disabled')
- .each(function() {
- var i, value = [], re = RegExp('^' + this.name + '\[[0-9]+\]$');
+ $('textarea[data-type="list"]', form).not('disabled').each(function() {
+ var i, v, value = [],
+ re = RegExp('^' + RegExp.escape(this.name) + '\[[0-9]+\]$');
for (i in data.json) {
if (i.match(re)) {
- if (i.value)
- value.push(i.value);
+ if (v = $('input[name="'+i+'"]', form).val())
+ value.push(v);
delete data.json[i];
}
}
-
data.json[this.name] = value;
});