From 3cacf941fa30e8c02f3f7aebcc8747036d0d8d20 Mon Sep 17 00:00:00 2001 From: alecpl Date: Wed, 1 Jun 2011 13:44:51 +0000 Subject: - Add popup with basic fields selection for addressbook search --- skins/default/functions.js | 70 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 58 insertions(+), 12 deletions(-) (limited to 'skins/default/functions.js') 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) -- cgit v1.2.3