]>
git.immae.eu Git - github/wallabag/wallabag.git/blob - themes/default/js/saveLink.js
bee453c09f9bce6f926d69800469a313fbcd5a1c
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 bagiti 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"});
27 $('#content').toggleClass("opacity03");
28 if (url
!== 'undefined' && url
) {
29 $('#plainurl').val(url
);
31 $('#plainurl').focus();
35 $bagit
.click(function(){
36 $bagit
.toggleClass("current");
37 $("#bagit-arrow").toggleClass("arrow-down");
41 $("#bagit-form-close").click(function(){
42 $bagit
.removeClass("current");
43 $("#bagit-arrow").removeClass("arrow-down");
48 //send "bag it link" form request via ajax
49 $bagitFormForm
.submit( function(event
) {
50 $("body").css("cursor", "wait");
51 $("#add-link-result").empty();
54 type: $bagitFormForm
.attr('method'),
55 url: $bagitFormForm
.attr('action'),
56 data: $bagitFormForm
.serialize(),
57 success: function(data
) {
58 $('#add-link-result').html("Done!");
59 $('#plainurl').val('');
60 $('#plainurl').blur('');
61 $("body").css("cursor", "auto");
62 //setTimeout( function() { toggleSaveLinkForm(); }, 1000); //close form after 1000 delay
64 error: function(data
) {
65 $('#add-link-result').html("Failed!");
66 $("body").css("cursor", "auto");
70 event
.preventDefault();
73 /* ==========================================================================
75 ========================================================================== */
77 $(window
).keydown(function(e
){
78 if ( ( e
.target
.tagName
.toLowerCase() !== 'input' && e
.keyCode
== 83 ) || (e
.keyCode
== 27 && $bagitForm
.is(':visible') ) ) {
79 $bagit
.removeClass("current");
80 $("#bagit-arrow").removeClass("arrow-down");
86 /* ==========================================================================
87 Process all links inside an article
88 ========================================================================== */
90 $("article a[href^='http']").after(function() {
91 return " <a href=\"" + $(this).attr('href') + "\" class=\"add-to-wallabag-link-after\" alt=\"add to wallabag\" title=\"add to wallabag\">w</a> ";
94 $(".add-to-wallabag-link-after").click(function(event
){
95 toggleSaveLinkForm($(this).attr('href'), event
);
96 event
.preventDefault();