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.

SyncEditor - A New Way to Post

View previous topic View next topic Go down

SyncEditor - A New Way to Post

Post by Ace 1 on October 19th 2016, 4:18 pm

If you've used StackOverflow before, then you know that they have a simplified version of the SCEditor that Forumotion uses. However, their editor shows a preview of the post as the user types.

With this plugin, that feature is now available on Forumotion!

Installation


Administration Panel > Modules > HTML & Javascript > Javascript codes management > Create new javascript (make sure Javascripts are enabled on your forum)

Title: SyncEditor
Placement: In all the pages

Code:

Code:
$(function() {
    'SyncEditor Version v0.2 2016';
    'Developed by Ace 1';
    'All rights reserved.';

    var select_code = true,
          preview_button_on = false;

    if ((/\/t\d+/.test(window.location.href) || /\/(post|(post\?(f|t|p)=\d+&mode=(newtopic|reply|quote|editpost)))/.test(window.location.href)) && $.sceditor) {

        if (!$('#preview .content').html() && $.sceditor) {
            var preview,

                version = $('.bodylinewidth')[0] ? 0 : document.getElementById('wrap') ? 1 : $('div.pun')[0] ? 2 : document.getElementById('ipbwrapper') ? 3 : '',

                simplePreview = [
                    '<table class="forumline preview" width="100%" border="0" cellspacing="1" cellpadding="4"><tbody><tr><th class="thHead" height="25">Preview</th></tr><tr><td class="row1"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tbody><tr><td><div class="postbody"></div></td></tr></tbody></table></td></tr><tr><td class="spaceRow" height="1"></td></tr></tbody></table><br clear="all">',
                    '<div id="preview" class="post row2"><div class="h3">Preview</div><div class="content"></div></div>',
                    '<div class="main-head clearfix preview"><p class="h2">Preview</p></div><div class="main-content topic" style="text-align: left;"><div class="post"><div class="posthead"><h2>This is how your post will appear once submitted.</h2></div><div class="postbody"><div class="post-entry"><div class="entry-content"></div></div></div></div></div>',
                    '<div id="preview" class="post borderwrap" style="background-color: #e4e6e9"><div class="maintitle clearfix"><h3>Preview</h3></div><div class="post-entry row1"></div></div>'
                ][version],

                createSimplePreview = function() {
                    version == 0 // PHPBB2
                        ? $('form[action="/viewforum"]').before(simplePreview)
                        : (
                          version == 1 // PHPBB3
                            ? $('#quick_reply').after(simplePreview)
                            : (
                              version == 2 // PUNBB
                                ? $('#quick_reply').append(simplePreview)
                                : (
                                    version == 3 // INVISION
                                    ? $('#qpost').after(simplePreview)
                                    : ''
                                )
                            )
                        )
                },

                advancedPreview = [
                    '<table class="forumline preview" width="100%" border="0" cellspacing="1" cellpadding="4"><tbody><tr><th class="thHead" height="25">Preview</th></tr><tr><td class="row1"><span class="postdetails"><img src="https://illiweb.com/fa/empty.gif" alt="Post" title="Post" border="0">Subject: <img src="https://illiweb.com/fa/empty.gif" alt="" border="0"><span style="user-select: none !important; color: transparent !important; text-shadow: none !important; background: none !important;">&lt;3</span>' + formatDate() + '</span></td></tr><tr><td class="row1"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tbody><tr><td><div class="postbody"></div></td></tr></tbody></table></td></tr><tr><td class="spaceRow" height="1"><img src="http://illiweb.com/fa/empty.gif" height="1" width="1" alt=""></td></tr></tbody></table><br clear="all">',
                    '<div id="preview" class="post row2"><div class="inner"><span class="corners-top"><span></span></span><div class="postbody"><div class="h3">Preview</div><div class="content"></div></div><span class="corners-bottom"><span></span></span></div></div>',
                    '<div class="main-head clearfix preview"><p class="h2">Preview</p></div><div class="main-content topic"><div class="post"><div class="postmain"><div class="posthead"><h2>This is how your post will appear once submitted.</h2></div><div class="postbody"><div class="user"><h4 class="user-ident"><span class="username">' + _userdata.username + '</span></h4></div><div class="post-entry"><div class="entry-content"></div></div></div></div></div></div>',
                    '<div id="preview" class="post borderwrap"><div class="maintitle clearfix"><h3>Preview</h3></div><div class="postbody"><div class="post-entry row1"></div></div></div>'
                ][version],

                createAdvancedPreview = function() {
                    version == 0 // PHPBB2
                        ? $('form[action="/post"]').before(advancedPreview)
                        : (
                          version == 1 // PHPBB3
                            ? $('h1.page-title').after(advancedPreview)
                            : (
                              version == 2 // PUNBB
                                ? $('form.frm-form').prepend(advancedPreview)
                                : (
                                  version == 3 // INVISION
                                    ? $('ul#navstrip').after(advancedPreview)
                                    : ''
                                )
                            )
                        )
                },

                actualContainer = [
                    '.preview .row1 table .postbody',
                    '#preview .content',
                    'form.frm-form .entry-content',
                    '#preview .post-entry'
                ][version];

            if ( version == 0 && document.forms.post.subject ) {
                document.forms.post.subject.oninput = function() {
                    var v = this.value;
                    $('span.postdetails').eq(0).contents().filter(function() {return this.nodeType == 3})[0].textContent = 'Subject: ' + (v == 'undefined' ? '' : v);
                };
            }

            function formatDate() {
                var d = Date(),
                    y = new Date().getFullYear(),
                    m = new Date().getMinutes(),
                    s = new Date().getSeconds(),
                    n = d.indexOf(m + ':' + s),
                    realDate = d.substring(0, n + 5);
                realDate = realDate.slice(0, realDate.indexOf(y) + 4) + " - " + realDate.slice(realDate.indexOf(y) + 5);
                return realDate;
            }

            /\/t\d+/.test(window.location.href)
                ? createSimplePreview()
                : /\/(post|(post\?(f|t|p)=\d+&mode=(newtopic|reply|quote|editpost)))/.test(window.location.href) ? createAdvancedPreview() : '';
        }

        $('#text_editor_textarea').ready(function() {
            var instance = $('#text_editor_textarea').sceditor('instance'),

                sceditorContent, previewContent,

                convert = function() {
                    sceditorContent = instance.val();
                    previewContent = instance.fromBBCode(sceditorContent, false);
                    $(actualContainer).html(previewContent);

                    // Smilies
                    var s, s2, re;

                    for ( s in smileys ) {
                      if ( /\W/.test(s.replace(':', '')) )  s2 = s.replace(/(.{1})/g, '\\$1');
                      else s2 = s;
                      re = new RegExp(s2, 'gi');
                      $(actualContainer).html($(actualContainer).html().replace(re, '<img src="' + smileys[s] + '" />'));
                    }

                    // Quote
                    $.sceditor.plugins.bbcode.bbcode.set('quote', {
                        tags: {
                            'div': {
                                'class': ['quote']
                            }
                        },
                        format: '[quote]{0}[/quote]',
                        html: function(token, attrs, content) {
                            var a = attrs.defaultattr,
                                c = content,
                                cite = true,
                                citation = function(author) {
                                    // author = '<a>' + author + '</a>';
                                    var wrapping = ( version == 0 ? '<dt><span class="genmed"><b>' + author + ' wrote:</b></span></dt>' : '<cite>' + author + ' wrote:</cite>');
                                    return wrapping;
                                };
                            if (a == undefined || a == '' || a == '\"') cite = false;
                            if (a.charAt(0) == '\"') a = a.replace(/\"/, '');
                            if ( version == 0 ) c = (cite ? citation(a) : '') + '<dd class="quote">' + c + '</dd>';
                            else c = '<div>' + (cite ? citation(a) : '') + c + '</div>';

                            return ( version == 0 ? '<dl class="codebox">' + c + '</dl>' : '<blockquote>' + c + '</blockquote>' );
                        }
                    });

                    // Code
                    $.sceditor.plugins.bbcode.bbcode.set('code', {
                        tags: {
                            'div': {
                                'class': ['code']
                            }
                        },
                        // allowedChildren: ['#'],
                        format: '[code]{0}[/code]',
                        html: function(token, attrs, content) {
                            var c = content,
                                selection = '<span onclick="selectCode(this)" class="selectCode">Select Content</span>',
                                title = 'Code:' + (select_code ? selection : '');
                            if ( version == 0 ) c = '<dt><span class="genmed"><b>' + title + '</b></span></dt><dd class="code"><div class="cont_code">' + c + '</div></dd>';
                            else c = '<dt>' + title + '</dt><dd><code>' + c + '</code></dd>';

                            return '<dl class="codebox">' + c + '</dl>';
                        }
                    });

                    // Spoiler
                    $.sceditor.plugins.bbcode.bbcode.set('spoiler', {
                        tags: {
                            'div': {
                                'class': ['spoiler']
                            }
                        },
                        format: '[spoiler]{0}[/spoiler]',
                        html: function(token, attrs, content) {
                            var a = attrs.defaultattr,
                                c = content;
                            if (a == undefined || a == '' || a == '\"') a = 'Spoiler';
                            if (a.charAt(0) == '\"') a = a.replace(/\"/, '');

                            if ( version == 0 ) c = '<dt style="cursor: pointer;">' + a + ':</dt><dd class="spoiler_closed">&nbsp;</dd><dd><div class="spoiler_content hidden">' + c + '</div></dd>';                             
                            else c = '<dt style="cursor: pointer;">' + a + ':</dt><dd><div class="spoiler_content">' + c + '</div></dd>';

                            return '<dl class="codebox spoiler">' + c + '</dl>';
                        }
                    });

                    if ( version == 0 || version == 2 ) {
                        // Headings For PHPBB2 && PunBB
                        $.sceditor.plugins.bbcode.bbcode.set('h2', {format: '[h2]{0}[/h2]',html: '<h2 class="post-content">{0}</h2>'});
                        $.sceditor.plugins.bbcode.bbcode.set('h3', {format: '[h3]{0}[/h3]',html: '<h3 class="post-content">{0}</h3>'});
                        $.sceditor.plugins.bbcode.bbcode.set('h4', {format: '[h4]{0}[/h4]',html: '<h4 class="post-content">{0}</h4>'});
                    }

                    // Scroll
                    $.sceditor.plugins.bbcode.bbcode.set('scroll', {
                        tags: {
                            'div': {
                                'class': ['scroll']
                            }
                        },
                        format: '[scroll]{0}[/scroll]',
                        html: function(token, attrs, content) {
                            var c = content;
                            c = '<marquee>' + c + '</marquee>';

                            return '<span>' + c + '</span>';
                        }
                    });

                    // Updown
                    $.sceditor.plugins.bbcode.bbcode.set('updown', {
                        tags: {
                            'div': {
                                'class': ['updown']
                            }
                        },
                        format: '[updown]{0}[/updown]',
                        html: function(token, attrs, content) {
                            var c = content;
                            c = '<marquee direction="up" scrollamount="1" style="height: 60px;">' + c + '</marquee>';

                            return '<span>' + c + '</span>';
                        }
                    });
                };

            /\/(post|(post\?(f|t|p)=\d+&mode=(newtopic|reply|quote|editpost)))/.test(window.location.href) ? convert() : '';

            instance.bind('focus blur keydown keyup nodechanged', function() {convert(); });

            $('.sceditor-button').click(function() {
                convert();
                $('.sceditor-dropdown div input.button').add('.sceditor-header-picker *').add('.sceditor-dropdown a.sceditor-fontsize-option').add('.sceditor-dropdown a.sceditor-fontsize-option > *').on('click', function() {
                    convert()
                });
                // $('.smiley-element > img').click(function() { setTimeout(convert, 100) });
            });

        });

        !preview_button_on ? $(document.forms.post.preview).remove() : '';
    }
});

Modification


Code:
select_code = false

Change this to
Code:
true
if you have Forumotion's Select Code feature enabled on your forum.

Click here for more information on the Select Code function.

Code:
preview_button_enabled = false

Change this to
Code:
true
if you still want to have a "Preview" button on your forum.

Other Information


On some versions, you may want to add some CSS to style the look of the preview. For example, on PHPBB3, you may want to add this to the CSS Stylesheet (AP > Display > Colors > CSS):

Code:
[name="quickreply"] + .h3 + br + #quick_reply input[type="submit"] { margin-bottom: 25px; }

#quick_reply + #preview { padding: 5px 10px; border-radius: 3px; }
#quick_reply + #preview .h3 { margin: 3px 0; }
#quick_reply + #preview .content { font-size: 1.3em; padding: 1px; }

Other than that, everything else should work out finely. If you have any questions, just ask Wink
SyncEditor
SyncEditor

This is how it looks on PHPBB3:





Note: This is optimized to work on all versions so if there is a bug or if there is a modification you want made personally, just let me know and I'll gladly get it done.


Last edited by Ace 1 on October 31st 2016, 6:39 pm; edited 1 time in total

Ace 1
Helper
Helper

Male Posts : 767
Reputation : 51
Language : English - French?
Location : Druid Hill Park

http://help.forumotion.com

Back to top Go down

Re: SyncEditor - A New Way to Post

Post by SSYT on October 20th 2016, 2:45 am

Great job @Ace, I liked your work.

SSYT
Forumember

Male Posts : 41
Reputation : 2
Language : RO-10, EN-3, FR-1
Location : Romania

http://help.forumgratuit.ro/forum

Back to top Go down

Re: SyncEditor - A New Way to Post

Post by Ace 1 on October 20th 2016, 12:22 pm

Thank you @SSYT and this is to everyone:

Emoticons don't seem to work on here but don't worry I'm going to fix that in due time.

Ace 1
Helper
Helper

Male Posts : 767
Reputation : 51
Language : English - French?
Location : Druid Hill Park

http://help.forumotion.com

Back to top Go down

Re: SyncEditor - A New Way to Post

Post by SLGray on October 20th 2016, 10:09 pm

Does everyone see this on this topic:


When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.


SLGray
Administrator
Administrator

Male Posts : 36691
Reputation : 2445
Language : English
Location : United States

http://ztwds.forumotion.com/

Back to top Go down

Re: SyncEditor - A New Way to Post

Post by jucarese on October 20th 2016, 11:05 pm

Yes I do

jucarese
Forumember

Male Posts : 979
Reputation : 13
Language : spanish
Location : Spanish forum support

http://asistencia.foroactivo.com/u23082

Back to top Go down

Re: SyncEditor - A New Way to Post

Post by Valoish on October 20th 2016, 11:40 pm

@SLGray Yeah I do LOL. I wondered what that was at first as well but @Ace 1 said its a form of a watermark

Valoish
Forumember

Female Posts : 115
Reputation : 25
Language : English
Location : NYC

http://www.canvasforums.com

Back to top Go down

Re: SyncEditor - A New Way to Post

Post by YoshiGM on October 22nd 2016, 7:46 pm

Nice Work Ace 1.
I prefer do not change the editor, because i like the Sceditor.

@SLGray Yup, me too.

YoshiGM
Forumember

Male Posts : 533
Reputation : 80
Language : Spanish & English
Location : Mexico

http://asistencia.foroactivo.com/u21373

Back to top Go down

Re: SyncEditor - A New Way to Post

Post by Ace 1 on October 22nd 2016, 9:06 pm

Oh, @YoshiGM I should've clarified that it doesn't change the SCEditor. It just shows a live preview as you type.

Ace 1
Helper
Helper

Male Posts : 767
Reputation : 51
Language : English - French?
Location : Druid Hill Park

http://help.forumotion.com

Back to top Go down

Re: SyncEditor - A New Way to Post

Post by Ace 1 on October 31st 2016, 6:44 pm

Update

Smilies have been enabled.

Ace 1
Helper
Helper

Male Posts : 767
Reputation : 51
Language : English - French?
Location : Druid Hill Park

http://help.forumotion.com

Back to top Go down

Re: SyncEditor - A New Way to Post

Post by Flappypaddles on October 31st 2016, 7:18 pm

@Ace 1 wrote:If you've used StackOverflow before, then you know that they have a simplified version of the SCEditor that Forumotion uses. However, their editor shows a preview of the post as the user types.

With this plugin, that feature is now available on Forumotion!

Installation


Administration Panel > Modules > HTML & Javascript > Javascript codes management > Create new javascript (make sure Javascripts are enabled on your forum)

Title: SyncEditor
Placement: In all the pages

Code:

Code:
$(function() {
    'SyncEditor Version v0.2 2016';
    'Developed by Ace 1';
    'All rights reserved.';

    var select_code = true,
          preview_button_on = false;

    if ((/\/t\d+/.test(window.location.href) || /\/(post|(post\?(f|t|p)=\d+&mode=(newtopic|reply|quote|editpost)))/.test(window.location.href)) && $.sceditor) {

        if (!$('#preview .content').html() && $.sceditor) {
            var preview,

                version = $('.bodylinewidth')[0] ? 0 : document.getElementById('wrap') ? 1 : $('div.pun')[0] ? 2 : document.getElementById('ipbwrapper') ? 3 : '',

                simplePreview = [
                    '<table class="forumline preview" width="100%" border="0" cellspacing="1" cellpadding="4"><tbody><tr><th class="thHead" height="25">Preview</th></tr><tr><td class="row1"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tbody><tr><td><div class="postbody"></div></td></tr></tbody></table></td></tr><tr><td class="spaceRow" height="1"></td></tr></tbody></table><br clear="all">',
                    '<div id="preview" class="post row2"><div class="h3">Preview</div><div class="content"></div></div>',
                    '<div class="main-head clearfix preview"><p class="h2">Preview</p></div><div class="main-content topic" style="text-align: left;"><div class="post"><div class="posthead"><h2>This is how your post will appear once submitted.</h2></div><div class="postbody"><div class="post-entry"><div class="entry-content"></div></div></div></div></div>',
                    '<div id="preview" class="post borderwrap" style="background-color: #e4e6e9"><div class="maintitle clearfix"><h3>Preview</h3></div><div class="post-entry row1"></div></div>'
                ][version],

                createSimplePreview = function() {
                    version == 0 // PHPBB2
                        ? $('form[action="/viewforum"]').before(simplePreview)
                        : (
                          version == 1 // PHPBB3
                            ? $('#quick_reply').after(simplePreview)
                            : (
                              version == 2 // PUNBB
                                ? $('#quick_reply').append(simplePreview)
                                : (
                                    version == 3 // INVISION
                                    ? $('#qpost').after(simplePreview)
                                    : ''
                                )
                            )
                        )
                },

                advancedPreview = [
                    '<table class="forumline preview" width="100%" border="0" cellspacing="1" cellpadding="4"><tbody><tr><th class="thHead" height="25">Preview</th></tr><tr><td class="row1"><span class="postdetails"><img src="https://illiweb.com/fa/empty.gif" alt="Post" title="Post" border="0">Subject: <img src="https://illiweb.com/fa/empty.gif" alt="" border="0"><span style="user-select: none !important; color: transparent !important; text-shadow: none !important; background: none !important;"><3</span>' + formatDate() + '</span></td></tr><tr><td class="row1"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tbody><tr><td><div class="postbody"></div></td></tr></tbody></table></td></tr><tr><td class="spaceRow" height="1"><img src="http://illiweb.com/fa/empty.gif" height="1" width="1" alt=""></td></tr></tbody></table><br clear="all">',
                    '<div id="preview" class="post row2"><div class="inner"><span class="corners-top"><span></span></span><div class="postbody"><div class="h3">Preview</div><div class="content"></div></div><span class="corners-bottom"><span></span></span></div></div>',
                    '<div class="main-head clearfix preview"><p class="h2">Preview</p></div><div class="main-content topic"><div class="post"><div class="postmain"><div class="posthead"><h2>This is how your post will appear once submitted.</h2></div><div class="postbody"><div class="user"><h4 class="user-ident"><span class="username">' + _userdata.username + '</span></h4></div><div class="post-entry"><div class="entry-content"></div></div></div></div></div></div>',
                    '<div id="preview" class="post borderwrap"><div class="maintitle clearfix"><h3>Preview</h3></div><div class="postbody"><div class="post-entry row1"></div></div></div>'
                ][version],

                createAdvancedPreview = function() {
                    version == 0 // PHPBB2
                        ? $('form[action="/post"]').before(advancedPreview)
                        : (
                          version == 1 // PHPBB3
                            ? $('h1.page-title').after(advancedPreview)
                            : (
                              version == 2 // PUNBB
                                ? $('form.frm-form').prepend(advancedPreview)
                                : (
                                  version == 3 // INVISION
                                    ? $('ul#navstrip').after(advancedPreview)
                                    : ''
                                )
                            )
                        )
                },

                actualContainer = [
                    '.preview .row1 table .postbody',
                    '#preview .content',
                    'form.frm-form .entry-content',
                    '#preview .post-entry'
                ][version];

            if ( version == 0 && document.forms.post.subject ) {
                document.forms.post.subject.oninput = function() {
                    var v = this.value;
                    $('span.postdetails').eq(0).contents().filter(function() {return this.nodeType == 3})[0].textContent = 'Subject: ' + (v == 'undefined' ? '' : v);
                };
            }

            function formatDate() {
                var d = Date(),
                    y = new Date().getFullYear(),
                    m = new Date().getMinutes(),
                    s = new Date().getSeconds(),
                    n = d.indexOf(m + ':' + s),
                    realDate = d.substring(0, n + 5);
                realDate = realDate.slice(0, realDate.indexOf(y) + 4) + " - " + realDate.slice(realDate.indexOf(y) + 5);
                return realDate;
            }

            /\/t\d+/.test(window.location.href)
                ? createSimplePreview()
                : /\/(post|(post\?(f|t|p)=\d+&mode=(newtopic|reply|quote|editpost)))/.test(window.location.href) ? createAdvancedPreview() : '';
        }

        $('#text_editor_textarea').ready(function() {
            var instance = $('#text_editor_textarea').sceditor('instance'),

                sceditorContent, previewContent,

                convert = function() {
                    sceditorContent = instance.val();
                    previewContent = instance.fromBBCode(sceditorContent, false);
                    $(actualContainer).html(previewContent);

                    // Smilies
                    var s, s2, re;

                    for ( s in smileys ) {
                      if ( /\W/.test(s.replace(':', '')) )  s2 = s.replace(/(.{1})/g, '\\$1');
                      else s2 = s;
                      re = new RegExp(s2, 'gi');
                      $(actualContainer).html($(actualContainer).html().replace(re, '<img src="' + smileys[s] + '" />'));
                    }

                    // Quote
                    $.sceditor.plugins.bbcode.bbcode.set('quote', {
                        tags: {
                            'div': {
                                'class': ['quote']
                            }
                        },
                        format: '[quote]{0}[/quote]',
                        html: function(token, attrs, content) {
                            var a = attrs.defaultattr,
                                c = content,
                                cite = true,
                                citation = function(author) {
                                    // author = '<a>' + author + '</a>';
                                    var wrapping = ( version == 0 ? '<dt><span class="genmed"><b>' + author + ' wrote:</b></span></dt>' : '<cite>' + author + ' wrote:</cite>');
                                    return wrapping;
                                };
                            if (a == undefined || a == '' || a == '"') cite = false;
                            if (a.charAt(0) == '"') a = a.replace(/"/, '');
                            if ( version == 0 ) c = (cite ? citation(a) : '') + '<dd class="quote">' + c + '</dd>';
                            else c = '<div>' + (cite ? citation(a) : '') + c + '</div>';

                            return ( version == 0 ? '<dl class="codebox">' + c + '</dl>' : '<blockquote>' + c + '</blockquote>' );
                        }
                    });

                    // Code
                    $.sceditor.plugins.bbcode.bbcode.set('code', {
                        tags: {
                            'div': {
                                'class': ['code']
                            }
                        },
                        // allowedChildren: ['#'],
                        format: '[code]{0}[/code]',
                        html: function(token, attrs, content) {
                            var c = content,
                                selection = '<span onclick="selectCode(this)" class="selectCode">Select Content</span>',
                                title = 'Code:' + (select_code ? selection : '');
                            if ( version == 0 ) c = '<dt><span class="genmed"><b>' + title + '</b></span></dt><dd class="code"><div class="cont_code">' + c + '</div></dd>';
                            else c = '<dt>' + title + '</dt><dd><code>' + c + '</code></dd>';

                            return '<dl class="codebox">' + c + '</dl>';
                        }
                    });

                    // Spoiler
                    $.sceditor.plugins.bbcode.bbcode.set('spoiler', {
                        tags: {
                            'div': {
                                'class': ['spoiler']
                            }
                        },
                        format: '[spoiler]{0}[/spoiler]',
                        html: function(token, attrs, content) {
                            var a = attrs.defaultattr,
                                c = content;
                            if (a == undefined || a == '' || a == '"') a = 'Spoiler';
                            if (a.charAt(0) == '"') a = a.replace(/"/, '');

                            if ( version == 0 ) c = '<dt style="cursor: pointer;">' + a + ':</dt><dd class="spoiler_closed">&nbsp;</dd><dd><div class="spoiler_content hidden">' + c + '</div></dd>';                             
                            else c = '<dt style="cursor: pointer;">' + a + ':</dt><dd><div class="spoiler_content">' + c + '</div></dd>';

                            return '<dl class="codebox spoiler">' + c + '</dl>';
                        }
                    });

                    if ( version == 0 || version == 2 ) {
                        // Headings For PHPBB2 && PunBB
                        $.sceditor.plugins.bbcode.bbcode.set('h2', {format: '[h2]{0}[/h2]',html: '<h2 class="post-content">{0}</h2>'});
                        $.sceditor.plugins.bbcode.bbcode.set('h3', {format: '[h3]{0}[/h3]',html: '<h3 class="post-content">{0}</h3>'});
                        $.sceditor.plugins.bbcode.bbcode.set('h4', {format: '[h4]{0}[/h4]',html: '<h4 class="post-content">{0}</h4>'});
                    }

                    // Scroll
                    $.sceditor.plugins.bbcode.bbcode.set('scroll', {
                        tags: {
                            'div': {
                                'class': ['scroll']
                            }
                        },
                        format: '[scroll]{0}[/scroll]',
                        html: function(token, attrs, content) {
                            var c = content;
                            c = '<marquee>' + c + '</marquee>';

                            return '<span>' + c + '</span>';
                        }
                    });

                    // Updown
                    $.sceditor.plugins.bbcode.bbcode.set('updown', {
                        tags: {
                            'div': {
                                'class': ['updown']
                            }
                        },
                        format: '[updown]{0}[/updown]',
                        html: function(token, attrs, content) {
                            var c = content;
                            c = '<marquee direction="up" scrollamount="1" style="height: 60px;">' + c + '</marquee>';

                            return '<span>' + c + '</span>';
                        }
                    });
                };

            /\/(post|(post\?(f|t|p)=\d+&mode=(newtopic|reply|quote|editpost)))/.test(window.location.href) ? convert() : '';

            instance.bind('focus blur keydown keyup nodechanged', function() {convert(); });

            $('.sceditor-button').click(function() {
                convert();
                $('.sceditor-dropdown div input.button').add('.sceditor-header-picker *').add('.sceditor-dropdown a.sceditor-fontsize-option').add('.sceditor-dropdown a.sceditor-fontsize-option > *').on('click', function() {
                    convert()
                });
                // $('.smiley-element > img').click(function() { setTimeout(convert, 100) });
            });

        });

        !preview_button_on ? $(document.forms.post.preview).remove() : '';
    }
});

Modification


Code:
select_code = false

Change this to
Code:
true
if you have Forumotion's Select Code feature enabled on your forum.

Click here for more information on the Select Code function.

Code:
preview_button_enabled = false

Change this to
Code:
true
if you still want to have a "Preview" button on your forum.

Other Information


On some versions, you may want to add some CSS to style the look of the preview. For example, on PHPBB3, you may want to add this to the CSS Stylesheet (AP > Display > Colors > CSS):

Code:
[name="quickreply"] + .h3 + br + #quick_reply input[type="submit"] { margin-bottom: 25px; }

#quick_reply + #preview { padding: 5px 10px; border-radius: 3px; }
#quick_reply + #preview .h3 { margin: 3px 0; }
#quick_reply + #preview .content { font-size: 1.3em; padding: 1px; }

Other than that, everything else should work out finely. If you have any questions, just ask Wink
SyncEditor
SyncEditor

This is how it looks on PHPBB3:





Note: This is optimized to work on all versions so if there is a bug or if there is a modification you want made personally, just let me know and I'll gladly get it done.

nice addition, but for some reason my preview appears above the text I am typing and not below, is there an easy way to get it below what you are editing?

Flappypaddles
Forumember

Posts : 249
Reputation : 1
Language : english

http://inaflap.forumotion.co.uk

Back to top Go down

Re: SyncEditor - A New Way to Post

Post by Ace 1 on October 31st 2016, 7:34 pm

Hm..

What version are you using? And have you modified the
Code:
viewtopic_body
template?

Ace 1
Helper
Helper

Male Posts : 767
Reputation : 51
Language : English - French?
Location : Druid Hill Park

http://help.forumotion.com

Back to top Go down

Re: SyncEditor - A New Way to Post

Post by Flappypaddles on October 31st 2016, 8:41 pm

@Ace 1 wrote:Hm..

What version are you using? And have you modified the
Code:
viewtopic_body
template?

the version is phpbb3

and it does not look like the viewtopic_body has been altered.

Flappypaddles
Forumember

Posts : 249
Reputation : 1
Language : english

http://inaflap.forumotion.co.uk

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