Sha256: b8c9e0689e2ff0aeab7ef8ce72d6fe7caee0d71f3ab8a603a4773799a98124fc

Contents?: true

Size: 1.63 KB

Versions: 5

Compression:

Stored size: 1.63 KB

Contents

// = require jquery
// = require jquery_ujs

var Editor = function () {
    var editor = {
        contents: {},
        update: function (name) {
            jQuery('#geri-editor-save').removeClass('disabled');
            jQuery('#geri-editor-revert').removeClass('disabled');
            GERI_EDITOR.contents[name] = jQuery('#' + name).html();
            GERI_EDITOR.changed = true
        },
        reset: function () {
            location.reload()
        },
        changed: false
    };
    jQuery('.editable').each(function () {
        elem = jQuery(this);
        editor.contents[elem.attr('id')] = elem.html();
        elem.addClass('highlight')
    });

    jQuery('a').not('.editor-link').click(function (event) {
        if (GERI_EDITOR.changed) {
            var confirmation = confirm('You have not saved your changes, are you sure you want to navigate away from this page?');
            if (!confirmation) {
                event.preventDefault();
            }
        }
    });

    jQuery('#geri-editor-save').click(function (event) {
        event.preventDefault();
        jQuery.post('/admin/editor', {contents: GERI_EDITOR.contents}, function(){
            GERI_EDITOR.reset()
        })
    });

    jQuery('#geri-editor-revert').click(function (event) {
        event.preventDefault();
        var confirmation = confirm('Are you sure you wish to revert your changes?');
        if (confirmation) {
            GERI_EDITOR.reset()
        }
    });
    return editor
};

jQuery(function () {
    jQuery.get('admin/editor.html', function (data) {
        jQuery('body').prepend(data)
        window.GERI_EDITOR = new Editor
    });

});

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
geri-0.1.4 app/assets/javascripts/geri/admin/editor.js
geri-0.1.3 app/assets/javascripts/geri/admin/editor.js
geri-0.1.1 app/assets/javascripts/geri/admin/editor.js
geri-0.1.0 app/assets/javascripts/geri/admin/editor.js
geri-0.0.1 app/assets/javascripts/geri/admin/editor.js