Sha256: 3580a00dc8d8e9c7b28ee3c47bd9cd8a0d8f333e292b2e679317ec222c24a11f

Contents?: true

Size: 964 Bytes

Versions: 15

Compression:

Stored size: 964 Bytes

Contents

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

  template: 'pageflow/ui/templates/inputs/check_box',
  className: 'check_box_input',

  events: {
    'change': 'save'
  },

  ui: {
    input: 'input',
    label: 'label'
  },

  onRender: function() {
    this.ui.label.attr('for', this.cid);
    this.ui.input.attr('id', this.cid);

    this.load();
    this.listenTo(this.model, 'change:' + this.options.propertyName, this.load);
  },

  save: function() {
    if (!this.options.disabled) {
      this.model.set(this.options.propertyName, this.ui.input.is(':checked'));
    }
  },

  load: function() {
    if (!this.isClosed) {
      this.ui.input.prop('checked', this.displayValue());
    }
  },

  displayValue: function() {
    if (this.options.disabled && this.options.displayUncheckedIfDisabled) {
      return false;
    }
    else {
      return this.model.get(this.options.propertyName);
    }
  }
});

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
pageflow-0.11.4 app/assets/javascripts/pageflow/ui/views/inputs/check_box_input_view.js
pageflow-0.11.3 app/assets/javascripts/pageflow/ui/views/inputs/check_box_input_view.js
pageflow-0.11.2 app/assets/javascripts/pageflow/ui/views/inputs/check_box_input_view.js
pageflow-0.11.1 app/assets/javascripts/pageflow/ui/views/inputs/check_box_input_view.js
pageflow-0.11.0 app/assets/javascripts/pageflow/ui/views/inputs/check_box_input_view.js
pageflow-0.10.0 app/assets/javascripts/pageflow/ui/views/inputs/check_box_input_view.js
pageflow-0.9.2 app/assets/javascripts/pageflow/ui/views/inputs/check_box_input_view.js
pageflow-0.9.1 app/assets/javascripts/pageflow/ui/views/inputs/check_box_input_view.js
pageflow-0.9.0 app/assets/javascripts/pageflow/ui/views/inputs/check_box_input_view.js
pageflow-0.8.2 app/assets/javascripts/pageflow/ui/views/inputs/check_box_input_view.js
pageflow-0.8.1 app/assets/javascripts/pageflow/ui/views/inputs/check_box_input_view.js
pageflow-0.8.0 app/assets/javascripts/pageflow/ui/views/inputs/check_box_input_view.js
pageflow-0.7.2 app/assets/javascripts/pageflow/ui/views/inputs/check_box_input_view.js
pageflow-0.7.1 app/assets/javascripts/pageflow/ui/views/inputs/check_box_input_view.js
pageflow-0.7.0 app/assets/javascripts/pageflow/ui/views/inputs/check_box_input_view.js