aboutsummaryrefslogtreecommitdiffhomepage
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
parent5ecdfcd041767c9e3244a92bb0a6cc3c3f80fea3 (diff)
downloadwallabag-0743287f955fd19fd1a04c91f3b40a4ac2236423.tar.gz
wallabag-0743287f955fd19fd1a04c91f3b40a4ac2236423.tar.zst
wallabag-0743287f955fd19fd1a04c91f3b40a4ac2236423.zip
clean & lint stuff
-rw-r--r--.eslintrc.json4
-rw-r--r--Gruntfile.js124
-rw-r--r--app/Resources/static/themes/_global/js/restoreScroll.js28
-rw-r--r--app/Resources/static/themes/baggy/js/autoClose.js12
-rwxr-xr-xapp/Resources/static/themes/baggy/js/autoCompleteTags.js35
-rw-r--r--app/Resources/static/themes/baggy/js/closeMessage.js36
-rwxr-xr-xapp/Resources/static/themes/baggy/js/init.js99
-rw-r--r--app/Resources/static/themes/baggy/js/popupForm.js167
-rwxr-xr-xapp/Resources/static/themes/baggy/js/saveLink.js67
-rwxr-xr-xapp/Resources/static/themes/material/js/init.js201
-rw-r--r--package.json8
11 files changed, 391 insertions, 390 deletions
diff --git a/.eslintrc.json b/.eslintrc.json
new file mode 100644
index 00000000..976a9eb5
--- /dev/null
+++ b/.eslintrc.json
@@ -0,0 +1,4 @@
1{
2 "extends": "airbnb",
3 "installedESLint": true,
4}
diff --git a/Gruntfile.js b/Gruntfile.js
index c63c392b..04fd1fe8 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -9,85 +9,81 @@ module.exports = function (grunt) {
9 material: { 9 material: {
10 options: { 10 options: {
11 map: { 11 map: {
12 inline: false 12 inline: false,
13 }, 13 },
14 14
15 processors: [ 15 processors: [
16 require('pixrem')(), 16 require('pixrem')(),
17 require('autoprefixer')({browsers: 'last 2 versions'}), 17 require('autoprefixer')({ browsers: 'last 2 versions' }),
18 require('cssnano')() 18 require('cssnano')(),
19 ] 19 ],
20 }, 20 },
21 src: '<%= buildDir %>/material.css', 21 src: '<%= buildDir %>/material.css',
22 dest: '<%= buildDir %>/themes/material/css/style.min.css' 22 dest: '<%= buildDir %>/themes/material/css/style.min.css',
23 }, 23 },
24 baggy: { 24 baggy: {
25 options: { 25 options: {
26 map: { 26 map: {
27 inline: false 27 inline: false,
28 }, 28 },
29 29
30 processors: [ 30 processors: [
31 require('pixrem')(), 31 require('pixrem')(),
32 require('autoprefixer')({browsers: 'last 2 versions'}), 32 require('autoprefixer')({ browsers: 'last 2 versions' }),
33 require('cssnano')() 33 require('cssnano')(),
34 ] 34 ],
35 }, 35 },
36 src: '<%= buildDir %>/baggy.css', 36 src: '<%= buildDir %>/baggy.css',
37 dest: '<%= buildDir %>/themes/baggy/css/style.min.css' 37 dest: '<%= buildDir %>/themes/baggy/css/style.min.css',
38 } 38 },
39 }, 39 },
40 concat: { 40 concat: {
41 options: { 41 options: {
42 separator: ';' 42 separator: ';',
43 }, 43 },
44 jsMaterial: { 44 jsMaterial: {
45 src: [ 45 src: [
46 'node_modules/jquery/dist/jquery.js', 46 '<%= appDir %>/themes/material/js/init.js',
47 'node_modules/jquery-ui/jquery-ui.js',
48 'node_modules/materialize-css/bin/materialize.js',
49 '<%= appDir %>/themes/_global/js/restoreScroll.js', 47 '<%= appDir %>/themes/_global/js/restoreScroll.js',
50 '<%= appDir %>/themes/material/js/init.js'
51 ], 48 ],
52 dest: '<%= buildDir %>/material.js' 49 dest: '<%= buildDir %>/material.js',
53 }, 50 },
54 jsBaggy: { 51 jsBaggy: {
55 src: [ 52 src: [
56 'node_modules/jquery/dist/jquery.js',
57 'node_modules/jquery-ui/jquery-ui.js',
58 '<%= appDir %>/themes/baggy/js/init.js', 53 '<%= appDir %>/themes/baggy/js/init.js',
59 '<%= appDir %>/themes/_global/js/restoreScroll.js', 54 '<%= appDir %>/themes/_global/js/restoreScroll.js',
60 '<%= appDir %>/themes/baggy/js/autoClose.js', 55 '<%= appDir %>/themes/baggy/js/autoClose.js',
61 '<%= appDir %>/themes/baggy/js/autoCompleteTags.js', 56 '<%= appDir %>/themes/baggy/js/autoCompleteTags.js',
62 '<%= appDir %>/themes/baggy/js/closeMessage.js', 57 '<%= appDir %>/themes/baggy/js/closeMessage.js',
63 '<%= appDir %>/themes/baggy/js/popupForm.js', 58 '<%= appDir %>/themes/baggy/js/popupForm.js',
64 '<%= appDir %>/themes/baggy/js/saveLink.js' 59 // Save link is no more used for now
60 // '<%= appDir %>/themes/baggy/js/saveLink.js',
65 ], 61 ],
66 dest: '<%= buildDir %>/baggy.js' 62 dest: '<%= buildDir %>/baggy.js',
67 }, 63 },
68 cssMaterial: { 64 cssMaterial: {
69 src: [ 65 src: [
70 'node_modules/materialize-css/bin/materialize.css', 66 'node_modules/materialize-css/bin/materialize.css',
71 '<%= appDir %>/themes/material/css/*.css' 67 '<%= appDir %>/themes/material/css/*.css',
72 ], 68 ],
73 dest: '<%= buildDir %>/material.css' 69 dest: '<%= buildDir %>/material.css',
74 }, 70 },
75 cssBaggy: { 71 cssBaggy: {
76 src: [ 72 src: [
77 '<%= appDir %>/themes/baggy/css/*.css' 73 '<%= appDir %>/themes/baggy/css/*.css',
78 ], 74 ],
79 dest: '<%= buildDir %>/baggy.css' 75 dest: '<%= buildDir %>/baggy.css',
80 } 76 },
81 }, 77 },
82 browserify: { 78 browserify: {
83 '<%= buildDir %>/material.browser.js': ['<%= buildDir %>/material.js'], 79 '<%= buildDir %>/material.browser.js': ['<%= buildDir %>/material.js'],
84 '<%= buildDir %>/baggy.browser.js': ['<%= buildDir %>/baggy.js'] 80 '<%= buildDir %>/baggy.browser.js': ['<%= buildDir %>/baggy.js'],
85 }, 81 },
86 uglify: { 82 uglify: {
87 material: { 83 material: {
88 files: { 84 files: {
89 '<%= buildDir %>/themes/material/js/material.min.js': 85 '<%= buildDir %>/themes/material/js/material.min.js':
90 ['<%= buildDir %>/material.browser.js'] 86 ['<%= buildDir %>/material.browser.js'],
91 }, 87 },
92 options: { 88 options: {
93 sourceMap: true, 89 sourceMap: true,
@@ -96,7 +92,7 @@ module.exports = function (grunt) {
96 baggy: { 92 baggy: {
97 files: { 93 files: {
98 '<%= buildDir %>/themes/baggy/js/baggy.min.js': 94 '<%= buildDir %>/themes/baggy/js/baggy.min.js':
99 ['<%= buildDir %>/baggy.browser.js'] 95 ['<%= buildDir %>/baggy.browser.js'],
100 }, 96 },
101 options: { 97 options: {
102 sourceMap: true, 98 sourceMap: true,
@@ -108,14 +104,14 @@ module.exports = function (grunt) {
108 expand: true, 104 expand: true,
109 cwd: 'node_modules/pickadate/lib', 105 cwd: 'node_modules/pickadate/lib',
110 src: 'picker.js', 106 src: 'picker.js',
111 dest: '<%= buildDir %>' 107 dest: '<%= buildDir %>',
112 }, 108 },
113 annotator: { 109 annotator: {
114 expand: true, 110 expand: true,
115 cwd: 'node_modules/annotator/pkg', 111 cwd: 'node_modules/annotator/pkg',
116 src: 'annotator.min.js', 112 src: 'annotator.min.js',
117 dest: '<%= buildDir %>/themes/_global/js/' 113 dest: '<%= buildDir %>/themes/_global/js/',
118 } 114 },
119 }, 115 },
120 symlink: { 116 symlink: {
121 baggyfonts: { 117 baggyfonts: {
@@ -123,50 +119,50 @@ module.exports = function (grunt) {
123 { 119 {
124 expand: true, 120 expand: true,
125 overwrite: true, 121 overwrite: true,
126 cwd: "<%= appDir %>/lib/icomoon-bower/", 122 cwd: '<%= appDir %>/lib/icomoon-bower/',
127 src: "fonts", 123 src: 'fonts',
128 dest: "<%= buildDir %>/themes/baggy/" 124 dest: '<%= buildDir %>/themes/baggy/',
129 }, 125 },
130 { 126 {
131 expand: true, 127 expand: true,
132 overwrite: true, 128 overwrite: true,
133 cwd: "<%= appDir %>/lib/bower-pt-sans/fonts", 129 cwd: '<%= appDir %>/lib/bower-pt-sans/fonts',
134 src: "*", 130 src: '*',
135 dest: "<%= buildDir %>/themes/baggy/fonts/" 131 dest: '<%= buildDir %>/themes/baggy/fonts/',
136 } 132 },
137 ] 133 ],
138 }, 134 },
139 materialfonts: { 135 materialfonts: {
140 files: [ 136 files: [
141 { 137 {
142 expand: true, 138 expand: true,
143 overwrite: true, 139 overwrite: true,
144 cwd: "<%= appDir %>/lib/icomoon-bower/", 140 cwd: '<%= appDir %>/lib/icomoon-bower/',
145 src: "fonts", 141 src: 'fonts',
146 dest: "<%= buildDir %>/themes/material/" 142 dest: '<%= buildDir %>/themes/material/',
147 }, 143 },
148 { 144 {
149 expand: true, 145 expand: true,
150 overwrite: true, 146 overwrite: true,
151 cwd: "node_modules/materialize-css/", 147 cwd: 'node_modules/materialize-css/',
152 src: "font", 148 src: 'font',
153 dest: "<%= buildDir %>/themes/material" 149 dest: '<%= buildDir %>/themes/material',
154 }, 150 },
155 { 151 {
156 expand: true, 152 expand: true,
157 overwrite: true, 153 overwrite: true,
158 cwd: "<%= appDir %>/lib/roboto-fontface/fonts/", 154 cwd: '<%= appDir %>/lib/roboto-fontface/fonts/',
159 src: "*", 155 src: '*',
160 dest: "<%= buildDir %>/themes/material/fonts/roboto/" 156 dest: '<%= buildDir %>/themes/material/fonts/roboto/',
161 }, 157 },
162 { 158 {
163 expand: true, 159 expand: true,
164 overwrite: true, 160 overwrite: true,
165 cwd: "<%= appDir %>/lib/material-design-icons/iconfont/", 161 cwd: '<%= appDir %>/lib/material-design-icons/iconfont/',
166 src: "*", 162 src: '*',
167 dest: "<%= buildDir %>/themes/material/fonts/" 163 dest: '<%= buildDir %>/themes/material/fonts/',
168 } 164 },
169 ] 165 ],
170 }, 166 },
171 pics: { 167 pics: {
172 files: [ 168 files: [
@@ -175,22 +171,22 @@ module.exports = function (grunt) {
175 overwrite: true, 171 overwrite: true,
176 cwd: '<%= appDir %>/themes/_global/', 172 cwd: '<%= appDir %>/themes/_global/',
177 src: 'img', 173 src: 'img',
178 dest: '<%= buildDir %>/themes/_global/' 174 dest: '<%= buildDir %>/themes/_global/',
179 } 175 },
180 ] 176 ],
181 } 177 },
182 }, 178 },
183 clean: { 179 clean: {
184 css: { 180 css: {
185 src: [ '<%= buildDir %>/**/*.css' ] 181 src: ['<%= buildDir %>/**/*.css'],
186 }, 182 },
187 js: { 183 js: {
188 src: ['<%= buildDir %>/**/*.js', '<%= buildDir %>/**/*.map'] 184 src: ['<%= buildDir %>/**/*.js', '<%= buildDir %>/**/*.map'],
189 }, 185 },
190 all: { 186 all: {
191 src: ['./<%= buildDir %>'] 187 src: ['./<%= buildDir %>'],
192 } 188 },
193 } 189 },
194 }); 190 });
195 191
196 grunt.registerTask( 192 grunt.registerTask(
@@ -216,4 +212,4 @@ module.exports = function (grunt) {
216 'Compiles the stylesheets.', 212 'Compiles the stylesheets.',
217 ['clean:css', 'concat:cssMaterial', 'concat:cssBaggy', 'postcss'] 213 ['clean:css', 'concat:cssMaterial', 'concat:cssBaggy', 'postcss']
218 ); 214 );
219} 215};
diff --git a/app/Resources/static/themes/_global/js/restoreScroll.js b/app/Resources/static/themes/_global/js/restoreScroll.js
index e63d06c6..9c4d7e20 100644
--- a/app/Resources/static/themes/_global/js/restoreScroll.js
+++ b/app/Resources/static/themes/_global/js/restoreScroll.js
@@ -1,25 +1,25 @@
1function supportsLocalStorage() { 1function supportsLocalStorage() {
2 try { 2 try {
3 return 'localStorage' in window && window['localStorage'] !== null; 3 return 'localStorage' in window && window.localStorage !== null;
4 } catch (e) { 4 } catch (e) {
5 return false; 5 return false;
6 } 6 }
7} 7}
8 8
9function savePercent(id, percent) { 9function savePercent(id, percent) {
10 if (!supportsLocalStorage()) { return false; } 10 if (!supportsLocalStorage()) { return false; }
11 localStorage["wallabag.article." + id + ".percent"] = percent; 11 localStorage['wallabag.article.' + id + '.percent'] = percent;
12 return true; 12 return true;
13} 13}
14 14
15function retrievePercent(id) { 15function retrievePercent(id) {
16 if (!supportsLocalStorage()) { return false; } 16 if (!supportsLocalStorage()) { return false; }
17 17
18 var bheight = $(document).height(); 18 var bheight = $(document).height();
19 var percent = localStorage["wallabag.article." + id + ".percent"]; 19 var percent = localStorage['wallabag.article.' + id + '.percent'];
20 var scroll = bheight * percent; 20 var scroll = bheight * percent;
21 21
22 $('html,body').animate({scrollTop: scroll}, 'fast'); 22 $('html,body').animate({ scrollTop: scroll }, 'fast');
23 23
24 return true; 24 return true;
25} 25}
diff --git a/app/Resources/static/themes/baggy/js/autoClose.js b/app/Resources/static/themes/baggy/js/autoClose.js
index e9145b7e..b0dafab2 100644
--- a/app/Resources/static/themes/baggy/js/autoClose.js
+++ b/app/Resources/static/themes/baggy/js/autoClose.js
@@ -1,6 +1,8 @@
1$(document).ready(function() { 1var $ = global.jquery = require('jquery');
2 current_url = window.location.href 2
3 if (current_url.match("&closewin=true")) { 3$(document).ready(function () {
4 window.close(); 4 var currentUrl = window.location.href;
5 } 5 if (currentUrl.match('&closewin=true')) {
6 window.close();
7 }
6}); 8});
diff --git a/app/Resources/static/themes/baggy/js/autoCompleteTags.js b/app/Resources/static/themes/baggy/js/autoCompleteTags.js
index 90bc982c..edd0a421 100755
--- a/app/Resources/static/themes/baggy/js/autoCompleteTags.js
+++ b/app/Resources/static/themes/baggy/js/autoCompleteTags.js
@@ -1,47 +1,46 @@
1jQuery(function($) { 1var $ = global.jquery = require('jquery');
2 2
3 function split( val ) { 3jQuery(function ($) {
4 return val.split( /,\s*/ ); 4 function split(val) {
5 return val.split(/,\s*/);
5 } 6 }
6 function extractLast( term ) { 7 function extractLast(term) {
7 return split( term ).pop(); 8 return split(term).pop();
8 } 9 }
9 10
10 11
11 $("#value").bind("keydown", function(event) { 12 $('#value').bind('keydown', function (event) {
12 if (event.keyCode === $.ui.keyCode.TAB && $(this).data("ui-autocomplete").menu.active) { 13 if (event.keyCode === $.ui.keyCode.TAB && $(this).data('ui-autocomplete').menu.active) {
13 event.preventDefault(); 14 event.preventDefault();
14 } 15 }
15 }).autocomplete({ 16 }).autocomplete({
16 source : function(request, response) { 17 source: function (request, response) {
17 $.getJSON("./?view=tags", { 18 $.getJSON('./?view=tags', {
18 term : extractLast(request.term), 19 term: extractLast(request.term),
19 //id: $(':hidden#entry_id').val() 20 //id: $(':hidden#entry_id').val()
20 }, response); 21 }, response);
21 }, 22 },
22 search : function() { 23 search: function () {
23 // custom minLength 24 // custom minLength
24 var term = extractLast(this.value); 25 var term = extractLast(this.value);
25 if (term.length < 1) { 26 if (term.length < 1) {
26 return false; 27 return false;
27 } 28 }
28 }, 29 },
29 focus : function() { 30 focus: function () {
30 // prevent value inserted on focus 31 // prevent value inserted on focus
31 return false; 32 return false;
32 }, 33 },
33 select : function(event, ui) { 34 select: function (event, ui) {
34 var terms = split(this.value); 35 var terms = split(this.value);
35 // remove the current input 36 // remove the current input
36 terms.pop(); 37 terms.pop();
37 // add the selected item 38 // add the selected item
38 terms.push(ui.item.value); 39 terms.push(ui.item.value);
39 // add placeholder to get the comma-and-space at the end 40 // add placeholder to get the comma-and-space at the end
40 terms.push(""); 41 terms.push('');
41 this.value = terms.join(", "); 42 this.value = terms.join(', ');
42 return false; 43 return false;
43 } 44 },
44 }); 45 });
45
46
47}); 46});
diff --git a/app/Resources/static/themes/baggy/js/closeMessage.js b/app/Resources/static/themes/baggy/js/closeMessage.js
index 527719d5..ae4b1791 100644
--- a/app/Resources/static/themes/baggy/js/closeMessage.js
+++ b/app/Resources/static/themes/baggy/js/closeMessage.js
@@ -1,17 +1,19 @@
1$(function(){ 1var $ = global.jquery = require('jquery');
2 //--------------------------------------------------------------------------- 2
3 // Show the close icon when the user hover over a message 3$(function () {
4 //--------------------------------------------------------------------------- 4 //---------------------------------------------------------------------------
5 // $('.messages').on('mouseenter', function(){ 5 // Show the close icon when the user hover over a message
6 // $(this).find('a.closeMessage').stop(true, true).show(); 6 //---------------------------------------------------------------------------
7 // }).on('mouseleave', function(){ 7 // $('.messages').on('mouseenter', function(){
8 // $(this).find('a.closeMessage').stop(true, true).hide(); 8 // $(this).find('a.closeMessage').stop(true, true).show();
9 // }); 9 // }).on('mouseleave', function(){
10 //--------------------------------------------------------------------------- 10 // $(this).find('a.closeMessage').stop(true, true).hide();
11 // Close the message box when the user clicks the close icon 11 // });
12 //--------------------------------------------------------------------------- 12 //---------------------------------------------------------------------------
13 $('a.closeMessage').on('click', function(){ 13 // Close the message box when the user clicks the close icon
14 $(this).parents('div.messages').slideUp(300, function(){ $(this).remove(); }); 14 //---------------------------------------------------------------------------
15 return false; 15 $('a.closeMessage').on('click', function () {
16 }); 16 $(this).parents('div.messages').slideUp(300, function () { $(this).remove(); });
17}); \ No newline at end of file 17 return false;
18 });
19});
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});
diff --git a/app/Resources/static/themes/baggy/js/popupForm.js b/app/Resources/static/themes/baggy/js/popupForm.js
index 0b478fad..95ba60ee 100644
--- a/app/Resources/static/themes/baggy/js/popupForm.js
+++ b/app/Resources/static/themes/baggy/js/popupForm.js
@@ -1,100 +1,101 @@
1$(document).ready(function() { 1var $ = global.jquery = require('jquery');
2 2
3 $("#search-form").hide(); 3$(document).ready(function () {
4 $("#bagit-form").hide(); 4 $('#search-form').hide();
5 $("#filter-form").hide(); 5 $('#bagit-form').hide();
6 $("#download-form").hide(); 6 $('#filter-form').hide();
7 $('#download-form').hide();
7 8
8 //--------------------------------------------------------------------------- 9 //---------------------------------------------------------------------------
9 // Toggle the "Search" popup in the sidebar 10 // Toggle the 'Search' popup in the sidebar
10 //--------------------------------------------------------------------------- 11 //---------------------------------------------------------------------------
11 function toggleSearch() { 12 function toggleSearch() {
12 $("#search-form").toggle(); 13 $('#search-form').toggle();
13 $("#search").toggleClass("current"); 14 $('#search').toggleClass('current');
14 $("#search").toggleClass("active-current"); 15 $('#search').toggleClass('active-current');
15 $("#search-arrow").toggleClass("arrow-down"); 16 $('#search-arrow').toggleClass('arrow-down');
16 if ($("#search").hasClass("current")) { 17 if ($('#search').hasClass('current')) {
17 $("#content").addClass("opacity03"); 18 $('#content').addClass('opacity03');
18 } else { 19 } else {
19 $("#content").removeClass("opacity03"); 20 $('#content').removeClass('opacity03');
20 }
21 } 21 }
22 }
22 23
23 //--------------------------------------------------------------------------- 24 //---------------------------------------------------------------------------
24 // Toggle the "Filter" popup on entries list 25 // Toggle the 'Filter' popup on entries list
25 //--------------------------------------------------------------------------- 26 //---------------------------------------------------------------------------
26 function toggleFilter() { 27 function toggleFilter() {
27 $("#filter-form").toggle(); 28 $('#filter-form').toggle();
28 } 29 }
29 30
30 //--------------------------------------------------------------------------- 31 //---------------------------------------------------------------------------
31 // Toggle the "Download" popup on entries list 32 // Toggle the 'Download' popup on entries list
32 //--------------------------------------------------------------------------- 33 //---------------------------------------------------------------------------
33 function toggleDownload() { 34 function toggleDownload() {
34 $("#download-form").toggle(); 35 $('#download-form').toggle();
35 } 36 }
36 37
37 //--------------------------------------------------------------------------- 38 //---------------------------------------------------------------------------
38 // Toggle the "Save a Link" popup in the sidebar 39 // Toggle the 'Save a Link' popup in the sidebar
39 //--------------------------------------------------------------------------- 40 //---------------------------------------------------------------------------
40 function toggleBagit() { 41 function toggleBagit() {
41 $("#bagit-form").toggle(); 42 $('#bagit-form').toggle();
42 $("#bagit").toggleClass("current"); 43 $('#bagit').toggleClass('current');
43 $("#bagit").toggleClass("active-current"); 44 $('#bagit').toggleClass('active-current');
44 $("#bagit-arrow").toggleClass("arrow-down"); 45 $('#bagit-arrow').toggleClass('arrow-down');
45 if ($("#bagit").hasClass("current")) { 46 if ($('#bagit').hasClass('current')) {
46 $("#content").addClass("opacity03"); 47 $('#content').addClass('opacity03');
47 } else { 48 } else {
48 $("#content").removeClass("opacity03"); 49 $('#content').removeClass('opacity03');
49 }
50 } 50 }
51 }
51 52
52 //--------------------------------------------------------------------------- 53 //---------------------------------------------------------------------------
53 // Close all #links popups in the sidebar 54 // Close all #links popups in the sidebar
54 //--------------------------------------------------------------------------- 55 //---------------------------------------------------------------------------
55 function closePopups() { 56 function closePopups() {
56 $("#links .messages").hide(); 57 $('#links .messages').hide();
57 $("#links > li > a").removeClass("active-current"); 58 $('#links > li > a').removeClass('active-current');
58 $("#links > li > a").removeClass("current"); 59 $('#links > li > a').removeClass('current');
59 $("[id$=-arrow]").removeClass("arrow-down"); 60 $('[id$=-arrow]').removeClass('arrow-down');
60 $("#content").removeClass("opacity03"); 61 $('#content').removeClass('opacity03');
61 } 62 }
62 63
63 $("#search").click(function(){ 64 $('#search').click(function () {
64 closePopups(); 65 closePopups();
65 toggleSearch(); 66 toggleSearch();
66 $("#searchfield").focus(); 67 $('#searchfield').focus();
67 }); 68 });
68 69
69 $(".filter-btn").click(function(){ 70 $('.filter-btn').click(function () {
70 closePopups(); 71 closePopups();
71 toggleFilter(); 72 toggleFilter();
72 }); 73 });
73 74
74 $(".download-btn").click(function(){ 75 $('.download-btn').click(function () {
75 closePopups(); 76 closePopups();
76 toggleDownload(); 77 toggleDownload();
77 }); 78 });
78 79
79 $("#bagit").click(function(){ 80 $('#bagit').click(function () {
80 closePopups(); 81 closePopups();
81 toggleBagit(); 82 toggleBagit();
82 $("#plainurl").focus(); 83 $('#plainurl').focus();
83 }); 84 });
84 85
85 $("#search-form-close").click(function(){ 86 $('#search-form-close').click(function () {
86 toggleSearch(); 87 toggleSearch();
87 }); 88 });
88 89
89 $("#filter-form-close").click(function(){ 90 $('#filter-form-close').click(function () {
90 toggleFilter(); 91 toggleFilter();
91 }); 92 });
92 93
93 $("#download-form-close").click(function(){ 94 $('#download-form-close').click(function () {
94 toggleDownload(); 95 toggleDownload();
95 }); 96 });
96 97
97 $("#bagit-form-close").click(function(){ 98 $('#bagit-form-close').click(function () {
98 toggleBagit(); 99 toggleBagit();
99 }); 100 });
100}); 101});
diff --git a/app/Resources/static/themes/baggy/js/saveLink.js b/app/Resources/static/themes/baggy/js/saveLink.js
index 91cc2c3f..5c720886 100755
--- a/app/Resources/static/themes/baggy/js/saveLink.js
+++ b/app/Resources/static/themes/baggy/js/saveLink.js
@@ -1,60 +1,60 @@
1$.fn.ready(function() { 1var $ = global.jquery = require('jquery');
2 2
3 var $bagit = $('#bagit'), 3$.fn.ready(function () {
4 $bagitForm = $('#bagit-form'), 4 var $bagit = $('#bagit');
5 $bagitFormForm = $('#bagit-form-form'); 5 var $bagitForm = $('#bagit-form');
6 var $bagitFormForm = $('#bagit-form-form');
6 7
7 /* ========================================================================== 8 /* ==========================================================================
8 bag it link and close button 9 bag it link and close button
9 ========================================================================== */ 10 ========================================================================== */
10 11
11 function toggleSaveLinkForm(url, event) { 12 function toggleSaveLinkForm(url, event) {
12 $("#add-link-result").empty(); 13 $('#add-link-result').empty();
13 14
14 $bagit.toggleClass("active-current"); 15 $bagit.toggleClass('active-current');
15 16
16 //only if bag-it link is not presented on page 17 // only if bag-it link is not presented on page
17 if ( $bagit.length === 0 ) { 18 if ($bagit.length === 0) {
18 if ( event !== 'undefined' && event ) { 19 if (event !== 'undefined' && event) {
19 $bagitForm.css( {position:"absolute", top:event.pageY, left:event.pageX-200}); 20 $bagitForm.css({ position: 'absolute', top: event.pageY, left: event.pageX - 200 });
20 } 21 } else {
21 else { 22 $bagitForm.css({ position: 'relative', top: 'auto', left: 'auto' });
22 $bagitForm.css( {position:"relative", top:"auto", left:"auto"});
23 } 23 }
24 } 24 }
25 25
26 if ($("#search-form").length != 0) { 26 if ($('#search-form').length !== 0) {
27 $("#search").removeClass("current"); 27 $('#search').removeClass('current');
28 $("#search-arrow").removeClass("arrow-down"); 28 $('#search-arrow').removeClass('arrow-down');
29 $("#search-form").hide(); 29 $('#search-form').hide();
30 } 30 }
31 $bagitForm.toggle(); 31 $bagitForm.toggle();
32 $('#content').toggleClass("opacity03"); 32 $('#content').toggleClass('opacity03');
33 if (url !== 'undefined' && url) { 33 if (url !== 'undefined' && url) {
34 $('#plainurl').val(url); 34 $('#plainurl').val(url);
35 } 35 }
36 $('#plainurl').focus(); 36 $('#plainurl').focus();
37 } 37 }
38 38
39 //send "bag it link" form request via ajax 39 // send 'bag it link' form request via ajax
40 $bagitFormForm.submit( function(event) { 40 $bagitFormForm.submit(function (event) {
41 $("body").css("cursor", "wait"); 41 $('body').css('cursor', 'wait');
42 $("#add-link-result").empty(); 42 $('#add-link-result').empty();
43 43
44 $.ajax({ 44 $.ajax({
45 type: $bagitFormForm.attr('method'), 45 type: $bagitFormForm.attr('method'),
46 url: $bagitFormForm.attr('action'), 46 url: $bagitFormForm.attr('action'),
47 data: $bagitFormForm.serialize(), 47 data: $bagitFormForm.serialize(),
48 success: function(data) { 48 success: function (data) {
49 $('#add-link-result').html("Done!"); 49 $('#add-link-result').html('Done!');
50 $('#plainurl').val(''); 50 $('#plainurl').val('');
51 $('#plainurl').blur(''); 51 $('#plainurl').blur('');
52 $("body").css("cursor", "auto"); 52 $('body').css('cursor', 'auto');
53 },
54 error: function (data) {
55 $('#add-link-result').html('Failed!');
56 $('body').css('cursor', 'auto');
53 }, 57 },
54 error: function(data) {
55 $('#add-link-result').html("Failed!");
56 $("body").css("cursor", "auto");
57 }
58 }); 58 });
59 59
60 event.preventDefault(); 60 event.preventDefault();
@@ -64,15 +64,12 @@ $.fn.ready(function() {
64 Process all links inside an article 64 Process all links inside an article
65 ========================================================================== */ 65 ========================================================================== */
66 66
67 $("article a[href^='http']").after(function() { 67 $('article a[href^="http"]').after(function () {
68 return " <a href=\"" + $(this).attr('href') + "\" class=\"add-to-wallabag-link-after\" alt=\"add to wallabag\" title=\"add to wallabag\"></a> "; 68 return ' <a href="' + $(this).attr('href') + '" class="add-to-wallabag-link-after" alt="add to wallabag" title="add to wallabag"></a> ';
69 }); 69 });
70 70
71 $(".add-to-wallabag-link-after").click(function(event){ 71 $('.add-to-wallabag-link-after').click(function (event) {
72 toggleSaveLinkForm($(this).attr('href'), event); 72 toggleSaveLinkForm($(this).attr('href'), event);
73 event.preventDefault(); 73 event.preventDefault();
74 }); 74 });
75
76}); 75});
77
78
diff --git a/app/Resources/static/themes/material/js/init.js b/app/Resources/static/themes/material/js/init.js
index 33019d3d..d6a87941 100755
--- a/app/Resources/static/themes/material/js/init.js
+++ b/app/Resources/static/themes/material/js/init.js
@@ -1,116 +1,117 @@
1var $ = require("jquery"), 1var $ = require('jquery');
2materialize = require("materialize"); 2require('materialize');
3var annotator = require('annotator'); 3var annotator = require('annotator');
4 4
5function init_filters() { 5function initFilters() {
6 // no display if filters not aviable 6 // no display if filters not aviable
7 if ($("div").is("#filters")) { 7 if ($('div').is('#filters')) {
8 $('#button_filters').show(); 8 $('#button_filters').show();
9 $('.button-collapse-right').sideNav({ edge: 'right' }); 9 $('.button-collapse-right').sideNav({ edge: 'right' });
10 $('#clear_form_filters').on('click', function(){ 10 $('#clear_form_filters').on('click', function () {
11 $('#filters input').val(''); 11 $('#filters input').val('');
12 $('#filters :checked').removeAttr('checked'); 12 $('#filters :checked').removeAttr('checked');
13 return false; 13 return false;
14 }); 14 });
15 } 15 }
16} 16}
17 17
18function init_export() { 18function initExport() {
19 // no display if export not aviable 19 // no display if export not aviable
20 if ($("div").is("#export")) { 20 if ($('div').is('#export')) {
21 $('#button_export').show(); 21 $('#button_export').show();
22 $('.button-collapse-right').sideNav({ edge: 'right' }); 22 $('.button-collapse-right').sideNav({ edge: 'right' });
23 } 23 }
24} 24}
25 25
26$(document).ready(function(){ 26$(document).ready(function () {
27 // sideNav 27 // sideNav
28 $('.button-collapse').sideNav(); 28 $('.button-collapse').sideNav();
29 $('select').material_select(); 29 $('select').material_select();
30 $('.collapsible').collapsible({ 30 $('.collapsible').collapsible({
31 accordion : false 31 accordion: false,
32 }); 32 });
33 $('.datepicker').pickadate({ 33 $('.datepicker').pickadate({
34 selectMonths: true, 34 selectMonths: true,
35 selectYears: 15, 35 selectYears: 15,
36 formatSubmit: 'dd/mm/yyyy', 36 formatSubmit: 'dd/mm/yyyy',
37 hiddenName: true, 37 hiddenName: true,
38 format: 'dd/mm/yyyy', 38 format: 'dd/mm/yyyy',
39 }); 39 });
40 init_filters(); 40 initFilters();
41 init_export(); 41 initExport();
42 42
43 $('#nav-btn-add-tag').on('click', function(){ 43 $('#nav-btn-add-tag').on('click', function () {
44 $(".nav-panel-add-tag").toggle(100); 44 $('.nav-panel-add-tag').toggle(100);
45 $(".nav-panel-menu").addClass('hidden'); 45 $('.nav-panel-menu').addClass('hidden');
46 $("#tag_label").focus(); 46 $('#tag_label').focus();
47 return false; 47 return false;
48 }); 48 });
49 $('#nav-btn-add').on('click', function(){ 49 $('#nav-btn-add').on('click', function () {
50 $(".nav-panel-buttom").hide(100); 50 $('.nav-panel-buttom').hide(100);
51 $(".nav-panel-add").show(100); 51 $('.nav-panel-add').show(100);
52 $(".nav-panels .action").hide(100); 52 $('.nav-panels .action').hide(100);
53 $(".nav-panel-menu").addClass('hidden'); 53 $('.nav-panel-menu').addClass('hidden');
54 $(".nav-panels").css('background', 'white'); 54 $('.nav-panels').css('background', 'white');
55 $("#entry_url").focus(); 55 $('#entry_url').focus();
56 return false; 56 return false;
57 }); 57 });
58 $('#nav-btn-search').on('click', function(){ 58 $('#nav-btn-search').on('click', function () {
59 $(".nav-panel-buttom").hide(100); 59 $('.nav-panel-buttom').hide(100);
60 $(".nav-panel-search").show(100); 60 $('.nav-panel-search').show(100);
61 $(".nav-panels .action").hide(100); 61 $('.nav-panels .action').hide(100);
62 $(".nav-panel-menu").addClass('hidden'); 62 $('.nav-panel-menu').addClass('hidden');
63 $(".nav-panels").css('background', 'white'); 63 $('.nav-panels').css('background', 'white');
64 $("#searchfield").focus(); 64 $('#searchfield').focus();
65 return false; 65 return false;
66 }); 66 });
67 $('.close').on('click', function(){ 67 $('.close').on('click', function () {
68 $(".nav-panel-add").hide(100); 68 $('.nav-panel-add').hide(100);
69 $(".nav-panel-search").hide(100); 69 $('.nav-panel-search').hide(100);
70 $(".nav-panel-buttom").show(100); 70 $('.nav-panel-buttom').show(100);
71 $(".nav-panels .action").show(100); 71 $('.nav-panels .action').show(100);
72 $(".nav-panel-menu").removeClass('hidden'); 72 $('.nav-panel-menu').removeClass('hidden');
73 $(".nav-panels").css('background', 'transparent'); 73 $('.nav-panels').css('background', 'transparent');
74 return false; 74 return false;
75 }); 75 });
76 $(window).scroll(function () { 76 $(window).scroll(function () {
77 var s = $(window).scrollTop(), 77 var s = $(window).scrollTop();
78 d = $(document).height(), 78 var d = $(document).height();
79 c = $(window).height(); 79 var c = $(window).height();
80 var scrollPercent = (s / (d-c)) * 100; 80 var scrollPercent = (s / (d - c)) * 100;
81 $(".progress .determinate").css('width', scrollPercent+'%'); 81 $('.progress .determinate').css('width', scrollPercent + '%');
82 }); 82 });
83
84/* ==========================================================================
85 Annotations & Remember position
86 ========================================================================== */
83 87
84 /* ========================================================================== 88 if ($('article').length) {
85 Annotations & Remember position 89 var app = new annotator.App();
86 ========================================================================== */ 90 var x = JSON.parse($('#annotationroutes').html());
87 91
88 if ($("article").length) {
89 var app = new annotator.App();
90 92
91 app.include(annotator.ui.main, { 93 app.include(annotator.ui.main, {
92 element: document.querySelector('article') 94 element: document.querySelector('article'),
93 }); 95 });
94 96
95 var x = JSON.parse($('#annotationroutes').html()); 97 app.include(annotator.storage.http, x);
96 app.include(annotator.storage.http, x);
97 98
98 app.start().then(function () { 99 app.start().then(function () {
99 app.annotations.load({entry: x.entryId}); 100 app.annotations.load({ entry: x.entryId });
100 }); 101 });
101 102
102 $(window).scroll(function(e){ 103 $(window).scroll(function (e) {
103 var scrollTop = $(window).scrollTop(); 104 var scrollTop = $(window).scrollTop();
104 var docHeight = $(document).height(); 105 var docHeight = $(document).height();
105 var scrollPercent = (scrollTop) / (docHeight); 106 var scrollPercent = (scrollTop) / (docHeight);
106 var scrollPercentRounded = Math.round(scrollPercent*100)/100; 107 var scrollPercentRounded = Math.round(scrollPercent * 100) / 100;
107 savePercent(x.entryId, scrollPercentRounded); 108 savePercent(x.entryId, scrollPercentRounded);
108 }); 109 });
109 110
110 retrievePercent(x.entryId); 111 retrievePercent(x.entryId);
111 112
112 $(window).resize(function(){ 113 $(window).resize(function () {
113 retrievePercent(x.entryId); 114 retrievePercent(x.entryId);
114 }); 115 });
115 } 116 }
116}); 117});
diff --git a/package.json b/package.json
index 603596ae..5d6306f0 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
1{ 1{
2 "name": "wallabag", 2 "name": "wallabag",
3 "version": "2.0.0", 3 "version": "2.1.0",
4 "description": "wallabag is a self hostable application for saving web pages", 4 "description": "wallabag is a self hostable application for saving web pages",
5 "main": "index.js", 5 "main": "index.js",
6 "private": true, 6 "private": true,
@@ -20,11 +20,9 @@
20 "grunt-contrib-clean": "^1.0.0", 20 "grunt-contrib-clean": "^1.0.0",
21 "grunt-contrib-concat": "^1.0.0", 21 "grunt-contrib-concat": "^1.0.0",
22 "grunt-contrib-copy": "^1.0.0", 22 "grunt-contrib-copy": "^1.0.0",
23 "grunt-contrib-cssmin": "^1.0.0",
24 "grunt-contrib-symlink": "^1.0.0", 23 "grunt-contrib-symlink": "^1.0.0",
25 "grunt-contrib-uglify": "^1.0.0", 24 "grunt-contrib-uglify": "^1.0.0",
26 "grunt-postcss": "^0.8.0", 25 "grunt-postcss": "^0.8.0",
27 "grunt-shell": "^1.2.1",
28 "hammerjs": "^2.0.6", 26 "hammerjs": "^2.0.6",
29 "jquery": "^2.2.1", 27 "jquery": "^2.2.1",
30 "jquery-ui": "^1.10.5", 28 "jquery-ui": "^1.10.5",
@@ -80,5 +78,9 @@
80 "license": "MIT", 78 "license": "MIT",
81 "bugs": { 79 "bugs": {
82 "url": "https://github.com/wallabag/wallabag/issues" 80 "url": "https://github.com/wallabag/wallabag/issues"
81 },
82 "devDependencies": {
83 "eslint": "^2.11.1",
84 "eslint-config-airbnb": "^9.0.1",
83 } 85 }
84} 86}