-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathimage.js
More file actions
executable file
·72 lines (61 loc) · 2.2 KB
/
image.js
File metadata and controls
executable file
·72 lines (61 loc) · 2.2 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
import './image.scss';
import imageTemplate from './image.tpl.html';
const ImageService = ($mdDialog, $timeout) => {
const service = {
openImage,
};
return service;
//
function openImage(params) {
return $mdDialog.show({
parent: angular.element(document.body),
targetEvent: params.event,
clickOutsideToClose: true,
template: imageTemplate,
controller: ($scope) => {
const list = params.list;
const vm = $scope;
vm.close = () => $mdDialog.hide();
vm.image = params.image;
vm.keyDown = keyDown;
vm.nextImage = nextImage;
vm.prevImage = prevImage;
vm.activate_scroll = params.activate_scroll
init();
$timeout(() => { vm.loaded = true; }, 150);
function init() {
vm.author = vm.image.extmetadata.Artist ? vm.image.extmetadata.Artist.value : '';
vm.date = vm.image.extmetadata.DateTime ? new Date(vm.image.extmetadata.DateTime.value) : '';
vm.description = vm.image.extmetadata.ImageDescription ? vm.image.extmetadata.ImageDescription.value : '';
vm.license = vm.image.extmetadata.LicenseShortName ? vm.image.extmetadata.LicenseShortName.value : '';
}
function keyDown(key) {
if (key.keyCode === 39) { nextImage(); }
if (key.keyCode === 37) { prevImage(); }
}
function nextImage() {
let currentIndex = list.indexOf(vm.image);
if (currentIndex > -1) {
currentIndex = currentIndex + 1 === list.length ? 0 : currentIndex + 1;
vm.image = list[currentIndex];
init();
}
}
function prevImage() {
let currentIndex = list.indexOf(vm.image);
if (currentIndex > -1) {
currentIndex = currentIndex ? currentIndex - 1 : list.length - 1;
vm.image = list[currentIndex];
init();
}
}
},
});
}
};
export default () => {
angular
.module('monumental')
.factory('imageService', ImageService)
.filter('htmlToPlaintext', () => text => angular.element(`<div>${text}</div>`).text());
};