Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Discuss Data Project
Discuss Data
Commits
1e0df4bc
Commit
1e0df4bc
authored
Jun 02, 2020
by
felix.herrmann
Browse files
feat(maxlength): set new div to empty if chars are deleted under maxlength-50
parent
21147f9b
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
discuss_data/static/js/project.js
View file @
1e0df4bc
...
...
@@ -166,18 +166,24 @@ $(document).on('keyup','.textarea, .textinput', function() {
var
remainingLength
=
maxLength
-
length
;
// get this elements id
var
elemId
=
$
(
this
).
attr
(
'
id
'
);
// construct new id using this elements id
var
charsLeftId
=
elemId
+
'
_chars_left
'
;
if
(
remainingLength
<
50
)
{
// construct new id using this elements id
var
charsLeftId
=
elemId
+
'
_chars_left
'
;
if
(
$
(
'
#
'
+
charsLeftId
).
length
)
{
// if new div exists set text
$
(
'
#
'
+
charsLeftId
).
html
(
remainingLength
);
$
(
'
#
'
+
charsLeftId
).
text
(
remainingLength
);
}
else
{
// create new div using new id
$
(
"
<div class='chars-left' id='
"
+
charsLeftId
+
"
'>
"
+
remainingLength
+
"
</div>
"
).
insertAfter
(
'
#
'
+
elemId
);
}
}
else
{
// if chars are deleted and remainingLength > 50 make new div empty
if
(
$
(
'
#
'
+
charsLeftId
).
length
)
{
$
(
'
#
'
+
charsLeftId
).
text
(
''
);
}
}
}
});
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment