<script type="text/javascript" src="{{ CKEDITOR_JS_URL }}"></script>

<style type="text/css">
    span.cke_skin_kama { border: none !important; }
    div[id*='cke_id_'], span[id*='cke_id_'] { margin-left: 170px; }
</style>

<script type="text/javascript">
    {% block config %}
    CKEDITOR.config.width = '787';
    CKEDITOR.config.height= '300';
    CKEDITOR.config.format_tags = 'p;h1;h2;h3;h4;pre';
    CKEDITOR.config.toolbar = [
        {% block toolbar %}['Maximize','-','Format','-','Bold','Italic','Underline','Strike','-','Subscript','Superscript','-','NumberedList','BulletedList','-','Anchor', 'Link','Unlink','-','Source']{% endblock %}
    ];
    {% endblock %}

    (function($){
        function feincms_richtext_remove_ckeditor(field) {
            var id = field ? field.id : this.id;
            if (id in CKEDITOR.instances) {
                CKEDITOR.instances[id].destroy();
            }
        }

        function feincms_richtext_add_ckeditor(field) {
            var id = field ? field.id : this.id;
            if (!(id in CKEDITOR.instances)) {
                CKEDITOR.replace(id);
            }
        }
        contentblock_init_handlers.push(function(){
            $('.order-machine textarea.item-richtext').each(function(){
                feincms_richtext_add_ckeditor(this);
            });

            contentblock_move_handlers.poorify.push(function(item) {
                item.find('textarea.item-richtext').each(feincms_richtext_remove_ckeditor);
            });
            contentblock_move_handlers.richify.push(function(item) {
                item.find('textarea.item-richtext').each(feincms_richtext_add_ckeditor);
            });
        });
    })(feincms.jQuery);
</script>
