Chris@76: Chris@76: // Handle the JavaScript surrounding personal messages send form. Chris@76: function smf_PersonalMessageSend(oOptions) Chris@76: { Chris@76: this.opt = oOptions; Chris@76: this.oBccDiv = null; Chris@76: this.oBccDiv2 = null; Chris@76: this.oToAutoSuggest = null; Chris@76: this.oBccAutoSuggest = null; Chris@76: this.oToListContainer = null; Chris@76: this.init(); Chris@76: } Chris@76: Chris@76: smf_PersonalMessageSend.prototype.init = function() Chris@76: { Chris@76: if (!this.opt.bBccShowByDefault) Chris@76: { Chris@76: // Hide the BCC control. Chris@76: this.oBccDiv = document.getElementById(this.opt.sBccDivId); Chris@76: this.oBccDiv.style.display = 'none'; Chris@76: this.oBccDiv2 = document.getElementById(this.opt.sBccDivId2); Chris@76: this.oBccDiv2.style.display = 'none'; Chris@76: Chris@76: // Show the link to bet the BCC control back. Chris@76: var oBccLinkContainer = document.getElementById(this.opt.sBccLinkContainerId); Chris@76: oBccLinkContainer.style.display = ''; Chris@76: setInnerHTML(oBccLinkContainer, this.opt.sShowBccLinkTemplate); Chris@76: Chris@76: // Make the link show the BCC control. Chris@76: var oBccLink = document.getElementById(this.opt.sBccLinkId); Chris@76: oBccLink.instanceRef = this; Chris@76: oBccLink.onclick = function () { Chris@76: this.instanceRef.showBcc(); Chris@76: return false; Chris@76: }; Chris@76: } Chris@76: Chris@76: var oToControl = document.getElementById(this.opt.sToControlId); Chris@76: this.oToAutoSuggest = new smc_AutoSuggest({ Chris@76: sSelf: this.opt.sSelf + '.oToAutoSuggest', Chris@76: sSessionId: this.opt.sSessionId, Chris@76: sSessionVar: this.opt.sSessionVar, Chris@76: sSuggestId: 'to_suggest', Chris@76: sControlId: this.opt.sToControlId, Chris@76: sSearchType: 'member', Chris@76: sPostName: 'recipient_to', Chris@76: sURLMask: 'action=profile;u=%item_id%', Chris@76: sTextDeleteItem: this.opt.sTextDeleteItem, Chris@76: bItemList: true, Chris@76: sItemListContainerId: 'to_item_list_container', Chris@76: aListItems: this.opt.aToRecipients Chris@76: }); Chris@76: this.oToAutoSuggest.registerCallback('onBeforeAddItem', this.opt.sSelf + '.callbackAddItem'); Chris@76: Chris@76: this.oBccAutoSuggest = new smc_AutoSuggest({ Chris@76: sSelf: this.opt.sSelf + '.oBccAutoSuggest', Chris@76: sSessionId: this.opt.sSessionId, Chris@76: sSessionVar: this.opt.sSessionVar, Chris@76: sSuggestId: 'bcc_suggest', Chris@76: sControlId: this.opt.sBccControlId, Chris@76: sSearchType: 'member', Chris@76: sPostName: 'recipient_bcc', Chris@76: sURLMask: 'action=profile;u=%item_id%', Chris@76: sTextDeleteItem: this.opt.sTextDeleteItem, Chris@76: bItemList: true, Chris@76: sItemListContainerId: 'bcc_item_list_container', Chris@76: aListItems: this.opt.aBccRecipients Chris@76: }); Chris@76: this.oBccAutoSuggest.registerCallback('onBeforeAddItem', this.opt.sSelf + '.callbackAddItem'); Chris@76: Chris@76: } Chris@76: Chris@76: smf_PersonalMessageSend.prototype.showBcc = function() Chris@76: { Chris@76: // No longer hide it, show it to the world! Chris@76: this.oBccDiv.style.display = ''; Chris@76: this.oBccDiv2.style.display = ''; Chris@76: } Chris@76: Chris@76: Chris@76: // Prevent items to be added twice or to both the 'To' and 'Bcc'. Chris@76: smf_PersonalMessageSend.prototype.callbackAddItem = function(oAutoSuggestInstance, sSuggestId) Chris@76: { Chris@76: this.oToAutoSuggest.deleteAddedItem(sSuggestId); Chris@76: this.oBccAutoSuggest.deleteAddedItem(sSuggestId); Chris@76: Chris@76: return true; Chris@76: }