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

10
src/definitions/modules/dropdown.less

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

Loading…
Cancel
Save