Browse Source

! Fix bugs related to auto-saving drafts

Signed-off-by: Michael Eshom <[email protected]>
Michael Eshom 11 years ago
parent
commit
c605228a20
2 changed files with 6 additions and 6 deletions
  1. 1 1
      Themes/default/Display.template.php
  2. 5 5
      Themes/default/scripts/drafts.js

+ 1 - 1
Themes/default/Display.template.php

@@ -317,7 +317,7 @@ function template_main()
 			echo '
 								<input type="button" value="', $txt['spell_check'], '" onclick="spellCheck(\'postmodify\', \'message\');" tabindex="', $context['tabindex']++, '" class="button_submit" />';
 
-		if ($context['drafts_save'] && !empty($options['drafts_show_saved_enabled']))
+		if ($context['drafts_save'])
 			echo '
 								<input type="submit" name="save_draft" value="', $txt['draft_save'], '" onclick="return confirm(' . JavaScriptEscape($txt['draft_save_note']) . ') && submitThisOnce(this);" accesskey="d" tabindex="', $context['tabindex']++, '" class="button_submit" />
 								<input type="hidden" id="id_draft" name="id_draft" value="', empty($context['id_draft']) ? 0 : $context['id_draft'], '" />';

+ 5 - 5
Themes/default/scripts/drafts.js

@@ -27,9 +27,9 @@ smf_DraftAutoSave.prototype.init = function ()
 		this.interval_id = window.setInterval(this.opt.sSelf + '.draft' + (this.bPM ? 'PM' : '') + 'Save();', this.opt.iFreq);
 
 		// Set up window focus and blur events
-		this.oDraftHandle.instanceRef = this;
-		this.oDraftHandle.onblur = function (oEvent) {return this.instanceRef.draftBlur(oEvent, true);};
-		this.oDraftHandle.onfocus = function (oEvent) {return this.instanceRef.draftFocus(oEvent, true);};
+		var instanceRef = this;
+		this.oDraftHandle.onblur = function (oEvent) {return instanceRef.draftBlur(oEvent, true);};
+		this.oDraftHandle.onfocus = function (oEvent) {return instanceRef.draftFocus(oEvent, true);};
 
 		// If we found the iframe window, set body focus/blur events for it
 		if (oIframeWindow.document)
@@ -91,7 +91,7 @@ smf_DraftAutoSave.prototype.draftSave = function ()
 	// Get the form elements that we want to save
 	var aSections = [
 		'topic=' + parseInt(document.forms.postmodify.elements['topic'].value),
-		'id_draft=' + parseInt(document.forms.postmodify.elements['id_draft'].value),
+		'id_draft=' + (('id_draft' in document.forms.postmodify.elements) ? parseInt(document.forms.postmodify.elements['id_draft'].value) : 0),
 		'subject=' + escape(document.forms.postmodify['subject'].value.replace(/&#/g, "&#38;#").php_to8bit()).replace(/\+/g, "%2B"),
 		'message=' + escape(sPostdata.replace(/&#/g, "&#38;#").php_to8bit()).replace(/\+/g, "%2B"),
 		'icon=' + escape(document.forms.postmodify['icon'].value.replace(/&#/g, "&#38;#").php_to8bit()).replace(/\+/g, "%2B"),
@@ -142,7 +142,7 @@ smf_DraftAutoSave.prototype.draftPMSave = function ()
 	// Get the rest of the form elements that we want to save, and load them up
 	var aSections = [
 		'replied_to=' + parseInt(document.forms.postmodify.elements['replied_to'].value),
-		'id_pm_draft=' + parseInt(document.forms.postmodify.elements['id_pm_draft'].value),
+		'id_pm_draft=' + (('id_pm_draft' in document.forms.postmodify.elements) ? parseInt(document.forms.postmodify.elements['id_pm_draft'].value) : 0),
 		'subject=' + escape(document.forms.postmodify['subject'].value.replace(/&#/g, "&#38;#").php_to8bit()).replace(/\+/g, "%2B"),
 		'message=' + escape(sPostdata.replace(/&#/g, "&#38;#").php_to8bit()).replace(/\+/g, "%2B"),
 		'recipient_to=' + aTo,