Skip to content

Commit

Permalink
updated script to check if on/off, updated browser icon to have off s…
Browse files Browse the repository at this point in the history
…tate when sidekick is disabled
  • Loading branch information
spindle79 committed Nov 5, 2019
1 parent 64c16fd commit 438afbd
Show file tree
Hide file tree
Showing 12 changed files with 388 additions and 14 deletions.
333 changes: 333 additions & 0 deletions assets/contentful-logo-off.ai

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"eslint-config-airbnb-base": "^13.1.0",
"eslint-loader": "^2.1.1",
"eslint-plugin-import": "^2.14.0",
"jquery": "^3.3.1",
"lodash": "^4.17.11",
"jquery": "^3.4.1",
"lodash": "^4.17.15",
"webpack": "^4.28.4",
"webpack-merge": "^4.2.1"
},
Expand Down
2 changes: 1 addition & 1 deletion src/chrome/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Contentful Sidekick",
"short_name": "Contentful Sidekick",
"description": "Chrome Extension that enables inline editing for websites created in Contentful",
"version": "0.0.8",
"version": "0.0.9",
"permissions": [
"activeTab",
"cookies",
Expand Down
Binary file added src/shared/img/icon128Off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/shared/img/icon16Off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/shared/img/icon256Off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/shared/img/icon32Off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/shared/img/icon48Off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/shared/img/icon64Off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 36 additions & 1 deletion src/shared/js/background.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,51 @@
/* global chrome */
// Called when the user clicks on the browser action

const setExtensionIcon = (curEnabled = false) => {
if (curEnabled) {
chrome.browserAction.setIcon({
path: {
16: '../img/icon16.png',
32: '../img/icon32.png',
48: '../img/icon48.png',
64: '../img/icon64.png',
128: '../img/icon128.png',
256: '../img/icon256.png',
},
});
} else {
chrome.browserAction.setIcon({
path: {
16: '../img/icon16Off.png',
32: '../img/icon32Off.png',
48: '../img/icon48Off.png',
64: '../img/icon64Off.png',
128: '../img/icon128Off.png',
256: '../img/icon256Off.png',
},
});
}
};

const toggleActive = () => {
chrome.storage.sync.get({
sideKickEnabled: false,
}, (items) => {
const curEnabled = !items.sideKickEnabled;
chrome.storage.sync.set({ sideKickEnabled: curEnabled });
setExtensionIcon(curEnabled);
});
};

chrome.tabs.onUpdated.addListener(() => {
chrome.storage.sync.get({
sideKickEnabled: false,
}, (items) => {
setExtensionIcon(items.sideKickEnabled);
});
});


chrome.browserAction.onClicked.addListener((tab) => {
chrome.browserAction.onClicked.addListener(() => {
toggleActive();
});
14 changes: 10 additions & 4 deletions src/shared/js/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,16 @@ const init = () => {
.on('mouseenter', () => { $('#csk-overlay').addClass('show'); })
.on('mouseleave', () => { $('#csk-overlay').removeClass('show'); });

$('body').attr('data-init-csk', true);
if (!$('#csk-overlay').length) {
$('body').append($('<div>').attr('id', 'csk-overlay'));
}
chrome.storage.sync.get({
sideKickEnabled: false,
}, (items) => {
if (items.sideKickEnabled) {
$('body').attr('data-init-csk', true);
if (!$('#csk-overlay').length) {
$('body').append($('<div>').attr('id', 'csk-overlay'));
}
}
});
};

$(() => {
Expand Down

0 comments on commit 438afbd

Please sign in to comment.