/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ $(".view-main").on("ptr:refresh", ".ptr-content", function () { restartApplication(); }); function editNote(id) { var note = NOTES.get(id); router.navigate("/editnote", { context: { noteid: id, content: note.content, notetitle: note.title, } }); console.log("Editing " + id); } function favoriteNote(id) { } function makeList(id) { } function deleteNote(id) { app.dialog.confirm('Are you sure?', 'Delete Note', function () { NOTES.del(id, function () { app.ptr.refresh(); }); }); } $("#app").on("click", ".edit-note-btn", function () { editNote($(this).data("note")); app.popover.close(); }); $("#app").on("click", ".favorite-note-btn", function () { favoriteNote($(this).data("note")); app.popover.close(); }); $("#app").on("click", ".listify-note-btn", function () { makeList($(this).data("note")); app.popover.close(); }); $("#app").on("click", ".delete-note-btn", function () { deleteNote($(this).data("note")); app.popover.close(); }); function openNoteActionMenu(notecard) { var noteid = notecard.data("id"); if (window.innerWidth < 768) { var actionsheet = app.actions.create({ buttons: [ { text: "Edit", bold: true, icon: '', onClick: function () { editNote(noteid); } }, // { // text: "Favorite", // icon: '', // onClick: function () { // favoriteNote(noteid); // } // }, // { // text: "Make a List", // icon: '', // onClick: function () { // makeList(noteid); // } // }, { text: "Delete", icon: '', onClick: function () { deleteNote(noteid); } } ] }); actionsheet.open(); return false; } else { var contextPopover = app.popover.create({ targetEl: notecard.children(".menubtn"), content: '
' + '
' + '
' + '' + '
' + '
' + '
' }); contextPopover.open(); } return false; } $(".view-main").on("click", ".notecard .menubtn", function () { return openNoteActionMenu($(this).parent()); }); $(".view-main").on("contextmenu", ".notecard", function () { return openNoteActionMenu($(this)); });