aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/Resources/static/themes/baggy/js/saveLink.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/Resources/static/themes/baggy/js/saveLink.js')
-rwxr-xr-xapp/Resources/static/themes/baggy/js/saveLink.js67
1 files changed, 32 insertions, 35 deletions
diff --git a/app/Resources/static/themes/baggy/js/saveLink.js b/app/Resources/static/themes/baggy/js/saveLink.js
index 91cc2c3f..5c720886 100755
--- a/app/Resources/static/themes/baggy/js/saveLink.js
+++ b/app/Resources/static/themes/baggy/js/saveLink.js
@@ -1,60 +1,60 @@
1$.fn.ready(function() { 1var $ = global.jquery = require('jquery');
2 2
3 var $bagit = $('#bagit'), 3$.fn.ready(function () {
4 $bagitForm = $('#bagit-form'), 4 var $bagit = $('#bagit');
5 $bagitFormForm = $('#bagit-form-form'); 5 var $bagitForm = $('#bagit-form');
6 var $bagitFormForm = $('#bagit-form-form');
6 7
7 /* ========================================================================== 8 /* ==========================================================================
8 bag it link and close button 9 bag it link and close button
9 ========================================================================== */ 10 ========================================================================== */
10 11
11 function toggleSaveLinkForm(url, event) { 12 function toggleSaveLinkForm(url, event) {
12 $("#add-link-result").empty(); 13 $('#add-link-result').empty();
13 14
14 $bagit.toggleClass("active-current"); 15 $bagit.toggleClass('active-current');
15 16
16 //only if bag-it link is not presented on page 17 // only if bag-it link is not presented on page
17 if ( $bagit.length === 0 ) { 18 if ($bagit.length === 0) {
18 if ( event !== 'undefined' && event ) { 19 if (event !== 'undefined' && event) {
19 $bagitForm.css( {position:"absolute", top:event.pageY, left:event.pageX-200}); 20 $bagitForm.css({ position: 'absolute', top: event.pageY, left: event.pageX - 200 });
20 } 21 } else {
21 else { 22 $bagitForm.css({ position: 'relative', top: 'auto', left: 'auto' });
22 $bagitForm.css( {position:"relative", top:"auto", left:"auto"});
23 } 23 }
24 } 24 }
25 25
26 if ($("#search-form").length != 0) { 26 if ($('#search-form').length !== 0) {
27 $("#search").removeClass("current"); 27 $('#search').removeClass('current');
28 $("#search-arrow").removeClass("arrow-down"); 28 $('#search-arrow').removeClass('arrow-down');
29 $("#search-form").hide(); 29 $('#search-form').hide();
30 } 30 }
31 $bagitForm.toggle(); 31 $bagitForm.toggle();
32 $('#content').toggleClass("opacity03"); 32 $('#content').toggleClass('opacity03');
33 if (url !== 'undefined' && url) { 33 if (url !== 'undefined' && url) {
34 $('#plainurl').val(url); 34 $('#plainurl').val(url);
35 } 35 }
36 $('#plainurl').focus(); 36 $('#plainurl').focus();
37 } 37 }
38 38
39 //send "bag it link" form request via ajax 39 // send 'bag it link' form request via ajax
40 $bagitFormForm.submit( function(event) { 40 $bagitFormForm.submit(function (event) {
41 $("body").css("cursor", "wait"); 41 $('body').css('cursor', 'wait');
42 $("#add-link-result").empty(); 42 $('#add-link-result').empty();
43 43
44 $.ajax({ 44 $.ajax({
45 type: $bagitFormForm.attr('method'), 45 type: $bagitFormForm.attr('method'),
46 url: $bagitFormForm.attr('action'), 46 url: $bagitFormForm.attr('action'),
47 data: $bagitFormForm.serialize(), 47 data: $bagitFormForm.serialize(),
48 success: function(data) { 48 success: function (data) {
49 $('#add-link-result').html("Done!"); 49 $('#add-link-result').html('Done!');
50 $('#plainurl').val(''); 50 $('#plainurl').val('');
51 $('#plainurl').blur(''); 51 $('#plainurl').blur('');
52 $("body").css("cursor", "auto"); 52 $('body').css('cursor', 'auto');
53 },
54 error: function (data) {
55 $('#add-link-result').html('Failed!');
56 $('body').css('cursor', 'auto');
53 }, 57 },
54 error: function(data) {
55 $('#add-link-result').html("Failed!");
56 $("body").css("cursor", "auto");
57 }
58 }); 58 });
59 59
60 event.preventDefault(); 60 event.preventDefault();
@@ -64,15 +64,12 @@ $.fn.ready(function() {
64 Process all links inside an article 64 Process all links inside an article
65 ========================================================================== */ 65 ========================================================================== */
66 66
67 $("article a[href^='http']").after(function() { 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> "; 68 return ' <a href="' + $(this).attr('href') + '" class="add-to-wallabag-link-after" alt="add to wallabag" title="add to wallabag"></a> ';
69 }); 69 });
70 70
71 $(".add-to-wallabag-link-after").click(function(event){ 71 $('.add-to-wallabag-link-after').click(function (event) {
72 toggleSaveLinkForm($(this).attr('href'), event); 72 toggleSaveLinkForm($(this).attr('href'), event);
73 event.preventDefault(); 73 event.preventDefault();
74 }); 74 });
75
76}); 75});
77
78