'use strict';

togglbutton.render('#task-detail-view:not(.toggl)', { observe: true }, function (
  elem
) {
  const project = $('#project-setting input', elem).getAttribute('value');

  const text = function () {
    return $('.task-title', elem).textContent;
  };

  const link = togglbutton.createTimerLink({
    className: 'TickTick',
    description: text,
    projectName: project
  });

  $('#tasktitle').appendChild(link);
});

'use strict';

togglbutton.render('#task-detail-view:not(.toggl)', { observe: true }, function renderTickTick (elem) {
  function getProject () {
    const projectEl = elem.querySelector('.project-setting input');
    return projectEl ? projectEl.value.trim() : '';
  }

  function getDescription () {
    const descriptionEl = elem.querySelector('#tasktitle div[contenteditable]');
    return descriptionEl ? descriptionEl.textContent.trim() : '';
  }

  const button = togglbutton.createTimerLink({
    className: 'TickTick',
    description: getDescription,
    projectName: getProject
  });
  button.style.marginBottom = '15px';

  const root = elem.querySelector('#td-caption');
  if (root) {
    root.insertBefore(button, root.firstChild);
  }
});

Add support for new TickTick UI
fix(tick-tick): Add support for new TickTick UI

Closes #1514
