(function($) {
    var defaultConfig = {
        lineNumbers: true,
        mode: "django",
        indentUnit: 2
    }

    $(document).on('formset:added', function(event, $row, formsetName) {
        $('.codemirror-editor', $row).each(function(idx, el){
           CodeMirror.fromTextArea(el, defaultConfig);
        });
    });

    $('.module div.form-row .codemirror-editor').each(function(idx, el){
        CodeMirror.fromTextArea(el, defaultConfig);
    });

    $('.inline-group table tr.form-row:not(.empty-form) .codemirror-editor').each(function(idx, el){
        CodeMirror.fromTextArea(el, defaultConfig);
    });

})(django.jQuery);
