diff --git a/.gitignore b/.gitignore index 4c8461e..df4c6ae 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ node_modules tmp *.pem toggl-button.zip +toggl-button.sublime-project +toggl-button.sublime-workspace diff --git a/src/manifest.json b/src/manifest.json index 6395c02..1375faa 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -50,7 +50,9 @@ "*://trac-hacks.org/*", "*://*.trac.wordpress.org/*", "*://bugs.jquery.com/*", - "*://*.wunderlist.com/*" + "*://*.wunderlist.com/*", + "*://*.teamwork.com/*", + "*://*.teamworkpm.net/*" ], "icons": { "16": "images/icon-16.png", @@ -89,7 +91,9 @@ "*://*.trac.wordpress.org/*", "*://bugs.jquery.com/*", "*://*.wunderlist.com/*", - "*://*.toodledo.com/*" + "*://*.toodledo.com/*", + "*://*.teamwork.com/*", + "*://*.teamworkpm.net/*" ], "css": ["styles/style.css"], "js": ["scripts/common.js"] @@ -198,6 +202,13 @@ "matches": ["https://*.todoist.com/app*"], "js": ["scripts/content/todoist.js"] }, + { + "matches": [ + "*://*.teamwork.com/*", + "*://*.teamworkpm.net/*" + ], + "js": ["scripts/content/teamworkpm.js"] + }, { "matches": [ "*://trac.edgewall.org/*", diff --git a/src/scripts/content/teamworkpm.js b/src/scripts/content/teamworkpm.js new file mode 100644 index 0000000..563f332 --- /dev/null +++ b/src/scripts/content/teamworkpm.js @@ -0,0 +1,47 @@ +/*jslint indent: 2 */ +/*global $: false, document: false, togglbutton: false, createTag:false*/ + +'use strict'; + +console.log("Load Toggl for Teamwork"); + +togglbutton.render('div.taskRHS:not(.toggl)', {observe: true}, function (elem) { + var link, className = 'huh', container = $('.taskUsedOps', elem), spanTag; + + if (container === null) { + return; + } + + if( $('.taskName', elem) === null ) { + return; + } + var desc = $('.taskName', elem).textContent; + + link = togglbutton.createTimerLink({ + className: 'teamworkpm', + description: desc, + projectName: $("#projectName").innerHTML + }); + + link.classList.add( className ); + + link.addEventListener('click', function (e) { + + // Run through and hide all others + var i, len, elems = document.querySelectorAll(".toggl-button"); + for (i = 0, len = elems.length; i < len; i += 1) { + elems[i].classList.add('huh'); + } + + if (link.classList.contains( className ) ) { + link.classList.remove( className ); + } else { + link.classList.add( className ); + } + }); + + spanTag = document.createElement("span"); + link.style.width = 'auto'; + spanTag.appendChild(link); + container.insertBefore( spanTag, container.firstChild); +}); diff --git a/src/styles/style.css b/src/styles/style.css index 8df18f6..c3375cf 100644 --- a/src/styles/style.css +++ b/src/styles/style.css @@ -565,4 +565,15 @@ only screen and (min-resolution: 192dpi) { #toggl-button-edit-form .toggl-button.toodledo { position: static; +} + +/********* TEAMWORKPM *********/ +.toggl-button.huh.active { + visibility:visible; + opacity: 1; +} + +.taskUsedOps span a.toggl-button { + background-size:contain; + font-weight: normal; } \ No newline at end of file