<commit_before>var m = require('mithril');
var classSet = require('common').classSet;
var bindOnce = require('../util').bindOnce;
var plural = require('../util').plural;
var memberView = require('./studyMembers').view;
var chapterView = require('./studyChapters').view;
var chapterNewFormView = require('./chapterNewForm').view;
var chapterEditFormView = require('./chapterEditForm').view;
var commentFormView = require('./commentForm').view;
var currentCommentsView = require('./studyComments').currentComments;
var glyphFormView = require('./studyGlyph').view;
var inviteFormView = require('./inviteForm').view;
var studyFormView = require('./studyForm').view;
var studyShareView = require('./studyShare').view;
var notifView = require('./notif').view;
var tagsView = require('./studyTags').view;
var practiceView = require('./practice/studyPracticeView');

function buttons(root) {
  var ctrl = root.study;
  var canContribute = ctrl.members.canContribute();
  return m('div.study_buttons', [
    m('div.member_buttons', [
      ctrl.data.features.sticky ? m('a.button.mode.hint--top', {
        'data-hint': 'All sync members remain on the same position',
        class: classSet({on: ctrl.vm.mode.sticky }),
        onclick: ctrl.toggleSticky
      }, [ m('i.is'), 'Sync']) : null,
      ctrl.members.canContribute() ? m('a.button.mode.hint--top', {
        'data-hint': 'Write changes to the server',
        class: classSet({on: ctrl.vm.mode.write }),
        onclick: ctrl.toggleWrite
      }, [ m('i.is'), 'Record']) : null,
      m('a.button.share.hint--top', {
        class: classSet({
          active: ctrl.share.open()
        }),
        'data-hint': 'Share & export',
        config: bindOnce('click', ctrl.share.toggle)
      },
      m('i.[data-icon=z]')),
      canContribute ? [
        m('a.button.comment.hint--top', {
          class: classSet({
            active: ctrl.commentForm.current(),
            disabled: !ctrl.vm.mode.write
          }),
          'data-hint': 'Comment this position',
          config: bindOnce('click', function() {
            if (ctrl.vm.mode.write) ctrl.commentForm.toggle(ctrl.currentChapter().id, root.vm.path, root.vm.node);
          })
        }, m('i[data-icon=c]')),
        m('a.button.glyph.hint--top', {
          class: classSet({
            active: ctrl.glyphForm.isOpen(),
            disabled: !(root.vm.path && ctrl.vm.write)
          }),
          'data-hint': 'Annotate with symbols',
          config: bindOnce('click', function() {
            if (root.vm.path && ctrl.vm.mode.write) ctrl.glyphForm.toggle();
          })
        },
        m('i.glyph-icon'))
      ] : null
    ]),
    m('span.button.help.hint--top', {
      'data-hint': 'Need help? Get the tour!',
      onclick: ctrl.startTour
    }, m('i.text', {
      'data-icon': ''
    }, 'help'))<commit_msg>fix study button state<commit_after>var m = require('mithril');
var classSet = require('common').classSet;
var bindOnce = require('../util').bindOnce;
var plural = require('../util').plural;
var memberView = require('./studyMembers').view;
var chapterView = require('./studyChapters').view;
var chapterNewFormView = require('./chapterNewForm').view;
var chapterEditFormView = require('./chapterEditForm').view;
var commentFormView = require('./commentForm').view;
var currentCommentsView = require('./studyComments').currentComments;
var glyphFormView = require('./studyGlyph').view;
var inviteFormView = require('./inviteForm').view;
var studyFormView = require('./studyForm').view;
var studyShareView = require('./studyShare').view;
var notifView = require('./notif').view;
var tagsView = require('./studyTags').view;
var practiceView = require('./practice/studyPracticeView');

function buttons(root) {
  var ctrl = root.study;
  var canContribute = ctrl.members.canContribute();
  return m('div.study_buttons', [
    m('div.member_buttons', [
      ctrl.data.features.sticky ? m('a.button.mode.hint--top', {
        'data-hint': 'All sync members remain on the same position',
        class: classSet({on: ctrl.vm.mode.sticky }),
        onclick: ctrl.toggleSticky
      }, [ m('i.is'), 'Sync']) : null,
      ctrl.members.canContribute() ? m('a.button.mode.hint--top', {
        'data-hint': 'Write changes to the server',
        class: classSet({on: ctrl.vm.mode.write }),
        onclick: ctrl.toggleWrite
      }, [ m('i.is'), 'Record']) : null,
      m('a.button.share.hint--top', {
        class: classSet({
          active: ctrl.share.open()
        }),
        'data-hint': 'Share & export',
        config: bindOnce('click', ctrl.share.toggle)
      },
      m('i.[data-icon=z]')),
      canContribute ? [
        m('a.button.comment.hint--top', {
          class: classSet({
            active: ctrl.commentForm.current(),
            disabled: !ctrl.vm.mode.write
          }),
          'data-hint': 'Comment this position',
          config: bindOnce('click', function() {
            if (ctrl.vm.mode.write) ctrl.commentForm.toggle(ctrl.currentChapter().id, root.vm.path, root.vm.node);
          })
        }, m('i[data-icon=c]')),
        m('a.button.glyph.hint--top', {
          class: classSet({
            active: ctrl.glyphForm.isOpen(),
            disabled: !(root.vm.path && ctrl.vm.mode.write)
          }),
          'data-hint': 'Annotate with symbols',
          config: bindOnce('click', function() {
            if (root.vm.path && ctrl.vm.mode.write) ctrl.glyphForm.toggle();
          })
        },
        m('i.glyph-icon'))
      ] : null
    ]),
    m('span.button.help.hint--top', {
      'data-hint': 'Need help? Get the tour!',
      onclick: ctrl.startTour
    }, m('i.text', {
      'data-icon': ''
    }, 'help'))
{'fraction_non_alphanumeric': 0.18266199649737302, 'fraction_numerical': 0.0, 'mean_word_length': 2.7060350421804023, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4492647', 'n_tokens_mistral': 1774, 'n_tokens_neox': 1729, 'n_words': 330}