6 [% PROCESS 'i18n.inc' %]
8 [% INCLUDE 'doc-head-open.inc' %]
9 [% BLOCK page_heading %]
10 [% IF additional_content.id %]
11 [% IF category == 'news' %]
12 [% t("Modify news item") | html %]
13 [% ELSIF category == 'pages' %]
14 [% t("Modify page") | html %]
16 [% t("Modify HTML customization") | html %]
19 [% IF category == 'news' %]
20 [% t("New news item") | html %]
21 [% ELSIF category == 'pages' %]
22 [% t("New page") | html %]
24 [% t("New HTML customization") | html %]
28 [% BLOCK page_section %]
29 [% IF category == 'news' %]
30 [% t("News") | html %]
31 [% ELSIF category == 'pages' %]
32 [% t("Pages") | html %]
34 [% t("HTML customizations") | html %]
37 <title>[% FILTER collapse %]
38 [% IF op == 'add_form' %]
39 [% PROCESS page_heading %] ›
41 [% PROCESS page_section %] ›
42 [% t("Additional content") | html %] ›
43 [% t("Tools") | html %] ›
44 [% t("Koha") | html %]
46 [% INCLUDE 'doc-head-close.inc' %]
48 [% SET editmode = "wysiwyg" %]
50 [% SET editmode = "text" %]
51 [% Asset.css("lib/codemirror/codemirror.css") | $raw %]
52 [% Asset.css("lib/codemirror/lint.min.css") | $raw %]
61 .syspref-link::before {
64 .customization-link::before {
67 .customization-link:first-child::before {
71 label[for^="content_"] {
80 <body id="tools_additional-contents" class="tools">
81 [% WRAPPER 'header.inc' %]
82 [% INCLUDE 'cat-search.inc' %]
85 [% WRAPPER 'sub-header.inc' %]
86 [% WRAPPER breadcrumbs %]
87 [% WRAPPER breadcrumb_item %]
88 <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
90 [% WRAPPER breadcrumb_item %]
91 <a href="/cgi-bin/koha/tools/additional-contents.pl">Additional content</a>
93 [% IF op == 'add_form' %]
94 [% WRAPPER breadcrumb_item %]
95 [% IF category == 'news' %]
96 <a href="/cgi-bin/koha/tools/additional-contents.pl?category=news">News</a>
97 [% ELSIF category == 'pages' %]
98 <a href="/cgi-bin/koha/tools/additional-contents.pl?category=pages">Pages</a>
100 <a href="/cgi-bin/koha/tools/additional-contents.pl?category=html_customizations">HTML customizations</a>
103 [% WRAPPER breadcrumb_item bc_active= 1 %]
104 [% PROCESS page_heading %]
107 [% WRAPPER breadcrumb_item bc_active= 1 %]
108 [% PROCESS page_section %]
111 [% END #/ WRAPPER breadcrumbs %]
112 [% END #/ WRAPPER sub-header.inc %]
114 [% IF op == 'add_form' %]
115 <div class="main container-fluid">
117 <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
119 <div class="main container-fluid">
121 <div class="col-sm-10 col-sm-push-2">
126 [% FOR m IN messages %]
127 <div class="dialog [% m.type | html %]">
129 [% CASE 'error_on_update' %]
130 <span>An error occurred when updating this content. Perhaps it already exists</span>
131 [% CASE 'error_on_insert' %]
132 <span>An error occurred when adding this content. Check the logs</span>
133 [% CASE 'error_on_delete' %]
134 <span>An error occurred when deleting this content. Check the logs</span>
135 [% CASE 'success_on_update' %]
136 <span>Content updated successfully</span>
137 [% CASE 'success_on_insert' %]
138 <span>Content added successfully</span>
139 [% CASE 'success_on_delete' %]
140 <span>Content deleted successfully</span>
142 <span>[% m.code | html %]</span>
147 [% IF op == 'add_form' %]
148 [% PROCESS add_form %]
155 [% IF op != 'add_form' %]
156 </div> <!-- /.col-sm-10.col-sm-push-2 -->
158 <div class="col-sm-2 col-sm-pull-10">
161 <div id="news-filter">
162 <form action="/cgi-bin/koha/tools/additional-contents.pl" method="get">
164 <fieldset class="brief">
167 <label for="news_keyword">Keyword:</label>
168 <input type="text" name="news_keyword" id="news_keyword" />
171 <label for="news_display_location">Display location:</label>
172 <select name="news_display_location" id="news_display_location">
173 <option value="">All</option>
174 [% PROCESS locations_options category => category %]
178 <label for="news_library">Library: </label>
179 <select id="news_library" name="news_library">
180 <option value=""></option>
181 <option value="">All libraries</option>
182 [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode, unfiltered => 1, ) %]
187 <input type="checkbox" name="show_expired" id="show_expired" /> Show expired
195 [% INCLUDE 'tools-menu.inc' %]
197 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
199 </div> <!-- /.row -->
200 </div> <!-- /.main.container-fluid -->
203 <h1>[% PROCESS page_heading %]</h1>
205 <div id="toolbar" class="btn-toolbar">
206 <div class="btn-group">
207 <button class="btn btn-primary" id="submit_form"><i class="fa fa-save"></i> Save</button>
208 <button class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
209 <span class="caret"></span>
211 <ul class="dropdown-menu">
212 <li><a id="saveandcontinue" href="#">Save and continue editing</a></li>
215 [% IF category == 'news' %]
216 <a class="btn btn-default cancel" href="/cgi-bin/koha/tools/additional-contents.pl"><i class="fa fa-times"></i> Cancel</a>
217 [% ELSIF category == 'pages' %]
218 <a class="btn btn-default cancel" href="/cgi-bin/koha/tools/additional-contents.pl?category=pages"><i class="fa fa-times"></i> Cancel</a>
220 <a class="btn btn-default cancel" href="/cgi-bin/koha/tools/additional-contents.pl?category=html_customizations"><i class="fa fa-times"></i> Cancel</a>
224 <form id="add_additional_content" method="post" action="/cgi-bin/koha/tools/additional-contents.pl" class="validate">
225 [% INCLUDE 'csrf-token.inc' %]
226 <input type="hidden" name="op" value="add_validate" />
227 <input type="hidden" name="category" value="[% category | html %]" />
228 <input type="hidden" name="code" value="[% additional_content.code | html %]" />
229 <input type="hidden" name="id" value="[% additional_content.id | html %]" />
230 <input type="hidden" id="redirect" name="redirect" value="" />
231 <input type="hidden" id="editmode" name="editmode" value="[% editmode | html %]" />
232 <fieldset class="rows">
235 <label for="location">Display location:</label>
236 <select id="location" name="location">
237 [% PROCESS locations_options location => additional_content.location %]
239 [% INCLUDE 'html-customization-help.inc' %]
242 <label for="branchcode">Library: </label>
243 <select id="branchcode" name="branchcode">
244 [% IF additional_content.branchcode == '' %]
245 <option value="" selected="selected">All libraries</option>
247 <option value="">All libraries</option>
249 [% PROCESS options_for_libraries libraries => Branches.all( selected => additional_content.branchcode, unfiltered => 1, ) %]
252 [% UNLESS languages.size %]
254 [% IF category == 'news' %]
255 <label for="title" class="required">Title: </label>
256 <input id="title" size="100" maxlength="250" type="text" name="title_default" value="[% additional_content.title | html %]" required="required" class="required" /> <span class="required">Required</span>
258 <label for="title">Title: </label>
259 <input id="title" size="100" maxlength="250" type="text" name="title_default" value="[% additional_content.title | html %]" />
264 <label for="from">Publication date: </label>
265 <input id="from" type="text" name="published_on" size="15" value="[% additional_content.published_on | html %]" class="flatpickr" data-date_to="to" />
266 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
269 <label for="to">Expiration date: </label>
270 <input id="to" type="text" name="expirationdate" size="15" value="[% additional_content.expirationdate | html %]" class="flatpickr" />
272 [% INCLUDE 'date-format.inc' %]
273 [% IF category == 'news' %]
274 <br>News will still be accessible by direct URL if expired.
278 [% UNLESS category == 'pages' %]
280 <label for="number">Appear in position: </label>
281 [% IF ( additional_content.number ) %]
282 <input id="number" size="3" name="number" type="text" value="[% additional_content.number | html %]" />
284 <input id="number" size="3" name="number" type="text" />
291 <hr aria-hidden="true" />
293 [% IF languages.size %]
294 [% WRAPPER tabs id= "tabs" %]
295 [% WRAPPER tabs_nav %]
296 [% FOR language IN languages %]
297 [% IF language.lang == 'default' %]
298 [% WRAPPER tab_item tabname= "lang_default" %] <span>Default</span> [% END %]
300 [% WRAPPER tab_item tabname= "lang_${language.lang}" %] [% language.description | html %] [% END %]
303 [% END # /WRAPPER tabs_nav %]
305 [% WRAPPER tab_panels %]
306 [% FOR language IN languages %]
307 [% SET translated_content = translated_contents.item(language.lang) %]
308 [% WRAPPER tab_panel tabname="lang_${language.lang}" %]
312 <label for="title_[% language.lang | html %]">Title: </label>
313 <input id="title_[% language.lang| html %]" size="100" maxlength="250" type="text" name="title_[% language.lang | html %]" value="[% translated_content.title | html %]">
316 <label for="content_[% language.lang | html %]">Content: </label>
317 <textarea name="content_[% language.lang | html %]" id="content_[% language.lang | html %]" data-lang="[% language.lang | html%]" cols="75" rows="10">[% translated_content.content | html %]</textarea>
318 <input type="hidden" name="id_[% language.lang | html %]" value="[% translated_content.id | html %]" />
319 <input type="hidden" name="lang" value="[% language.lang | html %]" />
323 [% END # /WRAPPER tab_panel#lang %]
324 [% END # /FOR language %]
325 [% END # /WRAPPER tab_panels %]
326 [% END # /WRAPPER tabs %]
328 <div id="lang_default">
329 <div class="clearfix">
330 <textarea name="content" id="content_default" data-lang="[% language.lang | html %]" cols="75" rows="10">[% additional_content.content | html %]</textarea>
333 [% END # /IF languages.size %]
339 <div id="toolbar" class="btn-toolbar">
340 <div class="btn-group">
341 <a href="/cgi-bin/koha/tools/additional-contents.pl?op=add_form&category=[% category | uri %]&editmode=[% editmode | uri %]" class="btn btn-default" id="newentry"> <i class="fa fa-plus"></i> New entry</a><button class="btn btn-default dropdown-toggle" data-toggle="dropdown">
342 <span class="caret"></span>
344 <ul class="dropdown-menu pull-right">
347 <a href="/cgi-bin/koha/tools/additional-contents.pl?op=add_form&category=[% category | uri %]&editmode=text">New entry using text editor</a>
349 <a href="/cgi-bin/koha/tools/additional-contents.pl?op=add_form&category=[% category | uri %]&editmode=wysiwyg">New entry using WYSIWYG editor</a>
358 [% IF category == 'news' %]
359 [% t("News") | html %]
360 [% ELSIF category == 'pages' %]
361 [% t("Pages") | html %]
363 [% t("HTML customizations") | html %]
366 <span id="additional_contents_links">
368 <a class="customization-link" href="/cgi-bin/koha/tools/additional-contents.pl?category=news">News</a>
369 <a class="customization-link" href="/cgi-bin/koha/tools/additional-contents.pl?category=html_customizations">HTML customizations</a>
370 <a class="customization-link" href="/cgi-bin/koha/tools/additional-contents.pl?category=pages">Pages</a>
371 [% IF ( CAN_user_parameters_manage_sysprefs ) %]
372 <a class="syspref-link" href='/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=OPACUserJS'>OPACUserJS</a>
373 <a class="syspref-link" href='/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=OPACUserCSS'>OPACUserCSS</a>
377 [% IF additional_contents.count %]
378 <div class="page-section">
379 <form id="del_form" method="post" action="/cgi-bin/koha/tools/additional-contents.pl">
380 <table id="table_additional_contents">
383 <th class="NoSort"> </th>
387 <th>Publication date</th>
388 <th>Expiration date</th>
389 <th class="anti-the">Title</th>
391 [% IF category == 'pages' %]
393 <th class="anti-the">Page</th>
395 <th class="anti-the">News</th>
397 <th class="NoSort noExport">Actions</th>
401 [% FOREACH c IN additional_contents%]
402 [% SET default_localization = c.default_localization %]
403 [% IF ( c.is_expired ) %]<tr class="expired">[% ELSE %]<tr>[% END %]
405 <input type="checkbox" name="ids" value="[% c.id | html %]" />
408 [% IF c.category == 'news' || c.category == 'pages' %]
409 [% IF c.location == 'staff_and_opac' %]<span>All</span>
410 [% ELSIF c.location == 'staff_only' %]<span>Staff interface</span>
411 [% ELSIF c.location == 'opac_only' %]<span>OPAC</span>
412 [% ELSIF c.location == 'slip' %]<span>Slip</span>
413 [% ELSE %]<span>Unknown ('[% location | html %]')</span>
416 [% c.location | html %]
420 [% IF ( c.branchcode == "" ) -%]
422 [% ELSE %][% c.library.branchname | html %]
425 <td>[% c.number | html %]</td>
426 <td data-order="[% c.published_on | html %]">[% c.published_on | $KohaDates %]</td>
427 <td data-order="[% c.expirationdate | html %]">[% c.expirationdate | $KohaDates %] [% IF ( c.is_expired ) %](<span class="expired">expired</span>)[% END %]</td>
428 <td>[% default_localization.title | html %]</td>
429 <td>[% IF ( c.author) %][% INCLUDE 'patron-title.inc' patron=c.author %][% END %]</td>
430 [% IF category == 'pages' %]
432 [% IF c.location == 'opac_only' OR c.location == 'staff_and_opac' %]
433 <a target="_blank" href="[% Koha.Preference('OPACBaseURL') | url %]/cgi-bin/koha/opac-page.pl?page_id=[% c.id | uri %]" title="View on OPAC"><strong>OPAC</strong></a>
435 [% IF c.location == 'staff_only' OR c.location == 'staff_and_opac' %]
436 [% IF c.location == 'staff_and_opac' %]<br/>[% END %]
437 <a target="_blank" href="/cgi-bin/koha/tools/page.pl?page_id=[% c.id | uri %]" title="View on staff interface"><strong>Staff</strong></a>
442 <div class="btn-group">
443 <a class="preview_news btn btn-default btn-xs" data-number="[% loop.count | html %]"><i class="fa-solid fa-eye" aria-hidden="true"></i> Preview content</a>
445 <div id="contentModal[% loop.count | html %]" class="modal" tabindex="-1" role="dialog" data-number="[% loop.count | html %]">
446 <div class="modal-dialog" role="document">
447 <div class="modal-content modal-lg">
448 <div class="modal-header">
449 <h5 class="modal-title">Preview of: "[% default_localization.title | html %]"</h5>
451 <div class="modal-body">
452 [% default_localization.content | $raw %]
454 <div class="modal-footer">
455 <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
461 <div class="btn-group dropup">
462 <a href="/cgi-bin/koha/tools/additional-contents.pl?op=add_form&id=[% c.id | uri %]&editmode=[% editmode | uri %]" class="btn btn-default btn-xs"> <i class="fa-solid fa-pencil"></i> Edit</a><button class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
463 <span class="caret"></span>
465 <ul class="dropdown-menu pull-right">
468 <a href="/cgi-bin/koha/tools/additional-contents.pl?op=add_form&id=[% c.id | uri %]&editmode=text"><i class="fa-solid fa-pencil"></i> Edit with text editor</a>
470 <a href="/cgi-bin/koha/tools/additional-contents.pl?op=add_form&id=[% c.id | uri %]&editmode=wysiwyg"><i class="fa-solid fa-pencil"></i> Edit with WYSIWYG editor</a>
475 <div class="btn-group">
476 <a href="#" class="delete_news btn btn-default btn-xs" data-id="[% c.id | html %]"><i class="fa fa-trash-can"></i> Delete</a>
483 <input type="hidden" name="op" value="delete_confirmed" />
484 <input type="hidden" name="category" value="[% category | html %]" />
485 <fieldset class="action"><input type="submit" class="btn btn-primary" value="Delete selected" /></fieldset>
487 <form action="/cgi-bin/koha/tools/additional-contents.pl" method="post" id="delete_single">
488 [% INCLUDE 'csrf-token.inc' %]
489 <input type="hidden" id="del_op" name="op" value="delete_confirmed" />
490 <input type="hidden" id="del_category" name="category" value="[% category | html %]" />
491 <input type="hidden" id="del_ids" name="ids" />
493 </div> <!-- /.page-section -->
495 <div class="dialog message">There are no additional contents.</div>
499 [% BLOCK locations_options %]
500 [% IF category == 'news' || category == 'pages' %]
501 [% IF location == "staff_and_opac" %]
502 <option value="staff_and_opac" selected="selected">Staff interface and OPAC</option>
504 <option value="staff_and_opac">Staff interface and OPAC</option>
507 [% IF location == "staff_only" %]
508 <option value="staff_only" selected="selected">Staff interface</option>
510 <option value="staff_only">Staff interface</option>
513 [% IF location == "opac_only" %]
514 <option value="opac_only" selected="selected">OPAC</option>
516 <option value="opac_only">OPAC</option>
519 [% UNLESS category == 'pages' %]
520 [% IF location == "slip" %]
521 <option value="slip" selected="selected">Slip</option>
523 <option value="slip">Slip</option>
527 [% SET opac_available_options = [ 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits', 'OpacLoginInstructions', 'OpacNav', 'OpacNavBottom', 'OpacSuggestionInstructions', 'ArticleRequestsDisclaimerText', 'OpacMoreSearches', 'OpacMySummaryNote', 'OpacLibraryInfo', 'CatalogConcernHelp', 'CatalogConcernTemplate', 'CookieConsentBar', 'CookieConsentPopup' ] %]
528 <optgroup label="OPAC">
529 [% FOREACH l IN opac_available_options.sort %]
530 [% IF l == location %]
531 <option value="[% l | html %]" selected="selected">[% l | html %]</option>
533 <option value="[% l | html %]">[% l | html %]</option>
537 [% SET staff_available_options = [ 'StaffAcquisitionsHome', 'StaffAuthoritiesHome', 'StaffCataloguingHome', 'StaffListsHome', 'StaffPatronsHome', 'StaffPOSHome', 'StaffSerialsHome' ] %]
538 <optgroup label="Staff">
539 [% FOREACH l IN staff_available_options.sort %]
540 [% IF l == location %]
541 <option value="[% l | html %]" selected="selected">[% l | html %]</option>
543 <option value="[% l | html %]">[% l | html %]</option>
550 [% MACRO jsinclude BLOCK %]
551 [% INCLUDE 'calendar.inc' %]
552 [% INCLUDE 'select2.inc' %]
553 [% Asset.js("js/tools-menu.js") | $raw %]
554 [% Asset.js("lib/hc-sticky.js") | $raw %]
556 $("#saveandcontinue").on("click",function(e){
558 $("#redirect").val("just_save");
559 $("#submit_form").click();
562 [% IF additional_contents.count %]
563 [% INCLUDE 'datatables.inc' %]
565 $('.preview_news').click( function() {
566 modalNumber = $(this).attr('data-number');
567 $('.modal[data-number="'+modalNumber+'"]').modal('show');
570 var form = document.getElementById('del_form');
571 var inputs = form.getElementsByTagName('input');
573 for (var i=0; i<inputs.length; i++) {
574 if (inputs[i].type == 'checkbox' && inputs[i].name == 'ids') {
575 checked = inputs[i].checked;
576 if (checked) return true;
581 function filterDataTable( table, column, term ){
583 table.column( column ).search( term ).draw();
585 table.search( term ).draw();
590 function clearFilter( term ){
592 $(".dt_button_clear_filter").addClass("disabled");
594 $(".dt_button_clear_filter").removeClass("disabled");
598 /* Custom table search configuration: If a table row
599 has an "expired" class, hide it UNLESS the
600 show_expired checkbox is checked */
601 $.fn.dataTable.ext.search.push(
602 function( settings, searchData, index, rowData, counter ) {
603 var row = $(settings.aoData[index].nTr);
604 if( row.hasClass("expired") && !$("#show_expired").prop("checked") ){
612 $(document).ready(function() {
614 var table = $("#table_additional_contents").DataTable($.extend(true, {}, dataTablesDefaults, {
615 "order": [[ 4, "desc" ]],
617 { "sortable": false, "searchable": false, 'targets': [ 'NoSort' ] },
618 { "type": "anti-the", "targets": [ "anti-the" ] }
620 "sPaginationType": "full_numbers"
623 $("#del_form").on("click", ".delete_news", function(e){
625 if( confirmDelete( _("Are you sure you want to delete this content? This cannot be undone.") ) ){
626 $("#del_ids").val( $(this).data("id") );
627 $("#delete_single").submit();
631 $("#del_form").on("submit",function(){
633 return confirmDelete( _("Are you sure you want to delete the selected content?") );
635 alert(_("Please select content to delete."));
640 $("#show_expired").on("change", function(){
641 /* redraw the DataTable according to the custom search function */
645 table.on( 'search.dt', function () {
646 var term = table.search();
647 $("#news_keyword").val( term );
650 $("#news_keyword").on("keyup", function(){
651 var term = $(this).val();
652 filterDataTable( table, null, term );
655 $("#news_display_location").on("change", function(){
656 var term = $(this).val();
657 filterDataTable( table, 1, term );
660 $("#news_library").on("change", function(){
661 // Table must be filtered by the <option>'s text, not its value
662 var opt = $(this).find("option:selected").text();
663 filterDataTable( table, 2, opt );
666 $(".dt_button_clear_filter").on("click", function(){
667 table.search('').columns().search('').draw();
668 $("#news-filter select").each(function(){
676 function showLocationNotes( location ){
677 $(".customization_note").hide();
678 $( "#" + location + "_notes" ).show();
681 $(document).ready(function() {
682 [% IF category == 'news' %]
683 $("#add_additional_content").validate({
684 submitHandler: function(form){
685 if ( ! $("#title_default").val().length > 0 ) {
686 alert(_("Please specify a title for 'Default'"));
691 let content = $('#content_default').siblings(".CodeMirror")[0].CodeMirror.getValue();
693 let content = tinyMCE.get('content_default').getContent();
696 if ( ! content.length > 0 ) {
697 alert(_("Please specify a content for 'Default'"));
707 showLocationNotes( $("#location").val() );
709 $("#location").on("change", function(){
710 showLocationNotes( $(this).val() );
713 $("#submit_form").on("click",function(){
714 $("#add_additional_content").submit();
717 Sticky = $("#toolbar");
720 stickyClass: "floating"
722 $("#location").select2({ width: '50%' });
726 [% UNLESS ( wysiwyg ) %]
727 [% Asset.js( "lib/codemirror/codemirror.min.js" ) | $raw %]
728 [% Asset.js( "lib/codemirror/xml.min.js" ) | $raw %]
729 [% Asset.js( "lib/codemirror/lint.min.js" ) | $raw %]
730 [% Asset.js( "lib/linters/htmlhint.min.js" ) | $raw %]
731 [% Asset.js( "lib/codemirror/html-lint.min.js" ) | $raw %]
733 let editors = new Object(); /* Keeps track of initialized CodeMirror instances */
734 $(document).ready(function(){
736 if( $("#tabs .tab-pane.active").length < 1 ){
737 /* Activate first tab and initialize its CodeMirror instance */
738 let firstTab = $("#tabs a:first");
739 firstTab.tab("show");
741 initCodeMirror( firstTab[0].hash );
745 $("#tabs a[data-toggle='tab']").on("shown.bs.tab", function (e) {
746 /* Try to initialize CodeMirror instance when tab opens */
747 initCodeMirror( e.target.hash );
751 function initCodeMirror( container ){
752 /* Initialize CodeMirror instance only if it doesn't exist */
753 if( !editors[ container ] ){
754 let textarea = $( container ).find("textarea[name^='content_']");
755 let this_lang = textarea.attr('data-lang');
756 let editor = CodeMirror.fromTextArea( document.getElementById('content_' + this_lang), {
761 gutters: ["CodeMirror-lint-markers"],
762 viewportMargin: Infinity,
764 editors[ container ] = editor;
770 [% Asset.js("lib/tiny_mce/tinymce.min.js") | $raw %]
771 [% INCLUDE 'str/tinymce_i18n.inc' %]
774 $(document).ready(function(){
775 if( $("#tabs").length > 0 && $("#tabs .tab-pane.active").length < 1 ){
776 /* Activate first tab and initialize its tinyMCE instance */
777 let firstTab = $("#tabs a:first");
778 firstTab.tab("show");
779 initTinyMce( firstTab[0].hash );
782 $("#tabs a[data-toggle='tab']").on("shown.bs.tab", function (e) {
783 /* Try to initialize tinyMCE instance when tab opens */
784 initTinyMce( e.target.hash );
788 function initTinyMce( container ){
789 let textarea = $( container ).find("textarea[name^='content_']");
790 /* TinyMCE seems to do its own check to prevent double-initialization
791 so We don't need to keep track of it */
792 let editor = tinyMCE.init({
794 block_unsupported_drop : false,
795 content_css : "[% interface | html %]/[% theme | html %]/css/tinymce.css",
796 custom_elements:"style,link,~link",
797 extended_valid_elements:"style,link[href|rel]",
798 force_br_newlines : false,
799 force_p_newlines : false,
800 forced_root_block : '',
801 menubar : "file edit view insert format tools table",
802 plugins : "autoresize table hr link image charmap lists code emoticons",
803 autoresize_bottom_margin: 60,
804 relative_urls : false,
805 selector: "#" + textarea[0].id,
808 "formatselect | bold italic | cut copy paste | alignleft aligncenter alignright | outdent indent | image link unlink anchor cleanup hr",
809 "table | bullist numlist | undo redo | removeformat | emoticons charmap | forecolor backcolor | code"
815 [% END # /UNLESS wysiwyg %]
818 [% INCLUDE 'intranet-bottom.inc' %]