multi-select 0.0.1
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.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +37 -0
- data/Rakefile +1 -0
- data/lib/multi-select.rb +9 -0
- data/lib/multi-select/version.rb +5 -0
- data/multi-select.gemspec +18 -0
- data/vendor/assets/images/switch.png +0 -0
- data/vendor/assets/javascripts/jquery.multi-select.js +334 -0
- data/vendor/assets/stylesheets/multi-select.css +86 -0
- metadata +57 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2012 Alagunambi Welkin
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Multi::Select
|
|
2
|
+
|
|
3
|
+
A simple gem to integrate Jquery multi-select js feature
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
gem 'multi-select'
|
|
10
|
+
|
|
11
|
+
And then execute:
|
|
12
|
+
|
|
13
|
+
$ bundle
|
|
14
|
+
|
|
15
|
+
Or install it yourself as:
|
|
16
|
+
|
|
17
|
+
$ gem install multi-select
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
Just add in application.js:
|
|
22
|
+
|
|
23
|
+
//= require jquery.multi-select.js
|
|
24
|
+
|
|
25
|
+
In application.css:
|
|
26
|
+
|
|
27
|
+
*= require multi-select.css
|
|
28
|
+
|
|
29
|
+
For more on usage and demos please refer http://loudev.com/
|
|
30
|
+
|
|
31
|
+
## Contributing
|
|
32
|
+
|
|
33
|
+
1. Fork it
|
|
34
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
35
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
36
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
37
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/multi-select.rb
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'multi-select/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |gem|
|
|
7
|
+
gem.name = "multi-select"
|
|
8
|
+
gem.version = Multi::Select::VERSION
|
|
9
|
+
gem.authors = ["Alagunambi Welkin"]
|
|
10
|
+
gem.email = ["welkin@udproducts.in"]
|
|
11
|
+
gem.description = %q{A gem to integrate Jquery multi-select js}
|
|
12
|
+
gem.summary = %q{Simple integrator of Jquery multi-select js(http://loudev.com/)}
|
|
13
|
+
gem.homepage = "https://github.com/udproducts/multi-select"
|
|
14
|
+
gem.files = `git ls-files`.split($/)
|
|
15
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
16
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
17
|
+
gem.require_paths = ["lib", "vendor"]
|
|
18
|
+
end
|
|
Binary file
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* MultiSelect v0.8
|
|
3
|
+
* Copyright (c) 2012 Louis Cuny
|
|
4
|
+
*
|
|
5
|
+
* This program is free software. It comes without any warranty, to
|
|
6
|
+
* the extent permitted by applicable law. You can redistribute it
|
|
7
|
+
* and/or modify it under the terms of the Do What The Fuck You Want
|
|
8
|
+
* To Public License, Version 2, as published by Sam Hocevar. See
|
|
9
|
+
* http://sam.zoy.org/wtfpl/COPYING for more details.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
(function($){
|
|
13
|
+
var msMethods = {
|
|
14
|
+
'init' : function(options){
|
|
15
|
+
this.settings = {
|
|
16
|
+
disabledClass : 'disabled',
|
|
17
|
+
selectCallbackOnInit: false,
|
|
18
|
+
keepOrder : false,
|
|
19
|
+
dblClick : false
|
|
20
|
+
};
|
|
21
|
+
if(options) {
|
|
22
|
+
this.settings = $.extend(this.settings, options);
|
|
23
|
+
}
|
|
24
|
+
var multiSelects = this;
|
|
25
|
+
multiSelects.css('position', 'absolute').css('left', '-9999px');
|
|
26
|
+
return multiSelects.each(function(){
|
|
27
|
+
var ms = $(this);
|
|
28
|
+
|
|
29
|
+
if (ms.next('.ms-container').length == 0){
|
|
30
|
+
ms.attr('id', ms.attr('id') ? ms.attr('id') : 'ms-'+Math.ceil(Math.random()*1000));
|
|
31
|
+
var container = $('<div id="ms-'+ms.attr('id')+'" class="ms-container"></div>'),
|
|
32
|
+
selectableContainer = $('<div class="ms-selectable"></div>'),
|
|
33
|
+
selectedContainer = $('<div class="ms-selection"></div>'),
|
|
34
|
+
selectableUl = $('<ul class="ms-list"></ul>'),
|
|
35
|
+
selectedUl = $('<ul class="ms-list"></ul>');
|
|
36
|
+
|
|
37
|
+
ms.data('settings', multiSelects.settings);
|
|
38
|
+
|
|
39
|
+
var optgroupLabel = null,
|
|
40
|
+
optgroupId = null,
|
|
41
|
+
optgroupCpt = 0,
|
|
42
|
+
scroll = 0;
|
|
43
|
+
ms.find('optgroup,option').each(function(){
|
|
44
|
+
if ($(this).is('optgroup')){
|
|
45
|
+
optgroupLabel = $(this).attr('label');
|
|
46
|
+
optgroupId = 'ms-'+ms.attr('id')+'-optgroup-'+optgroupCpt;
|
|
47
|
+
selectableUl.append($('<li class="ms-optgroup-container" id="'+
|
|
48
|
+
optgroupId+'"><ul class="ms-optgroup"><li class="ms-optgroup-label">'+
|
|
49
|
+
optgroupLabel+'</li></ul></li>'));
|
|
50
|
+
optgroupCpt++;
|
|
51
|
+
} else {
|
|
52
|
+
var klass = $(this).attr('class') ? ' '+$(this).attr('class') : '';
|
|
53
|
+
var selectableLi = $('<li class="ms-elem-selectable'+klass+'" ms-value="'+$(this).val()+'">'+$(this).text()+'</li>');
|
|
54
|
+
|
|
55
|
+
if ($(this).attr('title'))
|
|
56
|
+
selectableLi.attr('title', $(this).attr('title'));
|
|
57
|
+
if ($(this).attr('disabled') || ms.attr('disabled')){
|
|
58
|
+
selectableLi.attr('disabled', 'disabled');
|
|
59
|
+
selectableLi.addClass(multiSelects.settings.disabledClass);
|
|
60
|
+
}
|
|
61
|
+
if(multiSelects.settings.dblClick) {
|
|
62
|
+
selectableLi.dblclick(function(){
|
|
63
|
+
ms.multiSelect('select', $(this).attr('ms-value'));
|
|
64
|
+
});
|
|
65
|
+
} else {
|
|
66
|
+
selectableLi.click(function(){
|
|
67
|
+
ms.multiSelect('select', $(this).attr('ms-value'));
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
var container = optgroupId ? selectableUl.children('#'+optgroupId).find('ul').first() : selectableUl;
|
|
71
|
+
container.append(selectableLi);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
if (multiSelects.settings.selectableHeader){
|
|
75
|
+
selectableContainer.append(multiSelects.settings.selectableHeader);
|
|
76
|
+
}
|
|
77
|
+
selectableContainer.append(selectableUl);
|
|
78
|
+
if (multiSelects.settings.selectedHeader){
|
|
79
|
+
selectedContainer.append(multiSelects.settings.selectedHeader);
|
|
80
|
+
}
|
|
81
|
+
selectedContainer.append(selectedUl);
|
|
82
|
+
container.append(selectableContainer);
|
|
83
|
+
container.append(selectedContainer);
|
|
84
|
+
ms.after(container);
|
|
85
|
+
ms.find('option:selected').each(function(){
|
|
86
|
+
ms.multiSelect('select', $(this).val(), 'init');
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
$('.ms-elem-selectable', selectableUl).on('mouseenter', function(){
|
|
90
|
+
$('li', container).removeClass('ms-hover');
|
|
91
|
+
$(this).addClass('ms-hover');
|
|
92
|
+
}).on('mouseout', function(){
|
|
93
|
+
$('li', container).removeClass('ms-hover');
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
selectableUl.on('focusin', function(){
|
|
99
|
+
$(this).addClass('ms-focus');
|
|
100
|
+
selectedUl.focusout();
|
|
101
|
+
}).on('focusout', function(){
|
|
102
|
+
$(this).removeClass('ms-focus');
|
|
103
|
+
$('li', container).removeClass('ms-hover');
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
selectedUl.on('focusin', function(){
|
|
107
|
+
$(this).addClass('ms-focus');
|
|
108
|
+
}).on('focusout', function(){
|
|
109
|
+
$(this).removeClass('ms-focus');
|
|
110
|
+
$('li', container).removeClass('ms-hover');
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
ms.on('focusin', function(){
|
|
114
|
+
selectableUl.focus();
|
|
115
|
+
}).on('focusout', function(){
|
|
116
|
+
selectableUl.removeClass('ms-focus');
|
|
117
|
+
selectedUl.removeClass('ms-focus');
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
ms.onKeyDown = function(e, keyContainer){
|
|
121
|
+
var selectables = $('.'+keyContainer+' li:visible:not(.ms-optgroup-label, .ms-optgroup-container)', container),
|
|
122
|
+
selectablesLength = selectables.length,
|
|
123
|
+
selectableFocused = $('.'+keyContainer+' li.ms-hover', container),
|
|
124
|
+
selectableFocusedIndex = $('.'+keyContainer+' li:visible:not(.ms-optgroup-label, .ms-optgroup-container)', container).index(selectableFocused),
|
|
125
|
+
liHeight = selectables.first().outerHeight(),
|
|
126
|
+
numberOfItemsDisplayed = Math.ceil(container.outerHeight()/liHeight),
|
|
127
|
+
scrollStart = Math.ceil(numberOfItemsDisplayed/4);
|
|
128
|
+
|
|
129
|
+
selectables.removeClass('ms-hover');
|
|
130
|
+
if (e.keyCode == 32){ // space
|
|
131
|
+
var method = keyContainer == 'ms-selectable' ? 'select' : 'deselect';
|
|
132
|
+
ms.multiSelect(method, selectableFocused.first().attr('ms-value'));
|
|
133
|
+
|
|
134
|
+
} else if (e.keyCode == 40){ // Down
|
|
135
|
+
var nextIndex = (selectableFocusedIndex+1 != selectablesLength) ? selectableFocusedIndex+1 : 0,
|
|
136
|
+
nextSelectableLi = selectables.eq(nextIndex);
|
|
137
|
+
|
|
138
|
+
nextSelectableLi.addClass('ms-hover');
|
|
139
|
+
if (nextIndex > scrollStart){
|
|
140
|
+
scroll += liHeight;
|
|
141
|
+
} else if (nextIndex == 0){
|
|
142
|
+
scroll = 0;
|
|
143
|
+
}
|
|
144
|
+
$('.'+keyContainer+' ul', container).scrollTop(scroll);
|
|
145
|
+
} else if (e.keyCode == 38){ // Up
|
|
146
|
+
var prevIndex = (selectableFocusedIndex-1 >= 0) ? selectableFocusedIndex-1 : selectablesLength-1,
|
|
147
|
+
prevSelectableLi = selectables.eq(prevIndex);
|
|
148
|
+
selectables.removeClass('ms-hover');
|
|
149
|
+
prevSelectableLi.addClass('ms-hover');
|
|
150
|
+
if (selectablesLength-prevIndex+1 < scrollStart){
|
|
151
|
+
scroll = liHeight*(selectablesLength-scrollStart);
|
|
152
|
+
} else {
|
|
153
|
+
scroll -= liHeight;
|
|
154
|
+
}
|
|
155
|
+
$('.'+keyContainer+' ul', container).scrollTop(scroll);
|
|
156
|
+
} else if (e.keyCode == 37 || e.keyCode == 39){ // Right and Left
|
|
157
|
+
if (selectableUl.hasClass('ms-focus')){
|
|
158
|
+
selectableUl.focusout();
|
|
159
|
+
selectedUl.focusin();
|
|
160
|
+
} else {
|
|
161
|
+
selectableUl.focusin();
|
|
162
|
+
selectedUl.focusout();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
ms.on('keydown', function(e){
|
|
168
|
+
if (ms.is(':focus')){
|
|
169
|
+
var keyContainer = selectableUl.hasClass('ms-focus') ? 'ms-selectable' : 'ms-selection';
|
|
170
|
+
ms.onKeyDown(e, keyContainer);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
},
|
|
176
|
+
'refresh' : function() {
|
|
177
|
+
$("#ms-"+$(this).attr("id")).remove();
|
|
178
|
+
$(this).multiSelect("init", $(this).data("settings"));
|
|
179
|
+
},
|
|
180
|
+
'select' : function(value, method){
|
|
181
|
+
var ms = this,
|
|
182
|
+
selectedOption = ms.find('option[value="'+value +'"]'),
|
|
183
|
+
text = selectedOption.text(),
|
|
184
|
+
klass = selectedOption.attr('class'),
|
|
185
|
+
titleAttr = selectedOption.attr('title');
|
|
186
|
+
|
|
187
|
+
var selectedLi = $('<li class="ms-elem-selected'+(klass ? ' '+klass : '')+'" ms-value="'+value+'">'+text+'</li>'),
|
|
188
|
+
selectableUl = $('#ms-'+ms.attr('id')+' .ms-selectable ul'),
|
|
189
|
+
selectedUl = $('#ms-'+ms.attr('id')+' .ms-selection ul'),
|
|
190
|
+
selectableLi = selectableUl.children('li[ms-value="'+value+'"]'),
|
|
191
|
+
haveToSelect = null;
|
|
192
|
+
|
|
193
|
+
if (method == 'init'){
|
|
194
|
+
haveToSelect = !selectableLi.hasClass(ms.data('settings').disabledClass) && selectedOption.prop('selected');
|
|
195
|
+
} else {
|
|
196
|
+
haveToSelect = !selectableLi.hasClass(ms.data('settings').disabledClass);
|
|
197
|
+
ms.focus();
|
|
198
|
+
}
|
|
199
|
+
if (haveToSelect && selectedUl.children('li[ms-value="'+value+'"]').length == 0){
|
|
200
|
+
var parentOptgroup = selectableLi.parent('.ms-optgroup');
|
|
201
|
+
if (parentOptgroup.length > 0)
|
|
202
|
+
if (parentOptgroup.children('.ms-elem-selectable:not(:hidden)').length == 1)
|
|
203
|
+
parentOptgroup.children('.ms-optgroup-label').hide();
|
|
204
|
+
selectableLi.addClass('ms-selected');
|
|
205
|
+
selectableLi.hide();
|
|
206
|
+
selectedOption.prop('selected', true);
|
|
207
|
+
if(titleAttr){
|
|
208
|
+
selectedLi.attr('title', titleAttr)
|
|
209
|
+
}
|
|
210
|
+
if (selectableLi.hasClass(ms.data('settings').disabledClass)){
|
|
211
|
+
selectedLi.addClass(ms.data('settings').disabledClass);
|
|
212
|
+
} else {
|
|
213
|
+
if(ms.data('settings').dblClick) {
|
|
214
|
+
selectedLi.dblclick(function(){
|
|
215
|
+
ms.multiSelect('deselect', $(this).attr('ms-value'));
|
|
216
|
+
});
|
|
217
|
+
} else {
|
|
218
|
+
selectedLi.click(function(){
|
|
219
|
+
ms.multiSelect('deselect', $(this).attr('ms-value'));
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
var selectedUlLis = selectedUl.children('.ms-elem-selected');
|
|
225
|
+
if (method != 'init' && ms.data('settings').keepOrder && selectedUlLis.length > 0) {
|
|
226
|
+
|
|
227
|
+
var getIndexOf = function(value) {
|
|
228
|
+
elems = selectableUl.children('.ms-elem-selectable');
|
|
229
|
+
return(elems.index(elems.closest('[ms-value="'+value+'"]')));
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
var index = getIndexOf(selectedLi.attr('ms-value'));
|
|
233
|
+
if (index == 0)
|
|
234
|
+
selectedUl.prepend(selectedLi);
|
|
235
|
+
else {
|
|
236
|
+
for (i = index - 1; i >= 0; i--){
|
|
237
|
+
if (selectedUlLis[i] && getIndexOf($(selectedUlLis[i]).attr('ms-value')) < index) {
|
|
238
|
+
$(selectedUlLis[i]).after(selectedLi);
|
|
239
|
+
break;
|
|
240
|
+
} else if (i == 0) {
|
|
241
|
+
$(selectedUlLis[i]).before(selectedLi);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
} else {
|
|
246
|
+
selectedUl.append(selectedLi);
|
|
247
|
+
}
|
|
248
|
+
selectedLi.on('mouseenter', function(){
|
|
249
|
+
$('li', selectedUl).removeClass('ms-hover');
|
|
250
|
+
$(this).addClass('ms-hover');
|
|
251
|
+
}).on('mouseout', function(){
|
|
252
|
+
$('li', selectedUl).removeClass('ms-hover');
|
|
253
|
+
});
|
|
254
|
+
if (method == "select_all" && parentOptgroup.children('.ms-elem-selectable').length > 0){
|
|
255
|
+
parentOptgroup.children('.ms-optgroup-label').hide();
|
|
256
|
+
}
|
|
257
|
+
if(method != 'init' || ms.data('settings').selectCallbackOnInit){
|
|
258
|
+
ms.trigger('change');
|
|
259
|
+
selectedUl.trigger('change');
|
|
260
|
+
selectableUl.trigger('change');
|
|
261
|
+
if (typeof ms.data('settings').afterSelect == 'function' &&
|
|
262
|
+
(method != 'init' || ms.data('settings').selectCallbackOnInit)) {
|
|
263
|
+
ms.data('settings').afterSelect.call(this, value, text);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
'deselect' : function(value){
|
|
269
|
+
var ms = this,
|
|
270
|
+
selectedUl = $('#ms-'+ms.attr('id')+' .ms-selection ul'),
|
|
271
|
+
selectedOption = ms.find('option[value="'+value +'"]'),
|
|
272
|
+
selectedLi = selectedUl.children('li[ms-value="'+value+'"]');
|
|
273
|
+
|
|
274
|
+
if(selectedLi){
|
|
275
|
+
selectedUl.focusin();
|
|
276
|
+
var selectableUl = $('#ms-'+ms.attr('id')+' .ms-selectable ul'),
|
|
277
|
+
selectedUl = $('#ms-'+ms.attr('id')+' .ms-selection ul'),
|
|
278
|
+
selectableLi = selectableUl.children('li[ms-value="'+value+'"]'),
|
|
279
|
+
selectedLi = selectedUl.children('li[ms-value="'+value+'"]');
|
|
280
|
+
|
|
281
|
+
var parentOptgroup = selectableLi.parent('.ms-optgroup');
|
|
282
|
+
if (parentOptgroup.length > 0){
|
|
283
|
+
parentOptgroup.children('.ms-optgroup-label').addClass('ms-collapse').show();
|
|
284
|
+
parentOptgroup.children('.ms-elem-selectable:not(.ms-selected)').show();
|
|
285
|
+
}
|
|
286
|
+
selectedOption.prop('selected', false);
|
|
287
|
+
selectableLi.show();
|
|
288
|
+
selectableLi.removeClass('ms-selected');
|
|
289
|
+
selectedLi.remove();
|
|
290
|
+
selectedUl.trigger('change');
|
|
291
|
+
selectableUl.trigger('change');
|
|
292
|
+
ms.trigger('change');
|
|
293
|
+
if (typeof ms.data('settings').afterDeselect == 'function') {
|
|
294
|
+
ms.data('settings').afterDeselect.call(this, value, selectedLi.text());
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
'select_all' : function(visible){
|
|
299
|
+
var ms = this,
|
|
300
|
+
selectableUl = $('#ms-'+ms.attr('id')+' .ms-selectable ul');
|
|
301
|
+
|
|
302
|
+
ms.find("option:not(:selected)").each(function(){
|
|
303
|
+
var value = $(this).val();
|
|
304
|
+
if (visible){
|
|
305
|
+
var selectableLi = selectableUl.children('li[ms-value="'+value+'"]');
|
|
306
|
+
if (selectableLi.filter(':visible').length > 0){
|
|
307
|
+
ms.multiSelect('select', value, 'select_all');
|
|
308
|
+
}
|
|
309
|
+
} else {
|
|
310
|
+
ms.multiSelect('select', value, 'select_all');
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
},
|
|
314
|
+
'deselect_all' : function(){
|
|
315
|
+
var ms = this,
|
|
316
|
+
selectedUl = $('#ms-'+ms.attr('id')+' .ms-selection ul');
|
|
317
|
+
|
|
318
|
+
ms.find("option:selected").each(function(){
|
|
319
|
+
ms.multiSelect('deselect', $(this).val(), 'deselect_all');
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
$.fn.multiSelect = function(method){
|
|
325
|
+
if ( msMethods[method] ) {
|
|
326
|
+
return msMethods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
|
|
327
|
+
} else if ( typeof method === 'object' || ! method ) {
|
|
328
|
+
return msMethods.init.apply( this, arguments );
|
|
329
|
+
} else {
|
|
330
|
+
if(console.log) console.log( 'Method ' + method + ' does not exist on jquery.multiSelect' );
|
|
331
|
+
}
|
|
332
|
+
return false;
|
|
333
|
+
};
|
|
334
|
+
})(jQuery);
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
.ms-container{
|
|
2
|
+
background: transparent url('../assets/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 #cccccc;
|
|
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
|
+
.ms-container ul.ms-list{
|
|
54
|
+
width: 160px;
|
|
55
|
+
height: 200px;
|
|
56
|
+
padding: 0px 0px;
|
|
57
|
+
overflow-y: auto;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.ms-container .ms-selectable li.ms-elem-selectable,
|
|
61
|
+
.ms-container .ms-selection li.ms-elem-selected{
|
|
62
|
+
border-bottom: 1px #eee solid;
|
|
63
|
+
padding: 2px 10px;
|
|
64
|
+
color: #555;
|
|
65
|
+
font-size: 14px;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.ms-container .ms-selectable li.disabled,
|
|
69
|
+
.ms-container .ms-selection li.disabled{
|
|
70
|
+
background-color: #eee;
|
|
71
|
+
color: #aaa;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.ms-container .ms-optgroup-label{
|
|
75
|
+
padding: 5px 0px 0px 5px;
|
|
76
|
+
cursor: pointer;
|
|
77
|
+
color: #999;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.ms-container li.ms-elem-selectable:not(.disabled).ms-hover,
|
|
81
|
+
.ms-container .ms-selection li:not(.disabled).ms-hover{
|
|
82
|
+
cursor: pointer;
|
|
83
|
+
color: #ffffff;
|
|
84
|
+
text-decoration: none;
|
|
85
|
+
background-color: #0088cc;
|
|
86
|
+
}
|
metadata
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: multi-select
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Alagunambi Welkin
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2012-11-15 00:00:00.000000000 Z
|
|
13
|
+
dependencies: []
|
|
14
|
+
description: A gem to integrate Jquery multi-select js
|
|
15
|
+
email:
|
|
16
|
+
- welkin@udproducts.in
|
|
17
|
+
executables: []
|
|
18
|
+
extensions: []
|
|
19
|
+
extra_rdoc_files: []
|
|
20
|
+
files:
|
|
21
|
+
- .gitignore
|
|
22
|
+
- Gemfile
|
|
23
|
+
- LICENSE.txt
|
|
24
|
+
- README.md
|
|
25
|
+
- Rakefile
|
|
26
|
+
- lib/multi-select.rb
|
|
27
|
+
- lib/multi-select/version.rb
|
|
28
|
+
- multi-select.gemspec
|
|
29
|
+
- vendor/assets/images/switch.png
|
|
30
|
+
- vendor/assets/javascripts/jquery.multi-select.js
|
|
31
|
+
- vendor/assets/stylesheets/multi-select.css
|
|
32
|
+
homepage: https://github.com/udproducts/multi-select
|
|
33
|
+
licenses: []
|
|
34
|
+
post_install_message:
|
|
35
|
+
rdoc_options: []
|
|
36
|
+
require_paths:
|
|
37
|
+
- lib
|
|
38
|
+
- vendor
|
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
40
|
+
none: false
|
|
41
|
+
requirements:
|
|
42
|
+
- - ! '>='
|
|
43
|
+
- !ruby/object:Gem::Version
|
|
44
|
+
version: '0'
|
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
46
|
+
none: false
|
|
47
|
+
requirements:
|
|
48
|
+
- - ! '>='
|
|
49
|
+
- !ruby/object:Gem::Version
|
|
50
|
+
version: '0'
|
|
51
|
+
requirements: []
|
|
52
|
+
rubyforge_project:
|
|
53
|
+
rubygems_version: 1.8.23
|
|
54
|
+
signing_key:
|
|
55
|
+
specification_version: 3
|
|
56
|
+
summary: Simple integrator of Jquery multi-select js(http://loudev.com/)
|
|
57
|
+
test_files: []
|