SammyLin/redactor-rails

Better rails_admin settings

Opened this issue · 0 comments

<%= form.send :text_area, field.method_name, class: 'redactor' %>
<%= stylesheet_link_tag 'redactor-rails/css/redactor' %>
<%= javascript_include_tag 'redactor-rails/redactor' %>

<script type="text/javascript">
    window.init_redactor = function(){
        var csrf_token = $('meta[name=csrf-token]').attr('content');
        var csrf_param = $('meta[name=csrf-param]').attr('content');
        var params;
        if (csrf_param !== undefined && csrf_token !== undefined) {
            params = csrf_param + "=" + encodeURIComponent(csrf_token);
        }
        $('.redactor').redactor(
                { imageUpload: "/redactor_rails/pictures?" + params,
                    imageGetJson: "/redactor_rails/pictures",
                    fileUpload: "/redactor_rails/documents",
                    path: "/assets/redactor-rails",
                    autoresize: false,
                    fixed: true,
                    toolbarFixedBox: true,
                    minHeight: 400}
        );
    }

    $(document).ready( window.init_redactor );
    $(window).bind('page:change', window.init_redactor);

</script>