diff options
Diffstat (limited to 'themes/default/js/saveLink.js')
-rwxr-xr-x | themes/default/js/saveLink.js | 106 |
1 files changed, 0 insertions, 106 deletions
diff --git a/themes/default/js/saveLink.js b/themes/default/js/saveLink.js deleted file mode 100755 index b52b8a2c..00000000 --- a/themes/default/js/saveLink.js +++ /dev/null | |||
@@ -1,106 +0,0 @@ | |||
1 | $.fn.ready(function() { | ||
2 | |||
3 | var $bagit = $('#bagit'), | ||
4 | $bagitForm = $('#bagit-form'), | ||
5 | $bagitFormForm = $('#bagit-form-form'); | ||
6 | |||
7 | /* ========================================================================== | ||
8 | bag it link and close button | ||
9 | ========================================================================== */ | ||
10 | |||
11 | function toggleSaveLinkForm(url, event) { | ||
12 | $("#add-link-result").empty(); | ||
13 | |||
14 | $bagit.toggleClass("active-current"); | ||
15 | |||
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}); | ||
20 | } | ||
21 | else { | ||
22 | $bagitForm.css( {position:"relative", top:"auto", left:"auto"}); | ||
23 | } | ||
24 | } | ||
25 | |||
26 | if ($("#search-form").length != 0) { | ||
27 | $("#search").removeClass("current"); | ||
28 | $("#search-arrow").removeClass("arrow-down"); | ||
29 | $("#search-form").hide(); | ||
30 | } | ||
31 | $bagitForm.toggle(); | ||
32 | $('#content').toggleClass("opacity03"); | ||
33 | if (url !== 'undefined' && url) { | ||
34 | $('#plainurl').val(url); | ||
35 | } | ||
36 | $('#plainurl').focus(); | ||
37 | } | ||
38 | |||
39 | |||
40 | $bagit.click(function(){ | ||
41 | $bagit.toggleClass("current"); | ||
42 | $("#bagit-arrow").toggleClass("arrow-down"); | ||
43 | toggleSaveLinkForm(); | ||
44 | }); | ||
45 | |||
46 | $("#bagit-form-close").click(function(){ | ||
47 | $bagit.removeClass("current"); | ||
48 | $("#bagit-arrow").removeClass("arrow-down"); | ||
49 | toggleSaveLinkForm(); | ||
50 | }); | ||
51 | |||
52 | |||
53 | //send "bag it link" form request via ajax | ||
54 | $bagitFormForm.submit( function(event) { | ||
55 | $("body").css("cursor", "wait"); | ||
56 | $("#add-link-result").empty(); | ||
57 | |||
58 | $.ajax({ | ||
59 | type: $bagitFormForm.attr('method'), | ||
60 | url: $bagitFormForm.attr('action'), | ||
61 | data: $bagitFormForm.serialize(), | ||
62 | success: function(data) { | ||
63 | $('#add-link-result').html("Done!"); | ||
64 | $('#plainurl').val(''); | ||
65 | $('#plainurl').blur(''); | ||
66 | $("body").css("cursor", "auto"); | ||
67 | //setTimeout( function() { toggleSaveLinkForm(); }, 1000); //close form after 1000 delay | ||
68 | }, | ||
69 | error: function(data) { | ||
70 | $('#add-link-result').html("Failed!"); | ||
71 | $("body").css("cursor", "auto"); | ||
72 | } | ||
73 | }); | ||
74 | |||
75 | event.preventDefault(); | ||
76 | }); | ||
77 | |||
78 | /* ========================================================================== | ||
79 | Keyboard gestion | ||
80 | ========================================================================== */ | ||
81 | |||
82 | $(window).keydown(function(e){ | ||
83 | if ( ( e.target.tagName.toLowerCase() !== 'input' && e.keyCode == 83 ) || (e.keyCode == 27 && $bagitForm.is(':visible') ) ) { | ||
84 | $bagit.removeClass("current"); | ||
85 | $("#bagit-arrow").removeClass("arrow-down"); | ||
86 | toggleSaveLinkForm(); | ||
87 | return false; | ||
88 | } | ||
89 | }); | ||
90 | |||
91 | /* ========================================================================== | ||
92 | Process all links inside an article | ||
93 | ========================================================================== */ | ||
94 | |||
95 | $("article a[href^='http']").after(function() { | ||
96 | return " <a href=\"" + $(this).attr('href') + "\" class=\"add-to-wallabag-link-after\" alt=\"add to wallabag\" title=\"add to wallabag\"></a> "; | ||
97 | }); | ||
98 | |||
99 | $(".add-to-wallabag-link-after").click(function(event){ | ||
100 | toggleSaveLinkForm($(this).attr('href'), event); | ||
101 | event.preventDefault(); | ||
102 | }); | ||
103 | |||
104 | }); | ||
105 | |||
106 | |||