PMA.UI Examples 2.43.3by Pathomation

Simple gallery

basicgallery
Console
PMA.UI version: 2.43.3
Gallery example, showing available events.
gallery.html
1<!doctype html>
2<html lang="en">
3
4<head>
5    <meta charset="utf-8">
6    <meta http-equiv="X-UA-Compatible" content="IE=10">
7    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
8
9    <!-- Include PMA.UI required libraries -->
10    <script src="./pma.ui/jquery-3.1.0.js"></script>
11    <link href="./pma.ui/font-awesome.min.css" type="text/css" rel="stylesheet">
12
13    <!-- Include PMA.UI script & css -->
14    <script src="./pma.ui/pma.ui.js"></script>
15    <link href="./pma.ui/pma.ui.css" type="text/css" rel="stylesheet">
16
17    <!-- Include custom script & css -->
18    <script src="./js/gallery.js"></script>
19    <link href="./css/gallery.css" type="text/css" rel="stylesheet">
20
21    <title>Simple Gallery</title>
22</head>
23
24<body>
25    <!-- The element that will host the gallery -->
26    <div id="gallery"></div>
27</body>
28
29</html>
gallery.css
1html,
2body
3{
4    height: 100%;
5    padding: 0px;
6    margin: 0px;
7}
8
9#gallery
10{
11    height: 100vh;
12}
gallery.js
1// Initial declarations
2var serverUrl = "https://host.pathomation.com/pma.core.2/";
3var serverUsername = "PMA_UI_demo";
4var serverPassword = "PMA_UI_demo";
5var directoryPath = "Reference/3DHistech";
6var galleryElementSelector = "#gallery";
7var caller = "DemoPortal";
8var galleryMode = "horizontal";
9var thumbnailWidth = 200;
10var thumbnailHeight = 150;
11
12jQuery(function () {
13    console.log(`PMA.UI version: ${PMA.UI.getVersion()}`);
14
15    // Create a context
16    var context = new PMA.UI.Components.Context({ caller: caller });
17
18    // Add an autologin authentication provider
19    new PMA.UI.Authentication.AutoLogin(context, [{ serverUrl: serverUrl, username: serverUsername, password: serverPassword }]);
20
21    // create a gallery that will display the contents of a directory
22    var gallery = new PMA.UI.Components.Gallery(context, {
23        element: galleryElementSelector,
24        thumbnailWidth: thumbnailWidth,
25        thumbnailHeight: thumbnailHeight,
26        mode: galleryMode,
27    });
28
29    // Load the contents of a directory
30    gallery.loadDirectory(serverUrl, directoryPath);
31
32    // Listen for the slide selected event by the gallery
33    gallery.listen(PMA.UI.Components.Events.SlideSelected, function (args) {
34        console.log("Slide selected");
35        console.log(args);
36    });
37
38    // Listen for the slide deselected event by the gallery
39    gallery.listen(PMA.UI.Components.Events.SlideDeSelected, function (args) {
40        console.log("Slide deselected");
41        console.log(args);
42    });
43
44    // Listen for the slide info error event by gallery
45    gallery.listen(PMA.UI.Components.Events.SlideInfoError, function (args) {
46        console.log("Slide info error");
47        console.log(args);
48    });
49
50    // Listen for the data dropped event by the gallery
51    gallery.listen(PMA.UI.Components.Events.Dropped, function (args) {
52        console.log("Data dropped in gallery");
53        console.log(args);
54    });
55});