X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=themes%2Fbaggy%2Fjs%2Finit.js;h=4830bd25021237739e466a406b2148b57b7ab1a2;hb=6775da70a845a7fa8364dd3bc1a8e7702e9789bf;hp=99bffd09b20b30840c07cac757ba787a60120850;hpb=4744cb0e1df8ee7c1cd10c9fbd67caec73051024;p=github%2Fwallabag%2Fwallabag.git diff --git a/themes/baggy/js/init.js b/themes/baggy/js/init.js index 99bffd09..4830bd25 100755 --- a/themes/baggy/js/init.js +++ b/themes/baggy/js/init.js @@ -48,28 +48,58 @@ $.fn.ready(function() { } /* ========================================================================== - bag it link - ========================================================================== */ + bag it link and close button + ========================================================================== */ - $bagit.click(function(){ + function toggleSaveLinkForm(url) { + $bagit.toggleClass("active-current"); $bagitForm.toggle(); + $('#content').toggleClass("opacity03"); + if (url !== 'undefined' && url) { + $('#plainurl').val(url); + } + $('#plainurl').focus(); + } + + $bagit.click(function(){ + toggleSaveLinkForm(); + }); + + $("#bagit-form-close").click(function(){ + toggleSaveLinkForm(); + }); + + $('#bagit-form form').submit(function(){ + toggleSaveLinkForm(); + return true; }); /* ========================================================================== - Keyboard gestion - ========================================================================== */ + Keyboard gestion + ========================================================================== */ $(window).keydown(function(e){ - switch (e.keyCode) { - // s letter - case 83: - $bagitForm.toggle(); - break; - case 27: - $bagitForm.hide(); - break; + if ( ( e.target.tagName.toLowerCase() !== 'input' && e.keyCode == 83 ) || e.keyCode == 27 ) { + toggleSaveLinkForm(); + return false; } - }) + }); + + /* ========================================================================== + Process all links inside an article + ========================================================================== */ + + $("article a[href^='http']").after(function() { + return " w "; + }); + + $(".add-to-wallabag-link-after").click(function(event){ + event.preventDefault(); + toggleSaveLinkForm($(this).attr('href')); + return false; + }); + + -}); \ No newline at end of file +});