]>
git.immae.eu Git - github/wallabag/wallabag.git/blob - app/Resources/static/themes/baggy/js/saveLink.js
1 var $ = global
.jquery
= require('jquery');
3 $.fn
.ready(function () {
4 var $bagit
= $('#bagit');
5 var $bagitForm
= $('#bagit-form');
6 var $bagitFormForm
= $('#bagit-form-form');
8 /* ==========================================================================
9 bag it link and close button
10 ========================================================================== */
12 function toggleSaveLinkForm(url
, event
) {
13 $('#add-link-result').empty();
15 $bagit
.toggleClass('active-current');
17 // only if bag-it link is not presented on page
18 if ($bagit
.length
=== 0) {
19 if (event
!== 'undefined' && event
) {
20 $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 // send 'bag it link' form request via ajax
40 $bagitFormForm
.submit(function (event
) {
41 $('body').css('cursor', 'wait');
42 $('#add-link-result').empty();
45 type: $bagitFormForm
.attr('method'),
46 url: $bagitFormForm
.attr('action'),
47 data: $bagitFormForm
.serialize(),
48 success: function (data
) {
49 $('#add-link-result').html('Done!');
50 $('#plainurl').val('');
51 $('#plainurl').blur('');
52 $('body').css('cursor', 'auto');
54 error: function (data
) {
55 $('#add-link-result').html('Failed!');
56 $('body').css('cursor', 'auto');
60 event
.preventDefault();
63 /* ==========================================================================
64 Process all links inside an article
65 ========================================================================== */
67 $('article a[href^="http"]').after(function () {
68 return ' <a href="' + $(this).attr('href') + '" class="add-to-wallabag-link-after" alt="add to wallabag" title="add to wallabag"></a> ';
71 $('.add-to-wallabag-link-after').click(function (event
) {
72 toggleSaveLinkForm($(this).attr('href'), event
);
73 event
.preventDefault();