PageSourceSearch

https://commondigital.pe/templates/gk_news/js/gk.scripts.js

js commondigital.pe collected 2026-10-03 18:11:58 UTC 7,281 bytes, 241 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 */
10jQuery.noConflict();
11jQuery.cookie = function (key, value, options) {
12
13    // key and at least value given, set cookie...
14    if (arguments.length > 1 && String(value) !== "[object Object]") {
15        options = jQuery.extend({}, options);
16
17        if (value === null || value === undefined) {
18            options.expires = -1;
19        }
20
21        if (typeof options.expires === 'number') {
22            var days = options.expires, t = options.expires = new Date();
23            t.setDate(t.getDate() + days);
24        }
25
26        value = String(value);
27
28        return (document.cookie = [
29            encodeURIComponent(key), '=',
30            options.raw ? value : encodeURIComponent(value),
31            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
32            options.path ? '; path=' + options.path : '',
33            options.domain ? '; domain=' + options.domain : '',
34            options.secure ? '; secure' : ''
35        ].join(''));
36    }
37
38    // key and possibly options given, get cookie...
39    options = value || {};
40    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
41    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
42};
43
44/**
45 *
46 * Template scripts
47 *
48 **/
49
50jQuery(document).ready(function() {	
51	// smooth anchor scrolling
52	if(!(jQuery('#modules-form').length || jQuery('#gkMainbody').find('.item-page').hasClass('edit'))) {
53		jQuery('a[href*="#"]').on('click', function (e) {
54	        e.preventDefault();
55	        if(this.hash !== '' && this.hash.indexOf('carousel') === -1) {
56	            var target = jQuery(this.hash);
57	            
58	            if(this.hash !== '' && this.href.replace(this.hash, '') == window.location.href.replace(window.location.hash, '')) {    
59	                if(target.length && this.hash !== '#') {
60	                    jQuery('html, body').stop().animate({
61	                        'scrollTop': target.offset().top
62	                    }, 1000, 'swing', function () {
63	                        if(this.hash !== '#') {
64	                            window.location.hash = target.selector;
65	                        }
66	                    });
67	                } else if(this.hash !== '' && this.href.replace(this.hash, '') !== '') {
68	                	window.location.href = this.href;
69	                }
70	            } else if(this.hash !== '' && this.href.replace(this.hash, '') !== '') {
71	            	window.location.href = this.href;
72	            }
73	        }
74	    });
75    }
76	
77	// style area
78	if(jQuery('#gkStyleArea')){
79		jQuery('#gkStyleArea').find('a').each(function(i, element){
80			jQuery(element).click(function(e){
81	            e.preventDefault();
82	            e.stopPropagation();
83				changeStyle(i+1);
84			});
85		});
86		
87		jQuery('#gkBackgrounds').find('a').each(function(i, element){
88			element.addEvent('click',function(e){
89		        e.preventDefault();
90		        e.stopPropagation();
91				changeBg(i+1);
92			});
93		});
94	}
95	
96	// login popup
97	if(jQuery('#gkPopupLogin')) {
98		var popup_overlay = jQuery('#gkPopupOverlay');
99		popup_overlay.css({'display': 'none', 'opacity' : 0});
100		
101		popup_overlay.fadeOut();
102		
103		jQuery('#gkPopupLogin').css({'display': 'block', 'opacity': 0, 'height' : 0});
104		var opened_popup = null;
105		var popup_login = null;
106		var popup_login_h = null;
107		var popup_login_fx = null;
108		
109		if(jQuery('#gkPopupLogin') && jQuery('#btnLogin')) {
110			popup_login = jQuery('#gkPopupLogin');
111			popup_login.css('display', 'block');
112			popup_login_h = popup_login.find('.gkPopupWrap').outerHeight();
113			 
114			jQuery('#gkLogin').click( function(e) {
115				e.preventDefault();
116				e.stopPropagation();
117				popup_overlay.css({'opacity' : 0.6});
118				popup_overlay.fadeIn('slow');
119				
120				popup_login.animate({'opacity':1, 'height': popup_login_h},200, 'swing');
121				opened_popup = 'login';
122				
123				(function() {
124					if(jQuery('#modlgn-username')) {
125						jQuery('#modlgn-username').focus();
126					}
127				}).delay(600);
128			});
129		}
130		
131		popup_overlay.click( function() {
132			if(opened_popup == 'login')	{
133				popup_overlay.fadeOut('slow');
134				popup_login.css({
135					'opacity' : 0,
136					'height' : 0
137				});
138			}
139		});
140	}
141	
142	// NSP header suffix
143	jQuery('.header').each(function(i, elm) {
144		if(elm.hasClass('box')) {
145			jQuery(elm).find('.nspArt').each(function(i, art) {
146				art = jQuery(art);
147				art.find('.nspImageWrapper').append(art.find('.nspHeader'));
148			});
149		}
150	});
151	
152	// NSP nsphover suffix
153	jQuery('.nsphover').each(function(i,elm) {
154		if(elm.hasClass('box')) {
155			jQuery(elm).find('.nspArt').each(function(i, art) {
156				var overlay = jQuery('<div></div>');
157				overlay.attr('class', 'nspHoverOverlay');
158				//.appendTo(art);
159				var test = jQuery('<div></div>');
160				art = jQuery(art);
161				var info = art.find('.nspInfo1');
162				art.append(overlay);
163				overlay.append(art.find('.nspText'));
164				var copy = art.find('.nspHeader').clone();
165				overlay.prepend(copy);
166				
167				art.mouseenter(function() {
168					overlay.addClass('active');
169					if(info) {
170						info.addClass('active');
171					}
172				});
173				
174				art.mouseleave(function() {
175					overlay.removeClass('active');
176					if(info) {
177						info.removeClass('active');
178					}
179				});
180			});
181		}
182	});
183	
184	// Newsletter popup
185	var newsletter_submit = jQuery('#gk-newsletter-submit');
186	
187	if(newsletter_submit.length) {	
188		newsletter_submit.click(function() {
189			jQuery.cookie('gk-news-newsletter-popup', 1, { expires: 30, path: '/' });
190		});
191		
192		jQuery('#gk-newsletter-popup-close').click(function(e) {
193			e.preventDefault();
194			
195			jQuery.cookie('gk-news-newsletter-popup', 1, { expires: 30, path: '/' });
196			jQuery('#gk-newsletter-popup').addClass('hidden-popup');
197		});
198	}
199});
200
201// Newsletter display
202jQuery(window).load(function() {
203	var newsletter = jQuery('#gk-newsletter-popup');
204	
205	if(newsletter.length) {
206		switch (newsletter.attr('data-display')) {
207		  	case 'direct':
208				setTimeout(function() {
209					newsletter.removeClass('hidden-popup');
210				}, 1000);
211				break;
212			case 'after_time':
213				setTimeout(function() {
214					newsletter.removeClass('hidden-popup');
215				}, newsletter.attr('data-time') * 1000);
216				break;
217			case 'after_scroll': 
218				var win = jQuery(window);
219				var destination = newsletter.attr('data-scroll');
220				
221				var newsletter_scroll = function() {
222					if(win.scrollTop() >= destination) {
223						newsletter.removeClass('hidden-popup');
224						jQuery(window).off('scroll', newsletter_scroll);
225					}
226				};
227				
228				jQuery(window).on('scroll', newsletter_scroll);
229				break;
230		}
231	}
232});
233
234// Function to change styles
235function changeStyle(style){
236	var file1 = $GK_TMPL_URL+'/css/style'+style+'.css';
237	var file2 = $GK_TMPL_URL+'/css/typography/typography.style'+style+'.css';
238	jQuery('head').append('<link rel="stylesheet" href="'+file1+'" type="text/css" />');
239	jQuery('head').append('<link rel="stylesheet" href="'+file2+'" type="text/css" />');
240	jQuery.cookie('gk_news_j30_style', style, { expires: 365, path: '/' });
241}

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.