소스 검색

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 년 전
부모
커밋
86b4a5d8e2
8개의 변경된 파일20개의 추가작업 그리고 10개의 파일을 삭제
  1. 4 2
      dist/js/select2.amd.full.js
  2. 4 2
      dist/js/select2.amd.js
  3. 4 2
      dist/js/select2.full.js
  4. 0 0
      dist/js/select2.full.min.js
  5. 4 2
      dist/js/select2.js
  6. 0 0
      dist/js/select2.min.js
  7. 1 1
      src/js/jquery.select2.js
  8. 3 1
      src/js/select2/defaults.js

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

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 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 {

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 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,

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.