HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/buyercall_new/buyercall/buyercall/static/js/pages/compGallery.js
/*
 *  Document   : compGallery.js
 *  Author     : pixelcave
 *  Description: Custom javascript code used in Image Gallery page
 */

var CompGallery = function() {

    return {
        init: function() {
            var galleryFilter = $('.gallery-filter');
            var gallery       = $('.gallery');
            var showCategory;

            // When a gallery filter link is clicked
            galleryFilter.find('a').on('click', function() {
                // Get its data-category value
                showCategory = $(this).data('category');

                // Procceed only if the user clicked on an inactive category
                if ( ! $(this).hasClass('active')) {
                    // Remove active class from all filter links
                    galleryFilter.find('a').removeClass('active');

                    // Add the active class to the clicked link
                    $(this).addClass('active');

                    // If the value is 'all' hide the current visible items and show them all together, else hide them all and show only from the category we need
                    if (showCategory === 'all') {
                        gallery
                            .find('.gallery-image-container')
                            .parent()
                            .hide(0, function(){
                                $(this).show(0);
                            });
                    } else {
                        gallery
                            .find('.gallery-image-container')
                            .parent()
                            .hide(0, function(){
                                gallery
                                    .find('[data-category="' + showCategory + '"]')
                                    .parent('div')
                                    .show(0);
                            });
                    }
                }
            });
        }
    };
}();