<commit_before>part of modal_dialog.dialog.template;

typedef void _Callback(ModalDialog dialog);

/// Modal dialog.
class ModalDialog {
  /// Dialog title
  final String title;

  /// Dialog message
  final String message;

  ModalWindow _modalWindow;
  ModalBlock _footer;

  /// Creates a modal dialog with a [title] and a [message].
  ///
  /// Example:
  ///
  ///     final dialog = new ModalDialog(
  ///       'Please confirm',
  ///       'Do you want to remove the record?'
  ///     );
  ///     dialog.addButton('Accept').on(
  ///       'click', () => print('Deleting record...')
  ///     );
  ///     dialog.addButton('Cancel');
  ///
  ModalDialog(this.title, this.message) {
    _modalWindow = new ModalWindow();
    _modalWindow.add(new ModalBlock('header')..text = title);
    _modalWindow.add(new ModalBlock('body')..text = message);
    _modalWindow.add(_footer = new ModalBlock('footer'));
  }

  /// Modal window instance.
  ModalWindow get modalWindow => _modalWindow;

  /// Adds a button with a [label].
  ///
  /// When the user presses the button, it calls the [action] function.
  DomElement addButton(String label, [_Callback action]) {
    final btn = $('<button type="button" />')
      ..text = label
      ..addTo(_footer.element);

    if (action != null) {
      btn..on('click', () => Function.apply(action, [this]));
    }

    return btn;
  }

  /// Closes the modal dialog.
  void close() {
    final modalWindow = new ModalWindow();
    modalWindow.close();
  }
}<commit_msg>recode<commit_after>part of modal_dialog.dialog.template;

typedef void _Callback(ModalDialog dialog);

/// Modal dialog.
class ModalDialog {
  /// Dialog title
  final String title;

  /// Dialog message
  final String message;

  ModalWindow _modalWindow;
  ModalBlock _footer;

  /// Creates a modal dialog with a [title] and a [message].
  ///
  /// Example:
  ///
  ///     final dialog = new ModalDialog(
  ///       'Please confirm',
  ///       'Do you want to remove the record?'
  ///     );
  ///     dialog.addButton('Accept').on(
  ///       'click', () => print('Deleting record...')
  ///     );
  ///     dialog.addButton('Cancel');
  ///
  ModalDialog(this.title, this.message) {
    _modalWindow = new ModalWindow();
    _modalWindow.add(new ModalBlock('header')..text = title);
    _modalWindow.add(new ModalBlock('body')..text = message);
    _modalWindow.add(_footer = new ModalBlock('footer'));
  }

  /// Modal window instance.
  ModalWindow get modalWindow => _modalWindow;

  /// Adds a button with a [label].
  ///
  /// When the user presses the button, it calls the [action] function.
  DomElement addButton(String label, [_Callback action]) {
    final btn = $('<button type="button" />')
      ..text = label
      ..addTo(_footer.element);

    if (action != null) {
      btn..on('click', () => Function.apply(action, [this]));
    }

    return btn;
  }

  /// Closes the modal dialog.
  void close() => _modalWindow.close();
}
{'fraction_non_alphanumeric': 0.16196236559139784, 'fraction_numerical': 0.0, 'mean_word_length': 2.4900351699882766, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, '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': '2540632', 'n_tokens_mistral': 927, 'n_tokens_neox': 893, 'n_words': 242}