Last active
August 29, 2015 14:13
-
-
Save ryardley/479cc146e980b662c6b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.directive('myOverlayer', function(ElementRegistry){ | |
return { | |
link: function(scope, element, attrs){ | |
var content, background, | |
registry = new ElementRegistry(scope); | |
registry.find('button', function(button){ | |
button.on('click', function(){ | |
scope.overlayShowing = !scope.overlayShowing; | |
}); | |
}); | |
registry.find('content', function(elem){ | |
content = elem; | |
}); | |
registry.find('background', function(elem){ | |
background = elem; | |
}); | |
scope.$watch('overlayShowing', function(showing){ | |
var display = showing ? 'block' : 'none'; | |
if(content) { content.css('display', display) } | |
if(background) { background.css('display', display) } | |
}); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment