aboutsummaryrefslogtreecommitdiffhomepage
path: root/themes/baggy/public/js
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2015-01-20 14:11:26 +0100
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2015-01-20 14:11:26 +0100
commit79e051a1f216704752e05f5174633abf20dde582 (patch)
treee55b7f46aad7c8df42534e638b25cdbc258a3c40 /themes/baggy/public/js
parent97a2dd74c872891b694bff0485a0fcc9a82a09e4 (diff)
downloadwallabag-79e051a1f216704752e05f5174633abf20dde582.tar.gz
wallabag-79e051a1f216704752e05f5174633abf20dde582.tar.zst
wallabag-79e051a1f216704752e05f5174633abf20dde582.zip
restructure folders
Diffstat (limited to 'themes/baggy/public/js')
-rw-r--r--themes/baggy/public/js/closeMessage.js17
-rwxr-xr-xthemes/baggy/public/js/init.js51
-rwxr-xr-xthemes/baggy/public/js/jquery.cookie.js117
-rw-r--r--themes/baggy/public/js/restoreScroll.js25
4 files changed, 210 insertions, 0 deletions
diff --git a/themes/baggy/public/js/closeMessage.js b/themes/baggy/public/js/closeMessage.js
new file mode 100644
index 00000000..527719d5
--- /dev/null
+++ b/themes/baggy/public/js/closeMessage.js
@@ -0,0 +1,17 @@
1$(function(){
2 //---------------------------------------------------------------------------
3 // Show the close icon when the user hover over a message
4 //---------------------------------------------------------------------------
5 // $('.messages').on('mouseenter', function(){
6 // $(this).find('a.closeMessage').stop(true, true).show();
7 // }).on('mouseleave', function(){
8 // $(this).find('a.closeMessage').stop(true, true).hide();
9 // });
10 //---------------------------------------------------------------------------
11 // Close the message box when the user clicks the close icon
12 //---------------------------------------------------------------------------
13 $('a.closeMessage').on('click', function(){
14 $(this).parents('div.messages').slideUp(300, function(){ $(this).remove(); });
15 return false;
16 });
17}); \ No newline at end of file
diff --git a/themes/baggy/public/js/init.js b/themes/baggy/public/js/init.js
new file mode 100755
index 00000000..74cbae68
--- /dev/null
+++ b/themes/baggy/public/js/init.js
@@ -0,0 +1,51 @@
1$.fn.ready(function() {
2
3 var $listmode = $('#listmode'),
4 $listentries = $("#list-entries");
5
6 /* ==========================================================================
7 Menu
8 ========================================================================== */
9
10 $("#menu").click(function(){
11 $("#links").toggleClass('menu--open');
12 if ($('#content').hasClass('opacity03')) {
13 $('#content').removeClass('opacity03');
14 }
15 });
16
17 /* ==========================================================================
18 List mode or Table Mode
19 ========================================================================== */
20
21 $listmode.click(function(){
22 if ( $.cookie("listmode") == 1 ) {
23 // Cookie
24 $.removeCookie("listmode");
25
26 $listentries.removeClass("listmode");
27 $listmode.removeClass("tablemode");
28 $listmode.addClass("listmode");
29 }
30 else {
31 // Cookie
32 $.cookie("listmode", 1, {expires: 365});
33
34 $listentries.addClass("listmode");
35 $listmode.removeClass("listmode");
36 $listmode.addClass("tablemode");
37 }
38
39 });
40
41 /* ==========================================================================
42 Cookie listmode
43 ========================================================================== */
44
45 if ( $.cookie("listmode") == 1 ) {
46 $listentries.addClass("listmode");
47 $listmode.removeClass("listmode");
48 $listmode.addClass("tablemode");
49 }
50
51});
diff --git a/themes/baggy/public/js/jquery.cookie.js b/themes/baggy/public/js/jquery.cookie.js
new file mode 100755
index 00000000..92719000
--- /dev/null
+++ b/themes/baggy/public/js/jquery.cookie.js
@@ -0,0 +1,117 @@
1/*!
2 * jQuery Cookie Plugin v1.4.0
3 * https://github.com/carhartl/jquery-cookie
4 *
5 * Copyright 2013 Klaus Hartl
6 * Released under the MIT license
7 */
8(function (factory) {
9 if (typeof define === 'function' && define.amd) {
10 // AMD. Register as anonymous module.
11 define(['jquery'], factory);
12 } else {
13 // Browser globals.
14 factory(jQuery);
15 }
16}(function ($) {
17
18 var pluses = /\+/g;
19
20 function encode(s) {
21 return config.raw ? s : encodeURIComponent(s);
22 }
23
24 function decode(s) {
25 return config.raw ? s : decodeURIComponent(s);
26 }
27
28 function stringifyCookieValue(value) {
29 return encode(config.json ? JSON.stringify(value) : String(value));
30 }
31
32 function parseCookieValue(s) {
33 if (s.indexOf('"') === 0) {
34 // This is a quoted cookie as according to RFC2068, unescape...
35 s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
36 }
37
38 try {
39 // Replace server-side written pluses with spaces.
40 // If we can't decode the cookie, ignore it, it's unusable.
41 s = decodeURIComponent(s.replace(pluses, ' '));
42 } catch(e) {
43 return;
44 }
45
46 try {
47 // If we can't parse the cookie, ignore it, it's unusable.
48 return config.json ? JSON.parse(s) : s;
49 } catch(e) {}
50 }
51
52 function read(s, converter) {
53 var value = config.raw ? s : parseCookieValue(s);
54 return $.isFunction(converter) ? converter(value) : value;
55 }
56
57 var config = $.cookie = function (key, value, options) {
58
59 // Write
60 if (value !== undefined && !$.isFunction(value)) {
61 options = $.extend({}, config.defaults, options);
62
63 if (typeof options.expires === 'number') {
64 var days = options.expires, t = options.expires = new Date();
65 t.setDate(t.getDate() + days);
66 }
67
68 return (document.cookie = [
69 encode(key), '=', stringifyCookieValue(value),
70 options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
71 options.path ? '; path=' + options.path : '',
72 options.domain ? '; domain=' + options.domain : '',
73 options.secure ? '; secure' : ''
74 ].join(''));
75 }
76
77 // Read
78
79 var result = key ? undefined : {};
80
81 // To prevent the for loop in the first place assign an empty array
82 // in case there are no cookies at all. Also prevents odd result when
83 // calling $.cookie().
84 var cookies = document.cookie ? document.cookie.split('; ') : [];
85
86 for (var i = 0, l = cookies.length; i < l; i++) {
87 var parts = cookies[i].split('=');
88 var name = decode(parts.shift());
89 var cookie = parts.join('=');
90
91 if (key && key === name) {
92 // If second argument (value) is a function it's a converter...
93 result = read(cookie, value);
94 break;
95 }
96
97 // Prevent storing a cookie that we couldn't decode.
98 if (!key && (cookie = read(cookie)) !== undefined) {
99 result[name] = cookie;
100 }
101 }
102
103 return result;
104 };
105
106 config.defaults = {};
107
108 $.removeCookie = function (key, options) {
109 if ($.cookie(key) !== undefined) {
110 // Must not alter options, thus extending a fresh object...
111 $.cookie(key, '', $.extend({}, options, { expires: -1 }));
112 return true;
113 }
114 return false;
115 };
116
117}));
diff --git a/themes/baggy/public/js/restoreScroll.js b/themes/baggy/public/js/restoreScroll.js
new file mode 100644
index 00000000..331c9e19
--- /dev/null
+++ b/themes/baggy/public/js/restoreScroll.js
@@ -0,0 +1,25 @@
1function supportsLocalStorage() {
2 try {
3 return 'localStorage' in window && window['localStorage'] !== null;
4 } catch (e) {
5 return false;
6 }
7}
8
9function savePercent(id, percent) {
10 if (!supportsLocalStorage()) { return false; }
11 localStorage["poche.article." + id + ".percent"] = percent;
12 return true;
13}
14
15function retrievePercent(id) {
16 if (!supportsLocalStorage()) { return false; }
17
18 var bheight = $(document).height();
19 var percent = localStorage["poche.article." + id + ".percent"];
20 var scroll = bheight * percent;
21
22 $('html,body').animate({scrollTop: scroll}, 'fast');
23
24 return true;
25} \ No newline at end of file