-
Notifications
You must be signed in to change notification settings - Fork 25
/
script.js
73 lines (65 loc) · 2.36 KB
/
script.js
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
/* DOKUWIKI:include_once simple-lightbox/simple-lightbox.js */
/* DOKUWIKI:include script/prosemirror.js */
jQuery(function () {
/**
* Add a quicklink to the media popup
*/
(function() {
const $opts = jQuery('#media__opts');
if (!$opts.length) return;
if (!window.opener) return; // we're not in the popup
const glbl = document.createElement('label');
const glnk = document.createElement('a');
const gbrk = document.createElement('br');
glnk.innerHTML = LANG.plugins.gallery.addgal;
glnk.style.cursor = 'pointer';
glnk.href = '#';
glnk.onclick = function () {
const $h1 = jQuery('#media__ns');
if (!$h1.length) return;
const ns = $h1[0].textContent;
opener.insertAtCarret('wiki__text', '{{gallery>' + ns + '}}');
if (!dw_mediamanager.keepopen) window.close();
};
$opts[0].appendChild(glbl);
glbl.appendChild(glnk);
$opts[0].appendChild(gbrk);
})();
/**
* Display a selected page and hide all others
*/
(function() {
// hide all pages except the first one in each gallery
jQuery('.plugin-gallery').each(function() {
const $gallery = jQuery(this);
$gallery.find('.gallery-page').hide().eq(0).show();
$gallery.find('.gallery-page-selector a').eq(0).addClass('active');
});
// attach page selector
jQuery('.gallery-page-selector a').click(function(e) {
const $self = jQuery(this);
$self.siblings().removeClass('active');
$self.addClass('active');
const $gallery = $self.closest('.plugin-gallery');
$gallery.find('.gallery-page').hide();
$gallery.find(e.target.hash).show();
e.preventDefault();
});
// make page selector visible
jQuery('.gallery-page-selector').show();
})();
/**
* Initialize the lightbox
*/
new SimpleLightbox("a.lightbox, a[rel^='lightbox']", {
sourceAttr: 'data-url',
captionSelector: 'self',
captionType: 'data',
captionsData: 'caption',
captionPosition: 'outside',
captionHTML: true, // we allow HTML and double escape in the formatter
alertError: false,
fileExt: false,
uniqueImages: false
});
});