Sha256: 3df2f86dc69e9a2dc8c2b5aad5e1f62b0ad073cf36df75f34fbdb9efc894f309

Contents?: true

Size: 810 Bytes

Versions: 7

Compression:

Stored size: 810 Bytes

Contents

class Backbone.Poised.NumberControl extends Backbone.Poised.BaseControl
  initialize: (options = {}) ->
    super

    @options = _.chain(options)
      .pick('model', 'clearOnFocus', 'stepSize', 'precision', 'range', 'attribute', 'unit', 'minValue', 'maxValue')
      .defaults
        clearOnFocus: true
        type: 'number'
        minValue: _.firstDefined(options.minValue, options.range?[0])
        maxValue: _.firstDefined(options.maxValue, options.range?[1])
        parentView: this
      .value()

    if @options.stepSize? and not @options.precision?
      @options.precision = _.find([0..3], (i) =>
        @options.stepSize * Math.pow(10, i) >= 1)

  render: =>
    super

    @subviews.spinner = new Backbone.Poised.Textfield(@options)
    @$input.html(@subviews.spinner.render().el)

    this

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ela-4.1.6 app/js/vendor/backbone.poised/form/number_control.coffee
ela-4.1.5 app/js/vendor/backbone.poised/form/number_control.coffee
ela-4.1.4 app/js/vendor/backbone.poised/form/number_control.coffee
ela-4.1.3 app/js/vendor/backbone.poised/form/number_control.coffee
ela-4.1.2 app/js/vendor/backbone.poised/form/number_control.coffee
ela-4.1.1 app/js/vendor/backbone.poised/form/number_control.coffee
ela-4.1.0 app/js/vendor/backbone.poised/form/number_control.coffee