diff options
Diffstat (limited to 'themes/baggy/js/init.js')
-rwxr-xr-x | themes/baggy/js/init.js | 80 |
1 files changed, 1 insertions, 79 deletions
diff --git a/themes/baggy/js/init.js b/themes/baggy/js/init.js index da644fbe..00470fbf 100755 --- a/themes/baggy/js/init.js +++ b/themes/baggy/js/init.js | |||
@@ -1,10 +1,7 @@ | |||
1 | $.fn.ready(function() { | 1 | $.fn.ready(function() { |
2 | 2 | ||
3 | var $listmode = $('#listmode'), | 3 | var $listmode = $('#listmode'), |
4 | $listentries = $("#list-entries"), | 4 | $listentries = $("#list-entries"); |
5 | $bagit = $('#bagit'), | ||
6 | $bagitForm = $('#bagit-form'); | ||
7 | $bagitFormForm = $('#bagit-form-form'); | ||
8 | 5 | ||
9 | /* ========================================================================== | 6 | /* ========================================================================== |
10 | Menu | 7 | Menu |
@@ -48,79 +45,4 @@ $.fn.ready(function() { | |||
48 | $listmode.addClass("tablemode"); | 45 | $listmode.addClass("tablemode"); |
49 | } | 46 | } |
50 | 47 | ||
51 | /* ========================================================================== | ||
52 | bag it link and close button | ||
53 | ========================================================================== */ | ||
54 | |||
55 | function toggleSaveLinkForm(url) { | ||
56 | $bagit.toggleClass("active-current"); | ||
57 | $bagitForm.toggle(); | ||
58 | $('#content').toggleClass("opacity03"); | ||
59 | if (url !== 'undefined' && url) { | ||
60 | $('#plainurl').val(url); | ||
61 | } | ||
62 | $('#plainurl').focus(); | ||
63 | } | ||
64 | |||
65 | $bagit.click(function(){ | ||
66 | toggleSaveLinkForm(); | ||
67 | }); | ||
68 | |||
69 | $("#bagit-form-close").click(function(){ | ||
70 | toggleSaveLinkForm(); | ||
71 | }); | ||
72 | |||
73 | |||
74 | //send "bag it link" form request via ajax | ||
75 | $bagitFormForm.submit( function(event) { | ||
76 | $bagitFormForm.css("cursor", "wait"); | ||
77 | $("#add-link-result").empty(); | ||
78 | |||
79 | $.ajax({ | ||
80 | type: $bagitFormForm.attr('method'), | ||
81 | url: $bagitFormForm.attr('action'), | ||
82 | data: $bagitFormForm.serialize(), | ||
83 | success: function(data) { | ||
84 | $('#add-link-result').html("Done!"); | ||
85 | $('#plainurl').val(''); | ||
86 | $('#plainurl').blur(''); | ||
87 | $bagitFormForm.css("cursor", "auto"); | ||
88 | //setTimeout( function() { toggleSaveLinkForm(); }, 1000); //close form after 1000 delay | ||
89 | }, | ||
90 | error: function(data) { | ||
91 | $('#add-link-result').html("Failed!"); | ||
92 | $bagitFormForm.css("cursor", "auto"); | ||
93 | } | ||
94 | }); | ||
95 | |||
96 | event.preventDefault(); | ||
97 | }); | ||
98 | |||
99 | /* ========================================================================== | ||
100 | Keyboard gestion | ||
101 | ========================================================================== */ | ||
102 | |||
103 | $(window).keydown(function(e){ | ||
104 | if ( ( e.target.tagName.toLowerCase() !== 'input' && e.keyCode == 83 ) || e.keyCode == 27 ) { | ||
105 | toggleSaveLinkForm(); | ||
106 | return false; | ||
107 | } | ||
108 | }); | ||
109 | |||
110 | /* ========================================================================== | ||
111 | Process all links inside an article | ||
112 | ========================================================================== */ | ||
113 | |||
114 | $("article a[href^='http']").after(function() { | ||
115 | return " <a href=\"" + $(this).attr('href') + "\" class=\"add-to-wallabag-link-after\" alt=\"add to wallabag\" title=\"add to wallabag\">w</a> "; | ||
116 | }); | ||
117 | |||
118 | $(".add-to-wallabag-link-after").click(function(event){ | ||
119 | toggleSaveLinkForm($(this).attr('href')); | ||
120 | event.preventDefault(); | ||
121 | }); | ||
122 | |||
123 | |||
124 | |||
125 | |||
126 | }); | 48 | }); |