Sha256: ac469347593eb3b213e534e47a9381adcdd89176dd620102db373a0ac75514e6

Contents?: true

Size: 1.53 KB

Versions: 5

Compression:

Stored size: 1.53 KB

Contents

// Replace any <textarea class="editor"> with a ckeditor widget.
//
// Note: Uses noConflict version of jquery to avoid possible issues with loading ckeditor.
jQuery(function ($) {
    $('textarea.editor').each(function (e) {
        if (editorEnabled()) {
            loadEditor(this.id);
        }
    });
});

function editorEnabled() {
    return $.cookie('editorEnabled') ? $.cookie('editorEnabled') == "true" : true;
}

function disableEditor(id) {
    if (typeof(CKEDITOR) != "undefined" && CKEDITOR.instances[id] != null) {
        $('#' + id).val(CKEDITOR.instances[id].getData()).show();
        CKEDITOR.instances[id].destroy();
        $.cookie('editorEnabled', false, { expires:90, path:'/' });
    }
}

function enableEditor(id) {
    if (typeof(CKEDITOR) != "undefined" && CKEDITOR.instances[id] != null) {
        CKEDITOR.instances[id].setData($('#' + id).val());
        $('#' + id).hide();
        $.cookie('editorEnabled', true, { expires:90, path:'/' });
    }
}

function toggleEditor(id, status) {
    loadEditor(id);
    if (status == 'Simple Text' || status.value == 'disabled') {
        disableEditor(id);
    } else {
        enableEditor(id);
    }
}

function loadEditor(id) {
    if (typeof(CKEDITOR) != "undefined") {
        if (CKEDITOR.instances[id] == null) {
            CKEDITOR.replace(id, { customConfig:'<%= asset_path(Rails.application.config.cms.ckeditor.configuration_file) %>' });
        }
        $.cookie('editorEnabled', true, { expires:90, path:'/' });
        return true;
    } else {
        return false;
    }
}

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
browsercms-4.0.0.alpha app/assets/javascripts/bcms/ckeditor_load.js.erb
browsercms-3.5.7 app/assets/javascripts/bcms/ckeditor_load.js.erb
browsercms-3.5.6 app/assets/javascripts/bcms/ckeditor_load.js.erb
browsercms-3.5.5 app/assets/javascripts/bcms/ckeditor_load.js.erb
browsercms-3.5.4 app/assets/javascripts/bcms/ckeditor_load.js.erb