Add tray to NW.js version

master
Skylar Ittner 5 years ago
parent e6fdbb893e
commit 82583f45ba

Binary file not shown.

After

Width:  |  Height:  |  Size: 839 B

@ -27,6 +27,7 @@ function loadCards(callback) {
window.shuffleInstance.remove(window.shuffleInstance.items[i]); window.shuffleInstance.remove(window.shuffleInstance.items[i]);
} }
$(".notecard-col").remove(); $(".notecard-col").remove();
var trayitems = [];
for (n in notes) { for (n in notes) {
var note = notes[n]; var note = notes[n];
$("#notecards-bin").append('<div class="col-100 tablet-50 desktop-33 notecard-col" id="notecard-col-' + note.noteid + '" data-favorite="' + (note.favorite ? "1" : "0") + '">' $("#notecards-bin").append('<div class="col-100 tablet-50 desktop-33 notecard-col" id="notecard-col-' + note.noteid + '" data-favorite="' + (note.favorite ? "1" : "0") + '">'
@ -40,7 +41,12 @@ function loadCards(callback) {
+ '<div class="card-content card-content-padding"><div class="btnswrapthing"></div>' + note.html + '</div>' + '<div class="card-content card-content-padding"><div class="btnswrapthing"></div>' + note.html + '</div>'
+ '</div>' + '</div>'
+ '</div>'); + '</div>');
trayitems.push({
title: note.title,
id: note.noteid
});
} }
console.log(trayitems);
var noteElements = document.getElementsByClassName("notecard-col"); var noteElements = document.getElementsByClassName("notecard-col");
window.shuffleInstance.add(noteElements); window.shuffleInstance.add(noteElements);
window.shuffleInstance.sort({ window.shuffleInstance.sort({
@ -49,6 +55,7 @@ function loadCards(callback) {
return el.getAttribute("data-favorite"); return el.getAttribute("data-favorite");
} }
}); });
setTrayMenu(trayitems);
if (typeof callback == 'function') { if (typeof callback == 'function') {
callback(); callback();
} }

@ -6,10 +6,16 @@
var platform_type = ""; var platform_type = "";
var nw_tray = null;
var openBrowser = function (url) { var openBrowser = function (url) {
} }
var setTrayMenu = function (items) {
}
function initCordova() { function initCordova() {
platform_type = "cordova"; platform_type = "cordova";
@ -66,6 +72,76 @@ function initNW() {
browserwin.menu = browsermenu; browserwin.menu = browsermenu;
}); });
} }
nw_tray = new nw.Tray({
title: 'NotePost',
icon: 'www/img/logo_64.png'
});
setTrayMenu = function (items) {
var menu = new nw.Menu();
menu.append(new nw.MenuItem({
type: 'normal',
label: 'Open NotePost',
click: function () {
nw.Window.get().show();
}
}));
menu.append(new nw.MenuItem({
type: 'normal',
label: 'New Note',
click: function () {
router.navigate("/editnote");
nw.Window.get().show();
}
}));
menu.append(new nw.MenuItem({
type: 'separator'
}));
if (items.length > 0) {
for (i in items) {
console.log(items[i]);
var label_max = 50;
var label = items[i].title;
if (label.length > label_max) {
label = label.substring(0, label_max) + "...";
}
menu.append(new nw.MenuItem({
type: 'normal',
label: label,
click: function (id) {
return function () {
editNote(id);
nw.Window.get().show();
}
}(items[i].id)
}));
;
}
menu.append(new nw.MenuItem({
type: 'separator'
}));
}
menu.append(new nw.MenuItem({
type: 'normal',
label: 'Exit NotePost',
click: function () {
nw.App.quit();
}
}));
nw_tray.menu = menu;
}
nw.Window.get().on('minimize', function () {
nw.Window.get().hide();
});
nw_tray.on('click', function () {
nw.Window.get().show();
});
setTrayMenu([]);
} }
function initPlatform() { function initPlatform() {

Loading…
Cancel
Save