Skip to content

Commit

Permalink
#2689 #2690 Fixes issues with restore defaults. Fixes issues with con…
Browse files Browse the repository at this point in the history
…fusion over set selected
  • Loading branch information
jlukic committed Jul 21, 2015
1 parent ff74fb8 commit 46b5d53
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions src/definitions/modules/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -1441,10 +1441,16 @@ $.fn.dropdown = function(parameters) {
};
},
value: function() {
return ($input.length > 0)
? $input.val()
: $module.data(metadata.value)
var
value = ($input.length > 0)
? $input.val()
: $module.data(metadata.value)
;
// prevents placeholder element from being selected when multiple
if($.isArray(value) && value.length === 1 && value[0] === '') {
return '';
}
return value;
},
values: function() {
var
Expand Down Expand Up @@ -2099,7 +2105,6 @@ $.fn.dropdown = function(parameters) {
module.debug('Adding user option', value);
module.add.optionValue(value);
}

module.debug('Updating input value', value, currentValue);
$input
.val(value)
Expand Down Expand Up @@ -2130,6 +2135,11 @@ $.fn.dropdown = function(parameters) {
visible: function() {
$module.addClass(className.visible);
},
exactly: function(value, $selectedItem) {
module.debug('Setting selected to exact values');
module.clear();
module.set.selected(value, $selectedItem);
},
selected: function(value, $selectedItem) {
var
isMultiple = module.is.multiple(),
Expand Down Expand Up @@ -2529,26 +2539,13 @@ $.fn.dropdown = function(parameters) {
module.verbose('Removed value from delimited string', removedValue, values);
return values;
},
label: function(value) {
label: function(value, shouldAnimate) {
var
$labels = $module.find(selector.label),
$removedLabel = $labels.filter('[data-value="' + value +'"]'),
labelCount = $labels.length,
isLastLabel = ($labels.index($removedLabel) + 1 == labelCount),
shouldAnimate = ( (!module.is.searchSelection() || !module.is.focusedOnSearch()) && isLastLabel)
;
if(shouldAnimate) {
module.verbose('Animating and removing label', $removedLabel);
$removedLabel
.transition(settings.label.transition, settings.label.duration, function() {
$removedLabel.remove();
})
;
}
else {
module.verbose('Removing label', $removedLabel);
$removedLabel.remove();
}
$removedLabel = $labels.filter('[data-value="' + value +'"]')
;
module.verbose('Removing label', $removedLabel);
$removedLabel.remove();
},
activeLabels: function($activeLabels) {
$activeLabels = $activeLabels || $module.find(selector.label).filter('.' + className.active);
Expand Down

0 comments on commit 46b5d53

Please sign in to comment.