Added an editor hook that allows plugins to insert their own content right before the editor box.
authorDan Fuhry <dan@enanocms.org>
Thu, 28 Oct 2010 03:04:24 -0400
changeset 1307 5d9f6ecf748e
parent 1306 e00489a30c72
child 1308 f9bee9b125ee
Added an editor hook that allows plugins to insert their own content right before the editor box.
includes/clientside/static/autofill.js
includes/clientside/static/editor.js
--- a/includes/clientside/static/autofill.js	Tue Oct 12 23:07:27 2010 -0400
+++ b/includes/clientside/static/autofill.js	Thu Oct 28 03:04:24 2010 -0400
@@ -152,7 +152,7 @@
 	
 		// Create results
 		var results = document.createElement("div");
-		$(results).addClass('tblholder').css('z-index', getHighestZ() + 1).css('margin-top', 0);
+		$(results).addClass('tblholder').css('z-index', getHighestZ() + 50).css('margin-top', 0);
 		$(results).css('clip', 'rect(0px,auto,auto,0px)').css('overflow', 'auto').css('max-height', '300px');
 	
 		// Create jQuery object for results
--- a/includes/clientside/static/editor.js	Tue Oct 12 23:07:27 2010 -0400
+++ b/includes/clientside/static/editor.js	Thu Oct 28 03:04:24 2010 -0400
@@ -6,6 +6,8 @@
 var editor_img_path = cdnPath + '/images/editor';
 var editor_save_lock = false;
 var editor_wikitext_transform_enable = true;
+var editor_orig_text = '';
+var editor_last_draft = '';
 
 window.ajaxEditor = function(revid)
 {
@@ -194,6 +196,10 @@
 	// Textarea containing the content
 	var ta_wrapper = document.createElement('div');
 	ta_wrapper.style.margin = '10px 0';
+	
+	// A hook allowing plugins to create a toolbar on top of the textarea
+	eval(setHook('editor_gui_toolbar'));
+	
 	// ta_wrapper.style.clear = 'both';
 	var textarea = document.createElement('textarea');
 	ta_wrapper.appendChild(textarea);
@@ -480,6 +486,7 @@
 	$dynano('ajaxEditArea').object.focus();
 	$dynano('ajaxEditArea').object._edTimestamp = timestamp;
 	$dynano('ajaxEditArea').setContent(content);
+	editor_orig_text = content;
 	
 	// If the editor preference is tinymce, switch the editor to TinyMCE now
 	if ( response.page_format == 'xhtml' && allow_wysiwyg )
@@ -1071,11 +1078,13 @@
 	
 	var ta_content = $dynano('ajaxEditArea').getContent();
 	
-	if ( ta_content == '' || ta_content == '<p></p>' || ta_content == '<p>&nbsp;</p>' )
+	if ( ta_content == '' || ta_content == '<p></p>' || ta_content == '<p>&nbsp;</p>' || ta_content == editor_orig_text || ta_content == editor_last_draft )
 	{
 		return false;
 	}
 	
+	editor_last_draft = ta_content;
+	
 	ajaxEditorSave(true);
 }
 
@@ -1110,6 +1119,7 @@
 				
 				$dynano('ajaxEditArea').setContent(response.src);
 				$dynano('ajaxEditArea').object.used_draft = true;
+				editor_orig_text = editor_last_draft = response.src;
 				
 				var es = document.getElementById('enano_editor_field_summary');
 				if ( es.value == '' )