selectivity-rails 0.0.8 → 0.0.9
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f193b5755b553f98fc709e5290054ec9f02d6b19
|
4
|
+
data.tar.gz: e0df86c48b839a856bce58f13d4a3239416e3032
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b70b0fe542ad62b62bc52c13004bce87aecb11c7fa15f572667c49b81f2ce2479b3f7559953730b2ce3bf8a4ef365c77bda5cb0f258eeb7fefc644b4f772ec1
|
7
|
+
data.tar.gz: 568502d3cb475107c5c3d2d04fb7e0656c6a27a326eb21a07f5a4b312e8e2e537bd7c83917a0d3c515ff1ffc3923ff2589b17b5ffb54f77f3d318f6526162f9a
|
data/README.md
CHANGED
@@ -108,11 +108,13 @@ selectivity_select('Poland', from: '#country')
|
|
108
108
|
To handle multiple select:
|
109
109
|
|
110
110
|
```ruby
|
111
|
-
selectivity_select('Netherlands', 'Russia', from: '#countries')
|
111
|
+
selectivity_select('Netherlands', 'Russia', 'Spain', from: '#countries')
|
112
112
|
# or, by single value:
|
113
|
-
selectivity_select('
|
113
|
+
selectivity_select('Poland', from: '#countries')
|
114
114
|
|
115
|
-
selectivity_unselect('Russia', from: '#countries')
|
115
|
+
selectivity_unselect('Russia', 'Spain', from: '#countries')
|
116
|
+
# or, by single value:
|
117
|
+
selectivity_unselect('Netherlands', from: '#countries')
|
116
118
|
```
|
117
119
|
|
118
120
|
## Demos and examples
|
@@ -2964,6 +2964,9 @@ var KEY_UP_ARROW = 38;
|
|
2964
2964
|
*/
|
2965
2965
|
function listener(selectivity, $input) {
|
2966
2966
|
|
2967
|
+
var keydownCanceled = false;
|
2968
|
+
var closeSubmenu = null;
|
2969
|
+
|
2967
2970
|
/**
|
2968
2971
|
* Moves a dropdown's highlight to the next or previous result item.
|
2969
2972
|
*
|
@@ -3037,7 +3040,20 @@ function listener(selectivity, $input) {
|
|
3037
3040
|
|
3038
3041
|
var dropdown = selectivity.dropdown;
|
3039
3042
|
if (dropdown) {
|
3040
|
-
if (event.keyCode ===
|
3043
|
+
if (event.keyCode === KEY_BACKSPACE) {
|
3044
|
+
if (!$input.val()) {
|
3045
|
+
if (dropdown.submenu) {
|
3046
|
+
var submenu = dropdown.submenu;
|
3047
|
+
while (submenu.submenu) {
|
3048
|
+
submenu = submenu.submenu;
|
3049
|
+
}
|
3050
|
+
closeSubmenu = submenu;
|
3051
|
+
}
|
3052
|
+
|
3053
|
+
event.preventDefault();
|
3054
|
+
keydownCanceled = true;
|
3055
|
+
}
|
3056
|
+
} else if (event.keyCode === KEY_DOWN_ARROW) {
|
3041
3057
|
moveHighlight(dropdown, 1);
|
3042
3058
|
} else if (event.keyCode === KEY_UP_ARROW) {
|
3043
3059
|
moveHighlight(dropdown, -1);
|
@@ -3058,18 +3074,13 @@ function listener(selectivity, $input) {
|
|
3058
3074
|
}
|
3059
3075
|
|
3060
3076
|
var dropdown = selectivity.dropdown;
|
3061
|
-
if (
|
3062
|
-
|
3063
|
-
|
3064
|
-
var submenu = dropdown.submenu;
|
3065
|
-
while (submenu.submenu) {
|
3066
|
-
submenu = submenu.submenu;
|
3067
|
-
}
|
3068
|
-
submenu.close();
|
3069
|
-
selectivity.focus();
|
3070
|
-
}
|
3077
|
+
if (keydownCanceled) {
|
3078
|
+
event.preventDefault();
|
3079
|
+
keydownCanceled = false;
|
3071
3080
|
|
3072
|
-
|
3081
|
+
if (closeSubmenu) {
|
3082
|
+
closeSubmenu.close();
|
3083
|
+
closeSubmenu = null;
|
3073
3084
|
}
|
3074
3085
|
} else if (event.keyCode === KEY_ENTER && !event.ctrlKey) {
|
3075
3086
|
if (dropdown) {
|
@@ -4283,11 +4294,11 @@ Selectivity.Templates = {
|
|
4283
4294
|
return (
|
4284
4295
|
'<span class="selectivity-multiple-selected-item' + extraClass + '" ' +
|
4285
4296
|
'data-item-id="' + escape(options.id) + '">' +
|
4286
|
-
escape(options.text) +
|
4287
4297
|
(options.removable ? '<a class="selectivity-multiple-selected-item-remove">' +
|
4288
4298
|
'<i class="fa fa-remove"></i>' +
|
4289
4299
|
'</a>'
|
4290
4300
|
: '') +
|
4301
|
+
escape(options.text) +
|
4291
4302
|
'</span>'
|
4292
4303
|
);
|
4293
4304
|
},
|
@@ -4420,8 +4431,8 @@ Selectivity.Templates = {
|
|
4420
4431
|
* mode - Mode in which select exists, single or multiple.
|
4421
4432
|
*/
|
4422
4433
|
selectCompliance: function(options) {
|
4423
|
-
if (options.mode === 'multiple' &&
|
4424
|
-
options.name
|
4434
|
+
if (options.mode === 'multiple' && options.name.slice(-2) !== '[]') {
|
4435
|
+
options.name += '[]';
|
4425
4436
|
}
|
4426
4437
|
return ('<select name="' + options.name + '"' + (options.mode === 'multiple' ? ' multiple' : '') + '></select>');
|
4427
4438
|
},
|
@@ -4519,23 +4530,25 @@ var Selectivity = _dereq_(7);
|
|
4519
4530
|
|
4520
4531
|
function replaceSelectElement($el, options) {
|
4521
4532
|
|
4522
|
-
var
|
4533
|
+
var data = (options.multiple ? [] : null);
|
4523
4534
|
|
4524
4535
|
var mapOptions = function() {
|
4525
4536
|
var $this = $(this);
|
4526
4537
|
if ($this.is('option')) {
|
4527
|
-
var
|
4538
|
+
var text = $this.text();
|
4539
|
+
var id = $this.attr('value') || text;
|
4528
4540
|
if ($this.prop('selected')) {
|
4541
|
+
var item = { id: id, text: text };
|
4529
4542
|
if (options.multiple) {
|
4530
|
-
|
4543
|
+
data.push(item);
|
4531
4544
|
} else {
|
4532
|
-
|
4545
|
+
data = item;
|
4533
4546
|
}
|
4534
4547
|
}
|
4535
4548
|
|
4536
4549
|
return {
|
4537
4550
|
id: id,
|
4538
|
-
text: $this.attr('label') ||
|
4551
|
+
text: $this.attr('label') || text
|
4539
4552
|
};
|
4540
4553
|
} else {
|
4541
4554
|
return {
|
@@ -4547,11 +4560,12 @@ function replaceSelectElement($el, options) {
|
|
4547
4560
|
|
4548
4561
|
options.allowClear = ('allowClear' in options ? options.allowClear : !$el.prop('required'));
|
4549
4562
|
|
4550
|
-
|
4563
|
+
var items = $el.children('option,optgroup').map(mapOptions).get();
|
4564
|
+
options.items = (options.query ? null : items);
|
4551
4565
|
|
4552
4566
|
options.placeholder = options.placeholder || $el.data('placeholder') || '';
|
4553
4567
|
|
4554
|
-
options.
|
4568
|
+
options.data = data;
|
4555
4569
|
|
4556
4570
|
var classes = ($el.attr('class') || 'selectivity-input').split(' ');
|
4557
4571
|
if (classes.indexOf('selectivity-input') === -1) {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: selectivity-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Konrad Jurkowski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|