+var $ = global.jquery = require('jquery');
+require('jquery.cookie');
+require('jquery-ui');
+var annotator = require('annotator');
+
+
$.fn.ready(function() {
var $listmode = $('#listmode'),
========================================================================== */
$listmode.click(function(){
- if ( $.cookie("listmode") == 1 ) {
+ if ( jquery.cookie("listmode") == 1 ) {
// Cookie
$.removeCookie("listmode");
}
else {
// Cookie
- $.cookie("listmode", 1, {expires: 365});
+ jquery.cookie("listmode", 1, {expires: 365});
$listentries.addClass("listmode");
$listmode.removeClass("listmode");
Cookie listmode
========================================================================== */
- if ( $.cookie("listmode") == 1 ) {
+ if ( jquery.cookie("listmode") == 1 ) {
$listentries.addClass("listmode");
$listmode.removeClass("listmode");
$listmode.addClass("tablemode");
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);
+ });
+ }
});