bootstrap-multiselect-rails 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +1 -38
- data/lib/bootstrap-multiselect/rails/version.rb +5 -0
- data/lib/rails.rb +8 -0
- data/vendor/assets/javascripts/bootstrap-multiselect.js +107 -98
- metadata +22 -76
- data/README.rdoc +0 -3
- data/lib/bootstrap-multiselect-rails.rb +0 -4
- data/lib/bootstrap-multiselect-rails/version.rb +0 -3
- data/lib/tasks/bootstrap-multiselect-rails_tasks.rake +0 -4
- data/test/bootstrap-multiselect-rails_test.rb +0 -7
- data/test/dummy/README.rdoc +0 -261
- data/test/dummy/Rakefile +0 -7
- data/test/dummy/app/assets/javascripts/application.js +0 -15
- data/test/dummy/app/assets/stylesheets/application.css +0 -13
- data/test/dummy/app/controllers/application_controller.rb +0 -3
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/config.ru +0 -4
- data/test/dummy/config/application.rb +0 -59
- data/test/dummy/config/boot.rb +0 -10
- data/test/dummy/config/database.yml +0 -25
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -37
- data/test/dummy/config/environments/production.rb +0 -67
- data/test/dummy/config/environments/test.rb +0 -37
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/inflections.rb +0 -15
- data/test/dummy/config/initializers/mime_types.rb +0 -5
- data/test/dummy/config/initializers/secret_token.rb +0 -7
- data/test/dummy/config/initializers/session_store.rb +0 -8
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -5
- data/test/dummy/config/routes.rb +0 -58
- data/test/dummy/public/404.html +0 -26
- data/test/dummy/public/422.html +0 -26
- data/test/dummy/public/500.html +0 -25
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +0 -6
- data/test/test_helper.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b61fad2e4a7ae7fd6ea103d630cc1541403e69c
|
4
|
+
data.tar.gz: 82986b14141417ee6ec1fe9db45cd7d9179bf41c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54d6abfd1c2140f5bc5ce0b54fa7558ba8fdae414fa8947feccc558b77d14304032abddb530b68070b23b715a762e959f33613ab2cffe5790d51cdd76169f88d
|
7
|
+
data.tar.gz: 55d9e736173711f2a00c812d41f99ed32d86d6d034f48611868ad024fa1e5d2ca7f8cd5ef674800dd8d82802b8e449d6b0091b39b8644adffc7a6775d3256164
|
data/Rakefile
CHANGED
@@ -1,38 +1 @@
|
|
1
|
-
|
2
|
-
begin
|
3
|
-
require 'bundler/setup'
|
4
|
-
rescue LoadError
|
5
|
-
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
-
end
|
7
|
-
begin
|
8
|
-
require 'rdoc/task'
|
9
|
-
rescue LoadError
|
10
|
-
require 'rdoc/rdoc'
|
11
|
-
require 'rake/rdoctask'
|
12
|
-
RDoc::Task = Rake::RDocTask
|
13
|
-
end
|
14
|
-
|
15
|
-
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
-
rdoc.rdoc_dir = 'rdoc'
|
17
|
-
rdoc.title = 'BootstrapMultiselectRails'
|
18
|
-
rdoc.options << '--line-numbers'
|
19
|
-
rdoc.rdoc_files.include('README.rdoc')
|
20
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
-
end
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
Bundler::GemHelper.install_tasks
|
27
|
-
|
28
|
-
require 'rake/testtask'
|
29
|
-
|
30
|
-
Rake::TestTask.new(:test) do |t|
|
31
|
-
t.libs << 'lib'
|
32
|
-
t.libs << 'test'
|
33
|
-
t.pattern = 'test/**/*_test.rb'
|
34
|
-
t.verbose = false
|
35
|
-
end
|
36
|
-
|
37
|
-
|
38
|
-
task :default => :test
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/rails.rb
ADDED
@@ -73,7 +73,7 @@
|
|
73
73
|
|
74
74
|
/**
|
75
75
|
* Constructor to create a new multiselect using the given select.
|
76
|
-
*
|
76
|
+
*
|
77
77
|
* @param {jQuery} select
|
78
78
|
* @param {Object} options
|
79
79
|
* @returns {Multiselect}
|
@@ -101,10 +101,10 @@
|
|
101
101
|
this.buildDropdown();
|
102
102
|
this.buildDropdownOptions();
|
103
103
|
this.buildFilter();
|
104
|
-
|
104
|
+
|
105
105
|
this.updateButtonText();
|
106
106
|
this.updateSelectAll();
|
107
|
-
|
107
|
+
|
108
108
|
this.$select.hide().after(this.$container);
|
109
109
|
};
|
110
110
|
|
@@ -114,7 +114,7 @@
|
|
114
114
|
/**
|
115
115
|
* Default text function will either print 'None selected' in case no
|
116
116
|
* option is selected or a list of the selected options up to a length of 3 selected options.
|
117
|
-
*
|
117
|
+
*
|
118
118
|
* @param {jQuery} options
|
119
119
|
* @param {jQuery} select
|
120
120
|
* @returns {String}
|
@@ -158,7 +158,7 @@
|
|
158
158
|
},
|
159
159
|
/**
|
160
160
|
* Create a label.
|
161
|
-
*
|
161
|
+
*
|
162
162
|
* @param {jQuery} element
|
163
163
|
* @returns {String}
|
164
164
|
*/
|
@@ -168,7 +168,7 @@
|
|
168
168
|
/**
|
169
169
|
* Triggered on change of the multiselect.
|
170
170
|
* Not triggered when selecting/deselecting options manually.
|
171
|
-
*
|
171
|
+
*
|
172
172
|
* @param {jQuery} option
|
173
173
|
* @param {Boolean} checked
|
174
174
|
*/
|
@@ -177,19 +177,19 @@
|
|
177
177
|
},
|
178
178
|
/**
|
179
179
|
* Triggered when the dropdown is shown.
|
180
|
-
*
|
180
|
+
*
|
181
181
|
* @param {jQuery} event
|
182
182
|
*/
|
183
183
|
onDropdownShow: function(event) {
|
184
|
-
|
184
|
+
|
185
185
|
},
|
186
186
|
/**
|
187
187
|
* Triggered when the dropdown is hidden.
|
188
|
-
*
|
188
|
+
*
|
189
189
|
* @param {jQuery} event
|
190
190
|
*/
|
191
191
|
onDropdownHide: function(event) {
|
192
|
-
|
192
|
+
|
193
193
|
},
|
194
194
|
buttonClass: 'btn btn-default',
|
195
195
|
dropRight: false,
|
@@ -199,7 +199,9 @@
|
|
199
199
|
// Maximum height of the dropdown menu.
|
200
200
|
// If maximum height is exceeded a scrollbar will be displayed.
|
201
201
|
maxHeight: false,
|
202
|
+
checkboxName: 'multiselect',
|
202
203
|
includeSelectAllOption: false,
|
204
|
+
includeSelectAllIfMoreThan: 0,
|
203
205
|
selectAllText: ' Select all',
|
204
206
|
selectAllValue: 'multiselect-all',
|
205
207
|
enableFiltering: false,
|
@@ -210,16 +212,15 @@
|
|
210
212
|
preventInputChangeEvent: false,
|
211
213
|
nonSelectedText: 'None selected',
|
212
214
|
nSelectedText: 'selected',
|
213
|
-
numberDisplayed: 3
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
liGroup: '<li><label class="multiselect-group"></label></li>'
|
215
|
+
numberDisplayed: 3,
|
216
|
+
templates: {
|
217
|
+
button: '<button type="button" class="multiselect dropdown-toggle" data-toggle="dropdown"></button>',
|
218
|
+
ul: '<ul class="multiselect-container dropdown-menu"></ul>',
|
219
|
+
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>',
|
220
|
+
li: '<li><a href="javascript:void(0);"><label></label></a></li>',
|
221
|
+
divider: '<li class="divider"></li>',
|
222
|
+
liGroup: '<li><label class="multiselect-group"></label></li>'
|
223
|
+
}
|
223
224
|
},
|
224
225
|
|
225
226
|
constructor: Multiselect,
|
@@ -237,7 +238,7 @@
|
|
237
238
|
* Builds the button of the multiselect.
|
238
239
|
*/
|
239
240
|
buildButton: function() {
|
240
|
-
this.$button = $(this.templates.button).addClass(this.options.buttonClass);
|
241
|
+
this.$button = $(this.options.templates.button).addClass(this.options.buttonClass);
|
241
242
|
|
242
243
|
// Adopt active state.
|
243
244
|
if (this.$select.prop('disabled')) {
|
@@ -248,7 +249,7 @@
|
|
248
249
|
}
|
249
250
|
|
250
251
|
// Manually add button width if set.
|
251
|
-
if (this.options.buttonWidth && this.options.buttonWidth
|
252
|
+
if (this.options.buttonWidth && this.options.buttonWidth !== 'auto') {
|
252
253
|
this.$button.css({
|
253
254
|
'width' : this.options.buttonWidth
|
254
255
|
});
|
@@ -269,7 +270,7 @@
|
|
269
270
|
buildDropdown: function() {
|
270
271
|
|
271
272
|
// Build ul.
|
272
|
-
this.$ul = $(this.templates.ul);
|
273
|
+
this.$ul = $(this.options.templates.ul);
|
273
274
|
|
274
275
|
if (this.options.dropRight) {
|
275
276
|
this.$ul.addClass('pull-right');
|
@@ -295,7 +296,7 @@
|
|
295
296
|
buildDropdownOptions: function() {
|
296
297
|
|
297
298
|
this.$select.children().each($.proxy(function(index, element) {
|
298
|
-
|
299
|
+
|
299
300
|
// Support optgroups and options without a group simultaneously.
|
300
301
|
var tag = $(element).prop('tagName')
|
301
302
|
.toLowerCase();
|
@@ -313,51 +314,50 @@
|
|
313
314
|
}
|
314
315
|
|
315
316
|
}
|
316
|
-
|
317
|
+
|
317
318
|
// Other illegal tags will be ignored.
|
318
319
|
}, this));
|
319
320
|
|
320
321
|
// Bind the change event on the dropdown elements.
|
321
322
|
$('li input', this.$ul).on('change', $.proxy(function(event) {
|
322
|
-
var
|
323
|
-
|
323
|
+
var $target = $(event.target);
|
324
|
+
|
325
|
+
var checked = $target.prop('checked') || false;
|
326
|
+
var isSelectAllOption = $target.val() === this.options.selectAllValue;
|
324
327
|
|
325
328
|
// Apply or unapply the configured selected class.
|
326
329
|
if (this.options.selectedClass) {
|
327
330
|
if (checked) {
|
328
|
-
$
|
331
|
+
$target.parents('li')
|
329
332
|
.addClass(this.options.selectedClass);
|
330
333
|
}
|
331
334
|
else {
|
332
|
-
$
|
335
|
+
$target.parents('li')
|
333
336
|
.removeClass(this.options.selectedClass);
|
334
337
|
}
|
335
338
|
}
|
336
339
|
|
337
340
|
// Get the corresponding option.
|
338
|
-
var value = $
|
341
|
+
var value = $target.val();
|
339
342
|
var $option = this.getOptionByValue(value);
|
340
343
|
|
341
344
|
var $optionsNotThis = $('option', this.$select).not($option);
|
342
|
-
var $checkboxesNotThis = $('input', this.$container).not($
|
345
|
+
var $checkboxesNotThis = $('input', this.$container).not($target);
|
343
346
|
|
344
347
|
if (isSelectAllOption) {
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
}
|
353
|
-
}
|
348
|
+
var values = [];
|
349
|
+
|
350
|
+
// Select the visible checkboxes except the "select-all" and possible divider.
|
351
|
+
var availableInputs = $('li input[value!="' + this.options.selectAllValue + '"][data-role!="divider"]', this.$ul).filter(':visible');
|
352
|
+
for (var i = 0, j = availableInputs.length; i < j; i++) {
|
353
|
+
values.push(availableInputs[i].value);
|
354
|
+
}
|
354
355
|
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
}
|
356
|
+
if (checked) {
|
357
|
+
this.select(values);
|
358
|
+
}
|
359
|
+
else {
|
360
|
+
this.deselect(values);
|
361
361
|
}
|
362
362
|
}
|
363
363
|
|
@@ -392,7 +392,7 @@
|
|
392
392
|
|
393
393
|
this.$select.change();
|
394
394
|
this.options.onChange($option, checked);
|
395
|
-
|
395
|
+
|
396
396
|
this.updateButtonText();
|
397
397
|
this.updateSelectAll();
|
398
398
|
|
@@ -404,19 +404,21 @@
|
|
404
404
|
$('li a', this.$ul).on('touchstart click', function(event) {
|
405
405
|
event.stopPropagation();
|
406
406
|
|
407
|
+
var $target = $(event.target);
|
408
|
+
|
407
409
|
if (event.shiftKey) {
|
408
|
-
var checked = $
|
410
|
+
var checked = $target.prop('checked') || false;
|
409
411
|
|
410
412
|
if (checked) {
|
411
|
-
var prev = $
|
413
|
+
var prev = $target.parents('li:last')
|
412
414
|
.siblings('li[class="active"]:first');
|
413
415
|
|
414
|
-
var currentIdx = $
|
416
|
+
var currentIdx = $target.parents('li')
|
415
417
|
.index();
|
416
418
|
var prevIdx = prev.index();
|
417
419
|
|
418
420
|
if (currentIdx > prevIdx) {
|
419
|
-
$
|
421
|
+
$target.parents("li:last").prevUntil(prev).each(
|
420
422
|
function() {
|
421
423
|
$(this).find("input:first").prop("checked", true)
|
422
424
|
.trigger("change");
|
@@ -424,7 +426,7 @@
|
|
424
426
|
);
|
425
427
|
}
|
426
428
|
else {
|
427
|
-
$
|
429
|
+
$target.parents("li:last").nextUntil(prev).each(
|
428
430
|
function() {
|
429
431
|
$(this).find("input:first").prop("checked", true)
|
430
432
|
.trigger("change");
|
@@ -434,7 +436,7 @@
|
|
434
436
|
}
|
435
437
|
}
|
436
438
|
|
437
|
-
$
|
439
|
+
$target.blur();
|
438
440
|
});
|
439
441
|
|
440
442
|
// Keyboard support.
|
@@ -444,7 +446,7 @@
|
|
444
446
|
}
|
445
447
|
if ((event.keyCode === 9 || event.keyCode === 27)
|
446
448
|
&& this.$container.hasClass('open')) {
|
447
|
-
|
449
|
+
|
448
450
|
// Close on tab or escape.
|
449
451
|
this.$button.click();
|
450
452
|
}
|
@@ -487,7 +489,7 @@
|
|
487
489
|
|
488
490
|
/**
|
489
491
|
* Create an option using the given select option.
|
490
|
-
*
|
492
|
+
*
|
491
493
|
* @param {jQuery} element
|
492
494
|
*/
|
493
495
|
createOptionValue: function(element) {
|
@@ -500,9 +502,9 @@
|
|
500
502
|
var value = $(element).val();
|
501
503
|
var inputType = this.options.multiple ? "checkbox" : "radio";
|
502
504
|
|
503
|
-
var $li = $(this.templates.li);
|
505
|
+
var $li = $(this.options.templates.li);
|
504
506
|
$('label', $li).addClass(inputType);
|
505
|
-
$('label', $li).append('<input type="' + inputType + '" />');
|
507
|
+
$('label', $li).append('<input type="' + inputType + '" name="' + this.options.checkboxName + '" />');
|
506
508
|
|
507
509
|
var selected = $(element).prop('selected') || false;
|
508
510
|
var $checkbox = $('input', $li);
|
@@ -534,24 +536,24 @@
|
|
534
536
|
|
535
537
|
/**
|
536
538
|
* Creates a divider using the given select option.
|
537
|
-
*
|
539
|
+
*
|
538
540
|
* @param {jQuery} element
|
539
541
|
*/
|
540
542
|
createDivider: function(element) {
|
541
|
-
var $divider = $(this.templates.divider);
|
543
|
+
var $divider = $(this.options.templates.divider);
|
542
544
|
this.$ul.append($divider);
|
543
545
|
},
|
544
546
|
|
545
547
|
/**
|
546
548
|
* Creates an optgroup.
|
547
|
-
*
|
549
|
+
*
|
548
550
|
* @param {jQuery} group
|
549
551
|
*/
|
550
552
|
createOptgroup: function(group) {
|
551
553
|
var groupName = $(group).prop('label');
|
552
554
|
|
553
555
|
// Add a header for the group.
|
554
|
-
var $li = $(this.templates.liGroup);
|
556
|
+
var $li = $(this.options.templates.liGroup);
|
555
557
|
$('label', $li).text(groupName);
|
556
558
|
|
557
559
|
this.$ul.append($li);
|
@@ -572,12 +574,15 @@
|
|
572
574
|
*/
|
573
575
|
buildSelectAll: function() {
|
574
576
|
var alreadyHasSelectAll = this.hasSelectAll();
|
575
|
-
|
576
|
-
|
577
|
-
|
577
|
+
|
578
|
+
if (!alreadyHasSelectAll && this.options.includeSelectAllOption && this.options.multiple
|
579
|
+
&& $('option[data-role!="divider"]', this.$select).length > this.options.includeSelectAllIfMoreThan) {
|
580
|
+
|
581
|
+
// Check whether to add a divider after the select all.
|
578
582
|
if (this.options.includeSelectAllDivider) {
|
579
583
|
this.$select.prepend('<option value="" disabled="disabled" data-role="divider">');
|
580
584
|
}
|
585
|
+
|
581
586
|
this.$select.prepend('<option value="' + this.options.selectAllValue + '">' + this.options.selectAllText + '</option>');
|
582
587
|
}
|
583
588
|
},
|
@@ -593,7 +598,7 @@
|
|
593
598
|
|
594
599
|
if (this.$select.find('option').length >= enableFilterLength) {
|
595
600
|
|
596
|
-
this.$filter = $(this.templates.filter);
|
601
|
+
this.$filter = $(this.options.templates.filter);
|
597
602
|
$('input', this.$filter).attr('placeholder', this.options.filterPlaceholder);
|
598
603
|
this.$ul.prepend(this.$filter);
|
599
604
|
|
@@ -612,19 +617,22 @@
|
|
612
617
|
var value = $('input', element).val();
|
613
618
|
var text = $('label', element).text();
|
614
619
|
|
620
|
+
var filterCandidate = '';
|
621
|
+
if ((this.options.filterBehavior === 'text')) {
|
622
|
+
filterCandidate = text;
|
623
|
+
}
|
624
|
+
else if ((this.options.filterBehavior === 'value')) {
|
625
|
+
filterCandidate = value;
|
626
|
+
}
|
627
|
+
else if (this.options.filterBehavior === 'both') {
|
628
|
+
filterCandidate = text + '\n' + value;
|
629
|
+
}
|
630
|
+
|
615
631
|
if (value !== this.options.selectAllValue && text) {
|
616
632
|
// by default lets assume that element is not
|
617
633
|
// interesting for this search
|
618
634
|
var showElement = false;
|
619
635
|
|
620
|
-
var filterCandidate = '';
|
621
|
-
if ((this.options.filterBehavior === 'text' || this.options.filterBehavior === 'both')) {
|
622
|
-
filterCandidate = text;
|
623
|
-
}
|
624
|
-
if ((this.options.filterBehavior === 'value' || this.options.filterBehavior === 'both')) {
|
625
|
-
filterCandidate = value;
|
626
|
-
}
|
627
|
-
|
628
636
|
if (this.options.enableCaseInsensitiveFiltering && filterCandidate.toLowerCase().indexOf(this.query.toLowerCase()) > -1) {
|
629
637
|
showElement = true;
|
630
638
|
}
|
@@ -655,6 +663,7 @@
|
|
655
663
|
destroy: function() {
|
656
664
|
this.$container.remove();
|
657
665
|
this.$select.show();
|
666
|
+
this.$select.data('multiselect', null);
|
658
667
|
},
|
659
668
|
|
660
669
|
/**
|
@@ -702,11 +711,11 @@
|
|
702
711
|
|
703
712
|
/**
|
704
713
|
* Select all options of the given values.
|
705
|
-
*
|
714
|
+
*
|
706
715
|
* @param {Array} selectValues
|
707
716
|
*/
|
708
717
|
select: function(selectValues) {
|
709
|
-
if(
|
718
|
+
if(!$.isArray(selectValues)) {
|
710
719
|
selectValues = [selectValues];
|
711
720
|
}
|
712
721
|
|
@@ -730,7 +739,7 @@
|
|
730
739
|
|
731
740
|
/**
|
732
741
|
* Clears all selected items
|
733
|
-
*
|
742
|
+
*
|
734
743
|
*/
|
735
744
|
clearSelection: function () {
|
736
745
|
|
@@ -751,11 +760,11 @@
|
|
751
760
|
|
752
761
|
/**
|
753
762
|
* Deselects all options of the given values.
|
754
|
-
*
|
763
|
+
*
|
755
764
|
* @param {Array} deselectValues
|
756
765
|
*/
|
757
766
|
deselect: function(deselectValues) {
|
758
|
-
if(
|
767
|
+
if(!$.isArray(deselectValues)) {
|
759
768
|
deselectValues = [deselectValues];
|
760
769
|
}
|
761
770
|
|
@@ -794,14 +803,14 @@
|
|
794
803
|
this.buildSelectAll();
|
795
804
|
this.buildDropdownOptions();
|
796
805
|
this.buildFilter();
|
797
|
-
|
806
|
+
|
798
807
|
this.updateButtonText();
|
799
808
|
this.updateSelectAll();
|
800
809
|
},
|
801
810
|
|
802
811
|
/**
|
803
812
|
* The provided data will be used to build the dropdown.
|
804
|
-
*
|
813
|
+
*
|
805
814
|
* @param {Array} dataprovider
|
806
815
|
*/
|
807
816
|
dataprovider: function(dataprovider) {
|
@@ -834,7 +843,7 @@
|
|
834
843
|
|
835
844
|
/**
|
836
845
|
* Set the options.
|
837
|
-
*
|
846
|
+
*
|
838
847
|
* @param {Array} options
|
839
848
|
*/
|
840
849
|
setOptions: function(options) {
|
@@ -843,30 +852,30 @@
|
|
843
852
|
|
844
853
|
/**
|
845
854
|
* Merges the given options with the default options.
|
846
|
-
*
|
855
|
+
*
|
847
856
|
* @param {Array} options
|
848
857
|
* @returns {Array}
|
849
858
|
*/
|
850
859
|
mergeOptions: function(options) {
|
851
|
-
return $.extend({}, this.defaults,
|
860
|
+
return $.extend(true, {}, this.defaults, options);
|
852
861
|
},
|
853
|
-
|
862
|
+
|
854
863
|
/**
|
855
864
|
* Checks whether a select all option is present.
|
856
|
-
*
|
865
|
+
*
|
857
866
|
* @returns {Boolean}
|
858
867
|
*/
|
859
868
|
hasSelectAll: function() {
|
860
|
-
return
|
869
|
+
return $('option[value="' + this.options.selectAllValue + '"]', this.$select).length > 0;
|
861
870
|
},
|
862
|
-
|
871
|
+
|
863
872
|
/**
|
864
873
|
* Updates the select all option based on the currently selected options.
|
865
874
|
*/
|
866
875
|
updateSelectAll: function() {
|
867
876
|
if (this.hasSelectAll()) {
|
868
877
|
var selected = this.getSelected();
|
869
|
-
|
878
|
+
|
870
879
|
if (selected.length === $('option:not([data-role=divider])', this.$select).length - 1) {
|
871
880
|
this.select(this.options.selectAllValue);
|
872
881
|
}
|
@@ -875,16 +884,16 @@
|
|
875
884
|
}
|
876
885
|
}
|
877
886
|
},
|
878
|
-
|
887
|
+
|
879
888
|
/**
|
880
889
|
* Update the button text and its title based on the currently selected options.
|
881
890
|
*/
|
882
891
|
updateButtonText: function() {
|
883
892
|
var options = this.getSelected();
|
884
|
-
|
893
|
+
|
885
894
|
// First update the displayed button text.
|
886
895
|
$('button', this.$container).html(this.options.buttonText(options, this.$select));
|
887
|
-
|
896
|
+
|
888
897
|
// Now update the title attribute of the button.
|
889
898
|
$('button', this.$container).attr('title', this.options.buttonTitle(options, this.$select));
|
890
899
|
|
@@ -892,7 +901,7 @@
|
|
892
901
|
|
893
902
|
/**
|
894
903
|
* Get all selected options.
|
895
|
-
*
|
904
|
+
*
|
896
905
|
* @returns {jQUery}
|
897
906
|
*/
|
898
907
|
getSelected: function() {
|
@@ -903,7 +912,7 @@
|
|
903
912
|
|
904
913
|
/**
|
905
914
|
* Gets a select option by its value.
|
906
|
-
*
|
915
|
+
*
|
907
916
|
* @param {String} value
|
908
917
|
* @returns {jQuery}
|
909
918
|
*/
|
@@ -914,7 +923,7 @@
|
|
914
923
|
|
915
924
|
for (var i = 0; i < options.length; i = i + 1) {
|
916
925
|
var option = options[i];
|
917
|
-
if (option.value
|
926
|
+
if (option.value === valueToCompare) {
|
918
927
|
return $(option);
|
919
928
|
}
|
920
929
|
}
|
@@ -922,7 +931,7 @@
|
|
922
931
|
|
923
932
|
/**
|
924
933
|
* Get the input (radio/checkbox) by its value.
|
925
|
-
*
|
934
|
+
*
|
926
935
|
* @param {String} value
|
927
936
|
* @returns {jQuery}
|
928
937
|
*/
|
@@ -933,7 +942,7 @@
|
|
933
942
|
|
934
943
|
for (var i = 0; i < checkboxes.length; i = i + 1) {
|
935
944
|
var checkbox = checkboxes[i];
|
936
|
-
if (checkbox.value
|
945
|
+
if (checkbox.value === valueToCompare) {
|
937
946
|
return $(checkbox);
|
938
947
|
}
|
939
948
|
}
|
@@ -958,7 +967,7 @@
|
|
958
967
|
return this.each(function() {
|
959
968
|
var data = $(this).data('multiselect');
|
960
969
|
var options = typeof option === 'object' && option;
|
961
|
-
|
970
|
+
|
962
971
|
// Initialize the multiselect.
|
963
972
|
if (!data) {
|
964
973
|
data = new Multiselect(this, options);
|
@@ -968,7 +977,7 @@
|
|
968
977
|
// Call multiselect method.
|
969
978
|
if (typeof option === 'string') {
|
970
979
|
data[option](parameter);
|
971
|
-
|
980
|
+
|
972
981
|
if (option === 'destroy') {
|
973
982
|
$(this).data('multiselect', false);
|
974
983
|
}
|