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