]>
git.immae.eu Git - github/wallabag/wallabag.git/blob - src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/saveLink.js
a7acd84c3e808969cac189ca5cf57d267cdba8d6
1 $.fn
.ready(function() {
3 var $bagit
= $('#bagit'),
4 $bagitForm
= $('#bagit-form'),
5 $bagitFormForm
= $('#bagit-form-form');
7 /* ==========================================================================
8 bag it link and close button
9 ========================================================================== */
11 function toggleSaveLinkForm(url
, event
) {
12 $("#add-link-result").empty();
14 $bagit
.toggleClass("active-current");
16 //only if bag-it link is not presented on page
17 if ( $bagit
.length
=== 0 ) {
18 if ( event
!== 'undefined' && event
) {
19 $bagitForm
.css( {position:"absolute", top:event
.pageY
, left:event
.pageX
-200});
22 $bagitForm
.css( {position:"relative", top:"auto", left:"auto"});
26 if ($("#search-form").length
!= 0) {
27 $("#search").removeClass("current");
28 $("#search-arrow").removeClass("arrow-down");
29 $("#search-form").hide();
32 $('#content').toggleClass("opacity03");
33 if (url
!== 'undefined' && url
) {
34 $('#plainurl').val(url
);
36 $('#plainurl').focus();
39 //---------------------------------------------------------------------------
40 // These two functions are now taken care of in popupForm.js
41 //---------------------------------------------------------------------------
43 // $bagit.click(function(){
44 // $bagit.toggleClass("current");
45 // $("#bagit-arrow").toggleClass("arrow-down");
46 // toggleSaveLinkForm();
49 // $("#bagit-form-close").click(function(){
50 // $bagit.removeClass("current");
51 // $("#bagit-arrow").removeClass("arrow-down");
52 // toggleSaveLinkForm();
56 //send "bag it link" form request via ajax
57 $bagitFormForm
.submit( function(event
) {
58 $("body").css("cursor", "wait");
59 $("#add-link-result").empty();
62 type: $bagitFormForm
.attr('method'),
63 url: $bagitFormForm
.attr('action'),
64 data: $bagitFormForm
.serialize(),
65 success: function(data
) {
66 $('#add-link-result').html("Done!");
67 $('#plainurl').val('');
68 $('#plainurl').blur('');
69 $("body").css("cursor", "auto");
70 //setTimeout( function() { toggleSaveLinkForm(); }, 1000); //close form after 1000 delay
72 error: function(data
) {
73 $('#add-link-result').html("Failed!");
74 $("body").css("cursor", "auto");
78 event
.preventDefault();
81 /* ==========================================================================
83 ========================================================================== */
85 $(window
).keydown(function(e
){
86 if ( ( e
.target
.tagName
.toLowerCase() !== 'input' && e
.keyCode
== 83 ) || (e
.keyCode
== 27 && $bagitForm
.is(':visible') ) ) {
87 $bagit
.removeClass("current");
88 $("#bagit-arrow").removeClass("arrow-down");
94 /* ==========================================================================
95 Process all links inside an article
96 ========================================================================== */
98 $("article a[href^='http']").after(function() {
99 return " <a href=\"" + $(this).attr('href') + "\" class=\"add-to-wallabag-link-after\" alt=\"add to wallabag\" title=\"add to wallabag\"></a> ";
102 $(".add-to-wallabag-link-after").click(function(event
){
103 toggleSaveLinkForm($(this).attr('href'), event
);
104 event
.preventDefault();