2017-03-31 18:21:41 +00:00
|
|
|
/* jQuery */
|
|
|
|
import $ from 'jquery';
|
|
|
|
|
|
|
|
/* Annotations */
|
|
|
|
import annotator from 'annotator';
|
|
|
|
|
2019-07-09 11:22:50 +00:00
|
|
|
import ClipboardJS from 'clipboard';
|
2019-09-27 14:01:55 +00:00
|
|
|
import 'mathjax/es5/tex-svg';
|
2019-07-09 11:22:50 +00:00
|
|
|
|
2017-03-31 18:21:41 +00:00
|
|
|
/* Fonts */
|
|
|
|
import 'material-design-icons-iconfont/dist/material-design-icons.css';
|
|
|
|
import 'lato-font/css/lato-font.css';
|
|
|
|
import './global.scss';
|
|
|
|
|
2017-09-06 20:42:23 +00:00
|
|
|
/* Shortcuts */
|
2017-03-31 18:21:41 +00:00
|
|
|
import './js/shortcuts/entry';
|
|
|
|
import './js/shortcuts/main';
|
|
|
|
|
2018-04-23 17:11:24 +00:00
|
|
|
/* Hightlight */
|
|
|
|
import './js/highlight';
|
2017-03-31 18:21:41 +00:00
|
|
|
|
2018-04-23 17:11:24 +00:00
|
|
|
import { savePercent, retrievePercent } from './js/tools';
|
2017-03-31 18:21:41 +00:00
|
|
|
|
|
|
|
/* ==========================================================================
|
|
|
|
Annotations & Remember position
|
|
|
|
========================================================================== */
|
|
|
|
|
|
|
|
$(document).ready(() => {
|
|
|
|
if ($('article').length) {
|
|
|
|
const app = new annotator.App();
|
|
|
|
|
|
|
|
app.include(annotator.ui.main, {
|
|
|
|
element: document.querySelector('article'),
|
|
|
|
});
|
|
|
|
|
2017-05-14 09:38:02 +00:00
|
|
|
const authorization = {
|
|
|
|
permits() { return true; },
|
|
|
|
};
|
|
|
|
app.registry.registerUtility(authorization, 'authorizationPolicy');
|
|
|
|
|
2017-03-31 18:21:41 +00:00
|
|
|
const x = JSON.parse($('#annotationroutes').html());
|
2017-05-07 15:21:30 +00: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 18:21:41 +00: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 06:27:15 +00:00
|
|
|
retrievePercent(x.entryId, true);
|
2017-03-31 18:21:41 +00:00
|
|
|
});
|
|
|
|
}
|
2018-01-24 16:29:26 +00: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 11:43:05 +00: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 11:22:50 +00:00
|
|
|
|
|
|
|
// handle copy to clipboard for developer stuff
|
|
|
|
const clipboard = new ClipboardJS('.btn');
|
|
|
|
clipboard.on('success', (e) => {
|
|
|
|
e.clearSelection();
|
|
|
|
});
|
2017-03-31 18:21:41 +00:00
|
|
|
});
|