Skip to content

Commit

Permalink
Teamwork.com support initially added
Browse files Browse the repository at this point in the history
  • Loading branch information
CFDan committed Dec 2, 2014
1 parent 0f94c30 commit 3231f77
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ node_modules
tmp
*.pem
toggl-button.zip
toggl-button.sublime-project
toggl-button.sublime-workspace
15 changes: 13 additions & 2 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"]
Expand Down Expand Up @@ -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/*",
Expand Down
47 changes: 47 additions & 0 deletions src/scripts/content/teamworkpm.js
Original file line number Diff line number Diff line change
@@ -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);
});
11 changes: 11 additions & 0 deletions src/styles/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 3231f77

Please sign in to comment.