summaryrefslogtreecommitdiff
path: root/skins/default/functions.js
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2011-06-01 13:44:51 +0000
committeralecpl <alec@alec.pl>2011-06-01 13:44:51 +0000
commit3cacf941fa30e8c02f3f7aebcc8747036d0d8d20 (patch)
tree3d873bb15f9454b28c3c4a8ba3216421ededdfd4 /skins/default/functions.js
parent2912de6f9bea6c0491a7bc4321e66637da0a6746 (diff)
- Add popup with basic fields selection for addressbook search
Diffstat (limited to 'skins/default/functions.js')
-rw-r--r--skins/default/functions.js70
1 files changed, 58 insertions, 12 deletions
diff --git a/skins/default/functions.js b/skins/default/functions.js
index 9057d97c4..603c703b2 100644
--- a/skins/default/functions.js
+++ b/skins/default/functions.js
@@ -186,9 +186,25 @@ searchmenu: function(show)
.find(':checked').prop('checked', false);
if (rcmail.env.search_mods) {
- var search_mods = rcmail.env.search_mods[rcmail.env.mailbox] ? rcmail.env.search_mods[rcmail.env.mailbox] : rcmail.env.search_mods['*'];
- for (var n in search_mods)
- $('#s_mod_' + n).prop('checked', true);
+ var n, mbox = rcmail.env.mailbox, mods = rcmail.env.search_mods;
+
+ if (rcmail.env.task != 'addressbook') {
+ mods = mods[mbox] ? mods[mbox] : mods['*'];
+
+ for (n in mods)
+ $('#s_mod_' + n).prop('checked', true);
+ }
+ else {
+ if (mods['*'])
+ $('input:checkbox[name="s_mods[]"]').map(function() {
+ this.checked = true;
+ this.disabled = this.value != '*';
+ });
+ else {
+ for (n in mods)
+ $('#s_mod_' + n).prop('checked', true);
+ }
+ }
}
}
obj[show?'show':'hide']();
@@ -196,16 +212,46 @@ searchmenu: function(show)
set_searchmod: function(elem)
{
- if (!rcmail.env.search_mods)
- rcmail.env.search_mods = {};
-
- if (!rcmail.env.search_mods[rcmail.env.mailbox])
- rcmail.env.search_mods[rcmail.env.mailbox] = rcube_clone_object(rcmail.env.search_mods['*']);
+ var task = rcmail.env.task,
+ mods = rcmail.env.search_mods,
+ mbox = rcmail.env.mailbox;
+
+ if (!mods)
+ mods = {};
+
+ if (task == 'mail') {
+ if (!mods[mbox])
+ mods[mbox] = rcube_clone_object(mods['*']);
+ if (!elem.checked)
+ delete(mods[mbox][elem.value]);
+ else
+ mods[mbox][elem.value] = 1;
+ }
+ else { //addressbook
+ if (!elem.checked)
+ delete(mods[elem.value]);
+ else
+ mods[elem.value] = 1;
+
+ // mark all fields
+ if (elem.value == '*') {
+ $('input:checkbox[name="s_mods[]"]').map(function() {
+ if (this == elem)
+ return;
+
+ if (elem.checked) {
+ mods[this.value] = 1;
+ this.checked = true;
+ this.disabled = true;
+ }
+ else {
+ this.disabled = false;
+ }
+ });
+ }
+ }
- if (!elem.checked)
- delete(rcmail.env.search_mods[rcmail.env.mailbox][elem.value]);
- else
- rcmail.env.search_mods[rcmail.env.mailbox][elem.value] = elem.value;
+ rcmail.env.search_mods = mods;
},
listmenu: function(show)