multi-select-rails 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +30 -0
- data/lib/multi-select-rails/version.rb +1 -1
- data/vendor/assets/javascripts/multi-select.js +44 -20
- data/vendor/assets/stylesheets/multi-select.scss +93 -86
- metadata +5 -4
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
desc "Update"
|
2
|
+
task :update do
|
3
|
+
system("rm -rf multi-select-src")
|
4
|
+
|
5
|
+
system("git clone https://github.com/lou/multi-select.git multi-select-src")
|
6
|
+
system("cp multi-select-src/img/switch.png vendor/assets/images/switch.png")
|
7
|
+
system("cp multi-select-src/css/multi-select.css vendor/assets/stylesheets/multi-select.scss")
|
8
|
+
system("cp multi-select-src/js/jquery.multi-select.js vendor/assets/javascripts/multi-select.js")
|
9
|
+
|
10
|
+
fixes
|
11
|
+
|
12
|
+
system("rm -rf multi-select-src")
|
13
|
+
end
|
14
|
+
|
15
|
+
def fixes
|
16
|
+
replace_string_in_file("vendor/assets/stylesheets/multi-select.scss", "url('../img/switch.png')", "image-url('switch.png')")
|
17
|
+
end
|
18
|
+
|
19
|
+
def replace_string_in_file(file, find, replace)
|
20
|
+
file_content = File.read(file)
|
21
|
+
|
22
|
+
File.open(file, "w") do |f|
|
23
|
+
f.puts file_content.gsub!(find, replace)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "Build"
|
28
|
+
task "build" do
|
29
|
+
system("gem build multi-select-rails.gemspec")
|
30
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* MultiSelect v0.9.
|
2
|
+
* MultiSelect v0.9.3
|
3
3
|
* Copyright (c) 2012 Louis Cuny
|
4
4
|
*
|
5
5
|
* This program is free software. It comes without any warranty, to
|
@@ -104,9 +104,19 @@
|
|
104
104
|
var selectableLi = $('<li '+attributes+'><span>'+$(this).text()+'</span></li>'),
|
105
105
|
selectedLi = selectableLi.clone();
|
106
106
|
|
107
|
-
var value = $(this).val()
|
108
|
-
|
109
|
-
|
107
|
+
var value = $(this).val(),
|
108
|
+
msId = that.sanitize(value);
|
109
|
+
|
110
|
+
selectableLi
|
111
|
+
.data('ms-value', value)
|
112
|
+
.addClass('ms-elem-selectable')
|
113
|
+
.attr('id', msId+'-selectable');
|
114
|
+
|
115
|
+
selectedLi
|
116
|
+
.data('ms-value', value)
|
117
|
+
.addClass('ms-elem-selection')
|
118
|
+
.attr('id', msId+'-selection')
|
119
|
+
.hide();
|
110
120
|
|
111
121
|
that.$selectionUl.find('.ms-optgroup-label').hide();
|
112
122
|
|
@@ -125,15 +135,17 @@
|
|
125
135
|
}
|
126
136
|
});
|
127
137
|
|
128
|
-
if (that.options.selectableHeader)
|
138
|
+
if (that.options.selectableHeader)
|
129
139
|
that.$selectableContainer.append(that.options.selectableHeader);
|
130
|
-
}
|
131
140
|
that.$selectableContainer.append(that.$selectableUl);
|
132
|
-
|
133
|
-
|
141
|
+
if (that.options.selectableFooter)
|
142
|
+
that.$selectableContainer.append(that.options.selectableFooter);
|
143
|
+
|
144
|
+
if (that.options.selectionHeader)
|
134
145
|
that.$selectionContainer.append(that.options.selectionHeader);
|
135
|
-
|
136
|
-
|
146
|
+
that.$selectionContainer.append(that.$selectionUl);
|
147
|
+
if (that.options.selectionFooter)
|
148
|
+
that.$selectionContainer.append(that.options.selectionFooter);
|
137
149
|
|
138
150
|
that.$container.append(that.$selectableContainer);
|
139
151
|
that.$container.append(that.$selectionContainer);
|
@@ -147,17 +159,17 @@
|
|
147
159
|
|
148
160
|
if(that.options.dblClick) {
|
149
161
|
that.$selectableUl.on('dblclick', '.ms-elem-selectable', function(){
|
150
|
-
that.select($(this).
|
162
|
+
that.select($(this).data('ms-value'));
|
151
163
|
});
|
152
164
|
that.$selectionUl.on('dblclick', '.ms-elem-selection', function(){
|
153
|
-
that.deselect($(this).
|
165
|
+
that.deselect($(this).data('ms-value'));
|
154
166
|
});
|
155
167
|
} else {
|
156
168
|
that.$selectableUl.on('click', '.ms-elem-selectable', function(){
|
157
|
-
that.select($(this).
|
169
|
+
that.select($(this).data('ms-value'));
|
158
170
|
});
|
159
171
|
that.$selectionUl.on('click', '.ms-elem-selection', function(){
|
160
|
-
that.deselect($(this).
|
172
|
+
that.deselect($(this).data('ms-value'));
|
161
173
|
});
|
162
174
|
}
|
163
175
|
|
@@ -206,9 +218,9 @@
|
|
206
218
|
if (liFocused.length >0){
|
207
219
|
var method = keyContainer == 'ms-selectable' ? 'select' : 'deselect';
|
208
220
|
if (keyContainer == 'ms-selectable'){
|
209
|
-
that.select(liFocused.
|
221
|
+
that.select(liFocused.data('ms-value'));
|
210
222
|
} else {
|
211
|
-
that.deselect(liFocused.
|
223
|
+
that.deselect(liFocused.data('ms-value'));
|
212
224
|
}
|
213
225
|
lis.removeClass('ms-hover');
|
214
226
|
that.scrollTo = 0;
|
@@ -273,17 +285,20 @@
|
|
273
285
|
that.options.afterInit.call(this, this.$container);
|
274
286
|
}
|
275
287
|
},
|
288
|
+
|
276
289
|
'refresh' : function() {
|
277
290
|
$("#ms-"+this.$element.attr("id")).remove();
|
278
291
|
this.init(this.options);
|
279
292
|
},
|
293
|
+
|
280
294
|
'select' : function(value, method){
|
281
295
|
if (typeof value == 'string')
|
282
296
|
value = [value]
|
283
297
|
var that = this,
|
284
298
|
ms = this.$element,
|
285
|
-
|
286
|
-
|
299
|
+
msIds = $.map(value, function(val, index){ return(that.sanitize(val)) }),
|
300
|
+
selectables = this.$selectableUl.find('#' + msIds.join('-selectable, #')+'-selectable').filter(':not(.'+that.options.disabledClass+')'),
|
301
|
+
selections = this.$selectionUl.find('#' + msIds.join('-selection, #') + '-selection'),
|
287
302
|
options = ms.find('option').filter(function(index){ return($.inArray(this.value, value) > -1) });
|
288
303
|
|
289
304
|
if (selectables.length > 0){
|
@@ -318,13 +333,15 @@
|
|
318
333
|
}
|
319
334
|
}
|
320
335
|
},
|
336
|
+
|
321
337
|
'deselect' : function(value){
|
322
338
|
if (typeof value == 'string')
|
323
339
|
value = [value]
|
324
340
|
var that = this,
|
325
341
|
ms = this.$element,
|
326
|
-
|
327
|
-
|
342
|
+
msIds = $.map(value, function(val, index){ return(that.sanitize(val)) }),
|
343
|
+
selectables = this.$selectableUl.find('#' + msIds.join('-selectable, #')+'-selectable'),
|
344
|
+
selections = this.$selectionUl.find('#' + msIds.join('-selection, #')+'-selection').filter('.ms-selected'),
|
328
345
|
options = ms.find('option').filter(function(index){ return($.inArray(this.value, value) > -1) });
|
329
346
|
|
330
347
|
if (selections.length > 0){
|
@@ -357,6 +374,7 @@
|
|
357
374
|
}
|
358
375
|
}
|
359
376
|
},
|
377
|
+
|
360
378
|
'select_all' : function(){
|
361
379
|
var ms = this.$element;
|
362
380
|
|
@@ -369,6 +387,7 @@
|
|
369
387
|
this.$selectableUl.focusout();
|
370
388
|
ms.trigger('change');
|
371
389
|
},
|
390
|
+
|
372
391
|
'deselect_all' : function(){
|
373
392
|
var ms = this.$element;
|
374
393
|
|
@@ -381,6 +400,7 @@
|
|
381
400
|
this.$selectionUl.focusout();
|
382
401
|
ms.trigger('change');
|
383
402
|
},
|
403
|
+
|
384
404
|
isDomNode: function (attr){
|
385
405
|
return (
|
386
406
|
attr &&
|
@@ -388,6 +408,10 @@
|
|
388
408
|
typeof attr.nodeType === "number" &&
|
389
409
|
typeof attr.nodeName === "string"
|
390
410
|
);
|
411
|
+
},
|
412
|
+
|
413
|
+
sanitize: function(value){
|
414
|
+
return(value.replace(/[^A-Za-z0-9]*/gi, '_'));
|
391
415
|
}
|
392
416
|
}
|
393
417
|
|
@@ -1,86 +1,93 @@
|
|
1
|
-
.ms-container{
|
2
|
-
background: transparent image-url('switch.png') no-repeat 170px 80px;
|
3
|
-
}
|
4
|
-
|
5
|
-
.ms-container:after{
|
6
|
-
content: "."; display: block; height: 0; line-height: 0; font-size: 0; clear: both; min-height: 0; visibility: hidden;
|
7
|
-
}
|
8
|
-
|
9
|
-
.ms-container .ms-selectable, .ms-container .ms-selection{
|
10
|
-
|
11
|
-
background: #fff;
|
12
|
-
color: #555555;
|
13
|
-
float: left;
|
14
|
-
}
|
15
|
-
|
16
|
-
.ms-container .ms-list{
|
17
|
-
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
18
|
-
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
19
|
-
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
20
|
-
-webkit-transition: border linear 0.2s, box-shadow linear 0.2s;
|
21
|
-
-moz-transition: border linear 0.2s, box-shadow linear 0.2s;
|
22
|
-
-ms-transition: border linear 0.2s, box-shadow linear 0.2s;
|
23
|
-
-o-transition: border linear 0.2s, box-shadow linear 0.2s;
|
24
|
-
transition: border linear 0.2s, box-shadow linear 0.2s;
|
25
|
-
|
26
|
-
-webkit-border-radius: 3px;
|
27
|
-
-moz-border-radius: 3px;
|
28
|
-
border-radius: 3px;
|
29
|
-
}
|
30
|
-
|
31
|
-
|
32
|
-
.ms-selected{
|
33
|
-
display:none;
|
34
|
-
}
|
35
|
-
.ms-container .ms-selectable{
|
36
|
-
margin-right: 40px;
|
37
|
-
}
|
38
|
-
|
39
|
-
.ms-container .ms-list.ms-focus{
|
40
|
-
border-color: rgba(82, 168, 236, 0.8);
|
41
|
-
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
|
42
|
-
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
|
43
|
-
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
|
44
|
-
outline: 0;
|
45
|
-
outline: thin dotted \9;
|
46
|
-
}
|
47
|
-
|
48
|
-
.ms-container ul{
|
49
|
-
margin: 0;
|
50
|
-
list-style-type: none;
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
padding:
|
76
|
-
|
77
|
-
|
78
|
-
}
|
79
|
-
|
80
|
-
.ms-container
|
81
|
-
.ms-container .ms-selection li
|
82
|
-
cursor: pointer;
|
83
|
-
color: #
|
84
|
-
text-decoration: none;
|
85
|
-
background-color: #
|
86
|
-
}
|
1
|
+
.ms-container{
|
2
|
+
background: transparent image-url('switch.png') no-repeat 170px 80px;
|
3
|
+
}
|
4
|
+
|
5
|
+
.ms-container:after{
|
6
|
+
content: "."; display: block; height: 0; line-height: 0; font-size: 0; clear: both; min-height: 0; visibility: hidden;
|
7
|
+
}
|
8
|
+
|
9
|
+
.ms-container .ms-selectable, .ms-container .ms-selection{
|
10
|
+
|
11
|
+
background: #fff;
|
12
|
+
color: #555555;
|
13
|
+
float: left;
|
14
|
+
}
|
15
|
+
|
16
|
+
.ms-container .ms-list{
|
17
|
+
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
18
|
+
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
19
|
+
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
20
|
+
-webkit-transition: border linear 0.2s, box-shadow linear 0.2s;
|
21
|
+
-moz-transition: border linear 0.2s, box-shadow linear 0.2s;
|
22
|
+
-ms-transition: border linear 0.2s, box-shadow linear 0.2s;
|
23
|
+
-o-transition: border linear 0.2s, box-shadow linear 0.2s;
|
24
|
+
transition: border linear 0.2s, box-shadow linear 0.2s;
|
25
|
+
border: 1px solid #ccc;
|
26
|
+
-webkit-border-radius: 3px;
|
27
|
+
-moz-border-radius: 3px;
|
28
|
+
border-radius: 3px;
|
29
|
+
}
|
30
|
+
|
31
|
+
|
32
|
+
.ms-selected{
|
33
|
+
display:none;
|
34
|
+
}
|
35
|
+
.ms-container .ms-selectable{
|
36
|
+
margin-right: 40px;
|
37
|
+
}
|
38
|
+
|
39
|
+
.ms-container .ms-list.ms-focus{
|
40
|
+
border-color: rgba(82, 168, 236, 0.8);
|
41
|
+
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
|
42
|
+
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
|
43
|
+
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
|
44
|
+
outline: 0;
|
45
|
+
outline: thin dotted \9;
|
46
|
+
}
|
47
|
+
|
48
|
+
.ms-container ul{
|
49
|
+
margin: 0;
|
50
|
+
list-style-type: none;
|
51
|
+
padding: 0;
|
52
|
+
}
|
53
|
+
|
54
|
+
.ms-container .ms-optgroup-container{
|
55
|
+
width: 100%;
|
56
|
+
}
|
57
|
+
|
58
|
+
.ms-container ul.ms-list{
|
59
|
+
width: 160px;
|
60
|
+
height: 200px;
|
61
|
+
padding: 0;
|
62
|
+
overflow-y: auto;
|
63
|
+
}
|
64
|
+
|
65
|
+
.ms-container .ms-optgroup-label{
|
66
|
+
margin: 0;
|
67
|
+
padding: 5px 0px 0px 5px;
|
68
|
+
cursor: pointer;
|
69
|
+
color: #999;
|
70
|
+
}
|
71
|
+
|
72
|
+
.ms-container .ms-selectable li.ms-elem-selectable,
|
73
|
+
.ms-container .ms-selection li.ms-elem-selection{
|
74
|
+
border-bottom: 1px #eee solid;
|
75
|
+
padding: 2px 10px;
|
76
|
+
color: #555;
|
77
|
+
font-size: 14px;
|
78
|
+
}
|
79
|
+
|
80
|
+
.ms-container .ms-selectable li.ms-hover,
|
81
|
+
.ms-container .ms-selection li.ms-hover{
|
82
|
+
cursor: pointer;
|
83
|
+
color: #fff;
|
84
|
+
text-decoration: none;
|
85
|
+
background-color: #08c;
|
86
|
+
}
|
87
|
+
|
88
|
+
.ms-container .ms-selectable li.disabled,
|
89
|
+
.ms-container .ms-selection li.disabled{
|
90
|
+
background-color: #eee;
|
91
|
+
color: #aaa;
|
92
|
+
cursor: text;
|
93
|
+
}
|
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.
|
4
|
+
version: 0.9.3
|
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:
|
12
|
+
date: 2013-01-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- .gitignore
|
70
70
|
- Gemfile
|
71
71
|
- README.md
|
72
|
+
- Rakefile
|
72
73
|
- lib/multi-select-rails.rb
|
73
74
|
- lib/multi-select-rails/engine.rb
|
74
75
|
- lib/multi-select-rails/railtie.rb
|
@@ -92,7 +93,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
92
93
|
version: '0'
|
93
94
|
segments:
|
94
95
|
- 0
|
95
|
-
hash: -
|
96
|
+
hash: -448448030300929018
|
96
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
98
|
none: false
|
98
99
|
requirements:
|
@@ -101,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
102
|
version: '0'
|
102
103
|
segments:
|
103
104
|
- 0
|
104
|
-
hash: -
|
105
|
+
hash: -448448030300929018
|
105
106
|
requirements: []
|
106
107
|
rubyforge_project:
|
107
108
|
rubygems_version: 1.8.24
|