summaryrefslogtreecommitdiffstats
path: root/activities/views/compose.py
diff options
context:
space:
mode:
authorAndrew Godwin2022-12-11 09:34:44 -0700
committerAndrew Godwin2022-12-11 09:34:44 -0700
commitf504e9c3516db48647b75477f4672e288413daf7 (patch)
treec1157495835df55e6267a4d58dbbcf417fbed352 /activities/views/compose.py
parent6d473a83cc791daaaf8ecadb06315be8594e2990 (diff)
downloadtakahe-f504e9c3516db48647b75477f4672e288413daf7.tar.gz
takahe-f504e9c3516db48647b75477f4672e288413daf7.tar.bz2
takahe-f504e9c3516db48647b75477f4672e288413daf7.zip
Fix form loading hyperscript config
Diffstat (limited to 'activities/views/compose.py')
-rw-r--r--activities/views/compose.py31
1 files changed, 18 insertions, 13 deletions
diff --git a/activities/views/compose.py b/activities/views/compose.py
index 08b54ab..e9092f7 100644
--- a/activities/views/compose.py
+++ b/activities/views/compose.py
@@ -30,19 +30,6 @@ class Compose(FormView):
"autofocus": "autofocus",
"maxlength": Config.lazy_system_value("post_length"),
"placeholder": "What's on your mind?",
- "_": f"""
- on load or input
- set characters to my.value.trim().length
- put { Config.system.post_length } - characters into #character-counter
-
- if characters > { Config.system.post_length } then
- set #character-counter's style.color to 'var(--color-text-error)'
- add [@disabled=] to #post-button
- else
- set #character-counter's style.color to ''
- remove @disabled from #post-button
- end
- """,
},
)
)
@@ -67,6 +54,24 @@ class Compose(FormView):
)
reply_to = forms.CharField(widget=forms.HiddenInput(), required=False)
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.fields["text"].widget.attrs[
+ "_"
+ ] = f"""
+ on load or input
+ set characters to my.value.trim().length
+ put {Config.system.post_length} - characters into #character-counter
+
+ if characters > {Config.system.post_length} then
+ set #character-counter's style.color to 'var(--color-text-error)'
+ add [@disabled=] to #post-button
+ else
+ set #character-counter's style.color to ''
+ remove @disabled from #post-button
+ end
+ """
+
def clean_text(self):
text = self.cleaned_data.get("text")
if not text: