(function($) {
    $(document).on("click", ".campaign-list", function(e){
        var dataTitle   = $(this).attr("bb-title");
        var dataList    = $(this).attr("bb-list");
        var dataAuthor  = $(this).attr("bb-author");
        var dataType    = $(this).attr("bb-type");
        var targetUrl   = $(this).attr("href") || $(this).attr("bb-href");

        console.log("Trigger");

        dataLayer.push({
            'event': 'campaignListClick',
            'nonprofit': {
                'click': {
                    'actionField': {'list': dataList},      // Optional list property.
                    'campaign': {
                        'name': dataTitle,                      // Name or ID is required.
                        'author': dataAuthor,
                        'type': dataType
                    }
                }
            },
            'eventCallback' : function() {
                document.location = targetUrl;
            }
        });

        e.preventDefault();
    });

    $(document).on("click", ".ceritaMereka-list", function(e){
        var dataTitle   = $(this).attr("bb-title");
        var dataList    = $(this).attr("bb-list");
        var dataAuthor  = $(this).attr("bb-author");
        var dataType    = $(this).attr("bb-type");
        var targetUrl   = $(this).attr("href") || $(this).attr("bb-href");

        console.log("Trigger");

        dataLayer.push({
            'event': 'CeritaMerekaListClick',
            'nonprofit': {
                'click': {
                    'actionField': {'list': dataList},      // Optional list property.
                    'campaign': {
                        'name': dataTitle,                      // Name or ID is required.
                        'author': dataAuthor,
                        'type': dataType
                    }
                }
            },
            'eventCallback' : function() {
                document.location = targetUrl;
            }
        });

        e.preventDefault();
    });

    $(document).on("click", ".bannerEvent-list", function(e){
        var dataTitle   = $(this).attr("bb-title");
        var dataList    = $(this).attr("bb-list");
        var dataAuthor  = $(this).attr("bb-author");
        var dataType    = $(this).attr("bb-type");
        var targetUrl   = $(this).attr("href") || $(this).attr("bb-href");

        console.log("Trigger"); 

        dataLayer.push({
            'event': 'BannerEventListClick',
            'nonprofit': {
                'click': {
                    'actionField': {'list': dataList},      // Optional list property.
                    'campaign': {
                        'name': dataTitle,                      // Name or ID is required.
                        'author': dataAuthor,
                        'type': dataType
                    }
                }
            },
            'eventCallback' : function() {
                document.location = targetUrl;
            }
        });

        e.preventDefault();
    });

    $(document).on("click", ".Impact-list", function(e){ 
        var dataTitle   = $(this).attr("bb-title");
        var dataList    = $(this).attr("bb-list");
        var dataAuthor  = $(this).attr("bb-author");
        var dataType    = $(this).attr("bb-type");
        var targetUrl   = $(this).attr("href") || $(this).attr("bb-href");

        console.log("Trigger"); 

        dataLayer.push({
            'event': 'ImpactListClick',
            'nonprofit': {
                'click': {
                    'actionField': {'list': dataList},      // Optional list property.
                    'campaign': {
                        'name': dataTitle,                      // Name or ID is required.
                        'author': dataAuthor,
                        'type': dataType
                    }
                }
            },
            'eventCallback' : function() {
                document.location = targetUrl;
            }
        });

        e.preventDefault();
    });

    $(document).on("click", ".banner-list", function(e){
        var dataTitle  = $(this).attr("bb-title");
        var dataList   = $(this).attr("bb-list");
        var targetUrl  = $(this).attr("href");

        dataLayer.push({
            'event': 'bannerListClick',
            'nonprofit': {
                'click': {
                    'actionField': {'list': dataList},      // Optional list property.
                    'banner': {
                        'name': dataTitle,                      // Name or ID is required.
                    }
                }
            },
            'eventCallback' : function() {
                document.location = targetUrl;
            }
        });

        e.preventDefault();
    });

    $(document).on("click", ".event-list", function(e){
        var dataTitle  = $(this).attr("bb-title");
        var dataList   = $(this).attr("bb-list");
        var targetUrl  = $(this).attr("href");

        dataLayer.push({
            'event': 'seasonListClick',
            'nonprofit': {
                'click': {
                    'actionField': {'list': dataList},      // Optional list property.
                    'banner': {
                        'name': dataTitle,                      // Name or ID is required.
                    }
                }
            },
            'eventCallback' : function() {
                document.location = targetUrl;
            }
        });

        e.preventDefault();
    });

    $(".session-list").on("click", function(e){
        var dataTitle  = $(this).attr("bb-name");
        var dataList   = $(this).attr("bb-list");
        var targetUrl  = $(this).attr("href") || $(this).attr("bb-href");

        var a, path;
        if(targetUrl){
            a = $('<a>', {
                href: targetUrl
            });
            path = a.prop('pathname');
        }

        dataLayer.push({
            'event': 'sessionEventClick',
            'nonprofit': {
                'click': {
                    'actionField': {'list': dataList},      // Optional list property.
                    'universal': {
                        'name': dataTitle,                      // Name or ID is required.
                        'target': path,                      // Name or ID is required.
                    }
                }
            },
            'eventCallback' : function() {
                document.location = targetUrl;
            }
        });

        e.preventDefault();
    });

    $(document).on("click", ".pilihan-zakat-list", function(e){
        var dataTitle   = $(this).attr("bb-title"); 
        var dataList    = $(this).attr("bb-list");
        var dataAuthor  = $(this).attr("bb-author");
        var dataType    = $(this).attr("bb-type");
        var targetUrl   = $(this).attr("href") || $(this).attr("bb-href");

        console.log("Trigger");   

        dataLayer.push({
            'event': 'pilihanZakatClick',
            'nonprofit': {
                'click': {
                    'actionField': {'list': dataList},      // Optional list property.
                    'campaign': {
                        'name': dataTitle,                      // Name or ID is required.
                        'author': dataAuthor,
                        'type': dataType
                    }
                }
            },
            'eventCallback' : function() {
                document.location = targetUrl;
            }
        });

        e.preventDefault();
    });

    $(document).on("click", ".download-ads-apk", function(e){
        var dataTitle  = $(this).attr("bb-title");
        var dataList   = $(this).attr("bb-list");
        // var targetUrl  = $(this).attr("href");

        dataLayer.push({
            'event': 'DownloadClick',
            'nonprofit': {
                'click': {
                    'actionField': {'list': dataList},      // Optional list property.
                    'banner': {
                        'name': dataTitle,                      // Name or ID is required.
                    }
                }
            }
        });
    });

})(jQuery);
