2017-03-31 20:21:41 +02:00
|
|
|
/* jQuery */
|
|
|
|
import $ from 'jquery';
|
|
|
|
|
|
|
|
/* Annotations */
|
|
|
|
import annotator from 'annotator';
|
|
|
|
|
2019-07-09 13:22:50 +02:00
|
|
|
import ClipboardJS from 'clipboard';
|
2019-09-27 16:01:55 +02:00
|
|
|
import 'mathjax/es5/tex-svg';
|
2019-07-09 13:22:50 +02:00
|
|
|
|
2017-03-31 20:21:41 +02:00
|
|
|
/* Fonts */
|
|
|
|
import 'material-design-icons-iconfont/dist/material-design-icons.css';
|
|
|
|
import 'lato-font/css/lato-font.css';
|
2023-07-29 12:26:44 +02:00
|
|
|
import 'open-dyslexic/open-dyslexic-regular.css';
|
|
|
|
import '@fontsource/atkinson-hyperlegible';
|
|
|
|
import '@fontsource/eb-garamond';
|
|
|
|
import '@fontsource/montserrat';
|
|
|
|
import '@fontsource/oswald';
|
2017-03-31 20:21:41 +02:00
|
|
|
import './global.scss';
|
|
|
|
|
2017-09-06 22:42:23 +02:00
|
|
|
/* Shortcuts */
|
2017-03-31 20:21:41 +02:00
|
|
|
import './js/shortcuts/entry';
|
|
|
|
import './js/shortcuts/main';
|
|
|
|
|
2023-09-17 22:54:49 +02:00
|
|
|
/* Highlight */
|
2018-04-23 19:11:24 +02:00
|
|
|
import './js/highlight';
|
2017-03-31 20:21:41 +02:00
|
|
|
|
2018-04-23 19:11:24 +02:00
|
|
|
import { savePercent, retrievePercent } from './js/tools';
|
2017-03-31 20:21:41 +02:00
|
|
|
|
|
|
|
/* ==========================================================================
|
|
|
|
Annotations & Remember position
|
|
|
|
========================================================================== */
|
|
|
|
|
|
|
|
$(document).ready(() => {
|
2023-07-29 12:26:44 +02:00
|
|
|
if ($('#article').length) {
|
2017-03-31 20:21:41 +02:00
|
|
|
const app = new annotator.App();
|
|
|
|
|
|
|
|
app.include(annotator.ui.main, {
|
|
|
|
element: document.querySelector('article'),
|
|
|
|
});
|
|
|
|
|
2017-05-14 11:38:02 +02:00
|
|
|
const authorization = {
|
|
|
|
permits() { return true; },
|
|
|
|
};
|
|
|
|
app.registry.registerUtility(authorization, 'authorizationPolicy');
|
|
|
|
|
2017-03-31 20:21:41 +02:00
|
|
|
const x = JSON.parse($('#annotationroutes').html());
|
2017-05-07 17:21:30 +02:00
|
|
|
app.include(annotator.storage.http, $.extend({}, x, {
|
|
|
|
onError(msg, xhr) {
|
|
|
|
if (!Object.prototype.hasOwnProperty.call(xhr, 'responseJSON')) {
|
|
|
|
annotator.notification.banner('An error occurred', 'error');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$.each(xhr.responseJSON.children, (k, v) => {
|
|
|
|
if (v.errors) {
|
|
|
|
$.each(v.errors, (n, errorText) => {
|
|
|
|
annotator.notification.banner(errorText, 'error');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
}));
|
2017-03-31 20:21:41 +02:00
|
|
|
|
|
|
|
app.start().then(() => {
|
|
|
|
app.annotations.load({ entry: x.entryId });
|
|
|
|
});
|
|
|
|
|
|
|
|
$(window).scroll(() => {
|
|
|
|
const scrollTop = $(window).scrollTop();
|
|
|
|
const docHeight = $(document).height();
|
|
|
|
const scrollPercent = (scrollTop) / (docHeight);
|
|
|
|
const scrollPercentRounded = Math.round(scrollPercent * 100) / 100;
|
|
|
|
savePercent(x.entryId, scrollPercentRounded);
|
|
|
|
});
|
|
|
|
|
|
|
|
retrievePercent(x.entryId);
|
|
|
|
|
|
|
|
$(window).resize(() => {
|
2018-05-24 08:27:15 +02:00
|
|
|
retrievePercent(x.entryId, true);
|
2017-03-31 20:21:41 +02:00
|
|
|
});
|
|
|
|
}
|
2018-01-24 17:29:26 +01:00
|
|
|
|
|
|
|
document.querySelectorAll('[data-handler=tag-rename]').forEach((item) => {
|
|
|
|
const current = item;
|
|
|
|
current.wallabag_edit_mode = false;
|
|
|
|
current.onclick = (event) => {
|
|
|
|
const target = event.currentTarget;
|
|
|
|
|
|
|
|
if (target.wallabag_edit_mode === false) {
|
|
|
|
$(target.parentNode.querySelector('[data-handle=tag-link]')).addClass('hidden');
|
|
|
|
$(target.parentNode.querySelector('[data-handle=tag-rename-form]')).removeClass('hidden');
|
|
|
|
target.parentNode.querySelector('[data-handle=tag-rename-form] input').focus();
|
|
|
|
target.querySelector('.material-icons').innerHTML = 'done';
|
|
|
|
|
|
|
|
target.wallabag_edit_mode = true;
|
|
|
|
} else {
|
|
|
|
target.parentNode.querySelector('[data-handle=tag-rename-form]').submit();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
2018-12-02 12:43:05 +01:00
|
|
|
|
|
|
|
// mimic radio button because emailTwoFactor is a boolean
|
|
|
|
$('#update_user_googleTwoFactor').on('change', () => {
|
|
|
|
$('#update_user_emailTwoFactor').prop('checked', false);
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#update_user_emailTwoFactor').on('change', () => {
|
|
|
|
$('#update_user_googleTwoFactor').prop('checked', false);
|
|
|
|
});
|
|
|
|
|
|
|
|
// same mimic for super admin
|
|
|
|
$('#user_googleTwoFactor').on('change', () => {
|
|
|
|
$('#user_emailTwoFactor').prop('checked', false);
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#user_emailTwoFactor').on('change', () => {
|
|
|
|
$('#user_googleTwoFactor').prop('checked', false);
|
|
|
|
});
|
2019-07-09 13:22:50 +02:00
|
|
|
|
|
|
|
// handle copy to clipboard for developer stuff
|
|
|
|
const clipboard = new ClipboardJS('.btn');
|
|
|
|
clipboard.on('success', (e) => {
|
|
|
|
e.clearSelection();
|
|
|
|
});
|
2017-03-31 20:21:41 +02:00
|
|
|
});
|