Browse Source

Fixes placeholder value in select multiple

pull/2034/head
jlukic 9 years ago
parent
commit
4fc448ed47
2 changed files with 30 additions and 22 deletions
  1. 42
      src/definitions/modules/dropdown.js
  2. 10
      src/definitions/modules/dropdown.less

42
src/definitions/modules/dropdown.js

@ -580,7 +580,7 @@ $.fn.dropdown = function(parameters) {
} }
}, },
input: function(event) { input: function(event) {
if(module.is.searchSelection()) {
if(module.is.multiple() || module.is.searchSelection()) {
module.set.filtered(); module.set.filtered();
} }
clearTimeout(module.timer); clearTimeout(module.timer);
@ -1090,7 +1090,7 @@ $.fn.dropdown = function(parameters) {
? preserveHTML ? preserveHTML
: settings.preserveHTML : settings.preserveHTML
; ;
if($choice !== undefined) {
if($choice) {
if($choice.find(selector.menu).length > 0) { if($choice.find(selector.menu).length > 0) {
module.verbose('Retreiving text of element with sub-menu'); module.verbose('Retreiving text of element with sub-menu');
$choice = $choice.clone(); $choice = $choice.clone();
@ -1107,6 +1107,9 @@ $.fn.dropdown = function(parameters) {
}, },
choiceValue: function($choice, choiceText) { choiceValue: function($choice, choiceText) {
choiceText = choiceText || module.get.choiceText($choice); choiceText = choiceText || module.get.choiceText($choice);
if(!$choice) {
return false;
}
return ($choice.data(metadata.value) !== undefined) return ($choice.data(metadata.value) !== undefined)
? $choice.data(metadata.value) ? $choice.data(metadata.value)
: (typeof choiceText === 'string') : (typeof choiceText === 'string')
@ -1278,14 +1281,10 @@ $.fn.dropdown = function(parameters) {
}, },
clear: function() { clear: function() {
var
placeholderText = $module.data(metadata.placeholderText)
;
module.set.text(placeholderText);
module.set.placeholderText();
module.clearValue(); module.clearValue();
module.remove.activeItem(); module.remove.activeItem();
module.remove.selectedItem(); module.remove.selectedItem();
$text.addClass(className.placeholder);
}, },
clearValue: function() { clearValue: function() {
@ -1306,10 +1305,16 @@ $.fn.dropdown = function(parameters) {
$search.css('width', searchWidth); $search.css('width', searchWidth);
} }
} }
else {
else if( !module.is.multiple() || module.is.multiple() && $input.val() == '') {
$text.removeClass(className.filtered); $text.removeClass(className.filtered);
} }
}, },
placeholderText: function(text) {
module.debug('Restoring placeholder text');
text = text || $module.data(metadata.placeholderText);
module.set.text(placeholderText);
$text.addClass(className.placeholder);
},
tabbable: function() { tabbable: function() {
if( module.has.search() ) { if( module.has.search() ) {
module.debug('Searchable dropdown initialized'); module.debug('Searchable dropdown initialized');
@ -1375,16 +1380,7 @@ $.fn.dropdown = function(parameters) {
} }
}, },
text: function(text) { text: function(text) {
if(settings.action == 'combo') {
module.debug('Changing combo button text', text, $combo);
if(settings.preserveHTML) {
$combo.html(text);
}
else {
$combo.text(text);
}
}
else if(settings.action !== 'select') {
if(settings.action !== 'select') {
module.debug('Changing text', text, $text); module.debug('Changing text', text, $text);
$text $text
.removeClass(className.filtered) .removeClass(className.filtered)
@ -1397,6 +1393,15 @@ $.fn.dropdown = function(parameters) {
$text.text(text); $text.text(text);
} }
} }
else if(settings.action == 'combo') {
module.debug('Changing combo button text', text, $combo);
if(settings.preserveHTML) {
$combo.html(text);
}
else {
$combo.text(text);
}
}
}, },
value: function(value, text, $selected) { value: function(value, text, $selected) {
var var
@ -1557,6 +1562,7 @@ $.fn.dropdown = function(parameters) {
} }
if(module.is.multiple()) { if(module.is.multiple()) {
module.remove.label(selectedValue); module.remove.label(selectedValue);
module.set.filtered();
} }
$selectedItem $selectedItem
.removeClass(className.active) .removeClass(className.active)

10
src/definitions/modules/dropdown.less

@ -616,18 +616,20 @@ select.ui.dropdown {
/* Prompt Text */ /* Prompt Text */
.ui.multiple.dropdown > .text { .ui.multiple.dropdown > .text {
display: none;
position: absolute; position: absolute;
top: auto;
left: auto;
top: 0;
left: 0;
padding: inherit;
margin: @multipleSelectionSearchMargin;
line-height: @searchSelectionLineHeight;
} }
/* Input */ /* Input */
.ui.multiple.selection.dropdown > input.search { .ui.multiple.selection.dropdown > input.search {
position: static; position: static;
padding: 0; padding: 0;
width: @multipleSelectionSearchWidth;
max-width: 100%; max-width: 100%;
width: @multipleSelectionSearchWidth;
margin: @multipleSelectionSearchMargin; margin: @multipleSelectionSearchMargin;
} }

Loading…
Cancel
Save