Sha256: 25f1f5c65090949a248bceea81d811e3f89a64fbbcc512ac7df4176ab2eb3931

Contents?: true

Size: 1.49 KB

Versions: 113

Compression:

Stored size: 1.49 KB

Contents

angular.module('NgPopup', [])
  .directive 'ngPopup',($timeout) ->
    restrict: 'A',
    scope: {
      ngPopup: '@'
    }
    controller: ($scope, $element) ->
      popup = document.createElement('div')
      popup.setAttribute('class','ng-popup ng-hide')
      exitStatus = true
      while exitStatus
        $scope.uniqueId   = Math.floor(Math.random()*(1000000))
        exitStatus = !!document.getElementById($scope.uniqueId)
      popup.setAttribute('id', $scope.uniqueId)
      document.body.appendChild(popup)

    link: (scope, element, attributes) ->
      setView = (start) ->
        if start
          pos = element[0].getBoundingClientRect()
          popup = document.getElementById(scope.uniqueId)
          popup.style.left = (pos.right + 3) + 'px'
          popup.style.top = (pos.top + 3) + 'px'
          scope.runner = $timeout ->
            document.getElementById(scope.uniqueId).innerHTML = scope.ngPopup
            setView(true)
          30
          popup.classList.remove('ng-hide')
        else
          $timeout.cancel scope.runner
          document.getElementById(scope.uniqueId).classList.add('ng-hide')
      startListener = if (element[0].tagName == 'INPUT' || element[0].tagName == 'INPUT') then 'focus' else 'mouseenter'
      stopListener  = if (element[0].tagName == 'INPUT' || element[0].tagName == 'INPUT') then 'blur'  else 'mouseout'
      element[0].addEventListener startListener, ->
        setView(true)
      element[0].addEventListener stopListener, ->
        setView()

Version data entries

113 entries across 113 versions & 1 rubygems

Version Path
material_raingular-0.6.16 lib/assets/javascripts/directives/ngpopup.js.coffee
material_raingular-0.6.15 lib/assets/javascripts/directives/ngpopup.js.coffee
material_raingular-0.6.14 lib/assets/javascripts/directives/ngpopup.js.coffee
material_raingular-0.6.13 lib/assets/javascripts/directives/ngpopup.js.coffee
material_raingular-0.6.12 lib/assets/javascripts/directives/ngpopup.js.coffee
material_raingular-0.6.11 lib/assets/javascripts/directives/ngpopup.js.coffee
material_raingular-0.6.10 lib/assets/javascripts/directives/ngpopup.js.coffee
material_raingular-0.6.9 lib/assets/javascripts/directives/ngpopup.js.coffee
material_raingular-0.6.8 lib/assets/javascripts/directives/ngpopup.js.coffee
material_raingular-0.6.7 lib/assets/javascripts/directives/ngpopup.js.coffee
material_raingular-0.6.6 lib/assets/javascripts/directives/ngpopup.js.coffee
material_raingular-0.6.5 lib/assets/javascripts/directives/ngpopup.js.coffee
material_raingular-0.6.4 lib/assets/javascripts/directives/ngpopup.js.coffee
material_raingular-0.6.3 lib/assets/javascripts/directives/ngpopup.js.coffee
material_raingular-0.6.2.3 lib/assets/javascripts/directives/ngpopup.js.coffee
material_raingular-0.6.2.2 lib/assets/javascripts/directives/ngpopup.js.coffee
material_raingular-0.6.2.1 lib/assets/javascripts/directives/ngpopup.js.coffee
material_raingular-0.6.2 lib/assets/javascripts/directives/ngpopup.js.coffee
material_raingular-0.6.1.1 lib/assets/javascripts/directives/ngpopup.js.coffee
material_raingular-0.6.1 lib/assets/javascripts/directives/ngpopup.js.coffee