]>
git.immae.eu Git - github/wallabag/wallabag.git/blob - app/Resources/static/themes/baggy/js/init.js
1 var $ = global
.jquery
= require('jquery');
2 require('jquery.cookie');
4 var annotator
= require('annotator');
7 $.fn
.ready(function () {
8 var $listmode
= $('#listmode');
9 var $listentries
= $('#list-entries');
11 /* ==========================================================================
13 ========================================================================== */
15 $('#menu').click(function () {
16 $('#links').toggleClass('menu--open');
17 if ($('#content').hasClass('opacity03')) {
18 $('#content').removeClass('opacity03');
22 /* ==========================================================================
23 List mode or Table Mode
24 ========================================================================== */
26 $listmode
.click(function () {
27 if (jquery
.cookie('listmode') === 1) {
29 $.removeCookie('listmode');
31 $listentries
.removeClass('listmode');
32 $listmode
.removeClass('tablemode');
33 $listmode
.addClass('listmode');
36 jquery
.cookie('listmode', 1, { expires: 365 });
38 $listentries
.addClass('listmode');
39 $listmode
.removeClass('listmode');
40 $listmode
.addClass('tablemode');
44 /* ==========================================================================
46 ========================================================================== */
48 if (jquery
.cookie('listmode') === 1) {
49 $listentries
.addClass('listmode');
50 $listmode
.removeClass('listmode');
51 $listmode
.addClass('tablemode');
54 /* ==========================================================================
56 ========================================================================== */
59 $('#nav-btn-add-tag').on('click', function () {
60 $('.nav-panel-add-tag').toggle(100);
61 $('.nav-panel-menu').addClass('hidden');
62 $('#tag_label').focus();
66 /* ==========================================================================
67 Annotations & Remember position
68 ========================================================================== */
70 if ($('article').length
) {
71 var app
= new annotator
.App();
73 app
.include(annotator
.ui
.main
, {
74 element: document
.querySelector('article'),
77 var x
= JSON
.parse($('#annotationroutes').html());
78 app
.include(annotator
.storage
.http
, x
);
80 app
.start().then(function () {
81 app
.annotations
.load({ entry: x
.entryId
});
84 $(window
).scroll(function (e
) {
85 var scrollTop
= $(window
).scrollTop();
86 var docHeight
= $(document
).height();
87 var scrollPercent
= (scrollTop
) / (docHeight
);
88 var scrollPercentRounded
= Math
.round(scrollPercent
* 100) / 100;
89 savePercent(x
.entryId
, scrollPercentRounded
);
92 retrievePercent(x
.entryId
);
94 $(window
).resize(function () {
95 retrievePercent(x
.entryId
);