Browse Source

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.
Kevin Brown 10 năm trước cách đây
mục cha
commit
86b4a5d8e2

+ 4 - 2
dist/js/select2.amd.full.js

@@ -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 {

+ 4 - 2
dist/js/select2.amd.js

@@ -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 {

+ 4 - 2
dist/js/select2.full.js

@@ -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 {

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
dist/js/select2.full.min.js


+ 4 - 2
dist/js/select2.js

@@ -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 {

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
dist/js/select2.min.js


+ 1 - 1
src/js/jquery.select2.js

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

+ 3 - 1
src/js/select2/defaults.js

@@ -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,

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác