Browse Source

Added back `select2("enable")`

This also adds a console warning if the `enable` or `val` method is
called.
Kevin Brown 10 years ago
parent
commit
3ff78d8145

+ 25 - 0
dist/js/select2.amd.full.js

@@ -3750,7 +3750,32 @@ define('select2/core',[
     return this.$container.hasClass('select2-container--open');
   };
 
+  Select2.prototype.enable = function (args) {
+    if (console && console.warn) {
+      console.warn(
+        'Select2: The `select2("val")` method has been deprecated and will be' +
+        ' removed in later Select2 versions. Use $element.prop("disabled") ' +
+        'instead.'
+      );
+    }
+
+    if (args.length === 0) {
+      args = [true];
+    }
+
+    var disabled = !args[0];
+
+    this.$element.prop('disabled', disabled);
+  };
+
   Select2.prototype.val = function (args) {
+    if (console && console.warn) {
+      console.warn(
+        'Select2: The `select2("val")` method has been deprecated and will be' +
+        ' removed in later Select2 versions. Use $element.val() instead.'
+      );
+    }
+
     if (args.length === 0) {
       return this.$element.val();
     }

+ 25 - 0
dist/js/select2.amd.js

@@ -3750,7 +3750,32 @@ define('select2/core',[
     return this.$container.hasClass('select2-container--open');
   };
 
+  Select2.prototype.enable = function (args) {
+    if (console && console.warn) {
+      console.warn(
+        'Select2: The `select2("val")` method has been deprecated and will be' +
+        ' removed in later Select2 versions. Use $element.prop("disabled") ' +
+        'instead.'
+      );
+    }
+
+    if (args.length === 0) {
+      args = [true];
+    }
+
+    var disabled = !args[0];
+
+    this.$element.prop('disabled', disabled);
+  };
+
   Select2.prototype.val = function (args) {
+    if (console && console.warn) {
+      console.warn(
+        'Select2: The `select2("val")` method has been deprecated and will be' +
+        ' removed in later Select2 versions. Use $element.val() instead.'
+      );
+    }
+
     if (args.length === 0) {
       return this.$element.val();
     }

+ 25 - 0
dist/js/select2.full.js

@@ -13285,7 +13285,32 @@ define('select2/core',[
     return this.$container.hasClass('select2-container--open');
   };
 
+  Select2.prototype.enable = function (args) {
+    if (console && console.warn) {
+      console.warn(
+        'Select2: The `select2("val")` method has been deprecated and will be' +
+        ' removed in later Select2 versions. Use $element.prop("disabled") ' +
+        'instead.'
+      );
+    }
+
+    if (args.length === 0) {
+      args = [true];
+    }
+
+    var disabled = !args[0];
+
+    this.$element.prop('disabled', disabled);
+  };
+
   Select2.prototype.val = function (args) {
+    if (console && console.warn) {
+      console.warn(
+        'Select2: The `select2("val")` method has been deprecated and will be' +
+        ' removed in later Select2 versions. Use $element.val() instead.'
+      );
+    }
+
     if (args.length === 0) {
       return this.$element.val();
     }

File diff suppressed because it is too large
+ 0 - 0
dist/js/select2.full.min.js


+ 25 - 0
dist/js/select2.js

@@ -4178,7 +4178,32 @@ define('select2/core',[
     return this.$container.hasClass('select2-container--open');
   };
 
+  Select2.prototype.enable = function (args) {
+    if (console && console.warn) {
+      console.warn(
+        'Select2: The `select2("val")` method has been deprecated and will be' +
+        ' removed in later Select2 versions. Use $element.prop("disabled") ' +
+        'instead.'
+      );
+    }
+
+    if (args.length === 0) {
+      args = [true];
+    }
+
+    var disabled = !args[0];
+
+    this.$element.prop('disabled', disabled);
+  };
+
   Select2.prototype.val = function (args) {
+    if (console && console.warn) {
+      console.warn(
+        'Select2: The `select2("val")` method has been deprecated and will be' +
+        ' removed in later Select2 versions. Use $element.val() instead.'
+      );
+    }
+
     if (args.length === 0) {
       return this.$element.val();
     }

File diff suppressed because it is too large
+ 0 - 0
dist/js/select2.min.js


+ 25 - 0
src/js/select2/core.js

@@ -297,7 +297,32 @@ define([
     return this.$container.hasClass('select2-container--open');
   };
 
+  Select2.prototype.enable = function (args) {
+    if (console && console.warn) {
+      console.warn(
+        'Select2: The `select2("val")` method has been deprecated and will be' +
+        ' removed in later Select2 versions. Use $element.prop("disabled") ' +
+        'instead.'
+      );
+    }
+
+    if (args.length === 0) {
+      args = [true];
+    }
+
+    var disabled = !args[0];
+
+    this.$element.prop('disabled', disabled);
+  };
+
   Select2.prototype.val = function (args) {
+    if (console && console.warn) {
+      console.warn(
+        'Select2: The `select2("val")` method has been deprecated and will be' +
+        ' removed in later Select2 versions. Use $element.val() instead.'
+      );
+    }
+
     if (args.length === 0) {
       return this.$element.val();
     }

Some files were not shown because too many files changed in this diff