[3.0] Theme split (wave 4, part 17) — move the signature counter's wiring into profile.js - #9438
Open
albertlast wants to merge 1 commit into
Open
Conversation
The signature editor generated a script to declare maxLength, call calcCharLeft() once and bind the preview button, and the textarea carried an onkeyup attribute. profile.js is loaded on every profile page anyway, so it can do all of that itself. The limit rides on the textarea as data-max-length instead of a global written into the page, so the number is in one place. It is only emitted when there is a limit, since the counter it feeds is only rendered then either. The handler is on "input" rather than "keyup", so pasting a signature in counts it as well. Signed-off-by: Mathias Alberts <mathiaspapealbert@hotmail.com> Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Part of the #7933 split, wave 4.
Profile area.
template_profile_signature_modify()generated a script to declaremaxLength, callcalcCharLeft()once and bind the preview button, and the textarea carried anonkeyupattribute. Both functions already live in
profile.js, which every profile page loads, soit can do its own wiring.
The limit travels on the textarea as
data-max-lengthrather than as a global written intothe page, so the number exists in one place. It is only emitted when there is a limit —
#signatureLeft, the counter it feeds, only exists then too, andcalcCharLeft()alreadyreturns early without it.
The handler is on
inputrather thankeyup, so pasting a signature in counts it.Not taken from the theme branch
It puts
maxlengthon the textarea instead. That would stop you typing past the limit, butSMF counts the signature with
\rstripped, so the browser would cut you off earlier thanthe server would on anything with line breaks. The counting here is unchanged.
It also drops
id="preview_button"and bindsf.preview_button— which isundefined,because the input is
name="preview_signature". That would leave the preview button dead.The id stays.
Checked
Forum Profile page, same signature limit (300), before and after:
300hello295x-200errorIdentical both ways, including the
errorclass lingering at the last step — that iscalcCharLeft()re-initialisingoldSignatureto""on every call and skipping its bodywhen the signature is empty, which is untouched here.
Preview still renders:
A [b]bold[/b] signature.comes back asA <strong>bold</strong> signature.into#preview_signature_display, with both thecurrent and preview rows revealed.
Issues References (Fixes|Related|Closes)
Part of #7933
Co-Authored-By: live627 john@jbrock.us