Sha256: a372915e528ad6a86df3f18f7450ab0993f436b52746057fb4c4259277b2e486

Contents?: true

Size: 794 Bytes

Versions: 1

Compression:

Stored size: 794 Bytes

Contents

angular.module('EssayApp.directives').directive "ngShave", ['$timeout', ($timeout) ->
  restrict: 'A'
  scope: true
  link: (scope, element, attrs) ->
    defaults = {
    }
    param = scope.$eval(attrs.ngShave)
    scope.content = undefined
    scope._cutted = true
    maxheight = if angular.isNumber(param)
                  param
                else
                  param?.maxheight || 100

    options = $.extend defaults, param

    scope.toggleShave = ->
      # TODO
      console.log 'toggleShave'
      scope._cutted = !scope._cutted
      if scope._cutted
        element.shave(maxheight, options)
      else
        element.html(scope.content)

    initShave = ->
      scope.content = element.html()
      element.shave(maxheight, options)

    $timeout initShave, 1, false

]

Version data entries

1 entries across 1 versions & 1 rubygems

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