]>
git.immae.eu Git - github/wallabag/wallabag.git/blob - app/Resources/static/themes/baggy/js/init.js
1721ae41ab392ffc1bd64827586733a904f64479
1 var $ = global
.jquery
= require('jquery');
2 require('jquery.cookie');
4 var annotator
= require('annotator');
7 $.fn
.ready(function() {
9 var $listmode
= $('#listmode'),
10 $listentries
= $("#list-entries");
12 /* ==========================================================================
14 ========================================================================== */
16 $("#menu").click(function(){
17 $("#links").toggleClass('menu--open');
18 if ($('#content').hasClass('opacity03')) {
19 $('#content').removeClass('opacity03');
23 /* ==========================================================================
24 List mode or Table Mode
25 ========================================================================== */
27 $listmode
.click(function(){
28 if ( jquery
.cookie("listmode") == 1 ) {
30 $.removeCookie("listmode");
32 $listentries
.removeClass("listmode");
33 $listmode
.removeClass("tablemode");
34 $listmode
.addClass("listmode");
38 jquery
.cookie("listmode", 1, {expires: 365});
40 $listentries
.addClass("listmode");
41 $listmode
.removeClass("listmode");
42 $listmode
.addClass("tablemode");
47 /* ==========================================================================
49 ========================================================================== */
51 if ( jquery
.cookie("listmode") == 1 ) {
52 $listentries
.addClass("listmode");
53 $listmode
.removeClass("listmode");
54 $listmode
.addClass("tablemode");
57 /* ==========================================================================
59 ========================================================================== */
62 $('#nav-btn-add-tag').on('click', function(){
63 $(".nav-panel-add-tag").toggle(100);
64 $(".nav-panel-menu").addClass('hidden');
65 $("#tag_label").focus();
69 /* ==========================================================================
70 Annotations & Remember position
71 ========================================================================== */
73 if ($("article").length
) {
74 var app
= new annotator
.App();
76 app
.include(annotator
.ui
.main
, {
77 element: document
.querySelector('article')
80 var x
= JSON
.parse($('#annotationroutes').html());
81 app
.include(annotator
.storage
.http
, x
);
83 app
.start().then(function () {
84 app
.annotations
.load({entry: x
.entryId
});
87 $(window
).scroll(function(e
){
88 var scrollTop
= $(window
).scrollTop();
89 var docHeight
= $(document
).height();
90 var scrollPercent
= (scrollTop
) / (docHeight
);
91 var scrollPercentRounded
= Math
.round(scrollPercent
*100)/100;
92 savePercent(x
.entryId
, scrollPercentRounded
);
95 retrievePercent(x
.entryId
);
97 $(window
).resize(function(){
98 retrievePercent(x
.entryId
);