<!DOCTYPE html>
<html ng-app="transclude-element">
<head>
<link data-require="foundation@*" data-semver="5.0.0" rel="stylesheet" href="//cdn.jsdelivr.net/foundation/5.0.0/css/normalize.css" />
<link data-require="foundation@*" data-semver="5.0.0" rel="stylesheet" href="//cdn.jsdelivr.net/foundation/5.0.0/css/foundation.min.css" />
<script data-require="jquery@*" data-semver="2.0.3" src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
<script data-require="angular.js@*" data-semver="1.2.9" src="http://code.angularjs.org/1.2.9/angular.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body>
<input type="text" drop-panel />
This is some stuff under the panel
</body>
</html>
angular.module('transclude-element', []).
directive('dropPanel', function(){
return {
transclude: 'element',
replace: true,
templateUrl: 'drop-panel.html',
link: function(scope, el){
var input = el.find('input[drop-panel]');
input.focus(function(){
el.addClass('is-active');
});
input.blur(function(){
el.removeClass('is-active');
});
}
}
});
.drop-panel {
position: relative;
}
.drop-panel input[drop-panel] {
margin-bottom: 0;
}
.drop-panel-panel {
position: absolute;
z-index: 100;
background-color: white;
border: 1px solid black;
left: 0;
right: 0;
padding: 10px 20px;
display: none;
}
.drop-panel.is-active .drop-panel-panel {
display: block;
}
<div class='drop-panel'>
<span ng-transclude></span>
<div class='drop-panel-panel'>
This is some panel content
</div>
</div>