{% comment %}
    Refactor requires you to have the resources referenced below installed under your STATIC_URL.
    You can download them from http://redactorjs.com/
{% endcomment %}

{% load wysiwyg %}
<link rel="stylesheet" type="text/css" href="{{ DJANGO_WYSIWYG_MEDIA_URL }}css/redactor.css"/>
<script type="text/javascript" src="{{ DJANGO_WYSIWYG_MEDIA_URL }}redactor.min.js"></script>
<script type="text/javascript">
    var django_wysiwyg_editor_configs = [];   // allow custom settings per editor ID{% block django_wysiwyg_editor_config %}
    var django_wysiwyg_editor_config = {};
{% endblock %}

    var django_wysiwyg =
    {
        editors: {},

        enable: function django_wysiwyg_enable(editor_name, field_id, config)
        {
            if( !config ) {
                config = django_wysiwyg_editor_configs[field_id] || django_wysiwyg_editor_config;
            }

            if( !this.editors[editor_name] ) {
                this.editors[editor_name] = jQuery("#" + field_id).redactor(config);
            }
        },

        disable: function django_wysiwyg_disable(editor_name)
        {
            var editor = this.editors[editor_name];
            if( editor ) {
                editor.destroyEditor();
                this.editors[editor_name] = null;
            }
        },

        is_loaded: function django_wysiwyg_is_loaded()
        {
            return window.jQuery != null && window.jQuery.fn.redactor != null;
        }
    }
</script>
