selectize-rails 0.9.1 → 0.11.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -20
- data/README.md +8 -7
- data/lib/selectize-rails/version.rb +1 -1
- data/update_from_vendor.sh +1 -1
- data/vendor/assets/javascripts/selectize.js +134 -56
- data/vendor/assets/stylesheets/selectize.bootstrap2.css +1 -1
- data/vendor/assets/stylesheets/selectize.bootstrap3.css +2 -2
- data/vendor/assets/stylesheets/selectize.css +1 -1
- data/vendor/assets/stylesheets/selectize.default.css +1 -1
- data/vendor/assets/stylesheets/selectize.legacy.css +1 -1
- metadata +2 -4
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6ddd296151375e4a6ec7c3bd1a15ff5139adc4b2
|
|
4
|
+
data.tar.gz: 6578eedb181b964165c7e82950efe047fd156696
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ccd238e0ffafe86c93f61860422edc40b2c29a177bca90737367f36d01f46a0737ed77dffc712ca98895c1039090f1a8b479ce7ba7f0d89f3860b53cd6357fd5
|
|
7
|
+
data.tar.gz: ad7b5c389063444e32f97f0304f9580625c6cdc191bb2f065bc2313048cad2106bbd79c0dfe76516f75f2a66bf9dafd5580c2c312a6e20370f37ec12ac52564b
|
data/CHANGELOG.md
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
| Version
|
|
4
|
-
|
|
|
5
|
-
| 0.
|
|
6
|
-
| 0.9.
|
|
7
|
-
| 0.
|
|
8
|
-
| 0.8.
|
|
9
|
-
| 0.8.
|
|
10
|
-
| 0.8.
|
|
11
|
-
| 0.8.
|
|
12
|
-
| 0.
|
|
13
|
-
| 0.7.
|
|
14
|
-
| 0.7.
|
|
15
|
-
| 0.7.
|
|
16
|
-
| 0.7.
|
|
17
|
-
| 0.7.
|
|
18
|
-
| 0.7.
|
|
19
|
-
|
|
|
20
|
-
|
|
|
21
|
-
| 0.6.
|
|
22
|
-
| 0.1
|
|
3
|
+
| Version | Notes |
|
|
4
|
+
| --------:| ----------------------------------------------------------- |
|
|
5
|
+
| 0.11.0 | Update to v0.11.0 of selectize.js |
|
|
6
|
+
| 0.9.1 | Update to v0.9.1 of selectize.js |
|
|
7
|
+
| 0.9.0 | Update to v0.9.0 of selectize.js |
|
|
8
|
+
| 0.8.5 | Update to v0.8.5 of selectize.js |
|
|
9
|
+
| 0.8.4 | Update to v0.8.4 of selectize.js |
|
|
10
|
+
| 0.8.3 | Update to v0.8.3 of selectize.js |
|
|
11
|
+
| 0.8.1 | Update to v0.8.1 of selectize.js |
|
|
12
|
+
| 0.8.0 | Update to v0.8.0 of selectize.js |
|
|
13
|
+
| 0.7.7 | Update to v0.7.7 of selectize.js |
|
|
14
|
+
| 0.7.6 | Update to v0.7.6 of selectize.js |
|
|
15
|
+
| 0.7.5 | Update to v0.7.5 of selectize.js |
|
|
16
|
+
| 0.7.4 | Update to v0.7.4 of selectize.js |
|
|
17
|
+
| 0.7.3 | Update to v0.7.3 of selectize.js |
|
|
18
|
+
| 0.7.2 | Update to v0.7.2 of selectize.js |
|
|
19
|
+
| 0.7.0 | Update to v0.7.0 of selectize.js |
|
|
20
|
+
| 0.6.14 | Update to v0.6.14 of selectize.js |
|
|
21
|
+
| 0.6.4 | Update to v0.6.4 of selectize.js |
|
|
22
|
+
| 0.6.1 | Update and set gem version equal to selectize.js version |
|
|
23
|
+
| 0.1.0 | Initial release |
|
data/README.md
CHANGED
|
@@ -39,13 +39,14 @@ See the [demo page of Brian Reavis](http://brianreavis.github.io/selectize.js/)
|
|
|
39
39
|
|
|
40
40
|
## Changes
|
|
41
41
|
|
|
42
|
-
| Version
|
|
43
|
-
|
|
|
44
|
-
| 0.
|
|
45
|
-
| 0.9.
|
|
46
|
-
| 0.
|
|
47
|
-
| 0.8.
|
|
48
|
-
| 0.8.
|
|
42
|
+
| Version | Notes |
|
|
43
|
+
| --------:| ----------------------------------------------------------- |
|
|
44
|
+
| 0.11.0 | Update to v0.11.0 of selectize.js |
|
|
45
|
+
| 0.9.1 | Update to v0.9.1 of selectize.js |
|
|
46
|
+
| 0.9.0 | Update to v0.9.0 of selectize.js |
|
|
47
|
+
| 0.8.5 | Update to v0.8.5 of selectize.js |
|
|
48
|
+
| 0.8.4 | Update to v0.8.4 of selectize.js |
|
|
49
|
+
| 0.8.3 | Update to v0.8.3 of selectize.js |
|
|
49
50
|
|
|
50
51
|
[older](CHANGELOG.md)
|
|
51
52
|
|
data/update_from_vendor.sh
CHANGED
|
@@ -12,6 +12,6 @@ cp tmp_vendor/dist/css/*.css vendor/assets/stylesheets/
|
|
|
12
12
|
|
|
13
13
|
# Delete vendor repo
|
|
14
14
|
echo "Removing cloned vendor repo"
|
|
15
|
-
rm -rf tmp_vendor
|
|
15
|
+
# rm -rf tmp_vendor
|
|
16
16
|
|
|
17
17
|
echo "Finished... You'll need to commit the changes. You should consider updating the changelog and gem version number"
|
|
@@ -425,17 +425,17 @@
|
|
|
425
425
|
};
|
|
426
426
|
|
|
427
427
|
var DIACRITICS = {
|
|
428
|
-
'a': '[
|
|
428
|
+
'a': '[aÀÁÂÃÄÅàáâãäåĀā]',
|
|
429
429
|
'c': '[cÇçćĆčČ]',
|
|
430
430
|
'd': '[dđĐďĎ]',
|
|
431
|
-
'e': '[
|
|
432
|
-
'i': '[
|
|
431
|
+
'e': '[eÈÉÊËèéêëěĚĒē]',
|
|
432
|
+
'i': '[iÌÍÎÏìíîïĪī]',
|
|
433
433
|
'n': '[nÑñňŇ]',
|
|
434
|
-
'o': '[
|
|
434
|
+
'o': '[oÒÓÔÕÕÖØòóôõöøŌō]',
|
|
435
435
|
'r': '[rřŘ]',
|
|
436
436
|
's': '[sŠš]',
|
|
437
437
|
't': '[tťŤ]',
|
|
438
|
-
'u': '[
|
|
438
|
+
'u': '[uÙÚÛÜùúûüůŮŪū]',
|
|
439
439
|
'y': '[yŸÿýÝ]',
|
|
440
440
|
'z': '[zŽž]'
|
|
441
441
|
};
|
|
@@ -585,7 +585,7 @@
|
|
|
585
585
|
}));
|
|
586
586
|
|
|
587
587
|
/**
|
|
588
|
-
* selectize.js (v0.
|
|
588
|
+
* selectize.js (v0.11.0)
|
|
589
589
|
* Copyright (c) 2013 Brian Reavis & contributors
|
|
590
590
|
*
|
|
591
591
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
|
@@ -726,10 +726,10 @@
|
|
|
726
726
|
* 1 -> '1'
|
|
727
727
|
*
|
|
728
728
|
* @param {string} value
|
|
729
|
-
* @returns {string}
|
|
729
|
+
* @returns {string|null}
|
|
730
730
|
*/
|
|
731
731
|
var hash_key = function(value) {
|
|
732
|
-
if (typeof value === 'undefined' || value === null) return
|
|
732
|
+
if (typeof value === 'undefined' || value === null) return null;
|
|
733
733
|
if (typeof value === 'boolean') return value ? '1' : '0';
|
|
734
734
|
return value + '';
|
|
735
735
|
};
|
|
@@ -1077,6 +1077,7 @@
|
|
|
1077
1077
|
isCmdDown : false,
|
|
1078
1078
|
isCtrlDown : false,
|
|
1079
1079
|
ignoreFocus : false,
|
|
1080
|
+
ignoreBlur : false,
|
|
1080
1081
|
ignoreHover : false,
|
|
1081
1082
|
hasOptions : false,
|
|
1082
1083
|
currentResults : null,
|
|
@@ -1113,6 +1114,16 @@
|
|
|
1113
1114
|
self.settings.hideSelected = self.settings.mode === 'multi';
|
|
1114
1115
|
}
|
|
1115
1116
|
|
|
1117
|
+
if (self.settings.create) {
|
|
1118
|
+
self.canCreate = function(input) {
|
|
1119
|
+
var filter = self.settings.createFilter;
|
|
1120
|
+
return input.length
|
|
1121
|
+
&& (typeof filter !== 'function' || filter.apply(self, [input]))
|
|
1122
|
+
&& (typeof filter !== 'string' || new RegExp(filter).test(input))
|
|
1123
|
+
&& (!(filter instanceof RegExp) || filter.test(input));
|
|
1124
|
+
};
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1116
1127
|
self.initializePlugins(self.settings.plugins);
|
|
1117
1128
|
self.setupCallbacks();
|
|
1118
1129
|
self.setupTemplates();
|
|
@@ -1139,6 +1150,7 @@
|
|
|
1139
1150
|
var eventNS = self.eventNS;
|
|
1140
1151
|
var $window = $(window);
|
|
1141
1152
|
var $document = $(document);
|
|
1153
|
+
var $input = self.$input;
|
|
1142
1154
|
|
|
1143
1155
|
var $wrapper;
|
|
1144
1156
|
var $control;
|
|
@@ -1154,8 +1166,8 @@
|
|
|
1154
1166
|
var classes_plugins;
|
|
1155
1167
|
|
|
1156
1168
|
inputMode = self.settings.mode;
|
|
1157
|
-
tab_index =
|
|
1158
|
-
classes =
|
|
1169
|
+
tab_index = $input.attr('tabindex') || '';
|
|
1170
|
+
classes = $input.attr('class') || '';
|
|
1159
1171
|
|
|
1160
1172
|
$wrapper = $('<div>').addClass(settings.wrapperClass).addClass(classes).addClass(inputMode);
|
|
1161
1173
|
$control = $('<div>').addClass(settings.inputClass).addClass('items').appendTo($wrapper);
|
|
@@ -1165,7 +1177,7 @@
|
|
|
1165
1177
|
$dropdown_content = $('<div>').addClass(settings.dropdownContentClass).appendTo($dropdown);
|
|
1166
1178
|
|
|
1167
1179
|
$wrapper.css({
|
|
1168
|
-
width:
|
|
1180
|
+
width: $input[0].style.width
|
|
1169
1181
|
});
|
|
1170
1182
|
|
|
1171
1183
|
if (self.plugins.names.length) {
|
|
@@ -1175,19 +1187,19 @@
|
|
|
1175
1187
|
}
|
|
1176
1188
|
|
|
1177
1189
|
if ((settings.maxItems === null || settings.maxItems > 1) && self.tagType === TAG_SELECT) {
|
|
1178
|
-
|
|
1190
|
+
$input.attr('multiple', 'multiple');
|
|
1179
1191
|
}
|
|
1180
1192
|
|
|
1181
1193
|
if (self.settings.placeholder) {
|
|
1182
1194
|
$control_input.attr('placeholder', settings.placeholder);
|
|
1183
1195
|
}
|
|
1184
1196
|
|
|
1185
|
-
if (
|
|
1186
|
-
$control_input.attr('autocorrect',
|
|
1197
|
+
if ($input.attr('autocorrect')) {
|
|
1198
|
+
$control_input.attr('autocorrect', $input.attr('autocorrect'));
|
|
1187
1199
|
}
|
|
1188
1200
|
|
|
1189
|
-
if (
|
|
1190
|
-
$control_input.attr('autocapitalize',
|
|
1201
|
+
if ($input.attr('autocapitalize')) {
|
|
1202
|
+
$control_input.attr('autocapitalize', $input.attr('autocapitalize'));
|
|
1191
1203
|
}
|
|
1192
1204
|
|
|
1193
1205
|
self.$wrapper = $wrapper;
|
|
@@ -1213,7 +1225,7 @@
|
|
|
1213
1225
|
keypress : function() { return self.onKeyPress.apply(self, arguments); },
|
|
1214
1226
|
resize : function() { self.positionDropdown.apply(self, []); },
|
|
1215
1227
|
blur : function() { return self.onBlur.apply(self, arguments); },
|
|
1216
|
-
focus : function() { return self.onFocus.apply(self, arguments); },
|
|
1228
|
+
focus : function() { self.ignoreBlur = false; return self.onFocus.apply(self, arguments); },
|
|
1217
1229
|
paste : function() { return self.onPaste.apply(self, arguments); }
|
|
1218
1230
|
});
|
|
1219
1231
|
|
|
@@ -1254,11 +1266,11 @@
|
|
|
1254
1266
|
// store original children and tab index so that they can be
|
|
1255
1267
|
// restored when the destroy() method is called.
|
|
1256
1268
|
this.revertSettings = {
|
|
1257
|
-
$children :
|
|
1258
|
-
tabindex :
|
|
1269
|
+
$children : $input.children().detach(),
|
|
1270
|
+
tabindex : $input.attr('tabindex')
|
|
1259
1271
|
};
|
|
1260
1272
|
|
|
1261
|
-
|
|
1273
|
+
$input.attr('tabindex', -1).hide().after(self.$wrapper);
|
|
1262
1274
|
|
|
1263
1275
|
if ($.isArray(settings.items)) {
|
|
1264
1276
|
self.setValue(settings.items);
|
|
@@ -1266,8 +1278,8 @@
|
|
|
1266
1278
|
}
|
|
1267
1279
|
|
|
1268
1280
|
// feature detect for the validation API
|
|
1269
|
-
if (
|
|
1270
|
-
|
|
1281
|
+
if ($input[0].validity) {
|
|
1282
|
+
$input.on('invalid' + eventNS, function(e) {
|
|
1271
1283
|
e.preventDefault();
|
|
1272
1284
|
self.isInvalid = true;
|
|
1273
1285
|
self.refreshState();
|
|
@@ -1280,17 +1292,21 @@
|
|
|
1280
1292
|
self.updatePlaceholder();
|
|
1281
1293
|
self.isSetup = true;
|
|
1282
1294
|
|
|
1283
|
-
if (
|
|
1295
|
+
if ($input.is(':disabled')) {
|
|
1284
1296
|
self.disable();
|
|
1285
1297
|
}
|
|
1286
1298
|
|
|
1287
1299
|
self.on('change', this.onChange);
|
|
1300
|
+
|
|
1301
|
+
$input.data('selectize', self);
|
|
1302
|
+
$input.addClass('selectized');
|
|
1288
1303
|
self.trigger('initialize');
|
|
1289
1304
|
|
|
1290
1305
|
// preload options
|
|
1291
1306
|
if (settings.preload === true) {
|
|
1292
1307
|
self.onSearchChange('');
|
|
1293
1308
|
}
|
|
1309
|
+
|
|
1294
1310
|
},
|
|
1295
1311
|
|
|
1296
1312
|
/**
|
|
@@ -1505,6 +1521,7 @@
|
|
|
1505
1521
|
case KEY_TAB:
|
|
1506
1522
|
if (self.settings.selectOnTab && self.isOpen && self.$activeOption) {
|
|
1507
1523
|
self.onOptionSelect({currentTarget: self.$activeOption});
|
|
1524
|
+
e.preventDefault();
|
|
1508
1525
|
}
|
|
1509
1526
|
if (self.settings.create && self.createItem()) {
|
|
1510
1527
|
e.preventDefault();
|
|
@@ -1599,6 +1616,14 @@
|
|
|
1599
1616
|
self.isFocused = false;
|
|
1600
1617
|
if (self.ignoreFocus) return;
|
|
1601
1618
|
|
|
1619
|
+
// necessary to prevent IE closing the dropdown when the scrollbar is clicked
|
|
1620
|
+
if (!self.ignoreBlur && document.activeElement === self.$dropdown_content[0]) {
|
|
1621
|
+
self.ignoreBlur = true;
|
|
1622
|
+
self.onFocus(e);
|
|
1623
|
+
|
|
1624
|
+
return;
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1602
1627
|
if (self.settings.create && self.settings.createOnBlur) {
|
|
1603
1628
|
self.createItem(false);
|
|
1604
1629
|
}
|
|
@@ -1643,7 +1668,7 @@
|
|
|
1643
1668
|
self.createItem();
|
|
1644
1669
|
} else {
|
|
1645
1670
|
value = $target.attr('data-value');
|
|
1646
|
-
if (value) {
|
|
1671
|
+
if (typeof value !== 'undefined') {
|
|
1647
1672
|
self.lastQuery = null;
|
|
1648
1673
|
self.setTextboxValue('');
|
|
1649
1674
|
self.addItem(value);
|
|
@@ -2077,7 +2102,7 @@
|
|
|
2077
2102
|
}
|
|
2078
2103
|
|
|
2079
2104
|
// add create option
|
|
2080
|
-
has_create_option = self.settings.create && results.query
|
|
2105
|
+
has_create_option = self.settings.create && self.canCreate(results.query);
|
|
2081
2106
|
if (has_create_option) {
|
|
2082
2107
|
$dropdown_content.prepend(self.render('option_create', {input: query}));
|
|
2083
2108
|
$create = $($dropdown_content[0].childNodes[0]);
|
|
@@ -2134,7 +2159,7 @@
|
|
|
2134
2159
|
}
|
|
2135
2160
|
|
|
2136
2161
|
value = hash_key(data[self.settings.valueField]);
|
|
2137
|
-
if (
|
|
2162
|
+
if (typeof value !== 'string' || self.options.hasOwnProperty(value)) return;
|
|
2138
2163
|
|
|
2139
2164
|
self.userOptions[value] = true;
|
|
2140
2165
|
self.options[value] = data;
|
|
@@ -2171,8 +2196,9 @@
|
|
|
2171
2196
|
value_new = hash_key(data[self.settings.valueField]);
|
|
2172
2197
|
|
|
2173
2198
|
// sanity checks
|
|
2199
|
+
if (value === null) return;
|
|
2174
2200
|
if (!self.options.hasOwnProperty(value)) return;
|
|
2175
|
-
if (
|
|
2201
|
+
if (typeof value_new !== 'string') throw new Error('Value must be set in option data');
|
|
2176
2202
|
|
|
2177
2203
|
// update references
|
|
2178
2204
|
if (value_new !== value) {
|
|
@@ -2284,7 +2310,7 @@
|
|
|
2284
2310
|
getElementWithValue: function(value, $els) {
|
|
2285
2311
|
value = hash_key(value);
|
|
2286
2312
|
|
|
2287
|
-
if (value) {
|
|
2313
|
+
if (typeof value !== 'undefined' && value !== null) {
|
|
2288
2314
|
for (var i = 0, n = $els.length; i < n; i++) {
|
|
2289
2315
|
if ($els[i].getAttribute('data-value') === value) {
|
|
2290
2316
|
return $($els[i]);
|
|
@@ -2331,7 +2357,7 @@
|
|
|
2331
2357
|
var $item, $option, $options;
|
|
2332
2358
|
var self = this;
|
|
2333
2359
|
var inputMode = self.settings.mode;
|
|
2334
|
-
var i, active, value_next;
|
|
2360
|
+
var i, active, value_next, wasFull;
|
|
2335
2361
|
value = hash_key(value);
|
|
2336
2362
|
|
|
2337
2363
|
if (self.items.indexOf(value) !== -1) {
|
|
@@ -2344,15 +2370,18 @@
|
|
|
2344
2370
|
if (inputMode === 'multi' && self.isFull()) return;
|
|
2345
2371
|
|
|
2346
2372
|
$item = $(self.render('item', self.options[value]));
|
|
2373
|
+
wasFull = self.isFull();
|
|
2347
2374
|
self.items.splice(self.caretPos, 0, value);
|
|
2348
2375
|
self.insertAtCaret($item);
|
|
2349
|
-
self.
|
|
2376
|
+
if (!self.isPending || (!wasFull && self.isFull())) {
|
|
2377
|
+
self.refreshState();
|
|
2378
|
+
}
|
|
2350
2379
|
|
|
2351
2380
|
if (self.isSetup) {
|
|
2352
2381
|
$options = self.$dropdown_content.find('[data-selectable]');
|
|
2353
2382
|
|
|
2354
2383
|
// update menu / remove the option (if this is not one item being added as part of series)
|
|
2355
|
-
if (!
|
|
2384
|
+
if (!self.isPending) {
|
|
2356
2385
|
$option = self.getOption(value);
|
|
2357
2386
|
value_next = self.getAdjacentOption($option, 1).attr('data-value');
|
|
2358
2387
|
self.refreshOptions(self.isFocused && inputMode !== 'single');
|
|
@@ -2362,7 +2391,7 @@
|
|
|
2362
2391
|
}
|
|
2363
2392
|
|
|
2364
2393
|
// hide the menu if the maximum number of items have been selected or no options are left
|
|
2365
|
-
if (!$options.length ||
|
|
2394
|
+
if (!$options.length || self.isFull()) {
|
|
2366
2395
|
self.close();
|
|
2367
2396
|
} else {
|
|
2368
2397
|
self.positionDropdown();
|
|
@@ -2428,7 +2457,7 @@
|
|
|
2428
2457
|
var self = this;
|
|
2429
2458
|
var input = $.trim(self.$control_input.val() || '');
|
|
2430
2459
|
var caret = self.caretPos;
|
|
2431
|
-
if (!input
|
|
2460
|
+
if (!self.canCreate(input)) return false;
|
|
2432
2461
|
self.lock();
|
|
2433
2462
|
|
|
2434
2463
|
if (typeof triggerDropdown === 'undefined') {
|
|
@@ -2447,7 +2476,7 @@
|
|
|
2447
2476
|
|
|
2448
2477
|
if (!data || typeof data !== 'object') return;
|
|
2449
2478
|
var value = hash_key(data[self.settings.valueField]);
|
|
2450
|
-
if (
|
|
2479
|
+
if (typeof value !== 'string') return;
|
|
2451
2480
|
|
|
2452
2481
|
self.setTextboxValue('');
|
|
2453
2482
|
self.addOption(data);
|
|
@@ -2485,10 +2514,11 @@
|
|
|
2485
2514
|
* and CSS classes.
|
|
2486
2515
|
*/
|
|
2487
2516
|
refreshState: function() {
|
|
2488
|
-
var self = this;
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2517
|
+
var invalid, self = this;
|
|
2518
|
+
if (self.isRequired) {
|
|
2519
|
+
if (self.items.length) self.isInvalid = false;
|
|
2520
|
+
self.$control_input.prop('required', invalid);
|
|
2521
|
+
}
|
|
2492
2522
|
self.refreshClasses();
|
|
2493
2523
|
},
|
|
2494
2524
|
|
|
@@ -2535,7 +2565,7 @@
|
|
|
2535
2565
|
updateOriginalInput: function() {
|
|
2536
2566
|
var i, n, options, self = this;
|
|
2537
2567
|
|
|
2538
|
-
if (self
|
|
2568
|
+
if (self.tagType === TAG_SELECT) {
|
|
2539
2569
|
options = [];
|
|
2540
2570
|
for (i = 0, n = self.items.length; i < n; i++) {
|
|
2541
2571
|
options.push('<option value="' + escape_html(self.items[i]) + '" selected="selected"></option>');
|
|
@@ -2546,6 +2576,7 @@
|
|
|
2546
2576
|
self.$input.html(options.join(''));
|
|
2547
2577
|
} else {
|
|
2548
2578
|
self.$input.val(self.getValue());
|
|
2579
|
+
self.$input.attr('value',self.$input.val());
|
|
2549
2580
|
}
|
|
2550
2581
|
|
|
2551
2582
|
if (self.isSetup) {
|
|
@@ -2631,7 +2662,9 @@
|
|
|
2631
2662
|
if (!self.items.length) return;
|
|
2632
2663
|
self.$control.children(':not(input)').remove();
|
|
2633
2664
|
self.items = [];
|
|
2665
|
+
self.lastQuery = null;
|
|
2634
2666
|
self.setCaret(0);
|
|
2667
|
+
self.setActiveItem(null);
|
|
2635
2668
|
self.updatePlaceholder();
|
|
2636
2669
|
self.updateOriginalInput();
|
|
2637
2670
|
self.refreshState();
|
|
@@ -2800,17 +2833,19 @@
|
|
|
2800
2833
|
i = Math.max(0, Math.min(self.items.length, i));
|
|
2801
2834
|
}
|
|
2802
2835
|
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2836
|
+
if(!self.isPending) {
|
|
2837
|
+
// the input must be moved by leaving it in place and moving the
|
|
2838
|
+
// siblings, due to the fact that focus cannot be restored once lost
|
|
2839
|
+
// on mobile webkit devices
|
|
2840
|
+
var j, n, fn, $children, $child;
|
|
2841
|
+
$children = self.$control.children(':not(input)');
|
|
2842
|
+
for (j = 0, n = $children.length; j < n; j++) {
|
|
2843
|
+
$child = $($children[j]).detach();
|
|
2844
|
+
if (j < i) {
|
|
2845
|
+
self.$control_input.before($child);
|
|
2846
|
+
} else {
|
|
2847
|
+
self.$control.append($child);
|
|
2848
|
+
}
|
|
2814
2849
|
}
|
|
2815
2850
|
}
|
|
2816
2851
|
|
|
@@ -2876,9 +2911,13 @@
|
|
|
2876
2911
|
.html('')
|
|
2877
2912
|
.append(revertSettings.$children)
|
|
2878
2913
|
.removeAttr('tabindex')
|
|
2914
|
+
.removeClass('selectized')
|
|
2879
2915
|
.attr({tabindex: revertSettings.tabindex})
|
|
2880
2916
|
.show();
|
|
2881
2917
|
|
|
2918
|
+
self.$control_input.removeData('grow');
|
|
2919
|
+
self.$input.removeData('selectize');
|
|
2920
|
+
|
|
2882
2921
|
$(window).off(eventNS);
|
|
2883
2922
|
$(document).off(eventNS);
|
|
2884
2923
|
$(document.body).off(eventNS);
|
|
@@ -2937,8 +2976,25 @@
|
|
|
2937
2976
|
}
|
|
2938
2977
|
|
|
2939
2978
|
return html;
|
|
2979
|
+
},
|
|
2980
|
+
|
|
2981
|
+
/**
|
|
2982
|
+
* Clears the render cache for a template. If
|
|
2983
|
+
* no template is given, clears all render
|
|
2984
|
+
* caches.
|
|
2985
|
+
*
|
|
2986
|
+
* @param {string} templateName
|
|
2987
|
+
*/
|
|
2988
|
+
clearCache: function(templateName) {
|
|
2989
|
+
var self = this;
|
|
2990
|
+
if (typeof templateName === 'undefined') {
|
|
2991
|
+
self.renderCache = {};
|
|
2992
|
+
} else {
|
|
2993
|
+
delete self.renderCache[templateName];
|
|
2994
|
+
}
|
|
2940
2995
|
}
|
|
2941
2996
|
|
|
2997
|
+
|
|
2942
2998
|
});
|
|
2943
2999
|
|
|
2944
3000
|
|
|
@@ -2950,6 +3006,7 @@
|
|
|
2950
3006
|
diacritics: true,
|
|
2951
3007
|
create: false,
|
|
2952
3008
|
createOnBlur: false,
|
|
3009
|
+
createFilter: null,
|
|
2953
3010
|
highlight: true,
|
|
2954
3011
|
openOnFocus: true,
|
|
2955
3012
|
maxOptions: 1000,
|
|
@@ -2958,6 +3015,7 @@
|
|
|
2958
3015
|
addPrecedence: false,
|
|
2959
3016
|
selectOnTab: false,
|
|
2960
3017
|
preload: false,
|
|
3018
|
+
allowEmptyOption: false,
|
|
2961
3019
|
|
|
2962
3020
|
scrollDuration: 60,
|
|
2963
3021
|
loadThrottle: 300,
|
|
@@ -3028,7 +3086,7 @@
|
|
|
3028
3086
|
*/
|
|
3029
3087
|
var init_textbox = function($input, settings_element) {
|
|
3030
3088
|
var i, n, values, option, value = $.trim($input.val() || '');
|
|
3031
|
-
if (!value.length) return;
|
|
3089
|
+
if (!settings.allowEmptyOption && !value.length) return;
|
|
3032
3090
|
|
|
3033
3091
|
values = value.split(settings.delimiter);
|
|
3034
3092
|
for (i = 0, n = values.length; i < n; i++) {
|
|
@@ -3066,7 +3124,7 @@
|
|
|
3066
3124
|
$option = $($option);
|
|
3067
3125
|
|
|
3068
3126
|
value = $option.attr('value') || '';
|
|
3069
|
-
if (!value.length) return;
|
|
3127
|
+
if (!value.length && !settings.allowEmptyOption) return;
|
|
3070
3128
|
|
|
3071
3129
|
// if the option already exists, it's probably been
|
|
3072
3130
|
// duplicated in another optgroup. in this case, push
|
|
@@ -3136,8 +3194,13 @@
|
|
|
3136
3194
|
var instance;
|
|
3137
3195
|
var $input = $(this);
|
|
3138
3196
|
var tag_name = this.tagName.toLowerCase();
|
|
3197
|
+
var placeholder = $input.attr('placeholder') || $input.attr('data-placeholder');
|
|
3198
|
+
if (!placeholder && !settings.allowEmptyOption) {
|
|
3199
|
+
placeholder = $input.children('option[value=""]').text();
|
|
3200
|
+
}
|
|
3201
|
+
|
|
3139
3202
|
var settings_element = {
|
|
3140
|
-
'placeholder' :
|
|
3203
|
+
'placeholder' : placeholder,
|
|
3141
3204
|
'options' : {},
|
|
3142
3205
|
'optgroups' : {},
|
|
3143
3206
|
'items' : []
|
|
@@ -3150,13 +3213,12 @@
|
|
|
3150
3213
|
}
|
|
3151
3214
|
|
|
3152
3215
|
instance = new Selectize($input, $.extend(true, {}, defaults, settings_element, settings_user));
|
|
3153
|
-
$input.data('selectize', instance);
|
|
3154
|
-
$input.addClass('selectized');
|
|
3155
3216
|
});
|
|
3156
3217
|
};
|
|
3157
3218
|
|
|
3158
3219
|
$.fn.selectize.defaults = Selectize.defaults;
|
|
3159
3220
|
|
|
3221
|
+
|
|
3160
3222
|
Selectize.define('drag_drop', function(options) {
|
|
3161
3223
|
if (!$.fn.sortable) throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".');
|
|
3162
3224
|
if (this.settings.mode !== 'multi') return;
|
|
@@ -3285,6 +3347,22 @@
|
|
|
3285
3347
|
};
|
|
3286
3348
|
})();
|
|
3287
3349
|
|
|
3350
|
+
var getScrollbarWidth = function() {
|
|
3351
|
+
var div;
|
|
3352
|
+
var width = getScrollbarWidth.width;
|
|
3353
|
+
var doc = document;
|
|
3354
|
+
|
|
3355
|
+
if (typeof width === 'undefined') {
|
|
3356
|
+
div = doc.createElement('div');
|
|
3357
|
+
div.innerHTML = '<div style="width:50px;height:50px;position:absolute;left:-50px;top:-50px;overflow:auto;"><div style="width:1px;height:100px;"></div></div>';
|
|
3358
|
+
div = div.firstChild;
|
|
3359
|
+
doc.body.appendChild(div);
|
|
3360
|
+
width = getScrollbarWidth.width = div.offsetWidth - div.clientWidth;
|
|
3361
|
+
doc.body.removeChild(div);
|
|
3362
|
+
}
|
|
3363
|
+
return width;
|
|
3364
|
+
};
|
|
3365
|
+
|
|
3288
3366
|
var equalizeSizes = function() {
|
|
3289
3367
|
var i, n, height_max, width, width_last, width_parent, $optgroups;
|
|
3290
3368
|
|
|
@@ -3301,7 +3379,7 @@
|
|
|
3301
3379
|
}
|
|
3302
3380
|
|
|
3303
3381
|
if (options.equalizeWidth) {
|
|
3304
|
-
width_parent = self.$dropdown_content.innerWidth();
|
|
3382
|
+
width_parent = self.$dropdown_content.innerWidth() - getScrollbarWidth();
|
|
3305
3383
|
width = Math.round(width_parent / n);
|
|
3306
3384
|
$optgroups.css({width: width});
|
|
3307
3385
|
if (n > 1) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* selectize.bootstrap3.css (v0.
|
|
2
|
+
* selectize.bootstrap3.css (v0.11.0) - Bootstrap 3 Theme
|
|
3
3
|
* Copyright (c) 2013 Brian Reavis & contributors
|
|
4
4
|
*
|
|
5
5
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
|
@@ -257,7 +257,7 @@
|
|
|
257
257
|
border-top: 0 none;
|
|
258
258
|
}
|
|
259
259
|
.selectize-dropdown .optgroup-header {
|
|
260
|
-
color: #
|
|
260
|
+
color: #777777;
|
|
261
261
|
background: #ffffff;
|
|
262
262
|
cursor: default;
|
|
263
263
|
}
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: selectize-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.11.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Manuel van Rijn
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-
|
|
11
|
+
date: 2014-08-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -46,8 +46,6 @@ extensions: []
|
|
|
46
46
|
extra_rdoc_files: []
|
|
47
47
|
files:
|
|
48
48
|
- ".gitignore"
|
|
49
|
-
- ".ruby-gemset"
|
|
50
|
-
- ".ruby-version"
|
|
51
49
|
- CHANGELOG.md
|
|
52
50
|
- Gemfile
|
|
53
51
|
- LICENSE.txt
|
data/.ruby-gemset
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
selectize-rails
|
data/.ruby-version
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
2.1.1
|