The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Add Code snippet to the editor

2 posters

Go down

Add Code snippet to the editor Empty Add Code snippet to the editor

Post by Zzbaivong Tue 23 Feb - 7:06

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


Add Code snippet to the editor Inline10

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 Mon 16 May - 10:46; edited 1 time in total
Zzbaivong
Zzbaivong
Forumember

Posts : 101
Reputation : 51
Language : JavaScript ^^

http://devs.forumvi.com

Back to top Go down

Add Code snippet to the editor Empty Re: Add Code snippet to the editor

Post by Abdalah_98 Mon 16 May - 9:35

Not worked to me ?

punbb
Abdalah_98
Abdalah_98
Forumember

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

http://uteach.forum0.net/

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum