Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Input & textarea label animation #15

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions javascripts/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,16 @@ MMCQ = (function() {
}
};

var setFormLabelState = function() {
$('.form_field_textarea, .form_field_textfield').each(function() {
var label = $(this).closest('.form_field').find('.edy-fe-label, .form_field_label');
if (!$(this).val()) {
label.css({transform: "translateY("+ label.height() +"px)", "pointer-events": "none", opacity: 1});
}
label.css({opacity: 1});
});
}

var init = function() {
// Add site wide functions here.
bindSideClicks();
Expand All @@ -1045,6 +1055,17 @@ MMCQ = (function() {
buildCustomShoppingCartIcon();
});

setFormLabelState();

$('.form_field_textfield, .form_field_textarea').focus(function() {
var label = $(this).closest('.form_field').find('.edy-fe-label, .form_field_label');
label.css({transform: "translateY(0)", "pointer-events": "all", transition: "all 0.3s cubic-bezier(0.1, 0.6, 0, 1)"});
});

$('.form_field_textfield, .form_field_textarea').blur(function() {
setFormLabelState();
});

if (!editmode()) {
wrapTables();
}
Expand Down
2 changes: 1 addition & 1 deletion javascripts/global.min.js

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions sources/javascripts/concat/global/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,16 @@
}
};

var setFormLabelState = function() {
$('.form_field_textarea, .form_field_textfield').each(function() {
var label = $(this).closest('.form_field').find('.edy-fe-label, .form_field_label');
if (!$(this).val()) {
label.css({transform: "translateY("+ label.height() +"px)", "pointer-events": "none", opacity: 1});
}
label.css({opacity: 1});
});
}

var init = function() {
// Add site wide functions here.
bindSideClicks();
Expand All @@ -504,6 +514,17 @@
buildCustomShoppingCartIcon();
});

setFormLabelState();

$('.form_field_textfield, .form_field_textarea').focus(function() {
var label = $(this).closest('.form_field').find('.edy-fe-label, .form_field_label');
label.css({transform: "translateY(0)", "pointer-events": "all", transition: "all 0.3s cubic-bezier(0.1, 0.6, 0, 1)"});
});

$('.form_field_textfield, .form_field_textarea').blur(function() {
setFormLabelState();
});

if (!editmode()) {
wrapTables();
}
Expand Down
1 change: 1 addition & 0 deletions sources/stylesheets/content/_forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
position: relative;
display: block;
margin-bottom: 4px;
opacity: 0;
}
}

Expand Down
1 change: 1 addition & 0 deletions stylesheets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ p {
position: relative;
display: block;
margin-bottom: 4px;
opacity: 0;
}
.content-formatted .form_field_required .form_field_label:after {
content: '*';
Expand Down
2 changes: 1 addition & 1 deletion stylesheets/main.min.css

Large diffs are not rendered by default.