Sha256: a6dc7fe039cdc35329cc90d59639b61f691c52d9b787658b6b156a17f148bd9d

Contents?: true

Size: 1.38 KB

Versions: 10

Compression:

Stored size: 1.38 KB

Contents

module = angular.module('maestrano.components.mno-helptext',[])

module.directive("mnoHelptext", ['$window', ($window) ->
  return {
    restrict: 'A'
    link: (scope, elem, attrs, ctrl) ->
      delay = attrs.helptextDelay
      scope.$watch(
        () ->
          attrs.mnoHelptext
        ,() ->
          $(elem).tooltip({
            title: attrs.mnoHelptext,
            html: true,
            delay: {
              show: (delay || 1000)
              hide: 100
            },
            animation: false,
            placement: () ->
              if attrs.helptextPlacement
                return attrs.helptextPlacement
              else
                # Calculate remaining space on bottom, right, left
                remainingBottom = $($window).height() + $($window).scrollTop() - $(elem).offset().top - $(elem).height()
                remainingLeft = $(elem).offset().left - $($window).scrollLeft()
                remainingRight = $($window).width() - remainingLeft - $(elem).width()

                # Adjust positioning based on remaining space
                # Note that according to the rules below bottom is clearly preferred
                position = (if remainingBottom < 200 then 'top' else 'bottom')
                position = 'right' if remainingLeft < 50
                position = 'left' if remainingRight < 50
                return position
          })
      )
  }
])

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
mno-enterprise-frontend-2.0.9 app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-helptext.js.coffee
mno-enterprise-frontend-2.0.8 app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-helptext.js.coffee
mno-enterprise-frontend-2.0.7 app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-helptext.js.coffee
mno-enterprise-frontend-2.0.6 app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-helptext.js.coffee
mno-enterprise-frontend-2.0.5 app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-helptext.js.coffee
mno-enterprise-frontend-2.0.4 app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-helptext.js.coffee
mno-enterprise-frontend-2.0.3 app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-helptext.js.coffee
mno-enterprise-frontend-2.0.2 app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-helptext.js.coffee
mno-enterprise-frontend-2.0.1 app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-helptext.js.coffee
mno-enterprise-frontend-2.0.0 app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-helptext.js.coffee