diff options
Diffstat (limited to 'themes/baggy/js/init.js')
-rwxr-xr-x | themes/baggy/js/init.js | 61 |
1 files changed, 44 insertions, 17 deletions
diff --git a/themes/baggy/js/init.js b/themes/baggy/js/init.js index 4e85beaa..4830bd25 100755 --- a/themes/baggy/js/init.js +++ b/themes/baggy/js/init.js | |||
@@ -48,31 +48,58 @@ $.fn.ready(function() { | |||
48 | } | 48 | } |
49 | 49 | ||
50 | /* ========================================================================== | 50 | /* ========================================================================== |
51 | bag it link | 51 | bag it link and close button |
52 | ========================================================================== */ | 52 | ========================================================================== */ |
53 | 53 | ||
54 | $bagit.click(function(){ | 54 | function toggleSaveLinkForm(url) { |
55 | $bagit.toggleClass("active-current"); | ||
55 | $bagitForm.toggle(); | 56 | $bagitForm.toggle(); |
57 | $('#content').toggleClass("opacity03"); | ||
58 | if (url !== 'undefined' && url) { | ||
59 | $('#plainurl').val(url); | ||
60 | } | ||
61 | $('#plainurl').focus(); | ||
62 | } | ||
63 | |||
64 | $bagit.click(function(){ | ||
65 | toggleSaveLinkForm(); | ||
66 | }); | ||
67 | |||
68 | $("#bagit-form-close").click(function(){ | ||
69 | toggleSaveLinkForm(); | ||
70 | }); | ||
71 | |||
72 | $('#bagit-form form').submit(function(){ | ||
73 | toggleSaveLinkForm(); | ||
74 | return true; | ||
56 | }); | 75 | }); |
57 | 76 | ||
58 | /* ========================================================================== | 77 | /* ========================================================================== |
59 | Keyboard gestion | 78 | Keyboard gestion |
60 | ========================================================================== */ | 79 | ========================================================================== */ |
61 | 80 | ||
62 | $(window).keydown(function(e){ | 81 | $(window).keydown(function(e){ |
63 | if ( e.target.tagName.toLowerCase() !== 'input' ) { | 82 | if ( ( e.target.tagName.toLowerCase() !== 'input' && e.keyCode == 83 ) || e.keyCode == 27 ) { |
64 | switch (e.keyCode) { | 83 | toggleSaveLinkForm(); |
65 | // s letter | 84 | return false; |
66 | case 83: | ||
67 | $bagitForm.toggle(); | ||
68 | return false; | ||
69 | break; | ||
70 | case 27: | ||
71 | $bagitForm.hide(); | ||
72 | break; | ||
73 | } | ||
74 | } | 85 | } |
75 | }) | 86 | }); |
87 | |||
88 | /* ========================================================================== | ||
89 | Process all links inside an article | ||
90 | ========================================================================== */ | ||
91 | |||
92 | $("article a[href^='http']").after(function() { | ||
93 | return " <a href=\"" + $(this).attr('href') + "\" class=\"add-to-wallabag-link-after\" alt=\"add to wallabag\" title=\"add to wallabag\">w</a> "; | ||
94 | }); | ||
95 | |||
96 | $(".add-to-wallabag-link-after").click(function(event){ | ||
97 | event.preventDefault(); | ||
98 | toggleSaveLinkForm($(this).attr('href')); | ||
99 | return false; | ||
100 | }); | ||
101 | |||
102 | |||
76 | 103 | ||
77 | 104 | ||
78 | }); | 105 | }); |