Sha256: d2c2ea3fdb33f831ddbf3fe72a592d8ae1a4b39a205003dd71c487f247f99002

Contents?: true

Size: 811 Bytes

Versions: 1

Compression:

Stored size: 811 Bytes

Contents

angular.module('EssayApp.directives').directive "spinner", ['$timeout', ($timeout) ->
  restrict: 'A'
  scope: true
  require: "?ngModel"
  link: (scope, element, attrs, ngModel) ->
    defaults =
      min: 0
      max: 10000
      step: 1
      spin: (event, ui) ->
        ngModel.$setViewValue(ui.value)
        scope.$apply()
      change: (event, ui) ->
        elem = $(this)
        max = elem.spinner("option", "max")

        if elem.spinner("value") > max
          elem.val(max)
          elem.trigger("change")

        return true

    # Take a hash of options from the chosen directive
    options = scope.$eval(attrs.spinner) or {}

    # Merge options with default options
    options = $.extend defaults, options

    $timeout (->
      element.spinner(options)
      return
    ), 0, false
]

Version data entries

1 entries across 1 versions & 1 rubygems

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