Skip to content
This repository has been archived by the owner on Jul 13, 2020. It is now read-only.

Commit

Permalink
v2.2.11
Browse files Browse the repository at this point in the history
  • Loading branch information
joshmanders committed Jul 23, 2017
1 parent 2f2eb30 commit 13c499e
Show file tree
Hide file tree
Showing 58 changed files with 3,713 additions and 1,409 deletions.
Binary file modified icons/icons.eot
Binary file not shown.
3,350 changes: 2,668 additions & 682 deletions icons/icons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/icons.ttf
Binary file not shown.
Binary file modified icons/icons.woff
Binary file not shown.
Binary file modified icons/icons.woff2
Binary file not shown.
158 changes: 108 additions & 50 deletions js/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,9 @@ $.fn.dropdown = function(parameters) {
if(module.is.multiple()) {
module.filterActive();
}
module.select.firstUnfiltered();
if(query || (!query && module.get.activeItem().length == 0)) {
module.select.firstUnfiltered();
}
if( module.has.allResultsFiltered() ) {
if( settings.onNoResults.call(element, searchTerm) ) {
if(settings.allowAdditions) {
Expand Down Expand Up @@ -1468,7 +1470,6 @@ $.fn.dropdown = function(parameters) {
// down arrow (open menu)
if(pressedKey == keys.downArrow && !module.is.visible()) {
module.verbose('Down key pressed, showing dropdown');
module.select.firstUnfiltered();
module.show();
event.preventDefault();
}
Expand Down Expand Up @@ -2367,21 +2368,31 @@ $.fn.dropdown = function(parameters) {
},
direction: function($menu) {
if(settings.direction == 'auto') {
if(module.is.onScreen($menu)) {
// reset position
module.remove.upward();

if(module.can.openDownward($menu)) {
module.remove.upward($menu);
}
else {
module.set.upward($menu);
}
if(!module.is.leftward($menu) && !module.can.openRightward($menu)) {
module.set.leftward($menu);
}
}
else if(settings.direction == 'upward') {
module.set.upward($menu);
}
},
upward: function($menu) {
var $element = $menu || $module;
upward: function($currentMenu) {
var $element = $currentMenu || $module;
$element.addClass(className.upward);
},
leftward: function($currentMenu) {
var $element = $currentMenu || $menu;
$element.addClass(className.leftward);
},
value: function(value, text, $selected) {
var
escapedValue = module.escape.value(value),
Expand Down Expand Up @@ -2729,10 +2740,14 @@ $.fn.dropdown = function(parameters) {
initialLoad: function() {
initialLoad = false;
},
upward: function($menu) {
var $element = $menu || $module;
upward: function($currentMenu) {
var $element = $currentMenu || $module;
$element.removeClass(className.upward);
},
leftward: function($currentMenu) {
var $element = $currentMenu || $menu;
$element.removeClass(className.leftward);
},
visible: function() {
$module.removeClass(className.visible);
},
Expand Down Expand Up @@ -3037,6 +3052,10 @@ $.fn.dropdown = function(parameters) {
: $menu.transition && $menu.transition('is animating')
;
},
leftward: function($subMenu) {
var $selectedMenu = $subMenu || $menu;
return $selectedMenu.hasClass(className.leftward);
},
disabled: function() {
return $module.hasClass(className.disabled);
},
Expand All @@ -3055,46 +3074,6 @@ $.fn.dropdown = function(parameters) {
initialLoad: function() {
return initialLoad;
},
onScreen: function($subMenu) {
var
$currentMenu = $subMenu || $menu,
canOpenDownward = true,
onScreen = {},
calculations
;
$currentMenu.addClass(className.loading);
calculations = {
context: {
scrollTop : $context.scrollTop(),
height : $context.outerHeight()
},
menu : {
offset: $currentMenu.offset(),
height: $currentMenu.outerHeight()
}
};
if(module.is.verticallyScrollableContext()) {
calculations.menu.offset.top += calculations.context.scrollTop;
}
onScreen = {
above : (calculations.context.scrollTop) <= calculations.menu.offset.top - calculations.menu.height,
below : (calculations.context.scrollTop + calculations.context.height) >= calculations.menu.offset.top + calculations.menu.height
};
if(onScreen.below) {
module.verbose('Dropdown can fit in context downward', onScreen);
canOpenDownward = true;
}
else if(!onScreen.below && !onScreen.above) {
module.verbose('Dropdown cannot fit in either direction, favoring downward', onScreen);
canOpenDownward = true;
}
else {
module.verbose('Dropdown cannot fit below, opening upward', onScreen);
canOpenDownward = false;
}
$currentMenu.removeClass(className.loading);
return canOpenDownward;
},
inObject: function(needle, object) {
var
found = false
Expand Down Expand Up @@ -3157,6 +3136,14 @@ $.fn.dropdown = function(parameters) {
: false
;
return (overflowY == 'auto' || overflowY == 'scroll');
},
horizontallyScrollableContext: function() {
var
overflowX = ($context.get(0) !== window)
? $context.css('overflow-X')
: false
;
return (overflowX == 'auto' || overflowX == 'scroll');
}
},

Expand All @@ -3173,6 +3160,79 @@ $.fn.dropdown = function(parameters) {
}
return false;
},
openDownward: function($subMenu) {
var
$currentMenu = $subMenu || $menu,
canOpenDownward = true,
onScreen = {},
calculations
;
$currentMenu
.addClass(className.loading)
;
calculations = {
context: {
scrollTop : $context.scrollTop(),
height : $context.outerHeight()
},
menu : {
offset: $currentMenu.offset(),
height: $currentMenu.outerHeight()
}
};
if(module.is.verticallyScrollableContext()) {
calculations.menu.offset.top += calculations.context.scrollTop;
}
onScreen = {
above : (calculations.context.scrollTop) <= calculations.menu.offset.top - calculations.menu.height,
below : (calculations.context.scrollTop + calculations.context.height) >= calculations.menu.offset.top + calculations.menu.height
};
if(onScreen.below) {
module.verbose('Dropdown can fit in context downward', onScreen);
canOpenDownward = true;
}
else if(!onScreen.below && !onScreen.above) {
module.verbose('Dropdown cannot fit in either direction, favoring downward', onScreen);
canOpenDownward = true;
}
else {
module.verbose('Dropdown cannot fit below, opening upward', onScreen);
canOpenDownward = false;
}
$currentMenu.removeClass(className.loading);
return canOpenDownward;
},
openRightward: function($subMenu) {
var
$currentMenu = $subMenu || $menu,
canOpenRightward = true,
isOffscreenRight = false,
calculations
;
$currentMenu
.addClass(className.loading)
;
calculations = {
context: {
scrollLeft : $context.scrollLeft(),
width : $context.outerWidth()
},
menu: {
offset : $currentMenu.offset(),
width : $currentMenu.outerWidth()
}
};
if(module.is.horizontallyScrollableContext()) {
calculations.menu.offset.left += calculations.context.scrollLeft;
}
isOffscreenRight = (calculations.menu.offset.left + calculations.menu.width >= calculations.context.scrollLeft + calculations.context.width);
if(isOffscreenRight) {
module.verbose('Dropdown cannot fit in context rightward', isOffscreenRight);
canOpenRightward = false;
}
$currentMenu.removeClass(className.loading);
return canOpenRightward;
},
click: function() {
return (hasTouch || settings.on == 'click');
},
Expand Down Expand Up @@ -3274,9 +3334,6 @@ $.fn.dropdown = function(parameters) {
queue : true,
onStart : start,
onComplete : function() {
if(settings.direction == 'auto') {
module.remove.upward($subMenu);
}
callback.call(element);
}
})
Expand Down Expand Up @@ -3706,6 +3763,7 @@ $.fn.dropdown.settings = {
selected : 'selected',
selection : 'selection',
upward : 'upward',
leftward : 'left',
visible : 'visible'
}

Expand Down
Loading

0 comments on commit 13c499e

Please sign in to comment.