Skip to content
This repository was archived by the owner on Jan 24, 2024. It is now read-only.

Commit c852067

Browse files
committed
Change single option to singleSelect and revert changes to multiple option
1 parent 418bd1d commit c852067

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

multiple-select.js

+15-13
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
var that = this,
128128
name = $el.attr('name') || options.name || '';
129129

130-
options.single = $el.prop('multiple') ? false : true;
130+
options.singleSelect = $el.prop('multiple') ? false : true;
131131

132132
this.options = options;
133133

@@ -143,7 +143,7 @@
143143
// restore class and title from select element
144144
this.$parent = $(sprintf(
145145
'<div class="ms-parent %s %s" %s/>',
146-
options.single ? 'ms-parent-single' : 'ms-parent-multiple',
146+
options.singleSelect ? 'ms-parent-single' : 'ms-parent-multiple',
147147
$el.attr('class') || '',
148148
sprintf('title="%s"', $el.attr('title'))));
149149

@@ -206,7 +206,7 @@
206206
);
207207
}
208208

209-
if (this.options.selectAll && !this.options.single) {
209+
if (this.options.selectAll && !this.options.singleSelect) {
210210
$ul.append([
211211
'<li class="ms-select-all">',
212212
'<label>',
@@ -273,9 +273,10 @@
273273
$elm = $(elm),
274274
classes = $elm.attr('class') || '',
275275
title = sprintf('title="%s"', $elm.attr('title')),
276-
multiple = this.options.single ? 'single' : 'multiple',
276+
multiple = this.options.multiple ? 'multiple' : '',
277+
singleSelect = this.options.singleSelect ? 'single': '',
277278
disabled,
278-
type = this.options.single ? 'radio' : 'checkbox';
279+
type = this.options.singleSelect ? 'radio' : 'checkbox';
279280

280281
if ($elm.is('option')) {
281282
var value = $elm.val(),
@@ -290,7 +291,7 @@
290291
disabled = groupDisabled || $elm.prop('disabled');
291292

292293
$el = $([
293-
sprintf('<li class="%s %s" %s %s>', multiple, classes, title, style),
294+
sprintf('<li class="%s %s %s" %s %s>', multiple, singleSelect, classes, title, style),
294295
sprintf('<label class="%s">', disabled ? 'disabled' : ''),
295296
sprintf('<input type="%s" %s%s%s%s%s>',
296297
type, this.selectItemName,
@@ -323,11 +324,11 @@
323324

324325
$group.append([
325326
'<li class="group">',
326-
sprintf('<label class="optgroup %s %s" data-group="%s">', disabled ? 'disabled' : '', this.options.hideOptgroupCheckboxes || this.options.single ? 'hide-control' : '', group),
327-
this.options.hideOptgroupCheckboxes || this.options.single ? '' :
327+
sprintf('<label class="optgroup %s %s" data-group="%s">', disabled ? 'disabled' : '', this.options.hideOptgroupCheckboxes || this.options.singleSelect ? 'hide-control' : '', group),
328+
this.options.hideOptgroupCheckboxes || this.options.singleSelect ? '' :
328329
sprintf('<input type="checkbox" %s %s>',
329330
this.selectGroupName, disabled ? 'disabled="disabled"' : ''),
330-
this.options.hideOptgroupCheckboxes || this.options.single ? '' :
331+
this.options.hideOptgroupCheckboxes || this.options.singleSelect ? '' :
331332
'<span class="ms-control-indicator"></span>',
332333
label,
333334
'</label>',
@@ -451,7 +452,7 @@
451452
});
452453
});
453454
this.$selectItems.off('click').on('click', function () {
454-
if (that.options.single && $(this).parents('li').hasClass('selected') && $(this).is(':checked')) {
455+
if (that.options.singleSelect && $(this).parents('li').hasClass('selected') && $(this).is(':checked')) {
455456
if (that.options.isOpen && !that.options.keepOpen) that.close();
456457
return;
457458
}
@@ -460,7 +461,7 @@
460461
that.update();
461462
that.updateOptGroupSelect();
462463

463-
if (that.options.single) {
464+
if (that.options.singleSelect) {
464465
var clickedVal = $(this).val();
465466
that.$allControlItems.filter(function() {
466467
return $(this).val() !== clickedVal;
@@ -477,7 +478,7 @@
477478
instance: that
478479
});
479480

480-
if (that.options.single && that.options.isOpen && !that.options.keepOpen) {
481+
if (that.options.singleSelect && that.options.isOpen && !that.options.keepOpen) {
481482
that.close();
482483
}
483484
});
@@ -817,8 +818,9 @@
817818
selectAllDelimiter: ['[', ']'],
818819
minimumCountSelected: 3,
819820
ellipsis: false,
821+
multiple: false,
820822
multipleWidth: 80,
821-
single: false,
823+
singleSelect: false,
822824
filter: false,
823825
width: undefined,
824826
dropWidth: undefined,

0 commit comments

Comments
 (0)