Project

General

Profile

1
$(function() {
2

    
3
    var $grid = $('#galleryGrid');
4
    $grid.waitForImages(function() {
5
        console.log('All images have loaded.');
6
        var grid = UIkit.grid($grid, {
7
            gutter: 16
8
        });
9
    });
10

    
11
    var $customModal = $('#custom-ligthbox');
12
    if($customModal.length) {
13
        var lightbox = UIkit.modal('#custom-ligthbox', {
14
                center: true
15
            });
16

    
17
        $('.custom-modal-open').on('click', function(e) {
18
            e.preventDefault();
19
            $(this).addClass('jQ-lightbox-triggered');
20

    
21
            var imageId = $(this).attr('data-image-id'),
22
                $invoice_template = $('#lightbox-template-content'),
23
                template = $invoice_template.html(),
24
                template_compiled = Handlebars.compile(template),
25
                context = {
26
                    'img': lightbox_data[imageId].img,
27
                    'user_avatar': lightbox_data[imageId].user_avatar,
28
                    'user_name': lightbox_data[imageId].user_name,
29
                    'comment': lightbox_data[imageId].comment
30
                },
31
                theCompiledHtml = template_compiled(context);
32

    
33
            $('#lightbox-content').html(theCompiledHtml);
34

    
35
            lightbox.show();
36
        });
37

    
38
        $customModal.on('click','.uk-slidenav-previous',function(e) {
39
            e.preventDefault();
40
            var $prev = $grid.find('.jQ-lightbox-triggered').closest('.md-card').parent('div').prev('div').find('.custom-modal-open');
41
            if($prev.length) {
42
                lightbox.hide();
43
                setTimeout(function() {
44
                    $prev.trigger('click')
45
                }, 300)
46
            }
47
        });
48
        $customModal.on('click','.uk-slidenav-next',function(e) {
49
            e.preventDefault();
50
            var $next = $grid.find('.jQ-lightbox-triggered').closest('.md-card').parent('div').next('div').find('.custom-modal-open');
51
            if($next.length) {
52
                lightbox.hide();
53
                setTimeout(function() {
54
                    $next.trigger('click')
55
                }, 300)
56
            }
57
        });
58

    
59
        $customModal.on({
60
            'hide.uk.modal': function(){
61
                $grid.find('.jQ-lightbox-triggered').removeClass('jQ-lightbox-triggered')
62
            }
63
        });
64

    
65
    }
66

    
67
});
(45-45/114)