News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

How to Disable wysiwyg manually? Is it possible?

Started by SoLoGHoST, October 09, 2011, 10:35:58 PM

Previous topic - Next topic

SoLoGHoST

Quote from: Arantor on July 29, 2012, 09:55:15 PM
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.

Sounds like it should work, but as I remember, there was a problem with calling that method before, when I tried to, which is why I suppose it's being done the long way.

Quote from: Arantor on July 29, 2012, 09:55:15 PM
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.

ummmm, Ok...

SoLoGHoST

Ok, here's another solution to this as well, via javascript:

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 (obj_wysiwyg.style.display != "none")
{
oEditorHandle_' . $context['page_content'] . '.toggleView(0);
}
}
}
else
{
document.getElementById("bbcBox_message").style.display = "";
document.getElementById("smileyBox_message").style.display = "";
}
}


After, testing this, Arantor is correct, you can call the toggleView method, instead of the 3 lines tmpMethod and getText that I called.  You can either use toggleView(0) or just toggleView().  Strange how I couldn't get it to work when I tried before, but now seems to work just fine.  It could've been that I was setting the bView parameter to 1 I suppose.

Thanks Arantor!

inter

Sorry for my English

SoLoGHoST

You're welcome, should probably get rid of the val parameter in the function, if not needed.  I was using for it a radio button and passing the value of the radio button into that parameter.  But in any case, this function also shows you how to hide the BBC and Smiley areas as well.

inter

#24
I have bad english
You have not understood what I wanted  8)

that's what I needed:

Sources/My Mod/.../Post2.php:
if (!empty($_REQUEST['message_mode']) && isset($_REQUEST['message']))
{
require_once($sourcedir . '/Subs-Editor.php');

$_REQUEST['message'] = html_to_bbc($_REQUEST['message']);

// We need to unhtml it now as it gets done shortly.
$_REQUEST['message'] = un_htmlspecialchars($_REQUEST['message']);

// We need this for everything else.
$_POST['message'] = $_REQUEST['message'];
}


Themes/.../My Mod/Post.template.php:
// @TODO: Ajax Preview
echo '
<script type="text/javascript"><!-- // --><![CDATA[
$("#postmodify").submit(function(){
if (oEditorHandle_' . $context['post_box_name'] . '.bRichTextEnabled === true)
{
var message_value = oEditorHandle_' . $context['post_box_name'] . '.getText();
$("#message_mode").val(1);
$("#message").val(message_value);
}
return true;
})
function previewPost()
{
if (oEditorHandle_' . $context['post_box_name'] . '.bRichTextEnabled === true)
{
var message_value = oEditorHandle_' . $context['post_box_name'] . '.getText();
$("#message_mode").val(1);
$("#message").val(message_value);
}
return true;
}
// ]]></script>';
Sorry for my English

Advertisement: