From 1a8a6a03fc31c3c179008b7116129dc9eaa3f22d Mon Sep 17 00:00:00 2001 From: anteldan <34574269+anteldan@users.noreply.github.com> Date: Mon, 18 Dec 2017 00:36:20 +0100 Subject: [PATCH 1/5] Introducing new menu checkbox to show/hide card short id Removed trailing white spaces on some lines and making a correct commit title. Introducing a new "View" menu and its checkbox item "Show card short id". All trello cards have a "short id" in a span element, which is hidden. CSS class is ".card-short-id hide". Checking/unchecking "Show card short id" will page.insertCSS a new class ".card-short-id.hide" definition "display: inline-flex; padding-right: .3em;" or "display: none;" Checkbox state is saved in config. I never developped with electron, so sorry if page.insertCSS is not the right way and please enhance the code ! --- index.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/index.js b/index.js index ba0fbf0..cb7522d 100644 --- a/index.js +++ b/index.js @@ -12,14 +12,24 @@ require('electron-context-menu')(); let mainWindow; let isQuitting = false; +let showCardShortId = config.get('showCardShortId'); + +function toggleShowCardShortId(page) { + if (!showCardShortId) + page.insertCSS('.card-short-id.hide { display:none; }'); + else + page.insertCSS('.card-short-id.hide { display: inline-flex; padding-right: .3em; }'); +} function createMainWindow() { const lastWindowState = config.get('lastWindowState'); + const lastShowCardShortId = config.get('showCardShortId'); const win = new electron.BrowserWindow({ title: app.getName(), show: false, x: lastWindowState.x, y: lastWindowState.y, + showCardShortId: lastShowCardShortId, width: lastWindowState.width, height: lastWindowState.height, icon: process.platform === 'linux' && path.join(__dirname, 'static', 'Icon.png'), @@ -45,6 +55,7 @@ function createMainWindow() { if (!mainWindow.isFullScreen()) { config.set('lastWindowState', mainWindow.getBounds()); } + config.set('showCardShortId', mainWindow.showCardShortId); } else { e.preventDefault(); @@ -65,6 +76,7 @@ app.on('ready', () => { page.on('dom-ready', () => { page.insertCSS(fs.readFileSync(path.join(__dirname, 'browser.css'), 'utf8')); + toggleShowCardShortId(page); mainWindow.show(); }); @@ -111,6 +123,20 @@ app.on('ready', () => { {label: 'Paste', accelerator: 'CmdOrCtrl+V', selector: 'paste:'}, {label: 'Select All', accelerator: 'CmdOrCtrl+A', selector: 'selectAll:'} ] + } , { + label: 'View', + submenu: [ + {label: 'Show card short id', + type: 'checkbox', + checked: showCardShortId, + click: item => { + showCardShortId = !showCardShortId; + item.checked = showCardShortId; + config.set('showCardShortId', showCardShortId); + toggleShowCardShortId(page); + } + } + ] } ]; @@ -128,3 +154,4 @@ app.on('activate', () => { app.on('before-quit', () => { isQuitting = true; }); + From ac74e7cc5c99499add292e47b83b1b5b7da865cf Mon Sep 17 00:00:00 2001 From: anteldan <34574269+anteldan@users.noreply.github.com> Date: Mon, 18 Dec 2017 00:48:05 +0100 Subject: [PATCH 2/5] Correct indentation --- index.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index cb7522d..347cf96 100644 --- a/index.js +++ b/index.js @@ -15,10 +15,12 @@ let isQuitting = false; let showCardShortId = config.get('showCardShortId'); function toggleShowCardShortId(page) { - if (!showCardShortId) - page.insertCSS('.card-short-id.hide { display:none; }'); - else + if (showCardShortId) { page.insertCSS('.card-short-id.hide { display: inline-flex; padding-right: .3em; }'); + } + else { + page.insertCSS('.card-short-id.hide { display:none; }'); + } } function createMainWindow() { @@ -130,10 +132,10 @@ app.on('ready', () => { type: 'checkbox', checked: showCardShortId, click: item => { - showCardShortId = !showCardShortId; - item.checked = showCardShortId; - config.set('showCardShortId', showCardShortId); - toggleShowCardShortId(page); + showCardShortId = !showCardShortId; + item.checked = showCardShortId; + config.set('showCardShortId', showCardShortId); + toggleShowCardShortId(page); } } ] From e07cfea41aede925dca092c4b3b6d27bcb0a2533 Mon Sep 17 00:00:00 2001 From: anteldan <34574269+anteldan@users.noreply.github.com> Date: Mon, 18 Dec 2017 00:55:59 +0100 Subject: [PATCH 3/5] Correct style for travis build --- index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 347cf96..f9bb45a 100644 --- a/index.js +++ b/index.js @@ -17,8 +17,7 @@ let showCardShortId = config.get('showCardShortId'); function toggleShowCardShortId(page) { if (showCardShortId) { page.insertCSS('.card-short-id.hide { display: inline-flex; padding-right: .3em; }'); - } - else { + } else { page.insertCSS('.card-short-id.hide { display:none; }'); } } @@ -125,7 +124,7 @@ app.on('ready', () => { {label: 'Paste', accelerator: 'CmdOrCtrl+V', selector: 'paste:'}, {label: 'Select All', accelerator: 'CmdOrCtrl+A', selector: 'selectAll:'} ] - } , { + }, { label: 'View', submenu: [ {label: 'Show card short id', From 80b134d3b1fabc1dafa1c60cc1e50592f55ef93b Mon Sep 17 00:00:00 2001 From: anteldan <34574269+anteldan@users.noreply.github.com> Date: Mon, 8 Jan 2018 16:31:30 +0100 Subject: [PATCH 4/5] Add files via upload Merged pull request #31 to add native Electron menu Removed .header-boards-button class definition in order to remove left margin in #header --- browser.css | 6 +----- index.js | 38 ++++++++++++++++++++++++++------------ 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/browser.css b/browser.css index 3d059f0..996aac8 100644 --- a/browser.css +++ b/browser.css @@ -4,10 +4,6 @@ right: 0; } -#header{ +#header { -webkit-app-region: drag; } - -.header-boards-button { - margin-left: 70px; -} diff --git a/index.js b/index.js index f9bb45a..21ed4c1 100644 --- a/index.js +++ b/index.js @@ -37,6 +37,7 @@ function createMainWindow() { minWidth: 400, minHeight: 200, titleBarStyle: 'hidden-inset', + // frame: false, autoHideMenuBar: true, webPreferences: { nodeIntegration: false, @@ -103,17 +104,6 @@ app.on('ready', () => { }); const template = [{ - label: 'Application', - submenu: [ - {label: 'About Application', selector: 'orderFrontStandardAboutPanel:'}, - {type: 'separator'}, - { - label: 'Quit', accelerator: 'Command+Q', click: () => { - app.quit(); - } - } - ] - }, { label: 'Edit', submenu: [ {label: 'Undo', accelerator: 'CmdOrCtrl+Z', selector: 'undo:'}, @@ -138,8 +128,32 @@ app.on('ready', () => { } } ] - } + }, { + label: 'Window', + role: 'window', + submenu: [ + {role: 'minimize'}, + {role: 'zoom'}, + {type: 'separator'}, + {role: 'close'} + ] + } ]; + + if (process.platform === 'darwin') { + template.unshift({ + label: app.getName(), + submenu: [ + {role: 'about'}, + {type: 'separator'}, + {role: 'hide'}, + {role: 'hideothers'}, + {role: 'unhide'}, + {type: 'separator'}, + {role: 'quit'} + ] + }); + } electron.Menu.setApplicationMenu(electron.Menu.buildFromTemplate(template)); }); From 347583e8f1cd2575546a2a044f0605e4294ba21d Mon Sep 17 00:00:00 2001 From: anteldan <34574269+anteldan@users.noreply.github.com> Date: Mon, 8 Jan 2018 16:47:42 +0100 Subject: [PATCH 5/5] Add files via upload --- index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 21ed4c1..571fdcd 100644 --- a/index.js +++ b/index.js @@ -136,12 +136,12 @@ app.on('ready', () => { {role: 'zoom'}, {type: 'separator'}, {role: 'close'} - ] - } + ] + } ]; - - if (process.platform === 'darwin') { - template.unshift({ + + if (process.platform === 'darwin') { + template.unshift({ label: app.getName(), submenu: [ {role: 'about'}, @@ -153,7 +153,7 @@ app.on('ready', () => { {role: 'quit'} ] }); - } + } electron.Menu.setApplicationMenu(electron.Menu.buildFromTemplate(template)); });