how i can get more headers ? Hitskin_logo Hitskin.com

This is a Hitskin.com skin preview
Install the skinReturn to the skin page

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.
2 posters

    how i can get more headers ?

    coolkool
    coolkool
    Forumember


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

    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]
    Ange Tuteur
    Ange Tuteur
    Forumaster


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

    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>');
        }
      }
    });
    coolkool
    coolkool
    Forumember


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

    Solved Re: how i can get more headers ?

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

    thanks it's work ^.^
    Ange Tuteur
    Ange Tuteur
    Forumaster


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

    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