2016-03-08 17:02:34 +01:00
|
|
|
var $ = global.jquery = require('jquery');
|
|
|
|
require('jquery.cookie');
|
|
|
|
require('jquery-ui');
|
|
|
|
var annotator = require('annotator');
|
|
|
|
|
|
|
|
|
2015-01-28 13:58:12 +01:00
|
|
|
$.fn.ready(function() {
|
|
|
|
|
|
|
|
var $listmode = $('#listmode'),
|
|
|
|
$listentries = $("#list-entries");
|
|
|
|
|
|
|
|
/* ==========================================================================
|
|
|
|
Menu
|
|
|
|
========================================================================== */
|
|
|
|
|
|
|
|
$("#menu").click(function(){
|
|
|
|
$("#links").toggleClass('menu--open');
|
|
|
|
if ($('#content').hasClass('opacity03')) {
|
|
|
|
$('#content').removeClass('opacity03');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
/* ==========================================================================
|
|
|
|
List mode or Table Mode
|
|
|
|
========================================================================== */
|
|
|
|
|
|
|
|
$listmode.click(function(){
|
2016-03-08 17:02:34 +01:00
|
|
|
if ( jquery.cookie("listmode") == 1 ) {
|
2015-01-28 13:58:12 +01:00
|
|
|
// Cookie
|
|
|
|
$.removeCookie("listmode");
|
|
|
|
|
|
|
|
$listentries.removeClass("listmode");
|
|
|
|
$listmode.removeClass("tablemode");
|
|
|
|
$listmode.addClass("listmode");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Cookie
|
2016-03-08 17:02:34 +01:00
|
|
|
jquery.cookie("listmode", 1, {expires: 365});
|
2015-01-28 13:58:12 +01:00
|
|
|
|
|
|
|
$listentries.addClass("listmode");
|
|
|
|
$listmode.removeClass("listmode");
|
|
|
|
$listmode.addClass("tablemode");
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
/* ==========================================================================
|
|
|
|
Cookie listmode
|
|
|
|
========================================================================== */
|
|
|
|
|
2016-03-08 17:02:34 +01:00
|
|
|
if ( jquery.cookie("listmode") == 1 ) {
|
2015-01-28 13:58:12 +01:00
|
|
|
$listentries.addClass("listmode");
|
|
|
|
$listmode.removeClass("listmode");
|
|
|
|
$listmode.addClass("tablemode");
|
|
|
|
}
|
|
|
|
|
2016-02-14 20:12:03 +01:00
|
|
|
/* ==========================================================================
|
|
|
|
Add tag panel
|
|
|
|
========================================================================== */
|
|
|
|
|
|
|
|
|
|
|
|
$('#nav-btn-add-tag').on('click', function(){
|
|
|
|
$(".nav-panel-add-tag").toggle(100);
|
|
|
|
$(".nav-panel-menu").addClass('hidden');
|
|
|
|
$("#tag_label").focus();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2016-03-08 17:02:34 +01:00
|
|
|
/* ==========================================================================
|
|
|
|
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);
|
|
|
|
});
|
|
|
|
}
|
2015-01-28 13:58:12 +01:00
|
|
|
});
|