Sha256: a6ac3cce3a32ccd6cd8a51f9cdb5ab2556f3e235faac4a6a484533db0f0d5ab1

Contents?: true

Size: 1.06 KB

Versions: 5

Compression:

Stored size: 1.06 KB

Contents

pageflow.SliderInputView = Backbone.Marionette.ItemView.extend({
  mixins: [pageflow.inputView],

  className: 'slider_input',
  template: 'pageflow/ui/templates/inputs/slider_input',

  ui: {
    widget: '.slider',
    value: '.value'
  },

  events: {
    'slidechange': 'save'
  },

  onRender: function() {
    this.ui.widget.slider({
      animate: 'fast',
      min: 'minValue' in this.options ? this.options.minValue : 0,
      max: 'maxValue' in this.options ? this.options.maxValue : 100,
    });

    this.load();
  },

  save: function() {
    var value = this.ui.widget.slider('option', 'value');
    var unit = 'unit' in this.options ? this.options.unit : '%';

    this.ui.value.text(value + unit);

    this.model.set(this.options.propertyName, value);
  },

  load: function() {
    var value;

    if (this.model.has(this.options.propertyName)) {
      value = this.model.get(this.options.propertyName)
    }
    else {
      value = 'defaultValue' in this.options ? this.options.defaultValue : 0
    }

    this.ui.widget.slider('option', 'value', value);
  }
});

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pageflow-0.11.4 app/assets/javascripts/pageflow/ui/views/inputs/slider_input_view.js
pageflow-0.11.3 app/assets/javascripts/pageflow/ui/views/inputs/slider_input_view.js
pageflow-0.11.2 app/assets/javascripts/pageflow/ui/views/inputs/slider_input_view.js
pageflow-0.11.1 app/assets/javascripts/pageflow/ui/views/inputs/slider_input_view.js
pageflow-0.11.0 app/assets/javascripts/pageflow/ui/views/inputs/slider_input_view.js