Parcourir la source

+ On preview of posts, PMs and newsletters screen goes to the top of the preview
! Signature is not cut by javascript in case is too long, instead the chars remaining become red and negative

emanuele il y a 12 ans
Parent
commit
f0dbc9bc4a

+ 2 - 2
Sources/Xml.php

@@ -78,7 +78,7 @@ function RetrievePreview()
 {
 	global $context;
 
-	$subActions = array(
+	$items = array(
 		'newspreview',
 		'newsletterpreview',
 		'sig_preview',
@@ -87,7 +87,7 @@ function RetrievePreview()
 
 	$context['sub_template'] = 'generic_xml';
 
-	if (!isset($_POST['item']) || !in_array($_POST['item'], $subActions))
+	if (!isset($_POST['item']) || !in_array($_POST['item'], $items))
 		return false;
 
 	$_POST['item']();

+ 2 - 2
Themes/default/ManageNews.template.php

@@ -348,8 +348,6 @@ function template_email_members_compose()
 				for (var i = 0, numErrors = errors.getElementsByTagName(\'error\').length; i < numErrors; i++)
 					errorList[errorList.length] = errors.getElementsByTagName(\'error\')[i].firstChild.nodeValue;
 				document.getElementById(\'errors\').style.display = numErrors == 0 ? \'none\' : \'\';
-				// @todo temporarly removed
-				//document.getElementById(\'error_serious\').style.display = errors.getAttribute(\'serious\') == 1 ? \'\' : \'none\';
 				setInnerHTML(document.getElementById(\'error_list\'), numErrors == 0 ? \'\' : errorList.join(\'<br />\'));
 
 				// Adjust the color of captions if the given data is erroneous.
@@ -367,7 +365,9 @@ function template_email_members_compose()
 					else
 						document.forms.newsmodify.', $context['post_box_name'], '.style.border = null;
 				}
+				location.hash = \'#\' + \'preview_section\';
 			}';
+
 	echo '
 		// ]]></script>';
 

+ 2 - 2
Themes/default/PersonalMessage.template.php

@@ -1131,8 +1131,6 @@ function template_send()
 				for (var i = 0, numErrors = errors.getElementsByTagName(\'error\').length; i < numErrors; i++)
 					errorList[errorList.length] = errors.getElementsByTagName(\'error\')[i].firstChild.nodeValue;
 				document.getElementById(\'errors\').style.display = numErrors == 0 ? \'none\' : \'\';
-				// @todo temporarly removed
-				//document.getElementById(\'error_serious\').style.display = errors.getAttribute(\'serious\') == 1 ? \'\' : \'none\';
 				setInnerHTML(document.getElementById(\'error_list\'), numErrors == 0 ? \'\' : errorList.join(\'<br />\'));
 
 				// Adjust the color of captions if the given data is erroneous.
@@ -1150,7 +1148,9 @@ function template_send()
 					else
 						document.forms.postmodify.', $context['post_box_name'], '.style.border = null;
 				}
+				location.hash = \'#\' + \'preview_section\';
 			}';
+
 	echo '
 		// ]]></script>';
 

+ 2 - 0
Themes/default/Post.template.php

@@ -690,6 +690,8 @@ function template_main()
 					}
 				}
 
+				location.hash = \'#\' + \'preview_section\';
+
 				if (typeof(smf_codeFix) != \'undefined\')
 					smf_codeFix();
 			}';

+ 12 - 28
Themes/default/Profile.template.php

@@ -2511,10 +2511,11 @@ function template_error_message()
 {
 	global $context, $txt;
 
+	echo '
+		<div class="errorbox" ', empty($context['post_errors']) ? 'style="display:none" ' : '', 'id="profile_error">';
 	if (!empty($context['post_errors']))
 	{
 		echo '
-		<div class="errorbox" id="profile_error">
 			<span>', !empty($context['custom_error_title']) ? $context['custom_error_title'] : $txt['profile_errors_occurred'], ':</span>
 			<ul id="list_errors">';
 
@@ -2524,13 +2525,10 @@ function template_error_message()
 				<li>', isset($txt['profile_error_' . $error]) ? $txt['profile_error_' . $error] : $error, '.</li>';
 
 		echo '
-			</ul>
-		</div>';
+			</ul>';
 	}
-	else
-		echo '
-		<div class="errorbox" style="display:none" id="profile_error">
-			<span>', !empty($context['custom_error_title']) ? $context['custom_error_title'] : $txt['profile_errors_occurred'], ':</span>
+
+	echo '
 		</div>';
 }
 
@@ -2652,20 +2650,11 @@ function template_profile_signature_modify()
 	// Some javascript used to count how many characters have been used so far in the signature.
 	echo '
 								<script type="text/javascript"><!-- // --><![CDATA[
-									function tick()
-									{
-										if (typeof(document.forms.creator) != "undefined")
-										{
-											calcCharLeft();
-											setTimeout("tick()", 1000);
-										}
-										else
-											setTimeout("tick()", 800);
-									}
+									var maxLength = ', $context['signature_limits']['max_length'], ';
+									var error_displayed = false;
 
 									function calcCharLeft()
 									{
-										var maxLength = ', $context['signature_limits']['max_length'], ';
 										var oldSignature = "", currentSignature = document.forms.creator.signature.value;
 										var currentChars = 0;
 
@@ -2678,27 +2667,20 @@ function template_profile_signature_modify()
 
 											var currentChars = currentSignature.replace(/\r/, "").length;
 											if (is_opera)
-												currentChars = currentSignature.replace(/\r/g,\'\').length;
+												currentChars = currentSignature.replace(/\r/g, "").length;
 
+											ajax_getSignaturePreview(false);
 											if (currentChars > maxLength)
-											{
 												document.getElementById("signatureLeft").className = "error";
-												if (!$("#profile_error").is(":visible"))
-													ajax_getSignaturePreview(false);
-											}
 											else
-											{
-												if ($("#profile_error").is(":visible"))
-													ajax_getSignaturePreview(false);
 												document.getElementById("signatureLeft").className = "";
-											}
 										}
 
 										setInnerHTML(document.getElementById("signatureLeft"), maxLength - currentChars);
 									}
 
-									addLoadEvent(tick);
 									$(document).ready(function() {
+										calcCharLeft();
 										$("#preview_button").click(function() {
 											return ajax_getSignaturePreview(true);
 										});
@@ -2726,6 +2708,7 @@ function template_profile_signature_modify()
 												if ($(request).find("error").text() != \'\')
 												{
 													$("#profile_error").css({display:""});
+													error_displayed = true;
 													var errors = $(request).find(\'[type="error"]\');
 													var errors_html = \'<span>\' + $(request).find(\'[type="errors_occurred"]\').text() + \'</span><ul class="reset">\';
 
@@ -2738,6 +2721,7 @@ function template_profile_signature_modify()
 												else
 												{
 													$("#profile_error").css({display:"none"});
+													error_displayed = false;
 													$("#profile_error").html(\'\');
 												}
 											return false;