X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=app%2FResources%2Fstatic%2Fthemes%2Fbaggy%2Fjs%2Finit.js;fp=src%2FWallabag%2FCoreBundle%2FResources%2Fpublic%2Fthemes%2Fbaggy%2Fjs%2Finit.js;h=1721ae41ab392ffc1bd64827586733a904f64479;hb=5ecdfcd041767c9e3244a92bb0a6cc3c3f80fea3;hp=9bdc6f2126eaf70dc5b3fec86ec02f015892f6a1;hpb=9f95b14dec88cf083cefa38d5fbd84189e07acac;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Resources/public/themes/baggy/js/init.js b/app/Resources/static/themes/baggy/js/init.js similarity index 56% rename from src/Wallabag/CoreBundle/Resources/public/themes/baggy/js/init.js rename to app/Resources/static/themes/baggy/js/init.js index 9bdc6f21..1721ae41 100755 --- a/src/Wallabag/CoreBundle/Resources/public/themes/baggy/js/init.js +++ b/app/Resources/static/themes/baggy/js/init.js @@ -1,3 +1,9 @@ +var $ = global.jquery = require('jquery'); +require('jquery.cookie'); +require('jquery-ui'); +var annotator = require('annotator'); + + $.fn.ready(function() { var $listmode = $('#listmode'), @@ -19,7 +25,7 @@ $.fn.ready(function() { ========================================================================== */ $listmode.click(function(){ - if ( $.cookie("listmode") == 1 ) { + if ( jquery.cookie("listmode") == 1 ) { // Cookie $.removeCookie("listmode"); @@ -29,7 +35,7 @@ $.fn.ready(function() { } else { // Cookie - $.cookie("listmode", 1, {expires: 365}); + jquery.cookie("listmode", 1, {expires: 365}); $listentries.addClass("listmode"); $listmode.removeClass("listmode"); @@ -42,7 +48,7 @@ $.fn.ready(function() { Cookie listmode ========================================================================== */ - if ( $.cookie("listmode") == 1 ) { + if ( jquery.cookie("listmode") == 1 ) { $listentries.addClass("listmode"); $listmode.removeClass("listmode"); $listmode.addClass("tablemode"); @@ -60,4 +66,36 @@ $.fn.ready(function() { return false; }); + /* ========================================================================== + 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); + }); + } });