-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathImageGrid.vue
More file actions
183 lines (171 loc) · 4.91 KB
/
ImageGrid.vue
File metadata and controls
183 lines (171 loc) · 4.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<template>
<!-- to use with a data, each item has to have id, imageURL and title. If the item has infoURL, geoLocations, authors, institutions, license they are used. -->
<div class="image-grid">
<div class="grid-items">
<div
class="grid-item"
v-for="(item, index) in items"
:key="item.id"
@click="showImageViewer(index)"
>
<img
:src="[item.thumbURL ? item.thumbURL : placeholder]"
class="thumb-image"
:alt="item.title"
>
<div class="thumb-image-info">
<div v-for="title in item.title" :key="title.id" class="thumb-title">{{ title }}</div>
<div class="thumb-credit">{{ getCredits(item) }}</div>
<img class="icon" :src="getIcon(item)" align="right">
</div>
<div class="thumb-image-header">
<div class="left-align" @click.stop>
<ImagesActionMenu v-bind:element="item"></ImagesActionMenu>
<div
v-if="item.geoLocations != undefined && item.geoLocations.length > 0"
class="header-item"
>
<a href="#" @click.stop.prevent="showItemGeolocation(item)">
<i class="wikiglyph wikiglyph-map-pin thumb-image-glyph"></i>
</a>
</div>
</div>
<div class="right-align">
<div v-if="item.infoURL != undefined" class="header-item">
<a href="#" @click.stop.prevent="openItemInfoURL(item.infoURL)">
<i class="wikiglyph wikiglyph-new-window thumb-image-glyph"></i>
</a>
</div>
<!-- <ImagesRemoveMenu></ImagesRemoveMenu> -->
</div>
</div>
</div>
</div>
<ImageViewer ref="imageviewer"></ImageViewer>
<!--<button type="button" @click="show">Show</button>-->
</div>
</template>
<script>
import ImageViewer from "@/components/image_viewer/ImageViewer";
import ImagesActionMenu from '@/components/menu/ImagesActionMenu';
// import ImagesRemoveMenu from '@/components/menu/ImagesRemoveMenu';
export default {
name: "ImageGrid",
props: {
items: Array
},
data() {
return {
placeholder: "../../static/pngs/imageplaceholder.png"
}
},
components: {
ImageViewer,
ImagesActionMenu,
// ImagesRemoveMenu,
},
methods: {
getCredits(item) {
let newAuthors = [];
if (item.source == "Finna") {
for (let author of item.creators) {
newAuthors.push(author.name + ", ");
}
} else if (!!item.creators && item.creators.length > 0) {
newAuthors = item.creators + ", ";
}
var newYear =
item.year != "" && item.year != null ? item.year + ". " : "";
var newInstitutions =
item.institutions != "" ? item.institutions + ", " : "";
var newLicense = item.license != "" ? item.license + ", " : "";
var credits = newAuthors + newYear + newInstitutions + newLicense;
if (credits.length > 0 && credits.slice(-2) == ", ") {
credits = credits.substr(0, credits.length - 2);
}
return credits;
},
getIcon(item) {
let icon = '';
switch (item.source) {
case 'Finna':
icon = '../../static/icons/finna-mini.png';
break;
case 'Flickr':
icon = '../../static/icons/flickr-mini.png';
break;
case 'Wikimedia Commons':
icon = '../../static/icons/commons-mini.png';
break;
case 'CC Search':
icon = '../../static/icons/cc-mini.png';
break;
case 'Europeana':
icon = '../../static/icons/europeana-mini.png';
break;
case 'Smithsonian':
icon = '../../static/icons/smithsonian-mini.png';
break;
case 'Trove':
icon = '../../static/icons/trove-mini.png';
break;
}
return icon;
},
showItemGeolocation(item) {
this.$emit("showItemGeolocation", item);
},
showImageViewer(index) {
this.$refs.imageviewer.show(this.items, index);
},
openItemInfoURL(url) {
window.open(url, "_blank");
}
}
};
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
/* .header-item {
line-height: 1;
height: 30px;
width: 30px;
}
.header-item a {
height: 100%;
display: flex;
align-items: center;
transition: color 80ms ease-in, background 80ms ease-in;
justify-content: center;
cursor: pointer;
box-shadow: none;
color: white;
}
.header-item:hover {
background: white;
}
.header-item:hover a {
color: var(--main-txt-color);
} */
/* .grid-items {
display: flex;
flex-wrap: wrap;
margin-left: 3px;
}
.grid-item {
cursor: pointer;
position: relative;
margin: 0 3px 3px 0;
flex: auto;
display: flex;
flex-direction: column;
}
.grid-item:hover * {
opacity: 1;
transition: opacity 80ms ease-in;
} */
/* .thumb-image {
height: 13rem;
object-fit: cover;
} */
</style>