From 30d81a47c689e1d7d963fcd3fd42af9958805e31 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Fri, 22 Jan 2016 13:45:10 +0100 Subject: Move public assets for themes So they can be installed using the `assets:install` command and there'll no longer symlink in the repo They moved from `web/themes/...` to `bundles/wallabagcore/themes/...` --- .../Resources/public/themes/baggy/js/saveLink.js | 109 +++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100755 src/Wallabag/CoreBundle/Resources/public/themes/baggy/js/saveLink.js (limited to 'src/Wallabag/CoreBundle/Resources/public/themes/baggy/js/saveLink.js') diff --git a/src/Wallabag/CoreBundle/Resources/public/themes/baggy/js/saveLink.js b/src/Wallabag/CoreBundle/Resources/public/themes/baggy/js/saveLink.js new file mode 100755 index 00000000..a7acd84c --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/public/themes/baggy/js/saveLink.js @@ -0,0 +1,109 @@ +$.fn.ready(function() { + + var $bagit = $('#bagit'), + $bagitForm = $('#bagit-form'), + $bagitFormForm = $('#bagit-form-form'); + + /* ========================================================================== + bag it link and close button + ========================================================================== */ + + function toggleSaveLinkForm(url, event) { + $("#add-link-result").empty(); + + $bagit.toggleClass("active-current"); + + //only if bag-it link is not presented on page + if ( $bagit.length === 0 ) { + if ( event !== 'undefined' && event ) { + $bagitForm.css( {position:"absolute", top:event.pageY, left:event.pageX-200}); + } + else { + $bagitForm.css( {position:"relative", top:"auto", left:"auto"}); + } + } + + if ($("#search-form").length != 0) { + $("#search").removeClass("current"); + $("#search-arrow").removeClass("arrow-down"); + $("#search-form").hide(); + } + $bagitForm.toggle(); + $('#content').toggleClass("opacity03"); + if (url !== 'undefined' && url) { + $('#plainurl').val(url); + } + $('#plainurl').focus(); + } + + //--------------------------------------------------------------------------- + // These two functions are now taken care of in popupForm.js + //--------------------------------------------------------------------------- + + // $bagit.click(function(){ + // $bagit.toggleClass("current"); + // $("#bagit-arrow").toggleClass("arrow-down"); + // toggleSaveLinkForm(); + // }); + + // $("#bagit-form-close").click(function(){ + // $bagit.removeClass("current"); + // $("#bagit-arrow").removeClass("arrow-down"); + // toggleSaveLinkForm(); + // }); + + + //send "bag it link" form request via ajax + $bagitFormForm.submit( function(event) { + $("body").css("cursor", "wait"); + $("#add-link-result").empty(); + + $.ajax({ + type: $bagitFormForm.attr('method'), + url: $bagitFormForm.attr('action'), + data: $bagitFormForm.serialize(), + success: function(data) { + $('#add-link-result').html("Done!"); + $('#plainurl').val(''); + $('#plainurl').blur(''); + $("body").css("cursor", "auto"); + //setTimeout( function() { toggleSaveLinkForm(); }, 1000); //close form after 1000 delay + }, + error: function(data) { + $('#add-link-result').html("Failed!"); + $("body").css("cursor", "auto"); + } + }); + + event.preventDefault(); + }); + + /* ========================================================================== + Keyboard gestion + ========================================================================== */ + + $(window).keydown(function(e){ + if ( ( e.target.tagName.toLowerCase() !== 'input' && e.keyCode == 83 ) || (e.keyCode == 27 && $bagitForm.is(':visible') ) ) { + $bagit.removeClass("current"); + $("#bagit-arrow").removeClass("arrow-down"); + toggleSaveLinkForm(); + return false; + } + }); + + /* ========================================================================== + Process all links inside an article + ========================================================================== */ + + $("article a[href^='http']").after(function() { + return " "; + }); + + $(".add-to-wallabag-link-after").click(function(event){ + toggleSaveLinkForm($(this).attr('href'), event); + event.preventDefault(); + }); + +}); + + -- cgit v1.2.3