Преглед на файлове

Added `lang` attribute support

Select2 will now detect the language based on the `lang` attribute
of the `<select>` element or any parent elements.
Kevin Brown преди 11 години
родител
ревизия
ec1bd3387b
променени са 7 файла, в които са добавени 40 реда и са изтрити 25 реда
  1. 8 5
      dist/js/select2.amd.full.js
  2. 8 5
      dist/js/select2.amd.js
  3. 8 5
      dist/js/select2.full.js
  4. 0 0
      dist/js/select2.full.min.js
  5. 8 5
      dist/js/select2.js
  6. 0 0
      dist/js/select2.min.js
  7. 8 5
      src/js/select2/options.js

+ 8 - 5
dist/js/select2.amd.full.js

@@ -3300,14 +3300,17 @@ define('select2/options',[
   }
 
   Options.prototype.fromElement = function ($e) {
-    var fromProperties = ['multiple'];
     var excludedData = ['select2'];
 
-    for (var p = 0; p < fromProperties.length; p++) {
-      var prop = fromProperties[p];
+    if (this.options.multiple == null) {
+      this.options.multiple = $e.prop('multiple');
+    }
 
-      if (this.options[prop] == null) {
-        this.options[prop] = $e.prop(prop);
+    if (this.options.language == null) {
+      if ($e.prop('lang')) {
+        this.options.language = $e.prop('lang').toLowerCase();
+      } else if ($e.closest('[lang]').prop('lang')) {
+        this.options.language = $e.closest('[lang]').prop('lang');
       }
     }
 

+ 8 - 5
dist/js/select2.amd.js

@@ -3300,14 +3300,17 @@ define('select2/options',[
   }
 
   Options.prototype.fromElement = function ($e) {
-    var fromProperties = ['multiple'];
     var excludedData = ['select2'];
 
-    for (var p = 0; p < fromProperties.length; p++) {
-      var prop = fromProperties[p];
+    if (this.options.multiple == null) {
+      this.options.multiple = $e.prop('multiple');
+    }
 
-      if (this.options[prop] == null) {
-        this.options[prop] = $e.prop(prop);
+    if (this.options.language == null) {
+      if ($e.prop('lang')) {
+        this.options.language = $e.prop('lang').toLowerCase();
+      } else if ($e.closest('[lang]').prop('lang')) {
+        this.options.language = $e.closest('[lang]').prop('lang');
       }
     }
 

+ 8 - 5
dist/js/select2.full.js

@@ -12835,14 +12835,17 @@ define('select2/options',[
   }
 
   Options.prototype.fromElement = function ($e) {
-    var fromProperties = ['multiple'];
     var excludedData = ['select2'];
 
-    for (var p = 0; p < fromProperties.length; p++) {
-      var prop = fromProperties[p];
+    if (this.options.multiple == null) {
+      this.options.multiple = $e.prop('multiple');
+    }
 
-      if (this.options[prop] == null) {
-        this.options[prop] = $e.prop(prop);
+    if (this.options.language == null) {
+      if ($e.prop('lang')) {
+        this.options.language = $e.prop('lang').toLowerCase();
+      } else if ($e.closest('[lang]').prop('lang')) {
+        this.options.language = $e.closest('[lang]').prop('lang');
       }
     }
 

Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
dist/js/select2.full.min.js


+ 8 - 5
dist/js/select2.js

@@ -3728,14 +3728,17 @@ define('select2/options',[
   }
 
   Options.prototype.fromElement = function ($e) {
-    var fromProperties = ['multiple'];
     var excludedData = ['select2'];
 
-    for (var p = 0; p < fromProperties.length; p++) {
-      var prop = fromProperties[p];
+    if (this.options.multiple == null) {
+      this.options.multiple = $e.prop('multiple');
+    }
 
-      if (this.options[prop] == null) {
-        this.options[prop] = $e.prop(prop);
+    if (this.options.language == null) {
+      if ($e.prop('lang')) {
+        this.options.language = $e.prop('lang').toLowerCase();
+      } else if ($e.closest('[lang]').prop('lang')) {
+        this.options.language = $e.closest('[lang]').prop('lang');
       }
     }
 

Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
dist/js/select2.min.js


+ 8 - 5
src/js/select2/options.js

@@ -13,14 +13,17 @@ define([
   }
 
   Options.prototype.fromElement = function ($e) {
-    var fromProperties = ['multiple'];
     var excludedData = ['select2'];
 
-    for (var p = 0; p < fromProperties.length; p++) {
-      var prop = fromProperties[p];
+    if (this.options.multiple == null) {
+      this.options.multiple = $e.prop('multiple');
+    }
 
-      if (this.options[prop] == null) {
-        this.options[prop] = $e.prop(prop);
+    if (this.options.language == null) {
+      if ($e.prop('lang')) {
+        this.options.language = $e.prop('lang').toLowerCase();
+      } else if ($e.closest('[lang]').prop('lang')) {
+        this.options.language = $e.closest('[lang]').prop('lang');
       }
     }
 

Някои файлове не бяха показани, защото твърде много файлове са промени