-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmain.js
More file actions
executable file
·94 lines (79 loc) · 2.38 KB
/
main.js
File metadata and controls
executable file
·94 lines (79 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
window.$ = window.jQuery = require('jquery');
var abar = require('address_bar');
var folder_view = require('folder_view');
//var nwGui = require('nw.gui');
var shell = require('shell');
// append default actions to menu for OSX
var initMenu = function () {
console.log(process.platform);
//try {
//var nwGui = require('nw.gui');
//var nativeMenuBar = new nwGui.Menu({type: "menubar"});
//if (process.platform == "darwin") {
// nativeMenuBar.createMacBuiltin && nativeMenuBar.createMacBuiltin("FileExplorer");
//}
//nwGui.Window.get().menu = nativeMenuBar;
//} catch (error) {
// console.error(error);
// setTimeout(function () {
// throw error
// }, 1);
//}
};
var App = {
// show "about" window
about: function () {
var params = 'toolbar=false, resizable=false, show=true, height=120, width=350';
var aboutWindow = window.open('about.html', 'about', params);
aboutWindow.on('document-end', function () {
aboutWindow.focus();
// open link in default browser
$(aboutWindow.window.document).find('a').bind('click', function (e) {
e.preventDefault();
shell.openExternal(this.href);
});
});
},
// change folder for sidebar links
cd: function (anchor) {
anchor = $(anchor);
$('#sidebar li').removeClass('active');
$('#sidebar i').removeClass('icon-white');
anchor.closest('li').addClass('active');
anchor.find('i').addClass('icon-white');
this.setPath(anchor.attr('nw-path'));
},
// set path for file explorer
setPath: function (path) {
if (path.indexOf('~') == 0) {
path = path.replace('~', process.env['HOME']);
}
this.folder.open(path);
this.addressbar.set(path);
}
};
$(document).ready(function () {
initMenu();
var folder = new folder_view.Folder($('#files'));
var addressbar = new abar.AddressBar($('#addressbar'));
folder.open(process.cwd());
addressbar.set(process.cwd());
App.folder = folder;
App.addressbar = addressbar;
folder.on('navigate', function (dir, mime) {
if (mime.type == 'folder') {
addressbar.enter(mime);
} else {
//nwGui.Shell.openItem(mime.path);
shell.openItem(mime.path);
}
});
addressbar.on('navigate', function (dir) {
folder.open(dir);
});
// sidebar favorites
$('[nw-path]').bind('click', function (event) {
event.preventDefault();
App.cd(this);
});
});