mobile web fixes

This commit is contained in:
zadam 2019-05-22 20:53:59 +02:00
parent 48b1aece4d
commit 79956b5676
7 changed files with 105 additions and 76 deletions

View File

@ -28,7 +28,9 @@
}
async function validatorJavaScript(text, options) {
if (glob.getActiveNote() == null || glob.getActiveNote().mime === 'application/json') {
if (glob.isMobile()
|| glob.getActiveNote() == null
|| glob.getActiveNote().mime === 'application/json') {
// eslint doesn't seem to validate pure JSON well
return [];
}

View File

@ -42,6 +42,9 @@ import macInit from './services/mac_init.js';
import cssLoader from './services/css_loader.js';
import dateNoteService from './services/date_notes.js';
window.glob.isDesktop = utils.isDesktop;
window.glob.isMobile = utils.isMobile;
// required for CKEditor image upload plugin
window.glob.getActiveNode = treeService.getActiveNode;
window.glob.getHeaders = server.getHeaders;

View File

@ -8,6 +8,9 @@ import treeChangesService from "./services/branches.js";
import utils from "./services/utils.js";
import treeUtils from "./services/tree_utils.js";
window.glob.isDesktop = utils.isDesktop;
window.glob.isMobile = utils.isMobile;
const $leftPane = $("#left-pane");
const $tree = $("#tree");
const $detail = $("#detail");
@ -42,6 +45,13 @@ async function showTree() {
source: tree,
scrollParent: $tree,
minExpandLevel: 2, // root can't be collapsed
click: (event, data) => {
if (data.targetType !== 'expander' && data.node.isActive()) {
$tree.fancytree('getTree').reactivate(true);
return false;
}
},
activate: async (event, data) => {
const node = data.node;
@ -97,11 +107,11 @@ $detail.on("click", ".note-menu-button", async e => {
treeService.createNote(node, node.data.noteId, 'into');
}
else if (cmd === "delete") {
treeChangesService.deleteNodes([node]);
if (await treeChangesService.deleteNodes([node])) {
// move to the tree
togglePanes();
}
}
else {
throw new Error("Unrecognized command " + cmd);
}

View File

@ -82,7 +82,7 @@ async function deleteNodes(nodes) {
nodes = await filterRootNote(nodes);
if (nodes.length === 0 || !confirm('Are you sure you want to delete select note(s) and all the sub-notes?')) {
return;
return false;
}
for (const node of nodes) {
@ -123,6 +123,8 @@ async function deleteNodes(nodes) {
}
infoService.showMessage("Note(s) has been deleted.");
return true;
}
async function moveNodeUpInHierarchy(node) {

View File

@ -1,6 +1,6 @@
import server from "./server.js";
import noteDetailService from "./note_detail.js";
import treeService from './tree.js';
import utils from './utils.js';
// this key needs to have this value so it's hit by the tooltip
const SELECTED_PATH_KEY = "data-note-path";
@ -21,18 +21,29 @@ async function autocompleteSource(term, cb) {
}
function clearText($el) {
if (utils.isMobile()) {
return;
}
$el.setSelectedPath("");
$el.autocomplete("val", "").change();
}
function showRecentNotes($el) {
if (utils.isMobile()) {
return;
}
$el.setSelectedPath("");
$el.autocomplete("val", "");
$el.focus();
}
function initNoteAutocomplete($el, options) {
if (!$el.hasClass("note-autocomplete-input")) {
if ($el.hasClass("note-autocomplete-input") || utils.isMobile()) {
return $el;
}
options = options || {};
$el.addClass("note-autocomplete-input");
@ -97,7 +108,6 @@ function initNoteAutocomplete($el, options) {
clearText($el);
}
});
}
return $el;
}

View File

@ -75,7 +75,10 @@ class TabContext {
treeService.setNoteTitle(this.noteId, title);
});
if (utils.isDesktop()) {
// keyboard plugin is not loaded in mobile
this.$noteTitle.bind('keydown', 'return', () => this.getComponent().focus());
}
this.$protectButton = this.$tabContent.find(".protect-button");
this.$protectButton.click(protectedSessionService.protectNoteAndSendToServer);

View File

@ -649,9 +649,8 @@ async function createNote(node, parentNoteId, target, extraOptions = {}) {
if (!node.getChildren() && node.isFolder()) {
await node.setExpanded();
}
else {
node.addChildren(newNode);
}
await node.getLastChild().setActive(true);