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

Feature #548 - allow select component to be controlled by keyboard #582

Closed
wants to merge 2 commits into from
Closed
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
42 changes: 22 additions & 20 deletions bin/materialize.css
Original file line number Diff line number Diff line change
Expand Up @@ -2464,7 +2464,7 @@ span.badge {
font-weight: normal;
font-style: normal; }

[class^="mdi-"], .select-wrapper span.select-dropdown:after, [class*=" mdi-"] {
[class^="mdi-"], [class*=" mdi-"] {
font-family: "Material-Design-Icons";
speak: none;
font-style: normal;
Expand Down Expand Up @@ -4455,7 +4455,7 @@ span.badge {
.mdi-navigation-arrow-back:before {
content: "\e893"; }

.mdi-navigation-arrow-drop-down:before, .select-wrapper span.select-dropdown:after {
.mdi-navigation-arrow-drop-down:before {
content: "\e894"; }

.mdi-navigation-arrow-drop-down-circle:before {
Expand Down Expand Up @@ -5686,7 +5686,7 @@ ul.tabs li.tab {
font-size: 1.2rem;
color: rgba(0, 0, 0, 0.87);
line-height: 1.5rem; }
.dropdown-content li:hover {
.dropdown-content li:hover, .dropdown-content li.active {
background-color: rgba(0, 0, 0, 0.06); }
.dropdown-content li > a, .dropdown-content li > span {
display: block;
Expand Down Expand Up @@ -6363,25 +6363,27 @@ input[type=checkbox]:first-child ~ .lever:active:after, input[type=checkbox][dis
/***************
Select Field
***************/
.select-wrapper span.select-dropdown {
position: relative;
cursor: pointer;
color: #444;
background-color: transparent;
border: none;
border-bottom: 1px solid #9e9e9e;
outline: none;
height: 3rem;
line-height: 3rem;
width: 100%;
font-size: 1rem;
margin: 0 0 15px 0;
padding: 0;
display: block;
.select-wrapper {
position: relative; }
.select-wrapper span.select-dropdown:after {
.select-wrapper input.select-dropdown {
position: relative;
cursor: pointer;
color: #444;
background-color: transparent;
border: none;
border-bottom: 1px solid #9e9e9e;
outline: none;
height: 3rem;
line-height: 3rem;
width: 100%;
font-size: 1rem;
margin: 0 0 15px 0;
padding: 0;
display: block; }
.select-wrapper .mdi-navigation-arrow-drop-down {
position: absolute;
right: 0;
top: 0;
font-size: 23px; }

select {
Expand All @@ -6393,7 +6395,7 @@ select.browser-default {
select:disabled {
color: rgba(0, 0, 0, 0.3); }

.select-wrapper span.select-dropdown.disabled {
.select-wrapper input.select-dropdown.disabled {
color: rgba(0, 0, 0, 0.3); }

.select-dropdown li.disabled {
Expand Down
6 changes: 3 additions & 3 deletions bin/materialize.js

Large diffs are not rendered by default.

42 changes: 22 additions & 20 deletions css/ghpages-materialize.css
Original file line number Diff line number Diff line change
Expand Up @@ -2464,7 +2464,7 @@ span.badge {
font-weight: normal;
font-style: normal; }

[class^="mdi-"], .select-wrapper span.select-dropdown:after, [class*=" mdi-"] {
[class^="mdi-"], [class*=" mdi-"] {
font-family: "Material-Design-Icons";
speak: none;
font-style: normal;
Expand Down Expand Up @@ -4455,7 +4455,7 @@ span.badge {
.mdi-navigation-arrow-back:before {
content: "\e893"; }

.mdi-navigation-arrow-drop-down:before, .select-wrapper span.select-dropdown:after {
.mdi-navigation-arrow-drop-down:before {
content: "\e894"; }

.mdi-navigation-arrow-drop-down-circle:before {
Expand Down Expand Up @@ -5686,7 +5686,7 @@ ul.tabs li.tab {
font-size: 1.2rem;
color: rgba(0, 0, 0, 0.87);
line-height: 1.5rem; }
.dropdown-content li:hover {
.dropdown-content li:hover, .dropdown-content li.active {
background-color: rgba(0, 0, 0, 0.06); }
.dropdown-content li > a, .dropdown-content li > span {
display: block;
Expand Down Expand Up @@ -6363,25 +6363,27 @@ input[type=checkbox]:first-child ~ .lever:active:after, input[type=checkbox][dis
/***************
Select Field
***************/
.select-wrapper span.select-dropdown {
position: relative;
cursor: pointer;
color: #444;
background-color: transparent;
border: none;
border-bottom: 1px solid #9e9e9e;
outline: none;
height: 3rem;
line-height: 3rem;
width: 100%;
font-size: 1rem;
margin: 0 0 15px 0;
padding: 0;
display: block;
.select-wrapper {
position: relative; }
.select-wrapper span.select-dropdown:after {
.select-wrapper input.select-dropdown {
position: relative;
cursor: pointer;
color: #444;
background-color: transparent;
border: none;
border-bottom: 1px solid #9e9e9e;
outline: none;
height: 3rem;
line-height: 3rem;
width: 100%;
font-size: 1rem;
margin: 0 0 15px 0;
padding: 0;
display: block; }
.select-wrapper .mdi-navigation-arrow-drop-down {
position: absolute;
right: 0;
top: 0;
font-size: 23px; }

select {
Expand All @@ -6393,7 +6395,7 @@ select.browser-default {
select:disabled {
color: rgba(0, 0, 0, 0.3); }

.select-wrapper span.select-dropdown.disabled {
.select-wrapper input.select-dropdown.disabled {
color: rgba(0, 0, 0, 0.3); }

.select-dropdown li.disabled {
Expand Down
58 changes: 30 additions & 28 deletions js/dropdown.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
(function ($) {

// Add posibility to scroll to selected option
// usefull for select for example
$.fn.scrollTo = function(elem) {
$(this).scrollTop($(this).scrollTop() - $(this).offset().top + $(elem).offset().top);
return this;
};

$.fn.dropdown = function (options) {
var defaults = {
inDuration: 300,
Expand Down Expand Up @@ -103,6 +110,22 @@
return isFixed;
}

function hideDropdown() {
activates.velocity(
{
opacity: 0
},
{
duration: options.outDuration,
easing: 'easeOutQuad',
complete: function(){
activates.css({
display: 'none',
'overflow-y': ''
});
}
});
}

// Hover
if (options.hover) {
Expand All @@ -113,20 +136,7 @@

// Document click handler
activates.on('mouseleave', function(e){ // Mouse out
activates.velocity(
{
opacity: 0
},
{
duration: options.outDuration,
easing: 'easeOutQuad',
complete: function(){
activates.css({
display: 'none',
'overflow-y': ''
});
}
});
hideDropdown();
});

// Click
Expand All @@ -140,30 +150,22 @@
placeDropdown();
$(document).bind('click.'+ activates.attr('id'), function (e) {
if (!activates.is(e.target) && (!origin.is(e.target))) {
activates.velocity({
opacity: 0
},
{
duration: options.outDuration,
easing: 'easeOutQuad',
complete: function(){
activates.css({
display: 'none',
'overflow-y': ''
});
}
});
hideDropdown();
$(document).unbind('click.' + activates.attr('id'));
}
});
});

} // End else

// Listen to open and close event - usefull for select component
origin.on('open', placeDropdown);
origin.on('close', hideDropdown);

// Window Resize Reposition
$(document).on('resize', function(){

});
});
}; // End dropdown plugin
}( jQuery ));
}( jQuery ));
Loading