includes/clientside/static/editor.js
changeset 1344 dc96d6c5cd1e
parent 1343 2a31905a567d
child 1346 b79029a49d28
equal deleted inserted replaced
1343:2a31905a567d 1344:dc96d6c5cd1e
    58 		});
    58 		});
    59 }
    59 }
    60 
    60 
    61 window.ajaxBuildEditor = function(readonly, timestamp, allow_wysiwyg, captcha_hash, revid, undo_info, response)
    61 window.ajaxBuildEditor = function(readonly, timestamp, allow_wysiwyg, captcha_hash, revid, undo_info, response)
    62 {
    62 {
       
    63 	try {
    63 	// Set flags
    64 	// Set flags
    64 	// We don't want the fancy confirmation framework to trigger if the user is only viewing the page source
    65 	// We don't want the fancy confirmation framework to trigger if the user is only viewing the page source
    65 	if ( !readonly )
    66 	if ( !readonly )
    66 	{
    67 	{
    67 		editor_open = true;
    68 		editor_open = true;
   488 		textarea.setAttribute('readonly', 'readonly');
   489 		textarea.setAttribute('readonly', 'readonly');
   489 	}
   490 	}
   490 	
   491 	
   491 	$dynano('ajaxEditArea').object.focus();
   492 	$dynano('ajaxEditArea').object.focus();
   492 	$dynano('ajaxEditArea').object._edTimestamp = timestamp;
   493 	$dynano('ajaxEditArea').object._edTimestamp = timestamp;
   493 	$dynano('ajaxEditArea').setContent(content);
   494 	ajaxEditorSetContent(content);
   494 	editor_orig_text = content;
   495 	editor_orig_text = content;
   495 	
   496 	
   496 	// If the editor preference is tinymce, switch the editor to TinyMCE now
   497 	// If the editor preference is tinymce, switch the editor to TinyMCE now
   497 	if ( response.page_format != 'wikitext' && allow_wysiwyg )
   498 	if ( response.page_format != 'wikitext' && allow_wysiwyg )
   498 	{
   499 	{
   529 			ajaxSetEditorPlain();
   530 			ajaxSetEditorPlain();
   530 			return false;
   531 			return false;
   531 		};
   532 		};
   532 		var a = document.getElementById('enano_edit_btn_mce').getElementsByTagName('a')[0];
   533 		var a = document.getElementById('enano_edit_btn_mce').getElementsByTagName('a')[0];
   533 		a.onclick = function() {
   534 		a.onclick = function() {
   534 			ajaxSetEditorMCE();
   535 			try
       
   536 			{
       
   537 				ajaxSetEditorMCE();
       
   538 			}
       
   539 			catch(e)
       
   540 			{
       
   541 				console.debug(e);
       
   542 			}
   535 			return false;
   543 			return false;
   536 		};
   544 		};
   537 	}
   545 	}
       
   546 	else
       
   547 	{
       
   548 		$('#enano_edit_btn_pt').hide();
       
   549 		$('#enano_edit_btn_mce').hide();
       
   550 	}
   538 	
   551 	
   539 	// if we're using the modal window, fade it in
   552 	// if we're using the modal window, fade it in
   540 	if ( editor_use_modal_window )
   553 	if ( editor_use_modal_window )
   541 	{
   554 	{
   542 		domOpacity(edcon, 0, 100, 500);
   555 		domOpacity(edcon, 0, 100, 500);
   544 	
   557 	
   545 	eval(setHook('editor_post_init'));
   558 	eval(setHook('editor_post_init'));
   546 	
   559 	
   547 	// Autosave every 5 minutes           (m  *  s  *  ms)
   560 	// Autosave every 5 minutes           (m  *  s  *  ms)
   548 	setInterval('ajaxPerformAutosave();', ( 5 * 60 * 1000 ));
   561 	setInterval('ajaxPerformAutosave();', ( 5 * 60 * 1000 ));
       
   562 	
       
   563 	}
       
   564 	catch(e)
       
   565 	{
       
   566 		console.debug(e);
       
   567 	}
   549 }
   568 }
   550 
   569 
   551 window.ajaxEditorDestroyModalWindow = function()
   570 window.ajaxEditorDestroyModalWindow = function()
   552 {
   571 {
   553 	if ( editor_use_modal_window )
   572 	if ( editor_use_modal_window )
   872 				}
   891 				}
   873 				
   892 				
   874 				setTimeout(function()
   893 				setTimeout(function()
   875 					{
   894 					{
   876 						editor_convert_if_needed(response.page_format);
   895 						editor_convert_if_needed(response.page_format);
   877 						$dynano('ajaxEditArea').setContent(response.src);
   896 						ajaxEditorSetContent(response.src);
   878 					}, aclDisableTransitionFX ? 10 : 750);
   897 					}, aclDisableTransitionFX ? 10 : 750);
   879 			}
   898 			}
   880 		}, true);
   899 		}, true);
   881 }
   900 }
   882 
   901 
   918 					onclick: function()
   937 					onclick: function()
   919 					{
   938 					{
   920 						setAjaxLoading();
   939 						setAjaxLoading();
   921 						editor_open = false;
   940 						editor_open = false;
   922 						enableUnload();
   941 						enableUnload();
   923 						$dynano('ajaxEditArea').destroyMCE(false);
   942 						if ( typeof(editor_formats[window.page_format]) == 'object' && typeof(editor_formats[window.page_format].ui_destroy) == 'function' )
       
   943 						{
       
   944 							editor_formats[window.page_format].ui_destroy();
       
   945 						}
   924 						ajaxEditorDestroyModalWindow();
   946 						ajaxEditorDestroyModalWindow();
   925 						ajaxReset();
   947 						ajaxReset();
   926 						miniPromptDestroy(this);
   948 						miniPromptDestroy(this);
   927 						return false;
   949 						return false;
   928 					}
   950 					}
  1054 	var span_mce  = $dynano('enano_edit_btn_mce').object;
  1076 	var span_mce  = $dynano('enano_edit_btn_mce').object;
  1055 	span_wiki.style.display = 'none';
  1077 	span_wiki.style.display = 'none';
  1056 	span_mce.style.display = 'inline';
  1078 	span_mce.style.display = 'inline';
  1057 	
  1079 	
  1058 	// Swap editor
  1080 	// Swap editor
  1059 	if ( typeof(editor_formats[window.page_format].ui_destroy) == 'function' )
  1081 	if ( typeof(editor_formats[window.page_format]) == 'object' && typeof(editor_formats[window.page_format].ui_destroy) == 'function' )
  1060 	{
  1082 	{
  1061 		if ( typeof(editor_formats[window.page_format].convert_from) == 'function' )
  1083 		if ( typeof(editor_formats[window.page_format].convert_from) == 'function' )
  1062 		{
  1084 		{
  1063 			var text = ajaxEditorGetContent();
  1085 			var text = ajaxEditorGetContent();
  1064 			var newtext = editor_formats[window.page_format].convert_from(text);
  1086 			var newtext = editor_formats[window.page_format].convert_from(text);
  1095 		blackout.style.left = $dynano('ajaxEditArea').Left() + 'px';
  1117 		blackout.style.left = $dynano('ajaxEditArea').Left() + 'px';
  1096 		blackout.style.width = $dynano('ajaxEditArea').Width() + 'px';
  1118 		blackout.style.width = $dynano('ajaxEditArea').Width() + 'px';
  1097 		blackout.style.height = $dynano('ajaxEditArea').Height() + 'px';
  1119 		blackout.style.height = $dynano('ajaxEditArea').Height() + 'px';
  1098 		blackout.style.backgroundColor = '#FFFFFF';
  1120 		blackout.style.backgroundColor = '#FFFFFF';
  1099 		domObjChangeOpac(60, blackout);
  1121 		domObjChangeOpac(60, blackout);
  1100 		blackout.style.backgroundImage = 'url(' + scriptPath + '/includes/clientside/tinymce/themes/advanced/skins/default/img/progress.gif)';
  1122 		blackout.style.backgroundImage = 'url(' + cdnPath + '/images/loading-big.gif)';
  1101 		blackout.style.backgroundPosition = 'center center';
  1123 		blackout.style.backgroundPosition = 'center center';
  1102 		blackout.style.backgroundRepeat = 'no-repeat';
  1124 		blackout.style.backgroundRepeat = 'no-repeat';
  1103 		blackout.id = 'enano_editor_blackout';
  1125 		blackout.id = 'enano_editor_blackout';
  1104 		blackout.style.zIndex = getHighestZ() + 2;
  1126 		blackout.style.zIndex = getHighestZ() + 2;
  1105 		
  1127 		
  1276 }
  1298 }
  1277 
  1299 
  1278 window.ajaxEditorSetFormat = function(plugin, success_func)
  1300 window.ajaxEditorSetFormat = function(plugin, success_func)
  1279 	{
  1301 	{
  1280 		// perform conversion
  1302 		// perform conversion
       
  1303 		if ( typeof(editor_formats[plugin]) != 'object' )
       
  1304 			return false;
       
  1305 		
  1281 		if ( typeof(editor_formats[plugin].convert_to) == 'function' )
  1306 		if ( typeof(editor_formats[plugin].convert_to) == 'function' )
  1282 		{
  1307 		{
  1283 			var result = editor_formats[plugin].convert_to($('#ajaxEditArea').val());
  1308 			var result = editor_formats[plugin].convert_to($('#ajaxEditArea').val());
  1284 		}
  1309 		}
  1285 		else
  1310 		else
  1320 				return $('#ajaxEditArea').val();
  1345 				return $('#ajaxEditArea').val();
  1321 			}
  1346 			}
  1322 		}
  1347 		}
  1323 	};
  1348 	};
  1324 
  1349 
       
  1350 window.ajaxEditorSetContent = function(text)
       
  1351 	{
       
  1352 		if ( window.page_format == 'wikitext' )
       
  1353 		{
       
  1354 			$('#ajaxEditArea').val(text);
       
  1355 		}
       
  1356 		else
       
  1357 		{
       
  1358 			if ( typeof(editor_formats[window.page_format].set_text) == 'function' )
       
  1359 			{
       
  1360 				editor_formats[window.page_format].set_text(text);
       
  1361 			}
       
  1362 			else
       
  1363 			{
       
  1364 				$('#ajaxEditArea').val(text);
       
  1365 			}
       
  1366 		}
       
  1367 	};