From 7351c61664bf6407e147577ec44422f078bd0511 Mon Sep 17 00:00:00 2001 From: Bogdan Begovic Date: Tue, 22 Mar 2016 18:09:21 +0100 Subject: [PATCH 1/2] Added option for maximization of main window ( #133 ) --- app/src/components/mainWindow/mainWindow.js | 7 +++++++ docs/api.md | 10 ++++++++++ src/build/buildApp.js | 3 ++- src/cli.js | 1 + src/options/optionsMain.js | 3 ++- 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/src/components/mainWindow/mainWindow.js b/app/src/components/mainWindow/mainWindow.js index 6ac236c..0c5c30f 100644 --- a/app/src/components/mainWindow/mainWindow.js +++ b/app/src/components/mainWindow/mainWindow.js @@ -52,6 +52,13 @@ function createMainWindow(options, onAppQuit, setDockBadge) { fs.writeFileSync(path.join(__dirname, '..', 'nativefier.json'), JSON.stringify(options)); } + // after first run, no longer force maximize to be true + if(options.maximize){ + mainWindow.maximize(); + options.maximize = undefined; + fs.writeFileSync(path.join(__dirname, '..', 'nativefier.json'), JSON.stringify(options)); + } + let currentZoom = 1; const onZoomIn = () => { diff --git a/docs/api.md b/docs/api.md index 88837ac..f286ed4 100644 --- a/docs/api.md +++ b/docs/api.md @@ -25,6 +25,7 @@ - [[flash]](#flash) - [[inject]](#inject) - [[full-screen]](#full-screen) + - [[maximize]](#maximize) - [Programmatic API](#programmatic-api) ## Command Line @@ -226,6 +227,15 @@ $ nativefier http://google.com --inject ./some-js-injection.js --inject ./some-c Makes the packaged app start in full screen. + +#### [maximize] + +``` +--maximize +``` + +Makes the packaged app start maximized. + ## Programmatic API You can use the Nativefier programmatic API as well. diff --git a/src/build/buildApp.js b/src/build/buildApp.js index db9d2f9..afc7872 100644 --- a/src/build/buildApp.js +++ b/src/build/buildApp.js @@ -105,7 +105,8 @@ function selectAppArgs(options) { ignoreCertificate: options.ignoreCertificate, insecure: options.insecure, flashPluginDir: options.flashPluginDir, - fullScreen: options.fullScreen + fullScreen: options.fullScreen, + maximize: options.maximize }; } diff --git a/src/cli.js b/src/cli.js index 1069e4d..7c1fb0a 100755 --- a/src/cli.js +++ b/src/cli.js @@ -39,6 +39,7 @@ if (require.main === module) { .option('--flash ', 'path to Chrome flash plugin, find it in `Chrome://plugins`') .option('--inject ', 'path to a file to be injected', collect, []) .option('--full-screen', 'if the app should always be started in full screen') + .option('--maximize', 'if the app should always be started maximized') .parse(process.argv); if (!process.argv.slice(2).length) { diff --git a/src/options/optionsMain.js b/src/options/optionsMain.js index 554fe73..351ab58 100644 --- a/src/options/optionsMain.js +++ b/src/options/optionsMain.js @@ -50,7 +50,8 @@ function optionsFactory(inpOptions, callback) { insecure: inpOptions.insecure || false, flashPluginDir: inpOptions.flash || null, inject: inpOptions.inject || null, - fullScreen: inpOptions.fullScreen || false + fullScreen: inpOptions.fullScreen || false, + maximize: inpOptions.maximize || false }; if (inpOptions.honest) { From 39e2459aad4cb454bcf0f07eb607e8aa29a95c23 Mon Sep 17 00:00:00 2001 From: Bogdan Begovic Date: Tue, 22 Mar 2016 18:16:34 +0100 Subject: [PATCH 2/2] Added option for maximization of main window ( #133 ) - Fixed linting errors --- app/src/components/mainWindow/mainWindow.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/components/mainWindow/mainWindow.js b/app/src/components/mainWindow/mainWindow.js index 0c5c30f..00590c9 100644 --- a/app/src/components/mainWindow/mainWindow.js +++ b/app/src/components/mainWindow/mainWindow.js @@ -53,7 +53,7 @@ function createMainWindow(options, onAppQuit, setDockBadge) { } // after first run, no longer force maximize to be true - if(options.maximize){ + if (options.maximize) { mainWindow.maximize(); options.maximize = undefined; fs.writeFileSync(path.join(__dirname, '..', 'nativefier.json'), JSON.stringify(options));