Page 1 of 1

BBCode and Smiley Menus

PostPosted: Sat Oct 17, 2009 9:04 pm
by cyaneo
I want use WYMeditor for my Drupal integrated advanced forum - so far if works like a charm!

But - as in this forum - I want add some custom buttons/menus:
BBcodes: Quote; Code; Img; URL;
and some Smileys

Ho can this be done?
PS: Please beware: I am a non-programmer, I just can insert code-snippets... :-(

Re: BBCode and Smiley Menus

PostPosted: Tue Oct 27, 2009 11:15 pm
by mr_lundis
Hi cyaneo!
Unfortunately I can't provide you with the full code to make what you describe work, but take a look at the wrap/unwrap test page. With a little customization you should be able to achieve the functionality you described.

The following lines are the ones that should be most interesting:
Code: Select all
            //construct the wrap button's html
            var html = "<li class='wym_tools_wrap'>"
                     + "<a name='Wrap' href='#'"
                     + " style='background-image:"
                     + " url(../wymeditor/skins/default/icons.png)'>"
                     + "Wrap"
                     + "<\/a><\/li>";

            //add the button to the tools box
            .find(wym._options.toolsSelector + wym._options.toolsListSelector)

            //handle click event
            .find('li.wym_tools_wrap a').click(function() {
                wym.wrap( '<span>', '<\/span>');

Its the wym.wrap()-line that's doing all the magic. It will wrap the current selection in whichever two strings you pass as arguments.

Cheers! ;)