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

'use strict';

togglbutton.render('#issue_view:not(.toggl)', {}, function (elem) {
  var
    projectSelect, project, link, container, spanTag,
    issue_id = $('#issue_overview > div.title > a', elem).innerHTML,
    description = $('#issue_overview div#summary div.display', elem).textContent;

  // find the project dropdown
  projectSelect = $('#project_chooser > form > select[name=current_project]', elem);
  // project is current value
  project = projectSelect.options[projectSelect.selectedIndex].text;

  link = togglbutton.createTimerLink({
    className: 'eventum',
    description: '#' + issue_id + ' ' + description,
    projectName: project
  });

  container = $('#issue_overview div.title', elem);
  spanTag = document.createElement("span");
  container.appendChild(spanTag.appendChild(link));
});

@@ -413,16 +413,101 @@
 ropdown%0A
+  // if the dropdown exists, its multiproject%0A  // otherwise take it from text value%0A
   projec
@@ -584,19 +584,16 @@
 elem);%0A 
- //
  project
@@ -597,36 +597,29 @@
 ect 
-is current value%0A  project =
+= projectSelect ?%0A   
  pro
@@ -670,16 +670,86 @@
 ex%5D.text
+ :%0A    $('#project_chooser').textContent.replace(/%5E%5Cs+Project:%5Cs/, '')
 ;%0A%0A  lin

fix project fetching for single-project eventum setups