basket.jsp 5.44 KB
Newer Older
Ubbo Veentjer's avatar
Ubbo Veentjer committed
1
2
3
4
5
6
7
8
9
<%@ page contentType="text/html" pageEncoding="UTF-8" %>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://textgrid.info/rep/utils" prefix="utils" %>

<%@ include file="base/head.jsp" %>
<%@ include file="components/js-incl.jsp" %>

Ubbo Veentjer's avatar
Ubbo Veentjer committed
10
11
12
13
14
<script type="text/javascript">
	document.addEventListener("DOMContentLoaded", function(event) {

		$(document).on('click', '.-remove-from-shelf', function(e) {
			var $this = $(this);
15
			var tgObjectUri = $this.attr('data-textgrid-targeturi');
Ubbo Veentjer's avatar
Ubbo Veentjer committed
16
			$.ajax({
17
					url: '/service/shelf/remove' ,
Ubbo Veentjer's avatar
Ubbo Veentjer committed
18
19
20
					type: 'POST',
					dataType:'json',
					data: {
21
						uri: tgObjectUri
Ubbo Veentjer's avatar
Ubbo Veentjer committed
22
23
24
					},
					success: function(data) {
						$this.closest('li.tgrep.result').remove();
Ubbo Veentjer's avatar
Ubbo Veentjer committed
25
26
27
						$this.closest('li.tgrep.gallery-item').remove();
						$('.tgrep.header_count').html(data);
						setBasketCount(data);
28
						removeFromAggregatorItemString(tgObjectUri)
Ubbo Veentjer's avatar
Ubbo Veentjer committed
29
30
31
32
33
34
					}
			});
		});

		$(document).on('click', '.tgrep.header_button.-clear', function(e) {
			$.ajax({
35
					url: '/service/shelf/clear' ,
Ubbo Veentjer's avatar
Ubbo Veentjer committed
36
37
38
					type: 'POST',
					dataType:'json',
					data: {
39
						empty: 'empty'
Ubbo Veentjer's avatar
Ubbo Veentjer committed
40
41
42
					},
					success: function(data) {
						$('.tgrep.results_list').empty();
Ubbo Veentjer's avatar
Ubbo Veentjer committed
43
						$('.tgrep.results_gallery').empty();
Ubbo Veentjer's avatar
Ubbo Veentjer committed
44
						$('.tgrep.header_count').html(0);
Ubbo Veentjer's avatar
Ubbo Veentjer committed
45
						setBasketCount(data);
46
						removeUselessActionsFromEmptyShelf();
Ubbo Veentjer's avatar
Ubbo Veentjer committed
47
48
49
					}
			});
		});
Ubbo Veentjer's avatar
Ubbo Veentjer committed
50
	});
Ubbo Veentjer's avatar
Ubbo Veentjer committed
51

52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
	// set by jsp
	var basketItemString = '${basketItemString}';

	// removes the tguri from aggregatorUrl
	function removeFromAggregatorItemString(tgObjectUri) {

		var basketItemStringOld = basketItemString;
		var itemArr = basketItemString.split(',');
		itemArr.splice(itemArr.indexOf(tgObjectUri),1);

		// are there any objects left on the shelf?
		if(itemArr.length > 0) {
			basketItemString = itemArr.join(',');
		  document.querySelectorAll('.aggregator-items').forEach( elem => {
		      elem.href = elem.href.replace(basketItemStringOld, basketItemString);
		  });
		} else {
			removeUselessActionsFromEmptyShelf();
		}
	}

	// dislable download and voyant links if shelf is empty
	function removeUselessActionsFromEmptyShelf() {
    document.querySelectorAll('.remove_on_shelf_empty').forEach( elem => {
        elem.remove();
    });
	}

Ubbo Veentjer's avatar
Ubbo Veentjer committed
80
81
</script>

Ubbo Veentjer's avatar
Ubbo Veentjer committed
82
<div class="tgrep wrap">
Ubbo Veentjer's avatar
Ubbo Veentjer committed
83
84
85
86
87
88
	<div class="tgrep sidebar-toggle">
		<button class="tgrep sidebar-toggle_button -show">${i18n['show-sidebar']}</button>
		<button class="tgrep sidebar-toggle_button -hide">${i18n['hide-sidebar']}</button>
	</div>

	<aside class="tgrep sidebar">
Ubbo Veentjer's avatar
Ubbo Veentjer committed
89

Ubbo Veentjer's avatar
Ubbo Veentjer committed
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
		<c:if test="${viewmodes != null}">
			<section class="tgrep sidebar_panel">
				<h3 class="tgrep sidebar_subheading">${i18n['views']}</h3>
				<ul class="tgrep sidebar_list">
					<c:forEach items="${viewmodes}" var="viewmode">
						<li class="tgrep sidebar_item">
							<a href="${viewmode.url}" rel="noindex nofollow" class="tgrep sidebar_link">${viewmode.label}</a>
						</li>
					</c:forEach>
				</ul>
				<c:if test="${viewmodes.size() > 6}">
					<button class="tgrep sidebar_expand">${i18n['expand']}</button>
				</c:if>
			</section>
		</c:if>
Ubbo Veentjer's avatar
Ubbo Veentjer committed
105

106
107
108
109
110
111
112
113
114
115
    <c:if test="${results.size() > 0}">
			<section class="tgrep sidebar_panel remove_on_shelf_empty">
	      <h3 class="tgrep sidebar_subheading">${i18n['tools']}</h3>
	      <ul class="tgrep sidebar_list">
	        <li class="tgrep sidebar_item">
	          <a class="aggregator-items" href="${voyantUrl}?input=${aggregatorUrl}/zip/${basketItemString}?meta=false&only=text/xml" rel="noindex nofollow" class="tgrep sidebar_link">Voyant</a>
			    </li>
			 </ul>
			 </section>
		 </c:if>
Ubbo Veentjer's avatar
Ubbo Veentjer committed
116
	</aside>
Ubbo Veentjer's avatar
Ubbo Veentjer committed
117

Ubbo Veentjer's avatar
Ubbo Veentjer committed
118
119
	<main class="tgrep main">
		<h1 class="tgrep main_heading">${i18n['shelf']}</h1>
Ubbo Veentjer's avatar
Ubbo Veentjer committed
120

Ubbo Veentjer's avatar
Ubbo Veentjer committed
121
122
123
124
125
		<header class="tgrep header">
			<h2 class="tgrep header_heading">${i18n['manage-the-shelf']}</h2>
			<div class="tgrep header_info">
				${i18n['there-are-currently']} <span class="tgrep header_count">${results.size()}</span> ${i18n['objects-on-your-shelf']}
			</div>
126
127
128
129
130
131
132
133
134
135
136
137
138
			<c:if test="${results.size() > 0}">
				<div class="tgrep header_actions remove_on_shelf_empty">
					<button class="tgrep header_button -expand-all">${i18n['expand-all']}</button>
					<button class="tgrep header_button -collapse-all ">${i18n['collapse-all']}</button>
					<button class="tgrep header_button -clear ">${i18n['clear']}</button>
					<div class="tg dropdown" role="group">
						<a class="tg dropdown_toggle">${i18n['download-all']}</a>
						<ul class="tg dropdown_menu">
							<li class="tg dropdown_item"><a class="aggregator-items tg dropdown_link" href="${aggregatorUrl}/epub/${basketItemString}" data-type="ebook">E-Book</a></li>
							<li class="tg dropdown_item"><a class="aggregator-items tg dropdown_link" href="${aggregatorUrl}/zip/${basketItemString}" data-type="zip">ZIP</a></li>
							<li class="tg dropdown_item"><a class="aggregator-items tg dropdown_link" href="${aggregatorUrl}/teicorpus/${basketItemString}" data-type="teicorpus">TEI-Corpus</a></li>
						</ul>
					</div>
Ubbo Veentjer's avatar
Ubbo Veentjer committed
139
				</div>
140
				</c:if>
Ubbo Veentjer's avatar
Ubbo Veentjer committed
141
		</header>
Ubbo Veentjer's avatar
Ubbo Veentjer committed
142

Ubbo Veentjer's avatar
Ubbo Veentjer committed
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
		<c:choose>
			<c:when test="${mode eq 'gallery'}">
				<ul class="tgrep results_gallery">
					<c:forEach items="${results}" var="result">
						<%@ include file="components/singleGalleryResult.jsp" %>
					</c:forEach>
				</ul>
			</c:when>
			<c:otherwise>
				<ul class="tgrep results_list">
					<c:forEach items="${results}" var="result">
						<%@ include file="components/singleListResult.jsp" %>
					</c:forEach>
				</ul>
			</c:otherwise>
		</c:choose>
	</main>
Ubbo Veentjer's avatar
Ubbo Veentjer committed
160
161
162
163
</div>


<%@ include file="base/foot.jsp" %>
Ubbo Veentjer's avatar
Ubbo Veentjer committed
164