Passed
Push — master ( 9ddb09...7fc5b5 )
by Jaisen
01:14
created

app/modules/toolbar-ui.js (7 issues)

1
var exports = module.exports = {};
2
3
var menubar = require('menubar'),
4
    menu = require('menu'),
5
    tray = require('tray'),
6
    config = require('./config.js'),
7
    loadUrl = null;
8
var os = require('os')
9
10
var s_dir = __dirname.substr(0,__dirname.lastIndexOf(os.platform() == 'win32' ? '\\' : '/')) + 
11
                              (os.platform() == 'win32' ? '\\html' : '/html');
12
                                              
13
exports.app = app = menubar(
14
  {
15
    preloadWindow: true,
16
    dir: s_dir,
17
    index: 'index.html',
18
    pages: {
19
      'blank': 'blank.html',
20
      'config': 'config.html',
21
      'location': 'location.html'
22
    },
23
    width: 400,
24
    height: 500,
25
    'window-position': 'trayCenter',
26
	'frame': os.platform() == 'win32' ? true : false,
27
	'always-on-top': os.platform() == 'win32' ? true : false
28
  }
29
);
30
31
exports.ready = function() {
32
  console.log('app is ready');
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
33
34
  var template = [{
35
    label: "Application",
36
    submenu: [
37
        { label: "Quit", accelerator: "Command+Q", click: function() { app.quit(); }}
38
    ]}, {
39
    label: "Edit",
40
    submenu: [
41
        { label: "Undo", accelerator: "CmdOrCtrl+Z", selector: "undo:" },
42
        { label: "Redo", accelerator: "Shift+CmdOrCtrl+Z", selector: "redo:" },
43
        { label: "Cut", accelerator: "CmdOrCtrl+X", selector: "cut:" },
44
        { label: "Copy", accelerator: "CmdOrCtrl+C", selector: "copy:" },
45
        { label: "Paste", accelerator: "CmdOrCtrl+V", selector: "paste:" },
46
        { label: "Select All", accelerator: "CmdOrCtrl+A", selector: "selectAll:" }
47
    ]}
48
  ];
49
  menu.setApplicationMenu(menu.buildFromTemplate(template));
50
51
  this.tray.setToolTip('Drag and drop files here');
52
    console.log(app.getOption('dir'));
53
  this.tray.setImage(app.getOption('dir') + '/img/[email protected]');
54
  this.tray.on('clicked', function clicked () {
55
    console.log('tray-clicked')
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
56
  });
57
  this.tray.on('drop-files', function dropFiles (ev, files) {
58
    loadUrl = app.getOption('pages')['location'];
59
    app.showWindow();
60
    //app.window.openDevTools();
61
    app.window.webContents.on('did-finish-load', function() {
62
      app.window.webContents.send('files', files);
63
      app.window.webContents.send('preview', files);
64
    });
65
  });
66
};
67
68
exports.onDropFiles = function(event, args) {
69
  var files = args;
70
  loadUrl = app.getOption('pages')['location'];
71
  app.showWindow();
72
 
73
  app.window.webContents.on('did-finish-load', function() {
74
  app.window.webContents.send('files', files);
75
  app.window.webContents.send('preview', files);
76
 });
77
};
78
 
79
80
exports.createWindow = function() {
81
  console.log('create-window')
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
82
};
83
84
exports.afterCreateWindow = function() {
85
  console.log('after-create-window')
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
86
};
87
88
exports.show = function() {
89
  if(!config.hasConfig()) {
90
    loadUrl = this.getOption('pages')['config'];
91
  } else if(loadUrl === null) {
92
    loadUrl = this.getOption('index');
93
  }
94
95
  this.window.loadUrl('file://' + this.getOption('dir') + '/' + loadUrl);
96
  loadUrl = null;
97
  //app.window.openDevTools();
98
};
99
100
exports.afterShow = function() {
101
  console.log('after-show');
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
102
};
103
104
exports.hide = function() {
105
  console.log('hide');
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
106
};
107
108
exports.afterHide = function() {
109
  console.log('after-hide')
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
110
  this.window.loadUrl('file://' + this.getOption('dir') + '/' + this.getOption('pages')['blank']);
111
};
112