Skip to content

Instantly share code, notes, and snippets.

@fracz
Last active June 21, 2016 19:43
Show Gist options
  • Save fracz/baf291849527607b42069fb6e0fa884a to your computer and use it in GitHub Desktop.
Save fracz/baf291849527607b42069fb6e0fa884a to your computer and use it in GitHub Desktop.
<div loading-cover="coversIfThisIsTrue">
   CONTENT
</div>
.loading-cover {
position: relative;
.loading:before, .loading:after {
content: " ";
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
min-height: 50px;
min-width: 50px;
z-index: 1000;
}
.loading:before {
background-color: white;
opacity: 0.5;
}
}
angular.module('emma').directive 'loadingCover', ->
restrict: 'A'
scope: no
link: (scope, element, attrs) ->
loadingLayer = angular.element('<div class="loading"></div>')
element.append(loadingLayer)
element.addClass('loading-cover')
scope.$watch attrs.loadingCover, (value) ->
loadingLayer.toggleClass('ng-hide', !value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment