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.

Add Code snippet to the editor

View previous topic View next topic Go down

Add Code snippet to the editor

Post by Zzbaivong on February 23rd 2016, 6:06 am

Inspired by the code snippet in help forumotion, I wrote this script, but using font bbcode instead of the table bbcode. This will allow more flexible use, for example, copied bbcode to other forums not available to this script.

Demo



How to set up?


Go to Admin Panel > Modules > JavaScript codes management and create a new script with the following settings:
Title: Code snippet
Placement: In all the pages
Code:
jQuery(function($) {

    'use strict';

    $('head').append($('<style>', {
        text: '.sceditor-button-inline-code div{background-image:url(http://i21.servimg.com/u/f21/18/21/41/30/snippe10.png)!important}.post-entry font[face="monospace"]{color:green;background:#f4f4f4;padding:0 5px;display:inline-block;margin:0 3px;border-radius:2px}'
    }));

    if (!$.sceditor) return;

    $(function() {
        $('#text_editor_textarea').sceditor('instance').css('font[face="monospace"]{color:green;background:#f4f4f4;padding:2px 5px;display:inline-block;margin:-2px 3px;border-radius:2px}');
    });

    function inlineCode(editor) {
        editor.insert('[font=monospace]', '[/font]');
    }

    $.sceditor.command.set('inline-code', {
        exec: function() {
            inlineCode(this);
        },
        txtExec: function() {
            inlineCode(this);
        },
        tooltip: 'Code snippet'
    });

    toolbar = toolbar.replace(/code/, 'code,inline-code');

});
Save the script. Done.


Last edited by Zzbaivong on May 16th 2016, 9:46 am; edited 1 time in total

Zzbaivong
Forumember

Posts : 95
Reputation : 46
Language : JavaScript ^^

http://devs.forumvi.com

Back to top Go down

Re: Add Code snippet to the editor

Post by Abdalah_98 on May 16th 2016, 8:35 am

Not worked to me ?

punbb

Abdalah_98
Forumember

Male Posts : 32
Reputation : 1
Language : EN,AR
Location : Earth :D

http://uteach.forum0.net/

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