{"size": 1766, "ext": "js", "max_stars_repo_path": "src/foam/u2/CheckBox.js", "max_stars_repo_name": "lchanmann/foam2", "max_stars_repo_stars_event_min_datetime": "2017-02-22T11:07:21.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-31T08:42:58.000Z", "max_issues_repo_path": "src/foam/u2/CheckBox.js", "max_issues_repo_name": "lchanmann/foam2", "max_issues_repo_issues_event_min_datetime": "2017-02-22T16:41:38.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-01T18:48:15.000Z", "max_forks_repo_path": "src/foam/u2/CheckBox.js", "max_forks_repo_name": "lchanmann/foam2", "max_forks_repo_forks_event_min_datetime": "2017-01-04T14:01:44.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-22T20:19:43.000Z"}
{"max_stars_count": 78, "max_issues_count": 1368, "max_forks_count": 112, "avg_line_length": 25.2285714286, "max_line_length": 75, "alphanum_fraction": 0.5973952435}
/**
 * @license
 * Copyright 2015 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

foam.CLASS({
  package: 'foam.u2',
  name: 'CheckBox',
  extends: 'foam.u2.property.AbstractCheckBox',

  documentation: 'Checkbox View.',

  css: `
    ^ {
      margin: 8px 0;
      padding: 8px;
    }
    ^:disabled {
      appearance: none;
      background: rgba(0,0,0,0);
      border: none;
      box-shadow: none;
      outline: none;
      padding-left: 0;
    }
    input[type='checkbox']^:checked:disabled:after {
      background: none;
      box-shadow: none;
      color: gray;
    }
    `,

  methods: [
    function initE() {
      this.SUPER();

      this.addClass(this.myClass());
      this.setAttribute('type', 'checkbox');

      var self = this;

      if ( this.showLabel ) {
        this.start('label')
          .addClass(this.myClass('label'))
          .addClass(this.myClass('noselect'))
          .callIfElse(this.labelFormatter,
            this.labelFormatter,
            function() { this.add(self.label$); })
          .on('click', function() {
            if ( self.getAttribute('disabled') ) return;
            this.data = ! this.data;
          }.bind(this))
        .end();
      }
    }
  ]
});
