PageSourceSearch

https://www.whatwouldcathyeat.com/wp-content/plugins/gourmet-ads/js/ga-fixed-widget_ver-5.0.4.js

js whatwouldcathyeat.com collected 2026-09-26 11:17:54 UTC 11,162 bytes, 270 lines download raw bytes

1var _____WB$wombat$assign$function_____=function(name){return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name))||self[name];};if(!self.__WB_pmw){self.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}{
2let window = _____WB$wombat$assign$function_____("window");
3let self = _____WB$wombat$assign$function_____("self");
4let document = _____WB$wombat$assign$function_____("document");
5let location = _____WB$wombat$assign$function_____("location");
6let top = _____WB$wombat$assign$function_____("top");
7let parent = _____WB$wombat$assign$function_____("parent");
8let frames = _____WB$wombat$assign$function_____("frames");
9let opens = _____WB$wombat$assign$function_____("opens");
10if (typeof ga_sidebar_options != 'undefined' && ga_sidebar_options.length > 0) {
11    if (window.jQuery) {
12        if (ga_sidebar_options[0].window_load_hook) {
13            jQuery(window).load(ga_sidebar_init());
14        } else {
15            jQuery(document).ready(ga_sidebar_init());
16        }
17    } else {
18        console.log('jQuery is not loaded!');
19    }
20} else {
21    console.log('ga_sidebar_options not found!');
22}
23
24function ga_sidebar_init() {
25    for (var i = 0; i < ga_sidebar_options.length; i++) {
26        ga_sidebar(ga_sidebar_options[i]);
27    }
28    jQuery(window).on('resize', function () {
29        for (var i = 0; i < ga_sidebar_options.length; i++) {
30            ga_sidebar(ga_sidebar_options[i]);
31        }
32    });
33    var MutationObserver = (function () {
34        var prefixes = ['WebKit', 'Moz', 'O', 'Ms', ''];
35        for (var i = 0; i < prefixes.length; i++) {
36            if (prefixes[i] + 'MutationObserver' in window) {
37                return window[prefixes[i] + 'MutationObserver'];
38            }
39        }
40        return false;
41    }());
42    if (ga_sidebar_options[0].disable_mo_api == false && MutationObserver) {
43        gaRefresh = false
44        var htmlObserver = new MutationObserver(function (mutations) {
45            mutations.forEach(function (mutation) {
46                if (ga_exclude_mutations_array(ga_sidebar_options).indexOf(mutation.target.id) == -1) {
47                    gaRefresh = true;
48                    //console.log('Mutation detected!');
49                }
50            });
51        });
52        htmlObserver.observe(document.body, {childList: true, attributes: true, attributeFilter: ['style', 'class'], subtree: true});
53        setInterval(function () {
54            if (gaRefresh) {
55                for (var i = 0; i < ga_sidebar_options.length; i++) {
56                    ga_sidebar(ga_sidebar_options[i]);
57                }
58                gaRefresh = false;
59            }
60        }, 300);
61    } else {
62        console.log('MutationObserver not supported or disabled!');
63        if (ga_sidebar_options[0].refresh_interval > 0) {
64            setInterval(function () {
65                for (var i = 0; i < ga_sidebar_options.length; i++) {
66                    ga_sidebar(ga_sidebar_options[i]);
67                }
68            }, ga_sidebar_options[0].refresh_interval);
69        }
70    }
71}
72
73function ga_exclude_mutations_array(ga_sidebar_options) {
74    var out = new Array();
75    for (var i = 0; i < ga_sidebar_options.length; i++) {
76        if (ga_sidebar_options[i].widgets.length > 0) {
77            for (var k = 0; k < ga_sidebar_options[i].widgets.length; k++) {
78                out.push(ga_sidebar_options[i].widgets[k]);
79                out.push(ga_sidebar_options[i].widgets[k] + '_clone');
80            }
81        }
82    }
83    return out;
84}
85
86function ga_sidebar(options) {
87
88    if (!options)
89        return false;
90
91    if (!options.widgets)
92        return false;
93
94    if (options.widgets.length < 1)
95        return false;
96
97    if (!options.sidebar)
98        options.sidebar = 'ga-default-sidebar';
99
100    //console.log(options.sidebar + '  call');
101
102    function widget() {} // widget class
103
104    var widgets = new Array();
105
106    var window_height = jQuery(window).height();
107    var document_height = jQuery(document).height();
108    var fixed_margin_top = options.margin_top;
109
110    if (jQuery('#wpadminbar').length) { // WordPress admin bar 
111        fixed_margin_top = options.margin_top + jQuery('#wpadminbar').height();
112    }
113
114    jQuery('.ga-widget-clone-' + options.sidebar).remove(); // clear fixed mode p1
115
116    for (var i = 0; i < options.widgets.length; i++) {
117        widget_obj = jQuery('#' + options.widgets[i]);
118        widget_obj.css('position', ''); // clear fixed mode p2
119        if (widget_obj.attr('id')) {
120            widgets[i] = new widget();
121            widgets[i].obj = widget_obj;
122            widgets[i].clone = widget_obj.clone();
123            widgets[i].clone.children().remove();
124            widgets[i].clone_id = widget_obj.attr('id') + '_clone';
125            widgets[i].clone.addClass('ga-widget-clone-' + options.sidebar);
126            widgets[i].clone.attr('id', widgets[i].clone_id);
127            widgets[i].clone.css('height', widget_obj.height());
128            widgets[i].clone.css('visibility', 'hidden');
129            widgets[i].offset_top = widget_obj.offset().top;
130            widgets[i].fixed_margin_top = fixed_margin_top;
131            widgets[i].height = widget_obj.outerHeight(true);
132            widgets[i].fixed_margin_bottom = fixed_margin_top + widgets[i].height;
133            fixed_margin_top += widgets[i].height;
134        } else {
135            widgets[i] = false;
136        }
137    }
138
139    var next_widgets_height = 0;
140
141    var widget_parent_container;
142
143    for (var i = widgets.length - 1; i >= 0; i--) {
144        if (widgets[i]) {
145            widgets[i].next_widgets_height = next_widgets_height;
146            widgets[i].fixed_margin_bottom += next_widgets_height;
147            next_widgets_height += widgets[i].height;
148            if (!widget_parent_container) {
149                widget_parent_container = widget_obj.parent();
150                widget_parent_container.addClass('ga-fixed-widget-container');
151                widget_parent_container.css('height', '');
152                widget_parent_container.height(widget_parent_container.height());
153            }
154        }
155    }
156
157    jQuery(window).off('scroll.' + options.sidebar);
158
159    for (var i = 0; i < widgets.length; i++) {
160        if (widgets[i])
161            fixed_widget(widgets[i]);
162    }
163
164    function fixed_widget(widget) {
165
166        //console.log('fixed_widget call: ' + widget.obj.attr('id') + '==>' +options.sidebar);
167
168        var trigger_top = widget.offset_top - widget.fixed_margin_top;
169        var trigger_bottom = document_height - options.margin_bottom;
170
171        if (options.stop_id && jQuery('#' + options.stop_id).length) {
172            trigger_bottom = jQuery('#' + options.stop_id).offset().top - options.margin_bottom;
173        }
174
175        var widget_width;
176        if (options.width_inherit)
177            widget_width = 'inherit';
178        else
179            widget_width = widget.obj.css('width');
180
181        var style_applied_top = false;
182        var style_applied_bottom = false;
183        var style_applied_normal = false;
184        
185        jQuery(window).on('scroll.' + options.sidebar, function (event) {
186            
187            if (jQuery(window).width() <= options.screen_max_width || jQuery(window).height() <= options.screen_max_height) {
188                if (!style_applied_normal) {
189                    widget.obj.css('position', '');
190                    widget.obj.css('top', '');
191                    widget.obj.css('bottom', '');
192                    widget.obj.css('width', '');
193                    widget.obj.css('margin', '');
194                    widget.obj.css('padding', '');
195                    widget_obj.parent().css('height', '');
196                    if (jQuery('#' + widget.clone_id).length > 0)
197                        jQuery('#' + widget.clone_id).remove();
198                    style_applied_normal = true;
199                    style_applied_top = false;
200                    style_applied_bottom = false;
201                }
202                //console.log('jQuery(window).width() <= options.screen_max_width');
203            } else {
204                var scroll = jQuery(this).scrollTop();
205                //console.log('Srcoll: ' + scroll + ' | Trigger top: ' + trigger_top + ' | Trigger bottom: ' + trigger_bottom);
206                if (scroll + widget.fixed_margin_bottom >= trigger_bottom) { // fixed bottom
207                    if (!style_applied_bottom) {
208                        widget.obj.css('position', 'fixed');
209                        widget.obj.css('top', '');
210                        widget.obj.css('width', widget_width);
211                        if (jQuery('#' + widget.clone_id).length <= 0)
212                            widget.obj.before(widget.clone);
213                        style_applied_bottom = true;
214                        style_applied_top = false;
215                        style_applied_normal = false;
216                    }
217                    widget.obj.css('bottom', scroll + window_height + widget.next_widgets_height - trigger_bottom);
218                } else if (scroll >= trigger_top) { // fixed top
219                    if (!style_applied_top) {
220                        widget.obj.css('position', 'fixed');
221                        widget.obj.css('top', widget.fixed_margin_top);
222                        widget.obj.css('bottom', '');
223                        widget.obj.css('width', widget_width);
224                        if (jQuery('#' + widget.clone_id).length <= 0)
225                            widget.obj.before(widget.clone);
226                        style_applied_top = true;
227                        style_applied_bottom = false;
228                        style_applied_normal = false;
229                    }
230                } else { // normal
231                    if (!style_applied_normal) {
232                        widget.obj.css('position', '');
233                        widget.obj.css('top', '');
234                        widget.obj.css('bottom', '');
235                        widget.obj.css('width', '');
236                        if (jQuery('#' + widget.clone_id).length > 0)
237                            jQuery('#' + widget.clone_id).remove();
238                        style_applied_normal = true;
239                        style_applied_top = false;
240                        style_applied_bottom = false;
241                    }
242                }
243            }
244            
245            var widget_position = jQuery('#'+widget.obj.attr('id')).css('position');
246            
247            if(widget_position == 'fixed' && typeof wct == 'undefined'){
248                wct = jQuery(window).scrollTop();
249            }
250            
251            if (widget_position == 'fixed' && jQuery(window).scrollTop()>(wct+ga_sidebar_remove_fixed))
252            {
253                widget.obj.css('position', '');
254                widget.obj.css('top', '');
255                widget.obj.css('bottom', '');
256                widget.obj.css('width', '');
257                if (jQuery('#' + widget.clone_id).length > 0)
258                    jQuery('#' + widget.clone_id).remove();
259                style_applied_normal = true;
260                style_applied_top = false;
261                style_applied_bottom = false;
262            } 
263            
264        }).trigger('scroll.' + options.sidebar);
265
266    }
267
268}
269
270}

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.