comparison forum/Themes/default/scripts/PersonalMessage.js @ 76:e3e11437ecea website

Add forum code
author Chris Cannam
date Sun, 07 Jul 2013 11:25:48 +0200
parents
children
comparison
equal deleted inserted replaced
75:72f59aa7e503 76:e3e11437ecea
1
2 // Handle the JavaScript surrounding personal messages send form.
3 function smf_PersonalMessageSend(oOptions)
4 {
5 this.opt = oOptions;
6 this.oBccDiv = null;
7 this.oBccDiv2 = null;
8 this.oToAutoSuggest = null;
9 this.oBccAutoSuggest = null;
10 this.oToListContainer = null;
11 this.init();
12 }
13
14 smf_PersonalMessageSend.prototype.init = function()
15 {
16 if (!this.opt.bBccShowByDefault)
17 {
18 // Hide the BCC control.
19 this.oBccDiv = document.getElementById(this.opt.sBccDivId);
20 this.oBccDiv.style.display = 'none';
21 this.oBccDiv2 = document.getElementById(this.opt.sBccDivId2);
22 this.oBccDiv2.style.display = 'none';
23
24 // Show the link to bet the BCC control back.
25 var oBccLinkContainer = document.getElementById(this.opt.sBccLinkContainerId);
26 oBccLinkContainer.style.display = '';
27 setInnerHTML(oBccLinkContainer, this.opt.sShowBccLinkTemplate);
28
29 // Make the link show the BCC control.
30 var oBccLink = document.getElementById(this.opt.sBccLinkId);
31 oBccLink.instanceRef = this;
32 oBccLink.onclick = function () {
33 this.instanceRef.showBcc();
34 return false;
35 };
36 }
37
38 var oToControl = document.getElementById(this.opt.sToControlId);
39 this.oToAutoSuggest = new smc_AutoSuggest({
40 sSelf: this.opt.sSelf + '.oToAutoSuggest',
41 sSessionId: this.opt.sSessionId,
42 sSessionVar: this.opt.sSessionVar,
43 sSuggestId: 'to_suggest',
44 sControlId: this.opt.sToControlId,
45 sSearchType: 'member',
46 sPostName: 'recipient_to',
47 sURLMask: 'action=profile;u=%item_id%',
48 sTextDeleteItem: this.opt.sTextDeleteItem,
49 bItemList: true,
50 sItemListContainerId: 'to_item_list_container',
51 aListItems: this.opt.aToRecipients
52 });
53 this.oToAutoSuggest.registerCallback('onBeforeAddItem', this.opt.sSelf + '.callbackAddItem');
54
55 this.oBccAutoSuggest = new smc_AutoSuggest({
56 sSelf: this.opt.sSelf + '.oBccAutoSuggest',
57 sSessionId: this.opt.sSessionId,
58 sSessionVar: this.opt.sSessionVar,
59 sSuggestId: 'bcc_suggest',
60 sControlId: this.opt.sBccControlId,
61 sSearchType: 'member',
62 sPostName: 'recipient_bcc',
63 sURLMask: 'action=profile;u=%item_id%',
64 sTextDeleteItem: this.opt.sTextDeleteItem,
65 bItemList: true,
66 sItemListContainerId: 'bcc_item_list_container',
67 aListItems: this.opt.aBccRecipients
68 });
69 this.oBccAutoSuggest.registerCallback('onBeforeAddItem', this.opt.sSelf + '.callbackAddItem');
70
71 }
72
73 smf_PersonalMessageSend.prototype.showBcc = function()
74 {
75 // No longer hide it, show it to the world!
76 this.oBccDiv.style.display = '';
77 this.oBccDiv2.style.display = '';
78 }
79
80
81 // Prevent items to be added twice or to both the 'To' and 'Bcc'.
82 smf_PersonalMessageSend.prototype.callbackAddItem = function(oAutoSuggestInstance, sSuggestId)
83 {
84 this.oToAutoSuggest.deleteAddedItem(sSuggestId);
85 this.oBccAutoSuggest.deleteAddedItem(sSuggestId);
86
87 return true;
88 }