Browse Source

! submitting by keybord a quick edit now posts the quick edit instead of the quick reply - Thanks The Omega for the report [Topic 450924] (and Labradoodle by PM :P) + post_box_name could not be present in display if not using the editor in quick reply (drafts related)

Signed-off-by: emanuele <[email protected]>
emanuele 12 years ago
parent
commit
3211531392
2 changed files with 55 additions and 3 deletions
  1. 4 3
      Themes/default/Display.template.php
  2. 51 0
      Themes/default/scripts/topic.js

+ 4 - 3
Themes/default/Display.template.php

@@ -796,8 +796,8 @@ function template_main()
 				var oDraftAutoSave = new smf_DraftAutoSave({
 					sSelf: \'oDraftAutoSave\',
 					sLastNote: \'draft_lastautosave\',
-					sLastID: \'id_draft\',
-					sSceditorID: \'', $context['post_box_name']. '\',
+					sLastID: \'id_draft\',', !empty($context['post_box_name']) ? '
+					sSceditorID: \'' . $context['post_box_name'] . '\',' : '', '
 					sType: \'', !empty($options['display_quick_reply']) && $options['display_quick_reply'] > 2 ? 'quick' : 'quick', '\',
 					iBoard: ', (empty($context['current_board']) ? 0 : $context['current_board']), ',
 					iFreq: ', (empty($modSettings['masterAutoSaveDraftsDelay']) ? 60000 : $modSettings['masterAutoSaveDraftsDelay'] * 1000), '
@@ -877,7 +877,8 @@ function template_main()
 							sTemplateBodyNormal: ', JavaScriptEscape('%body%'), ',
 							sTemplateSubjectNormal: ', JavaScriptEscape('<a href="' . $scripturl . '?topic=' . $context['current_topic'] . '.msg%msg_id%#msg%msg_id%" rel="nofollow">%subject%</a>'), ',
 							sTemplateTopSubject: ', JavaScriptEscape($txt['topic'] . ': %subject% &nbsp;(' . $txt['read'] . ' ' . $context['num_views'] . ' ' . $txt['times'] . ')'), ',
-							sErrorBorderStyle: ', JavaScriptEscape('1px solid red'), '
+							sErrorBorderStyle: ', JavaScriptEscape('1px solid red'), ($context['can_reply'] && !empty($options['display_quick_reply'])) ? ',
+							sFormRemoveAccessKeys: \'postmodify\'' : '', '
 						});
 
 						aJumpTo[aJumpTo.length] = new JumpTo({

+ 51 - 0
Themes/default/scripts/topic.js

@@ -196,6 +196,7 @@ function QuickModify(oOptions)
 	this.sMessageBuffer = '';
 	this.sSubjectBuffer = '';
 	this.bXmlHttpCapable = this.isXmlHttpCapable();
+	this.aAccessKeys = new Array();
 
 	// Show the edit buttons
 	if (this.bXmlHttpCapable)
@@ -233,6 +234,23 @@ QuickModify.prototype.modifyMsg = function (iMessageId)
 	if (typeof(sSessionVar) == 'undefined')
 		sSessionVar = 'sesc';
 
+	// Removes the accesskeys from the quickreply inputs and saves them in an array to use them later
+	if (typeof(this.opt.sFormRemoveAccessKeys) != 'undefined')
+	{
+		if (typeof(document.forms[this.opt.sFormRemoveAccessKeys]))
+		{
+			var aInputs = document.forms[this.opt.sFormRemoveAccessKeys].getElementsByTagName('input');
+			for (var i = 0; i < aInputs.length; i++)
+			{
+				if (aInputs[i].accessKey != '')
+				{
+					this.aAccessKeys[aInputs[i].name] = aInputs[i].accessKey;
+					aInputs[i].accessKey = '';
+				}
+			}
+		}
+	}
+
 	// First cancel if there's another message still being edited.
 	if (this.bInEditMode)
 		this.modifyCancel();
@@ -295,6 +313,22 @@ QuickModify.prototype.modifyCancel = function ()
 	// No longer in edit mode, that's right.
 	this.bInEditMode = false;
 
+	// Let's put back the accesskeys to their original place
+	if (typeof(this.opt.sFormRemoveAccessKeys) != 'undefined')
+	{
+		if (typeof(document.forms[this.opt.sFormRemoveAccessKeys]))
+		{
+			var aInputs = document.forms[this.opt.sFormRemoveAccessKeys].getElementsByTagName('input');
+			for (var i = 0; i < aInputs.length; i++)
+			{
+				if (typeof(this.aAccessKeys[aInputs[i].name]) != 'undefined')
+				{
+					aInputs[i].name = this.aAccessKeys[aInputs[i].name];
+				}
+			}
+		}
+	}
+
 	return false;
 }
 
@@ -309,6 +343,23 @@ QuickModify.prototype.modifySave = function (sSessionId, sSessionVar)
 	if (typeof(sSessionVar) == 'undefined')
 		sSessionVar = 'sesc';
 
+	// Let's put back the accesskeys to their original place
+	if (typeof(this.opt.sFormRemoveAccessKeys) != 'undefined')
+	{
+		if (typeof(document.forms[this.opt.sFormRemoveAccessKeys]))
+		{
+			var aInputs = document.forms[this.opt.sFormRemoveAccessKeys].getElementsByTagName('input');
+			for (var i = 0; i < aInputs.length; i++)
+			{
+				if (typeof(this.aAccessKeys[aInputs[i].name]) != 'undefined')
+				{
+					aInputs[i].name = this.aAccessKeys[aInputs[i].name];
+				}
+			}
+		}
+	}
+
+
 	var i, x = new Array();
 	x[x.length] = 'subject=' + escape(document.forms.quickModForm['subject'].value.replace(/&#/g, "&#38;#").php_to8bit()).replace(/\+/g, "%2B");
 	x[x.length] = 'message=' + escape(document.forms.quickModForm['message'].value.replace(/&#/g, "&#38;#").php_to8bit()).replace(/\+/g, "%2B");