1
0
mirror of synced 2025-02-09 16:49:24 +03:00

Added amdBase and amdLanguageBase options

This should allow those using their own build systems to
automatically load in translations. In the future, the `amdBase`
option may be used to optionally load some components of Select2.

As Select2 cannot know what the base directory is, it currently
has to load in all of the optional components in the default build.
By allowing users to set their own base, it will allow us to know
the base to load files from, which makes it easier to use the
`require` function to optionally load them.

This fixes https://github.com/select2/select2/issues/2899.
This commit is contained in:
Kevin Brown 2015-01-11 21:59:27 -05:00
parent 584d3b48a2
commit 86b4a5d8e2
8 changed files with 23 additions and 13 deletions

View File

@ -3570,7 +3570,7 @@ define('select2/defaults',[
language = Translation.loadPath(name);
} catch (e) {
// If we couldn't load it, check if it wasn't the full path
name = 'select2/i18n/' + name;
name = this.get('amdTranslationBase') + name;
language = Translation.loadPath(name);
}
@ -3641,6 +3641,8 @@ define('select2/defaults',[
}
this.defaults = {
amdBase: 'select2/',
amdLanguageBase: 'select2/i18n/',
language: EnglishTranslation,
matcher: matcher,
minimumInputLength: 0,
@ -4538,7 +4540,7 @@ define('select2/dropdown/attachContainer',[
define('jquery.select2',[
'jquery',
'select2/core'
'./select2/core'
], function ($, Select2) {
// Force jQuery.mousewheel to be loaded if it hasn't already
try {

View File

@ -3570,7 +3570,7 @@ define('select2/defaults',[
language = Translation.loadPath(name);
} catch (e) {
// If we couldn't load it, check if it wasn't the full path
name = 'select2/i18n/' + name;
name = this.get('amdTranslationBase') + name;
language = Translation.loadPath(name);
}
@ -3641,6 +3641,8 @@ define('select2/defaults',[
}
this.defaults = {
amdBase: 'select2/',
amdLanguageBase: 'select2/i18n/',
language: EnglishTranslation,
matcher: matcher,
minimumInputLength: 0,
@ -4254,7 +4256,7 @@ define('select2/core',[
define('jquery.select2',[
'jquery',
'select2/core'
'./select2/core'
], function ($, Select2) {
// Force jQuery.mousewheel to be loaded if it hasn't already
try {

View File

@ -13105,7 +13105,7 @@ define('select2/defaults',[
language = Translation.loadPath(name);
} catch (e) {
// If we couldn't load it, check if it wasn't the full path
name = 'select2/i18n/' + name;
name = this.get('amdTranslationBase') + name;
language = Translation.loadPath(name);
}
@ -13176,6 +13176,8 @@ define('select2/defaults',[
}
this.defaults = {
amdBase: 'select2/',
amdLanguageBase: 'select2/i18n/',
language: EnglishTranslation,
matcher: matcher,
minimumInputLength: 0,
@ -14073,7 +14075,7 @@ define('select2/dropdown/attachContainer',[
define('jquery.select2',[
'jquery',
'select2/core'
'./select2/core'
], function ($, Select2) {
// Force jQuery.mousewheel to be loaded if it hasn't already
try {

File diff suppressed because one or more lines are too long

6
dist/js/select2.js vendored
View File

@ -3998,7 +3998,7 @@ define('select2/defaults',[
language = Translation.loadPath(name);
} catch (e) {
// If we couldn't load it, check if it wasn't the full path
name = 'select2/i18n/' + name;
name = this.get('amdTranslationBase') + name;
language = Translation.loadPath(name);
}
@ -4069,6 +4069,8 @@ define('select2/defaults',[
}
this.defaults = {
amdBase: 'select2/',
amdLanguageBase: 'select2/i18n/',
language: EnglishTranslation,
matcher: matcher,
minimumInputLength: 0,
@ -4682,7 +4684,7 @@ define('select2/core',[
define('jquery.select2',[
'jquery',
'select2/core'
'./select2/core'
], function ($, Select2) {
// Force jQuery.mousewheel to be loaded if it hasn't already
try {

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
define([
'jquery',
'select2/core'
'./select2/core'
], function ($, Select2) {
// Force jQuery.mousewheel to be loaded if it hasn't already
try {

View File

@ -187,7 +187,7 @@ define([
language = Translation.loadPath(name);
} catch (e) {
// If we couldn't load it, check if it wasn't the full path
name = 'select2/i18n/' + name;
name = this.get('amdTranslationBase') + name;
language = Translation.loadPath(name);
}
@ -258,6 +258,8 @@ define([
}
this.defaults = {
amdBase: 'select2/',
amdLanguageBase: 'select2/i18n/',
language: EnglishTranslation,
matcher: matcher,
minimumInputLength: 0,