Sha256: 3631fa3dee0ce4898c845a7d4b6855f8537b9d305c4afa0d35c68b15b05b5706

Contents?: true

Size: 1.57 KB

Versions: 8

Compression:

Stored size: 1.57 KB

Contents

if (!RedactorPlugins) var RedactorPlugins = {};

RedactorPlugins.save = function()
{
  return {
    init: function()
    {
      var button = this.button.add('save', 'Save');
      this.button.addCallback(button, this.save.content);

      save_shortcut = $.proxy(function(e){
        var editor_active = this.$editor.hasClass('redactor-editor');

        if (editor_active)
          this.save.content();

        return editor_active;
      }, this);

      $(document).keydown(function(e){
        if ((e.which == '115' || e.which == '83' ) && (e.ctrlKey || e.metaKey))
        {
          if ( save_shortcut() )
          {
            e.preventDefault();

            return false;
          }
        }

        return true;
      });
    },
    content: function() {
      var post_url = '/annex/blocks',
          route = this.$editor.attr('data-route'),
          identifier = this.$editor.attr('data-identifier'),
          html_content = {};

      var callback = $.proxy(function() {
        var $this = this;
        var editor = this.$editor;

        editor.addClass('saved')
          .delay(1000)
          .queue(function(next){
            $(this).removeClass('saved');
            next();
          });

        setTimeout(function(){ $this.core.destroy(); }, 2000);
      }, this);

      html_content[identifier] = this.code.get();

      $.ajax({
        type: 'POST',
        url: post_url,
        data: {
          identifier: identifier,
          route: route,
          content: html_content
        },
        success: callback,
        dataType: 'json'
      });
    }
  };
};

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
annex-cms-0.3.8 app/assets/javascripts/annex/jquery.redactor.save.js
annex-cms-0.3.7 app/assets/javascripts/annex/jquery.redactor.save.js
annex-cms-0.3.6 app/assets/javascripts/annex/jquery.redactor.save.js
annex-cms-0.3.5 app/assets/javascripts/annex/jquery.redactor.save.js
annex-cms-0.3.4 app/assets/javascripts/annex/jquery.redactor.save.js
annex-cms-0.3.2 app/assets/javascripts/annex/jquery.redactor.save.js
annex-cms-0.3.1 app/assets/javascripts/annex/jquery.redactor.save.js
annex-cms-0.3.0 app/assets/javascripts/annex/jquery.redactor.save.js