multi-select-rails 0.9.11 → 0.9.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a3426dc95dcf805c6e8b453049706166b311f69
4
- data.tar.gz: 1bcac4123f932f41df2b92b9bd6060650fcb0c90
3
+ metadata.gz: df5e07089789a8b2bc30bf9c79e848b8173aeea0
4
+ data.tar.gz: 1ab86991f4a1c054acc277566c598617d879f138
5
5
  SHA512:
6
- metadata.gz: 406c20f4550b34e2aca2af53646d142b9afb33adf3d4163d4c7cf1ecdb2adfdaee966a22d3ca490b8b7b5117a1958a3b878ebf32ea38117228ede7f08311dec1
7
- data.tar.gz: 014c71c24913c9b313c2b0736846016eb400cc3e034fcf64e1f481ddaffdd98b1fd5520a29282f959acfa9f9bffe24f897edd51722e1e86970a2aad0de86be4b
6
+ metadata.gz: f00d65b5570c01e27f25f0525e909413c150fa636ddc1261507b2730554192a8006b1e3284e6ba1941b944f42cf14972ca844d52290fd5ebe5dc4d4a8466a990
7
+ data.tar.gz: 57e493df1d277c6607390e230ef891291caf7d18ea2b352b21699e0a2e55e7c41232b6d9c64ee6d681ee3de85e9ec2bfff066c47489fd53d56f000ee46e85144
data/README.md CHANGED
@@ -29,7 +29,7 @@ Add to your `app/assets/stylesheets/application.css`
29
29
  ## Updating the gem
30
30
  There are two rake tasks designed to ease the maintenance of this gem.
31
31
 
32
- The `update` task pulls the latest X-editable code from github and places images, stylesheets and javascripts in the correct gem paths. It also changes background-image properties in the stylesheet to asset pipeline equivalents.
32
+ The `update` task pulls the latest multi-select code from github and places images, stylesheets and javascripts in the correct gem paths. It also changes background-image properties in the stylesheet to asset pipeline equivalents.
33
33
 
34
34
  rake update
35
35
 
@@ -149,18 +149,18 @@
149
149
  $selectionOptgroup.append($(optgroupTpl));
150
150
  if (that.options.selectableOptgroup){
151
151
  $selectableOptgroup.find('.ms-optgroup-label').on('click', function(){
152
- var values = $optgroup.children(':not(:selected)').map(function(){ return $(this).val() }).get();
152
+ var values = $optgroup.children(':not(:selected, :disabled)').map(function(){ return $(this).val() }).get();
153
153
  that.select(values);
154
154
  });
155
155
  $selectionOptgroup.find('.ms-optgroup-label').on('click', function(){
156
- var values = $optgroup.children(':selected').map(function(){ return $(this).val() }).get();
156
+ var values = $optgroup.children(':selected:not(:disabled)').map(function(){ return $(this).val() }).get();
157
157
  that.deselect(values);
158
158
  });
159
159
  }
160
160
  that.$selectableUl.append($selectableOptgroup);
161
161
  that.$selectionUl.append($selectionOptgroup);
162
162
  }
163
- index = index == undefined ? $selectableOptgroup.children().length : index + 1;
163
+ index = index == undefined ? $selectableOptgroup.find('ul').children().length : index + 1;
164
164
  selectableLi.insertAt(index, $selectableOptgroup.children());
165
165
  selectedLi.insertAt(index, $selectionOptgroup.children());
166
166
  } else {
@@ -244,10 +244,6 @@
244
244
  containerHeight = $list.height(),
245
245
  containerSelector = '#'+this.$container.prop('id');
246
246
 
247
- // Deactive mouseenter event when move is active
248
- // It fixes a bug when mouse is over the list
249
- $elems.off('mouseenter');
250
-
251
247
  $elems.removeClass('ms-hover');
252
248
  if (direction === 1){ // DOWN
253
249
 
@@ -298,21 +294,22 @@
298
294
  },
299
295
 
300
296
  'selectHighlighted' : function($list){
301
- var $elems = $list.find(this.elemsSelector),
302
- $highlightedElem = $elems.filter('.ms-hover').first();
297
+ var $elems = $list.find(this.elemsSelector),
298
+ $highlightedElem = $elems.filter('.ms-hover').first();
303
299
 
304
- if ($highlightedElem.length > 0){
305
- if ($list.parent().hasClass('ms-selectable')){
306
- this.select($highlightedElem.data('ms-value'));
307
- } else {
308
- this.deselect($highlightedElem.data('ms-value'));
309
- }
310
- $elems.removeClass('ms-hover');
300
+ if ($highlightedElem.length > 0){
301
+ if ($list.parent().hasClass('ms-selectable')){
302
+ this.select($highlightedElem.data('ms-value'));
303
+ } else {
304
+ this.deselect($highlightedElem.data('ms-value'));
311
305
  }
306
+ $elems.removeClass('ms-hover');
307
+ }
312
308
  },
313
309
 
314
310
  'switchList' : function($list){
315
311
  $list.blur();
312
+ this.$container.find(this.elemsSelector).removeClass('ms-hover');
316
313
  if ($list.parent().hasClass('ms-selectable')){
317
314
  this.$selectionUl.focus();
318
315
  } else {
@@ -322,16 +319,10 @@
322
319
 
323
320
  'activeMouse' : function($list){
324
321
  var that = this;
325
- var lastMovedDom = false;
326
- $list.on('mousemove', function(){
327
- if (lastMovedDom === this) return;
328
- lastMovedDom = this;
329
- var elems = $list.find(that.elemsSelector);
330
-
331
- elems.on('mouseenter', function(){
332
- elems.removeClass('ms-hover');
333
- $(this).addClass('ms-hover');
334
- });
322
+
323
+ $('body').on('mouseenter', that.elemsSelector, function(){
324
+ $(this).parents('.ms-container').find(that.elemsSelector).removeClass('ms-hover');
325
+ $(this).addClass('ms-hover');
335
326
  });
336
327
  },
337
328
 
@@ -364,8 +355,11 @@
364
355
  if (selectables.length > 0){
365
356
  selectables.addClass('ms-selected').hide();
366
357
  selections.addClass('ms-selected').show();
358
+
367
359
  options.prop('selected', true);
368
360
 
361
+ that.$container.find(that.elemsSelector).removeClass('ms-hover');
362
+
369
363
  var selectableOptgroups = that.$selectableUl.children('.ms-optgroup-container');
370
364
  if (selectableOptgroups.length > 0){
371
365
  selectableOptgroups.each(function(){
@@ -383,8 +377,8 @@
383
377
  }
384
378
  });
385
379
  } else {
386
- if (that.options.keepOrder){
387
- var selectionLiLast = that.$selectionUl.find('.ms-selected');
380
+ if (that.options.keepOrder && method !== 'init'){
381
+ var selectionLiLast = that.$selectionUl.find('.ms-selected');
388
382
  if((selectionLiLast.length > 1) && (selectionLiLast.last().get(0) != selections.get(0))) {
389
383
  selections.insertAfter(selectionLiLast.last());
390
384
  }
@@ -414,6 +408,8 @@
414
408
  selections.removeClass('ms-selected').hide();
415
409
  options.prop('selected', false);
416
410
 
411
+ that.$container.find(that.elemsSelector).removeClass('ms-hover');
412
+
417
413
  var selectableOptgroups = that.$selectableUl.children('.ms-optgroup-container');
418
414
  if (selectableOptgroups.length > 0){
419
415
  selectableOptgroups.each(function(){
@@ -474,12 +470,12 @@
474
470
  },
475
471
 
476
472
  sanitize: function(value){
477
- var hash = 0, i, char;
473
+ var hash = 0, i, character;
478
474
  if (value.length == 0) return hash;
479
475
  var ls = 0;
480
476
  for (i = 0, ls = value.length; i < ls; i++) {
481
- char = value.charCodeAt(i);
482
- hash = ((hash<<5)-hash)+char;
477
+ character = value.charCodeAt(i);
478
+ hash = ((hash<<5)-hash)+character;
483
479
  hash |= 0; // Convert to 32bit integer
484
480
  }
485
481
  return hash;
@@ -1,5 +1,5 @@
1
1
  module MultiSelectRails
2
2
  module Rails
3
- VERSION = "0.9.11"
3
+ VERSION = "0.9.12"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multi-select-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.11
4
+ version: 0.9.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Per Andersson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-04 00:00:00.000000000 Z
11
+ date: 2014-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties