1
0
mirror of synced 2024-11-26 06:46:04 +03:00

Built out the translations

This migrates over the required English translations under their
new names.

The "Searching" message has also been adjusted to use "Searching..."
instead of "Loading more results...", which is what it used to
say sometimes.

This also changes the AJAX handler to call `abort` when needed.
This commit is contained in:
Kevin Brown 2014-11-19 17:48:46 -05:00
parent 7e6782d580
commit 5ec201ca30
11 changed files with 349 additions and 179 deletions

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

@ -1 +1 @@
window.$=window.$||{},function(){$&&$.fn&&$.fn.select2&&$.fn.select2.amd&&(define=$.fn.select2.amd.define,require=$.fn.select2.amd.require),define("select2/i18n/en",[],function(){return{inputTooShort:function(e){var t=e.minimum-e.input.length,n="Please enter "+t+" or more character";return t!=1&&(n+="s"),n},loadingMore:function(){return"Loading more results…"},noResults:function(){return"No results found"}}}),require("jquery.select2"),$.fn.select2.amd={define:define,require:require}}(); window.$=window.$||{},function(){$&&$.fn&&$.fn.select2&&$.fn.select2.amd&&(define=$.fn.select2.amd.define,require=$.fn.select2.amd.require),define("select2/i18n/en",[],function(){return{errorLoading:function(){return"The results could not be loaded."},inputTooLong:function(e){var t=e.input.length-e.maximum,n="Please delete "+t+" character";return t!=1&&(n+="s"),n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="Please enter "+t+" or more character";return t!=1&&(n+="s"),n},searching:function(){return"Searching…"},loadingMore:function(){return"Loading more results…"},maximumSelected:function(e){var t="You can only select"+e.maximum+" item";return e.maximum!=1&&(t+="s"),t},noResults:function(){return"No results found"}}}),require("jquery.select2"),$.fn.select2.amd={define:define,require:require}}();

View File

@ -267,7 +267,7 @@ define('select2/results',[
Results.prototype.showLoading = function (params) { Results.prototype.showLoading = function (params) {
this.hideLoading(); this.hideLoading();
var loadingMore = this.options.get('translations').get('loadingMore'); var loadingMore = this.options.get('translations').get('searching');
var loading = { var loading = {
disabled: true, disabled: true,
@ -578,9 +578,50 @@ define('select2/results',[
return Results; return Results;
}); });
define('select2/keys',[
], function () {
var KEYS = {
BACKSPACE: 8,
TAB: 9,
ENTER: 13,
SHIFT: 16,
CTRL: 17,
ALT: 18,
ESC: 27,
SPACE: 32,
PAGE_UP: 33,
PAGE_DOWN: 34,
END: 35,
HOME: 36,
LEFT: 37,
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;
}
};
return KEYS;
});
define('select2/selection/base',[ define('select2/selection/base',[
'../utils' '../utils',
], function (Utils) { '../keys'
], function (Utils, KEYS) {
function BaseSelection ($element, options) { function BaseSelection ($element, options) {
this.$element = $element; this.$element = $element;
this.options = options; this.options = options;
@ -666,46 +707,6 @@ define('select2/selection/base',[
return BaseSelection; return BaseSelection;
}); });
define('select2/keys',[
], function () {
var KEYS = {
BACKSPACE: 8,
TAB: 9,
ENTER: 13,
SHIFT: 16,
CTRL: 17,
ALT: 18,
ESC: 27,
SPACE: 32,
PAGE_UP: 33,
PAGE_DOWN: 34,
END: 35,
HOME: 36,
LEFT: 37,
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;
}
};
return KEYS;
});
define('select2/selection/single',[ define('select2/selection/single',[
'./base', './base',
'../utils', '../utils',
@ -1341,6 +1342,11 @@ define('select2/data/ajax',[
var matches = []; var matches = [];
var self = this; var self = this;
if (this._request) {
this._request.abort();
this._request = null;
}
var options = $.extend({ var options = $.extend({
type: 'GET' type: 'GET'
}, this.ajaxOptions); }, this.ajaxOptions);
@ -1361,6 +1367,8 @@ define('select2/data/ajax',[
callback(results); callback(results);
}); });
self._request = $request;
} }
if (this.ajaxOptions.delay && params.term !== '') { if (this.ajaxOptions.delay && params.term !== '') {
@ -1750,6 +1758,20 @@ define('select2/dropdown/infiniteScroll',[
define('select2/i18n/en',[],function () { define('select2/i18n/en',[],function () {
return { return {
errorLoading: function () {
return 'The results could not be loaded.';
},
inputTooLong: function (args) {
var overChars = args.input.length - args.maximum;
var message = 'Please delete ' + overChars + ' character';
if (overChars != 1) {
message += 's';
}
return message;
},
inputTooShort: function (args) { inputTooShort: function (args) {
var remainingChars = args.minimum - args.input.length; var remainingChars = args.minimum - args.input.length;
@ -1761,9 +1783,21 @@ define('select2/i18n/en',[],function () {
return message; return message;
}, },
searching: function () {
return 'Searching…';
},
loadingMore: function () { loadingMore: function () {
return 'Loading more results…'; return 'Loading more results…';
}, },
maximumSelected: function (args) {
var message = 'You can only select' + args.maximum + ' item';
if (args.maximum != 1) {
message += 's';
}
return message;
},
noResults: function () { noResults: function () {
return 'No results found'; return 'No results found';
} }

120
dist/js/select2.amd.js vendored
View File

@ -267,7 +267,7 @@ define('select2/results',[
Results.prototype.showLoading = function (params) { Results.prototype.showLoading = function (params) {
this.hideLoading(); this.hideLoading();
var loadingMore = this.options.get('translations').get('loadingMore'); var loadingMore = this.options.get('translations').get('searching');
var loading = { var loading = {
disabled: true, disabled: true,
@ -578,9 +578,50 @@ define('select2/results',[
return Results; return Results;
}); });
define('select2/keys',[
], function () {
var KEYS = {
BACKSPACE: 8,
TAB: 9,
ENTER: 13,
SHIFT: 16,
CTRL: 17,
ALT: 18,
ESC: 27,
SPACE: 32,
PAGE_UP: 33,
PAGE_DOWN: 34,
END: 35,
HOME: 36,
LEFT: 37,
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;
}
};
return KEYS;
});
define('select2/selection/base',[ define('select2/selection/base',[
'../utils' '../utils',
], function (Utils) { '../keys'
], function (Utils, KEYS) {
function BaseSelection ($element, options) { function BaseSelection ($element, options) {
this.$element = $element; this.$element = $element;
this.options = options; this.options = options;
@ -666,46 +707,6 @@ define('select2/selection/base',[
return BaseSelection; return BaseSelection;
}); });
define('select2/keys',[
], function () {
var KEYS = {
BACKSPACE: 8,
TAB: 9,
ENTER: 13,
SHIFT: 16,
CTRL: 17,
ALT: 18,
ESC: 27,
SPACE: 32,
PAGE_UP: 33,
PAGE_DOWN: 34,
END: 35,
HOME: 36,
LEFT: 37,
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;
}
};
return KEYS;
});
define('select2/selection/single',[ define('select2/selection/single',[
'./base', './base',
'../utils', '../utils',
@ -1341,6 +1342,11 @@ define('select2/data/ajax',[
var matches = []; var matches = [];
var self = this; var self = this;
if (this._request) {
this._request.abort();
this._request = null;
}
var options = $.extend({ var options = $.extend({
type: 'GET' type: 'GET'
}, this.ajaxOptions); }, this.ajaxOptions);
@ -1361,6 +1367,8 @@ define('select2/data/ajax',[
callback(results); callback(results);
}); });
self._request = $request;
} }
if (this.ajaxOptions.delay && params.term !== '') { if (this.ajaxOptions.delay && params.term !== '') {
@ -1750,6 +1758,20 @@ define('select2/dropdown/infiniteScroll',[
define('select2/i18n/en',[],function () { define('select2/i18n/en',[],function () {
return { return {
errorLoading: function () {
return 'The results could not be loaded.';
},
inputTooLong: function (args) {
var overChars = args.input.length - args.maximum;
var message = 'Please delete ' + overChars + ' character';
if (overChars != 1) {
message += 's';
}
return message;
},
inputTooShort: function (args) { inputTooShort: function (args) {
var remainingChars = args.minimum - args.input.length; var remainingChars = args.minimum - args.input.length;
@ -1761,9 +1783,21 @@ define('select2/i18n/en',[],function () {
return message; return message;
}, },
searching: function () {
return 'Searching…';
},
loadingMore: function () { loadingMore: function () {
return 'Loading more results…'; return 'Loading more results…';
}, },
maximumSelected: function (args) {
var message = 'You can only select' + args.maximum + ' item';
if (args.maximum != 1) {
message += 's';
}
return message;
},
noResults: function () { noResults: function () {
return 'No results found'; return 'No results found';
} }

View File

@ -9802,7 +9802,7 @@ define('select2/results',[
Results.prototype.showLoading = function (params) { Results.prototype.showLoading = function (params) {
this.hideLoading(); this.hideLoading();
var loadingMore = this.options.get('translations').get('loadingMore'); var loadingMore = this.options.get('translations').get('searching');
var loading = { var loading = {
disabled: true, disabled: true,
@ -10113,9 +10113,50 @@ define('select2/results',[
return Results; return Results;
}); });
define('select2/keys',[
], function () {
var KEYS = {
BACKSPACE: 8,
TAB: 9,
ENTER: 13,
SHIFT: 16,
CTRL: 17,
ALT: 18,
ESC: 27,
SPACE: 32,
PAGE_UP: 33,
PAGE_DOWN: 34,
END: 35,
HOME: 36,
LEFT: 37,
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;
}
};
return KEYS;
});
define('select2/selection/base',[ define('select2/selection/base',[
'../utils' '../utils',
], function (Utils) { '../keys'
], function (Utils, KEYS) {
function BaseSelection ($element, options) { function BaseSelection ($element, options) {
this.$element = $element; this.$element = $element;
this.options = options; this.options = options;
@ -10201,46 +10242,6 @@ define('select2/selection/base',[
return BaseSelection; return BaseSelection;
}); });
define('select2/keys',[
], function () {
var KEYS = {
BACKSPACE: 8,
TAB: 9,
ENTER: 13,
SHIFT: 16,
CTRL: 17,
ALT: 18,
ESC: 27,
SPACE: 32,
PAGE_UP: 33,
PAGE_DOWN: 34,
END: 35,
HOME: 36,
LEFT: 37,
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;
}
};
return KEYS;
});
define('select2/selection/single',[ define('select2/selection/single',[
'./base', './base',
'../utils', '../utils',
@ -10876,6 +10877,11 @@ define('select2/data/ajax',[
var matches = []; var matches = [];
var self = this; var self = this;
if (this._request) {
this._request.abort();
this._request = null;
}
var options = $.extend({ var options = $.extend({
type: 'GET' type: 'GET'
}, this.ajaxOptions); }, this.ajaxOptions);
@ -10896,6 +10902,8 @@ define('select2/data/ajax',[
callback(results); callback(results);
}); });
self._request = $request;
} }
if (this.ajaxOptions.delay && params.term !== '') { if (this.ajaxOptions.delay && params.term !== '') {
@ -11285,6 +11293,20 @@ define('select2/dropdown/infiniteScroll',[
define('select2/i18n/en',[],function () { define('select2/i18n/en',[],function () {
return { return {
errorLoading: function () {
return 'The results could not be loaded.';
},
inputTooLong: function (args) {
var overChars = args.input.length - args.maximum;
var message = 'Please delete ' + overChars + ' character';
if (overChars != 1) {
message += 's';
}
return message;
},
inputTooShort: function (args) { inputTooShort: function (args) {
var remainingChars = args.minimum - args.input.length; var remainingChars = args.minimum - args.input.length;
@ -11296,9 +11318,21 @@ define('select2/i18n/en',[],function () {
return message; return message;
}, },
searching: function () {
return 'Searching…';
},
loadingMore: function () { loadingMore: function () {
return 'Loading more results…'; return 'Loading more results…';
}, },
maximumSelected: function (args) {
var message = 'You can only select' + args.maximum + ' item';
if (args.maximum != 1) {
message += 's';
}
return message;
},
noResults: function () { noResults: function () {
return 'No results found'; return 'No results found';
} }

File diff suppressed because one or more lines are too long

120
dist/js/select2.js vendored
View File

@ -695,7 +695,7 @@ define('select2/results',[
Results.prototype.showLoading = function (params) { Results.prototype.showLoading = function (params) {
this.hideLoading(); this.hideLoading();
var loadingMore = this.options.get('translations').get('loadingMore'); var loadingMore = this.options.get('translations').get('searching');
var loading = { var loading = {
disabled: true, disabled: true,
@ -1006,9 +1006,50 @@ define('select2/results',[
return Results; return Results;
}); });
define('select2/keys',[
], function () {
var KEYS = {
BACKSPACE: 8,
TAB: 9,
ENTER: 13,
SHIFT: 16,
CTRL: 17,
ALT: 18,
ESC: 27,
SPACE: 32,
PAGE_UP: 33,
PAGE_DOWN: 34,
END: 35,
HOME: 36,
LEFT: 37,
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;
}
};
return KEYS;
});
define('select2/selection/base',[ define('select2/selection/base',[
'../utils' '../utils',
], function (Utils) { '../keys'
], function (Utils, KEYS) {
function BaseSelection ($element, options) { function BaseSelection ($element, options) {
this.$element = $element; this.$element = $element;
this.options = options; this.options = options;
@ -1094,46 +1135,6 @@ define('select2/selection/base',[
return BaseSelection; return BaseSelection;
}); });
define('select2/keys',[
], function () {
var KEYS = {
BACKSPACE: 8,
TAB: 9,
ENTER: 13,
SHIFT: 16,
CTRL: 17,
ALT: 18,
ESC: 27,
SPACE: 32,
PAGE_UP: 33,
PAGE_DOWN: 34,
END: 35,
HOME: 36,
LEFT: 37,
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;
}
};
return KEYS;
});
define('select2/selection/single',[ define('select2/selection/single',[
'./base', './base',
'../utils', '../utils',
@ -1769,6 +1770,11 @@ define('select2/data/ajax',[
var matches = []; var matches = [];
var self = this; var self = this;
if (this._request) {
this._request.abort();
this._request = null;
}
var options = $.extend({ var options = $.extend({
type: 'GET' type: 'GET'
}, this.ajaxOptions); }, this.ajaxOptions);
@ -1789,6 +1795,8 @@ define('select2/data/ajax',[
callback(results); callback(results);
}); });
self._request = $request;
} }
if (this.ajaxOptions.delay && params.term !== '') { if (this.ajaxOptions.delay && params.term !== '') {
@ -2178,6 +2186,20 @@ define('select2/dropdown/infiniteScroll',[
define('select2/i18n/en',[],function () { define('select2/i18n/en',[],function () {
return { return {
errorLoading: function () {
return 'The results could not be loaded.';
},
inputTooLong: function (args) {
var overChars = args.input.length - args.maximum;
var message = 'Please delete ' + overChars + ' character';
if (overChars != 1) {
message += 's';
}
return message;
},
inputTooShort: function (args) { inputTooShort: function (args) {
var remainingChars = args.minimum - args.input.length; var remainingChars = args.minimum - args.input.length;
@ -2189,9 +2211,21 @@ define('select2/i18n/en',[],function () {
return message; return message;
}, },
searching: function () {
return 'Searching…';
},
loadingMore: function () { loadingMore: function () {
return 'Loading more results…'; return 'Loading more results…';
}, },
maximumSelected: function (args) {
var message = 'You can only select' + args.maximum + ' item';
if (args.maximum != 1) {
message += 's';
}
return message;
},
noResults: function () { noResults: function () {
return 'No results found'; return 'No results found';
} }

File diff suppressed because one or more lines are too long

View File

@ -23,6 +23,11 @@ define([
var matches = []; var matches = [];
var self = this; var self = this;
if (this._request) {
this._request.abort();
this._request = null;
}
var options = $.extend({ var options = $.extend({
type: 'GET' type: 'GET'
}, this.ajaxOptions); }, this.ajaxOptions);
@ -43,6 +48,8 @@ define([
callback(results); callback(results);
}); });
self._request = $request;
} }
if (this.ajaxOptions.delay && params.term !== '') { if (this.ajaxOptions.delay && params.term !== '') {

View File

@ -1,5 +1,19 @@
define(function () { define(function () {
return { return {
errorLoading: function () {
return 'The results could not be loaded.';
},
inputTooLong: function (args) {
var overChars = args.input.length - args.maximum;
var message = 'Please delete ' + overChars + ' character';
if (overChars != 1) {
message += 's';
}
return message;
},
inputTooShort: function (args) { inputTooShort: function (args) {
var remainingChars = args.minimum - args.input.length; var remainingChars = args.minimum - args.input.length;
@ -11,9 +25,21 @@ define(function () {
return message; return message;
}, },
searching: function () {
return 'Searching…';
},
loadingMore: function () { loadingMore: function () {
return 'Loading more results…'; return 'Loading more results…';
}, },
maximumSelected: function (args) {
var message = 'You can only select' + args.maximum + ' item';
if (args.maximum != 1) {
message += 's';
}
return message;
},
noResults: function () { noResults: function () {
return 'No results found'; return 'No results found';
} }

View File

@ -113,7 +113,7 @@ define([
Results.prototype.showLoading = function (params) { Results.prototype.showLoading = function (params) {
this.hideLoading(); this.hideLoading();
var loadingMore = this.options.get('translations').get('loadingMore'); var loadingMore = this.options.get('translations').get('searching');
var loading = { var loading = {
disabled: true, disabled: true,

View File

@ -1,6 +1,7 @@
define([ define([
'../utils' '../utils',
], function (Utils) { '../keys'
], function (Utils, KEYS) {
function BaseSelection ($element, options) { function BaseSelection ($element, options) {
this.$element = $element; this.$element = $element;
this.options = options; this.options = options;