rallly/public/js/directives/dropdown.directive.js
Luke Vella 1b20a11bba New Features
- added notifications
- added toggle switches
- added delete feature
- added email verification
2015-01-26 13:11:48 +01:00

27 lines
853 B
JavaScript

angular.module('rallly')
.directive('dropdown', function($document){
return {
restrict : 'A',
link : function(scope, el, attrs){
el.addClass('dropdown');
scope.open = false;
var clickHandler = function(event){
var isClickedElementChildOfPopup = el.find(event.target).length > 0;
if (isClickedElementChildOfPopup) return;
scope.toggle();
}
scope.toggle = function(){
scope.open = !scope.open;
if (scope.open){
el.addClass('open');
$document.bind('click', clickHandler);
} else {
el.removeClass('open');
$document.unbind('click', clickHandler);
}
}
}
}
});