summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author文翼 <wenzhixin2010@gmail.com>2014-04-03 09:58:27 +0800
committer文翼 <wenzhixin2010@gmail.com>2014-04-03 09:58:27 +0800
commit392d3e10f3714c06977a50b8043844dc1e6a83b4 (patch)
treefdcf04715ff507fd10d1625090749eb396be85ff
parent3fe8e29e0ac6a0196853f4d7dda726a58b7f5be4 (diff)
parent11bfeb94e4af81bc8bd89d2b37efae828ab65680 (diff)
downloadmultiple-select-392d3e10f3714c06977a50b8043844dc1e6a83b4.zip
multiple-select-392d3e10f3714c06977a50b8043844dc1e6a83b4.tar.gz
multiple-select-392d3e10f3714c06977a50b8043844dc1e6a83b4.tar.bz2
Merge pull request #54 from jonagoldman/master
Added 3 new options: 'allSelected', 'minumimCountSelected' and 'countSelected'
-rw-r--r--jquery.multiple.select.js21
1 files changed, 13 insertions, 8 deletions
diff --git a/jquery.multiple.select.js b/jquery.multiple.select.js
index 456c41f..8522191 100644
--- a/jquery.multiple.select.js
+++ b/jquery.multiple.select.js
@@ -39,12 +39,12 @@
}
if (($(e.target)[0] === that.$drop[0] ||
$(e.target).parents('.ms-drop')[0] !== that.$drop[0]) &&
- that.options.isopen) {
+ that.options.isOpen) {
that.close();
}
});
- if (this.options.isopen) {
+ if (this.options.isOpen) {
this.open();
}
}
@@ -140,7 +140,7 @@
events: function() {
var that = this;
this.$choice.off('click').on('click', function() {
- that[that.options.isopen ? 'close' : 'open']();
+ that[that.options.isOpen ? 'close' : 'open']();
})
.off('focus').on('focus', this.options.onFocus)
.off('blur').on('blur', this.options.onBlur);
@@ -198,7 +198,7 @@
if (this.$choice.hasClass('disabled')) {
return;
}
- this.options.isopen = true;
+ this.options.isOpen = true;
this.$choice.find('>div').addClass('open');
this.$drop.show();
if (this.options.container) {
@@ -214,7 +214,7 @@
},
close: function() {
- this.options.isopen = false;
+ this.options.isOpen = false;
this.$choice.find('>div').removeClass('open');
this.$drop.hide();
if (this.options.container) {
@@ -230,8 +230,10 @@
update: function() {
var selects = this.getSelects('text'),
$span = this.$choice.find('>span');
- if(selects.length == this.$selectItems.length && this.options.overrideButtonText) {
- $span.removeClass('placeholder').html(this.options.selectAllText);
+ if (selects.length == this.$selectItems.length && this.options.allSelected) {
+ $span.removeClass('placeholder').html(this.options.allSelected);
+ } else if (selects.length > this.options.minumimCountSelected && this.options.countSelected) {
+ $span.removeClass('placeholder').html(this.options.countSelected.replace('#', selects.length).replace('%', this.$selectItems.length));
} else if (selects.length) {
$span.removeClass('placeholder').html(selects.join(', '));
} else {
@@ -416,10 +418,13 @@
};
$.fn.multipleSelect.defaults = {
- isopen: false,
+ isOpen: false,
placeholder: '',
selectAll: true,
selectAllText: 'Select all',
+ allSelected: 'All selected', // false or string
+ minumimCountSelected: 3, // int - 'countSelectedText' will be shown only if more than X items where selected
+ countSelected: '# of % selected', // false or string - '#' is replaced with the count of selected items, '%' is replaces with total items
multiple: false,
multipleWidth: 80,
single: false,