]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - app/Resources/static/themes/_global/index.js
Merge pull request #3636 from flozz/syntax-highlight
[github/wallabag/wallabag.git] / app / Resources / static / themes / _global / index.js
index 3fdcaa3d078b0525e1df27f5a0c55b534621b968..ae598e56e1374a45cb59be9b74f9d69a327e4ee1 100644 (file)
@@ -9,12 +9,14 @@ 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 +36,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 +67,7 @@ $(document).ready(() => {
     retrievePercent(x.entryId);
 
     $(window).resize(() => {
-      retrievePercent(x.entryId);
+      retrievePercent(x.entryId, true);
     });
   }
 });