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.

how i can get more headers ?

2 posters

Go down

Solved how i can get more headers ?

Post by coolkool 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
coolkool
Forumember

Male Posts : 140
Reputation : 3
Language : Arabic
Location : SA

http://x-gaming.forumakers.com/

Back to top Go down

Solved Re: how i can get more headers ?

Post by Ange Tuteur 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
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: how i can get more headers ?

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

thanks it's work ^.^
coolkool
coolkool
Forumember

Male Posts : 140
Reputation : 3
Language : Arabic
Location : SA

http://x-gaming.forumakers.com/

Back to top Go down

Solved Re: how i can get more headers ?

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

You're welcome ^^

Topic archived

Have a great day. Smile
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Back to top


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