Add icon button

This example shows how to add the font awesome icon to the button.

Code

<!--element -->
<textarea id="content"></textarea>

<!-- plugin code -->
<script>
(function($R)
{
    $R.add('plugin', 'mybutton', {
        translations: {
            en: {
                "mybutton": "My Button"
            }
        },
        init: function(app)
        {
            this.app = app;
            this.lang = app.lang;
            this.toolbar = app.toolbar;
        },
        start: function()
        {
            // create the button data
            var buttonData = {
                title: this.lang.get('mybutton'),
                icon: '<i class="fa fa-superpowers"></i>',
                api: 'plugin.mybutton.toggle'
            };

            // create the button
            var $button = this.toolbar.addButton('mybutton', buttonData);
        },
        toggle: function()
        {
            alert('My Button is toggled!');
        }
    });
})(Redactor);
</script>

<!-- call -->
<script>
$R('#content', { plugins: ['mybutton'] });
</script>