MyBB Hacks

Full Version: Mybb editor fix
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This is not the one that is available at mybb.com tutorial section.

As everyone knows that the editor once loaded does not get resized if you change the browser windows.

So I have tried to fix it. This modified editor.js does get resized if you change the browser width..

Download the file and replace the original editor.js with this one..
[attachment=494]


I have not tested it throughly so make sure you test it before using it on live forum..
Talking about MyBB editor (codebuttons and etc), I would like to see MyBB use a 'sharable' or 're-usable' editor, so we can use it for our XThreads textarea.

Thanks for sharing, Techu Smile
I think it can be done. But in order to do that the xthread must be modified to include an id tag in the textarea. and then we can use

Code:
.
. //language and other stuff
.
	var clickableEditor = new messageEditor("insert the ID of the text area", {lang: editor_language, rtl: 0, theme: "default"});
.
. //language and other stuff
.
 


to load the editor..

Very good if this can be done now (1.6). I've tried to 'steal' the editor using 1.4 before, unfortunately I failed to make it work if there is more than one textarea in the same page.
Maybe I'll try it later using 1.6.
I think MyBB didn't properly do the OOP model of the editor, so it was impossible to have more than one instance of it on a page.
Dunno if changed in 1.6 - will need to check.

Javascript Code
textInput.style.width = "99%";

I'm a little critical of relying on a 1% difference.  Is there a way to have some sort of containing div with a more fixed padding width?
You might also want to keep the height setting code in the Javascript, though I'm not sure if it really does much.
Haven't tried your code yet.

Although I don't like it, there's perhaps a reason why it's fixed width - for one, it ensures a minimum dimension so that the buttons don't go haywire.

If you just want it to fill 100% without supporting browser window resizes, it's probably better to do a HTML/CSS edit.

Thanks for sharing though - I also somewhat prefer a more dynamic width to the editor Smile

BTW, you moved the location of the video button - is that so it works better with smaller widths?

(03-28-2011 08:41 AM)ZiNgA BuRgA Wrote: [ -> ]I think MyBB didn't properly do the OOP model of the editor, so it was impossible to have more than one instance of it on a page.
Dunno if changed in 1.6 - will need to check.

Javascript Code
textInput.style.width = "99%";

I'm a little critical of relying on a 1% difference.  Is there a way to have some sort of containing div with a more fixed padding width?
You might also want to keep the height setting code in the Javascript, though I'm not sure if it really does much.
Haven't tried your code yet.

Although I don't like it, there's perhaps a reason why it's fixed width - for one, it ensures a minimum dimension so that the buttons don't go haywire.

99% was a quick and easy fix and it appears ok on all major browser so I went with that. Div would have be an better solution.
You are right, the height settings code does not do much so I removed the whole thing.

(03-28-2011 08:41 AM)ZiNgA BuRgA Wrote: [ -> ]Although I don't like it, there's perhaps a reason why it's fixed width - for one, it ensures a minimum dimension so that the buttons don't go haywire.

But minimum width can also be set using a div class. I am not sure why the developers made the editor that way.
BTW I have noticed that editors of other forum or cms script also has a fixed width, not really sure why..

(03-28-2011 08:41 AM)ZiNgA BuRgA Wrote: [ -> ]If you just want it to fill 100% without supporting browser window resizes, it's probably better to do a HTML/CSS edit.

Thanks for sharing though - I also somewhat prefer a more dynamic width to the editor Smile

BTW, you moved the location of the video button - is that so it works better with smaller widths?
Filling 100% without supporting browser window resizes can be done with the default editor.js all we have to change the values of cols and rows attributes of the textarea in newthread and newreply templates.

I moved the video button because the dropdown menu does not appear properly near the browser border..
(03-28-2011 04:30 AM)RateU Wrote: [ -> ]Very good if this can be done now (1.6). I've tried to 'steal' the editor using 1.4 before, unfortunately I failed to make it work if there is more than one textarea in the same page.
Maybe I'll try it later using 1.6.

I thought this might work but have`nt tried it myself.
(03-28-2011 01:14 PM)techu Wrote: [ -> ]99% was a quick and easy fix and it appears ok on all major browser so I went with that. Div would have be an better solution.
It may look okay in browsers - the thing is the size of the window.  It may look different on a maximised window on a 3840x2160 resolution screen, as opposed to a 400x300 window, for example.

(03-28-2011 01:14 PM)techu Wrote: [ -> ]But minimum width can also be set using a div class. I am not sure why the developers made the editor that way.
min-width/height CSS attributes are not supported by IE6.

(03-28-2011 01:14 PM)techu Wrote: [ -> ]BTW I have noticed that editors of other forum or cms script also has a fixed width, not really sure why..
Possibly so that the editor doesn't get too wide on a high resolution widescreen monitor.
those are also valid points...
Parts of MyBB's javascript will be updated in the next maintenance release after 1.6.3 to take advantage of Prototype 1.7. It's not jQuery, but it's better. Tongue
Reference URL's