Subversion Repositories wimsdev

Rev

Rev 14101 | Rev 15568 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. !! insert this before `!header` : `!read js/external/tinymce.phtml xxxx`
  2. !!  with xxxx pointing to an existing DOM element (a textarea)
  3.  
  4. !if $wims_read_parm!=
  5.  
  6.   !if createxo notin $module
  7.     !set iEdit_plugins=code help hr link lists
  8.     !set iEdit_toolbar=undo redo | formatselect aligncenter | bold italic strikethrough | subscript superscript | hr link | bullist numlist | removeformat | code | help
  9.     !reset iEdit_formats
  10.   !else
  11.     !set iEdit_plugins=code help hr lists
  12.     !set iEdit_toolbar=undo redo | styleselect aligncenter | bold italic strikethrough | subscript superscript | hr link | bullist numlist | removeformat | code | help
  13.     !set iEdit_formats=formats: {\
  14.         /*oef_indgood: { inline: 'span', classes: 'oef_indgood', exact: true },\
  15.         oef_indbad: { inline: 'span', classes: 'oef_indbad', exact: true },\
  16.         oef_indpartial: { inline: 'span', classes: 'oef_indpartial' },\
  17.         oef_indforget: { inline: 'span', classes: 'oef_indforget' },*/\
  18.         aligncenter: { selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'wimscenter' },\
  19.         wims_instruction: { block: 'div', classes: 'wims_instruction'},\
  20.         /*wims_msg_success: { block: 'div', classes: 'wims_msg success'},\
  21.         wims_msg_alert: { block: 'div', classes: 'wims_msg alert'},\
  22.         wims_msg_warning: { block: 'div', classes: 'wims_msg warning'},\
  23.         wims_msg_info: { block: 'div', classes: 'wims_msg info'},\
  24.         wims_msg_help: { block: 'div', classes: 'wims_msg help'},*/\
  25.         wims_difficultylevel: { inline: 'span', classes: 'wims_difficultylevel'},\
  26.         wims_emph: { inline: 'span', classes: 'wims_emph'},\
  27.         wims_smallhelp: { block: 'div', classes: 'wims_smallhelp'},\
  28.         wims_question: { block: 'div', classes: 'wims_question'},\
  29.         wims_color1: { block: 'div', classes: 'wims_color1'},\
  30.         wims_color2: { block: 'div', classes: 'wims_color2'},\
  31.         wims_color3: { block: 'div', classes: 'wims_color3'},\
  32.       },style_formats: [\
  33.       { title: 'Paragraph', format: 'p'},\
  34.       { title: 'Headings', items: [\
  35.         { title: 'Heading 1', format: 'h2' },\
  36.         { title: 'Heading 2', format: 'h3' },\
  37.         { title: 'Heading 3', format: 'h4' },\
  38.         { title: 'Heading 4', format: 'h5' },\
  39.         { title: 'Heading 5', format: 'h6' }\
  40.       ]},\
  41.       /*{ title: 'OEF answers', items: [\
  42.         { title: 'Good answer', format: 'oef_indgood' },\
  43.         { title: 'Bad answer', format: 'oef_indbad' },\
  44.         { title: 'Partial answer', format: 'oef_indpartial' },\
  45.         { title: 'Forgotten answer', format: 'oef_indforget' },\
  46.       ]},\
  47.       { title: 'WIMS Messages', items: [\
  48.         { title: 'Success', format: 'wims_msg_success' },\
  49.         { title: 'Alert', format: 'wims_msg_alert' },\
  50.         { title: 'Warning', format: 'wims_msg_warning' },\
  51.         { title: 'Info', format: 'wims_msg_info' },\
  52.         { title: 'Help', format: 'wims_msg_help' },\
  53.       ]},*/\
  54.       { title: 'Theme colors', items: [\
  55.         { title: 'Color 1', format: 'wims_color1' },\
  56.         { title: 'Color 2', format: 'wims_color2' },\
  57.         { title: 'Color 3', format: 'wims_color3' },\
  58.       ]},\
  59.       { title: 'Other WIMS styles', items: [\
  60.         { title: 'Instructions', format: 'wims_instruction' },\
  61.         { title: 'Exercice highlight', format: 'wims_question' },\
  62.         { title: 'Small help', format: 'wims_smallhelp' },\
  63.         { title: 'Blockquote', format: 'blockquote' },\
  64.         { title: 'Code', format: 'code' },\
  65.         { title: 'Difficulty level', format: 'wims_difficultylevel' },\
  66.         { title: 'Emphase', format: 'wims_emph' },\
  67.       ]},\
  68.     ],
  69.   !endif
  70.  
  71.  
  72.   !let name_WYSIWYG_activate=Activate editor
  73.   !let name_WYSIWYG_disable=Disable editor
  74.   !if $lang=ca
  75.     !set tiny_lang=language: 'ca',
  76.     !let name_WYSIWYG_activate=Activate editor
  77.     !let name_WYSIWYG_disable=Disable editor
  78.   !endif
  79.   !if $lang=cn
  80.     !set tiny_lang=language: 'zh_CN',
  81.     !let name_WYSIWYG_activate=Activate editor
  82.     !let name_WYSIWYG_disable=Disable editor
  83.   !endif
  84.   !if $lang=es
  85.     !set tiny_lang=language: 'es_ES',
  86.     !let name_WYSIWYG_activate=Activate editor
  87.     !let name_WYSIWYG_disable=Disable editor
  88.   !endif
  89.   !if $lang=fr
  90.     !set tiny_lang=language: 'fr_FR',
  91.     !let name_WYSIWYG_activate=Activer l'éditeur
  92.    !let name_WYSIWYG_disable=Désactiver l'éditeur
  93.   !endif
  94.   !if $lang=it
  95.     !set tiny_lang=language: 'it_IT',
  96.     !let name_WYSIWYG_activate=Activate editor
  97.     !let name_WYSIWYG_disable=Disable editor
  98.   !endif
  99.   !if $lang=nl
  100.     !set tiny_lang=language: 'nl',
  101.     !let name_WYSIWYG_activate=Activate editor
  102.     !let name_WYSIWYG_disable=Disable editor
  103.   !endif
  104.   !if $lang=si
  105.     !set tiny_lang=language: 'sl_SI',
  106.     !let name_WYSIWYG_activate=Activate editor
  107.     !let name_WYSIWYG_disable=Disable editor
  108.   !endif
  109.  
  110.  
  111.   !set wims_html_header= !append line <script src="scripts/js/external/tinymce/tinymce.min.js"></script>\
  112.   <style>.hidden_btn{display:none}.wysiwyg_btns{text-align:right;font-size:.6em}</style>\
  113.   <script>\
  114.   document.addEventListener("DOMContentLoaded", function() {\
  115.     /* Insert "enable/disable editor" buttons */\
  116.     var ed_instances = document.querySelectorAll("$wims_read_parm");\
  117.     ed_instances.forEach(function(ed) {\
  118.       if(ed.id){\
  119.         var div = document.createElement('div');\
  120.         div.classList.add('wysiwyg_btns');\
  121.         var a1 = document.createElement('a');\
  122.         var linkText = document.createTextNode("$name_WYSIWYG_disable");\
  123.         a1.appendChild(linkText);\
  124.         a1.setAttribute("onclick","javascript:tinymce.execCommand('mceRemoveEditor',true,'"+ed.id+"');this.classList.add('hidden_btn');this.nextElementSibling.classList.remove('hidden_btn');");\
  125.         div.appendChild(a1);\
  126.         var a2 = document.createElement('a');\
  127.         var linkText = document.createTextNode("$name_WYSIWYG_activate");\
  128.         a2.appendChild(linkText);\
  129.         a2.setAttribute("onclick","javascript:tinymce.execCommand('mceAddEditor',true,'"+ed.id+"');this.classList.add('hidden_btn');this.previousElementSibling.classList.remove('hidden_btn');");\
  130.         a2.classList.add("hidden_btn");\
  131.         div.appendChild(a2);\
  132.         /* insert just after editor */\
  133.         ed.parentNode.insertBefore(div, ed.nextSibling);\
  134.       }\
  135.     });\
  136.     /* Initialize editors */\
  137.     tinymce.init({\
  138.       selector:'$wims_read_parm',\
  139.       plugins: '$iEdit_plugins',\
  140.       block_formats : tinymce.translate('Paragraph')+'=p;' +tinymce.translate('Heading 1')+'=h2;'+tinymce.translate('Heading 2')+'=h3;' +tinymce.translate('Heading 3')+'=h4;' +tinymce.translate('Heading 4')+'=h5;' +tinymce.translate('Heading 5')+'=h6;' +tinymce.translate('Preformatted')+'=pre;' +tinymce.translate('Blockquote')+'=blockquote;',\
  141.       menubar: false,\
  142.       branding: false,\
  143.       toolbar: '$iEdit_toolbar',\
  144.       $tiny_lang\
  145.       $iEdit_formats\
  146.       convert_urls : false,\
  147.       entities : '160,nbsp,162,cent,8364,euro,163,pound',\
  148.       content_css : 'html/themes/$wims_theme/css.css',\
  149.       body_class: 'main_body',\
  150.       content_style : ':root{--wims_bgcolor: $wims_bgcolor;--wims_link_color: $wims_link_color;--wims_vlink_color: $wims_vlink_color;--wims_hlink_color: $wims_hlink_color;--wims_ref_menucolor: $wims_ref_menucolor;--wims_ref_bgcolor: $wims_ref_bgcolor;--wims_ref_button_color: $wims_ref_button_color;--wims_ref_button_bgcolor: $wims_ref_button_bgcolor;}a, .ui-widget-content a{color:$wims_link_color}a:hover, a:focus {color:$wims_hlink_color}table.wimstable th{background-color: $wims_ref_bgcolor;color: $wims_ref_menucolor}table.wimstable th a{color: $wims_ref_menucolor}.wimstable caption a{color: $wims_ref_menucolor}.wims_emph {color:$wims_ref_bgcolor}input[type="submit"],input[type="button"],.main_body .wims_button{background-color:$wims_ref_button_bgcolor;color:$wims_ref_button_color}.main_body .wims_button_help{background-color:$wims_ref_button_help_bgcolor;color:$wims_ref_button_help_color}.property_fields{border-color:$wims_ref_bgcolor}.property_fields legend{background-color: $wims_ref_bgcolor}.property_fields legend,.property_fields legend>a{color:$wims_ref_menucolor}.wims_color1 {background-color: $wims_ref_bgcolor;color:$wims_ref_menucolor}.wims_color2 {background-color:$wims_ref_button_bgcolor;color:$wims_ref_button_color}.wims_color3 {background-color:$wims_ref_button_help_bgcolor;color:$wims_ref_button_help_color}',\
  151.       init_instance_callback: function(editor) {\
  152.         editor.on('PostProcess', function (e) {\
  153.           // Avant d'afficher le code source\
  154.           e.content = e.content.replace("\"$wims_ref_name?cmd=getfile&amp;session=$wims_session&amp;special_parm=oefimg/", "\"\\imagedir/");\
  155.         });\
  156.         editor.on('BeforeSetContent', function (e) {\
  157.           // Lors de l'enregistrement du code source\
  158.           e.content = e.content.replace("\"\\imagedir/", "\"$wims_ref_name?cmd=getfile&session=$wims_session&special_parm=oefimg/");\
  159.         });\
  160.         // refresh content, searching for 'imagedir'\
  161.         editor.setContent(editor.getContent());\
  162.       }\
  163.     });\
  164.   });</script>\
  165.    to $wims_html_header
  166. !endif
  167.