X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=app%2FResources%2Fstatic%2Fthemes%2F_global%2Findex.js;h=66ac063bc97961ad4bac4d9629b62ad41a372979;hb=66fa0c26ab74467645e2cc63a4f48ef82e3f5748;hp=3fdcaa3d078b0525e1df27f5a0c55b534621b968;hpb=c07ec4b6820723165bd7b832681ad6d43ad605d0;p=github%2Fwallabag%2Fwallabag.git diff --git a/app/Resources/static/themes/_global/index.js b/app/Resources/static/themes/_global/index.js index 3fdcaa3d..66ac063b 100644 --- a/app/Resources/static/themes/_global/index.js +++ b/app/Resources/static/themes/_global/index.js @@ -4,17 +4,21 @@ import $ from 'jquery'; /* Annotations */ import annotator from 'annotator'; +import ClipboardJS from 'clipboard'; + /* Fonts */ import 'material-design-icons-iconfont/dist/material-design-icons.css'; import 'lato-font/css/lato-font.css'; import './global.scss'; -/* Shortcuts*/ +/* Shortcuts */ import './js/shortcuts/entry'; import './js/shortcuts/main'; -import { savePercent, retrievePercent } from './js/tools'; +/* Hightlight */ +import './js/highlight'; +import { savePercent, retrievePercent } from './js/tools'; /* ========================================================================== Annotations & Remember position @@ -34,7 +38,21 @@ $(document).ready(() => { app.registry.registerUtility(authorization, 'authorizationPolicy'); const x = JSON.parse($('#annotationroutes').html()); - app.include(annotator.storage.http, x); + 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'); + }); + } + }); + }, + })); app.start().then(() => { app.annotations.load({ entry: x.entryId }); @@ -51,7 +69,52 @@ $(document).ready(() => { retrievePercent(x.entryId); $(window).resize(() => { - retrievePercent(x.entryId); + retrievePercent(x.entryId, true); }); } + + 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(); + } + }; + }); + + // 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); + }); + + // handle copy to clipboard for developer stuff + const clipboard = new ClipboardJS('.btn'); + clipboard.on('success', (e) => { + console.info(e.text); + + e.clearSelection(); + }); });