diff --git a/.gitignore b/.gitignore
index ade14b9..46d280f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
.DS_Store
+.jshintrc
npm-debug.log
node_modules
diff --git a/.jshintrc b/.jshintrc
deleted file mode 100644
index eb362af..0000000
--- a/.jshintrc
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "globals" : {
- "describe" : false,
- "it" : false,
- "before" : false,
- "beforeEach" : false,
- "after" : false,
- "afterEach" : false
- },
- "camelcase": true,
- "curly": true,
- "eqeqeq": true,
- "freeze": true,
- "indent": 2,
- "latedef": true,
- "laxcomma": true,
- "node": true,
- "trailing": true,
- "strict": true,
- "unused": "vars",
- "undef": true
-}
diff --git a/README.md b/README.md
index e0db1ba..855d9c5 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# Touch Bar Utility
- Beware This package only works with Atom Beta v1.19
+ Beware This package only works with Atom >=v1.19
An Atom package that allows you to assign custom actions to Touch Bar components.
@@ -10,7 +10,7 @@ An Atom package that allows you to assign custom actions to Touch Bar components
1. Go to File → Settings → Packages
2. Find touch-bar-utility and click on the card **but not on the name of the package**
3. Go to Settings and edit the Buttons entry with a JSON array of Touch Bar components
- * A component has the following format: {type: \[, ...\]}
+ * A component has the following format: {"type": "<typeOfElement>"\[, ...\]}
## Touch Bar Components
@@ -22,7 +22,7 @@ An Atom package that allows you to assign custom actions to Touch Bar components
pathOfIcon | **String** | _Yes_ | Path to button icon.
iconPosition | **String** | _No_ | Can be left, right or overlay.
click | **Function** | _Yes_ | Function to call when the button is clicked.
- clickDispatchAction | **String** | _Yes_ | Event from another package that you want to execute when button is clicked. It will override the click property. It must be in the following format: ":" without quotation marks.
+ clickDispatchAction | **String** | _Yes_ | Event from another package that you want to execute when button is clicked. It will override the click property. It must be in the following format: "<package-name>:<event-name>" without quotation marks.
dispatchActionTarget | **String** | _Yes_ | Can have a value of 'workspace' or 'editor'. It defaults to 'workspace'.
### TouchBarColorPicker (type: "color-picker")
@@ -46,8 +46,8 @@ An Atom package that allows you to assign custom actions to Touch Bar components
Name of variable | Type of variable | Optional | Description
-----------------|---------------------------|----------|--------------------------------------------------------------------------------------------------
label | **String** | _Yes_ | Popover button text.
-
-
+ pathOfIcon | **String** | _Yes_ | Popover button icon.
+ items | **Array of elements** | _Yes_ | Items to display in the popover.
showCloseButton | **Boolean** | _Yes_ | true to display a close button on the left of the popover, false to not show it. Default is true.
### TouchBarSlider (type: "slider")
diff --git a/TODO.md b/TODO.md
index bbe67fb..740cc7a 100644
--- a/TODO.md
+++ b/TODO.md
@@ -1,3 +1,2 @@
## TODO
-* Add Touch Bar screenshot with sample configuration
* Add TouchBarScrubber and TouchBarSegmentedControl to the list of supported Touch Bar elements
diff --git a/lib/touch-bar-utility.js b/lib/touch-bar-utility.js
index 958fa84..18025f6 100644
--- a/lib/touch-bar-utility.js
+++ b/lib/touch-bar-utility.js
@@ -132,7 +132,7 @@ function configureButtons(configString, callback) {
} = TouchBar
try {
- let itemsConfig = JSON.parse(configString);
+ let itemsConfig = (typeof configString==='string')?JSON.parse(configString):configString;
let items = [];
itemsConfig.forEach(function(element) {
@@ -190,7 +190,7 @@ function configureButtons(configString, callback) {
break;
case 'group':
- if (!element.items || typeof element.items !== 'object' || element.items.name != 'TouchBar')
+ if (!element.items || typeof element.items !== 'object' || !Array.isArray(element.items))
return callback(new Error("The touch-bar-group's items must be an array of elements"));
configureButtons(element.items, function(err, items) {
@@ -223,7 +223,7 @@ function configureButtons(configString, callback) {
return callback(new Error("The popover's label must be a string"));
if (element.pathOfIcon && typeof element.pathOfIcon !== 'string')
return callback(new Error("The popover's pathOfIcon must be a a string path pointing to PNG or JPEG file"));
- if (element.items && (typeof element.items !== 'object' || element.items.name != 'TouchBar'))
+ if (element.items && (typeof element.items !== 'object' || !Array.isArray(element.items)))
return callback(new Error("The popover's items must be an array of elements"));
if (element.showCloseButton && typeof element.showCloseButton !== 'boolean')
return callback(new Error("The popover's showCloseButton must be a boolean"));