81 } |
81 } |
82 |
82 |
83 // do we need to enter a captcha before saving the page? |
83 // do we need to enter a captcha before saving the page? |
84 var captcha_hash = ( response.require_captcha ) ? response.captcha_id : false; |
84 var captcha_hash = ( response.require_captcha ) ? response.captcha_id : false; |
85 |
85 |
86 ajaxBuildEditor(response.src, (!response.auth_edit), response.time, captcha_hash); |
86 ajaxBuildEditor(response.src, (!response.auth_edit), response.time, response.allow_wysiwyg, captcha_hash); |
87 } |
87 } |
88 }); |
88 }); |
89 } |
89 } |
90 |
90 |
91 function ajaxBuildEditor(content, readonly, timestamp, captcha_hash) |
91 function ajaxBuildEditor(content, readonly, timestamp, allow_wysiwyg, captcha_hash) |
92 { |
92 { |
93 // Set flags |
93 // Set flags |
94 // We don't want the fancy confirmation framework to trigger if the user is only viewing the page source |
94 // We don't want the fancy confirmation framework to trigger if the user is only viewing the page source |
95 if ( !readonly ) |
95 if ( !readonly ) |
96 { |
96 { |
108 // |
108 // |
109 // BUILD EDITOR |
109 // BUILD EDITOR |
110 // |
110 // |
111 |
111 |
112 // Plaintext/wikitext toggler |
112 // Plaintext/wikitext toggler |
113 |
113 // Only build the editor if using TinyMCE is allowed. THIS IS WEAK |
114 var toggler = document.createElement('p'); |
114 // AND CANNOT BE MADE ANY STRONGER. |
115 toggler.style.marginLeft = '0'; |
115 |
116 |
116 if ( allow_wysiwyg ) |
117 var span_wiki = document.createElement('span'); |
117 { |
118 var span_mce = document.createElement('span'); |
118 var toggler = document.createElement('p'); |
119 span_wiki.id = 'enano_edit_btn_pt'; |
119 toggler.style.marginLeft = '0'; |
120 span_mce.id = 'enano_edit_btn_mce'; |
120 |
121 if ( readCookie('enano_editor_mode') == 'tinymce' ) |
121 var span_wiki = document.createElement('span'); |
122 { |
122 var span_mce = document.createElement('span'); |
123 // Current selection is TinyMCE - make span_wiki have the link and span_mce be plaintext |
123 span_wiki.id = 'enano_edit_btn_pt'; |
124 var a = document.createElement('a'); |
124 span_mce.id = 'enano_edit_btn_mce'; |
125 a.href = '#'; |
125 if ( readCookie('enano_editor_mode') == 'tinymce' ) |
126 a.onclick = function() { |
126 { |
127 ajaxSetEditorPlain(); |
127 // Current selection is TinyMCE - make span_wiki have the link and span_mce be plaintext |
128 return false; |
128 var a = document.createElement('a'); |
129 }; |
129 a.href = '#'; |
130 a.appendChild(document.createTextNode($lang.get('editor_btn_wikitext'))); |
130 a.onclick = function() { |
131 span_wiki.appendChild(a); |
131 ajaxSetEditorPlain(); |
132 toggler.appendChild(span_wiki); |
132 return false; |
133 toggler.appendChild(document.createTextNode(' | ')); |
133 }; |
134 span_mce.appendChild(document.createTextNode($lang.get('editor_btn_graphical'))); |
134 a.appendChild(document.createTextNode($lang.get('editor_btn_wikitext'))); |
135 toggler.appendChild(span_mce); |
135 span_wiki.appendChild(a); |
136 } |
136 toggler.appendChild(span_wiki); |
137 else |
137 toggler.appendChild(document.createTextNode(' | ')); |
138 { |
138 span_mce.appendChild(document.createTextNode($lang.get('editor_btn_graphical'))); |
139 // Current selection is wikitext - set span_wiki to plaintext and span_mce to link |
139 toggler.appendChild(span_mce); |
140 span_wiki.appendChild(document.createTextNode($lang.get('editor_btn_wikitext'))); |
140 } |
141 toggler.appendChild(span_wiki); |
141 else |
142 toggler.appendChild(document.createTextNode(' | ')); |
142 { |
143 var a = document.createElement('a'); |
143 // Current selection is wikitext - set span_wiki to plaintext and span_mce to link |
144 a.href = '#'; |
144 span_wiki.appendChild(document.createTextNode($lang.get('editor_btn_wikitext'))); |
145 a.onclick = function() { |
145 toggler.appendChild(span_wiki); |
146 ajaxSetEditorMCE(); |
146 toggler.appendChild(document.createTextNode(' | ')); |
147 return false; |
147 var a = document.createElement('a'); |
148 }; |
148 a.href = '#'; |
149 a.appendChild(document.createTextNode($lang.get('editor_btn_graphical'))); |
149 a.onclick = function() { |
150 span_mce.appendChild(a); |
150 ajaxSetEditorMCE(); |
151 toggler.appendChild(span_mce); |
151 return false; |
|
152 }; |
|
153 a.appendChild(document.createTextNode($lang.get('editor_btn_graphical'))); |
|
154 span_mce.appendChild(a); |
|
155 toggler.appendChild(span_mce); |
|
156 } |
152 } |
157 } |
153 |
158 |
154 // Form (to allow submits from MCE to trigger a real save) |
159 // Form (to allow submits from MCE to trigger a real save) |
155 var form = document.createElement('form'); |
160 var form = document.createElement('form'); |
156 form.action = 'javascript:void(0);'; |
161 form.action = 'javascript:void(0);'; |
362 en_div.className = 'usermessage'; |
367 en_div.className = 'usermessage'; |
363 en_div.style.margin = '10px 0 0 0'; |
368 en_div.style.margin = '10px 0 0 0'; |
364 } |
369 } |
365 |
370 |
366 // Put it all together... |
371 // Put it all together... |
367 form.appendChild(toggler); |
372 if ( allow_wysiwyg ) |
|
373 form.appendChild(toggler); |
368 form.appendChild(preview_anchor); |
374 form.appendChild(preview_anchor); |
369 form.appendChild(preview_container); |
375 form.appendChild(preview_container); |
370 form.appendChild(ta_wrapper); |
376 form.appendChild(ta_wrapper); |
371 form.appendChild(tblholder); |
377 form.appendChild(tblholder); |
372 edcon.appendChild(form); |
378 edcon.appendChild(form); |