1
0
mirror of https://github.com/chylex/Nextcloud-News.git synced 2024-10-16 23:42:49 +02:00
Nextcloud-News/js/directive/ClickOutside.js
Aurélien 2e316f8f64 Add directive ClickOutside for hide dropdown
Signed-off-by: Aurélien <dav.aurelien@gmail.com>
2021-04-08 23:17:31 +02:00

32 lines
854 B
JavaScript

/**
* Nextcloud - News
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Marco Nassabain <marco.nassabain@hotmail.com>
* @author Nicolas Wendling <nicolas.wendling1011@gmail.com>
* @author Jimmy Huynh <natorisaki@gmail.com>
* @author Aurélien David <dav.aurelien@gmail.com>
*/
app.directive('clickOutside', function ($document) {
'use strict';
return {
restrict: 'A',
scope: {
clickOutside: '&'
},
link: function (scope, el) {
$document.on('click', function (e) {
if (el !== e.target && !el[0].contains(e.target)) {
scope.$apply(function () {
scope.$eval(scope.clickOutside);
});
}
});
}
};
});