diff options
Diffstat (limited to 'app/Resources/static/themes/baggy/js/init.js')
-rwxr-xr-x | app/Resources/static/themes/baggy/js/init.js | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/app/Resources/static/themes/baggy/js/init.js b/app/Resources/static/themes/baggy/js/init.js new file mode 100755 index 00000000..1721ae41 --- /dev/null +++ b/app/Resources/static/themes/baggy/js/init.js | |||
@@ -0,0 +1,101 @@ | |||
1 | var $ = global.jquery = require('jquery'); | ||
2 | require('jquery.cookie'); | ||
3 | require('jquery-ui'); | ||
4 | var annotator = require('annotator'); | ||
5 | |||
6 | |||
7 | $.fn.ready(function() { | ||
8 | |||
9 | var $listmode = $('#listmode'), | ||
10 | $listentries = $("#list-entries"); | ||
11 | |||
12 | /* ========================================================================== | ||
13 | Menu | ||
14 | ========================================================================== */ | ||
15 | |||
16 | $("#menu").click(function(){ | ||
17 | $("#links").toggleClass('menu--open'); | ||
18 | if ($('#content').hasClass('opacity03')) { | ||
19 | $('#content').removeClass('opacity03'); | ||
20 | } | ||
21 | }); | ||
22 | |||
23 | /* ========================================================================== | ||
24 | List mode or Table Mode | ||
25 | ========================================================================== */ | ||
26 | |||
27 | $listmode.click(function(){ | ||
28 | if ( jquery.cookie("listmode") == 1 ) { | ||
29 | // Cookie | ||
30 | $.removeCookie("listmode"); | ||
31 | |||
32 | $listentries.removeClass("listmode"); | ||
33 | $listmode.removeClass("tablemode"); | ||
34 | $listmode.addClass("listmode"); | ||
35 | } | ||
36 | else { | ||
37 | // Cookie | ||
38 | jquery.cookie("listmode", 1, {expires: 365}); | ||
39 | |||
40 | $listentries.addClass("listmode"); | ||
41 | $listmode.removeClass("listmode"); | ||
42 | $listmode.addClass("tablemode"); | ||
43 | } | ||
44 | |||
45 | }); | ||
46 | |||
47 | /* ========================================================================== | ||
48 | Cookie listmode | ||
49 | ========================================================================== */ | ||
50 | |||
51 | if ( jquery.cookie("listmode") == 1 ) { | ||
52 | $listentries.addClass("listmode"); | ||
53 | $listmode.removeClass("listmode"); | ||
54 | $listmode.addClass("tablemode"); | ||
55 | } | ||
56 | |||
57 | /* ========================================================================== | ||
58 | Add tag panel | ||
59 | ========================================================================== */ | ||
60 | |||
61 | |||
62 | $('#nav-btn-add-tag').on('click', function(){ | ||
63 | $(".nav-panel-add-tag").toggle(100); | ||
64 | $(".nav-panel-menu").addClass('hidden'); | ||
65 | $("#tag_label").focus(); | ||
66 | return false; | ||
67 | }); | ||
68 | |||
69 | /* ========================================================================== | ||
70 | Annotations & Remember position | ||
71 | ========================================================================== */ | ||
72 | |||
73 | if ($("article").length) { | ||
74 | var app = new annotator.App(); | ||
75 | |||
76 | app.include(annotator.ui.main, { | ||
77 | element: document.querySelector('article') | ||
78 | }); | ||
79 | |||
80 | var x = JSON.parse($('#annotationroutes').html()); | ||
81 | app.include(annotator.storage.http, x); | ||
82 | |||
83 | app.start().then(function () { | ||
84 | app.annotations.load({entry: x.entryId}); | ||
85 | }); | ||
86 | |||
87 | $(window).scroll(function(e){ | ||
88 | var scrollTop = $(window).scrollTop(); | ||
89 | var docHeight = $(document).height(); | ||
90 | var scrollPercent = (scrollTop) / (docHeight); | ||
91 | var scrollPercentRounded = Math.round(scrollPercent*100)/100; | ||
92 | savePercent(x.entryId, scrollPercentRounded); | ||
93 | }); | ||
94 | |||
95 | retrievePercent(x.entryId); | ||
96 | |||
97 | $(window).resize(function(){ | ||
98 | retrievePercent(x.entryId); | ||
99 | }); | ||
100 | } | ||
101 | }); | ||