Subversion Repositories wimsdev

Rev

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