]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - app/Resources/static/themes/material/js/init.js
manage assets through npm
[github/wallabag/wallabag.git] / app / Resources / static / themes / material / js / init.js
similarity index 67%
rename from src/Wallabag/CoreBundle/Resources/public/themes/material/js/init.js
rename to app/Resources/static/themes/material/js/init.js
index 491a7916d68d5b1d2a09c240523375e28c23ccc2..33019d3db12dd4310251dfd33cf86e0a6e62ef1e 100755 (executable)
@@ -1,3 +1,7 @@
+var $ = require("jquery"),
+materialize = require("materialize");
+var annotator = require('annotator');
+
 function init_filters() {
     // no display if filters not aviable
     if ($("div").is("#filters")) {
@@ -60,7 +64,7 @@ $(document).ready(function(){
         $("#searchfield").focus();
         return false;
     });
-    $('.mdi-navigation-close').on('click', function(){
+    $('.close').on('click', function(){
         $(".nav-panel-add").hide(100);
         $(".nav-panel-search").hide(100);
         $(".nav-panel-buttom").show(100);
@@ -76,4 +80,37 @@ $(document).ready(function(){
         var scrollPercent = (s / (d-c)) * 100;
         $(".progress .determinate").css('width', scrollPercent+'%');
     });
+
+  /* ==========================================================================
+     Annotations & Remember position
+     ========================================================================== */
+
+    if ($("article").length) {
+        var app = new annotator.App();
+
+        app.include(annotator.ui.main, {
+            element: document.querySelector('article')
+        });
+
+        var x = JSON.parse($('#annotationroutes').html());
+        app.include(annotator.storage.http, x);
+
+        app.start().then(function () {
+             app.annotations.load({entry: x.entryId});
+        });
+
+        $(window).scroll(function(e){
+            var scrollTop = $(window).scrollTop();
+            var docHeight = $(document).height();
+            var scrollPercent = (scrollTop) / (docHeight);
+            var scrollPercentRounded = Math.round(scrollPercent*100)/100;
+            savePercent(x.entryId, scrollPercentRounded);
+        });
+
+        retrievePercent(x.entryId);
+
+        $(window).resize(function(){
+            retrievePercent(x.entryId);
+        });
+    }
 });