From bb8ff2d779ee4cf2dd7f9c84670f72e4012dba5f Mon Sep 17 00:00:00 2001 From: Valtteri Laine Date: Tue, 4 Dec 2018 07:20:59 +0200 Subject: [PATCH 1/8] Redefine empty check. --- dist/angular-selectize.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dist/angular-selectize.js b/dist/angular-selectize.js index a009975..54c7ed2 100755 --- a/dist/angular-selectize.js +++ b/dist/angular-selectize.js @@ -17,8 +17,13 @@ angular.module('selectize', []).value('selectizeConfig', {}).directive("selectiz scope.config = scope.config || {}; var isEmpty = function(val) { - return val === undefined || val === null || !val.length; //support checking empty arrays - }; + return ( + val === undefined || + val === null || + typeof val !== 'object' || + !val.length + ); + }; // Support checking empty array var toggle = function(disabled) { disabled ? selectize.disable() : selectize.enable(); From f4a22aead69d75fe12eb054852a35e3d7f64601b Mon Sep 17 00:00:00 2001 From: Valtteri Laine Date: Thu, 13 Dec 2018 10:54:53 +0200 Subject: [PATCH 2/8] Guick fix. --- dist/angular-selectize.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/dist/angular-selectize.js b/dist/angular-selectize.js index 54c7ed2..d5f1e8e 100755 --- a/dist/angular-selectize.js +++ b/dist/angular-selectize.js @@ -3,6 +3,8 @@ * https://github.com/machineboy2045/angular-selectize **/ +// jsruok MOD 2017-06-14: isEmpty array check redefined + angular.module('selectize', []).value('selectizeConfig', {}).directive("selectize", ['selectizeConfig', function(selectizeConfig) { return { restrict: 'EA', @@ -17,13 +19,8 @@ angular.module('selectize', []).value('selectizeConfig', {}).directive("selectiz scope.config = scope.config || {}; var isEmpty = function(val) { - return ( - val === undefined || - val === null || - typeof val !== 'object' || - !val.length - ); - }; // Support checking empty array + return val === undefined || val === null || (val && typeof val === 'object' && !val.length); //support checking empty arrays // MOD: !val.length => (val && typeof val === 'object' && !val.length) + }; var toggle = function(disabled) { disabled ? selectize.disable() : selectize.enable(); @@ -109,4 +106,4 @@ angular.module('selectize', []).value('selectizeConfig', {}).directive("selectiz }); } }; -}]); +}]); \ No newline at end of file From b502ac156bc8d2e66edbe9eaa77490d58a289abc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jussi=20Ruokom=C3=A4ki?= Date: Wed, 19 Jun 2019 14:51:52 +0200 Subject: [PATCH 3/8] Adds more precise check whether setValue should be called Using Selectize v.0.12.6 and angular-selectize v.3.0.1 the input loses focus when selectize.setValue() is called. To avoid losing focus we'll refrain from making unnecessary calls to setValue(). This doesn't happen using Selectize 0.12.1. The reason for losing the focus after update is unclear. --- dist/angular-selectize.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dist/angular-selectize.js b/dist/angular-selectize.js index d5f1e8e..1a311b1 100755 --- a/dist/angular-selectize.js +++ b/dist/angular-selectize.js @@ -53,7 +53,8 @@ angular.module('selectize', []).value('selectizeConfig', {}).directive("selectiz selectize.$control.toggleClass('ng-dirty', modelCtrl.$dirty); selectize.$control.toggleClass('ng-pristine', modelCtrl.$pristine); - if (!angular.equals(selectize.items, scope.ngModel)) { + if (settings.maxItems !== 1 && !angular.equals(selectize.items, scope.ngModel) || + selectize.items[0] != scope.ngModel) { selectize.setValue(scope.ngModel, true); } } @@ -106,4 +107,4 @@ angular.module('selectize', []).value('selectizeConfig', {}).directive("selectiz }); } }; -}]); \ No newline at end of file +}]); From ca6153457dece478105f0a1288e919a684160fbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jussi=20Ruokom=C3=A4ki?= Date: Thu, 20 Jun 2019 19:01:04 +0200 Subject: [PATCH 4/8] Adds comments to the earlier mod --- dist/angular-selectize.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dist/angular-selectize.js b/dist/angular-selectize.js index 1a311b1..f17f603 100755 --- a/dist/angular-selectize.js +++ b/dist/angular-selectize.js @@ -4,6 +4,7 @@ **/ // jsruok MOD 2017-06-14: isEmpty array check redefined +// jsruok MOD 2019-06-20: selectize.items, scope.ngModel comparison refined angular.module('selectize', []).value('selectizeConfig', {}).directive("selectize", ['selectizeConfig', function(selectizeConfig) { return { @@ -54,7 +55,7 @@ angular.module('selectize', []).value('selectizeConfig', {}).directive("selectiz selectize.$control.toggleClass('ng-pristine', modelCtrl.$pristine); if (settings.maxItems !== 1 && !angular.equals(selectize.items, scope.ngModel) || - selectize.items[0] != scope.ngModel) { + selectize.items[0] != scope.ngModel) { // If maxItems is 1, items is an array and ngModel is a string selectize.setValue(scope.ngModel, true); } } From c8d97dbaa6a583861c751f16c86b9c745a063e31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jussi=20Ruokom=C3=A4ki?= Date: Fri, 3 Jun 2022 13:32:55 +0300 Subject: [PATCH 5/8] Fixes auto close after second selection --- dist/angular-selectize.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/angular-selectize.js b/dist/angular-selectize.js index f17f603..7d8059d 100755 --- a/dist/angular-selectize.js +++ b/dist/angular-selectize.js @@ -55,7 +55,7 @@ angular.module('selectize', []).value('selectizeConfig', {}).directive("selectiz selectize.$control.toggleClass('ng-pristine', modelCtrl.$pristine); if (settings.maxItems !== 1 && !angular.equals(selectize.items, scope.ngModel) || - selectize.items[0] != scope.ngModel) { // If maxItems is 1, items is an array and ngModel is a string + settings.maxItems === 1 && selectize.items[0] != scope.ngModel) { // If maxItems is 1, items is an array and ngModel is a string selectize.setValue(scope.ngModel, true); } } From 54effee15a0a4ebf137e53029bc8135c3e5eb5fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jussi=20Ruokom=C3=A4ki?= Date: Fri, 3 Jun 2022 15:53:51 +0300 Subject: [PATCH 6/8] 3.0.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 317df0c..0172f1d 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ ], "main": "dist/angular-selectize.js", "description": "This is an Angular.js directive for Brian Reavis's selectize jQuery plugin. It supports all of Selectize's features", - "version": "v3.0.2", + "version": "3.0.3", "license": "MIT", "repository": { "type": "git", From e731a3f1b1959c526ef04a0882b56edcb37d6821 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jussi=20Ruokom=C3=A4ki?= Date: Fri, 3 Jun 2022 16:13:41 +0300 Subject: [PATCH 7/8] Version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0172f1d..c120d47 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ ], "main": "dist/angular-selectize.js", "description": "This is an Angular.js directive for Brian Reavis's selectize jQuery plugin. It supports all of Selectize's features", - "version": "3.0.3", + "version": "3.0.5", "license": "MIT", "repository": { "type": "git", From 71a698b675d3ae42aca1295063e1ea7a3fe17237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jussi=20Ruokom=C3=A4ki?= Date: Tue, 7 Jun 2022 11:40:52 +0300 Subject: [PATCH 8/8] Version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c120d47..dd477c3 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ ], "main": "dist/angular-selectize.js", "description": "This is an Angular.js directive for Brian Reavis's selectize jQuery plugin. It supports all of Selectize's features", - "version": "3.0.5", + "version": "v3.0.7", "license": "MIT", "repository": { "type": "git",