Bug 20945: (RM follow-up) Escape param_name too
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / includes / wysiwyg-systempreferences.inc
1 [% USE Asset %]
2 [% #Enable tinymce for system preferences %]
3 [% Asset.js("lib/tiny_mce/tiny_mce.js") %]
4 <script>
5
6 [%# Save TinyMCE content and trigger an event on the original element %]
7 function wysiwyg_change (ed){
8     ed.save();
9     var original_textarea = ed.getElement();
10     $(original_textarea).trigger("input");
11 }
12
13 tinyMCE.baseURL = "[% interface %]/lib/tiny_mce";
14 tinyMCE.init({
15     setup : function(ed) {
16         ed.onInit.add(function(editor){
17             [%-
18             #Ideally, it would be nice just to use the "oninput" event, which captures keyboard input, dragging, pasting, etc.
19             #However, it doesn't work in IE when the event listener is for an element which is "contenteditable". Since TinyMCE
20             #uses a "contenteditable" body element in an iframe element, it's never going to fire in IE.
21
22             #We can get around this a bit by using "onkeyup" and "ondragend".
23
24             #"ondragend" occurs after you drag content within the editor. "ondrop" is for when you drag content from outside the
25             #editor but it doesn't "dirty" the editor, which makes it useless, as the editor won't save unless it's dirty.
26             #"onpaste" is useless in this same way.
27
28             #Reference:
29             #https://developer.mozilla.org/en-US/docs/Web/Events/input
30             #https://connect.microsoft.com/IE/feedbackdetail/view/794285
31             -%]
32
33             tinyMCE.dom.Event.bind(editor.getBody(), 'input keyup dragend', function(e){
34                 if (ed.isDirty()){
35                     wysiwyg_change(ed);
36                 }
37             });
38         });
39
40         // Register change when TinyMCE command returns isDirty()
41         ed.onExecCommand.add(function(ed, cmd, ui, val) {
42             if (ed.isDirty()){
43                 wysiwyg_change(ed);
44             }
45         });
46
47     },
48     mode : "specific_textareas",
49     editor_selector : "mce",
50     theme : "advanced",
51     content_css : "[% interface %]/[% theme %]/css/tinymce.css",
52     plugins : "table,save,advhr,advlink,contextmenu,advimage",
53     theme_advanced_buttons1 : "bold,italic,|,cut,copy,paste,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,|,image,link,unlink,anchor,cleanup,help,code,advhr,",
54     theme_advanced_buttons2 : "tablecontrols,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,removeformat,|,visualaid,|,sub,sup,|,charmap|,forecolor,backcolor",
55     theme_advanced_buttons3 : "",
56     theme_advanced_toolbar_location : "top",
57     theme_advanced_toolbar_align : "left",
58     theme_advanced_path_location : "bottom",
59     theme_advanced_resizing : true,
60     apply_source_formatting : true
61 });
62 //]]>
63 </script>