combo_auto_box 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
@@ -19,6 +19,11 @@ var ComboAutoBox = {
|
|
19
19
|
if (options.type == 'full') {
|
20
20
|
$('#' + inputId).autocomplete( "close" );
|
21
21
|
selectData($('#' + inputId).val());
|
22
|
+
} else if (options.type == 'multiple') {
|
23
|
+
$('#' + inputId).autocomplete( "close" );
|
24
|
+
addItem(inputId, $('#' + inputId).val(), $('#' + inputId).val());
|
25
|
+
selectData($('#' + inputId).val());
|
26
|
+
$('#' + inputId).val('');
|
22
27
|
}
|
23
28
|
return false;
|
24
29
|
}
|
@@ -29,8 +34,13 @@ var ComboAutoBox = {
|
|
29
34
|
select: function(event, ui) {
|
30
35
|
if (options.type == 'simple') {
|
31
36
|
return selectData(ui.item.id);
|
32
|
-
} else {
|
37
|
+
} else if (options.type == 'full') {
|
33
38
|
return selectData($('#' + inputId).val());
|
39
|
+
} else if (options.type == 'multiple') {
|
40
|
+
$('#' + inputId).val('');
|
41
|
+
addItem(inputId, ui.item.label, ui.item.id);
|
42
|
+
selectData(ui.item.id);
|
43
|
+
return false;
|
34
44
|
}
|
35
45
|
}
|
36
46
|
});
|
@@ -54,7 +64,10 @@ var ComboAutoBox = {
|
|
54
64
|
var html = 'input type="text"';
|
55
65
|
if (options.html != null) {
|
56
66
|
$.each(options.html, function(key, value) {
|
57
|
-
|
67
|
+
if ((key == 'name') && (options.type == 'multiple')) {
|
68
|
+
return true;
|
69
|
+
}
|
70
|
+
html = html + ' '+ key +'="' + value + '"';
|
58
71
|
});
|
59
72
|
}
|
60
73
|
|
@@ -72,7 +85,14 @@ var ComboAutoBox = {
|
|
72
85
|
|
73
86
|
// Global div for combo auto box
|
74
87
|
var generateDivTag = function () {
|
75
|
-
|
88
|
+
var derivation = ''
|
89
|
+
if (options.type == 'multiple') {
|
90
|
+
derivation = ' multiple'
|
91
|
+
} else if (options.type == 'searchable') {
|
92
|
+
derivation = ' searchable'
|
93
|
+
}
|
94
|
+
|
95
|
+
return '<div class="container-combo-auto-box' + derivation + '">' + generateInputTag() + '</div>';
|
76
96
|
};
|
77
97
|
|
78
98
|
// dialog modal
|
@@ -157,7 +177,27 @@ var ComboAutoBox = {
|
|
157
177
|
|
158
178
|
generateDivDialogModal(generateAnId('model-dialog'));
|
159
179
|
};
|
180
|
+
|
181
|
+
// add item
|
182
|
+
var addItem = function (inputId, selectedData, selectedId) {
|
183
|
+
if (selectedData != '') {
|
184
|
+
var id = generateAnId('item');
|
185
|
+
$('#' + inputId).before('<div class="item" title="Remove Item" id="' + id + '">'+ selectedData +'<span>x</span><input type="hidden" name="'+ options.html.name +'[]" value="'+ selectedId +'"></div>');
|
186
|
+
|
187
|
+
$('#' + id + ' > span').click(function() {
|
188
|
+
$(this).parent().remove();
|
189
|
+
});
|
190
|
+
|
191
|
+
}
|
192
|
+
};
|
160
193
|
|
194
|
+
// Bind click on div for multiple
|
195
|
+
var bindContainerClick = function(inputId) {
|
196
|
+
$('#' + container + ' > div.multiple').click(function() {
|
197
|
+
$('#' + inputId).focus();
|
198
|
+
});
|
199
|
+
};
|
200
|
+
|
161
201
|
// on select data
|
162
202
|
var selectData = function (selectedData) {
|
163
203
|
if (options.complete != null) {
|
@@ -170,7 +210,7 @@ var ComboAutoBox = {
|
|
170
210
|
options = {};
|
171
211
|
}
|
172
212
|
|
173
|
-
if ((options.type == null) || ((options.type != 'simple') && (options.type != 'full'))) {
|
213
|
+
if ((options.type == null) || ((options.type != 'simple') && (options.type != 'full') && (options.type != 'multiple') && (options.type != 'searchable'))) {
|
174
214
|
options.type = 'simple';
|
175
215
|
}
|
176
216
|
|
@@ -181,6 +221,8 @@ var ComboAutoBox = {
|
|
181
221
|
|
182
222
|
if (options.type == 'simple') {
|
183
223
|
generateModalDialog(textField);
|
224
|
+
} else if (options.type == 'multiple') {
|
225
|
+
bindContainerClick(textField.attr('id'));
|
184
226
|
}
|
185
227
|
}
|
186
228
|
|
@@ -3,6 +3,14 @@ div.container-combo-auto-box span.expand{display:block;position:absolute;cursor:
|
|
3
3
|
|
4
4
|
div.container-combo-auto-box span.expand i{background-image:url(/assets/combo_auto_box_expand.png);width:19px;height:19px;display:block;font-size:0;}
|
5
5
|
|
6
|
+
div.multiple { border: 1px solid #CDCDCD; display:table; }
|
7
|
+
div.multiple input { border: 0px; float:left; height:22px; }
|
8
|
+
|
9
|
+
div.multiple div.item { font-family: arial,sans-serif; float:left; background-color:#EDEDED; margin: 2px 10px 2px 2px; padding:2px 10px 2px 10px; -moz-border-radius:4px;-webkit-border-radius:4px; border:1px solid #CECECE; font-size: 13px; }
|
10
|
+
div.multiple div.item span { margin-left:10px; color:#CCCCCC; }
|
11
|
+
div.multiple div.item span:hover { color:#9A9A9A; cursor:pointer;}
|
12
|
+
div.multiple input:focus {outline:none; }
|
13
|
+
|
6
14
|
div.dialog-modal div.head { display:block; width:99%; position:absolute; z-index:2002; top:0px; left:0px; border: 1px solid #000; background-color:#CECECE; height:30px; -moz-border-radius:4px;-webkit-border-radius:4px;}
|
7
15
|
div.dialog-modal div.head span.label { float:left; margin: 5px 0 0 10px; padding: 0 0 0 0; text-weight: bold; font-size:16px; font-family: "Trebuchet MS", "Helvetica", "Arial", "Verdana", "sans-serif";}
|
8
16
|
div.dialog-modal div.head span.close { float:right; margin: 5px 10px 0 0; padding: 0 0 0 0; font-size:16px; font-family: "Trebuchet MS", "Helvetica", "Arial", "Verdana", "sans-serif"; text-indent: 0;}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: combo_auto_box
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.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-
|
12
|
+
date: 2013-07-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|