0
|
1 /**
|
|
2 * vcard_attachments plugin script
|
|
3 *
|
|
4 * @licstart The following is the entire license notice for the
|
|
5 * JavaScript code in this file.
|
|
6 *
|
|
7 * Copyright (c) 2012-2016, The Roundcube Dev Team
|
|
8 *
|
|
9 * The JavaScript code in this page is free software: you can redistribute it
|
|
10 * and/or modify it under the terms of the GNU General Public License
|
|
11 * as published by the Free Software Foundation, either version 3 of
|
|
12 * the License, or (at your option) any later version.
|
|
13 *
|
|
14 * @licend The above is the entire license notice
|
|
15 * for the JavaScript code in this file.
|
|
16 */
|
|
17
|
|
18 function plugin_vcard_save_contact(mime_id)
|
|
19 {
|
|
20 var lock = rcmail.set_busy(true, 'loading');
|
|
21 rcmail.http_post('plugin.savevcard', { _uid: rcmail.env.uid, _mbox: rcmail.env.mailbox, _part: mime_id }, lock);
|
|
22
|
|
23 return false;
|
|
24 }
|
|
25
|
|
26 function plugin_vcard_insertrow(data)
|
|
27 {
|
|
28 var ctype = data.row.ctype;
|
|
29
|
|
30 if (ctype == 'text/vcard' || ctype == 'text/x-vcard' || ctype == 'text/directory') {
|
|
31 $('#rcmrow' + rcmail.html_identifier(data.uid, true) + ' > td.attachment')
|
|
32 .html('<img src="' + rcmail.env.vcard_icon + '" alt="" />');
|
|
33 }
|
|
34 }
|
|
35
|
|
36 function plugin_vcard_attach()
|
|
37 {
|
|
38 var id, n, contacts = [],
|
|
39 ts = new Date().getTime(),
|
|
40 args = {_uploadid: ts, _id: rcmail.env.compose_id};
|
|
41
|
|
42 for (n=0; n < rcmail.contact_list.selection.length; n++) {
|
|
43 id = rcmail.contact_list.selection[n];
|
|
44 if (id && id.charAt(0) != 'E' && rcmail.env.contactdata[id])
|
|
45 contacts.push(id);
|
|
46 }
|
|
47
|
|
48 if (!contacts.length)
|
|
49 return false;
|
|
50
|
|
51 args._uri = 'vcard://' + contacts.join(',');
|
|
52
|
|
53 // add to attachments list
|
|
54 if (!rcmail.add2attachment_list(ts, {name: '', html: rcmail.get_label('attaching'), classname: 'uploading', complete: false}))
|
|
55 rcmail.file_upload_id = rcmail.set_busy(true, 'attaching');
|
|
56
|
|
57 rcmail.http_post('upload', args);
|
|
58 }
|
|
59
|
|
60 window.rcmail && rcmail.addEventListener('init', function(evt) {
|
|
61 if (rcmail.gui_objects.messagelist)
|
|
62 rcmail.addEventListener('insertrow', function(data, evt) { plugin_vcard_insertrow(data); });
|
|
63
|
|
64 if (rcmail.env.action == 'compose' && rcmail.gui_objects.contactslist) {
|
|
65 rcmail.env.compose_commands.push('attach-vcard');
|
|
66 rcmail.register_command('attach-vcard', function() { plugin_vcard_attach(); });
|
|
67 rcmail.contact_list.addEventListener('select', function(list) {
|
|
68 // TODO: support attaching more than one at once
|
|
69 rcmail.enable_command('attach-vcard', list.selection.length == 1 && rcmail.contact_list.selection[0].charAt(0) != 'E');
|
|
70 });
|
|
71 }
|
|
72 });
|