PersonalMessage.js 2.7 KB

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