Commit 2f7761db authored by Tyf0x's avatar Tyf0x

** fix for #430 **

-> Moved the downward chevron to the button template.
-> The button text is now inserted into any container using the class "multiselect-selected-text" inside the button tag.
parent 847873e4
...@@ -139,23 +139,23 @@ ...@@ -139,23 +139,23 @@
*/ */
buttonText: function(options, select) { buttonText: function(options, select) {
if (options.length === 0) { if (options.length === 0) {
return this.nonSelectedText + ' <b class="caret"></b>'; return this.nonSelectedText;
} }
else if (options.length == $('option', $(select)).length) { else if (options.length == $('option', $(select)).length) {
return this.allSelectedText + ' <b class="caret"></b>'; return this.allSelectedText;
} }
else if (options.length > this.numberDisplayed) { else if (options.length > this.numberDisplayed) {
return options.length + ' ' + this.nSelectedText + ' <b class="caret"></b>'; return options.length + ' ' + this.nSelectedText;
} }
else { else {
var selected = ''; var selected = '';
options.each(function() { options.each(function() {
var label = ($(this).attr('label') !== undefined) ? $(this).attr('label') : $(this).html(); var label = ($(this).attr('label') !== undefined) ? $(this).attr('label') : $(this).text();
selected += label + ', '; selected += label + ', ';
}); });
return selected.substr(0, selected.length - 2) + ' <b class="caret"></b>'; return selected.substr(0, selected.length - 2);
} }
}, },
/** /**
...@@ -184,7 +184,7 @@ ...@@ -184,7 +184,7 @@
* @returns {String} * @returns {String}
*/ */
label: function(element){ label: function(element){
return $(element).attr('label') || $(element).html(); return $(element).attr('label') || $(element).text();
}, },
/** /**
* Triggered on change of the multiselect. * Triggered on change of the multiselect.
...@@ -257,7 +257,7 @@ ...@@ -257,7 +257,7 @@
numberDisplayed: 3, numberDisplayed: 3,
disableIfEmpty: false, disableIfEmpty: false,
templates: { templates: {
button: '<button type="button" class="multiselect dropdown-toggle" data-toggle="dropdown"></button>', button: '<button type="button" class="multiselect dropdown-toggle" data-toggle="dropdown"><span class="multiselect-selected-text"></span> <b class="caret"></b></button>',
ul: '<ul class="multiselect-container dropdown-menu"></ul>', ul: '<ul class="multiselect-container dropdown-menu"></ul>',
filter: '<li class="multiselect-item filter"><div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-search"></i></span><input class="form-control multiselect-search" type="text"></div></li>', filter: '<li class="multiselect-item filter"><div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-search"></i></span><input class="form-control multiselect-search" type="text"></div></li>',
filterClearBtn: '<span class="input-group-btn"><button class="btn btn-default multiselect-clear-filter" type="button"><i class="glyphicon glyphicon-remove-circle"></i></button></span>', filterClearBtn: '<span class="input-group-btn"><button class="btn btn-default multiselect-clear-filter" type="button"><i class="glyphicon glyphicon-remove-circle"></i></button></span>',
...@@ -1178,7 +1178,7 @@ ...@@ -1178,7 +1178,7 @@
var options = this.getSelected(); var options = this.getSelected();
// First update the displayed button text. // First update the displayed button text.
$('.multiselect', this.$container).html(this.options.buttonText(options, this.$select)); $('.multiselect .multiselect-selected-text', this.$container).text(this.options.buttonText(options, this.$select));
// Now update the title attribute of the button. // Now update the title attribute of the button.
$('.multiselect', this.$container).attr('title', this.options.buttonTitle(options, this.$select)); $('.multiselect', this.$container).attr('title', this.options.buttonTitle(options, this.$select));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment