Browse Source

Iterating on multi select completion

pull/2092/head
jlukic 10 years ago
parent
commit
f76eb496c0
3 changed files with 72 additions and 36 deletions
  1. 74
      src/definitions/modules/dropdown.js
  2. 26
      src/definitions/modules/dropdown.less
  3. 8
      src/themes/default/modules/dropdown.variables

74
src/definitions/modules/dropdown.js

@ -367,7 +367,6 @@ $.fn.dropdown = function(parameters) {
module.verbose('Mouse detected binding mouse events'); module.verbose('Mouse detected binding mouse events');
if(module.is.multiple()) { if(module.is.multiple()) {
$module $module
.on('click' + eventNamespace, module.event.click)
.on('click' + eventNamespace, selector.label, module.event.label.click) .on('click' + eventNamespace, selector.label, module.event.label.click)
.on('click' + eventNamespace, selector.remove, module.event.remove.click) .on('click' + eventNamespace, selector.remove, module.event.remove.click)
; ;
@ -548,7 +547,7 @@ $.fn.dropdown = function(parameters) {
event: { event: {
focus: function() { focus: function() {
if(settings.showonFocus && !activated && module.is.hidden()) {
if(settings.showOnFocus && !activated && module.is.hidden()) {
module.show(); module.show();
} }
}, },
@ -658,7 +657,12 @@ $.fn.dropdown = function(parameters) {
}, },
test: { test: {
toggle: function(event) { toggle: function(event) {
if( module.determine.eventOnElement(event, module.toggle) ) {
var
toggleBehavior = (module.is.multiple())
? module.show
: module.toggle
;
if( module.determine.eventOnElement(event, toggleBehavior) ) {
event.preventDefault(); event.preventDefault();
} }
}, },
@ -911,6 +915,7 @@ $.fn.dropdown = function(parameters) {
; ;
if($visibleItems.index( $nextItem ) < 0) { if($visibleItems.index( $nextItem ) < 0) {
module.verbose('Up key pressed but reached top of current menu'); module.verbose('Up key pressed but reached top of current menu');
event.preventDefault();
return; return;
} }
else { else {
@ -934,6 +939,7 @@ $.fn.dropdown = function(parameters) {
; ;
if($nextItem.length === 0) { if($nextItem.length === 0) {
module.verbose('Down key pressed but reached bottom of current menu'); module.verbose('Down key pressed but reached bottom of current menu');
event.preventDefault();
return; return;
} }
else { else {
@ -1032,20 +1038,19 @@ $.fn.dropdown = function(parameters) {
: text : text
; ;
module.set.selected(value, $(this)); module.set.selected(value, $(this));
module.hide(function() {
module.remove.filteredItem();
});
if(module.is.multiple() && !module.is.searchSelection() && !module.is.allFiltered()) {
module.filterActive();
}
else {
module.hide(function() {
module.remove.filteredItem();
});
}
}, },
select: function(text, value) { select: function(text, value) {
value = (value !== undefined)
? value
: text
;
module.set.selected(value, $(this));
module.hide(function() {
module.remove.filteredItem();
});
// mimics action.activate but does not select text
module.action.activate.call(this);
}, },
combo: function(text, value) { combo: function(text, value) {
@ -2107,41 +2112,59 @@ $.fn.dropdown.settings = {
verbose : false, verbose : false,
performance : true, performance : true,
// what event should show menu
on : 'click', on : 'click',
// action on item selection
action : 'activate', action : 'activate',
// add tabindex to element
allowTab : true, allowTab : true,
// show menu on focus
showOnFocus : true, showOnFocus : true,
// search anywhere in value
fullTextSearch : false, fullTextSearch : false,
preserveHTML : true,
sortSelect : false,
label: {
transition : 'horizontal flip',
duration : 250,
variation : false
},
// preserve html when selecting value
preserveHTML : true,
// sort selection on init
sortSelect : false,
// what to match against with search selection (both, text, or label)
match: 'both', match: 'both',
// allow elements with sub-menus to be selected
allowCategorySelection : false, allowCategorySelection : false,
delay : {
// delay before event
delay : {
hide : 300, hide : 300,
show : 200, show : 200,
search : 50, search : 50,
touch : 50 touch : 50
}, },
// force a value selection on search selection
forceSelection : true, forceSelection : true,
// widest glyph width in em (W is 1.0714 em)
// menu transiton
transition : 'auto',
duration : 250,
// widest glyph width in em (W is 1.0714 em) used to calculate multiselect input width
glyphWidth : 1.0714, glyphWidth : 1.0714,
transition : 'auto',
// multi select delimiting key
delimiter : ',', delimiter : ',',
duration : 250,
// label settings on multi-select
label: {
transition : 'horizontal flip',
duration : 250,
variation : false
},
/* Callbacks */ /* Callbacks */
onLabelSelect : function($selectedLabels){}, onLabelSelect : function($selectedLabels){},
@ -2151,7 +2174,6 @@ $.fn.dropdown.settings = {
onHide : function(){}, onHide : function(){},
/* Component */ /* Component */
name : 'Dropdown', name : 'Dropdown',
namespace : 'dropdown', namespace : 'dropdown',

26
src/definitions/modules/dropdown.less

@ -457,6 +457,21 @@ select.ui.dropdown {
box-shadow: @selectionVisibleMenuBoxShadow; box-shadow: @selectionVisibleMenuBoxShadow;
} }
/* Focus */
.ui.selection.dropdown:focus {
border-color: @selectionFocusBorderColor;
box-shadow: @selectionFocusBoxShadow;
}
.ui.selection.dropdown:focus .menu {
border-color: @selectionFocusBorderColor;
box-shadow: @selectionFocusMenuBoxShadow;
}
/* Visible */
.ui.selection.visible.dropdown > .text:not(.default) {
font-weight: @selectionVisibleTextFontWeight;
color: @selectionVisibleTextColor;
}
/* Visible Hover */ /* Visible Hover */
.ui.selection.visible.dropdown:hover { .ui.selection.visible.dropdown:hover {
@ -468,14 +483,6 @@ select.ui.dropdown {
box-shadow: @selectionVisibleHoverMenuBoxShadow; box-shadow: @selectionVisibleHoverMenuBoxShadow;
} }
/* Active Item */
.ui.selection.active.dropdown > .text:not(.default),
.ui.selection.visible.dropdown > .text:not(.default) {
font-weight: @selectionVisibleTextFontWeight;
color: @selectionVisibleTextColor;
}
/* Dropdown Icon */ /* Dropdown Icon */
.ui.active.selection.dropdown > .dropdown.icon, .ui.active.selection.dropdown > .dropdown.icon,
.ui.visible.selection.dropdown > .dropdown.icon { .ui.visible.selection.dropdown > .dropdown.icon {
@ -591,7 +598,7 @@ select.ui.dropdown {
/* Multiple Selection */ /* Multiple Selection */
.ui.multiple.dropdown { .ui.multiple.dropdown {
padding: @multipleSelectionTopPadding @multipleSelectionRightPadding @multipleSelectionBottomPadding @multipleSelectionLeftPadding;
padding: @multipleSelectionPadding;
} }
.ui.multiple.dropdown .menu { .ui.multiple.dropdown .menu {
cursor: auto; cursor: auto;
@ -711,6 +718,7 @@ select.ui.dropdown {
z-index: @activeItemZIndex; z-index: @activeItemZIndex;
} }
/*-------------------- /*--------------------
Default Text Default Text
----------------------*/ ----------------------*/

8
src/themes/default/modules/dropdown.variables

@ -182,6 +182,11 @@
@selectionHoverBorderColor: @selectedBorderColor; @selectionHoverBorderColor: @selectedBorderColor;
@selectionHoverBoxShadow: none; @selectionHoverBoxShadow: none;
/* Hover */
@selectionFocusBorderColor: @selectedBorderColor;
@selectionFocusBoxShadow: none;
@selectionFocusMenuBoxShadow: @raisedShadow;
/* Visible */ /* Visible */
@selectionVisibleTextFontWeight: normal; @selectionVisibleTextFontWeight: normal;
@selectionVisibleTextColor: @hoveredTextColor; @selectionVisibleTextColor: @hoveredTextColor;
@ -226,6 +231,7 @@
@multipleSelectionRightPadding: @selectionIconDistance; @multipleSelectionRightPadding: @selectionIconDistance;
@multipleSelectionBottomPadding: @multipleSelectionTopPadding; @multipleSelectionBottomPadding: @multipleSelectionTopPadding;
@multipleSelectionLeftPadding: (@selectionHorizontalPadding - @labelHorizontalPadding); @multipleSelectionLeftPadding: (@selectionHorizontalPadding - @labelHorizontalPadding);
@multipleSelectionPadding: @multipleSelectionTopPadding @multipleSelectionRightPadding @multipleSelectionBottomPadding @multipleSelectionLeftPadding;
@multipleSelectionInlineMargin: 0.4em 0em 0.4em 0.5em; @multipleSelectionInlineMargin: 0.4em 0em 0.4em 0.5em;
@multipleSelectionInlineLineHeight: @searchSelectionLineHeight; @multipleSelectionInlineLineHeight: @searchSelectionLineHeight;
@ -301,7 +307,7 @@
@upwardSelectionVisibleBoxShadow: 0px 0px 4px 0px rgba(0, 0, 0, 0.08); @upwardSelectionVisibleBoxShadow: 0px 0px 4px 0px rgba(0, 0, 0, 0.08);
@upwardSelectionVisibleHoverBoxShadow: 0px 0px 4px 0px rgba(0, 0, 0, 0.05); @upwardSelectionVisibleHoverBoxShadow: 0px 0px 4px 0px rgba(0, 0, 0, 0.05);
@upwardSelectionVisibleHoverMenuBoxShadow: 0px 0px 4px 0px rgba(0, 0, 0, 0.08); @upwardSelectionVisibleHoverMenuBoxShadow: 0px 0px 4px 0px rgba(0, 0, 0, 0.08);
@upwardSelectionVisibleBorderRadius: @selectionVisibleConnectingBorder @selectionVisibleConnectingBorder @borderRadius @borderRadius;
@upwardSelectionVisibleBorderRadius: @selectionVisibleConnectingBorder @selectionVisibleConnectingBorder @borderRadius @borderRadius;
/* Flyout Direction */ /* Flyout Direction */
@leftMenuDropdownIconFloat: left; @leftMenuDropdownIconFloat: left;

Loading…
Cancel
Save