]>
git.immae.eu Git - github/wallabag/wallabag.git/blob - themes/_global/js/saveLink.js
1 $.fn
.ready(function() {
3 var $bagit
= $('#bagit'),
4 $bagitForm
= $('#bagit-form'),
5 $bagitFormForm
= $('#bagit-form-form');
9 /* ==========================================================================
10 bag it link and close button
11 ========================================================================== */
13 function toggleSaveLinkForm(url
, event
) {
14 $("#add-link-result").empty();
16 $bagit
.toggleClass("active-current");
18 //only if bag-it link is not presented on page
19 if ( $bagit
.length
=== 0 ) {
20 if ( event
!== 'undefined' && event
) {
21 $bagitForm
.css( {position:"absolute", top:event
.pageY
, left:event
.pageX
-200});
24 $bagitForm
.css( {position:"relative", top:"auto", left:"auto"});
28 if ($("#search-form").length
!= 0) {
29 $("#search").removeClass("current");
30 $("#search-arrow").removeClass("arrow-down");
31 $("#search-form").hide();
34 $('#content').toggleClass("opacity03");
35 if (url
!== 'undefined' && url
) {
36 $('#plainurl').val(url
);
38 $('#plainurl').focus();
41 //---------------------------------------------------------------------------
42 // These two functions are now taken care of in popupForm.js
43 //---------------------------------------------------------------------------
45 // $bagit.click(function(){
46 // $bagit.toggleClass("current");
47 // $("#bagit-arrow").toggleClass("arrow-down");
48 // toggleSaveLinkForm();
51 // $("#bagit-form-close").click(function(){
52 // $bagit.removeClass("current");
53 // $("#bagit-arrow").removeClass("arrow-down");
54 // toggleSaveLinkForm();
58 //send "bag it link" form request via ajax
59 $bagitFormForm
.submit( function(event
) {
60 $("body").css("cursor", "wait");
61 $("#add-link-result").empty();
64 type: $bagitFormForm
.attr('method'),
65 url: $bagitFormForm
.attr('action'),
66 data: $bagitFormForm
.serialize(),
67 success: function(data
) {
68 $('#add-link-result').html("Done!");
69 $('#plainurl').val('');
70 $('#plainurl').blur('');
71 $("body").css("cursor", "auto");
72 //setTimeout( function() { toggleSaveLinkForm(); }, 1000); //close form after 1000 delay
74 error: function(data
) {
75 $('#add-link-result').html("Failed!");
76 $("body").css("cursor", "auto");
80 event
.preventDefault();
83 $('#showtaginput').click(function(){
84 $('#tags2add').toggle();
88 /* ==========================================================================
90 ========================================================================== */
92 $(window
).keydown(function(e
){
93 if ( ( e
.target
.tagName
.toLowerCase() !== 'input' && e
.keyCode
== 83 ) || (e
.keyCode
== 27 && $bagitForm
.is(':visible') ) ) {
94 $bagit
.removeClass("current");
95 $("#bagit-arrow").removeClass("arrow-down");
101 /* ==========================================================================
102 Process all links inside an article
103 ========================================================================== */
105 $("article a[href^='http']").after(function() {
106 return " <a href=\"" + $(this).attr('href') + "\" class=\"add-to-wallabag-link-after\" alt=\"add to wallabag\" title=\"add to wallabag\"></a> ";
109 $(".add-to-wallabag-link-after").click(function(event
){
110 toggleSaveLinkForm($(this).attr('href'), event
);
111 event
.preventDefault();