editor.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // *** smc_Editor class.
  2. function smc_Editor(oOptions)
  3. {
  4. this.opt = oOptions;
  5. var editor = $('#' + oOptions.sUniqueId);
  6. this.sUniqueId = this.opt.sUniqueId;
  7. this.bRichTextEnabled = true;
  8. }
  9. // Return the current text.
  10. smc_Editor.prototype.getText = function(bPrepareEntities, bModeOverride)
  11. {
  12. return $('#' + this.sUniqueId).data("sceditor").getText();
  13. }
  14. // Set the HTML content to be that of the text box - if we are in wysiwyg mode.
  15. smc_Editor.prototype.doSubmit = function()
  16. {}
  17. // Populate the box with text.
  18. smc_Editor.prototype.insertText = function(sText, bClear, bForceEntityReverse, iMoveCursorBack)
  19. {
  20. $('#' + this.sUniqueId).data("sceditor").InsertText(sText.replace(/<br \/>/gi, ''), bClear);
  21. }
  22. // Start up the spellchecker!
  23. smc_Editor.prototype.spellCheckStart = function()
  24. {
  25. if (!spellCheck)
  26. return false;
  27. // If we're in HTML mode we need to get the non-HTML text.
  28. if (this.bRichTextEnabled)
  29. {
  30. var sText = escape(this.getText(true, 1).php_to8bit());
  31. this.tmpMethod = sendXMLDocument;
  32. this.tmpMethod(smf_prepareScriptUrl(smf_scripturl) + 'action=jseditor;view=0;' + this.opt.sSessionVar + '=' + this.opt.sSessionId + ';xml', 'message=' + sText, this.onSpellCheckDataReceived);
  33. delete tmpMethod;
  34. }
  35. // Otherwise start spellchecking right away.
  36. else
  37. spellCheck(this.sFormId, this.opt.sUniqueId);
  38. return true;
  39. }