The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

A possible code to enable WYSIWYG mode for certain forums?

3 posters

Go down

Solved A possible code to enable WYSIWYG mode for certain forums?

Post by Ramdaman Tue Sep 02, 2014 12:07 am

Hi everyone,

I was wondering if it was possible to only enable WYSIWYG mode for a certain forum or certain forums, but not the whole thing. Thanks in advance Smile


Last edited by Ramdaman on Tue Sep 02, 2014 9:33 pm; edited 1 time in total
Ramdaman
Ramdaman
Active Poster

Male Posts : 1590
Reputation : 99
Language : English, Albanian, Macedonian, Russian | HTML, CSS
Location : New York City

http://ndihme.forumotion.com/forum

Back to top Go down

Solved Re: A possible code to enable WYSIWYG mode for certain forums?

Post by Row Tue Sep 02, 2014 6:27 am

Hi, it is impossible for the moment on Forumotion, see the suggestions of the members on the forum. Nice day.
Row
Row
New Member

Male Posts : 24
Reputation : 1
Language : English and French
Location : France

http://coqfr.forumactif.com/

Back to top Go down

Solved Re: A possible code to enable WYSIWYG mode for certain forums?

Post by Ange Tuteur Tue Sep 02, 2014 10:31 am

Hello Ramdaman,

This is absolutely possible with a bit of JavaScript. Wink

Go to Administration Panel > Modules > JavaScript codes management > create a new script

Title : Your choice
Placement : In the topics
Paste the code below :
Code:
$(function(){$(function(){
  var editor = $('#text_editor_textarea').sceditor('instance');
  if ( forum(1) || forum(2) || forum(3) ) {
    if (editor.inSourceMode()) {
      editor.sourceMode(false);
      $('.sceditor-button-source').removeClass('hover');
      $.cookie('WYSIWYG_STATE', '1', { expires: 365 });
    }
  }
  else {
    editor.sourceMode(true);
    $('.sceditor-button-source').addClass('hover');
    $.cookie('WYSIWYG_STATE', '0', { expires: 365 });
  }
  function forum(n) {return RegExp('\/f'+n+'-').test($('.topic-actions .pathname-box p a.nav:last').attr('href'))}
})});

In the script is a condition :
Code:
if ( forum(1) || forum(2) || forum(3) )

These are the forums whose topics you'll enabled WYSIWYG mode for. Simply write : forum(n) with n being a number value, that is the forum ID. You must separate multiple forums by ||.

So for example, if you wanted to enable WYSIWYG mode in announcement, you would write :
Code:
if ( forum(6) )

You can see the forum ID from the address bar while viewing the forum. e.g. http://www.agg-community.com/f6-announcements = f6 - f = 6

Note :
* The forums which don't allow WYSIWYG mode by default will start in source mode
* The mode can still be switched if the source button is visible
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: A possible code to enable WYSIWYG mode for certain forums?

Post by Ramdaman Tue Sep 02, 2014 11:46 am

I have made a form as shown in the Tips and Tricks, and I wanted to have it like forumotion has it for the graphic requests. Since forumotion has enabled WYSIWYG mode in the admin panel, I was wondering if this WYSIWYG script would work with the form script. Because it currently does not show.

Code for the form JS
Code:
$(function() {
    if (location.pathname == '/post' && location.search == '?f=17&mode=newtopic') {
       $('#text_editor_textarea').val('[FONT=ARIAL BLACK][B][COLOR=#3399ff]Time:[/B][COLOR=#3399ff][/COLOR][/FONT] Answer Here\n
[FONT=ARIAL BLACK][B][COLOR=#669900]In\-Game name of the player:[/B][COLOR=#669900][/COLOR][/FONT] Answer Here \n
[FONT=ARIAL BLACK][B][COLOR=#3399ff]What happened:[/B][COLOR=#3399ff][/COLOR][/FONT] Answer Here \n
[FONT=ARIAL BLACK][B][COLOR=#669900]Proof -Pictures or video-:[/B][COLOR=#669900][/COLOR][/FONT]  Answer Here');
    }
});

Code I inserted for certain forums containing WYSIWYG
Code:
$(function(){$(function(){
  var editor = $('#text_editor_textarea').sceditor('instance');
  if ( forum(17) ) {
    if (editor.inSourceMode()) {
      editor.sourceMode(false);
      $('.sceditor-button-source').removeClass('hover');
      $.cookie('WYSIWYG_STATE', '1', { expires: 365 });
    }
  }
  else {
    editor.sourceMode(true);
    $('.sceditor-button-source').addClass('hover');
    $.cookie('WYSIWYG_STATE', '0', { expires: 365 });
  }
  function forum(n) {return RegExp('\/f'+n+'-').test($('.topic-actions .pathname-box p a.nav:last').attr('href'))}
})});


I basically want the form to not be displayed with the BBBcodes in brackets but I want the BBCodes showing the design.
Ramdaman
Ramdaman
Active Poster

Male Posts : 1590
Reputation : 99
Language : English, Albanian, Macedonian, Russian | HTML, CSS
Location : New York City

http://ndihme.forumotion.com/forum

Back to top Go down

Solved Re: A possible code to enable WYSIWYG mode for certain forums?

Post by Ange Tuteur Tue Sep 02, 2014 7:15 pm

If that's the case, remove the last script and replace your form script by :
Code:
$$(function(){
  if (location.pathname == '/post' && location.search == '?f=17&mode=newtopic') {
    $('#text_editor_textarea').val('[FONT=ARIAL BLACK][B][COLOR=#3399ff]Time:[/B][COLOR=#3399ff][/COLOR][/FONT] Answer Here\n[FONT=ARIAL BLACK][B][COLOR=#669900]In\-Game name of the player:[/B][COLOR=#669900][/COLOR][/FONT] Answer Here \n[FONT=ARIAL BLACK][B][COLOR=#3399ff]What happened:[/B][COLOR=#3399ff][/COLOR][/FONT] Answer Here \n[FONT=ARIAL BLACK][B][COLOR=#669900]Proof -Pictures or video-:[/B][COLOR=#669900][/COLOR][/FONT]  Answer Here');
   
    $(function(){
      var editor = $('#text_editor_textarea').sceditor('instance');
      if (editor.inSourceMode()) {
        editor.sourceMode(false);
        $('.sceditor-button-source').removeClass('hover');
        $.cookie('WYSIWYG_STATE', '1', { expires: 365 });
      }
    });
  }
});
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: A possible code to enable WYSIWYG mode for certain forums?

Post by Ramdaman Tue Sep 02, 2014 7:29 pm

Still shows the bbcodes
Ramdaman
Ramdaman
Active Poster

Male Posts : 1590
Reputation : 99
Language : English, Albanian, Macedonian, Russian | HTML, CSS
Location : New York City

http://ndihme.forumotion.com/forum

Back to top Go down

Solved Re: A possible code to enable WYSIWYG mode for certain forums?

Post by Ange Tuteur Tue Sep 02, 2014 7:39 pm

Oops, I made a typo ^^' replace your script by :
Code:
$(function(){
  if (location.pathname == '/post' && location.search == '?f=17&mode=newtopic') {
    $('#text_editor_textarea').val('[FONT=ARIAL BLACK][B][COLOR=#3399ff]Time:[/B][COLOR=#3399ff][/COLOR][/FONT] Answer Here\n[FONT=ARIAL BLACK][B][COLOR=#669900]In\-Game name of the player:[/B][COLOR=#669900][/COLOR][/FONT] Answer Here \n[FONT=ARIAL BLACK][B][COLOR=#3399ff]What happened:[/B][COLOR=#3399ff][/COLOR][/FONT] Answer Here \n[FONT=ARIAL BLACK][B][COLOR=#669900]Proof -Pictures or video-:[/B][COLOR=#669900][/COLOR][/FONT]  Answer Here');
 
    $(function(){
      var editor = $('#text_editor_textarea').sceditor('instance');
      if (editor.inSourceMode()) {
        editor.sourceMode(false);
        $('.sceditor-button-source').removeClass('hover');
        $.cookie('WYSIWYG_STATE', '1', { expires: 365 });
      }
    });
  }
});
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: A possible code to enable WYSIWYG mode for certain forums?

Post by Ramdaman Tue Sep 02, 2014 9:32 pm

That fixes it. Thank you Smile
Ramdaman
Ramdaman
Active Poster

Male Posts : 1590
Reputation : 99
Language : English, Albanian, Macedonian, Russian | HTML, CSS
Location : New York City

http://ndihme.forumotion.com/forum

Back to top Go down

Solved Re: A possible code to enable WYSIWYG mode for certain forums?

Post by Ange Tuteur Tue Sep 02, 2014 10:20 pm

You're welcome.

Topic archived

Have a nice day. Smile
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum