|
@ -278,6 +278,9 @@ $.fn.dropdown = function(parameters) { |
|
|
} |
|
|
} |
|
|
if( module.can.show() && !module.is.active() ) { |
|
|
if( module.can.show() && !module.is.active() ) { |
|
|
module.debug('Showing dropdown'); |
|
|
module.debug('Showing dropdown'); |
|
|
|
|
|
if(module.is.multiple()) { |
|
|
|
|
|
module.filterActive(); |
|
|
|
|
|
} |
|
|
module.animate.show(function() { |
|
|
module.animate.show(function() { |
|
|
if( module.can.click() ) { |
|
|
if( module.can.click() ) { |
|
|
module.bind.intent(); |
|
|
module.bind.intent(); |
|
@ -357,6 +360,11 @@ $.fn.dropdown = function(parameters) { |
|
|
.on('blur' + eventNamespace, selector.search, module.event.searchBlur) |
|
|
.on('blur' + eventNamespace, selector.search, module.event.searchBlur) |
|
|
.on('click' + eventNamespace, selector.text, module.event.searchTextFocus) |
|
|
.on('click' + eventNamespace, selector.text, module.event.searchTextFocus) |
|
|
; |
|
|
; |
|
|
|
|
|
if(module.is.multiple()) { |
|
|
|
|
|
$module |
|
|
|
|
|
.on('click' + eventNamespace, module.event.click) |
|
|
|
|
|
; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
if(settings.on == 'click') { |
|
|
if(settings.on == 'click') { |
|
@ -450,6 +458,9 @@ $.fn.dropdown = function(parameters) { |
|
|
.not($results) |
|
|
.not($results) |
|
|
.addClass(className.filtered) |
|
|
.addClass(className.filtered) |
|
|
; |
|
|
; |
|
|
|
|
|
if(module.is.multiple()) { |
|
|
|
|
|
module.filterActive(); |
|
|
|
|
|
} |
|
|
module.verbose('Selecting first non-filtered element'); |
|
|
module.verbose('Selecting first non-filtered element'); |
|
|
module.remove.selectedItem(); |
|
|
module.remove.selectedItem(); |
|
|
$item |
|
|
$item |
|
@ -466,6 +477,12 @@ $.fn.dropdown = function(parameters) { |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
filterActive: function() { |
|
|
|
|
|
$item.filter('.' + className.active) |
|
|
|
|
|
.addClass(className.filtered) |
|
|
|
|
|
; |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
focusSearch: function() { |
|
|
focusSearch: function() { |
|
|
if( module.is.search() ) { |
|
|
if( module.is.search() ) { |
|
|
$search |
|
|
$search |
|
@ -483,7 +500,7 @@ $.fn.dropdown = function(parameters) { |
|
|
: $activeItem, |
|
|
: $activeItem, |
|
|
hasSelected = ($selectedItem.size() > 0) |
|
|
hasSelected = ($selectedItem.size() > 0) |
|
|
; |
|
|
; |
|
|
if(hasSelected) { |
|
|
|
|
|
|
|
|
if(hasSelected && !module.is.multiple()) { |
|
|
module.event.item.click.call($selectedItem); |
|
|
module.event.item.click.call($selectedItem); |
|
|
module.remove.filteredItem(); |
|
|
module.remove.filteredItem(); |
|
|
} |
|
|
} |
|
@ -493,6 +510,12 @@ $.fn.dropdown = function(parameters) { |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
event: { |
|
|
event: { |
|
|
|
|
|
click: function(event) { |
|
|
|
|
|
// focus search
|
|
|
|
|
|
if($(event.target).is($module) && !(document.activeElement === $search[0])) { |
|
|
|
|
|
$search.focus(); |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
// prevents focus callback from occuring on mousedown
|
|
|
// prevents focus callback from occuring on mousedown
|
|
|
mousedown: function() { |
|
|
mousedown: function() { |
|
|
activated = true; |
|
|
activated = true; |
|
@ -1243,12 +1266,16 @@ $.fn.dropdown = function(parameters) { |
|
|
selected: function(value) { |
|
|
selected: function(value) { |
|
|
var |
|
|
var |
|
|
$selectedItem = module.get.item(value), |
|
|
$selectedItem = module.get.item(value), |
|
|
|
|
|
isMultiple = module.is.multiple(), |
|
|
|
|
|
shouldAnimate = (isMultiple && $selectedItem.length == 1), |
|
|
selectedText, |
|
|
selectedText, |
|
|
selectedValue |
|
|
selectedValue |
|
|
; |
|
|
; |
|
|
if($selectedItem && !$selectedItem.hasClass(className.active) ) { |
|
|
if($selectedItem && !$selectedItem.hasClass(className.active) ) { |
|
|
module.debug('Setting selected menu item to', $selectedItem); |
|
|
module.debug('Setting selected menu item to', $selectedItem); |
|
|
module.remove.activeItem(); |
|
|
|
|
|
|
|
|
if(!module.is.multiple()) { |
|
|
|
|
|
module.remove.activeItem(); |
|
|
|
|
|
} |
|
|
module.remove.selectedItem(); |
|
|
module.remove.selectedItem(); |
|
|
$selectedItem |
|
|
$selectedItem |
|
|
.addClass(className.active) |
|
|
.addClass(className.active) |
|
@ -1259,8 +1286,8 @@ $.fn.dropdown = function(parameters) { |
|
|
; |
|
|
; |
|
|
selectedText = module.get.choiceText($selected); |
|
|
selectedText = module.get.choiceText($selected); |
|
|
selectedValue = module.get.choiceValue($selected, selectedText); |
|
|
selectedValue = module.get.choiceValue($selected, selectedText); |
|
|
if(module.is.multiple()) { |
|
|
|
|
|
module.add.label(selectedValue, selectedText); |
|
|
|
|
|
|
|
|
if(isMultiple) { |
|
|
|
|
|
module.add.label(selectedValue, selectedText, shouldAnimate); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
module.set.text(selectedText); |
|
|
module.set.text(selectedText); |
|
@ -1274,18 +1301,30 @@ $.fn.dropdown = function(parameters) { |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
add: { |
|
|
add: { |
|
|
label: function(value, text) { |
|
|
|
|
|
|
|
|
label: function(value, text, shouldAnimate) { |
|
|
var |
|
|
var |
|
|
$label = $('<a />') |
|
|
$label = $('<a />') |
|
|
.addClass(className.label) |
|
|
.addClass(className.label) |
|
|
.data('value', value) |
|
|
|
|
|
|
|
|
.attr('data-value', value) |
|
|
.html(text + '<i class="delete icon"></i>') |
|
|
.html(text + '<i class="delete icon"></i>') |
|
|
; |
|
|
; |
|
|
if(settings.label.variation) { |
|
|
if(settings.label.variation) { |
|
|
$label.addClass(settings.label.variation); |
|
|
$label.addClass(settings.label.variation); |
|
|
} |
|
|
} |
|
|
module.debug('Adding selection label', $label); |
|
|
|
|
|
$label.insertBefore($search); |
|
|
|
|
|
|
|
|
if(shouldAnimate) { |
|
|
|
|
|
module.debug('Animating in label', $label); |
|
|
|
|
|
$label |
|
|
|
|
|
.addClass(className.hidden) |
|
|
|
|
|
.insertBefore($search) |
|
|
|
|
|
.transition(settings.label.transition, settings.label.duration) |
|
|
|
|
|
; |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
module.debug('Adding selection label', $label); |
|
|
|
|
|
$label |
|
|
|
|
|
.insertBefore($search) |
|
|
|
|
|
; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
@ -1308,6 +1347,15 @@ $.fn.dropdown = function(parameters) { |
|
|
selectedItem: function() { |
|
|
selectedItem: function() { |
|
|
$item.removeClass(className.selected); |
|
|
$item.removeClass(className.selected); |
|
|
}, |
|
|
}, |
|
|
|
|
|
label: function(value) { |
|
|
|
|
|
$module |
|
|
|
|
|
.find(selector.label) |
|
|
|
|
|
.filter('[data-value="' + value +'"]') |
|
|
|
|
|
.transition(settings.label.transition, settings.label.duration, function() { |
|
|
|
|
|
$(this).remove(); |
|
|
|
|
|
}) |
|
|
|
|
|
; |
|
|
|
|
|
}, |
|
|
tabbable: function() { |
|
|
tabbable: function() { |
|
|
if( module.has.search() ) { |
|
|
if( module.has.search() ) { |
|
|
module.debug('Searchable dropdown initialized'); |
|
|
module.debug('Searchable dropdown initialized'); |
|
@ -1424,7 +1472,9 @@ $.fn.dropdown = function(parameters) { |
|
|
? callback |
|
|
? callback |
|
|
: function(){} |
|
|
: function(){} |
|
|
; |
|
|
; |
|
|
module.set.scrollPosition(module.get.activeItem(), true); |
|
|
|
|
|
|
|
|
if(!module.is.multiple()) { |
|
|
|
|
|
module.set.scrollPosition(module.get.activeItem(), true); |
|
|
|
|
|
} |
|
|
module.verbose('Doing menu show animation', $currentMenu); |
|
|
module.verbose('Doing menu show animation', $currentMenu); |
|
|
if( module.is.hidden($currentMenu) || module.is.animating($currentMenu) ) { |
|
|
if( module.is.hidden($currentMenu) || module.is.animating($currentMenu) ) { |
|
|
|
|
|
|
|
@ -1786,7 +1836,9 @@ $.fn.dropdown.settings = { |
|
|
sortSelect : false, |
|
|
sortSelect : false, |
|
|
|
|
|
|
|
|
label: { |
|
|
label: { |
|
|
variation: false |
|
|
|
|
|
|
|
|
transition : 'horizontal flip', |
|
|
|
|
|
duration : 250, |
|
|
|
|
|
variation : false |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
allowCategorySelection : false, |
|
|
allowCategorySelection : false, |
|
@ -1798,10 +1850,10 @@ $.fn.dropdown.settings = { |
|
|
touch : 50 |
|
|
touch : 50 |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
forceSelection: true, |
|
|
|
|
|
|
|
|
forceSelection : true, |
|
|
|
|
|
|
|
|
transition : 'auto', |
|
|
|
|
|
duration : 250, |
|
|
|
|
|
|
|
|
transition : 'auto', |
|
|
|
|
|
duration : 250, |
|
|
|
|
|
|
|
|
/* Callbacks */ |
|
|
/* Callbacks */ |
|
|
onNoResults : function(searchTerm){}, |
|
|
onNoResults : function(searchTerm){}, |
|
@ -1833,6 +1885,7 @@ $.fn.dropdown.settings = { |
|
|
dropdown : '.ui.dropdown', |
|
|
dropdown : '.ui.dropdown', |
|
|
input : '> input[type="hidden"], > select', |
|
|
input : '> input[type="hidden"], > select', |
|
|
item : '.item', |
|
|
item : '.item', |
|
|
|
|
|
label : '> .label', |
|
|
menu : '.menu', |
|
|
menu : '.menu', |
|
|
menuIcon : '.dropdown.icon', |
|
|
menuIcon : '.dropdown.icon', |
|
|
search : 'input.search, .menu > .search > input', |
|
|
search : 'input.search, .menu > .search > input', |
|
@ -1845,6 +1898,7 @@ $.fn.dropdown.settings = { |
|
|
disabled : 'disabled', |
|
|
disabled : 'disabled', |
|
|
dropdown : 'ui dropdown', |
|
|
dropdown : 'ui dropdown', |
|
|
filtered : 'filtered', |
|
|
filtered : 'filtered', |
|
|
|
|
|
hidden : 'hidden transition', |
|
|
label : 'ui label', |
|
|
label : 'ui label', |
|
|
loading : 'loading', |
|
|
loading : 'loading', |
|
|
menu : 'menu', |
|
|
menu : 'menu', |
|
|