diff --git a/dist/js/select2.amd.full.js b/dist/js/select2.amd.full.js index 76b95bd2..74b3b52d 100644 --- a/dist/js/select2.amd.full.js +++ b/dist/js/select2.amd.full.js @@ -46,13 +46,13 @@ define('select2/utils',[], function () { function DecoratedClass () { var unshift = Array.prototype.unshift; - unshift.call(arguments, SuperClass.prototype.constructor); - var argCount = DecoratorClass.prototype.constructor.length; var calledConstructor = SuperClass.prototype.constructor; if (argCount > 0) { + unshift.call(arguments, SuperClass.prototype.constructor); + calledConstructor = DecoratorClass.prototype.constructor; } @@ -74,23 +74,26 @@ define('select2/utils',[], function () { for (var m = 0; m < decoratedMethods.length; m++) { var methodName = decoratedMethods[m]; - var originalMethod = function () {}; + function calledMethod (methodName) { + // Stub out the original method if it's not decorating an actual method + var originalMethod = function () {}; - if (methodName in DecoratedClass.prototype) { - originalMethod = DecoratedClass.prototype[methodName]; + if (methodName in DecoratedClass.prototype) { + originalMethod = DecoratedClass.prototype[methodName]; + } + + var decoratedMethod = DecoratorClass.prototype[methodName]; + + return function () { + var unshift = Array.prototype.unshift; + + unshift.call(arguments, originalMethod); + + return decoratedMethod.apply(this, arguments); + } } - var decoratedMethod = DecoratorClass.prototype[methodName]; - - function calledMethod () { - var unshift = Array.prototype.unshift; - - unshift.call(arguments, originalMethod); - - return decoratedMethod.apply(this, arguments); - } - - DecoratedClass.prototype[methodName] = calledMethod; + DecoratedClass.prototype[methodName] = calledMethod(methodName); } return DecoratedClass; @@ -275,8 +278,6 @@ define('select2/results',[ var $options = self.$results.find(".option"); - console.log($options); - $options.each(function () { var $option = $(this); var item = $option.data("data"); @@ -430,7 +431,7 @@ define('select2/options',[ this.dataAdapter = SelectData; this.resultsAdapter = ResultsList; this.dropdownAdapter = Dropdown; - this.selectionAdapter = Selection; + this.selectionAdapter = options.selectionAdapter || Selection; } return Options; diff --git a/dist/js/select2.amd.js b/dist/js/select2.amd.js index 76b95bd2..74b3b52d 100644 --- a/dist/js/select2.amd.js +++ b/dist/js/select2.amd.js @@ -46,13 +46,13 @@ define('select2/utils',[], function () { function DecoratedClass () { var unshift = Array.prototype.unshift; - unshift.call(arguments, SuperClass.prototype.constructor); - var argCount = DecoratorClass.prototype.constructor.length; var calledConstructor = SuperClass.prototype.constructor; if (argCount > 0) { + unshift.call(arguments, SuperClass.prototype.constructor); + calledConstructor = DecoratorClass.prototype.constructor; } @@ -74,23 +74,26 @@ define('select2/utils',[], function () { for (var m = 0; m < decoratedMethods.length; m++) { var methodName = decoratedMethods[m]; - var originalMethod = function () {}; + function calledMethod (methodName) { + // Stub out the original method if it's not decorating an actual method + var originalMethod = function () {}; - if (methodName in DecoratedClass.prototype) { - originalMethod = DecoratedClass.prototype[methodName]; + if (methodName in DecoratedClass.prototype) { + originalMethod = DecoratedClass.prototype[methodName]; + } + + var decoratedMethod = DecoratorClass.prototype[methodName]; + + return function () { + var unshift = Array.prototype.unshift; + + unshift.call(arguments, originalMethod); + + return decoratedMethod.apply(this, arguments); + } } - var decoratedMethod = DecoratorClass.prototype[methodName]; - - function calledMethod () { - var unshift = Array.prototype.unshift; - - unshift.call(arguments, originalMethod); - - return decoratedMethod.apply(this, arguments); - } - - DecoratedClass.prototype[methodName] = calledMethod; + DecoratedClass.prototype[methodName] = calledMethod(methodName); } return DecoratedClass; @@ -275,8 +278,6 @@ define('select2/results',[ var $options = self.$results.find(".option"); - console.log($options); - $options.each(function () { var $option = $(this); var item = $option.data("data"); @@ -430,7 +431,7 @@ define('select2/options',[ this.dataAdapter = SelectData; this.resultsAdapter = ResultsList; this.dropdownAdapter = Dropdown; - this.selectionAdapter = Selection; + this.selectionAdapter = options.selectionAdapter || Selection; } return Options; diff --git a/dist/js/select2.full.js b/dist/js/select2.full.js index 88f93ec9..f2511667 100644 --- a/dist/js/select2.full.js +++ b/dist/js/select2.full.js @@ -9583,13 +9583,13 @@ define('select2/utils',[], function () { function DecoratedClass () { var unshift = Array.prototype.unshift; - unshift.call(arguments, SuperClass.prototype.constructor); - var argCount = DecoratorClass.prototype.constructor.length; var calledConstructor = SuperClass.prototype.constructor; if (argCount > 0) { + unshift.call(arguments, SuperClass.prototype.constructor); + calledConstructor = DecoratorClass.prototype.constructor; } @@ -9611,23 +9611,26 @@ define('select2/utils',[], function () { for (var m = 0; m < decoratedMethods.length; m++) { var methodName = decoratedMethods[m]; - var originalMethod = function () {}; + function calledMethod (methodName) { + // Stub out the original method if it's not decorating an actual method + var originalMethod = function () {}; - if (methodName in DecoratedClass.prototype) { - originalMethod = DecoratedClass.prototype[methodName]; + if (methodName in DecoratedClass.prototype) { + originalMethod = DecoratedClass.prototype[methodName]; + } + + var decoratedMethod = DecoratorClass.prototype[methodName]; + + return function () { + var unshift = Array.prototype.unshift; + + unshift.call(arguments, originalMethod); + + return decoratedMethod.apply(this, arguments); + } } - var decoratedMethod = DecoratorClass.prototype[methodName]; - - function calledMethod () { - var unshift = Array.prototype.unshift; - - unshift.call(arguments, originalMethod); - - return decoratedMethod.apply(this, arguments); - } - - DecoratedClass.prototype[methodName] = calledMethod; + DecoratedClass.prototype[methodName] = calledMethod(methodName); } return DecoratedClass; @@ -9812,8 +9815,6 @@ define('select2/results',[ var $options = self.$results.find(".option"); - console.log($options); - $options.each(function () { var $option = $(this); var item = $option.data("data"); @@ -9967,7 +9968,7 @@ define('select2/options',[ this.dataAdapter = SelectData; this.resultsAdapter = ResultsList; this.dropdownAdapter = Dropdown; - this.selectionAdapter = Selection; + this.selectionAdapter = options.selectionAdapter || Selection; } return Options; diff --git a/dist/js/select2.js b/dist/js/select2.js index 1c08c362..06ce806e 100644 --- a/dist/js/select2.js +++ b/dist/js/select2.js @@ -474,13 +474,13 @@ define('select2/utils',[], function () { function DecoratedClass () { var unshift = Array.prototype.unshift; - unshift.call(arguments, SuperClass.prototype.constructor); - var argCount = DecoratorClass.prototype.constructor.length; var calledConstructor = SuperClass.prototype.constructor; if (argCount > 0) { + unshift.call(arguments, SuperClass.prototype.constructor); + calledConstructor = DecoratorClass.prototype.constructor; } @@ -502,23 +502,26 @@ define('select2/utils',[], function () { for (var m = 0; m < decoratedMethods.length; m++) { var methodName = decoratedMethods[m]; - var originalMethod = function () {}; + function calledMethod (methodName) { + // Stub out the original method if it's not decorating an actual method + var originalMethod = function () {}; - if (methodName in DecoratedClass.prototype) { - originalMethod = DecoratedClass.prototype[methodName]; + if (methodName in DecoratedClass.prototype) { + originalMethod = DecoratedClass.prototype[methodName]; + } + + var decoratedMethod = DecoratorClass.prototype[methodName]; + + return function () { + var unshift = Array.prototype.unshift; + + unshift.call(arguments, originalMethod); + + return decoratedMethod.apply(this, arguments); + } } - var decoratedMethod = DecoratorClass.prototype[methodName]; - - function calledMethod () { - var unshift = Array.prototype.unshift; - - unshift.call(arguments, originalMethod); - - return decoratedMethod.apply(this, arguments); - } - - DecoratedClass.prototype[methodName] = calledMethod; + DecoratedClass.prototype[methodName] = calledMethod(methodName); } return DecoratedClass; @@ -703,8 +706,6 @@ define('select2/results',[ var $options = self.$results.find(".option"); - console.log($options); - $options.each(function () { var $option = $(this); var item = $option.data("data"); @@ -858,7 +859,7 @@ define('select2/options',[ this.dataAdapter = SelectData; this.resultsAdapter = ResultsList; this.dropdownAdapter = Dropdown; - this.selectionAdapter = Selection; + this.selectionAdapter = options.selectionAdapter || Selection; } return Options; diff --git a/playground/basic/basic.html b/playground/basic/basic.html index 048bdead..311a201f 100644 --- a/playground/basic/basic.html +++ b/playground/basic/basic.html @@ -120,29 +120,6 @@ -