From 50bd14537459608fb10b17178eefa126fd69213e Mon Sep 17 00:00:00 2001 From: Des Lownds Date: Thu, 1 Dec 2016 00:19:09 -0700 Subject: [PATCH 1/3] state.active exposed in init and by an event to allow starting in either mode. --- README.md | 16 +++++++++------- src/jerboa.js | 28 ++++++++++++++++------------ 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index d401a49..eca9060 100644 --- a/README.md +++ b/README.md @@ -31,13 +31,14 @@ Use it! ```js jerboa.init({ - data: {}, // Custom data that is included in the annotation object, - points: [], // Pre-populates the page with this array of annotation objects - currentUser: 'John Perkins', // Display name of current user, - currentUserId: '259837', // User's Id - isAdmin: 'false', // true or false, determines auth for changing status and owner of annotations - positioning: 'percent', // Valid values are 'pixel' and 'percent' - strategy: jerboa.strategies.global // Determines what element(s) is chosen to be the container + active: false //Start with feedback toggle engaged, or disengaged + data: {}, // Custom data that is included in the annotation object + points: [], // Pre-populates the page with this array of annotation objects + currentUser: 'John Perkins', // Display name of current user + currentUserId: '259837', // User's Id + isAdmin: 'false', // true or false, determines auth for changing status and owner of annotations + positioning: 'PERCENT', // Valid values are 'PIXEL' and 'PERCENT' + strategy: jerboa.strategies.global // Determines what element(s) is chosen to be the container }); ``` @@ -97,6 +98,7 @@ Listenable events are: * `deleteComment` - Fires when the user deletes a reply comment * `changeOwner` - Fires when the user changes the owner of an annotation * `changeStatus` - Fires when the user changes the status of an annotation +* `active` - Fires when feedback toggle is changed. The value of the event indicates the state. ----- diff --git a/src/jerboa.js b/src/jerboa.js index e6be1f1..5fbcc6d 100644 --- a/src/jerboa.js +++ b/src/jerboa.js @@ -132,26 +132,29 @@ function createToggleButton() { buttonContainer.style.left = left; buttonContainer.style.position = 'fixed'; - buttonDiv.addEventListener('click', event => { - event.preventDefault(); + let matchState=function(){ let feedbackSpots = document.getElementsByClassName('feedback-spot'); - if (buttonDiv.classList.contains('toggle-button-selected')) { - buttonDiv.classList.remove('toggle-button-selected'); - buttonLabel.textContent = 'Feedback Off'; - state.active = false; - Array.prototype.forEach.call(feedbackSpots, (feedbackSpotElement) => { - feedbackSpotElement.classList.add('off'); - }); - } else { + if (state.active) { buttonDiv.classList.add('toggle-button-selected'); buttonLabel.textContent = 'Feedback On'; - state.active = true; Array.prototype.forEach.call(feedbackSpots, (feedbackSpotElement) => { feedbackSpotElement.classList.remove('off'); }); + } else { + buttonDiv.classList.remove('toggle-button-selected'); + buttonLabel.textContent = 'Feedback Off'; + Array.prototype.forEach.call(feedbackSpots, (feedbackSpotElement) => { + feedbackSpotElement.classList.add('off'); + }); } + } + buttonDiv.addEventListener('click', event => { + event.preventDefault(); + state.active = !state.active; + matchState() + emit('active', state.active); }); - + matchState() document.body.appendChild(buttonContainer); } @@ -183,6 +186,7 @@ export default { init(options) { console.log('options', options); options = options || {}; + state.active = options.active || false state.currentStrategy = options.strategy || strategies.global; state.currentPositioning = options.positioning || 'PERCENT'; state.currentUser = options.currentUser; From f9935529b51b7fd958768f663a4f0acb5dbee8ea Mon Sep 17 00:00:00 2001 From: des09 Date: Mon, 5 Dec 2016 12:53:20 -0700 Subject: [PATCH 2/3] Enable experticity repo publishing --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index d9eca55..ced20c2 100644 --- a/package.json +++ b/package.json @@ -52,5 +52,6 @@ "dependencies": { "axios": "^0.15.2", "blueimp-md5": "^2.3.1" - } + }, + "private": true } From c7451c1cf8360413892b73d59bebb6a77d9feade Mon Sep 17 00:00:00 2001 From: des09 Date: Mon, 5 Dec 2016 13:00:32 -0700 Subject: [PATCH 3/3] Add expertcity specific junk gotta work out how to NOT do this. --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index ced20c2..32b1c77 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ }, "homepage": "https://github.com/camman3d/jerboa.js", "devDependencies": { + "exp-publish-node": "^0.1.0", "autoprefixer": "^6.3.7", "babel-core": "^6.10.4", "babel-loader": "^6.2.4",