Skip to content

Commit 32d0391

Browse files
committed
version 4.0.4
1 parent 0130210 commit 32d0391

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+240
-192
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ To apply the language, pass whatever language you'd like to use to the [`languag
5656

5757
Possible languages:
5858

59-
ar, az, bg, ca, cs, da, de, el, en, es, et, eu, fa, fi, fr, gl, he, hi, hr, hu, id, is, it, ja, km, ko, lt, lv, mk, ms, nb, nl, pl, pt, pt-BR, ro, ru, sk, sr, sr-Cyrl, sv, th, tr, uk, vi, zh-CN, zh-TW
59+
ar, az, bg, ca, cs, da, de, el, en, es, et, eu, fa, fi, fr, gl, he, hi, hr, hu, hy, id, is, it, ja, km, ko, lt, lv, mk, ms, nb, nl, pl, pt, pt-BR, ro, ru, sk, sl, sr, sr-Cyrl, sv, th, tr, uk, vi, zh-CN, zh-TW
6060

6161
## Example
6262
Code [here](https://github.com/argerim/select_2_example)

lib/select2-rails/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Select2
22
module Rails
3-
VERSION = '4.0.3'
3+
VERSION = '4.0.4'
44
end
55
end

vendor/assets/javascripts/select2-full.js

+88-67
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* Select2 4.0.3
2+
* Select2 4.0.4
33
* https://select2.github.io
44
*
55
* Released under the MIT license
@@ -9,19 +9,33 @@
99
if (typeof define === 'function' && define.amd) {
1010
// AMD. Register as an anonymous module.
1111
define(['jquery'], factory);
12-
} else if (typeof exports === 'object') {
12+
} else if (typeof module === 'object' && module.exports) {
1313
// Node/CommonJS
14-
factory(require('jquery'));
14+
module.exports = function (root, jQuery) {
15+
if (jQuery === undefined) {
16+
// require('jQuery') returns a factory that requires window to
17+
// build a jQuery instance, we normalize how we use modules
18+
// that require this pattern but the window provided is a noop
19+
// if it's defined (how jquery works)
20+
if (typeof window !== 'undefined') {
21+
jQuery = require('jquery');
22+
}
23+
else {
24+
jQuery = require('jquery')(root);
25+
}
26+
}
27+
factory(jQuery);
28+
return jQuery;
29+
};
1530
} else {
1631
// Browser globals
1732
factory(jQuery);
1833
}
19-
}(function (jQuery) {
34+
} (function (jQuery) {
2035
// This is needed so we can catch the AMD loader configuration and use it
2136
// The inner file should be wrapped (by `banner.start.js`) in a function that
2237
// returns the AMD loader references.
23-
var S2 =
24-
(function () {
38+
var S2 =(function () {
2539
// Restore the Select2 AMD loader so it can be used
2640
// Needed mostly in the language files, where the loader is not inserted
2741
if (jQuery && jQuery.fn && jQuery.fn.select2 && jQuery.fn.select2.amd) {
@@ -30,13 +44,11 @@
3044
var S2;(function () { if (!S2 || !S2.requirejs) {
3145
if (!S2) { S2 = {}; } else { require = S2; }
3246
/**
33-
* @license almond 0.3.1 Copyright (c) 2011-2014, The Dojo Foundation All Rights Reserved.
34-
* Available via the MIT or new BSD license.
35-
* see: http://github.com/jrburke/almond for details
47+
* @license almond 0.3.3 Copyright jQuery Foundation and other contributors.
48+
* Released under MIT license, http://github.com/requirejs/almond/LICENSE
3649
*/
3750
//Going sloppy to avoid 'use strict' string cost, but strict practices should
3851
//be followed.
39-
/*jslint sloppy: true */
4052
/*global setTimeout: false */
4153

4254
var requirejs, require, define;
@@ -64,60 +76,58 @@ var requirejs, require, define;
6476
*/
6577
function normalize(name, baseName) {
6678
var nameParts, nameSegment, mapValue, foundMap, lastIndex,
67-
foundI, foundStarMap, starI, i, j, part,
79+
foundI, foundStarMap, starI, i, j, part, normalizedBaseParts,
6880
baseParts = baseName && baseName.split("/"),
6981
map = config.map,
7082
starMap = (map && map['*']) || {};
7183

7284
//Adjust any relative paths.
73-
if (name && name.charAt(0) === ".") {
74-
//If have a base name, try to normalize against it,
75-
//otherwise, assume it is a top-level require that will
76-
//be relative to baseUrl in the end.
77-
if (baseName) {
78-
name = name.split('/');
79-
lastIndex = name.length - 1;
80-
81-
// Node .js allowance:
82-
if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
83-
name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');
84-
}
85+
if (name) {
86+
name = name.split('/');
87+
lastIndex = name.length - 1;
88+
89+
// If wanting node ID compatibility, strip .js from end
90+
// of IDs. Have to do this here, and not in nameToUrl
91+
// because node allows either .js or non .js to map
92+
// to same file.
93+
if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
94+
name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');
95+
}
8596

86-
//Lop off the last part of baseParts, so that . matches the
87-
//"directory" and not name of the baseName's module. For instance,
88-
//baseName of "one/two/three", maps to "one/two/three.js", but we
89-
//want the directory, "one/two" for this normalization.
90-
name = baseParts.slice(0, baseParts.length - 1).concat(name);
91-
92-
//start trimDots
93-
for (i = 0; i < name.length; i += 1) {
94-
part = name[i];
95-
if (part === ".") {
96-
name.splice(i, 1);
97-
i -= 1;
98-
} else if (part === "..") {
99-
if (i === 1 && (name[2] === '..' || name[0] === '..')) {
100-
//End of the line. Keep at least one non-dot
101-
//path segment at the front so it can be mapped
102-
//correctly to disk. Otherwise, there is likely
103-
//no path mapping for a path starting with '..'.
104-
//This can still fail, but catches the most reasonable
105-
//uses of ..
106-
break;
107-
} else if (i > 0) {
108-
name.splice(i - 1, 2);
109-
i -= 2;
110-
}
97+
// Starts with a '.' so need the baseName
98+
if (name[0].charAt(0) === '.' && baseParts) {
99+
//Convert baseName to array, and lop off the last part,
100+
//so that . matches that 'directory' and not name of the baseName's
101+
//module. For instance, baseName of 'one/two/three', maps to
102+
//'one/two/three.js', but we want the directory, 'one/two' for
103+
//this normalization.
104+
normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
105+
name = normalizedBaseParts.concat(name);
106+
}
107+
108+
//start trimDots
109+
for (i = 0; i < name.length; i++) {
110+
part = name[i];
111+
if (part === '.') {
112+
name.splice(i, 1);
113+
i -= 1;
114+
} else if (part === '..') {
115+
// If at the start, or previous value is still ..,
116+
// keep them so that when converted to a path it may
117+
// still work when converted to a path, even though
118+
// as an ID it is less than ideal. In larger point
119+
// releases, may be better to just kick out an error.
120+
if (i === 0 || (i === 1 && name[2] === '..') || name[i - 1] === '..') {
121+
continue;
122+
} else if (i > 0) {
123+
name.splice(i - 1, 2);
124+
i -= 2;
111125
}
112126
}
113-
//end trimDots
114-
115-
name = name.join("/");
116-
} else if (name.indexOf('./') === 0) {
117-
// No baseName, so this is ID is resolved relative
118-
// to baseUrl, pull off the leading dot.
119-
name = name.substring(2);
120127
}
128+
//end trimDots
129+
130+
name = name.join('/');
121131
}
122132

123133
//Apply map config if available.
@@ -230,32 +240,39 @@ var requirejs, require, define;
230240
return [prefix, name];
231241
}
232242

243+
//Creates a parts array for a relName where first part is plugin ID,
244+
//second part is resource ID. Assumes relName has already been normalized.
245+
function makeRelParts(relName) {
246+
return relName ? splitPrefix(relName) : [];
247+
}
248+
233249
/**
234250
* Makes a name map, normalizing the name, and using a plugin
235251
* for normalization if necessary. Grabs a ref to plugin
236252
* too, as an optimization.
237253
*/
238-
makeMap = function (name, relName) {
254+
makeMap = function (name, relParts) {
239255
var plugin,
240256
parts = splitPrefix(name),
241-
prefix = parts[0];
257+
prefix = parts[0],
258+
relResourceName = relParts[1];
242259

243260
name = parts[1];
244261

245262
if (prefix) {
246-
prefix = normalize(prefix, relName);
263+
prefix = normalize(prefix, relResourceName);
247264
plugin = callDep(prefix);
248265
}
249266

250267
//Normalize according
251268
if (prefix) {
252269
if (plugin && plugin.normalize) {
253-
name = plugin.normalize(name, makeNormalize(relName));
270+
name = plugin.normalize(name, makeNormalize(relResourceName));
254271
} else {
255-
name = normalize(name, relName);
272+
name = normalize(name, relResourceName);
256273
}
257274
} else {
258-
name = normalize(name, relName);
275+
name = normalize(name, relResourceName);
259276
parts = splitPrefix(name);
260277
prefix = parts[0];
261278
name = parts[1];
@@ -302,13 +319,14 @@ var requirejs, require, define;
302319
};
303320

304321
main = function (name, deps, callback, relName) {
305-
var cjsModule, depName, ret, map, i,
322+
var cjsModule, depName, ret, map, i, relParts,
306323
args = [],
307324
callbackType = typeof callback,
308325
usingExports;
309326

310327
//Use name if no relName
311328
relName = relName || name;
329+
relParts = makeRelParts(relName);
312330

313331
//Call the callback to define the module, if necessary.
314332
if (callbackType === 'undefined' || callbackType === 'function') {
@@ -317,7 +335,7 @@ var requirejs, require, define;
317335
//Default to [require, exports, module] if no deps
318336
deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps;
319337
for (i = 0; i < deps.length; i += 1) {
320-
map = makeMap(deps[i], relName);
338+
map = makeMap(deps[i], relParts);
321339
depName = map.f;
322340

323341
//Fast path CommonJS standard dependencies.
@@ -373,7 +391,7 @@ var requirejs, require, define;
373391
//deps arg is the module name, and second arg (if passed)
374392
//is just the relName.
375393
//Normalize module name, if it contains . or ..
376-
return callDep(makeMap(deps, callback).f);
394+
return callDep(makeMap(deps, makeRelParts(callback)).f);
377395
} else if (!deps.splice) {
378396
//deps is a config object, not an array.
379397
config = deps;
@@ -3191,7 +3209,7 @@ S2.define('select2/data/select',[
31913209
}
31923210
}
31933211

3194-
if (data.id) {
3212+
if (data.id !== undefined) {
31953213
option.value = data.id;
31963214
}
31973215

@@ -3550,7 +3568,10 @@ S2.define('select2/data/tags',[
35503568
}, true)
35513569
);
35523570

3553-
var checkText = option.text === params.term;
3571+
var optionText = (option.text || '').toUpperCase();
3572+
var paramsTerm = (params.term || '').toUpperCase();
3573+
3574+
var checkText = optionText === paramsTerm;
35543575

35553576
if (checkText || checkChildren) {
35563577
if (child) {
@@ -3941,7 +3962,7 @@ S2.define('select2/dropdown/search',[
39413962
});
39423963

39433964
container.on('focus', function () {
3944-
if (container.isOpen()) {
3965+
if (!container.isOpen()) {
39453966
self.$search.focus();
39463967
}
39473968
});

0 commit comments

Comments
 (0)