Newer
Older
dmpopidor / lib / assets / javascripts / views / org_admin / templates / new.js
@briley briley on 23 May 2018 547 bytes Template Versioning
import { Tinymce } from '../../../utils/tinymce';
import { enableValidations, validate } from '../../../utils/validation';
import { eachLinks } from '../../../utils/links';

$(() => {
  Tinymce.init({ selector: '.template' });
  enableValidations($('.new_template'));
  $('.new_template').on('submit', (e) => {
    const links = {};
    eachLinks((ctx, value) => {
      links[ctx] = value;
    }).done(() => {
      $('#template-links').val(JSON.stringify(links));
    });
    if (!validate(e.target)) {
      e.preventDefault();
    }
  });
});