Browse Source

Add tray to NW.js version

tags/v1.1.0
Skylar Ittner 9 months ago
parent
commit
82583f45ba
3 changed files with 83 additions and 0 deletions
  1. BIN
      www/img/logo_64.png
  2. 7
    0
      www/js/home.js
  3. 76
    0
      www/js/platform.js

BIN
www/img/logo_64.png View File


+ 7
- 0
www/js/home.js View File

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

+ 76
- 0
www/js/platform.js View File

@@ -6,10 +6,16 @@

var platform_type = "";

var nw_tray = null;

var openBrowser = function (url) {

}

var setTrayMenu = function (items) {

}

function initCordova() {
platform_type = "cordova";

@@ -66,6 +72,76 @@ function initNW() {
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() {

Loading…
Cancel
Save