Sha256: 770b7e6a346005eb76d9632db351ca907831999e48f1f3e7aabc11302d8bc38c
Contents?: true
Size: 1.87 KB
Versions: 62
Compression:
Stored size: 1.87 KB
Contents
/** * Handles the content block preview iframe functionality which is updated each * time the related form is updated. * * @namespace WORKAREA.contentEditorForms */ WORKAREA.registerModule('contentEditorForms', (function () { 'use strict'; var updatePreview = function (previewId, response) { $('.content-block__iframe', previewId) .attr('src', WORKAREA.routes.storefront.draftContentBlockPath({ id: response.id })); }, buildParams = function (form, preview) { var params = _.union(form, _.map(preview, function (value, name) { return { name: name, value: value }; })); return _.reduce(params, function (result, value) { if (value.name !== '_method') { result.push(value); } return result; }, []); }, postFormData = _.debounce(function (event) { var $form, previewData, formParams, formData; if ($(event.target).is('[data-publish-with-release-menu]')) { return; } $form = $(event.target).closest('form'), previewData = $form.data('contentEditorForm'), formParams = $form.serializeArray(), formData = buildParams(formParams, previewData.params); $.post(WORKAREA.routes.admin.contentBlockDraftsPath(), formData) .done(_.partial(updatePreview, previewData.previewId)); }, WORKAREA.config.contentEditorForms.previewDebounceValue), /** * @method * @name init * @memberof WORKAREA.contentEditorForms */ init = function ($scope) { $('[data-content-editor-form]', $scope) .on('input change wysiwygs:input', postFormData); }; return { init: init, buildParams: buildParams }; }()));
Version data entries
62 entries across 62 versions & 1 rubygems
Version | Path |
---|---|
workarea-admin-3.4.13 | app/assets/javascripts/workarea/admin/modules/content_editor_forms.js |
workarea-admin-3.4.12 | app/assets/javascripts/workarea/admin/modules/content_editor_forms.js |