/*jslint indent: 2 */
/*global $: false, document: false, togglbutton: false*/

'use strict';

togglbutton.render('.timeline-task-popup:not(.toggl)', {observe: true}, function (element) {
  var titleElement = $('[data-hook=input-name]', element),
    projectElement = $('[name=project_name]', element),
    container = $('[data-hook=row-actions]', element),
    link;

  if (titleElement === null || container === null) {
    return;
  }

  link = togglbutton.createTimerLink({
    className: 'teamweek-new',
    buttonType: 'minimal',
    description: titleElement.value,
    projectName: projectElement.value || null
  });

  container.appendChild(link);
});

/*jslint indent: 2 */
/*global $: false, document: false, togglbutton: false*/

'use strict';

togglbutton.render('.timeline-form:not(.toggl)', {observe: true}, function (element) {
  var titleElement = $('[data-hook=input-name]', element),
    projectElement = $('[name=project_name]', element),
    container = $('[data-hook=row-actions]', element),
    link;

  if (titleElement === null || container === null) {
    return;
  }

  link = togglbutton.createTimerLink({
    className: 'teamweek-new',
    buttonType: 'minimal',
    description: titleElement.value,
    projectName: projectElement.value || null
  });

  container.appendChild(link);
});

Update selector for tw closes #1046