             maxy = L.max offsets.map (o) -> o.top + o.height
             topBars = getTopBars offsets
             ystep = element[0].offsetHeight
+            unless ystep
+              $timeout doResize, 10
+              return
+
             p1 =
               x: element[0].offsetLeft
               y: element[0].offsetTop + 1 # Don't get intersects with own top bar.


            if factor > 1 and panelBody = element[0].querySelector('.panel-body')
              totalHeight = ystep * factor - margin
              panelBody.style.height = "#{ totalHeight - (p1.y - panelBody.offsetTop) }px"
              element.addClass 'expanded'

          $window.addEventListener 'resize', ->
            element[0].querySelector('.panel-body')?.style.height = null
            element.removeClass 'expanded'
            setTimeout doResize, 10

          setTimeout doResize, 10

  Directives.directive 'nativeTool', ($window, $compile, $injector) ->
    restrict: 'E'
    scope:
      tool: '=tool'
    link: (scope, element, attrs) ->

      scope.$watch 'tool.controllerURI', ->
        if scope.tool

          ctrl = $window.location.origin + scope.tool.controllerURI
          tmpl = $window.location.origin + scope.tool.templateURI

require ['angular', 'lodash', 'lines', 'jschannel', 'services'], (ng, L, lines, Channel) ->

  Directives = ng.module('steps.directives', ['steps.services'])

  Directives.directive 'html5FileUpload', ->
    restrict: 'E'
    require: ['ngModel']
    replace: true
    template: """<input type="file">"""
    link: (scope, elem, attrs, [ngModel]) ->
      elem.on 'change', -> scope.$apply ->
        file = elem[0].files[0]
        ngModel.$setViewValue file

  Directives.directive 'appVersion', ['version', (v) -> (scope, elm) -> elm.text(version)]

