The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

A possible code to enable WYSIWYG mode for certain forums?

View previous topic View next topic Go down

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

Post by Ramdaman on September 2nd 2014, 2: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 September 2nd 2014, 11:33 pm; edited 1 time in total

Ramdaman
Active Poster

Male Posts : 1614
Reputation : 97
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 on September 2nd 2014, 8:27 am

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

Row
New Member

Male Posts : 21
Reputation : 1
Language : English and French
Location : France, Paris

Back to top Go down

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

Post by Ange Tuteur on September 2nd 2014, 12:31 pm

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
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

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

Post by Ramdaman on September 2nd 2014, 1:46 pm

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
Active Poster

Male Posts : 1614
Reputation : 97
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 on September 2nd 2014, 9: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
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

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

Post by Ramdaman on September 2nd 2014, 9:29 pm

Still shows the bbcodes

Ramdaman
Active Poster

Male Posts : 1614
Reputation : 97
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 on September 2nd 2014, 9: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
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

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

Post by Ramdaman on September 2nd 2014, 11:32 pm

That fixes it. Thank you Smile

Ramdaman
Active Poster

Male Posts : 1614
Reputation : 97
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 on September 3rd 2014, 12:20 am

You're welcome.

Topic archived

Have a nice day. Smile

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

View previous topic View next topic Back to top


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