aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/Resources/static/themes/baggy/js/init.js
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2016-06-09 19:02:38 +0200
committerThomas Citharel <tcit@tcit.fr>2016-06-09 19:02:38 +0200
commit0743287f955fd19fd1a04c91f3b40a4ac2236423 (patch)
tree42d9f4efef7c8099416e24ce751de78524b9a58a /app/Resources/static/themes/baggy/js/init.js
parent5ecdfcd041767c9e3244a92bb0a6cc3c3f80fea3 (diff)
downloadwallabag-0743287f955fd19fd1a04c91f3b40a4ac2236423.tar.gz
wallabag-0743287f955fd19fd1a04c91f3b40a4ac2236423.tar.zst
wallabag-0743287f955fd19fd1a04c91f3b40a4ac2236423.zip
clean & lint stuff
Diffstat (limited to 'app/Resources/static/themes/baggy/js/init.js')
-rwxr-xr-xapp/Resources/static/themes/baggy/js/init.js99
1 files changed, 48 insertions, 51 deletions
diff --git a/app/Resources/static/themes/baggy/js/init.js b/app/Resources/static/themes/baggy/js/init.js
index 1721ae41..d7d4b166 100755
--- a/app/Resources/static/themes/baggy/js/init.js
+++ b/app/Resources/static/themes/baggy/js/init.js
@@ -4,19 +4,18 @@ require('jquery-ui');
4var annotator = require('annotator'); 4var annotator = require('annotator');
5 5
6 6
7$.fn.ready(function() { 7$.fn.ready(function () {
8 8 var $listmode = $('#listmode');
9 var $listmode = $('#listmode'), 9 var $listentries = $('#list-entries');
10 $listentries = $("#list-entries");
11 10
12 /* ========================================================================== 11 /* ==========================================================================
13 Menu 12 Menu
14 ========================================================================== */ 13 ========================================================================== */
15 14
16 $("#menu").click(function(){ 15 $('#menu').click(function () {
17 $("#links").toggleClass('menu--open'); 16 $('#links').toggleClass('menu--open');
18 if ($('#content').hasClass('opacity03')) { 17 if ($('#content').hasClass('opacity03')) {
19 $('#content').removeClass('opacity03'); 18 $('#content').removeClass('opacity03');
20 } 19 }
21 }); 20 });
22 21
@@ -24,34 +23,32 @@ $.fn.ready(function() {
24 List mode or Table Mode 23 List mode or Table Mode
25 ========================================================================== */ 24 ========================================================================== */
26 25
27 $listmode.click(function(){ 26 $listmode.click(function () {
28 if ( jquery.cookie("listmode") == 1 ) { 27 if (jquery.cookie('listmode') === 1) {
29 // Cookie 28 // Cookie
30 $.removeCookie("listmode"); 29 $.removeCookie('listmode');
31 30
32 $listentries.removeClass("listmode"); 31 $listentries.removeClass('listmode');
33 $listmode.removeClass("tablemode"); 32 $listmode.removeClass('tablemode');
34 $listmode.addClass("listmode"); 33 $listmode.addClass('listmode');
35 } 34 } else {
36 else {
37 // Cookie 35 // Cookie
38 jquery.cookie("listmode", 1, {expires: 365}); 36 jquery.cookie('listmode', 1, { expires: 365 });
39 37
40 $listentries.addClass("listmode"); 38 $listentries.addClass('listmode');
41 $listmode.removeClass("listmode"); 39 $listmode.removeClass('listmode');
42 $listmode.addClass("tablemode"); 40 $listmode.addClass('tablemode');
43 } 41 }
44
45 }); 42 });
46 43
47 /* ========================================================================== 44 /* ==========================================================================
48 Cookie listmode 45 Cookie listmode
49 ========================================================================== */ 46 ========================================================================== */
50 47
51 if ( jquery.cookie("listmode") == 1 ) { 48 if (jquery.cookie('listmode') === 1) {
52 $listentries.addClass("listmode"); 49 $listentries.addClass('listmode');
53 $listmode.removeClass("listmode"); 50 $listmode.removeClass('listmode');
54 $listmode.addClass("tablemode"); 51 $listmode.addClass('tablemode');
55 } 52 }
56 53
57 /* ========================================================================== 54 /* ==========================================================================
@@ -59,43 +56,43 @@ $.fn.ready(function() {
59 ========================================================================== */ 56 ========================================================================== */
60 57
61 58
62 $('#nav-btn-add-tag').on('click', function(){ 59 $('#nav-btn-add-tag').on('click', function () {
63 $(".nav-panel-add-tag").toggle(100); 60 $('.nav-panel-add-tag').toggle(100);
64 $(".nav-panel-menu").addClass('hidden'); 61 $('.nav-panel-menu').addClass('hidden');
65 $("#tag_label").focus(); 62 $('#tag_label').focus();
66 return false; 63 return false;
67 }); 64 });
68 65
69 /* ========================================================================== 66 /* ==========================================================================
70 Annotations & Remember position 67 Annotations & Remember position
71 ========================================================================== */ 68 ========================================================================== */
72 69
73 if ($("article").length) { 70 if ($('article').length) {
74 var app = new annotator.App(); 71 var app = new annotator.App();
75 72
76 app.include(annotator.ui.main, { 73 app.include(annotator.ui.main, {
77 element: document.querySelector('article') 74 element: document.querySelector('article'),
78 }); 75 });
79 76
80 var x = JSON.parse($('#annotationroutes').html()); 77 var x = JSON.parse($('#annotationroutes').html());
81 app.include(annotator.storage.http, x); 78 app.include(annotator.storage.http, x);
82 79
83 app.start().then(function () { 80 app.start().then(function () {
84 app.annotations.load({entry: x.entryId}); 81 app.annotations.load({ entry: x.entryId });
85 }); 82 });
86 83
87 $(window).scroll(function(e){ 84 $(window).scroll(function (e) {
88 var scrollTop = $(window).scrollTop(); 85 var scrollTop = $(window).scrollTop();
89 var docHeight = $(document).height(); 86 var docHeight = $(document).height();
90 var scrollPercent = (scrollTop) / (docHeight); 87 var scrollPercent = (scrollTop) / (docHeight);
91 var scrollPercentRounded = Math.round(scrollPercent*100)/100; 88 var scrollPercentRounded = Math.round(scrollPercent * 100) / 100;
92 savePercent(x.entryId, scrollPercentRounded); 89 savePercent(x.entryId, scrollPercentRounded);
93 }); 90 });
94 91
95 retrievePercent(x.entryId); 92 retrievePercent(x.entryId);
96 93
97 $(window).resize(function(){ 94 $(window).resize(function () {
98 retrievePercent(x.entryId); 95 retrievePercent(x.entryId);
99 }); 96 });
100 } 97 }
101}); 98});