2016-11-03 10:02:16 +01:00
|
|
|
/* jQuery */
|
2016-10-27 01:57:27 +02:00
|
|
|
import $ from 'jquery';
|
2016-11-03 10:02:16 +01:00
|
|
|
|
|
|
|
/* Annotations */
|
2016-10-27 01:57:27 +02:00
|
|
|
import annotator from 'annotator';
|
2016-11-03 10:02:16 +01:00
|
|
|
|
|
|
|
/* Tools */
|
2016-10-04 15:30:05 +02:00
|
|
|
import { savePercent, retrievePercent, initFilters, initExport } from '../../_global/js/tools';
|
2016-11-03 10:02:16 +01:00
|
|
|
|
|
|
|
/* Import shortcuts */
|
|
|
|
import './shortcuts/main';
|
|
|
|
import './shortcuts/entry';
|
|
|
|
import '../../_global/js/shortcuts/main';
|
|
|
|
import '../../_global/js/shortcuts/entry';
|
2016-10-04 15:30:05 +02:00
|
|
|
|
2016-10-27 01:57:27 +02:00
|
|
|
require('materialize'); // eslint-disable-line
|
2016-10-04 15:30:05 +02:00
|
|
|
|
2016-09-28 10:30:18 +02:00
|
|
|
global.jQuery = $;
|
2016-03-08 17:02:34 +01:00
|
|
|
|
2016-09-28 10:30:18 +02:00
|
|
|
$(document).ready(() => {
|
2016-06-09 19:02:38 +02:00
|
|
|
// sideNav
|
|
|
|
$('.button-collapse').sideNav();
|
|
|
|
$('select').material_select();
|
|
|
|
$('.collapsible').collapsible({
|
|
|
|
accordion: false,
|
|
|
|
});
|
|
|
|
$('.datepicker').pickadate({
|
|
|
|
selectMonths: true,
|
|
|
|
selectYears: 15,
|
|
|
|
formatSubmit: 'dd/mm/yyyy',
|
|
|
|
hiddenName: true,
|
|
|
|
format: 'dd/mm/yyyy',
|
|
|
|
});
|
|
|
|
initFilters();
|
|
|
|
initExport();
|
2015-08-04 18:39:26 +02:00
|
|
|
|
2016-09-28 10:30:18 +02:00
|
|
|
$('#nav-btn-add-tag').on('click', () => {
|
2016-06-09 19:02:38 +02:00
|
|
|
$('.nav-panel-add-tag').toggle(100);
|
|
|
|
$('.nav-panel-menu').addClass('hidden');
|
|
|
|
$('#tag_label').focus();
|
|
|
|
return false;
|
|
|
|
});
|
2016-09-28 10:30:18 +02:00
|
|
|
$('#nav-btn-add').on('click', () => {
|
2016-06-09 19:02:38 +02:00
|
|
|
$('.nav-panel-buttom').hide(100);
|
|
|
|
$('.nav-panel-add').show(100);
|
|
|
|
$('.nav-panels .action').hide(100);
|
|
|
|
$('.nav-panel-menu').addClass('hidden');
|
|
|
|
$('.nav-panels').css('background', 'white');
|
|
|
|
$('#entry_url').focus();
|
|
|
|
return false;
|
|
|
|
});
|
2016-09-28 10:30:18 +02:00
|
|
|
$('#nav-btn-search').on('click', () => {
|
2016-06-09 19:02:38 +02:00
|
|
|
$('.nav-panel-buttom').hide(100);
|
|
|
|
$('.nav-panel-search').show(100);
|
|
|
|
$('.nav-panels .action').hide(100);
|
|
|
|
$('.nav-panel-menu').addClass('hidden');
|
|
|
|
$('.nav-panels').css('background', 'white');
|
|
|
|
$('#searchfield').focus();
|
|
|
|
return false;
|
|
|
|
});
|
2016-09-28 10:30:18 +02:00
|
|
|
$('.close').on('click', () => {
|
2016-06-09 19:02:38 +02:00
|
|
|
$('.nav-panel-add').hide(100);
|
|
|
|
$('.nav-panel-search').hide(100);
|
|
|
|
$('.nav-panel-buttom').show(100);
|
|
|
|
$('.nav-panels .action').show(100);
|
|
|
|
$('.nav-panel-menu').removeClass('hidden');
|
|
|
|
$('.nav-panels').css('background', 'transparent');
|
|
|
|
return false;
|
|
|
|
});
|
2016-09-28 10:30:18 +02:00
|
|
|
$(window).scroll(() => {
|
|
|
|
const s = $(window).scrollTop();
|
|
|
|
const d = $(document).height();
|
|
|
|
const c = $(window).height();
|
|
|
|
const scrollPercent = (s / (d - c)) * 100;
|
|
|
|
$('.progress .determinate').css('width', `${scrollPercent}%`);
|
2016-06-09 19:02:38 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
/* ==========================================================================
|
|
|
|
Annotations & Remember position
|
|
|
|
========================================================================== */
|
2016-03-08 17:02:34 +01:00
|
|
|
|
2016-06-09 19:02:38 +02:00
|
|
|
if ($('article').length) {
|
2016-09-28 10:30:18 +02:00
|
|
|
const app = new annotator.App();
|
|
|
|
const x = JSON.parse($('#annotationroutes').html());
|
2016-03-08 17:02:34 +01:00
|
|
|
|
2016-06-09 19:02:38 +02:00
|
|
|
app.include(annotator.ui.main, {
|
|
|
|
element: document.querySelector('article'),
|
|
|
|
});
|
2016-03-08 17:02:34 +01:00
|
|
|
|
2016-06-09 19:02:38 +02:00
|
|
|
app.include(annotator.storage.http, x);
|
2016-03-08 17:02:34 +01:00
|
|
|
|
2016-09-28 10:30:18 +02:00
|
|
|
app.start().then(() => {
|
2016-06-09 19:02:38 +02:00
|
|
|
app.annotations.load({ entry: x.entryId });
|
|
|
|
});
|
2016-03-08 17:02:34 +01:00
|
|
|
|
2016-09-28 10:30:18 +02:00
|
|
|
$(window).scroll(() => {
|
|
|
|
const scrollTop = $(window).scrollTop();
|
|
|
|
const docHeight = $(document).height();
|
|
|
|
const scrollPercent = (scrollTop) / (docHeight);
|
|
|
|
const scrollPercentRounded = Math.round(scrollPercent * 100) / 100;
|
2016-06-09 19:02:38 +02:00
|
|
|
savePercent(x.entryId, scrollPercentRounded);
|
|
|
|
});
|
2016-03-08 17:02:34 +01:00
|
|
|
|
2016-06-09 19:02:38 +02:00
|
|
|
retrievePercent(x.entryId);
|
2016-03-08 17:02:34 +01:00
|
|
|
|
2016-09-28 10:30:18 +02:00
|
|
|
$(window).resize(() => {
|
2016-06-09 19:02:38 +02:00
|
|
|
retrievePercent(x.entryId);
|
|
|
|
});
|
|
|
|
}
|
2015-08-11 18:07:02 +02:00
|
|
|
});
|