Customizing SMF > SMF Coding Discussion

How to Disable wysiwyg manually? Is it possible?

<< < (4/5) > >>

Well done, you repeated yourself, I already realised that after your last post.

Since there's a button for it, call the same code the button uses.

I'm sorry I bothered replying to this topic.

It's a prototype, so you can't access the functions directly!  Anyways, here's code taken out of DreamPages.template.php for you to see how I did it.  If val does not equal 2, than it disables the WYSIWYG Toggle View.  You place a call to the check_bbc function on the onchange event of a Radio Button, or whatever for that matter...

And $context['page_content'] represents the $editorOptions['id'] value.  For example, when you build the editor:

--- Code: ---$editorOptions = array(
'id' => 'body',
'labels' => array(
'height' => '250px',
'width' => '100%',
'preview_type' => 2,
'rich_active' => false,
$context['page_content'] = $editorOptions['id'];

--- End code ---

So, in this case, the $context['page_content'] = 'body';

--- Code: ---function check_bbc(val)
if (val != 2)
var obj_wysiwyg = document.getElementById("html_' . $context['page_content'] . '");
document.getElementById("bbcBox_message").style.display = "none";
document.getElementById("smileyBox_message").style.display = "none";
if (obj_wysiwyg)
// Disable wysiwyg when switching to html/php options!
if ( != "none")
var sText = oEditorHandle_' . $context['page_content'] . '.getText(true, 1).replace(/&#/g, "&#").php_to8bit().php_urlencode();
oEditorHandle_' . $context['page_content'] . '.tmpMethod = sendXMLDocument;
oEditorHandle_' . $context['page_content'] . '.tmpMethod(smf_prepareScriptUrl(smf_scripturl) + "action=jseditor;view=0;', $context['session_var'] . '=' . $context['session_id'] . ';xml", "message=" + sText, oEditorHandle_' . $context['page_content'] . '.onToggleDataReceived);
document.getElementById("bbcBox_message").style.display = "";
document.getElementById("smileyBox_message").style.display = "";

--- End code ---

There, have fun with it.


--- Quote ---It's a prototype, so you can't access the functions directly!
--- End quote ---

Yes, I know that. But it's JS's equivalent of a class and it is instantiated into oEditorHandle_message (or whatever you've called it), whose properties and methods you CAN access because it's an object instance (hence the o prefix)

And you actually are doing that, except doing it the long way by extending the object with new methods and calling them yourself...

True True, if there is an easier way to do the same thing, I'm all for it.  I just took a look at the prototype and came up with my own workaround for this.

There is, it's called calling the object's toggleView method - the same thing that the Toggle View button calls. And you can even determine its current state by examining the object instance's bRichTextEnabled properly, as I already said.

Then again, you told me on multiple occasions I don't know what I'm talking about, so I don't really know why you'd listen to me about this.


[0] Message Index

[#] Next page

[*] Previous page

Go to full version