PageSourceSearch

https://garagegymbuilder.com/wp-content/themes/rev-template-parent/inc/giveaway/assets/giveaway.js?ver=1.0.4

js garagegymbuilder.com collected 2026-10-02 18:58:31 UTC 11,849 bytes, 279 lines download raw bytes

1/**
2 *  Content Giveaway
3 */
4
5(function ($) {
6    $(window).on('load', function () {
7        $('.clock-builder-output .flip').each(function (e) {
8            if (e == 6) $('.clock-builder-output').addClass('clock-builder-output_3');
9        });
10    });
11})(jQuery);
12
13class_giveaway =
14    {
15        container: null,
16        clock_output: null,
17        date: null,
18        ajax_nonce: null,
19        ajaxurl: null,
20        init: function (container, clock_output, date, ajax_nonce, ajaxurl) {
21            var self = this;
22            (function ($) {
23                $(document).on('ready', function () {
24
25                    //Popup
26                    var popup = $('.rc-gv-popup-wrap'), popup_show_timeout, hide_popup, enter_giveaway_param;
27                    hide_popup = self.getCookie('giveaway_done_popup'+ popup.data('id'));
28                    enter_giveaway_param = location.search.split('enter_giveaway=')[1];
29
30                    if(enter_giveaway_param == 'true') hide_popup = false;
31
32                    if(popup.length && !hide_popup) {
33                        if(enter_giveaway_param == 'true') {
34                            popup_show_timeout = 1;
35                        } else {
36                            popup_show_timeout = 15;
37                        }
38
39                        setTimeout(function () {
40                            popup.addClass('active');
41                            $('body').addClass('modal-open');
42                            var content_url = popup.find('.two-products .giveaway-content-url a > span:first-child');
43                            content_url.length && content_url.equivalent();
44                        }, popup_show_timeout *1000);
45                    }
46
47                    popup.on('click', '.button-close', function(e){
48                        e.preventDefault();
49                        if(!popup.hasClass('active')) return;
50
51                        self.close_popup(popup, ajaxurl);
52                    });
53
54                    /*$(document).mouseup(function (event) {
55                        if(!popup.length || !popup.hasClass('active')) return;
56
57                        if(  $(event.target).closest('.rc-gv-popup-items').length )
58                            return;
59
60                        self.close_popup(popup, ajaxurl);
61                    });*/
62
63                    //Close popup if not used after 1 min
64                    popup.on('click', '.rc-gv-popup-items', function(){
65                        popup.addClass('used');
66                    });
67                    setTimeout(function () {
68                        !popup.hasClass('used') && popup.removeClass('active');
69                    }, (popup_show_timeout + 60) *1000);
70
71                    //Widget
72                    var button = $('.buttom_giveaway'),
73                        widget = $('.fixed_gw'),
74                        header = $('.site-header'),
75                        closer = $('.p_closer'),
76                        button_id = button.data('id'),
77                        hide_button = self.getCookie('giveaway_hide_button'+ button_id);
78
79                    if(button.length && !hide_button && $(window).innerWidth() < 768) {
80                        button.show();
81                    }
82
83                    button.on('click', '.open', function(){
84                        button.attr('style', 'display:none;');
85                        widget.attr('style', 'display:block; z-index:444;');
86                        header.attr('style', 'top:-150px');
87
88                        var content_url = $('.two-products .giveaway-content-url a > span:first-child');
89                        var maxH = content_url.equivalent();
90                    });
91
92                    button.on('click', '.hide-gw-button', function(){
93                        self.setCookie('giveaway_hide_button' + button_id, 1, 1);
94                        button.height(0);
95                    });
96
97                    closer.on('click', function(){
98                        widget.attr('style', 'display:none; z-index:0;');
99                        button.attr('style', 'display:block;');
100                        header.attr('style', '');
101                    });
102
103                    if($('*').is('.buttom_giveaway')){
104                        $('.et_social_mobile, .et_social_active_button').attr('style', 'display:none;');
105                    }
106
107                    FlipClock.Lang.Custom = {days: 'Days', hours: 'Hours', minutes: 'Minutes', seconds: 'Seconds'};
108                    var opts = {
109                            clockFace: 'DailyCounter',
110                            countdown: true,
111                            showSeconds: false,
112                            language: 'Custom'
113                        },
114                        countdown = date - ((new Date().getTime()) / 1000);
115
116                    countdown = Math.max(1, countdown);
117                    $('.'+clock_output).FlipClock(countdown, opts);
118
119
120                    //Form
121                    $(document).on('click', '.'+container+' .submit-giveaway', function (e) {
122                        e.preventDefault();
123
124                        var self = $(this),
125                            widget = self.closest('.monthly-giveaway-item');
126
127                        if(widget.length && !widget.hasClass('visible') && window.innerWidth > 767) {
128                            widget.addClass('visible');
129                            $('html, body').animate({'scrollTop': $(window).scrollTop() + 240}, 'slow');
130                            return false;
131                        }
132
133                        var form = $('.' + container),
134                            type = form.data('type'),
135                            data = {
136                                action: 'giveaway_set',
137                                post_id: form.find('input[name=giveaway_entries_post]').val(),
138                                email: form.find('input[name=giveaway_email]').val(),
139                                type: type,
140                                security: ajax_nonce
141                            };
142
143                        if (typeof rc_utm_tags !== 'undefined' && typeof rc_utm_tags.aaff_page_code !== 'undefined') {
144                            data.page_code = rc_utm_tags.aaff_page_code
145                        }
146
147                        $.post(ajaxurl, data, function (data) {
148                            var parent = form.closest('.rc-gv-popup-wrap');
149                            if(type == 'popup' && data.data == 'Your email already saved') {
150                                parent.find('.popup-counter.email').hide();
151                                parent.find('.popup-counter.social').show();
152                                parent.find('.popup-counter.social .popup-title-form').html(' Your Email is already in our system.<br>Double your odds of winning by subscribing to Youtube! (We will contact you via the email in our system)');
153                            }
154
155                            if (data.success == true) {
156                                if(type == 'popup') {
157                                    parent.find('.popup-counter.email').hide();
158                                    parent.find('.popup-counter.social').show();
159                                    parent.find('.popup-counter.social .popup-title-form-m').show();
160                                }
161
162                                form.prepend('<p class="success-message">Your email has been successfully saved!</p>');
163                                form.find('[name=giveaway_email]').val('');
164                            } else {
165                                form.find('[name=giveaway_email]').addClass('error').val(data.data);
166                            }
167
168                        });
169
170                        $(document).on('click', '.'+container+' input.error', function (e) {
171                            $(this).removeClass('error').val('');
172                        });
173                        $(document).on('click', '.'+container, function (e) {
174                            $(this).find('.success-message').remove();
175                            $(this).find('.error-message').remove();
176                        });
177                    });
178                    $.fn.equivalent = function (){
179                        var $blocks = $(this),
180                            maxH    = $blocks.eq(0).height();
181
182                        $blocks.each(function(){
183                            maxH = ( $(this).height() > maxH ) ? $(this).height() : maxH;
184                        });
185
186                        $blocks.height(maxH);
187
188                        return maxH;
189                    };
190
191                    var content_url = widget.find('.two-products .giveaway-content-url a > span:first-child');
192                    content_url.length && window.innerWidth > 767 && content_url.equivalent();
193
194                    var content_url_a = $('.rc-gv-after-content-wrap .two-products .giveaway-content-url a > span:first-child');
195                    content_url_a.length && content_url_a.equivalent();
196                });
197            })(jQuery);
198        },
199
200        close_popup: function (popup, ajaxurl) {
201            var $post_id = popup.find('input[name=giveaway_entries_post]').val();
202            popup.removeClass('active');
203
204            jQuery('body').removeClass('modal-open');
205
206            this.setCookie('giveaway_done_popup' + $post_id, 1, 30);
207
208            /*var data = {
209                action: 'giveaway_close_popup',
210                post_id: popup.find('input[name=giveaway_entries_post]').val()
211            };
212            jQuery.post(ajaxurl, data, function (data) {
213                return false;
214            });*/
215        },
216
217        setCookie: function(key, value, period) {
218            var expires = new Date();
219            expires.setTime(expires.getTime() + (value * period * 24 * 60 * 60 * 1000));
220            document.cookie = key + '=' + value + ';expires=' + expires.toUTCString() + "; path=/";
221        },
222
223        getCookie: function (key) {
224            var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)');
225            return keyValue ? keyValue[2] : null;
226        }
227    };
228
229/**
230 *  Set Giveaway stat
231 */
232var giveawayStat = {
233    init: function () {
234        (function ($) {
235            $(document).on('ready', function () {
236                $(document).on('click', '.monthly-giveaway-content-wrap .easyazon-link', function () {
237                    var $parent = $(this).closest('.monthly-giveaway-content-wrap'),
238                        data = {
239                            action: 'giveaway_set_stat',
240                            post_id: $parent.data('id'),
241                            device: 'desktop',
242                            type: 'widget',
243                            security: giveaway_script.nonce
244                        };
245
246                    if(isMobile.any()) { data.device = 'mobile'}
247                    if($parent.hasClass('rc-gv-popup-wrap')) { data.type = 'popup'}
248                    console.log()
249                    $.post(giveaway_script.ajax_url, data, function (data) {
250                        //console.log(data);
251                    });
252                });
253            });
254        })(jQuery);
255    }
256};
257
258var isMobile = {
259    Android: function() {
260        return navigator.userAgent.match(/Android/i);
261    },
262    BlackBerry: function() {
263        return navigator.userAgent.match(/BlackBerry/i);
264    },
265    iOS: function() {
266        return navigator.userAgent.match(/iPhone|iPad|iPod/i);
267    },
268    Opera: function() {
269        return navigator.userAgent.match(/Opera Mini/i);
270    },
271    Windows: function() {
272        return navigator.userAgent.match(/IEMobile/i);
273    },
274    any: function() {
275        return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
276    }
277};
278
279giveawayStat.init();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.