Add character counter

parent 474f4107
......@@ -12,7 +12,8 @@ $(document).on 'submit', '.new_message', ->
this.action += "##{secret}"
$(document).on 'decrypt', (ev, data)->
$(document).on 'decrypt', (ev, data) ->
secret = location.hash.slice(1)
decrypted = CryptoJS.AES.decrypt(data, secret)
......@@ -22,8 +23,17 @@ $(document).on 'decrypt', (ev, data)->
$('pre.message').remove()
$('.wrong-key').attr('aria-hidden', 'false').show()
$(document).on 'submit', '.edit_message', ->
this.action += location.hash
$(document).on 'hash', (ev, url) ->
$('.share-link').text(url + location.hash)
$(document).on 'ready', ->
$('textarea').bind 'input', ->
max = parseInt($(this).attr('maxlength'))
current = $(this).val().length
$('[data-count]').text max - current
......@@ -160,6 +160,9 @@ strong
margin-top: -10px
visibility: visible
.new-message-container
position: relative
.new-message-field
background: $c-white
border: none
......@@ -170,6 +173,20 @@ strong
resize: vertical
width: 100%
.new-message-count
background-color: white
border: 1px solid $c-light
border-radius: 4px
bottom: 0
color: $c-gray
font:
family: $f-mono
size: 8px
padding: 4px
pointer-events: none
position: absolute
right: 20px
.share-link
background: $c-white
......
......@@ -46,6 +46,9 @@
padding: 0 10px
width: 100%
.new-message-count
right: 10px
@media screen and (max-width: 440px)
.slogan
......
%div.validation-error(aria-hidden='true' role='alert')= t('validation-error')
%textarea.new-message-field(autofocus placeholder="#{t('new-message.placeholder')}" maxlength=10000 name='body')
%div.new-message-container
%div.new-message-count
%span(data-count) 10000
%textarea.new-message-field(autofocus placeholder="#{t('new-message.placeholder')}" maxlength=10000 name='body')
= form_for @message do |f|
= f.hidden_field :data
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment