Skip to content

Commit 139d2a9

Browse files
authored
Merge pull request #13 from HSG-Library/develop
Release v2022.08.11
2 parents be45de1 + 095ed15 commit 139d2a9

File tree

26 files changed

+491
-21
lines changed

26 files changed

+491
-21
lines changed

css/hsg-collections-topbar.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/******************************************/
2+
/****** White collections top bar ******/
3+
/******************************************/
4+
prm-explore-main .header .transparent-top-bar::before {
5+
background-color: transparent;
6+
}

css/hsg-sublocation-link.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.hsg-sublocation-link {
2+
margin-left: 40px;
3+
}

css/slsp-i-button.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.lib-info {
2+
display: inline-block;
3+
}

js/main.js

Lines changed: 286 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { hsgAlertMessageModule } from './modules/hsg-alert-message/hsg-alert-mes
55
import { hsgExceptionHandlerModule } from './modules/hsg-exception-handler/hsg-exception-handler.module'
66
import { hsgAlmaOtherMembersAfterModule } from './modules/prm-alma-other-members-after/hsg-alma-other-members-after.module'
77
import { hsgAlmaViewitAfterModule } from './modules/prm-alma-viewit-after/hsg-alma-viewit-after.module'
8+
import { hsgGalleryItemAfterModule } from './modules/prm-gallery-item-after/hsg-gallery-item-after.module'
89
import { hsgJournalsAfterModule } from './modules/prm-journals-after/hsg-journals-after.module'
910
import { hsgLoanAfterModule } from './modules/prm-loan-after/hsg-loan-after.module'
1011
import { hsgLocationItemAfterModule } from './modules/prm-location-item-after/hsg-location-item-after.module'
@@ -27,6 +28,7 @@ app.requires.push(hsgHowovpAfterModule.name)
2728
app.requires.push(hsgHtgiSvcAfterModule.name)
2829
app.requires.push(hsgAlmaOtherMembersAfterModule.name)
2930
app.requires.push(hsgAlmaViewitAfterModule.name)
31+
app.requires.push(hsgGalleryItemAfterModule.name)
3032
app.requires.push(hsgJournalsAfterModule.name)
3133
app.requires.push(hsgLoanAfterModule.name)
3234
app.requires.push(hsgLocationItemAfterModule.name)
@@ -43,7 +45,16 @@ app.requires.push(slspHttpInterceptRequestsModule.name)
4345

4446
app.run(function () { console.log('** app running **') })
4547

46-
//BrowZine not enabled yet //
48+
window.isSandbox = function () {
49+
const sandboxView = "41SLSP_HSG:sandbox_jfu"
50+
const params = new URLSearchParams(window.location.search)
51+
if (params.has('vid')) {
52+
const vid = params.get('vid')
53+
return vid == sandboxView
54+
}
55+
return false
56+
}
57+
4758
// Begin BrowZine - Primo Integration (See: https://thirdiron.atlassian.net/wiki/spaces/BrowZineAPIDocs/pages/79200260/Ex+Libris+Primo+Integration)
4859
window.browzine = {
4960
api: "https://public-api.thirdiron.com/public/v1/libraries/2827",
@@ -73,3 +84,277 @@ document.head.appendChild(browzine.script)
7384

7485
// **controller is implemented in hsg-browzine-integration module**
7586
// End BrowZine - Primo Integration
87+
88+
if (window.isSandbox()) {
89+
///////////////////////////////////////////
90+
/// code for LibraryH3lp chat ///
91+
/// provided by support@libraryh3lp.com ///
92+
///////////////////////////////////////////
93+
function getClosest(elem, selector) {
94+
// Element.matches() polyfill
95+
if (!Element.prototype.matches) {
96+
Element.prototype.matches =
97+
Element.prototype.matchesSelector ||
98+
Element.prototype.mozMatchesSelector ||
99+
Element.prototype.msMatchesSelector ||
100+
Element.prototype.oMatchesSelector ||
101+
Element.prototype.webkitMatchesSelector ||
102+
function (s) {
103+
var matches = (this.document || this.ownerDocument).querySelectorAll(s),
104+
i = matches.length
105+
while (--i >= 0 && matches.item(i) !== this) { }
106+
return i > -1
107+
}
108+
}
109+
110+
// Get the closest matching element
111+
for (; elem && elem !== document; elem = elem.parentNode) {
112+
if (elem.matches(selector)) return elem
113+
}
114+
return null
115+
}
116+
117+
var chatFrameWrap = document.createElement('div')
118+
chatFrameWrap.setAttribute('id', 'lh3-chat-frame-wrap')
119+
chatFrameWrap.setAttribute('style', 'display: none; height: 390px; background-color: #fff; border: 1px solid #00802f; width: 400px')
120+
121+
var closeChatBar = document.createElement('div')
122+
closeChatBar.setAttribute('id', 'lh3-close-chat-bar')
123+
closeChatBar.setAttribute('style', 'background-color: #00802f; color: #fff; font-family: Arial, sans-serif; font-size: 20px; font-weight: bold; padding: 5px 10px; text-align: right;')
124+
var closeChat = document.createElement('span')
125+
closeChat.setAttribute('id', 'lh3-close-chat')
126+
closeChat.setAttribute('style', 'cursor: pointer;')
127+
closeChat.innerHTML = '✕'
128+
closeChatBar.appendChild(closeChat)
129+
chatFrameWrap.appendChild(closeChatBar)
130+
131+
var needsJs = document.createElement('div')
132+
needsJs.setAttribute('class', 'needs-js')
133+
chatFrameWrap.appendChild(needsJs)
134+
135+
var chatHeader = document.createElement('header')
136+
chatHeader.setAttribute('aria-labelled-by', 'lh3-chat-button')
137+
chatHeader.setAttribute('id', 'lh3-chat-header')
138+
chatHeader.setAttribute('style', 'display: block; position: absolute; top: -3px; left: -65px;')
139+
140+
var chatOnlineImage = document.createElement('img')
141+
chatOnlineImage.setAttribute('src', 'https://s3.amazonaws.com/libraryh3lp.com/eu/buttons/1725-st-gallen-chat-online.png')
142+
chatOnlineImage.setAttribute('alt', 'Chat online')
143+
chatOnlineImage.setAttribute('style', 'height: 46px; width: 46px; padding: 2px 0;')
144+
145+
var chatButton = document.createElement('button')
146+
chatButton.setAttribute('id', 'lh3-chat-button')
147+
chatButton.setAttribute('style', 'background-color: transparent; border: none; display: block; padding: 10px 10px 8px;')
148+
chatButton.appendChild(chatOnlineImage)
149+
150+
var chatTooltipHeader = document.createElement('div')
151+
chatTooltipHeader.setAttribute('style', 'font-weight: bold;')
152+
chatTooltipHeader.innerHTML = 'Live Chat'
153+
var chatTooltipContentDe = document.createElement('div')
154+
chatTooltipContentDe.innerHTML = 'Haben Sie Fragen?'
155+
var chatTooltipContentEn = document.createElement('div')
156+
chatTooltipContentEn.innerHTML = 'Do you have any questions?'
157+
var chatTooltip = document.createElement('div')
158+
chatTooltip.setAttribute('id', 'chat-tooltip')
159+
chatTooltip.setAttribute('style', 'display: none; position: absolute; top: 70px; right: 10px; width: max-content; text-align: right; padding: 5px; border: 1px solid #00802f; border-radius: 0; background-color: white; color: #3A3A3A; font-family: Source Sans Pro;')
160+
chatTooltip.appendChild(chatTooltipHeader)
161+
chatTooltip.appendChild(chatTooltipContentDe)
162+
chatTooltip.appendChild(chatTooltipContentEn)
163+
164+
var chatTooltipArrow = document.createElement('div')
165+
chatTooltipArrow.setAttribute('id', 'chat-tooltip-arrow')
166+
chatTooltipArrow.setAttribute('style', 'display: none; position: absolute; bottom: -2px; left: 15px; width: 0; border-top: 5px solid #00802f; border-right: 5px solid transparent; border-left: 5px solid transparent; font-size: 0; line-height: 0; transform: rotate(180deg);')
167+
168+
var lh3ChatOnline = false
169+
var showLH3Chat = false
170+
window.mouseOverChatTab = function (event) {
171+
if (lh3ChatOnline && !showLH3Chat) {
172+
document.getElementById('chat-tooltip').style.display = 'block'
173+
document.getElementById('chat-tooltip-arrow').style.display = 'block'
174+
}
175+
}
176+
window.mouseOutChatTab = function (event) {
177+
if (lh3ChatOnline && !showLH3Chat) {
178+
document.getElementById('chat-tooltip').style.display = 'none'
179+
document.getElementById('chat-tooltip-arrow').style.display = 'none'
180+
}
181+
}
182+
window.toggleChatTab = function (event) {
183+
if (event) {
184+
event.preventDefault()
185+
event.stopPropagation()
186+
} else if (showLH3Chat) {
187+
// Clicked a toggle somewhere from page, but chat is already open.
188+
return false
189+
}
190+
191+
// Hide any tooltip.
192+
document.getElementById('chat-tooltip').style.display = 'none'
193+
document.getElementById('chat-tooltip-arrow').style.display = 'none'
194+
195+
showLH3Chat = !showLH3Chat
196+
chatButton.style.display = showLH3Chat ? 'none' : 'block'
197+
chatFrameWrap.style.display = showLH3Chat ? 'block' : 'none'
198+
chatFrameWrap.style.width = ((window.screen.availWidth < 400) ? (window.screen.availWidth - 2) : 400) + 'px'
199+
chatHeader.style.left = showLH3Chat ? '-69px' : '-67px'
200+
if (!showLH3Chat) {
201+
chatWidget.setAttribute('style', 'position: fixed; top: 38.2%; right: 20px; z-index: 1000;')
202+
}
203+
return false
204+
}
205+
206+
closeChat.addEventListener('click', window.toggleChatTab)
207+
closeChat.addEventListener('touchend', window.toggleChatTab)
208+
chatButton.addEventListener('click', window.toggleChatTab)
209+
chatButton.addEventListener('mouseover', window.mouseOverChatTab)
210+
chatButton.addEventListener('mouseout', window.mouseOutChatTab)
211+
chatButton.addEventListener('touchend', window.toggleChatTab)
212+
chatHeader.appendChild(chatTooltip)
213+
chatHeader.appendChild(chatTooltipArrow)
214+
chatHeader.appendChild(chatButton)
215+
216+
var chatWidget = document.createElement('div')
217+
chatWidget.setAttribute('id', 'lh3-chat-widget')
218+
chatWidget.setAttribute('style', 'position: fixed; top: 35%; right: 20px; z-index: 1000;')
219+
chatWidget.appendChild(chatHeader)
220+
chatWidget.appendChild(chatFrameWrap)
221+
document.body.appendChild(chatWidget)
222+
223+
var chatWidgetMouseDown = false
224+
window.dragChatWidget = function (event) {
225+
event.preventDefault()
226+
const dataOffset = chatWidget.getAttribute('data-offset')
227+
if (chatWidgetMouseDown && dataOffset) {
228+
const offset = JSON.parse(dataOffset)
229+
const left = event.type === 'mousemove' ? event.clientX : event.targetTouches[0].clientX
230+
const top = event.type === 'mousemove' ? event.clientY : event.targetTouches[0].clientY
231+
chatWidget.style.left = (left + offset[0]) + 'px'
232+
chatWidget.style.top = (top + offset[1]) + 'px'
233+
}
234+
}
235+
window.stopDraggingChatWidget = function (event) {
236+
chatWidgetMouseDown = false
237+
document.removeEventListener('mousemove', window.dragChatWidget, true)
238+
document.removeEventListener('touchmove', window.dragChatWidget, true)
239+
document.removeEventListener('mouseup', window.stopDraggingChatWidget, true)
240+
document.removeEventListener('touchend', window.stopDraggingChatWidget, true)
241+
}
242+
window.startDraggingChatWidget = function (event) {
243+
if (chatFrameWrap.style.display === 'none') {
244+
return // Chat box is not visible.
245+
}
246+
247+
event.preventDefault()
248+
event.stopPropagation()
249+
250+
chatWidgetMouseDown = true
251+
const left = event.type === 'mousedown' ? event.clientX : event.targetTouches[0].clientX
252+
const top = event.type === 'mousedown' ? event.clientY : event.targetTouches[0].clientY
253+
const chatWidgetOffset = [
254+
chatWidget.offsetLeft - left,
255+
chatWidget.offsetTop - top
256+
]
257+
chatWidget.setAttribute('data-offset', JSON.stringify(chatWidgetOffset))
258+
259+
document.addEventListener('mousemove', window.dragChatWidget, true)
260+
document.addEventListener('touchmove', window.dragChatWidget, true)
261+
document.addEventListener('mouseup', window.stopDraggingChatWidget, true)
262+
document.addEventListener('touchend', window.stopDraggingChatWidget, true)
263+
}
264+
265+
chatWidget.addEventListener('mousedown', window.startDraggingChatWidget, true)
266+
chatWidget.addEventListener('touchstart', window.startDraggingChatWidget, true)
267+
268+
window.lh3PresenceCheck = function () {
269+
s = document.createElement('script')
270+
s.async = true
271+
s.id = 'lh3-presence-check'
272+
s.src = 'https://eu.libraryh3lp.com/presence/jid/hsg-library-queue/chat.eu.libraryh3lp.com/js?cb=window.updateChatTab'
273+
s.type = 'application/javascript'
274+
document.body.appendChild(s)
275+
}
276+
277+
window.updateChatTab = function () {
278+
for (var i = 0; i < jabber_resources.length; ++i) {
279+
var resource = jabber_resources[i]
280+
if (resource.show !== 'available' && resource.show !== 'chat') {
281+
lh3ChatOnline = false
282+
283+
var busyText = document.querySelector('.lh3-busy')
284+
var offlineText = document.querySelector('.lh3-offline')
285+
286+
if (!busyText && !offlineText) {
287+
setTimeout(lh3PresenceCheck, 1000)
288+
}
289+
290+
var wrap = document.getElementById('lh3-chat-frame-wrap')
291+
wrap.style.borderColor = '#00802f'
292+
293+
var bar = document.getElementById('lh3-close-chat-bar')
294+
bar.style.backgroundColor = '#00802f'
295+
296+
var chatOfflineImage = document.createElement('img')
297+
if (resource.show === 'dnd') { // Busy
298+
chatOfflineImage.setAttribute('src', 'https://s3.amazonaws.com/libraryh3lp.com/eu/buttons/1725-st-gallen-chat-online.png')
299+
chatOfflineImage.setAttribute('alt', 'Chat ausgelastet / busy')
300+
301+
var lh3ChatFrameWrap = document.querySelector('#lh3-chat-frame-wrap')
302+
if (lh3ChatFrameWrap) {
303+
lh3ChatFrameWrap.style.borderColor = "#6829ff"
304+
lh3ChatFrameWrap.children[0].style.backgroundColor = "#6829ff"
305+
}
306+
307+
if (busyText && offlineText) {
308+
busyText.style.display = 'block'
309+
offlineText.style.display = 'none'
310+
}
311+
} else { // Away, Extended Away, Unavailable
312+
chatOfflineImage.setAttribute('src', 'https://s3.amazonaws.com/libraryh3lp.com/eu/buttons/1725-st-gallen-chat-offline.svg')
313+
chatOfflineImage.setAttribute('alt', 'Chat offline')
314+
315+
if (busyText && offlineText) {
316+
busyText.style.display = 'none'
317+
offlineText.style.display = 'block'
318+
}
319+
}
320+
chatOfflineImage.setAttribute('style', 'height: 46px; width: 46px; padding: 2px 0;')
321+
322+
var button = document.getElementById('lh3-chat-button')
323+
button.innerHTML = ''
324+
button.appendChild(chatOfflineImage)
325+
} else {
326+
lh3ChatOnline = true
327+
}
328+
}
329+
}
330+
331+
function clickAway(event) {
332+
var linkToggleRegex = RegExp('toggleChatTab')
333+
var linkElement = getClosest(event.target, 'a')
334+
if (showLH3Chat && !lh3ChatOnline && !getClosest(event.target, '#lh3-chat-widget') && (!linkElement || !linkToggleRegex.test(linkElement.getAttribute('onclick')))) {
335+
window.toggleChatTab(event)
336+
}
337+
}
338+
339+
document.addEventListener('click', clickAway)
340+
document.addEventListener('touchend', clickAway)
341+
342+
function handleEscape(event) {
343+
if (event.key === "Escape" && showLH3Chat && !lh3ChatOnline) {
344+
window.toggleChatTab(event)
345+
}
346+
}
347+
document.addEventListener('keyup', handleEscape)
348+
349+
var s = document.createElement('script')
350+
s.async = true
351+
s.id = 'lh3-chat-snippet'
352+
s.src = 'https://eu.libraryh3lp.com/js/libraryh3lp.js?1564'
353+
s.type = 'application/javascript'
354+
s.onload = lh3PresenceCheck
355+
document.body.appendChild(s)
356+
///////////////////////////////////////////
357+
/// code for LibraryH3lp chat ends here ///
358+
/// provided by support@libraryh3lp.com ///
359+
///////////////////////////////////////////
360+
}

js/modules/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ There is a proof of concept to report exceptions to a remote serivce via http, i
2626
* **`slsp-archives-viewit`** *module*\
2727
Adapted from SLSP, see: https://github.com/Swiss-Library-Service-Platform/central-customization-package/tree/main/41SLSP_NETWORK-CENTRAL_PACKAGE/js/slsp-archives-viewit
2828
<br><br>
29+
* **`prm-gallery-item-after`** *hook*
30+
* **`hsg-collections-show-author`** *module*\
31+
Show author name in collections.
32+
<br><br>
2933
* **`prm-journals-after`** *hook*
3034
* **`hsg-journals-startpage`** *module*\
3135
Start page for the journals search, similar to the [ETHZ Solution](https://gitlab.com/ethlibrary/slsp/customization-eth-view/-/tree/master/js/modules/prm-journals-after/eth-journals-startpage)

js/modules/alma-howovp-after/slsp-ill-signin-order-alert/slsp-ill-signin-order-alert.controller.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
export class slspIllSigninOrderAlertController {
22

3-
constructor() {
4-
this.vm = this.afterCtrl
5-
}
3+
constructor() { }
64

75
getAlert() {
6+
this.vm = this.afterCtrl
87
var ga = this.vm.parentCtrl.almaHowToGetitService.reqAlert._htmlMsg
98
var myEl2 = angular.element(document.querySelector('primo-explore'))
109

js/modules/alma-htgi-svc-after/slsp-archives-htgi/slsp-archives-htgi.controller.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
export class slspArchivesHtgiController {
22

3-
constructor() {
4-
this.parentCtrl = this.afterCtrl.parentCtrl
5-
}
3+
constructor() { }
64

75
$onInit() {
6+
this.parentCtrl = this.afterCtrl.parentCtrl
7+
88
if (!this.parentCtrl.item.pnx.display.source || this.parentCtrl.item.pnx.display.source.length === 0) {
99
return
1010
}

js/modules/prm-alma-other-members-after/slsp-collapse-other-inst/slsp-collapse-other-inst.controller.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
export class slspCollapseOtherInstController {
2-
constructor() {
2+
constructor() { }
3+
4+
$onInit() {
35
this.parentCtrl = this.afterCtrl.parentCtrl
46
this.parentCtrl.isCollapsed = true
57
}

js/modules/prm-alma-viewit-after/hsg-report-broken-link/hsg-report-broken-link.controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ export class hsgReportBrokenLinkController {
1111
this.status = ''
1212
this.errorMessage
1313
this.info = new LinkInfo()
14-
this.parentCtrl = this.afterCtrl.parentCtrl
1514
}
1615

1716
$onInit() {
17+
this.parentCtrl = this.afterCtrl.parentCtrl
1818
// not for open access
1919
if (this.parentCtrl.item.pnx.addata.openaccess && this.parentCtrl.item.pnx.addata.openaccess[0] === 'true') {
2020
return

js/modules/prm-alma-viewit-after/slsp-archives-viewit/slsp-archives-viewit.controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ export class slspArchivesViewitController {
22

33
constructor($translate) {
44
this.$translate = $translate
5-
this.parentCtrl = this.afterCtrl.parentCtrl
65
}
76

87
$onInit() {
8+
this.parentCtrl = this.afterCtrl.parentCtrl
99
if (!this.parentCtrl.item.pnx.display.source || this.parentCtrl.item.pnx.display.source.length === 0) {
1010
return
1111
}

0 commit comments

Comments
 (0)