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

Commit

Permalink
Simple nw init script
Browse files Browse the repository at this point in the history
see #96
  • Loading branch information
hypery2k committed Nov 18, 2015
1 parent 54c7696 commit 0518f13
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@

<!-- build:js({.tmp,src}) scripts/app.js -->
<script src="scripts/app.js"></script>
<script src="scripts/nw.js"></script>
<!-- endbuild -->

<!-- build:js({.tmp,src}) scripts/controllers.js -->
Expand Down
4 changes: 2 additions & 2 deletions app/src/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "flynn",
"name": "Flynn Book Scanner",
"version": "1.6.2",
"main": "index.html",
"window": {
"toolbar": false,
"frame": true
}
}
}
7 changes: 6 additions & 1 deletion app/src/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ ngFlynnApp.showErrorDialog = function ($rootScope, $scope, $ionicLoading, log, e
'use strict';

$ionicLoading.show();
navigator.notification.alert(errorCode + '\n' + errorDetails, ngFlynnApp.errorDialogClosed($rootScope, $scope, log), 'Error - ' + errorTitle);
if(navigator.notification){
navigator.notification.alert(errorCode + '\n' + errorDetails, ngFlynnApp.errorDialogClosed($rootScope, $scope, log), 'Error - ' + errorTitle);
} else {
window.alert(errorCode + '\n' + errorDetails);
ngFlynnApp.errorDialogClosed($rootScope, $scope, log);
}
$ionicLoading.hide();
};

Expand Down
25 changes: 25 additions & 0 deletions app/src/scripts/nw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var gui = require('nw.gui');
var ngFlynnApp = ngFlynnApp || {};// jshint ignore:line
var global = global || {};// jshint ignore:line

// new nw namespace
ngFlynnApp.nw = {};

ngFlynnApp.nw.init = function () {

var win = global.gui.Window.get();
// init defult mac menu
if (process.platform === "darwin") {
var mb = new gui.Menu({type: 'menubar'});
mb.createMacBuiltin('My App');
gui.Window.get().menu = mb;
}
};

// only run if nw is detected
if (gui) {
global.window = window;
global.gui = gui;
console.log('Running in nw.js');
ngFlynnApp.nw.init();
}

0 comments on commit 0518f13

Please sign in to comment.