{"size": 1841, "ext": "js", "max_stars_repo_path": "view/frontend/web/js/google-analytics.js", "max_stars_repo_name": "magenable/module-purchase-from-partners", "max_stars_repo_stars_event_min_datetime": "2021-04-07T10:27:36.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-09T06:27:40.000Z", "max_issues_repo_path": "view/frontend/web/js/google-analytics.js", "max_issues_repo_name": "magenable/module-purchase-from-partners", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "view/frontend/web/js/google-analytics.js", "max_forks_repo_name": "magenable/module-purchase-from-partners", "max_forks_repo_forks_event_min_datetime": "2021-08-19T04:59:30.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-03T19:19:40.000Z"}
{"max_stars_count": 3, "max_issues_count": null, "max_forks_count": 2, "avg_line_length": 32.875, "max_line_length": 99, "alphanum_fraction": 0.4557305812}
define(['jquery', 'domReady!'], function ($) {
    'use strict';

    var defined = false;

    return function(analitycsIsEnabled, isOpenLinkInNewTab) {
        if (defined) {
            return false;
        }
        defined = true;

        $('.product-item-purchase-partner > button').on('click', function(e){
            $(e.currentTarget.nextElementSibling).toggleClass('hidden');
        });
        $('.product-item-purchase-partner').on('mouseleave', function(e){
            $(e.currentTarget).find('.magenable-purchase-partner-urls-wrapper').addClass('hidden');
        });

        $('.magenable-purchase-partner-url').on('click onchange', function(e){
            var $element = $(e.currentTarget);
            if ($element.prop('tagName').toUpperCase() == 'SELECT') {
                $element = $element.find('option:selected');
            }
            if (!$element.data('link')) {
                return false;
            }
            $('body').trigger('processStart');

            if (analitycsIsEnabled && window.ga) {
                ga(
                    'send',
                    {
                        hitType: 'event',
                        eventCategory: $element.data('event-category'),
                        eventAction: $element.data('event-action'),
                        eventLabel: $element.data('link'),
                        eventValue: $element.data('event-value')
                    }
                );
            }

            if (isOpenLinkInNewTab) {
                window.open(
                    $element.data('link'),
                    '_blank'
                ).focus();
                $('body').trigger('processStop');
            } else {
                document.location = $element.data('link');
            }

            e.preventDefault();
        });
    }
});
