Welcome to mirror list, hosted at ThFree Co, Russian Federation.

lightGallery-init.js « js « assets - github.com/Fastbyte01/KeepIt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 67de4051dd262cb6acbd643aac6ecdce36b71604 (plain)
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
 $(document).ready(function() {
     let items = [];
     $('.post-content figure').each(function() {
         if ($(this).attr('class') == 'gallery-ignore') return true; // ignore any figures where class="pswp-ignore"
         // get properties from child a/img/figcaption elements,
         let $figure = $(this),
             $img = $figure.find('img'),
             $src = $img.attr('data-src'),
             $title = $figure.find('figcaption').html();

         if ($img.data('size')) {
			let $size 	= $a.data('size').split('x');
			var item = {
             'src': $src,
             'thumb': $src,
             'subHtml': $title,
             'width': $size[0],
             'height': $size[1]
         }
         }else{
 			var item = {
             'src': $src,
             'thumb': $src,
             'subHtml': $title
         	}	
         	var img = new Image(); 
			img.src = $src;
			var wait = setInterval(function() {
				var w = img.naturalWidth,
					h = img.naturalHeight;
				if (w && h) {
					clearInterval(wait);
					item.width = w;
					item.height = h;
				}
			}, 30);
         }    
        
         var index = items.length;
         items.push(item);
        // console.log(item)

         $figure.on('click', function(event) {
             event.preventDefault(); 
             $(this).lightGallery({
                 dynamic: true,
                 download: false,
                 showThumbByDefault: false,
                 dynamicEl: items,
                 index: index
             })
         });
     });
 });