Sha256: c129fcd409f4b82ad0944950dd0afb573c1c51e6ebdff36b32b9a58652f75510

Contents?: true

Size: 811 Bytes

Versions: 12

Compression:

Stored size: 811 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)
    @$info.append(@subviews.spinner.render().el)

    this

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ela-4.0.0 app/js/vendor/backbone.poised/form/number_control.coffee
ela-3.4.3 app/js/vendor/backbone.poised/form/number_control.coffee
ela-3.4.2 app/js/vendor/backbone.poised/form/number_control.coffee
ela-3.4.0 app/js/vendor/backbone.poised/form/number_control.coffee
ela-3.3.1 app/js/vendor/backbone.poised/form/number_control.coffee
ela-3.3.0 app/js/vendor/backbone.poised/form/number_control.coffee
ela-3.2.0 app/js/vendor/backbone.poised/form/number_control.coffee
ela-3.1.1 app/js/vendor/backbone.poised/form/number_control.coffee
ela-3.1.0 app/js/vendor/backbone.poised/form/number_control.coffee
ela-3.0.0 app/js/vendor/backbone.poised/form/number_control.coffee
ela-2.0.0 app/js/vendor/backbone.poised/form/number_control.coffee
ela-1.1.0 app/js/vendor/backbone.poised/form/number_control.coffee