PageSourceSearch

https://africawrites.org/wp-content/plugins/cj-popups/assets/js/cjpopups.js

js africawrites.org collected 2026-10-02 11:21:04 UTC 12,118 bytes, 318 lines download raw bytes

1jQuery(document).ready(function($) {
2
3    $(window).load(function() {
4        //$('body').live('each', '.cjpopup', function() {
5        $('.cjpopup').each(function() {
6            var click = $(this).attr('data-click');
7            var right_click = $(this).attr('data-right-click');
8            var popup = $(this);
9            if (click === '' && right_click === 'no') {
10                show_popup(popup);
11            } else if (right_click == 'yes') {
12                document.oncontextmenu = function() {
13                    return false;
14                };
15                $(document).mousedown(function(e) {
16                    if (e.button == 2) {
17                        show_popup(popup);
18                        return false;
19                    }
20                    return true;
21                });
22            } else {
23                $(click).on('click', function() {
24                    show_popup(popup);
25                    return false;
26                });
27            }
28        });
29    });
30
31    function show_popup(el) {
32        $('body').addClass('cjpopup-on');
33        var popid = el.attr('id');
34        var disable_body_scroll = el.attr('data-disable-body-scroll');
35        var bgcolor = el.attr('data-bgcolor');
36        var textcolor = el.attr('data-textcolor');
37        var linkcolor = el.attr('data-linkcolor');
38        var closebgcolor = el.attr('data-closebgcolor');
39        var closetextcolor = el.attr('data-closetextcolor');
40        var delay = el.attr('data-delay');
41        var autohide = el.attr('data-autohide');
42        var hideclosebutton = el.attr('data-hideclosebutton');
43        var padding = el.attr('data-padding');
44        var width = el.attr('data-width');
45        var popup_height = el.attr('data-height');
46        var animation_in = el.attr('data-animation-in');
47        var animation_out = el.attr('data-animation-out');
48        var cookie_expires = el.attr('data-cookie');
49        var popuptype = el.attr('data-popup-type');
50        var backdrop_id = el.attr('data-backdrop-id');
51        var window_width = $(window).width();
52        var onclick = el.attr('data-click');
53        var onclick_close = el.attr('data-close-click');
54        var right_click = el.attr('data-right-click');
55        var esc_key = el.attr('data-esc-key');
56        var anywhere_click_close = el.attr('data-anywhere-click-close');
57
58        if(onclick_close != undefined || onclick_close != ''){
59            $(onclick_close).on('click', function(){
60                el.find('.close-cjpopup').trigger('click');
61            });
62        }
63
64        if (disable_body_scroll == 'on') {
65            $('body').addClass('cjpopup-body-no-scroll');
66        }
67
68        // Auto hide
69        var autohide_duration = autohide * 1000;
70        if (autohide > 0) {
71            setTimeout(function() {
72                el.find('.close-cjpopup').trigger('click');
73            }, autohide_duration);
74        }
75
76        if (hideclosebutton == 'on') {
77            $('.close-cjpopup').hide(0);
78        }
79
80        // Cookie management
81        var cookie = getCookie(popid);
82        if (cookie == 'hide') {
83            return;
84        }
85
86        // responsive
87        if (window_width < 1023) {
88            width = 'auto';
89        } else {
90            width = width;
91        }
92
93        if (popup_height != '' || popup_height != undefined) {
94            el.css('height', popup_height);
95        }
96
97        el.css('width', width);
98        el.css('visibility', 'visible');
99        el.find('.popup-content').css('padding', padding);
100
101        el.css('background-color', bgcolor);
102        el.css('color', textcolor);
103        el.find('a').css('color', linkcolor);
104        el.find('a.close-cjpopup').css('background-color', closebgcolor);
105        el.find('a.close-cjpopup').css('color', closetextcolor);
106        el.find('a.close-cjpopup span').css('color', closetextcolor);
107        el.find('.popup-content').css('color', textcolor);
108
109        $(window).resize(function() {
110            window_width = $(window).width();
111            if (window.innerWidth == screen.width) {
112                $('body').addClass('fullscreen-popup');
113                el.removeClass(animation_in, animation_out);
114            } else {
115                $('body').removeClass('fullscreen-popup');
116                el.removeClass(animation_in);
117            }
118            if (window_width < 1023) {
119                el.css('width', 'auto');
120            } else {
121                el.css('width', width);
122            }
123            if (popuptype == 'modal-box') {
124                if (window_width < 1023) {
125                    el.css('left', '20px');
126                    el.css('width', 'auto');
127                    el.css('margin-left', 0);
128                }
129                if (window_width > 1023) {
130                    width = width.replace('px', '');
131                    var modal_margin_left = width / 2 * -1;
132                    el.css('left', '50%');
133                    el.css('width', width);
134                    el.css('margin-left', modal_margin_left);
135                }
136            }
137        });
138
139
140
141        setTimeout(function() {
142            $('#' + backdrop_id).removeClass('cjpopup-hidden');
143            $('#' + backdrop_id).toggleClass('animated fadeIn');
144        }, delay * 1000);
145
146        setTimeout(function() {
147            el.removeClass('cjpopup-hidden');
148            if (popuptype == 'modal-box' && window_width > 1023) {
149                var modal_margin_left = el.innerWidth() / 2 * -1;
150                el.css('margin-left', modal_margin_left);
151            }
152            if (popuptype == 'modal-box' && window_width < 1023) {
153                var modal_margin_left = 'auto';
154                el.css('margin-left', 'auto');
155            }
156            animate(el, animation_in);
157            // $('body').css('overflow', 'hidden');
158        }, delay * 1000 + 500);
159
160        el.finish();
161
162
163        el.find('.close-cjpopup, .close-popup').on('click', function() {
164            // Close PopUp Code
165            $('body').removeClass('cjpopup-on');
166            $('body').removeClass('cjpopup-body-no-scroll');
167            $('#' + backdrop_id).toggleClass('fadeIn fadeOut');
168            animate(el, animation_out);
169            $(el).removeClass(animation_in);
170            setTimeout(function() {
171                $('#' + backdrop_id).addClass('cjpopup-hidden');
172                $('#' + backdrop_id).removeClass('animated fadeOut');
173                $(el).addClass('cjpopup-hidden');
174                $(el).removeClass(animation_out);
175                // $('body').css('overflow', 'auto');
176                if (onclick === '' && right_click != 'yes') {
177                    el.remove();
178                    $('#' + backdrop_id).remove();
179                    setCookie(popid, 'hide', cookie_expires);
180                }
181                el.finish();
182            }, 1000);
183            // Close PopUp Code ends
184            return false;
185        });
186
187
188        if (esc_key == 'yes') {
189            $(document).keyup(function(e) {
190                if (e.keyCode == 27 && $('body').hasClass('cjpopup-on')) {
191                    $('.cjpopup').each(function() {
192                        var el = $(this);
193                        var backdrop_id = $(this).attr('data-backdrop-id');
194                        if (el.hasClass('cjpopup-hidden') === false) {
195                            // Close PopUp Code
196                            $('body').removeClass('cjpopup-on');
197                            $('#' + backdrop_id).toggleClass('fadeIn fadeOut');
198                            animate(el, animation_out);
199                            $(el).removeClass(animation_in);
200                            setTimeout(function() {
201                                $('#' + backdrop_id).addClass('cjpopup-hidden');
202                                $('#' + backdrop_id).removeClass('animated fadeOut');
203                                $(el).addClass('cjpopup-hidden');
204                                $(el).removeClass(animation_out);
205                                // $('body').css('overflow', 'auto');
206                                if (onclick === '' && right_click != 'yes') {
207                                    el.remove();
208                                    $('#' + backdrop_id).remove();
209                                    setCookie(popid, 'hide', cookie_expires);
210                                }
211                                el.finish();
212                            }, 1000);
213                            // Close PopUp Code ends
214                        }
215                    });
216                    return false;
217                }
218            });
219        }
220
221
222        if (anywhere_click_close == 'yes') {
223
224            $(document).click(function() {
225                if ($('body').hasClass('cjpopup-on')) {
226                    $('.cjpopup').each(function() {
227                        var el = $(this);
228                        var backdrop_id = $(this).attr('data-backdrop-id');
229                        if (el.hasClass('cjpopup-hidden') === false) {
230                            // Close PopUp Code
231                            $('body').removeClass('cjpopup-on');
232                            $('#' + backdrop_id).toggleClass('fadeIn fadeOut');
233                            animate(el, animation_out);
234                            $(el).removeClass(animation_in);
235                            setTimeout(function() {
236                                $('#' + backdrop_id).addClass('cjpopup-hidden');
237                                $('#' + backdrop_id).removeClass('animated fadeOut');
238                                $(el).addClass('cjpopup-hidden');
239                                $(el).removeClass(animation_out);
240                                // $('body').css('overflow', 'auto');
241                                if (onclick === '' && right_click != 'yes') {
242                                    el.remove();
243                                    $('#' + backdrop_id).remove();
244                                    setCookie(popid, 'hide', cookie_expires);
245                                }
246                                el.finish();
247                            }, 1000);
248                            // Close PopUp Code ends
249                        }
250                    });
251                }
252            });
253            $(el).click(function(e) {
254                e.stopPropagation(); // This is the preferred method.
255                // return false; // This should not be used unless you do not want
256                // any click events registering inside the div
257            });
258        }
259
260    }
261
262
263    function animate(el, x) {
264        $(el).removeClass('cjpopup-hidden');
265        $(el).addClass('animated ' + x);
266    }
267
268
269    function setCookie(cname, cvalue, exdays) {
270        var d = new Date();
271        d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
272        var expires = "expires=" + d.toGMTString();
273        document.cookie = cname + "=" + cvalue + "; " + expires+ "; path=/";
274    }
275
276    function getCookie(cname) {
277        var name = cname + "=";
278        var ca = document.cookie.split(';');
279        for (var i = 0; i < ca.length; i++) {
280            var c = ca[i];
281            while (c.charAt(0) == ' ') c = c.substring(1);
282            if (c.indexOf(name) != -1) return c.substring(name.length, c.length);
283        }
284        return "";
285    }
286
287    $('.cjpopup-fullscreen').each(function(){
288        var win_width = $(window).width();
289        var win_height = $(window).height();
290        $(this).css({
291            width: win_width,
292            height: win_height
293        });
294        $(this).find('iframe').css({
295            width: win_width,
296            height: win_height,
297            margin: 0
298        });
299    });
300
301    $(window).resize(function(){
302        $('.cjpopup-fullscreen').each(function(){
303            var win_width = $(window).width();
304            var win_height = $(window).height();
305            $(this).css({
306                width: win_width,
307                height: win_height
308            });
309            $(this).find('iframe').css({
310                width: win_width,
311                height: win_height,
312                margin: 0
313            });
314        });
315    })
316
317
318});

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.