diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Resources/views/themes/baggy')
6 files changed, 255 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/layout.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/layout.html.twig index dffea036..229c5a34 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/layout.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/layout.html.twig | |||
@@ -14,4 +14,8 @@ | |||
14 | {{ parent() }} | 14 | {{ parent() }} |
15 | 15 | ||
16 | <script src="{{ asset('themes/baggy/js/init.js') }}"></script> | 16 | <script src="{{ asset('themes/baggy/js/init.js') }}"></script> |
17 | <script src="{{ asset('themes/baggy/js/closeMessage.js') }}"></script> | ||
18 | <script src="{{ asset('themes/baggy/js/autoClose.js') }}"></script> | ||
19 | <script src="{{ asset('themes/baggy/js/saveLink.js') }}"></script> | ||
20 | <script src="{{ asset('themes/baggy/js/popupForm.js') }}"></script> | ||
17 | {% endblock %} | 21 | {% endblock %} |
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/autoClose.js b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/autoClose.js new file mode 100644 index 00000000..e9145b7e --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/autoClose.js | |||
@@ -0,0 +1,6 @@ | |||
1 | $(document).ready(function() { | ||
2 | current_url = window.location.href | ||
3 | if (current_url.match("&closewin=true")) { | ||
4 | window.close(); | ||
5 | } | ||
6 | }); | ||
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/autoCompleteTags.js b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/autoCompleteTags.js new file mode 100755 index 00000000..90bc982c --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/autoCompleteTags.js | |||
@@ -0,0 +1,47 @@ | |||
1 | jQuery(function($) { | ||
2 | |||
3 | function split( val ) { | ||
4 | return val.split( /,\s*/ ); | ||
5 | } | ||
6 | function extractLast( term ) { | ||
7 | return split( term ).pop(); | ||
8 | } | ||
9 | |||
10 | |||
11 | $("#value").bind("keydown", function(event) { | ||
12 | if (event.keyCode === $.ui.keyCode.TAB && $(this).data("ui-autocomplete").menu.active) { | ||
13 | event.preventDefault(); | ||
14 | } | ||
15 | }).autocomplete({ | ||
16 | source : function(request, response) { | ||
17 | $.getJSON("./?view=tags", { | ||
18 | term : extractLast(request.term), | ||
19 | //id: $(':hidden#entry_id').val() | ||
20 | }, response); | ||
21 | }, | ||
22 | search : function() { | ||
23 | // custom minLength | ||
24 | var term = extractLast(this.value); | ||
25 | if (term.length < 1) { | ||
26 | return false; | ||
27 | } | ||
28 | }, | ||
29 | focus : function() { | ||
30 | // prevent value inserted on focus | ||
31 | return false; | ||
32 | }, | ||
33 | select : function(event, ui) { | ||
34 | var terms = split(this.value); | ||
35 | // remove the current input | ||
36 | terms.pop(); | ||
37 | // add the selected item | ||
38 | terms.push(ui.item.value); | ||
39 | // add placeholder to get the comma-and-space at the end | ||
40 | terms.push(""); | ||
41 | this.value = terms.join(", "); | ||
42 | return false; | ||
43 | } | ||
44 | }); | ||
45 | |||
46 | |||
47 | }); | ||
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/closeMessage.js b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/closeMessage.js new file mode 100644 index 00000000..527719d5 --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/closeMessage.js | |||
@@ -0,0 +1,17 @@ | |||
1 | $(function(){ | ||
2 | //--------------------------------------------------------------------------- | ||
3 | // Show the close icon when the user hover over a message | ||
4 | //--------------------------------------------------------------------------- | ||
5 | // $('.messages').on('mouseenter', function(){ | ||
6 | // $(this).find('a.closeMessage').stop(true, true).show(); | ||
7 | // }).on('mouseleave', function(){ | ||
8 | // $(this).find('a.closeMessage').stop(true, true).hide(); | ||
9 | // }); | ||
10 | //--------------------------------------------------------------------------- | ||
11 | // Close the message box when the user clicks the close icon | ||
12 | //--------------------------------------------------------------------------- | ||
13 | $('a.closeMessage').on('click', function(){ | ||
14 | $(this).parents('div.messages').slideUp(300, function(){ $(this).remove(); }); | ||
15 | return false; | ||
16 | }); | ||
17 | }); \ No newline at end of file | ||
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/popupForm.js b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/popupForm.js new file mode 100644 index 00000000..d233e600 --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/popupForm.js | |||
@@ -0,0 +1,72 @@ | |||
1 | $(document).ready(function() { | ||
2 | |||
3 | $("#search-form").hide(); | ||
4 | $("#bagit-form").hide(); | ||
5 | |||
6 | //--------------------------------------------------------------------------- | ||
7 | // Toggle the "Search" popup in the sidebar | ||
8 | //--------------------------------------------------------------------------- | ||
9 | function toggleSearch() { | ||
10 | $("#search-form").toggle(); | ||
11 | $("#search").toggleClass("current"); | ||
12 | $("#search").toggleClass("active-current"); | ||
13 | $("#search-arrow").toggleClass("arrow-down"); | ||
14 | if ($("#search").hasClass("current")) { | ||
15 | $("#content").addClass("opacity03"); | ||
16 | } else { | ||
17 | $("#content").removeClass("opacity03"); | ||
18 | } | ||
19 | } | ||
20 | |||
21 | //--------------------------------------------------------------------------- | ||
22 | // Toggle the "Save a Link" popup in the sidebar | ||
23 | //--------------------------------------------------------------------------- | ||
24 | function toggleBagit() { | ||
25 | $("#bagit-form").toggle(); | ||
26 | $("#bagit").toggleClass("current"); | ||
27 | $("#bagit").toggleClass("active-current"); | ||
28 | $("#bagit-arrow").toggleClass("arrow-down"); | ||
29 | if ($("#bagit").hasClass("current")) { | ||
30 | $("#content").addClass("opacity03"); | ||
31 | } else { | ||
32 | $("#content").removeClass("opacity03"); | ||
33 | } | ||
34 | } | ||
35 | |||
36 | //--------------------------------------------------------------------------- | ||
37 | // Close all #links popups in the sidebar | ||
38 | //--------------------------------------------------------------------------- | ||
39 | function closePopups() { | ||
40 | $("#links .messages").hide(); | ||
41 | $("#links > li > a").removeClass("active-current"); | ||
42 | $("#links > li > a").removeClass("current"); | ||
43 | $("[id$=-arrow]").removeClass("arrow-down"); | ||
44 | $("#content").removeClass("opacity03"); | ||
45 | } | ||
46 | |||
47 | $("#search").click(function(){ | ||
48 | closePopups(); | ||
49 | toggleSearch(); | ||
50 | $("#searchfield").focus(); | ||
51 | }); | ||
52 | |||
53 | $("#bagit").click(function(){ | ||
54 | closePopups(); | ||
55 | toggleBagit(); | ||
56 | $("#plainurl").focus(); | ||
57 | }); | ||
58 | |||
59 | $("#search-form-close").click(function(){ | ||
60 | toggleSearch(); | ||
61 | }); | ||
62 | |||
63 | $("#bagit-form-close").click(function(){ | ||
64 | toggleBagit(); | ||
65 | }); | ||
66 | |||
67 | // $("#").click(function(){ | ||
68 | // toggleSearch(); | ||
69 | // }); | ||
70 | |||
71 | |||
72 | }); | ||
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/saveLink.js b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/saveLink.js new file mode 100755 index 00000000..a7acd84c --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/saveLink.js | |||
@@ -0,0 +1,109 @@ | |||
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 | // These two functions are now taken care of in popupForm.js | ||
41 | //--------------------------------------------------------------------------- | ||
42 | |||
43 | // $bagit.click(function(){ | ||
44 | // $bagit.toggleClass("current"); | ||
45 | // $("#bagit-arrow").toggleClass("arrow-down"); | ||
46 | // toggleSaveLinkForm(); | ||
47 | // }); | ||
48 | |||
49 | // $("#bagit-form-close").click(function(){ | ||
50 | // $bagit.removeClass("current"); | ||
51 | // $("#bagit-arrow").removeClass("arrow-down"); | ||
52 | // toggleSaveLinkForm(); | ||
53 | // }); | ||
54 | |||
55 | |||
56 | //send "bag it link" form request via ajax | ||
57 | $bagitFormForm.submit( function(event) { | ||
58 | $("body").css("cursor", "wait"); | ||
59 | $("#add-link-result").empty(); | ||
60 | |||
61 | $.ajax({ | ||
62 | type: $bagitFormForm.attr('method'), | ||
63 | url: $bagitFormForm.attr('action'), | ||
64 | data: $bagitFormForm.serialize(), | ||
65 | success: function(data) { | ||
66 | $('#add-link-result').html("Done!"); | ||
67 | $('#plainurl').val(''); | ||
68 | $('#plainurl').blur(''); | ||
69 | $("body").css("cursor", "auto"); | ||
70 | //setTimeout( function() { toggleSaveLinkForm(); }, 1000); //close form after 1000 delay | ||
71 | }, | ||
72 | error: function(data) { | ||
73 | $('#add-link-result').html("Failed!"); | ||
74 | $("body").css("cursor", "auto"); | ||
75 | } | ||
76 | }); | ||
77 | |||
78 | event.preventDefault(); | ||
79 | }); | ||
80 | |||
81 | /* ========================================================================== | ||
82 | Keyboard gestion | ||
83 | ========================================================================== */ | ||
84 | |||
85 | $(window).keydown(function(e){ | ||
86 | if ( ( e.target.tagName.toLowerCase() !== 'input' && e.keyCode == 83 ) || (e.keyCode == 27 && $bagitForm.is(':visible') ) ) { | ||
87 | $bagit.removeClass("current"); | ||
88 | $("#bagit-arrow").removeClass("arrow-down"); | ||
89 | toggleSaveLinkForm(); | ||
90 | return false; | ||
91 | } | ||
92 | }); | ||
93 | |||
94 | /* ========================================================================== | ||
95 | Process all links inside an article | ||
96 | ========================================================================== */ | ||
97 | |||
98 | $("article a[href^='http']").after(function() { | ||
99 | return " <a href=\"" + $(this).attr('href') + "\" class=\"add-to-wallabag-link-after\" alt=\"add to wallabag\" title=\"add to wallabag\"></a> "; | ||
100 | }); | ||
101 | |||
102 | $(".add-to-wallabag-link-after").click(function(event){ | ||
103 | toggleSaveLinkForm($(this).attr('href'), event); | ||
104 | event.preventDefault(); | ||
105 | }); | ||
106 | |||
107 | }); | ||
108 | |||
109 | |||