Sha256: 65e3e168cd1c1b299f2d4011c75b0735b90ac72391fd6ea5fa646d658f654728
Contents?: true
Size: 1.51 KB
Versions: 3
Compression:
Stored size: 1.51 KB
Contents
(function($) { CKEDITOR.disableAutoInline = true; var setupMicroCms = function() { for (var instance in CKEDITOR.instances) { if (!CKEDITOR.instances.hasOwnProperty(instance)) { break; } CKEDITOR.instances[instance].on('blur', function(event) { event.editor.updateElement(); var element = event.editor.element.$; var updateUrl = element.getAttribute('data-update-url'); var authorizationToken = element.getAttribute('data-authorization-token'); window.e = event; var data = new FormData(); data.append('micro_cms_content_block[content]', event.editor.getData()); data.append('micro_cms_content_block[authorization_token]', authorizationToken); function blink(className) { $(element).addClass(className); setTimeout(function () { $(element).removeClass(className); }, 1000); } Rails.ajax({ type: 'PATCH', url: updateUrl, dataType: 'json', contentType: 'multipart/form-data', data: data, beforeSend: function() { return true; }, success: function(e) { blink('successful'); }, error: function(e) { console.error(e); blink('error'); }, }) }); } }; window.addEventListener('load', setupMicroCms); if ('Turbolinks' in window && Turbolinks.supported) { $(document).on('turbolinks:load', setupMicroCms); } })(jQuery);
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
micro_cms-0.2.0 | app/assets/javascripts/micro_cms.js |
micro_cms-0.1.2 | app/assets/javascripts/micro_cms.js |
micro_cms-0.1.1 | app/assets/javascripts/micro_cms.js |