multi-select-rails 0.9.3 → 0.9.4

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.
@@ -1,5 +1,5 @@
1
1
  module MultiSelectRails
2
2
  module Rails
3
- VERSION = "0.9.3"
3
+ VERSION = "0.9.4"
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  /*
2
- * MultiSelect v0.9.3
2
+ * MultiSelect v0.9.4
3
3
  * Copyright (c) 2012 Louis Cuny
4
4
  *
5
5
  * This program is free software. It comes without any warranty, to
@@ -121,8 +121,13 @@
121
121
  that.$selectionUl.find('.ms-optgroup-label').hide();
122
122
 
123
123
  if ($(this).prop('disabled') || ms.prop('disabled')){
124
- selectableLi.prop('disabled', true);
125
- selectableLi.addClass(that.options.disabledClass);
124
+ if (this.selected) {
125
+ selectedLi.prop('disabled', true);
126
+ selectedLi.addClass(that.options.disabledClass);
127
+ } else {
128
+ selectableLi.prop('disabled', true);
129
+ selectableLi.addClass(that.options.disabledClass);
130
+ }
126
131
  }
127
132
 
128
133
  if (optgroupId){
@@ -266,7 +271,7 @@
266
271
  } else {
267
272
  that.$selectableUl.focusin();
268
273
  that.$selectionUl.focusout();
269
- }
274
+ }
270
275
  }
271
276
  }
272
277
 
@@ -376,7 +381,8 @@
376
381
  },
377
382
 
378
383
  'select_all' : function(){
379
- var ms = this.$element;
384
+ var ms = this.$element,
385
+ values = ms.val();
380
386
 
381
387
  ms.find('option').prop('selected', true);
382
388
  this.$selectableUl.find('.ms-elem-selectable').addClass('ms-selected').hide();
@@ -386,10 +392,17 @@
386
392
  this.$selectionUl.focusin();
387
393
  this.$selectableUl.focusout();
388
394
  ms.trigger('change');
395
+ if (typeof this.options.afterSelect == 'function') {
396
+ var selectedValues = $.grep(ms.val(), function(item){
397
+ return $.inArray(item, values) < 0;
398
+ });
399
+ this.options.afterSelect.call(this, selectedValues);
400
+ }
389
401
  },
390
402
 
391
403
  'deselect_all' : function(){
392
- var ms = this.$element;
404
+ var ms = this.$element,
405
+ values = ms.val();
393
406
 
394
407
  ms.find('option').prop('selected', false);
395
408
  this.$selectableUl.find('.ms-elem-selectable').removeClass('ms-selected').show();
@@ -399,6 +412,9 @@
399
412
  this.$selectableUl.focusin();
400
413
  this.$selectionUl.focusout();
401
414
  ms.trigger('change');
415
+ if (typeof this.options.afterDeselect == 'function') {
416
+ this.options.afterDeselect.call(this, values);
417
+ }
402
418
  },
403
419
 
404
420
  isDomNode: function (attr){
@@ -421,7 +437,7 @@
421
437
  $.fn.multiSelect = function () {
422
438
  var option = arguments[0],
423
439
  args = arguments;
424
-
440
+
425
441
  return this.each(function () {
426
442
  var $this = $(this),
427
443
  data = $this.data('multiselect'),
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multi-select-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-02 00:00:00.000000000 Z
12
+ date: 2013-01-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
@@ -93,7 +93,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
93
93
  version: '0'
94
94
  segments:
95
95
  - 0
96
- hash: -448448030300929018
96
+ hash: -3524931676532548001
97
97
  required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  none: false
99
99
  requirements:
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  version: '0'
103
103
  segments:
104
104
  - 0
105
- hash: -448448030300929018
105
+ hash: -3524931676532548001
106
106
  requirements: []
107
107
  rubyforge_project:
108
108
  rubygems_version: 1.8.24