Skip to content
This repository has been archived by the owner on May 21, 2021. It is now read-only.

Commit

Permalink
feat(dropdown): provide hooks for dropdown open and dropdown close ev…
Browse files Browse the repository at this point in the history
…ents

It is implemented via w11kSelectConfig.dropdown.onOpen and .onClose.

Closes #24
  • Loading branch information
Philipp Burgmer committed Feb 2, 2016
1 parent b163b99 commit 54ab150
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/w11k-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ angular.module('w11k.select').constant('w11kSelectConfig', {
*/
text: undefined
},
dropdown: {
onOpen: undefined,
onClose: undefined
},
/** all the configuration for the filter section within the dropdown */
filter: {
/** activate filter input to search for options */
Expand Down Expand Up @@ -386,6 +390,10 @@ angular.module('w11k.select').directive('w11kSelect', [
}
});
jqWindow.on('resize', adjustHeight);

if (angular.isFunction(scope.config.dropdown.onOpen)) {
scope.config.dropdown.onOpen();
}
},
onClose: function () {
// important: set properties of filter.values to empty strings not to null,
Expand All @@ -397,6 +405,10 @@ angular.module('w11k.select').directive('w11kSelect', [
});
$document.off('keyup', onEscPressed);
jqWindow.off('resize', adjustHeight);

if (angular.isFunction(scope.config.dropdown.onClose)) {
scope.config.dropdown.onClose();
}
}
};

Expand Down
10 changes: 9 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

angular.module('demo', ['w11k.select']);

angular.module('demo').controller('TestCtrl', function ($scope) {
angular.module('demo').controller('TestCtrl', function ($scope, $log) {

var amount = 1000;

Expand Down Expand Up @@ -31,6 +31,14 @@ angular.module('demo').controller('TestCtrl', function ($scope) {
disabled: false,
header: {
placeholder: 'test'
},
dropdown: {
onOpen: function () {
$log.debug('dropdown onOpen callback called');
},
onClose: function () {
$log.debug('dropdown onClose callback called');
}
}
};

Expand Down

0 comments on commit 54ab150

Please sign in to comment.