diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-01-22 13:45:10 +0100 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-01-22 13:45:14 +0100 |
commit | 30d81a47c689e1d7d963fcd3fd42af9958805e31 (patch) | |
tree | cf1e1ccb801842cf4acc51c353bb481ede37d364 /src/Wallabag/CoreBundle/Resources/public/themes/baggy/js | |
parent | 124f8091cbb1e5cccd7972fa368f8e7c434e0e5b (diff) | |
download | wallabag-30d81a47c689e1d7d963fcd3fd42af9958805e31.tar.gz wallabag-30d81a47c689e1d7d963fcd3fd42af9958805e31.tar.zst wallabag-30d81a47c689e1d7d963fcd3fd42af9958805e31.zip |
Move public assets for themes
So they can be installed using the `assets:install` command and there'll no longer symlink in the repo
They moved from `web/themes/...` to `bundles/wallabagcore/themes/...`
Diffstat (limited to 'src/Wallabag/CoreBundle/Resources/public/themes/baggy/js')
7 files changed, 338 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Resources/public/themes/baggy/js/autoClose.js b/src/Wallabag/CoreBundle/Resources/public/themes/baggy/js/autoClose.js new file mode 100644 index 00000000..e9145b7e --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/public/themes/baggy/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/public/themes/baggy/js/autoCompleteTags.js b/src/Wallabag/CoreBundle/Resources/public/themes/baggy/js/autoCompleteTags.js new file mode 100755 index 00000000..90bc982c --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/public/themes/baggy/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/public/themes/baggy/js/closeMessage.js b/src/Wallabag/CoreBundle/Resources/public/themes/baggy/js/closeMessage.js new file mode 100644 index 00000000..527719d5 --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/public/themes/baggy/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/public/themes/baggy/js/init.js b/src/Wallabag/CoreBundle/Resources/public/themes/baggy/js/init.js new file mode 100755 index 00000000..74cbae68 --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/public/themes/baggy/js/init.js | |||
@@ -0,0 +1,51 @@ | |||
1 | $.fn.ready(function() { | ||
2 | |||
3 | var $listmode = $('#listmode'), | ||
4 | $listentries = $("#list-entries"); | ||
5 | |||
6 | /* ========================================================================== | ||
7 | Menu | ||
8 | ========================================================================== */ | ||
9 | |||
10 | $("#menu").click(function(){ | ||
11 | $("#links").toggleClass('menu--open'); | ||
12 | if ($('#content').hasClass('opacity03')) { | ||
13 | $('#content').removeClass('opacity03'); | ||
14 | } | ||
15 | }); | ||
16 | |||
17 | /* ========================================================================== | ||
18 | List mode or Table Mode | ||
19 | ========================================================================== */ | ||
20 | |||
21 | $listmode.click(function(){ | ||
22 | if ( $.cookie("listmode") == 1 ) { | ||
23 | // Cookie | ||
24 | $.removeCookie("listmode"); | ||
25 | |||
26 | $listentries.removeClass("listmode"); | ||
27 | $listmode.removeClass("tablemode"); | ||
28 | $listmode.addClass("listmode"); | ||
29 | } | ||
30 | else { | ||
31 | // Cookie | ||
32 | $.cookie("listmode", 1, {expires: 365}); | ||
33 | |||
34 | $listentries.addClass("listmode"); | ||
35 | $listmode.removeClass("listmode"); | ||
36 | $listmode.addClass("tablemode"); | ||
37 | } | ||
38 | |||
39 | }); | ||
40 | |||
41 | /* ========================================================================== | ||
42 | Cookie listmode | ||
43 | ========================================================================== */ | ||
44 | |||
45 | if ( $.cookie("listmode") == 1 ) { | ||
46 | $listentries.addClass("listmode"); | ||
47 | $listmode.removeClass("listmode"); | ||
48 | $listmode.addClass("tablemode"); | ||
49 | } | ||
50 | |||
51 | }); | ||
diff --git a/src/Wallabag/CoreBundle/Resources/public/themes/baggy/js/popupForm.js b/src/Wallabag/CoreBundle/Resources/public/themes/baggy/js/popupForm.js new file mode 100644 index 00000000..b933acd1 --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/public/themes/baggy/js/popupForm.js | |||
@@ -0,0 +1,83 @@ | |||
1 | $(document).ready(function() { | ||
2 | |||
3 | $("#search-form").hide(); | ||
4 | $("#bagit-form").hide(); | ||
5 | $("#filter-form").hide(); | ||
6 | |||
7 | //--------------------------------------------------------------------------- | ||
8 | // Toggle the "Search" popup in the sidebar | ||
9 | //--------------------------------------------------------------------------- | ||
10 | function toggleSearch() { | ||
11 | $("#search-form").toggle(); | ||
12 | $("#search").toggleClass("current"); | ||
13 | $("#search").toggleClass("active-current"); | ||
14 | $("#search-arrow").toggleClass("arrow-down"); | ||
15 | if ($("#search").hasClass("current")) { | ||
16 | $("#content").addClass("opacity03"); | ||
17 | } else { | ||
18 | $("#content").removeClass("opacity03"); | ||
19 | } | ||
20 | } | ||
21 | |||
22 | //--------------------------------------------------------------------------- | ||
23 | // Toggle the "Filter" popup on entries list | ||
24 | //--------------------------------------------------------------------------- | ||
25 | function toggleFilter() { | ||
26 | $("#filter-form").toggle(); | ||
27 | } | ||
28 | |||
29 | //--------------------------------------------------------------------------- | ||
30 | // Toggle the "Save a Link" popup in the sidebar | ||
31 | //--------------------------------------------------------------------------- | ||
32 | function toggleBagit() { | ||
33 | $("#bagit-form").toggle(); | ||
34 | $("#bagit").toggleClass("current"); | ||
35 | $("#bagit").toggleClass("active-current"); | ||
36 | $("#bagit-arrow").toggleClass("arrow-down"); | ||
37 | if ($("#bagit").hasClass("current")) { | ||
38 | $("#content").addClass("opacity03"); | ||
39 | } else { | ||
40 | $("#content").removeClass("opacity03"); | ||
41 | } | ||
42 | } | ||
43 | |||
44 | //--------------------------------------------------------------------------- | ||
45 | // Close all #links popups in the sidebar | ||
46 | //--------------------------------------------------------------------------- | ||
47 | function closePopups() { | ||
48 | $("#links .messages").hide(); | ||
49 | $("#links > li > a").removeClass("active-current"); | ||
50 | $("#links > li > a").removeClass("current"); | ||
51 | $("[id$=-arrow]").removeClass("arrow-down"); | ||
52 | $("#content").removeClass("opacity03"); | ||
53 | } | ||
54 | |||
55 | $("#search").click(function(){ | ||
56 | closePopups(); | ||
57 | toggleSearch(); | ||
58 | $("#searchfield").focus(); | ||
59 | }); | ||
60 | |||
61 | $("#filter").click(function(){ | ||
62 | closePopups(); | ||
63 | toggleFilter(); | ||
64 | }); | ||
65 | |||
66 | $("#bagit").click(function(){ | ||
67 | closePopups(); | ||
68 | toggleBagit(); | ||
69 | $("#plainurl").focus(); | ||
70 | }); | ||
71 | |||
72 | $("#search-form-close").click(function(){ | ||
73 | toggleSearch(); | ||
74 | }); | ||
75 | |||
76 | $("#filter-form-close").click(function(){ | ||
77 | toggleFilter(); | ||
78 | }); | ||
79 | |||
80 | $("#bagit-form-close").click(function(){ | ||
81 | toggleBagit(); | ||
82 | }); | ||
83 | }); | ||
diff --git a/src/Wallabag/CoreBundle/Resources/public/themes/baggy/js/restoreScroll.js b/src/Wallabag/CoreBundle/Resources/public/themes/baggy/js/restoreScroll.js new file mode 100644 index 00000000..331c9e19 --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/public/themes/baggy/js/restoreScroll.js | |||
@@ -0,0 +1,25 @@ | |||
1 | function supportsLocalStorage() { | ||
2 | try { | ||
3 | return 'localStorage' in window && window['localStorage'] !== null; | ||
4 | } catch (e) { | ||
5 | return false; | ||
6 | } | ||
7 | } | ||
8 | |||
9 | function savePercent(id, percent) { | ||
10 | if (!supportsLocalStorage()) { return false; } | ||
11 | localStorage["poche.article." + id + ".percent"] = percent; | ||
12 | return true; | ||
13 | } | ||
14 | |||
15 | function retrievePercent(id) { | ||
16 | if (!supportsLocalStorage()) { return false; } | ||
17 | |||
18 | var bheight = $(document).height(); | ||
19 | var percent = localStorage["poche.article." + id + ".percent"]; | ||
20 | var scroll = bheight * percent; | ||
21 | |||
22 | $('html,body').animate({scrollTop: scroll}, 'fast'); | ||
23 | |||
24 | return true; | ||
25 | } \ No newline at end of file | ||
diff --git a/src/Wallabag/CoreBundle/Resources/public/themes/baggy/js/saveLink.js b/src/Wallabag/CoreBundle/Resources/public/themes/baggy/js/saveLink.js new file mode 100755 index 00000000..a7acd84c --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/public/themes/baggy/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 | |||