| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- (function () {
- 'use strict';
- angular.module('ariaNg').factory('ariaNgNativeElectronService', [function () {
- var electron = angular.isFunction(window.nodeRequire) ? nodeRequire('electron') : {};
- var remote = electron.remote || {
- getGlobal: function () {
- return {};
- },
- getCurrentWindow: function () {
- return {};
- }
- };
- var shell = electron.shell || {
- openExternal: function () {
- return false;
- }
- };
- return {
- remote: remote,
- shell: shell,
- getSettings: function () {
- return remote.getGlobal('settings');
- },
- getRuntimeEnvironment: function () {
- if (!remote.process || !remote.process.versions) {
- return null;
- }
- var versions = remote.process.versions;
- var items = [];
- items.push({name: 'Electron', value: versions.electron});
- items.push({name: 'Node.js', value: versions.node});
- items.push({name: 'Chrome', value: versions.chrome});
- items.push({name: 'V8', value: versions.v8});
- return items;
- },
- version: function() {
- return this.getSettings().version;
- },
- ariaNgVersion: function() {
- return this.getSettings().ariaNgVersion;
- },
- isDevMode: function () {
- return !!this.getSettings().isDevMode;
- },
- useCustomAppTitle: function () {
- return !!this.getSettings().useCustomAppTitle;
- },
- getCurrentWindow: function () {
- return remote.getCurrentWindow();
- },
- openExternalLink: function (url) {
- return shell.openExternal(url);
- },
- registerEvent: function (event, callback) {
- this.getCurrentWindow().on && this.getCurrentWindow().on(event, callback);
- },
- isMaximized: function () {
- return this.getCurrentWindow().isMaximized && this.getCurrentWindow().isMaximized();
- },
- minimizeWindow: function () {
- this.getCurrentWindow().minimize();
- },
- maximizeOrRestoreWindow: function () {
- if (!this.getCurrentWindow().isMaximized()) {
- this.getCurrentWindow().maximize();
- } else {
- this.getCurrentWindow().unmaximize();
- }
- },
- exitApp: function () {
- this.getCurrentWindow().close();
- }
- };
- }]);
- }());
|