Subversion Repositories wimsdev

Rev

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

Rev Author Line No. Line
13602 obado 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
 
13722 obado 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: {\
13724 obado 14
        /*oef_indgood: { inline: 'span', classes: 'oef_indgood', exact: true },\
13722 obado 15
        oef_indbad: { inline: 'span', classes: 'oef_indbad', exact: true },\
16
        oef_indpartial: { inline: 'span', classes: 'oef_indpartial' },\
13724 obado 17
        oef_indforget: { inline: 'span', classes: 'oef_indforget' },*/\
13722 obado 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'},\
13724 obado 20
        /*wims_msg_success: { block: 'div', classes: 'wims_msg success'},\
13722 obado 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'},\
13724 obado 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'},\
13746 bpr 28
        wims_question: { block: 'div', classes: 'wims_question'},\
13724 obado 29
        wims_color1: { block: 'div', classes: 'wims_color1'},\
30
        wims_color2: { block: 'div', classes: 'wims_color2'},\
31
        wims_color3: { block: 'div', classes: 'wims_color3'},\
13722 obado 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
      ]},\
13724 obado 41
      /*{ title: 'OEF answers', items: [\
13722 obado 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' },\
13724 obado 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' },\
13722 obado 58
      ]},\
59
      { title: 'Other WIMS styles', items: [\
60
        { title: 'Instructions', format: 'wims_instruction' },\
13745 bpr 61
        { title: 'Exercice highlight', format: 'wims_question' },\
13724 obado 62
        { title: 'Small help', format: 'wims_smallhelp' },\
63
        { title: 'Blockquote', format: 'blockquote' },\
13722 obado 64
        { title: 'Code', format: 'code' },\
13724 obado 65
        { title: 'Difficulty level', format: 'wims_difficultylevel' },\
66
        { title: 'Emphase', format: 'wims_emph' },\
13722 obado 67
      ]},\
68
    ],
69
  !endif
70
 
71
 
13695 obado 72
  !let name_WYSIWYG_activate=Activate editor
73
  !let name_WYSIWYG_disable=Disable editor
14101 obado 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
13602 obado 89
  !if $lang=fr
13614 obado 90
    !set tiny_lang=language: 'fr_FR',
13695 obado 91
    !let name_WYSIWYG_activate=Activer l'éditeur
92
    !let name_WYSIWYG_disable=Désactiver l'éditeur
13602 obado 93
  !endif
13614 obado 94
  !if $lang=it
14101 obado 95
    !set tiny_lang=language: 'it_IT',
13695 obado 96
    !let name_WYSIWYG_activate=Activate editor
97
    !let name_WYSIWYG_disable=Disable editor
13614 obado 98
  !endif
14101 obado 99
  !if $lang=nl
100
    !set tiny_lang=language: 'nl',
13695 obado 101
    !let name_WYSIWYG_activate=Activate editor
102
    !let name_WYSIWYG_disable=Disable editor
13602 obado 103
  !endif
14101 obado 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
13602 obado 109
 
14101 obado 110
 
13606 obado 111
  !set wims_html_header= !append line <script src="scripts/js/external/tinymce/tinymce.min.js"></script>\
13695 obado 112
  <style>.hidden_btn{display:none}.wysiwyg_btns{text-align:right;font-size:.6em}</style>\
13602 obado 113
  <script>\
13695 obado 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 */\
15017 obado 137
    // RegExp du texte a chercher\
138
    var find1 = '\\\\imagedir\/';\
139
    var re1 = new RegExp(find1, 'g');\
140
    // texte de remplacement\
141
    var replace1 = '\\imagedir\/';\
142
    var replace2 = '$wims_ref_name?cmd=getfile&amp;session=$wims_session&amp;special_parm=oefimg/';\
143
    // convertit l'url de remplacement en RegExp\
144
    var find2 = replace2.replace(/\//g, '\\/');\
145
    var find2 = find2.replace(/\./g, '\\.');\
146
    var find2 = find2.replace(/\?/g, '\\?');\
147
    var re2 = new RegExp(find2, 'g');\
13602 obado 148
    tinymce.init({\
149
      selector:'$wims_read_parm',\
13722 obado 150
      plugins: '$iEdit_plugins',\
151
      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;',\
13602 obado 152
      menubar: false,\
153
      branding: false,\
13722 obado 154
      toolbar: '$iEdit_toolbar',\
13614 obado 155
      $tiny_lang\
13722 obado 156
      $iEdit_formats\
14241 obado 157
      convert_urls : false,\
13775 obado 158
      entities : '160,nbsp,162,cent,8364,euro,163,pound',\
13622 obado 159
      content_css : 'html/themes/$wims_theme/css.css',\
160
      body_class: 'main_body',\
14241 obado 161
      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}',\
162
      init_instance_callback: function(editor) {\
163
        editor.on('PostProcess', function (e) {\
164
          // Avant d'afficher le code source\
15017 obado 165
          e.content = e.content.replace(re2, replace1);\
14241 obado 166
        });\
167
        editor.on('BeforeSetContent', function (e) {\
168
          // Lors de l'enregistrement du code source\
15017 obado 169
          e.content = e.content.replace(re1, replace2);\
14241 obado 170
        });\
171
        // refresh content, searching for 'imagedir'\
172
        editor.setContent(editor.getContent());\
173
      }\
13602 obado 174
    });\
14101 obado 175
  });</script>\
176
   to $wims_html_header
13602 obado 177
!endif