Move cursor to end of textarea when replying

main2
Bob Mottram 2019-09-22 10:14:39 +01:00
parent faa0b2a8b5
commit fb6a19a071
1 changed files with 15 additions and 2 deletions

View File

@ -1004,7 +1004,7 @@ def htmlNewPost(translate: {},baseDir: str, \
'</form>' '</form>'
if not reportUrl: if not reportUrl:
newPostForm+='<script>'+clickToDropDownScript()+'</script>' newPostForm+='<script>'+clickToDropDownScript()+cursorToEndOfTextScript()+'</script>'
newPostForm+=htmlFooter() newPostForm+=htmlFooter()
return newPostForm return newPostForm
@ -1375,6 +1375,19 @@ def clickToDropDownScript() -> str:
#'}' #'}'
return script return script
def cursorToEndOfTextScript() -> str:
"""Moves the cursor to the end of the text in a textarea
This avoids the cursor being in the wrong position when replying
"""
script = \
"var replyTextArea = document.getElementByName('message');" \
'' \
'replyTextArea.onFocus = function() {' \
' var theVal = replyTextArea.value;' \
' replyTextArea.value = theVal;' \
'}'
return script
def contentWarningScript() -> str: def contentWarningScript() -> str:
"""Returns a script used for content warnings """Returns a script used for content warnings
""" """
@ -2083,7 +2096,7 @@ def htmlTimeline(translate: {},pageNumber: int, \
'</div></form>' '</div></form>'
# add the javascript for content warnings # add the javascript for content warnings
tlStr+='<script>'+contentWarningScript()+clickToDropDownScript()+'</script>' tlStr+='<script>'+contentWarningScript()+'</script>'
# page up arrow # page up arrow
if pageNumber>1: if pageNumber>1: