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.

how i can get more headers ?

View previous topic View next topic Go down

Solved how i can get more headers ?

Post by coolkool on October 22nd 2015, 9:45 pm

hi 
i want add more headers in the headers button in sceditor

like that : 

H2

h3

H4

[h5]H5[/h5]

coolkool
Forumember

Posts : 116
Reputation : 3
Language : arabic

http://x-gaming.lforum.biz

Back to top Go down

Solved Re: how i can get more headers ?

Post by Ange Tuteur on October 22nd 2015, 9:56 pm

Hi @coolkool,

You could use this JavaScript in all the pages to redefine the header command :
Code:
$(function() {
  if(!$.sceditor) return;
$.sceditor.command.set("headers", {
    // Creates the dropdown for both WYSIWYG and Source modes
    createDropdown: function(editor, callback) {
        var $content = $("<div />");

        for (var i=1; i<= 6; i++) {
            $(
                '<a class="sceditor-header-option" href="#">' +
                    '<h' + i + '>Heading ' + i + '</h' + i + '>' +
                '</a>'
            )
            .data('headersize', i)
            .click(function (e) {
                callback($(this).data('headersize'));

                editor.closeDropDown(true);
                e.preventDefault();
            })
            .appendTo($content);
        }

        return $content;
    },
    // WYSIWYG mode
    exec: function(caller) {
        var editor = this;

        var $content = $.sceditor.command.get("headers").createDropdown(editor, function(size) {
            editor.execCommand("formatblock", "<h" + size + ">");
        });

        editor.createDropDown(caller, "header-picker", $content);
    },
    // Source mode
    txtExec: function(caller) {
        var editor = this;

        var $content = $.sceditor.command.get("headers").createDropdown(editor, function(size) {
            editor.insert('[h' + size + ']', '[/h' + size + ']');
        });

        editor.createDropDown(caller, "header-picker", $content);
    },
    tooltip: "Format Headers"
});
});

Then you'll just need a JavaScript set "in the topics" to parse the tags that weren't parsed server-side.
Code:
$(function() {
  for (var a = $('.postbody'), i = 0, j = a.length; i < j; i++) {
    if (/\[h\d+\].*?\[\/h\d+\]/i.test(a[i].innerHTML)) {
      a[i].innerHTML = a[i].innerHTML.replace(/\[h(\d+)\](.*?)\[\/h\d+\]/ig, '<h$1>$2</h$1>');
    }
  }
});

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: how i can get more headers ?

Post by coolkool on October 22nd 2015, 10:43 pm

thanks it's work ^.^

coolkool
Forumember

Posts : 116
Reputation : 3
Language : arabic

http://x-gaming.lforum.biz

Back to top Go down

Solved Re: how i can get more headers ?

Post by Ange Tuteur on October 22nd 2015, 10:45 pm

You're welcome ^^

Topic archived

Have a great day. Smile

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

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