Skip to content

Commit

Permalink
Make float labels work with different mark-up and check inputs on load.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bart van der Waerden committed Aug 17, 2017
1 parent eb6062e commit ccce417
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions arctic/static/arctic/src/assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ $(document).ready(function() {
// Stepper input
var $stepperInput = $('.stepper-input input');

// Check if flaot 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%'
});
};

function incrementStepperInput(amount) {
$stepperInput.val((parseInt($stepperInput.val()) || 0) + amount);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
}
}

.styled-select label {
.styled-select label,
.styled-select + label {
top: .3rem;
font-size: 75%;
}
Expand Down
2 changes: 1 addition & 1 deletion arctic/templates/arctic/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{% block content %}
<h4 id="form" data-magellan-target="form">Form with validation</h4>
<form class="content-block__flex-wrap" data-abide novalidate>
<form class="content-block__flex-wrap float-label" data-abide novalidate>
<fieldset type="get">
<div data-abide-error class="alert callout" style="display: none;">
<p><i class="fi-alert"></i> There are some errors in your form.</p>
Expand Down
1 change: 1 addition & 0 deletions example/articles/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def get_category_field(self, row):


class ArticleUpdateView(UpdateView):
form_display = 'float-label'
page_title = _("Edit Article")
permission_required = "change_article"
model = Article
Expand Down

0 comments on commit ccce417

Please sign in to comment.