Sha256: c1297ec92c419bd086136a6cd317f6a858aba60fcda2c7f457fa74ef4920e7a2
Contents?: true
Size: 1.49 KB
Versions: 5
Compression:
Stored size: 1.49 KB
Contents
if (!RedactorPlugins) var RedactorPlugins = {}; RedactorPlugins.save = { init: function() { this.buttonAdd('save', 'Save', function(){ this.saveContent(); }); this.buttonAddSeparator(); this.buttonSetRight('save'); save_shortcut = $.proxy(function(e){ var editor_active = this.getEditor().hasClass('redactor_editor'); if ( editor_active ) this.saveContent(); 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; }); }, saveContent: function() { var post_url = '/annex/blocks', route = this.getEditor().attr('data-route'), identifier = this.getEditor().attr('data-identifier'), html_content = {}; var callback = $.proxy(function() { var $this = this; var editor = this.getEditor(); editor.addClass('saved') .delay(1000) .queue(function(next){ $(this).removeClass('saved'); next(); }); setTimeout(function(){ $this.destroy(); }, 2000); }, this); html_content[identifier] = this.get(); $.ajax({ type: 'POST', url: post_url, data: { route: route, content: html_content }, success: callback, dataType: 'json' }); } };
Version data entries
5 entries across 5 versions & 1 rubygems