diff --git a/app/views/orgs/admin_edit.html.erb b/app/views/orgs/admin_edit.html.erb index 4383cb6..d13180e 100644 --- a/app/views/orgs/admin_edit.html.erb +++ b/app/views/orgs/admin_edit.html.erb @@ -52,10 +52,6 @@ <%= f.label _('Top banner text'), for: @org.banner_text, class: "col-sm-2 control-label" %>
<%= text_area_tag('org_banner_text', @org.banner_text, id: "org_banner_text", class: "form-control") %> -
diff --git a/lib/assets/javascripts/views/orgs/admin_edit.js b/lib/assets/javascripts/views/orgs/admin_edit.js index ec5dd6f..64c3ed3 100644 --- a/lib/assets/javascripts/views/orgs/admin_edit.js +++ b/lib/assets/javascripts/views/orgs/admin_edit.js @@ -1,20 +1,21 @@ // Import TinyMCE import tinymce from 'tinymce/tinymce'; +import { Tinymce } from '../../utils/tinymce'; import ariatiseForm from '../../utils/ariatiseForm'; import { SHOW_ORG_BANNER_MESSAGE } from '../../constants'; -// Returns text statistics for the specified editor by id -function getStats(id) { - const body = tinymce.get(id).getBody(); - const text = tinymce.trim(body.innerText || body.textContent); - return { - chars: text.length, - }; -} - $(() => { ariatiseForm({ selector: '#edit_org_details_form' }); + // Returns text statistics for the specified editor by id + const getStats = (id) => { + const body = tinymce.get(id).getBody(); + const text = tinymce.trim(body.innerText || body.textContent); + return { + chars: text.length, + }; + }; + // Validate banner_text area for less than 165 character $('#edit_org_details_form').on('submit', (e) => { if (getStats('org_banner_text').chars > 165) { @@ -22,4 +23,7 @@ e.preventDefault(); } }); + /* Initialises an editor for textarea defined above with id org_banner_text */ + Tinymce.init({ selector: '#org_banner_text' }); }); +