1
0
mirror of https://gitlab.com/brutaldon/brutaldon.git synced 2024-12-04 14:46:24 -05:00

Add character count to toot forms

This commit is contained in:
Jason McBrayer 2018-09-07 16:28:33 -04:00
parent a894a9674b
commit 67bfcde2fe
5 changed files with 54 additions and 0 deletions

View File

@ -172,3 +172,18 @@ emoji-link
95% {left: 120%;} 95% {left: 120%;}
to {left: 100%;} to {left: 100%;}
} }
#status_count
{
margin-left: 90%;
margin-top: 1rem;
background-color: #888;
color: #FFF;
float: right;
padding: 0.5ex;
border-radius: 5px;
min-height: 1.5rem;
min-width: 1.5rem;
font-size: 0.8em;
text-align: right;
}

View File

@ -143,3 +143,18 @@ emoji-link
95% {left: 120%;} 95% {left: 120%;}
to {left: 100%;} to {left: 100%;}
} }
#status_count
{
margin-left: 90%;
margin-top: 1rem;
background-color: #888;
color: #FFF;
float: right;
padding: 0.5ex;
border-radius: 5px;
min-height: 1.5rem;
min-width: 1.5rem;
font-size: 0.8em;
text-align: right;
}

View File

@ -130,3 +130,19 @@ function fileButtonUpdaters()
}; };
} }
function characterCountSetup()
{
$("#status_count").text(characterCount());
$("#id_status").keyup(function(){
$("#status_count").text(characterCount());
});
$("#id_spoiler_text").keyup(function(){
$("#status_count").text(characterCount());
});
}
function characterCount()
{
return $("#id_status").val().length + $("#id_spoiler_text").val().length;
}

View File

@ -19,6 +19,7 @@
<div class="control"> <div class="control">
{% render_field form.status class+="textarea is-primary mousetrap" rows="3" %} {% render_field form.status class+="textarea is-primary mousetrap" rows="3" %}
</div> </div>
<div id="status_count"></div>
</div> </div>
<div class="field has-addons"> <div class="field has-addons">
@ -38,4 +39,9 @@
</a> </a>
</div> </div>
</div> </div>
{% if not preferences.theme.is_brutalist %}
<script type="application/javascript">
Intercooler.ready(characterCountSetup);
</script>
{% endif %}
</form> </form>

View File

@ -26,6 +26,7 @@
<div class="control"> <div class="control">
{% render_field form.status class+="textarea mousetrap is-primary" rows="4" %} {% render_field form.status class+="textarea mousetrap is-primary" rows="4" %}
</div> </div>
<div id="status_count"></div>
</div> </div>
<div class="field"> <div class="field">
@ -130,6 +131,7 @@
<script type="application/javascript"> <script type="application/javascript">
fileButtonUpdaters(); fileButtonUpdaters();
Intercooler.ready(fileButtonUpdaters); Intercooler.ready(fileButtonUpdaters);
Intercooler.ready(characterCountSetup);
</script> </script>
{% endif %} {% endif %}
</form> </form>