Skip to content
This repository has been archived by the owner on Apr 21, 2021. It is now read-only.

Commit

Permalink
basic touchbar support
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-sap committed Mar 9, 2017
1 parent 13f08d4 commit 4c825ad
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 9 deletions.
3 changes: 3 additions & 0 deletions app/addressbar/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ header.error .addressbar { padding-right: 40px; }
.star-box.is-starred .js-star { display: none; }
.star-box.is-starred .js-unstar { display: inline; }


input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
5 changes: 5 additions & 0 deletions app/addressbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ function focusAddressbar () {
setTimeout(() => { el[0].select(); }, 10);
}

function focusIssuebox () {
setTimeout(() => { issueBox[0].select(); }, 10);
}



function onFocus () {
Expand Down Expand Up @@ -151,6 +155,7 @@ function init () {
$.on(EVENT.url.change.to, gotoUrl);
$.on(EVENT.url.change.done, onUrlChanged);
$.on(EVENT.address.focus, focusAddressbar);
$.on(EVENT.address.issueFocus, focusIssuebox);

isReady = true;
}
Expand Down
1 change: 1 addition & 0 deletions app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const components = [
'contextmenu',
'projects',
'updater',
'touchbar',
];

components.forEach(init);
Expand Down
6 changes: 4 additions & 2 deletions app/db/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ module.exports = {
key: 'address-input',
end: 'address-input-end'
},
focus: 'focus-address'
focus: 'focus-address',
issueFocus: 'focus-issue-box',
},
bookmark: {
add: 'add-bookmark',
Expand Down Expand Up @@ -38,7 +39,8 @@ module.exports = {
notifications: {
toggle: 'notifications-toggle',
devtools: 'notification-devtools-toggle',
count: 'notifications-count-updated'
count: 'notifications-count-updated',
refresh: 'refresh-notifications'
},
contextmenu: {
show: 'show-contextmenu',
Expand Down
1 change: 1 addition & 0 deletions app/notifications/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ function init () {

el.on('click', onClick);

$.on(EVENT.notifications.refresh, refresh);
$.on(EVENT.notifications.toggle, toggle);
$.on(EVENT.notifications.devtools, toggleDevTools);
$.on(EVENT.settings.changed, () => refresh(true));
Expand Down
66 changes: 66 additions & 0 deletions app/touchbar/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
const {TouchBar, getCurrentWindow} = require('electron').remote;
const {TouchBarLabel, TouchBarButton, TouchBarSpacer} = TouchBar;

const $ = require('../util');
const EVENT = require('../db/events');

function initBar () {
const btnBack = new TouchBarButton({
label: '←',
click: () => $.trigger(EVENT.frame.goto, 'prev')
});
const btnForward = new TouchBarButton({
label: '→',
click: () => $.trigger(EVENT.frame.goto, 'next')
});
const btnRefresh = new TouchBarButton({
label: '↻',
click: () => $.trigger(EVENT.frame.goto, 'refresh')
});

const btnBookmark = new TouchBarButton({
label: '☆',
click: () => {}
});

const btnAddressbar = new TouchBarButton({
label: 'Search or type url ', // these are nbsp chars
click: () => $.trigger(EVENT.address.focus)
});

const btnIssueNo = new TouchBarButton({
label: 'Issue #',
click: () => $.trigger(EVENT.address.issueFocus)
});

const btnRefreshNotifications = new TouchBarButton({
label: '↻',
backgroundColor: '#2C384D',
click: () => $.trigger(EVENT.notifications.refresh)
});

return new TouchBar([
btnBack,
btnForward,
btnRefresh,
btnAddressbar,
btnIssueNo,
btnBookmark,

// new TouchBarSpacer({ size: 'small' }),
btnRefreshNotifications,
]);
}



function init () {
const touchBar = initBar();
getCurrentWindow().setTouchBar(touchBar);
}



module.exports = {
init
};
4 changes: 2 additions & 2 deletions app/updater/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const events = {
'update-available': updateAvailable,
'update-not-available': updateNotAvailable,
'error': () => dialog.error('There was an error with the upload.\nPlease try again later.'),
'download-progress': log('Downloading update...'),
'download-progress': () => log('Downloading update...'),
'update-downloaded': updateDownloaded,
};

Expand Down Expand Up @@ -67,7 +67,7 @@ function init () {
if (typeof events[name] === 'function') events[name](params);
});
$.on(EVENT.updater.check, checkForUpdates);
setTimeout(() => checkForUpdates(true), 5000);
if (!isDev) setTimeout(() => checkForUpdates(true), 5000);
}


Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ <h1>Projects</h1>
</div>

<input class="addr-input addressbar" autofocus tabindex="1" />
<input class="addr-input issue-id-bar" autocomplete="on" tabindex="3" />
<input class="addr-input issue-id-bar" autocomplete="on" tabindex="3" type="number" />

<i class="header-btn js-sync ion-ios-nuclear"></i>
<i class="header-btn js-error ion-ios-alert-outline" title="Cannot connect to github. Check your network."></i>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"tingodb": "^0.5.1"
},
"devDependencies": {
"electron": "^1.6.1",
"electron": "beta",
"electron-builder": "^15.1.1",
"electron-packager": "^8.3.0"
}
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -599,9 +599,9 @@ electron-window-state@^4.0.1:
jsonfile "^2.2.3"
mkdirp "^0.5.1"

electron@^1.6.1:
version "1.6.2"
resolved "https://registry.yarnpkg.com/electron/-/electron-1.6.2.tgz#b0ccd7703f86d09c4d2a7273455c3f993f158994"
electron@beta:
version "1.6.3"
resolved "https://registry.yarnpkg.com/electron/-/electron-1.6.3.tgz#95fc62899e50838563fa768baa2011ea860d04b1"
dependencies:
electron-download "^3.0.1"
extract-zip "^1.0.3"
Expand Down

0 comments on commit 4c825ad

Please sign in to comment.