Module: BBcode version 2 (complete rewrite)

Posted by Maurice Makaay 
Re: Module: BBcode version 2 (complete rewrite)
April 23, 2008 03:56PM
@optimal: Thanks. I'll take a look at that scrolling code. I think you posted it somewhere already, but during travel I lost track of it and could not find it back. I'm most happy to integrate that in the javascript code.

@brianlmoon: The URL is not linked indeed. The bare url feature was disabled in the module settings, but enabling it did not make the URL clickable. Apparently that was not it. It appeared to be a simple typo in the code. I fixed this bug in 2.0.1.

@hcgtv: I implemented a new tag feature to strip the first break after the closing tag and enabled that feature for the [list] tag. This fixes the extra spacing after the lists. Please try out module version 2.0.1 to see if that fixes things for you. We have to try out if that feature has to be enabled for other tags like [quote] and [code] as well. Didn't do that bit yet.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce



Edited 1 time(s). Last edit at 04/23/2008 04:05PM by mmakaay.
Re: Module: BBcode version 2 (complete rewrite)
April 23, 2008 04:13PM
The scrollTop feature is fully cross browser compatible? I only have FireFox to test out here in the desert. I think I tried something with that in the past, but found some problem with it. Might also have been a different one though or a problem with some of the old browsers like MSIE5. But wrapping it with if (thetextarea.scrollTop) would take care of possible incompatibilities if there are any. Thanks for the code. I'll defenitely will incorporate that in the editor tools in some way.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Module: BBcode version 2 (complete rewrite)
April 23, 2008 04:19PM
Quote
mmakaay
@optimal: Thanks. I'll take a look at that scrolling code. I think you posted it somewhere already, but during travel I lost track of it and could not find it back. I'm most happy to integrate that in the javascript code.

Perhaps you are talking about my proposal?

Regards
Oliver


Using Phorum since 7/2000: forum.langzeittest.de (actual version 5.2.23)
Modules "Made in Germany" for version 5.2: Author_as_Sender, CarCost, Close_Topic, Conceal_Message_Timestamp,
Format_Email, Index_Structure, Mailing_List, Pervasive_Forum, Spritmonitor, Terms_of_Service and German_Language_Files_Package.
Re: Module: BBcode version 2 (complete rewrite)
April 23, 2008 04:21PM
Quote
Oliver Riesen
Perhaps you are talking about my proposal?
That explains why I didn't find it in the forums ;-)
Thanks to you both.

edit: maurice, are you just showing off the parser now? - Brian


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce



Edited 1 time(s). Last edit at 04/23/2008 04:25PM by brianlmoon.
Re: Module: BBcode version 2 (complete rewrite)
April 23, 2008 05:35PM
Err, it was part of another project, that I tested on the "big set";

Windoze: IE6, IE7, Opera, Netscape, FFox
Linux: FFox, Opera
Apple: Safari

But I only have Linux FFox to test with recently so I can't properly confirm. Also, I don't think you need to add in an if statement because the worst case scenario is that you set a new property to the textarea of undefined which wont *do* anything!

I actually prefer textareas to expand as I add content, so that scrolling is part of the main page rather than having scroll areas within scroll areas (if that makes sense). I would have added that to the code, but I can't fully test it. Something like this:

  // On some key event:
  el.style.height = (el.scrollHeight > 60 ? el.scrollHeight : 75) + 'px';
  el.scrollTop = 0;

Thing is, that sort of code requires the CSS to be just right, which obviously doesn't sit well with templating!


If it moves, eat it. If it doesn't move, wait till it moves, then eat it
Re: Module: BBcode version 2 (complete rewrite)
April 24, 2008 08:38PM
Yeah, you're absolutely right about the property. And reading scrollTop would fallback to a NULL value too nicely, so nothing to worry about. I already incorporated the scrolling and reselecting of the previously selected text in the Editor Tools module on my laptop. I only need to get my head around the reasons the nice computation that you have in the code for MSIE ;-)
newSel.end   -= newSel.start + el.value.slice (newSel.start + 1, newSel.end).split ('\n').length - 1;
newSel.start -= el.value.slice (0, newSel.start).split ('\n').length - 1;
Maybe I'll wait with that part till I'm home and can work with MSIE again. For Firefox and compatible browsers, it's working like a charm already with the new code.

One thing in your example code didn't quite work failsafe IMO. That is if you select a part of text and then click on a button like the [hr] tag. Instead of adding the [hr], it will replace the selected text with [hr]. In fact, that is how my really early editor tools worked too, but it p*ssed of users on my boards that they could lose the interesting stuff that they were typing up. So maybe something to be aware of in your project.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Module: BBcode version 2 (complete rewrite)
April 25, 2008 09:00AM
Oh OK, I had to go out of my way to do that, it's the way I prefer it to work!

// Build and write the new string (in parts)
  var newVal = {};
  newVal.start = val.substr (0, sel.start) + openTag;
  if (closeTag) {
    newVal.sel = val.substr (sel.start, sel.end - sel.start);
    newVal.end = closeTag + val.substr (sel.end, val.length);
  } else {
    newVal.sel = '';
    newVal.end = val.substr (sel.end, val.length);
  }
  el.value = newVal.start + newVal.sel + newVal.end;

should read

// Build and write the new string (in parts)
  var newVal = {};
  newVal.start = val.substr (0, sel.start) + openTag;
  newVal.sel = val.substr (sel.start, sel.end - sel.start);
  newVal.end = closeTag + val.substr (sel.end, val.length);
  el.value = newVal.start + newVal.sel + newVal.end;



And as for the MSIE code, I wrote that a wee while back, and TBH I forget how it works too, but hell, if it aint broke!!


If it moves, eat it. If it doesn't move, wait till it moves, then eat it
Re: Module: BBcode version 2 (complete rewrite)
April 25, 2008 09:23PM
I agree, but I have this weird tendency / neurotic tic of wanting to know what the code does that I put in my packages, but no worries. I'll figure that bit out when I get home.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Module: BBcode version 2 (complete rewrite)
April 25, 2008 10:23PM
Uploaded version 2.0.2.
  • A help text for [list] was added to the BBcode help page. Translations will be needed for the available languages.
    For now, the english help was added to all help files for all languages.
  • Added back the templates directory which holds the template for the "disable BBcode" option in the posting editor.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Module: BBcode version 2 (complete rewrite)
April 26, 2008 11:19AM
Hi Maurice,

Quote
mmakaay
Translations will be needed for the available languages.

German language files enclosed.

Regards
Oliver

[File removed]


Using Phorum since 7/2000: forum.langzeittest.de (actual version 5.2.23)
Modules "Made in Germany" for version 5.2: Author_as_Sender, CarCost, Close_Topic, Conceal_Message_Timestamp,
Format_Email, Index_Structure, Mailing_List, Pervasive_Forum, Spritmonitor, Terms_of_Service and German_Language_Files_Package.




Edited 1 time(s). Last edit at 05/12/2008 02:21PM by Oliver Riesen.
Sorry, only registered users may post in this forum.

Click here to login