includes/clientside/static/editor.js
changeset 1307 5d9f6ecf748e
parent 1291 a971f6efcb7b
child 1311 a228f7e8fb15
equal deleted inserted replaced
1306:e00489a30c72 1307:5d9f6ecf748e
     4 var AUTOSAVE_TIMEOUT = 15;
     4 var AUTOSAVE_TIMEOUT = 15;
     5 var AutosaveTimeoutObj = null;
     5 var AutosaveTimeoutObj = null;
     6 var editor_img_path = cdnPath + '/images/editor';
     6 var editor_img_path = cdnPath + '/images/editor';
     7 var editor_save_lock = false;
     7 var editor_save_lock = false;
     8 var editor_wikitext_transform_enable = true;
     8 var editor_wikitext_transform_enable = true;
       
     9 var editor_orig_text = '';
       
    10 var editor_last_draft = '';
     9 
    11 
    10 window.ajaxEditor = function(revid)
    12 window.ajaxEditor = function(revid)
    11 {
    13 {
    12 	if ( KILL_SWITCH )
    14 	if ( KILL_SWITCH )
    13 		return true;
    15 		return true;
   192 	preview_container.style.clear = 'left';
   194 	preview_container.style.clear = 'left';
   193 	
   195 	
   194 	// Textarea containing the content
   196 	// Textarea containing the content
   195 	var ta_wrapper = document.createElement('div');
   197 	var ta_wrapper = document.createElement('div');
   196 	ta_wrapper.style.margin = '10px 0';
   198 	ta_wrapper.style.margin = '10px 0';
       
   199 	
       
   200 	// A hook allowing plugins to create a toolbar on top of the textarea
       
   201 	eval(setHook('editor_gui_toolbar'));
       
   202 	
   197 	// ta_wrapper.style.clear = 'both';
   203 	// ta_wrapper.style.clear = 'both';
   198 	var textarea = document.createElement('textarea');
   204 	var textarea = document.createElement('textarea');
   199 	ta_wrapper.appendChild(textarea);
   205 	ta_wrapper.appendChild(textarea);
   200 	
   206 	
   201 	textarea.id = 'ajaxEditArea';
   207 	textarea.id = 'ajaxEditArea';
   478 	}
   484 	}
   479 	
   485 	
   480 	$dynano('ajaxEditArea').object.focus();
   486 	$dynano('ajaxEditArea').object.focus();
   481 	$dynano('ajaxEditArea').object._edTimestamp = timestamp;
   487 	$dynano('ajaxEditArea').object._edTimestamp = timestamp;
   482 	$dynano('ajaxEditArea').setContent(content);
   488 	$dynano('ajaxEditArea').setContent(content);
       
   489 	editor_orig_text = content;
   483 	
   490 	
   484 	// If the editor preference is tinymce, switch the editor to TinyMCE now
   491 	// If the editor preference is tinymce, switch the editor to TinyMCE now
   485 	if ( response.page_format == 'xhtml' && allow_wysiwyg )
   492 	if ( response.page_format == 'xhtml' && allow_wysiwyg )
   486 	{
   493 	{
   487 		$dynano('ajaxEditArea').switchToMCE(false);
   494 		$dynano('ajaxEditArea').switchToMCE(false);
  1069 	var now = unix_time();
  1076 	var now = unix_time();
  1070 	aed.as_last_save = now;
  1077 	aed.as_last_save = now;
  1071 	
  1078 	
  1072 	var ta_content = $dynano('ajaxEditArea').getContent();
  1079 	var ta_content = $dynano('ajaxEditArea').getContent();
  1073 	
  1080 	
  1074 	if ( ta_content == '' || ta_content == '<p></p>' || ta_content == '<p>&nbsp;</p>' )
  1081 	if ( ta_content == '' || ta_content == '<p></p>' || ta_content == '<p>&nbsp;</p>' || ta_content == editor_orig_text || ta_content == editor_last_draft )
  1075 	{
  1082 	{
  1076 		return false;
  1083 		return false;
  1077 	}
  1084 	}
       
  1085 	
       
  1086 	editor_last_draft = ta_content;
  1078 	
  1087 	
  1079 	ajaxEditorSave(true);
  1088 	ajaxEditorSave(true);
  1080 }
  1089 }
  1081 
  1090 
  1082 window.ajaxEditorUseDraft = function()
  1091 window.ajaxEditorUseDraft = function()
  1108 				
  1117 				
  1109 				editor_convert_if_needed(response.page_format);
  1118 				editor_convert_if_needed(response.page_format);
  1110 				
  1119 				
  1111 				$dynano('ajaxEditArea').setContent(response.src);
  1120 				$dynano('ajaxEditArea').setContent(response.src);
  1112 				$dynano('ajaxEditArea').object.used_draft = true;
  1121 				$dynano('ajaxEditArea').object.used_draft = true;
       
  1122 				editor_orig_text = editor_last_draft = response.src;
  1113 				
  1123 				
  1114 				var es = document.getElementById('enano_editor_field_summary');
  1124 				var es = document.getElementById('enano_editor_field_summary');
  1115 				if ( es.value == '' )
  1125 				if ( es.value == '' )
  1116 				{
  1126 				{
  1117 					es.value = response.edit_summary;
  1127 					es.value = response.edit_summary;