Sha256: cc0413e39c0aae5347cb6fb3f016acd0110c5fde63a5a6e74b02966312d5a5ab

Contents?: true

Size: 647 Bytes

Versions: 1

Compression:

Stored size: 647 Bytes

Contents

angular.module('EssayApp.directives').directive "ngDisabledWith", [() ->
  restrict: 'A'
  scope: true
  require: "?ngModel"
  link: (scope, element, attrs, ngModel) ->
    _by_value = element.is('input')

    scope.fn = fn = ->
      element?.attr('disabled')

    scope.title = if _by_value
      attrs.value
    else
      element.html()
    scope.alter = attrs.ngDisabledWith

    setValue = (value)->
      if _by_value
        element.attr('value', value)
      else
        element.html(value)

    scope.$watch fn, (v1, v2) ->
      if v1 != v2
        if v1?
          setValue(scope.alter)
        else
          setValue(scope.title)
]

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
translation_cms-0.1.5 app/assets/javascripts/app/directives/ng-disabled-with.js.coffee