From f15e53772594a22ae053c0fe955f437529ef4113 Mon Sep 17 00:00:00 2001 From: Rick Pastoor Date: Fri, 18 Sep 2015 23:45:16 +0200 Subject: [PATCH 1/4] Check in initial version of Firefox build --- platform/chromium/manifest.json | 2 +- platform/firefox/index.js | 9 ++++ platform/firefox/package.json | 13 +++++ src/scrummer.js | 84 ++++++++++++++++----------------- tools/make-firefox.sh | 25 ++++++++++ 5 files changed, 90 insertions(+), 43 deletions(-) create mode 100644 platform/firefox/index.js create mode 100644 platform/firefox/package.json create mode 100755 tools/make-firefox.sh diff --git a/platform/chromium/manifest.json b/platform/chromium/manifest.json index da4ab75..4c36205 100644 --- a/platform/chromium/manifest.json +++ b/platform/chromium/manifest.json @@ -1,6 +1,6 @@ { "name": "Scrummer", - "version": "0.10", + "version": "0.11", "description": "Adds Storypoints to Trello", "content_scripts": [ { diff --git a/platform/firefox/index.js b/platform/firefox/index.js new file mode 100644 index 0000000..85263f8 --- /dev/null +++ b/platform/firefox/index.js @@ -0,0 +1,9 @@ +var data = require("sdk/self").data; +var pageMod = require("sdk/page-mod"); + +pageMod.PageMod({ + include: "*.trello.com", + contentScriptFile: data.url("scrummer.js"), + contentStyleFile: data.url("scrummer.css"), + attachTo: ["top"] +}); diff --git a/platform/firefox/package.json b/platform/firefox/package.json new file mode 100644 index 0000000..56ffe78 --- /dev/null +++ b/platform/firefox/package.json @@ -0,0 +1,13 @@ +{ + "title": "Scrummer", + "name": "scrummer", + "version": "0.11.0", + "description": "", + "main": "index.js", + "author": "Rick Pastoor", + "engines": { + "firefox": ">=38.0a1", + "fennec": ">=38.0a1" + }, + "license": "" +} diff --git a/src/scrummer.js b/src/scrummer.js index 36702df..14ef403 100644 --- a/src/scrummer.js +++ b/src/scrummer.js @@ -108,7 +108,7 @@ var calculateStoryPointsForCard = function (card, pointsSinceSeparator) { cardNameElement.insertBefore(badgeElement, cardNameElement.firstChild); } - badgeElement.innerText = calculatedPoints; + badgeElement.textContent = calculatedPoints; cardNameElement.lastChild.textContent = originalTitle.replace('(' + calculatedPoints + ')', '').trim(); @@ -163,7 +163,7 @@ var calculateStoryPointsForList = function (list) { listHeader.insertBefore(badgeElement, listHeader.firstChild); } - badgeElement.innerText = listPoints; + badgeElement.textContent = listPoints; } var calculateStoryPointsForBoard = function () { @@ -183,6 +183,46 @@ var calculateStoryPointsForBoardDebounced = function () { debounce(calculateStoryPointsForBoard, 200, true)(); } +/** + * The point picker + */ +var buildPicker = function (values, callback) { + var itemsContainer = document.createElement('div'); + itemsContainer.className = 'scrummer-picker-container'; + + values.forEach(function (value) { + var button = document.createElement('a'); + button.textContent = value; + button.addEventListener('click', callback.bind(this, value)); + button.href = 'javascript:;'; + button.className = 'scrummer-picker-button'; + itemsContainer.appendChild(button); + }); + + return itemsContainer; +} + +/** + * This sets up a listener to see if a detail window is presented + */ +var setupWindowListener = function (callback) { + var windowChangeObserver = new MutationObserver(function (mutations) { + mutations.forEach(function (mutation) { + if (mutation.target.classList.contains('edit-controls') && + mutation.target.previousSibling.classList.contains('single-line')) { + callback(); + } + }); + }); + + windowChangeObserver.observe(document.querySelector('.window-overlay'), { + childList: true, + characterData: false, + attributes: false, + subtree: true + }); +} + var checkForLists = function () { if (document.querySelectorAll('.list').length > 0) { calculateStoryPointsForBoard(); @@ -222,43 +262,3 @@ var checkForLists = function () { // Launch the plugin by checking at a certain interval if any // lists have been loaded. checkForLists(); - -/** - * The point picker - */ -var buildPicker = function (values, callback) { - var itemsContainer = document.createElement('div'); - itemsContainer.className = 'scrummer-picker-container'; - - values.forEach(function (value) { - var button = document.createElement('a'); - button.innerText = value; - button.addEventListener('click', callback.bind(this, value)); - button.href = 'javascript:;'; - button.className = 'scrummer-picker-button'; - itemsContainer.appendChild(button); - }); - - return itemsContainer; -} - -/** - * This sets up a listener to see if a detail window is presented - */ -var setupWindowListener = function (callback) { - var windowChangeObserver = new MutationObserver(function (mutations) { - mutations.forEach(function (mutation) { - if (mutation.target.classList.contains('edit-controls') && - mutation.target.previousSibling.classList.contains('single-line')) { - callback(); - } - }); - }); - - windowChangeObserver.observe(document.querySelector('.window-overlay'), { - childList: true, - characterData: false, - attributes: false, - subtree: true - }); -} diff --git a/tools/make-firefox.sh b/tools/make-firefox.sh new file mode 100755 index 0000000..2a8f3d3 --- /dev/null +++ b/tools/make-firefox.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# +# This script assumes a linux environment + +echo "*** uMatrix.firefox: Copying files" + +DES=dist/build/scrummer.firefox +rm -rf $DES +mkdir -p $DES +mkdir -p $DES/data + +cp -R src/* $DES/data +cp platform/firefox/index.js $DES/ +cp platform/firefox/package.json $DES/ +cp -R platform/chromium/img $DES/ +mv $DES/img/icon128.png $DES/icon.png + +if [ "$1" = all ]; then + echo "*** scrummer.firefox: Creating package..." + pushd $DES/ + zip ../scrummer.firefox.xpi -qr * + popd +fi + +echo "*** scrummer.firefox: Package done." From 321d66dd23f3a44b98d4d9cc242e1321a347b926 Mon Sep 17 00:00:00 2001 From: Rick Pastoor Date: Sat, 19 Sep 2015 10:33:04 +0200 Subject: [PATCH 2/4] Add Firefox to build matrix --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index e6b0a8a..3432c2d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ sudo: false env: matrix: - BROWSER=chromium EXT=zip + - BROWSER=firefox EXT=xpi script: ./tools/make-${BROWSER}.sh all deploy: provider: releases From c84296c6f674e42421e5c3d34b6bb2b03d23842d Mon Sep 17 00:00:00 2001 From: Rick Pastoor Date: Sat, 19 Sep 2015 10:53:57 +0200 Subject: [PATCH 3/4] Fix hover state and gradient in Firefox --- src/scrummer.css | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/scrummer.css b/src/scrummer.css index 5157df7..8c50c22 100644 --- a/src/scrummer.css +++ b/src/scrummer.css @@ -1,6 +1,9 @@ .scrummer-points, .scrummer-list-points, .scrummer-picker-button { - background-color: #50BBE4; - background-image: -webkit-linear-gradient(bottom, #4CB2D9 50%, #50BBE4 50%); + background: #47bae0; /* Old browsers */ + background: -moz-linear-gradient(top, #47bae0 50%, #4dbbe2 50%, #33b5e0 50%); /* FF3.6+ */ + background: -webkit-gradient(linear, left top, left bottom, color-stop(50%,#47bae0), color-stop(50%,#4dbbe2), color-stop(50%,#33b5e0)); /* Chrome,Safari4+ */ + background: -webkit-linear-gradient(top, #47bae0 50%,#4dbbe2 50%,#33b5e0 50%); /* Chrome10+,Safari5.1+ */ + background: linear-gradient(to bottom, #47bae0 50%,#4dbbe2 50%,#33b5e0 50%); /* W3C */ padding: 1px 5px; margin-right: 3px; border-radius: 5px; @@ -30,8 +33,11 @@ } .scrummer-separator-card { - background-color: #50BBE4; - background-image: -webkit-linear-gradient(bottom, #4CB2D9 50%, #50BBE4 50%); + background: #47bae0; /* Old browsers */ + background: -moz-linear-gradient(top, #47bae0 50%, #4dbbe2 50%, #33b5e0 50%); /* FF3.6+ */ + background: -webkit-gradient(linear, left top, left bottom, color-stop(50%,#47bae0), color-stop(50%,#4dbbe2), color-stop(50%,#33b5e0)); /* Chrome,Safari4+ */ + background: -webkit-linear-gradient(top, #47bae0 50%,#4dbbe2 50%,#33b5e0 50%); /* Chrome10+,Safari5.1+ */ + background: linear-gradient(to bottom, #47bae0 50%,#4dbbe2 50%,#33b5e0 50%); /* W3C */ } .scrummer-separator-card .list-card-title { From e09068426f42464d28494334c24f9d4f47e4d717 Mon Sep 17 00:00:00 2001 From: Rick Pastoor Date: Sat, 19 Sep 2015 10:59:20 +0200 Subject: [PATCH 4/4] Update documentation --- README.md | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bea7fef..369ee4e 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,9 @@ Sketching out your sprints is pretty hard, just like planning in general. I foun Add a new card with the contents `#!!` anywhere in your board. It will count the points that are added to the card above it. You can add multiple separators in a single column: it will always start counting from the separator above. This allows you to prepare your sprints in advance, all within your Trello board. -## Developing and testing +## Developing and testing Chrome -To get started with developing your own additions to this plugin, clone this repo and run this command: +To get started with developing your own additions to this plugin, run this command: ``` tools/make-chromium.sh @@ -34,3 +34,19 @@ tools/make-chromium.sh After this, add a new unpacked extension to your local Google Chrome and point this to the `dist/build/scrummer.chromium` folder. Now make your changes, run `make-chromium` and refresh your plugin in Chrome to see if everything is working as it should. There are no tests yet, because YOLO. + +## Developing and testing Firefox + +To get started with developing your own additions to this plugin, run this command: + +``` +tools/make-firefox.sh +``` + +After this, install JPM: + +``` +npm install jpm --global +``` + +With JPM, you can run the plugin in a debug environment. Change your directory to `dist/build/scrummer.firefox` and run `jpm run`. Now open your Trello board to see if your changes are working as expected. Happy coding!