1
0
mirror of synced 2024-11-22 04:56:08 +03:00

Fix undefined variables

There were a few undefined variables being referenced within the
Select2 code.  The JSHint configuration has been modified to fail
if there are undefined variables being referenced, including any
global variables.

There is an exception that is being made for the jQuery shim, as it
must try to find the global jQuery references.

An exception is made for the test helpers, as the SauceLabs reporting
variables are not camelCase, and would normally trigger warnings.

This closes https://github.com/select2/select2/pull/3028.
This commit is contained in:
Kevin Brown 2015-02-13 22:49:54 -05:00
parent e383cb573c
commit 081580bcd8
27 changed files with 117 additions and 171 deletions

View File

@ -1 +1,2 @@
tests/vendor/*.js
tests/helpers.js

View File

@ -6,11 +6,20 @@
"eqnull": true,
"freeze": true,
"globals": {
"define": true
"console": false,
"define": false,
"document": false,
"expect": false,
"MockContainer": false,
"module": false,
"require": false,
"test": false,
"window": false
},
"indent": 2,
"maxlen": 80,
"noarg": true,
"nonew": true,
"quotmark": "single"
"quotmark": "single",
"undef": true
}

View File

@ -303,9 +303,12 @@ module.exports = function (grunt) {
grunt.registerTask('compile', ['requirejs', 'sass:dev']);
grunt.registerTask('minify', ['uglify', 'sass:dist']);
grunt.registerTask('test', ['qunit', 'jshint']);
grunt.registerTask('test', ['connect:tests', 'qunit', 'jshint']);
grunt.registerTask('ci', ['compile', 'connect:tests', 'saucelabs-qunit', 'test']);
grunt.registerTask('ci', [
'compile', 'connect:tests',
'saucelabs-qunit', 'qunit', 'jshint'
]);
grunt.registerTask('docs', ['symlink:docs', 'jekyll:serve']);

2
dist/js/i18n/ca.js vendored
View File

@ -1 +1 @@
(function(){if(window.define)var e=window.define;if(window.require)var t=window.require;if(window.jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd.define,t=jQuery.fn.select2.amd.require;e("select2/i18n/ca",[],function(){return{errorLoading:function(){return"La càrrega ha fallat"},inputTooLong:function(e){var t=e.input.length-e.maximum,n="Si us plau, elimina "+t+" car";return t==1?n+="àcter":n+="àcters",n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="Si us plau, introdueix "+remainingChars+" car";return remainingChars==1?n+="àcter":n+="àcters",n},loadingMore:function(){return"Carregant més resultats…"},maximumSelection:function(e){var t="Només es pot seleccionar "+e.maximum+" element";return e.maximum!=1&&(t+="s"),t},noResults:function(){return"No s'han trobat resultats"},searching:function(){return"Cercant…"}}}),t("jquery.select2"),jQuery.fn.select2.amd={define:e,require:t}})();
(function(){if(window.define)var e=window.define;if(window.require)var t=window.require;if(window.jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd.define,t=jQuery.fn.select2.amd.require;e("select2/i18n/ca",[],function(){return{errorLoading:function(){return"La càrrega ha fallat"},inputTooLong:function(e){var t=e.input.length-e.maximum,n="Si us plau, elimina "+t+" car";return t==1?n+="àcter":n+="àcters",n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="Si us plau, introdueix "+t+" car";return t==1?n+="àcter":n+="àcters",n},loadingMore:function(){return"Carregant més resultats…"},maximumSelection:function(e){var t="Només es pot seleccionar "+e.maximum+" element";return e.maximum!=1&&(t+="s"),t},noResults:function(){return"No s'han trobat resultats"},searching:function(){return"Cercant…"}}}),t("jquery.select2"),jQuery.fn.select2.amd={define:e,require:t}})();

2
dist/js/i18n/es.js vendored
View File

@ -1 +1 @@
(function(){if(window.define)var e=window.define;if(window.require)var t=window.require;if(window.jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd.define,t=jQuery.fn.select2.amd.require;e("select2/i18n/es",[],function(){return{errorLoading:function(){return"La carga falló"},inputTooLong:function(e){var t=e.input.length-e.maximum,n="Por favor, elimine "+t+" car";return t==1?n+="ácter":n+="acteres",n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="Por favor, introduzca "+remainingChars+" car";return remainingChars==1?n+="ácter":n+="acteres",n},loadingMore:function(){return"Cargando más resultados…"},maximumSelection:function(e){var t="Sólo puede seleccionar "+e.maximum+" elemento";return e.maximum!=1&&(t+="s"),t},noResults:function(){return"No se encontraron resultados"},searching:function(){return"Buscando…"}}}),t("jquery.select2"),jQuery.fn.select2.amd={define:e,require:t}})();
(function(){if(window.define)var e=window.define;if(window.require)var t=window.require;if(window.jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd.define,t=jQuery.fn.select2.amd.require;e("select2/i18n/es",[],function(){return{errorLoading:function(){return"La carga falló"},inputTooLong:function(e){var t=e.input.length-e.maximum,n="Por favor, elimine "+t+" car";return t==1?n+="ácter":n+="acteres",n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="Por favor, introduzca "+t+" car";return t==1?n+="ácter":n+="acteres",n},loadingMore:function(){return"Cargando más resultados…"},maximumSelection:function(e){var t="Sólo puede seleccionar "+e.maximum+" elemento";return e.maximum!=1&&(t+="s"),t},noResults:function(){return"No se encontraron resultados"},searching:function(){return"Buscando…"}}}),t("jquery.select2"),jQuery.fn.select2.amd={define:e,require:t}})();

2
dist/js/i18n/eu.js vendored
View File

@ -1 +1 @@
(function(){if(window.define)var e=window.define;if(window.require)var t=window.require;if(window.jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd.define,t=jQuery.fn.select2.amd.require;e("select2/i18n/eu",[],function(){return{inputTooLong:function(e){var t=e.input.length-e.maximum,n="Idatzi ";return t==1?n+="karaktere bat":n+=t+" karaktere",n+=" gutxiago",n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="Idatzi ";return overChars==1?n+="karaktere bat":n+=overChars+" karaktere",n+=" gehiago",n},loadingMore:function(){return"Emaitza gehiago kargatzen…"},maximumSelection:function(e){return e.maximum===1?"Elementu bakarra hauta dezakezu":e.maximum+" elementu hauta ditzakezu soilik"},noResults:function(){return"Ez da bat datorrenik aurkitu"},searching:function(){return"Bilatzen…"}}}),t("jquery.select2"),jQuery.fn.select2.amd={define:e,require:t}})();
(function(){if(window.define)var e=window.define;if(window.require)var t=window.require;if(window.jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd.define,t=jQuery.fn.select2.amd.require;e("select2/i18n/eu",[],function(){return{inputTooLong:function(e){var t=e.input.length-e.maximum,n="Idatzi ";return t==1?n+="karaktere bat":n+=t+" karaktere",n+=" gutxiago",n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="Idatzi ";return t==1?n+="karaktere bat":n+=t+" karaktere",n+=" gehiago",n},loadingMore:function(){return"Emaitza gehiago kargatzen…"},maximumSelection:function(e){return e.maximum===1?"Elementu bakarra hauta dezakezu":e.maximum+" elementu hauta ditzakezu soilik"},noResults:function(){return"Ez da bat datorrenik aurkitu"},searching:function(){return"Bilatzen…"}}}),t("jquery.select2"),jQuery.fn.select2.amd={define:e,require:t}})();

2
dist/js/i18n/is.js vendored
View File

@ -1 +1 @@
(function(){if(window.define)var e=window.define;if(window.require)var t=window.require;if(window.jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd.define,t=jQuery.fn.select2.amd.require;e("select2/i18n/is",[],function(){return{inputTooLong:function(e){var t=e.input.length-e.maximum,n="Vinsamlegast styttið texta um "+t+" staf";return t<=1?n:n+"i"},inputTooShort:function(e){var t=e.minimum-e.input.length,n="Vinsamlegast skrifið "+t+" staf";return overChars>1&&(n+="i"),n+=" í viðbót",n},loadingMore:function(){return"Sæki fleiri niðurstöður…"},maximumSelection:function(e){return"Þú getur aðeins valið "+e.maximum+" atriði"},noResults:function(){return"Ekkert fannst"},searching:function(){return"Leita…"}}}),t("jquery.select2"),jQuery.fn.select2.amd={define:e,require:t}})();
(function(){if(window.define)var e=window.define;if(window.require)var t=window.require;if(window.jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd.define,t=jQuery.fn.select2.amd.require;e("select2/i18n/is",[],function(){return{inputTooLong:function(e){var t=e.input.length-e.maximum,n="Vinsamlegast styttið texta um "+t+" staf";return t<=1?n:n+"i"},inputTooShort:function(e){var t=e.minimum-e.input.length,n="Vinsamlegast skrifið "+t+" staf";return t>1&&(n+="i"),n+=" í viðbót",n},loadingMore:function(){return"Sæki fleiri niðurstöður…"},maximumSelection:function(e){return"Þú getur aðeins valið "+e.maximum+" atriði"},noResults:function(){return"Ekkert fannst"},searching:function(){return"Leita…"}}}),t("jquery.select2"),jQuery.fn.select2.amd={define:e,require:t}})();

2
dist/js/i18n/lt.js vendored
View File

@ -1 +1 @@
(function(){if(window.define)var e=window.define;if(window.require)var t=window.require;if(window.jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd.define,t=jQuery.fn.select2.amd.require;e("select2/i18n/lt",[],function(){function e(e,t,n,r){return e%100>9&&e%100<21||e%10===0?e%10>1?n:r:t}return{inputTooLong:function(t){var n=t.input.length-t.maximum,r="Pašalinkite "+remainingChars+" simbol";return r+=e(remainingChars,"ių","ius","į"),r},inputTooShort:function(t){var n=t.minimum-t.input.length,r="Įrašykite dar "+n+" simbol";return r+=e(n,"ių","ius","į"),r},loadingMore:function(){return"Kraunama daugiau rezultatų…"},maximumSelection:function(t){var n="Jūs galite pasirinkti tik "+t.maximum+" element";return n+=e(t.maximum,"ų","us","ą"),n},noResults:function(){return"Atitikmenų nerasta"},searching:function(){return"Ieškoma…"}}}),t("jquery.select2"),jQuery.fn.select2.amd={define:e,require:t}})();
(function(){if(window.define)var e=window.define;if(window.require)var t=window.require;if(window.jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd.define,t=jQuery.fn.select2.amd.require;e("select2/i18n/lt",[],function(){function e(e,t,n,r){return e%100>9&&e%100<21||e%10===0?e%10>1?n:r:t}return{inputTooLong:function(t){var n=t.input.length-t.maximum,r="Pašalinkite "+n+" simbol";return r+=e(n,"ių","ius","į"),r},inputTooShort:function(t){var n=t.minimum-t.input.length,r="Įrašykite dar "+n+" simbol";return r+=e(n,"ių","ius","į"),r},loadingMore:function(){return"Kraunama daugiau rezultatų…"},maximumSelection:function(t){var n="Jūs galite pasirinkti tik "+t.maximum+" element";return n+=e(t.maximum,"ų","us","ą"),n},noResults:function(){return"Atitikmenų nerasta"},searching:function(){return"Ieškoma…"}}}),t("jquery.select2"),jQuery.fn.select2.amd={define:e,require:t}})();

2
dist/js/i18n/lv.js vendored
View File

@ -1 +1 @@
(function(){if(window.define)var e=window.define;if(window.require)var t=window.require;if(window.jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd.define,t=jQuery.fn.select2.amd.require;e("select2/i18n/lv",[],function(){function e(e,t,n,r){return e===11?t:e%10===1?n:r}return{inputTooLong:function(t){var n=t.input.length-t.maximum,r="Lūdzu ievadiet par "+n;return r+=" simbol"+e(n,"iem","u","iem"),r+" mazāk"},inputTooShort:function(t){var n=t.minimum-t.input.length,r="Lūdzu ievadiet vēl "+n;return r+=" simbol"+e(overChars,"us","u","us"),r},loadingMore:function(){return"Datu ielāde…"},maximumSelection:function(t){var n="Jūs varat izvēlēties ne vairāk kā "+t.maximum;return n+=" element"+e(t.maximum,"us","u","us"),n},noResults:function(){return"Sakritību nav"},searching:function(){return"Meklēšana…"}}}),t("jquery.select2"),jQuery.fn.select2.amd={define:e,require:t}})();
(function(){if(window.define)var e=window.define;if(window.require)var t=window.require;if(window.jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd.define,t=jQuery.fn.select2.amd.require;e("select2/i18n/lv",[],function(){function e(e,t,n,r){return e===11?t:e%10===1?n:r}return{inputTooLong:function(t){var n=t.input.length-t.maximum,r="Lūdzu ievadiet par "+n;return r+=" simbol"+e(n,"iem","u","iem"),r+" mazāk"},inputTooShort:function(t){var n=t.minimum-t.input.length,r="Lūdzu ievadiet vēl "+n;return r+=" simbol"+e(n,"us","u","us"),r},loadingMore:function(){return"Datu ielāde…"},maximumSelection:function(t){var n="Jūs varat izvēlēties ne vairāk kā "+t.maximum;return n+=" element"+e(t.maximum,"us","u","us"),n},noResults:function(){return"Sakritību nav"},searching:function(){return"Meklēšana…"}}}),t("jquery.select2"),jQuery.fn.select2.amd={define:e,require:t}})();

View File

@ -765,21 +765,7 @@ define('select2/keys',[
UP: 38,
RIGHT: 39,
DOWN: 40,
DELETE: 46,
isArrow: function (k) {
k = k.which ? k.which : k;
switch (k) {
case KEY.LEFT:
case KEY.RIGHT:
case KEY.UP:
case KEY.DOWN:
return true;
}
return false;
}
DELETE: 46
};
return KEYS;
@ -1164,7 +1150,7 @@ define('select2/selection/allowClear',[
decorated.call(this, container, $container);
if (self.placeholder == null) {
if (console && console.error) {
if (window.console && console.error) {
console.error(
'Select2: The `allowClear` option should be used in combination ' +
'with the `placeholder` option.'
@ -2385,7 +2371,7 @@ define('select2/data/select',[
data.push.apply(data, currentData);
for (var d = 0; d < data.length; d++) {
id = data[d].id;
var id = data[d].id;
if (val.indexOf(id) === -1) {
val.push(id);
@ -2423,7 +2409,7 @@ define('select2/data/select',[
var val = [];
for (var d = 0; d < currentData.length; d++) {
id = currentData[d].id;
var id = currentData[d].id;
if (id !== data.id && val.indexOf(id) === -1) {
val.push(id);
@ -2759,7 +2745,7 @@ define('select2/data/ajax',[
var $request = options.transport(options, function (data) {
var results = self.processResults(data, params);
if (console && console.error) {
if (window.console && console.error) {
// Check to make sure that the response included a `results` key.
if (!results || !results.results || !$.isArray(results.results)) {
console.error(
@ -3428,7 +3414,7 @@ define('select2/dropdown/attachBody',[
var resizeEvent = 'resize.select2.' + container.id;
var orientationEvent = 'orientationchange.select2.' + container.id;
$watchers = this.$container.parents().filter(Utils.hasScroll);
var $watchers = this.$container.parents().filter(Utils.hasScroll);
$watchers.each(function () {
$(this).data('select2-scroll-position', {
x: $(this).scrollLeft(),
@ -3453,7 +3439,7 @@ define('select2/dropdown/attachBody',[
var resizeEvent = 'resize.select2.' + container.id;
var orientationEvent = 'orientationchange.select2.' + container.id;
$watchers = this.$container.parents().filter(Utils.hasScroll);
var $watchers = this.$container.parents().filter(Utils.hasScroll);
$watchers.off(scrollEvent);
$(window).off(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent);
@ -3545,7 +3531,7 @@ define('select2/dropdown/minimumResultsForSearch',[
], function () {
function countResults (data) {
count = 0;
var count = 0;
for (var d = 0; d < data.length; d++) {
var item = data[d];
@ -3918,7 +3904,7 @@ define('select2/defaults',[
// The translation could not be loaded at all. Sometimes this is
// because of a configuration problem, other times this can be
// because of how Select2 helps load all possible translation files.
if (console && console.warn) {
if (window.console && console.warn) {
console.warn(
'Select2: The lanugage file for "' + name + '" could not be ' +
'automatically loaded. A fallback will be used instead.'
@ -4085,7 +4071,7 @@ define('select2/options',[
$e.prop('multiple', this.options.multiple);
if ($e.data('select2-tags')) {
if (console && console.warn) {
if (window.console && console.warn) {
console.warn(
'Select2: The `data-select2-tags` attribute has been changed to ' +
'use the `data-data` and `data-tags="true"` attributes and will be ' +
@ -4098,7 +4084,7 @@ define('select2/options',[
}
if ($e.data('ajax-url')) {
if (console && console.warn) {
if (window.console && console.warn) {
console.warn(
'Select2: The `data-ajax-url` attribute has been changed to ' +
'`data-ajax--url` and support for the old attribute will be removed' +
@ -4284,8 +4270,8 @@ define('select2/core',[
var attrs = style.split(';');
for (i = 0, l = attrs.length; i < l; i = i + 1) {
attr = attrs[i].replace(/\s/g, '');
for (var i = 0, l = attrs.length; i < l; i = i + 1) {
var attr = attrs[i].replace(/\s/g, '');
var matches = attr.match(WIDTH);
if (matches !== null && matches.length >= 1) {
@ -4532,7 +4518,7 @@ define('select2/core',[
};
Select2.prototype.enable = function (args) {
if (console && console.warn) {
if (window.console && console.warn) {
console.warn(
'Select2: The `select2("enable")` method has been deprecated and will' +
' be removed in later Select2 versions. Use $element.prop("disabled")' +
@ -4550,7 +4536,7 @@ define('select2/core',[
};
Select2.prototype.data = function () {
if (arguments.length > 0 && console && console.warn) {
if (arguments.length > 0 && window.console && console.warn) {
console.warn(
'Select2: Data can no longer be set using `select2("data")`. You ' +
'should consider setting the value instead using `$element.val()`.'
@ -4567,7 +4553,7 @@ define('select2/core',[
};
Select2.prototype.val = function (args) {
if (console && console.warn) {
if (window.console && console.warn) {
console.warn(
'Select2: The `select2("val")` method has been deprecated and will be' +
' removed in later Select2 versions. Use $element.val() instead.'
@ -4911,7 +4897,7 @@ define('select2/compat/initSelection',[
'jquery'
], function ($) {
function InitSelection (decorated, $element, options) {
if (console && console.warn) {
if (window.console && console.warn) {
console.warn(
'Select2: The `initSelection` option has been deprecated in favor' +
' of a custom data adapter that overrides the `current` method. ' +
@ -4954,7 +4940,7 @@ define('select2/compat/query',[
], function () {
function Query (decorated, $element, options) {
if (console && console.warn) {
if (window.console && console.warn) {
console.warn(
'Select2: The `query` option has been deprecated in favor of a ' +
'custom data adapter that overrides the `query` method. Support ' +

View File

@ -765,21 +765,7 @@ define('select2/keys',[
UP: 38,
RIGHT: 39,
DOWN: 40,
DELETE: 46,
isArrow: function (k) {
k = k.which ? k.which : k;
switch (k) {
case KEY.LEFT:
case KEY.RIGHT:
case KEY.UP:
case KEY.DOWN:
return true;
}
return false;
}
DELETE: 46
};
return KEYS;
@ -1164,7 +1150,7 @@ define('select2/selection/allowClear',[
decorated.call(this, container, $container);
if (self.placeholder == null) {
if (console && console.error) {
if (window.console && console.error) {
console.error(
'Select2: The `allowClear` option should be used in combination ' +
'with the `placeholder` option.'
@ -2385,7 +2371,7 @@ define('select2/data/select',[
data.push.apply(data, currentData);
for (var d = 0; d < data.length; d++) {
id = data[d].id;
var id = data[d].id;
if (val.indexOf(id) === -1) {
val.push(id);
@ -2423,7 +2409,7 @@ define('select2/data/select',[
var val = [];
for (var d = 0; d < currentData.length; d++) {
id = currentData[d].id;
var id = currentData[d].id;
if (id !== data.id && val.indexOf(id) === -1) {
val.push(id);
@ -2759,7 +2745,7 @@ define('select2/data/ajax',[
var $request = options.transport(options, function (data) {
var results = self.processResults(data, params);
if (console && console.error) {
if (window.console && console.error) {
// Check to make sure that the response included a `results` key.
if (!results || !results.results || !$.isArray(results.results)) {
console.error(
@ -3428,7 +3414,7 @@ define('select2/dropdown/attachBody',[
var resizeEvent = 'resize.select2.' + container.id;
var orientationEvent = 'orientationchange.select2.' + container.id;
$watchers = this.$container.parents().filter(Utils.hasScroll);
var $watchers = this.$container.parents().filter(Utils.hasScroll);
$watchers.each(function () {
$(this).data('select2-scroll-position', {
x: $(this).scrollLeft(),
@ -3453,7 +3439,7 @@ define('select2/dropdown/attachBody',[
var resizeEvent = 'resize.select2.' + container.id;
var orientationEvent = 'orientationchange.select2.' + container.id;
$watchers = this.$container.parents().filter(Utils.hasScroll);
var $watchers = this.$container.parents().filter(Utils.hasScroll);
$watchers.off(scrollEvent);
$(window).off(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent);
@ -3545,7 +3531,7 @@ define('select2/dropdown/minimumResultsForSearch',[
], function () {
function countResults (data) {
count = 0;
var count = 0;
for (var d = 0; d < data.length; d++) {
var item = data[d];
@ -3918,7 +3904,7 @@ define('select2/defaults',[
// The translation could not be loaded at all. Sometimes this is
// because of a configuration problem, other times this can be
// because of how Select2 helps load all possible translation files.
if (console && console.warn) {
if (window.console && console.warn) {
console.warn(
'Select2: The lanugage file for "' + name + '" could not be ' +
'automatically loaded. A fallback will be used instead.'
@ -4085,7 +4071,7 @@ define('select2/options',[
$e.prop('multiple', this.options.multiple);
if ($e.data('select2-tags')) {
if (console && console.warn) {
if (window.console && console.warn) {
console.warn(
'Select2: The `data-select2-tags` attribute has been changed to ' +
'use the `data-data` and `data-tags="true"` attributes and will be ' +
@ -4098,7 +4084,7 @@ define('select2/options',[
}
if ($e.data('ajax-url')) {
if (console && console.warn) {
if (window.console && console.warn) {
console.warn(
'Select2: The `data-ajax-url` attribute has been changed to ' +
'`data-ajax--url` and support for the old attribute will be removed' +
@ -4284,8 +4270,8 @@ define('select2/core',[
var attrs = style.split(';');
for (i = 0, l = attrs.length; i < l; i = i + 1) {
attr = attrs[i].replace(/\s/g, '');
for (var i = 0, l = attrs.length; i < l; i = i + 1) {
var attr = attrs[i].replace(/\s/g, '');
var matches = attr.match(WIDTH);
if (matches !== null && matches.length >= 1) {
@ -4532,7 +4518,7 @@ define('select2/core',[
};
Select2.prototype.enable = function (args) {
if (console && console.warn) {
if (window.console && console.warn) {
console.warn(
'Select2: The `select2("enable")` method has been deprecated and will' +
' be removed in later Select2 versions. Use $element.prop("disabled")' +
@ -4550,7 +4536,7 @@ define('select2/core',[
};
Select2.prototype.data = function () {
if (arguments.length > 0 && console && console.warn) {
if (arguments.length > 0 && window.console && console.warn) {
console.warn(
'Select2: Data can no longer be set using `select2("data")`. You ' +
'should consider setting the value instead using `$element.val()`.'
@ -4567,7 +4553,7 @@ define('select2/core',[
};
Select2.prototype.val = function (args) {
if (console && console.warn) {
if (window.console && console.warn) {
console.warn(
'Select2: The `select2("val")` method has been deprecated and will be' +
' removed in later Select2 versions. Use $element.val() instead.'

View File

@ -422,6 +422,7 @@ var requirejs, require, define;
define("almond", function(){});
/* global jQuery:false, $:false */
define('jquery',[],function () {
var _$ = jQuery || $;
@ -1203,21 +1204,7 @@ define('select2/keys',[
UP: 38,
RIGHT: 39,
DOWN: 40,
DELETE: 46,
isArrow: function (k) {
k = k.which ? k.which : k;
switch (k) {
case KEY.LEFT:
case KEY.RIGHT:
case KEY.UP:
case KEY.DOWN:
return true;
}
return false;
}
DELETE: 46
};
return KEYS;
@ -1602,7 +1589,7 @@ define('select2/selection/allowClear',[
decorated.call(this, container, $container);
if (self.placeholder == null) {
if (console && console.error) {
if (window.console && console.error) {
console.error(
'Select2: The `allowClear` option should be used in combination ' +
'with the `placeholder` option.'
@ -2823,7 +2810,7 @@ define('select2/data/select',[
data.push.apply(data, currentData);
for (var d = 0; d < data.length; d++) {
id = data[d].id;
var id = data[d].id;
if (val.indexOf(id) === -1) {
val.push(id);
@ -2861,7 +2848,7 @@ define('select2/data/select',[
var val = [];
for (var d = 0; d < currentData.length; d++) {
id = currentData[d].id;
var id = currentData[d].id;
if (id !== data.id && val.indexOf(id) === -1) {
val.push(id);
@ -3197,7 +3184,7 @@ define('select2/data/ajax',[
var $request = options.transport(options, function (data) {
var results = self.processResults(data, params);
if (console && console.error) {
if (window.console && console.error) {
// Check to make sure that the response included a `results` key.
if (!results || !results.results || !$.isArray(results.results)) {
console.error(
@ -3866,7 +3853,7 @@ define('select2/dropdown/attachBody',[
var resizeEvent = 'resize.select2.' + container.id;
var orientationEvent = 'orientationchange.select2.' + container.id;
$watchers = this.$container.parents().filter(Utils.hasScroll);
var $watchers = this.$container.parents().filter(Utils.hasScroll);
$watchers.each(function () {
$(this).data('select2-scroll-position', {
x: $(this).scrollLeft(),
@ -3891,7 +3878,7 @@ define('select2/dropdown/attachBody',[
var resizeEvent = 'resize.select2.' + container.id;
var orientationEvent = 'orientationchange.select2.' + container.id;
$watchers = this.$container.parents().filter(Utils.hasScroll);
var $watchers = this.$container.parents().filter(Utils.hasScroll);
$watchers.off(scrollEvent);
$(window).off(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent);
@ -3983,7 +3970,7 @@ define('select2/dropdown/minimumResultsForSearch',[
], function () {
function countResults (data) {
count = 0;
var count = 0;
for (var d = 0; d < data.length; d++) {
var item = data[d];
@ -4356,7 +4343,7 @@ define('select2/defaults',[
// The translation could not be loaded at all. Sometimes this is
// because of a configuration problem, other times this can be
// because of how Select2 helps load all possible translation files.
if (console && console.warn) {
if (window.console && console.warn) {
console.warn(
'Select2: The lanugage file for "' + name + '" could not be ' +
'automatically loaded. A fallback will be used instead.'
@ -4523,7 +4510,7 @@ define('select2/options',[
$e.prop('multiple', this.options.multiple);
if ($e.data('select2-tags')) {
if (console && console.warn) {
if (window.console && console.warn) {
console.warn(
'Select2: The `data-select2-tags` attribute has been changed to ' +
'use the `data-data` and `data-tags="true"` attributes and will be ' +
@ -4536,7 +4523,7 @@ define('select2/options',[
}
if ($e.data('ajax-url')) {
if (console && console.warn) {
if (window.console && console.warn) {
console.warn(
'Select2: The `data-ajax-url` attribute has been changed to ' +
'`data-ajax--url` and support for the old attribute will be removed' +
@ -4722,8 +4709,8 @@ define('select2/core',[
var attrs = style.split(';');
for (i = 0, l = attrs.length; i < l; i = i + 1) {
attr = attrs[i].replace(/\s/g, '');
for (var i = 0, l = attrs.length; i < l; i = i + 1) {
var attr = attrs[i].replace(/\s/g, '');
var matches = attr.match(WIDTH);
if (matches !== null && matches.length >= 1) {
@ -4970,7 +4957,7 @@ define('select2/core',[
};
Select2.prototype.enable = function (args) {
if (console && console.warn) {
if (window.console && console.warn) {
console.warn(
'Select2: The `select2("enable")` method has been deprecated and will' +
' be removed in later Select2 versions. Use $element.prop("disabled")' +
@ -4988,7 +4975,7 @@ define('select2/core',[
};
Select2.prototype.data = function () {
if (arguments.length > 0 && console && console.warn) {
if (arguments.length > 0 && window.console && console.warn) {
console.warn(
'Select2: Data can no longer be set using `select2("data")`. You ' +
'should consider setting the value instead using `$element.val()`.'
@ -5005,7 +4992,7 @@ define('select2/core',[
};
Select2.prototype.val = function (args) {
if (console && console.warn) {
if (window.console && console.warn) {
console.warn(
'Select2: The `select2("val")` method has been deprecated and will be' +
' removed in later Select2 versions. Use $element.val() instead.'
@ -5349,7 +5336,7 @@ define('select2/compat/initSelection',[
'jquery'
], function ($) {
function InitSelection (decorated, $element, options) {
if (console && console.warn) {
if (window.console && console.warn) {
console.warn(
'Select2: The `initSelection` option has been deprecated in favor' +
' of a custom data adapter that overrides the `current` method. ' +
@ -5392,7 +5379,7 @@ define('select2/compat/query',[
], function () {
function Query (decorated, $element, options) {
if (console && console.warn) {
if (window.console && console.warn) {
console.warn(
'Select2: The `query` option has been deprecated in favor of a ' +
'custom data adapter that overrides the `query` method. Support ' +

File diff suppressed because one or more lines are too long

47
dist/js/select2.js vendored
View File

@ -422,6 +422,7 @@ var requirejs, require, define;
define("almond", function(){});
/* global jQuery:false, $:false */
define('jquery',[],function () {
var _$ = jQuery || $;
@ -1203,21 +1204,7 @@ define('select2/keys',[
UP: 38,
RIGHT: 39,
DOWN: 40,
DELETE: 46,
isArrow: function (k) {
k = k.which ? k.which : k;
switch (k) {
case KEY.LEFT:
case KEY.RIGHT:
case KEY.UP:
case KEY.DOWN:
return true;
}
return false;
}
DELETE: 46
};
return KEYS;
@ -1602,7 +1589,7 @@ define('select2/selection/allowClear',[
decorated.call(this, container, $container);
if (self.placeholder == null) {
if (console && console.error) {
if (window.console && console.error) {
console.error(
'Select2: The `allowClear` option should be used in combination ' +
'with the `placeholder` option.'
@ -2823,7 +2810,7 @@ define('select2/data/select',[
data.push.apply(data, currentData);
for (var d = 0; d < data.length; d++) {
id = data[d].id;
var id = data[d].id;
if (val.indexOf(id) === -1) {
val.push(id);
@ -2861,7 +2848,7 @@ define('select2/data/select',[
var val = [];
for (var d = 0; d < currentData.length; d++) {
id = currentData[d].id;
var id = currentData[d].id;
if (id !== data.id && val.indexOf(id) === -1) {
val.push(id);
@ -3197,7 +3184,7 @@ define('select2/data/ajax',[
var $request = options.transport(options, function (data) {
var results = self.processResults(data, params);
if (console && console.error) {
if (window.console && console.error) {
// Check to make sure that the response included a `results` key.
if (!results || !results.results || !$.isArray(results.results)) {
console.error(
@ -3866,7 +3853,7 @@ define('select2/dropdown/attachBody',[
var resizeEvent = 'resize.select2.' + container.id;
var orientationEvent = 'orientationchange.select2.' + container.id;
$watchers = this.$container.parents().filter(Utils.hasScroll);
var $watchers = this.$container.parents().filter(Utils.hasScroll);
$watchers.each(function () {
$(this).data('select2-scroll-position', {
x: $(this).scrollLeft(),
@ -3891,7 +3878,7 @@ define('select2/dropdown/attachBody',[
var resizeEvent = 'resize.select2.' + container.id;
var orientationEvent = 'orientationchange.select2.' + container.id;
$watchers = this.$container.parents().filter(Utils.hasScroll);
var $watchers = this.$container.parents().filter(Utils.hasScroll);
$watchers.off(scrollEvent);
$(window).off(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent);
@ -3983,7 +3970,7 @@ define('select2/dropdown/minimumResultsForSearch',[
], function () {
function countResults (data) {
count = 0;
var count = 0;
for (var d = 0; d < data.length; d++) {
var item = data[d];
@ -4356,7 +4343,7 @@ define('select2/defaults',[
// The translation could not be loaded at all. Sometimes this is
// because of a configuration problem, other times this can be
// because of how Select2 helps load all possible translation files.
if (console && console.warn) {
if (window.console && console.warn) {
console.warn(
'Select2: The lanugage file for "' + name + '" could not be ' +
'automatically loaded. A fallback will be used instead.'
@ -4523,7 +4510,7 @@ define('select2/options',[
$e.prop('multiple', this.options.multiple);
if ($e.data('select2-tags')) {
if (console && console.warn) {
if (window.console && console.warn) {
console.warn(
'Select2: The `data-select2-tags` attribute has been changed to ' +
'use the `data-data` and `data-tags="true"` attributes and will be ' +
@ -4536,7 +4523,7 @@ define('select2/options',[
}
if ($e.data('ajax-url')) {
if (console && console.warn) {
if (window.console && console.warn) {
console.warn(
'Select2: The `data-ajax-url` attribute has been changed to ' +
'`data-ajax--url` and support for the old attribute will be removed' +
@ -4722,8 +4709,8 @@ define('select2/core',[
var attrs = style.split(';');
for (i = 0, l = attrs.length; i < l; i = i + 1) {
attr = attrs[i].replace(/\s/g, '');
for (var i = 0, l = attrs.length; i < l; i = i + 1) {
var attr = attrs[i].replace(/\s/g, '');
var matches = attr.match(WIDTH);
if (matches !== null && matches.length >= 1) {
@ -4970,7 +4957,7 @@ define('select2/core',[
};
Select2.prototype.enable = function (args) {
if (console && console.warn) {
if (window.console && console.warn) {
console.warn(
'Select2: The `select2("enable")` method has been deprecated and will' +
' be removed in later Select2 versions. Use $element.prop("disabled")' +
@ -4988,7 +4975,7 @@ define('select2/core',[
};
Select2.prototype.data = function () {
if (arguments.length > 0 && console && console.warn) {
if (arguments.length > 0 && window.console && console.warn) {
console.warn(
'Select2: Data can no longer be set using `select2("data")`. You ' +
'should consider setting the value instead using `$element.val()`.'
@ -5005,7 +4992,7 @@ define('select2/core',[
};
Select2.prototype.val = function (args) {
if (console && console.warn) {
if (window.console && console.warn) {
console.warn(
'Select2: The `select2("val")` method has been deprecated and will be' +
' removed in later Select2 versions. Use $element.val() instead.'

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,4 @@
/* global jQuery:false, $:false */
define(function () {
var _$ = jQuery || $;

View File

@ -143,8 +143,8 @@ define([
var attrs = style.split(';');
for (i = 0, l = attrs.length; i < l; i = i + 1) {
attr = attrs[i].replace(/\s/g, '');
for (var i = 0, l = attrs.length; i < l; i = i + 1) {
var attr = attrs[i].replace(/\s/g, '');
var matches = attr.match(WIDTH);
if (matches !== null && matches.length >= 1) {

View File

@ -47,7 +47,7 @@ define([
data.push.apply(data, currentData);
for (var d = 0; d < data.length; d++) {
id = data[d].id;
var id = data[d].id;
if (val.indexOf(id) === -1) {
val.push(id);
@ -85,7 +85,7 @@ define([
var val = [];
for (var d = 0; d < currentData.length; d++) {
id = currentData[d].id;
var id = currentData[d].id;
if (id !== data.id && val.indexOf(id) === -1) {
val.push(id);

View File

@ -81,7 +81,7 @@ define([
var resizeEvent = 'resize.select2.' + container.id;
var orientationEvent = 'orientationchange.select2.' + container.id;
$watchers = this.$container.parents().filter(Utils.hasScroll);
var $watchers = this.$container.parents().filter(Utils.hasScroll);
$watchers.each(function () {
$(this).data('select2-scroll-position', {
x: $(this).scrollLeft(),
@ -106,7 +106,7 @@ define([
var resizeEvent = 'resize.select2.' + container.id;
var orientationEvent = 'orientationchange.select2.' + container.id;
$watchers = this.$container.parents().filter(Utils.hasScroll);
var $watchers = this.$container.parents().filter(Utils.hasScroll);
$watchers.off(scrollEvent);
$(window).off(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent);

View File

@ -2,7 +2,7 @@ define([
], function () {
function countResults (data) {
count = 0;
var count = 0;
for (var d = 0; d < data.length; d++) {
var item = data[d];

View File

@ -5,11 +5,11 @@ define(function () {
return 'La càrrega ha fallat';
},
inputTooLong: function (args) {
var remainingChars = args.input.length - args.maximum;
var overChars = args.input.length - args.maximum;
var message = 'Si us plau, elimina ' + remainingChars + ' car';
var message = 'Si us plau, elimina ' + overChars + ' car';
if (remainingChars == 1) {
if (overChars == 1) {
message += 'àcter';
} else {
message += 'àcters';
@ -18,7 +18,7 @@ define(function () {
return message;
},
inputTooShort: function (args) {
var remaningChars = args.minimum - args.input.length;
var remainingChars = args.minimum - args.input.length;
var message = 'Si us plau, introdueix ' + remainingChars + ' car';

View File

@ -18,7 +18,7 @@ define(function () {
return message;
},
inputTooShort: function (args) {
var remaningChars = args.minimum - args.input.length;
var remainingChars = args.minimum - args.input.length;
var message = 'Por favor, introduzca ' + remainingChars + ' car';

View File

@ -21,10 +21,10 @@ define(function () {
var message = 'Idatzi ';
if (overChars == 1) {
if (remainingChars == 1) {
message += 'karaktere bat';
} else {
message += overChars + ' karaktere';
message += remainingChars + ' karaktere';
}
message += ' gehiago';

View File

@ -17,7 +17,7 @@ define(function () {
var message = 'Vinsamlegast skrifið ' + remainingChars + ' staf';
if (overChars > 1) {
if (remainingChars > 1) {
message += 'i';
}

View File

@ -16,9 +16,9 @@ define(function () {
inputTooLong: function (args) {
var overChars = args.input.length - args.maximum;
var message = 'Pašalinkite ' + remainingChars + ' simbol';
var message = 'Pašalinkite ' + overChars + ' simbol';
message += ending(remainingChars, 'ių', 'ius', 'į');
message += ending(overChars, 'ių', 'ius', 'į');
return message;
},

View File

@ -27,7 +27,7 @@ define(function () {
var message = 'Lūdzu ievadiet vēl ' + remainingChars;
message += ' simbol' + ending(overChars, 'us', 'u', 'us');
message += ' simbol' + ending(remainingChars, 'us', 'u', 'us');
return message;
},

View File

@ -18,21 +18,7 @@ define([
UP: 38,
RIGHT: 39,
DOWN: 40,
DELETE: 46,
isArrow: function (k) {
k = k.which ? k.which : k;
switch (k) {
case KEY.LEFT:
case KEY.RIGHT:
case KEY.UP:
case KEY.DOWN:
return true;
}
return false;
}
DELETE: 46
};
return KEYS;