Skip to content

Commit

Permalink
added dynamic 'empty' class to inputs to improve detection of when th…
Browse files Browse the repository at this point in the history
…ey are empty and style accordingly
  • Loading branch information
mmarcos committed Feb 13, 2018
1 parent 0ecfa72 commit 693746d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 18 deletions.
8 changes: 7 additions & 1 deletion arctic/static/arctic/dist/assets/js/app.js

Large diffs are not rendered by default.

29 changes: 21 additions & 8 deletions arctic/static/arctic/src/assets/js/components/float_label.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
$(document).ready(function() {
$('.float-label input, .float-label textarea').each(function() {
if (($(this).val().length == 0) && ($(this).text() == 0)) {
$(this).addClass('empty');
}
});

$('.float-label input, .float-label textarea').blur(function() {
// Check if float label input is not empty, if so then add some CSS
if (($(this).val().length > 0) || ($(this).text() > 0)) {
$(this).removeClass('empty');
alert('not empty');
}
else {
$(this).addClass('empty');
alert('empty');
}
});

// Check if float label input has items, if so then add some CSS
if ($('.float-label .selectize-input').find('.item').length > 0) {
$('.selectize-input').parent().next('label').css({
top: '.3rem',
fontSize: '75%'
});
// Selectize controls
$('.float-label .selectize-input').each(function() {
if $(this).find('.item').length == 0) {
$(this).addClass('empty');
}
}
$('.float-label .selectize-input').blur(function() {
if $(this).find('.item').length > 0) {
$(this).removeClass('empty');
}
else {
$(this).addClass('empty');
}
}


});
16 changes: 7 additions & 9 deletions arctic/templates/arctic/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,19 @@ <h1 class="page-login__title">{{ SITE_NAME }}</h1>
{% endfor %}
{% endif %}
<div class="log-in-form">
{% block form %}
{% block form_fields %}
{% include "arctic/partials/form_fields.html" with form=form %}
{% block form %}
{% block form_fields %}
{% include "arctic/partials/form_fields.html" with form=form %}
{% endblock %}
{% endblock %}
{% endblock %}
<p><button type="submit" class="btn btn-primary btn-block">Login</button></p>
<p><button type="submit" class="btn btn-primary btn-block">Login</button></p>
{% block login_extra %}
{% endblock %}
</div>
</fieldset>
</form>
</div>
</div>
</div>
</div>
</div></div></div>
</div>
</div>

{% endblock %}

0 comments on commit 693746d

Please sign in to comment.