<commit_before>package EnsEMBL::Web::Form::Element::DASCheckBox;

use strict;

use base qw(
  EnsEMBL::Web::DOM::Node::Element::Div
  EnsEMBL::Web::Form::Element
);

use constant {
  CSS_CLASS                  => 'ele-das',
  CSS_CLASS_CHECKBOX_WRAPPER => 'ele-das-left',
  CSS_CLASS_TEXT             => 'ele-das-right',
};

sub configure {
  ## @overrides
  my ($self, $params) = @_;
  
  $params->{'name'}   ||= 'logic_name';
  $params->{'value'}  ||= $params->{'das'}->logic_name;
  $params->{'label'}  ||= $params->{'das'}->label;
  $params->{'id'}     ||= $self->unique_id;

  $self->set_attribute('class', $self->CSS_CLASS.' '.($params->{'wrapper_class'} || ''));
  $self->set_attribute('id', $params->{'wrapper_id'}) if $params->{'wrapper_id'};
  
  my $checkbox = $self->dom->create_element('inputcheckbox', {'id' => $params->{'id'}, 'name' => $params->{'name'}, 'value', $params->{'value'}});
  $checkbox->set_attribute('class', $params->{'class'}) if $params->{'class'};
  $checkbox->checked(1)  if $params->{'checked'};
  $checkbox->disabled(1) if $params->{'disabled'};

  $self->append_child($self->dom->create_element('p', {'class' => $self->CSS_CLASS_CHECKBOX_WRAPPER}))->append_child($checkbox);
  $self->append_child($self->dom->create_element('div', {
    'inner_HTML'  => sprintf(qq(<p><label for="$params->{'id'}">$params->{'label'}) . ($params->{'das'}->logic_name eq  $params->{'label'} ? '' : ' ('.$params->{'das'}->logic_name.')') . qq(</label></p><div>$params->{'das'}->{'description'}  %s </div>), $params->{'das'}->{'homepage'} ? qq([<a href="$params->{'das'}->{'homepage'}">Homepage</a>]) : '' ),
    'class'       => $self->CSS_CLASS_TEXT
  }));
}

1;
<commit_msg>ade lesser method call; code tidy<commit_after>package EnsEMBL::Web::Form::Element::DASCheckBox;

use strict;

use base qw(
  EnsEMBL::Web::DOM::Node::Element::Div
  EnsEMBL::Web::Form::Element
);

use constant {
  CSS_CLASS                  => 'ele-das',
  CSS_CLASS_CHECKBOX_WRAPPER => 'ele-das-left',
  CSS_CLASS_TEXT             => 'ele-das-right',
};

sub configure {
  ## @overrides
  my ($self, $params) = @_;

  my $das               = $params->{'das'};
  my $logic_name        = $das->logic_name;
  $params->{'name'}   ||= 'logic_name';
  $params->{'value'}  ||= $logic_name;
  $params->{'label'}  ||= $das->label;
  $params->{'id'}     ||= $self->unique_id;

  $self->set_attributes({'class' => [$self->CSS_CLASS, $params->{'wrapper_class'} || ()], $params->{'wrapper_id'} ? ('id' => $params->{'wrapper_id'}) : ()});
  $self->append_children({
    'node_name'   => 'p',
    'class'       => $self->CSS_CLASS_CHECKBOX_WRAPPER,
    'children'    => [{
      'node_name'               => 'inputcheckbox',
      (map {$params->{$_} ? ($_ => $params->{$_}) : ()} qw(id name value class)),
      (map {$params->{$_} ? ($_ => $_)            : ()} qw(checked disabled)),
    }]
  }, {
    'node_name'   => 'div',
    'class'       => $self->CSS_CLASS_TEXT,
    'inner_HTML'  => sprintf(
      q(<p><label for="%s">%s</label></p><div>%s%s</div>),
      $params->{'id'},
      $params->{'label'} eq $logic_name ? $params->{'label'} : "$params->{'label'} ($logic_name)",
      $das->{'description'},
      $das->{'homepage'} ? qq( [<a href="$das->{'homepage'}">Homepage</a>]) : ''),
  });  
}

1;
{'fraction_non_alphanumeric': 0.2706812652068126, 'fraction_numerical': 0.0012165450121654502, 'mean_word_length': 3.829662261380323, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 116, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4931646', 'n_tokens_mistral': 1236, 'n_tokens_neox': 1212, 'n_words': 165}