PageSourceSearch

https://www.ciat.org/wp-content/themes/News-Child/js/gk.scripts.js

js ciat.org collected 2026-10-02 03:27:01 UTC 23,624 bytes, 574 lines download raw bytes

1/**
2 * jQuery Cookie plugin
3 *
4 * Copyright (c) 2010 Klaus Hartl (stilbuero.de)
5 * Dual licensed under the MIT and GPL licenses:
6 * http://www.opensource.org/licenses/mit-license.php
7 * http://www.gnu.org/licenses/gpl.html
8 *
9 */
10var theLanguage = jQuery('html').attr('lang');
11
12var num = 100; //number of pixels before modifying styles
13(function () {
14    "use strict";
15    jQuery.cookie = function (key, value, options) {
16
17        // key and at least value given, set cookie...
18        if (arguments.length > 1 && String(value) !== "[object Object]") {
19            options = jQuery.extend({}, options);
20
21            if (value === null || value === undefined) {
22                options.expires = -1;
23            }
24
25            if (typeof options.expires === 'number') {
26                var days = options.expires,
27                    t = options.expires = new Date();
28                t.setDate(t.getDate() + days);
29            }
30
31            value = String(value);
32
33            return (document.cookie = [
34                encodeURIComponent(key), '=',
35                options.raw ? value : encodeURIComponent(value),
36                options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
37                options.path ? '; path=' + options.path : '',
38                options.domain ? '; domain=' + options.domain : '',
39                options.secure ? '; secure' : ''
40            ].join(''));
41        }
42
43        // key and possibly options given, get cookie...
44        options = value || {};
45        var result, decode = options.raw ? function (s) {
46                return s;
47            } : decodeURIComponent;
48        return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
49    };
50
51    /**
52     *
53     * Template scripts
54     *
55     **/
56
57    // onDOMLoadedContent event
58    jQuery(document).ready(function () {
59        //Parallax
60        var padding = 0;
61        padding = ( (jQuery(window).height() / 2) / 2);
62        jQuery('.parallax').css("height", jQuery(window).height());
63        jQuery('.parallax-padding').css("padding-top", padding);
64        jQuery('.parallax-padding').css("padding-bottom", padding);
65        jQuery(window).on('resize', function(){
66            padding = 0;
67            padding = ( (jQuery(window).height() / 2) / 2 );
68            jQuery('.parallax').css("height", jQuery(window).height());                
69            jQuery('.parallax-padding').css("padding-top", padding);
70            jQuery('.parallax-padding').css("padding-bottom", padding);
71
72        });
73        //Formularios de registros y perfil
74        if (jQuery("#wppb-edit-user").length > 0) {
75            jQuery("#nickname").prop('disabled', true);
76            //jQuery("#email").prop('disabled', true);
77            jQuery("#country").prop('disabled', true);
78        }        
79        if(jQuery("#wppb-register-user").length > 0){
80            theLanguage = theLanguage.split("-");
81            jQuery("#lang_register").val(theLanguage[0]);
82        }
83		// SmoothScroll jQUery substitue
84        /*jQuery('a[href^="#"][class*="mega-menu-link"]:not([href=#])').on('click', function (e) {
85            e.preventDefault();
86            if(this.hash !== '' && this.href.replace(this.hash, '') == window.location.href.replace(window.location.hash, '')) {
87                var target = jQuery(this.hash);
88                if(target.length) {
89                    jQuery('html, body').stop().animate({
90                        'scrollTop': target.offset().top - 70
91                    }, 1000, 'swing', function () {
92                        //window.location.hash = target.selector;  //Imprime el id del selector.
93                    });
94                } else {
95                    //window.location = jQuery(this).attr('href');  //Imprime el id del selector.
96                }
97            } else {
98                //window.location = jQuery(this).attr('href');  //Imprime el id del selector.
99            }
100        });*/
101        // Scroll para menu
102        jQuery(window).scroll(function () {
103            if (jQuery(this).scrollTop() > num) {
104                jQuery('.gk-page-menu').addClass("fx");
105            } else {
106                jQuery('.gk-page-menu').removeClass("fx");
107            }
108        });
109        // Back to Top Scroll
110        jQuery('#gk-top-link').click(function () {
111            jQuery('body,html').animate({
112                scrollTop: 0
113            }, 800);
114            return false;
115        });
116        // Thickbox use
117        jQuery(document).ready(function () {
118            if (typeof tb_init !== "undefined") {
119                tb_init('div.wp-caption a'); //pass where to apply thickbox
120            }
121        });
122        // style area
123        if (jQuery('#gk-style-area')) {
124            jQuery('#gk-style-area div').each(function () {
125                jQuery(this).find('a').each(function () {
126                    jQuery(this).click(function (e) {
127                        e.stopPropagation();
128                        e.preventDefault();
129                        changeStyle(jQuery(this).attr('href').replace('#', ''));
130                    });
131                });
132            });
133        }
134        // font-size switcher
135        if (jQuery('#gk-font-size') && jQuery('#gk-mainbody')) {
136            var current_fs = 100;
137            jQuery('#gk-mainbody').css('font-size', current_fs + "%");
138
139            jQuery('#gk-increment').click(function (e) {
140                e.stopPropagation();
141                e.preventDefault();
142
143                if (current_fs < 150) {
144                    jQuery('#gk-mainbody').animate({
145                        'font-size': (current_fs + 10) + "%"
146                    }, 200);
147                    current_fs += 10;
148                }
149            });
150
151            jQuery('#gk-reset').click(function (e) {
152                e.stopPropagation();
153                e.preventDefault();
154
155                jQuery('#gk-mainbody').animate({
156                    'font-size': "100%"
157                }, 200);
158                current_fs = 100;
159            });
160
161            jQuery('#gk-decrement').click(function (e) {
162                e.stopPropagation();
163                e.preventDefault();
164
165                if (current_fs > 70) {
166                    jQuery('#gk-mainbody').animate({
167                        'font-size': (current_fs - 10) + "%"
168                    }, 200);
169                    current_fs -= 10;
170                }
171            });
172        }
173
174        // Function to change styles
175
176        function changeStyle(style) {
177            var file = $GK_TMPL_URL + '/css/' + style;
178            jQuery('head').append('<link rel="stylesheet" href="' + file + '" type="text/css" />');
179            jQuery.cookie($GK_TMPL_NAME + '_style', style, {
180                expires: 365,
181                path: '/'
182            });
183        }
184
185        // Responsive tables
186        jQuery('article section table').each(function (i, table) {
187            table = jQuery(table);
188            var heads = table.find('thead th');
189            var cells = table.find('tbody td');
190            var heads_amount = heads.length;
191            // if there are the thead cells
192            if (heads_amount) {
193                var cells_len = cells.length;
194                for (var j = 0; j < cells_len; j++) {
195                    var head_content = jQuery(heads.get(j % heads_amount)).text();
196                    jQuery(cells.get(j)).html('<span class="gk-table-label">' + head_content + '</span>' + jQuery(cells.get(j)).html());
197                }
198            }
199        });
200        
201        //Barra de Administrador de Sistemas
202        jQuery('#gk-handler').on('click', function (e) {
203            var handler = jQuery('#gk-handler');
204            if(jQuery('#gk-toolbar').hasClass('active')){   
205                jQuery('#gk-toolbar').addClass('gk-hidden').removeClass('active');
206                handler.find('i').addClass('fa-caret-right').removeClass('fa-caret-left');
207               }
208            else{   
209                jQuery('#gk-toolbar').addClass('active').removeClass('gk-hidden'); 
210                handler.find('i').removeClass('fa-caret-right').addClass('fa-caret-left');
211            }
212        });
213        jQuery('.mega-menu-toggle').on('click', function (e) {
214            if(jQuery('.mega-menu-toggle').hasClass('mega-menu-open')){  
215                jQuery('.mega-menu-wrap').removeClass('overflow')
216               }
217            else{   
218                jQuery('.mega-menu-wrap').addClass('overflow')
219            }
220        });
221
222        /*jQuery('body').find('.gk-icons').each(function(i,element) {
223            elementsToAnimate.push(['queue_anim', element, jQuery(element).offset().top, '.gk-icon2']);
224        });*/
225
226        // Testimonials
227        var testimonials = jQuery('.gk-testimonials');
228
229        if(testimonials.length > 0) {
230            testimonials.each(function(i, wrapper) {
231                wrapper = jQuery(wrapper);
232                var amount = wrapper.data('amount');
233
234                var testimonial_prev = jQuery('<a>', { class: 'gk-testimonials-prev' });
235                var testimonial_next = jQuery('<a>', { class: 'gk-testimonials-next' });
236                var testimonial_pagination = jQuery('<ul>', { class: 'gk-testimonials-pagination' });
237
238                var quotes = wrapper.find('blockquote');
239                var current_page = 0;
240                var sliding_wrapper = wrapper.find('div div');
241
242                for(var j = 0; j < amount; j++) {
243                    var titem = '<li' + (j === 0 ? ' class="active"' : '') + '>
243' + (j+1) + '</li>';
244                    testimonial_pagination.html(testimonial_pagination.html() + titem);
245                }
246
247                testimonial_prev.appendTo(wrapper);
248                testimonial_next.appendTo(wrapper);
249                testimonial_pagination.appendTo(wrapper);
250                var pages = testimonial_pagination.find('li');
251                // hide quotes
252                quotes.each(function(i, quote) {
253                    if(i > 0) {
254                        jQuery(quote).addClass('hidden');
255                    }
256                });
257                // navigation
258                testimonial_prev.click(function(e) {
259                    e.preventDefault();
260                    e.stopPropagation();
261
262                    jQuery(quotes[current_page]).addClass('hidden');
263                    current_page = (current_page > 0) ? current_page - 1 : pages.length - 1;
264                    jQuery(quotes[current_page]).removeClass('hidden');
265                    pages.removeClass('active');
266                    jQuery(pages[current_page]).addClass('active');
267                    sliding_wrapper.css('margin-left', -1 * (current_page * 100) + "%");
268                });
269
270                testimonial_next.click(function(e) {
271                    e.preventDefault();
272                    e.stopPropagation();
273
274                    jQuery(quotes[current_page]).addClass('hidden');
275                    current_page = (current_page < pages.length - 1) ? current_page + 1 : 0;
276                    jQuery(quotes[current_page]).removeClass('hidden');
277                    pages.removeClass('active');
278                    jQuery(pages[current_page]).addClass('active');
279                    sliding_wrapper.css('margin-left', -1 * (current_page * 100) + "%");
280                });
281
282                pages.each(function(i, page) {
283                    page = jQuery(page);
284                    page.click(function() {
285                        quotes[current_page].addClass('hidden');
286                        current_page = i;
287                        jQuery(quotes[current_page]).removeClass('hidden');
288                        pages.removeClass('active');
289                        jQuery(pages[current_page]).addClass('active');
290                        sliding_wrapper.css('margin-left', -1 * (current_page * 100) + "%");
291                    });
292                });
293            });
294        }
295
296        jQuery(document).on("change","input[type='checkbox'][name='noti_field_system[]'][class='custom_field_checkbox']",function(e){"all"==jQuery(this).val()?jQuery("input[name='noti_field_system[]']").not(this).prop("checked",this.checked):jQuery("input[name='noti_field_system[]'][value='all']").prop("checked",!1)});
297        
298    });
299
300    // Image Show & Title Overlay
301    jQuery(window).load(function () {
302        jQuery('.gk-title-overlay').each(function (i, wrapper) {
303            jQuery(wrapper).addClass('active');
304        });
305
306        jQuery(".gk-is-wrapper-gk-shop-and-buy").each(function (i, wrapper) {
307            wrapper = jQuery(wrapper);
308            var slides = [];
309            var imagesToLoad = [];
310            var loadedImages = 0;
311            // animation variables
312            var $G = [];
313            $G.anim_speed = parseInt(wrapper.attr('data-speed'), 10);
314            $G.anim_interval = parseInt(wrapper.attr('data-interval'), 10);
315            $G.autoanim = wrapper.attr('data-autoanim');
316            $G.animation_timer = false;
317            $G.actual_slide = 0;
318            $G.blank = false;
319            $G.progress = false;
320            $G.scrollarea = wrapper.find('.gk-is-image-scroll');
321            // load the images
322            wrapper.find('div.gk-is-slide').each(function (i, el) {
323                el = jQuery(el);
324                var newImg = jQuery('<img title="' + el.text() + '" class="' + el.attr('class') + '" style="' + el.attr('data-style') + '" src="' + el.attr('data-path') + '" data-num="' + i + '" data-url="' + el.attr('data-link') + '" />');
325                imagesToLoad.push(newImg);
326                el.after(newImg);
327                el.remove();
328            });
329
330            var time = setInterval(function () {
331                var process = 0;
332                jQuery(imagesToLoad).each(function (i, img) {
333                    if (img[0].complete) {
334                        process++;
335                    }
336                });
337
338                if (process === imagesToLoad.length) {
339                    clearInterval(time);
340                    loadedImages = process;
341                    setTimeout(function () {
342                        wrapper.find('.gk-is-preloader').fadeOut();
343                    }, 400);
344                }
345            }, 200);
346
347            var time_main = setInterval(function () {
348                if (loadedImages) {
349                    clearInterval(time_main);
350
351                    wrapper.find(".gk-is-slide").each(function (i, elmt) {
352                        elmt = jQuery(elmt);
353                        slides[i] = elmt;
354                        elmt.click(function (e) {
355                            window.location = jQuery(e.target).attr('data-url');
356                        });
357                        elmt.css("cursor", "pointer");
358                    });
359
360                    // pagination
361                    if (wrapper.find('ol').length) {
362                        wrapper.find('ol li').each(function (i, btn) {
363                            btn = jQuery(btn);
364                            btn.click(function () {
365                                if (i !== $G.actual_slide) {
366                                    $G.blank = true;
367                                    gk_shop_and_buy_autoanimate($G, wrapper, 'next', i);
368                                }
369                            });
370                        });
371                    }
372                    //
373                    var initText = wrapper.find('.figcaption');
374                    initText.css('margin-top', -0.5 * initText.outerHeight() + "px");
375                    // buttons 
376                    if (wrapper.find('.gk-is-btn-prev')) {
377                        wrapper.find('.gk-is-btn-prev').click(function (e) {
378                            e.preventDefault();
379                            $G.blank = true;
380                            gk_shop_and_buy_autoanimate($G, wrapper, 'prev', null);
381                        });
382
383                        wrapper.find('.gk-is-btn-next').click(function (e) {
384                            e.preventDefault();
385                            $G.blank = true;
386                            gk_shop_and_buy_autoanimate($G, wrapper, 'next', null);
387                        });
388                    }
389
390                    wrapper.mouseenter(function () {
391                        wrapper.addClass('hover');
392                    });
393
394                    wrapper.mouseleave(function () {
395                        wrapper.removeClass('hover');
396                    });
397
398                    // auto animation
399                    if ($G.autoanim === 'on') {
400                        $G.animation_timer = setTimeout(function () {
401                            gk_shop_and_buy_autoanimate($G, wrapper, 'next', null);
402                        }, $G.anim_interval);
403                    }
404
405                    // pagination
406                    var slide_pos_start_x = 0;
407                    var slide_pos_start_y = 0;
408                    var slide_time_start = 0;
409                    var slide_swipe = false;
410
411                    wrapper.bind('touchstart', function (e) {
412                        slide_swipe = true;
413                        var touches = e.originalEvent.changedTouches || e.originalEvent.touches;
414
415                        if (touches.length > 0) {
416                            slide_pos_start_x = touches[0].pageX;
417                            slide_pos_start_y = touches[0].pageY;
418                            slide_time_start = new Date().getTime();
419                        }
420                    });
421
422                    wrapper.bind('touchmove', function (e) {
423                        var touches = e.originalEvent.changedTouches || e.originalEvent.touches;
424
425                        if (touches.length > 0 && slide_swipe) {
426                            if (
427                                Math.abs(touches[0].pageX - slide_pos_start_x) > Math.abs(touches[0].pageY - slide_pos_start_y)
428                            ) {
429                                e.preventDefault();
430                            } else {
431                                slide_swipe = false;
432                            }
433                        }
434                    });
435
436                    wrapper.bind('touchend', function (e) {
437                        var touches = e.originalEvent.changedTouches || e.originalEvent.touches;
438
439                        if (touches.length > 0 && slide_swipe) {
440                            if (
441                                Math.abs(touches[0].pageX - slide_pos_start_x) >= 50 &&
442                                new Date().getTime() - slide_time_start <= 500
443                            ) {
444                                if (touches[0].pageX - slide_pos_start_x > 0) {
445                                    $G.blank = true;
446                                    gk_shop_and_buy_autoanimate($G, wrapper, 'prev', null);
447                                } else {
448                                    $G.blank = true;
449                                    gk_shop_and_buy_autoanimate($G, wrapper, 'next', null);
450                                }
451                            }
452                        }
453                    });
454                }
455            }, 250);
456        });
457    });
458
459    var gk_shop_and_buy_animate = function ($G, wrapper, imgPrev, imgNext, dir, next) {
460        var prevText = jQuery(imgPrev).find('.figcaption');
461        var nextText = jQuery(imgNext).find('.figcaption');
462        imgPrev = jQuery(imgPrev);
463        imgNext = jQuery(imgNext);
464
465        if (prevText) {
466            prevText.css('margin-top', -0.5 * prevText.outerHeight() + "px");
467            nextText.css('margin-top', -0.5 * nextText.outerHeight() + "px");
468
469            if (dir === 'next') {
470                //
471                imgPrev.find('img').first().css('margin-left', 0);
472                imgPrev.find('img').first().animate({
473                        'margin-left': 300
474                    },
475                    $G.anim_speed,
476                    'linear',
477                    function () {
478                        setTimeout(function () {
479                            imgPrev.find('img').first().css('margin-left', 0);
480                        }, 100);
481                    }
482                );
483                //
484                imgNext.find('img').first().css('margin-left', '-300px');
485                imgNext.find('img').first().animate({
486                        'margin-left': 0
487                    },
488                    $G.anim_speed,
489                    'linear',
490                    function () {
491                        setTimeout(function () {
492                            imgPrev.find('img').first().css('margin-left', 0);
493                        }, 100);
494                    }
495                );
496            } else {
497                //
498                imgPrev.find('img').first().css('margin-left', 0);
499                imgPrev.find('img').first().animate({
500                        'margin-left': -300
501                    },
502                    $G.anim_speed,
503                    'linear',
504                    function () {
505                        setTimeout(function () {
506                            imgPrev.find('img').first().css('margin-left', 0);
507                        }, 100);
508                    }
509                );
510                //
511                imgNext.find('img').first().css('margin-left', '300px');
512                imgNext.find('img').first().animate({
513                        'margin-left': 0
514                    },
515                    $G.anim_speed,
516                    'linear',
517                    function () {
518                        setTimeout(function () {
519                            imgPrev.find('img').first().css('margin-left', 0);
520                        }, 100);
521                    }
522                );
523            }
524        }
525        //
526        imgPrev.removeClass('active');
527        imgNext.addClass('active');
528        //
529        $G.scrollarea.animate({
530                'margin-left': (next * -1 * 100) + "%"
531            },
532            $G.anim_speed,
533            'linear',
534            function () {
535                $G.progress = false;
536                if ($G.autoanim === 'on') {
537                    clearTimeout($G.animation_timer);
538
539                    $G.animation_timer = setTimeout(function () {
540                        if ($G.blank) {
541                            $G.blank = false;
542                            clearTimeout($G.animation_timer);
543
544                            $G.animation_timer = setTimeout(function () {
545                                gk_shop_and_buy_autoanimate($G, wrapper, 'next', null);
546                            }, $G.anim_interval);
547                        } else {
548                            gk_shop_and_buy_autoanimate($G, wrapper, 'next', null);
549                        }
550                    }, $G.anim_interval);
551                }
552            }
553        );
554    };
555
556    var gk_shop_and_buy_autoanimate = function ($G, wrapper, dir, nextSlide) {
557        if (!$G.progress) {
558            $G.progress = true;
559            var i = $G.actual_slide;
560            var imgs = wrapper.find('.figure');
561            var next = nextSlide;
562
563            if (nextSlide === null) {
564                next = (dir === 'next') ? ((i < imgs.length - 1) ? i + 1 : 0) : ((i === 0) ? imgs.length - 1 : i - 1); // dir: next|prev
565            }
566
567            gk_shop_and_buy_animate($G, wrapper, imgs[i], imgs[next], ((next > $G.actual_slide) ? 'next' : 'prev'), next);
568            $G.actual_slide = next;
569            wrapper.find('ol li').attr('class', '');
570            jQuery(wrapper.find('ol li')[next]).attr('class', 'active');
571        }
572    };
573
574})();

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.