-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added dynamic 'empty' class to inputs to improve detection of when th…
…ey are empty and style accordingly
- Loading branch information
Showing
3 changed files
with
35 additions
and
18 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
29 changes: 21 additions & 8 deletions
29
arctic/static/arctic/src/assets/js/components/float_label.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
} | ||
|
||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters