X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=app%2FResources%2Fstatic%2Fthemes%2Fmaterial%2Fjs%2Finit.js;fp=src%2FWallabag%2FCoreBundle%2FResources%2Fpublic%2Fthemes%2Fmaterial%2Fjs%2Finit.js;h=33019d3db12dd4310251dfd33cf86e0a6e62ef1e;hb=5ecdfcd041767c9e3244a92bb0a6cc3c3f80fea3;hp=491a7916d68d5b1d2a09c240523375e28c23ccc2;hpb=9f95b14dec88cf083cefa38d5fbd84189e07acac;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Resources/public/themes/material/js/init.js b/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 491a7916..33019d3d 100755 --- a/src/Wallabag/CoreBundle/Resources/public/themes/material/js/init.js +++ b/app/Resources/static/themes/material/js/init.js @@ -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); + }); + } });