PageSourceSearch

https://www.casadomo.com/wp-content/themes/magazine-pro/gtr/assets/js/gtr.js?ver=1.9.1

js casadomo.com collected 2026-10-03 22:18:13 UTC 13,989 bytes, 380 lines download raw bytes

1/**!
2 * trunk8 v1.3.2
3 * https://github.com/rviscomi/trunk8
4 *
5 * Copyright 2012 Rick Viscomi
6 * Released under the MIT License.
7 *
8 * Date: October 21, 2012
9 */
10
11 (function($){var methods,utils,SIDES={center:'center',left:'left',right:'right'},WIDTH={auto:'auto'};function trunk8(element){this.$element=$(element);this.original_text=this.$element.html();this.settings=$.extend({},$.fn.trunk8.defaults);}trunk8.prototype.updateSettings=function(options){this.settings=$.extend(this.settings,options);};function truncate(){var data=this.data('trunk8'),settings=data.settings,width=settings.width,side=settings.side,fill=settings.fill,line_height=utils.getLineHeight(this)*settings.lines,str=data.original_text,length=str.length,max_bite='',lower,upper,bite_size,bite;this.html(str);if(width===WIDTH.auto){if(this.height()<=line_height){return;}lower=0;upper=length-1;while(lower<=upper){bite_size=lower+((upper-lower)>>1);bite=utils.eatStr(str,side,length-bite_size,fill);this.html(bite);if(this.height()>line_height){upper=bite_size-1;}else{lower=bite_size+1;max_bite=(max_bite.length>bite.length)?max_bite:bite;}}this.html('');this.html(max_bite);if(settings.tooltip){this.attr('title',str);}}else if(!isNaN(width)){bite_size=length-width;bite=utils.eatStr(str,side,bite_size,fill);this.html(bite);if(settings.tooltip){this.attr('title',str);}}else{$.error('Invalid width "'+width+'".');}}methods={init:function(options){return this.each(function(){var $this=$(this),data=$this.data('trunk8');if(!data){$this.data('trunk8',(data=new trunk8(this)));}data.updateSettings(options);truncate.call($this);});},update:function(new_string){return this.each(function(){var $this=$(this);if(new_string){$this.data('trunk8').original_text=new_string;}truncate.call($this);});},revert:function(){return this.each(function(){var text=$(this).data('trunk8').original_text;$(this).html(text);});},getSettings:function(){return this.get(0).data('trunk8').settings;}};utils={eatStr:function(str,side,bite_size,fill){var length=str.length,key=utils.eatStr.generateKey.apply(null,arguments),half_length,half_bite_size;if(utils.eatStr.cache[key]){return utils.eatStr.cache[key];}if((typeof str!=='string')||(length===0)){$.error('Invalid source string "'+str+'".');}if((bite_size<0)||(bite_size>length)){$.error('Invalid bite size "'+bite_size+'".');}else if(bite_size===0){return str;}if(typeof(fill+'')!=='string'){$.error('Fill unable to be converted to a string.');}switch(side){case SIDES.right:return utils.eatStr.cache[key]=$.trim(str.substr(0,length-bite_size))+fill;case SIDES.left:return utils.eatStr.cache[key]=fill+$.trim(str.substr(bite_size));case SIDES.center:half_length=length>>1;half_bite_size=bite_size>>1;return utils.eatStr.cache[key]=$.trim(utils.eatStr(str.substr(0,length-half_length),SIDES.right,bite_size-half_bite_size,''))+fill+$.trim(utils.eatStr(str.substr(length-half_length),SIDES.left,half_bite_size,''));default:$.error('Invalid side "'+side+'".');}},getLineHeight:function(elem){var $elem=$(elem),float=$elem.css('float'),position=$elem.css('position'),html=$elem.html(),wrapper_id='line-height-test',line_height;if(float!=='none'){$elem.css('float','none');}if(position==='absolute'){$elem.css('position','static');}$elem.html('i').wrap('<div id="'+wrapper_id+'" />');line_height=$('#'+wrapper_id).innerHeight();$elem.html(html).css({'float':float,'position':position}).unwrap();return line_height;}};utils.eatStr.cache={};utils.eatStr.generateKey=function(){return Array.prototype.join.call(arguments,'');};$.fn.trunk8=function(method){if(methods[method]){return methods[method].apply(this,Array.prototype.slice.call(arguments,1));}else if(typeof method==='object'||!method){return methods.init.apply(this,arguments);}else{$.error('Method '+method+' does not exist on jQuery.trunk8');}};$.fn.trunk8.defaults={fill:'&hellip;',lines:1,side:SIDES.right,tooltip:true,width:WIDTH.auto};})(jQuery);
12
13
14
15/*
16* jquery-match-height 0.7.2 by @liabru
17* http://brm.io/jquery-match-height/
18* License MIT
19*/
20!function(t){"use strict";"function"==typeof define&&define.amd?define(["jquery"],t):"undefined"!=typeof module&&module.exports?module.exports=t(require("jquery")):t(jQuery)}(function(t){var e=-1,o=-1,n=function(t){return parseFloat(t)||0},a=function(e){var o=1,a=t(e),i=null,r=[];return a.each(function(){var e=t(this),a=e.offset().top-n(e.css("margin-top")),s=r.length>0?r[r.length-1]:null;null===s?r.push(e):Math.floor(Math.abs(i-a))<=o?r[r.length-1]=s.add(e):r.push(e),i=a}),r},i=function(e){var o={
21	byRow:!0,property:"height",target:null,remove:!1};return"object"==typeof e?t.extend(o,e):("boolean"==typeof e?o.byRow=e:"remove"===e&&(o.remove=!0),o)},r=t.fn.matchHeight=function(e){var o=i(e);if(o.remove){var n=this;return this.css(o.property,""),t.each(r._groups,function(t,e){e.elements=e.elements.not(n)}),this}return this.length<=1&&!o.target?this:(r._groups.push({elements:this,options:o}),r._apply(this,o),this)};r.version="0.7.2",r._groups=[],r._throttle=80,r._maintainScroll=!1,r._beforeUpdate=null,
22	r._afterUpdate=null,r._rows=a,r._parse=n,r._parseOptions=i,r._apply=function(e,o){var s=i(o),h=t(e),l=[h],c=t(window).scrollTop(),p=t("html").outerHeight(!0),u=h.parents().filter(":hidden");return u.each(function(){var e=t(this);e.data("style-cache",e.attr("style"))}),u.css("display","block"),s.byRow&&!s.target&&(h.each(function(){var e=t(this),o=e.css("display");"inline-block"!==o&&"flex"!==o&&"inline-flex"!==o&&(o="block"),e.data("style-cache",e.attr("style")),e.css({display:o,"padding-top":"0",
23	"padding-bottom":"0","margin-top":"0","margin-bottom":"0","border-top-width":"0","border-bottom-width":"0",height:"100px",overflow:"hidden"})}),l=a(h),h.each(function(){var e=t(this);e.attr("style",e.data("style-cache")||"")})),t.each(l,function(e,o){var a=t(o),i=0;if(s.target)i=s.target.outerHeight(!1);else{if(s.byRow&&a.length<=1)return void a.css(s.property,"");a.each(function(){var e=t(this),o=e.attr("style"),n=e.css("display");"inline-block"!==n&&"flex"!==n&&"inline-flex"!==n&&(n="block");var a={
24	display:n};a[s.property]="",e.css(a),e.outerHeight(!1)>i&&(i=e.outerHeight(!1)),o?e.attr("style",o):e.css("display","")})}a.each(function(){var e=t(this),o=0;s.target&&e.is(s.target)||("border-box"!==e.css("box-sizing")&&(o+=n(e.css("border-top-width"))+n(e.css("border-bottom-width")),o+=n(e.css("padding-top"))+n(e.css("padding-bottom"))),e.css(s.property,i-o+"px"))})}),u.each(function(){var e=t(this);e.attr("style",e.data("style-cache")||null)}),r._maintainScroll&&t(window).scrollTop(c/p*t("html").outerHeight(!0)),
25	this},r._applyDataApi=function(){var e={};t("[data-match-height], [data-mh]").each(function(){var o=t(this),n=o.attr("data-mh")||o.attr("data-match-height");n in e?e[n]=e[n].add(o):e[n]=o}),t.each(e,function(){this.matchHeight(!0)})};var s=function(e){r._beforeUpdate&&r._beforeUpdate(e,r._groups),t.each(r._groups,function(){r._apply(this.elements,this.options)}),r._afterUpdate&&r._afterUpdate(e,r._groups)};r._update=function(n,a){if(a&&"resize"===a.type){var i=t(window).width();if(i===e)return;e=i;
26	}n?o===-1&&(o=setTimeout(function(){s(a),o=-1},r._throttle)):s(a)},t(r._applyDataApi);var h=t.fn.on?"on":"bind";t(window)[h]("load",function(t){r._update(!1,t)}),t(window)[h]("resize orientationchange",function(t){r._update(!0,t)})});
27
28
29
30/**
31 * GTR handlers
32 */
33
34function gtrthm_trunk8($) {
35
36	if (!$('.gtr-view-grid-associated').length) {
37		return;
38	}
39
40	$('.gtr-view-grid-associated .entry-title a').trunk8({
41		lines: 3,
42		parseHTML: true
43	});
44
45	$('.gtr-view-grid-associated a.gtr-in-taxonomy').trunk8({
46		lines: 1,
47		parseHTML: true
48	});
49
50	$('.gtr-view-grid-associated a.gtr-in-congress').trunk8({
51		lines: 1,
52		parseHTML: true
53	});
54}
55
56/*function gtrthm_addthis($) {
57	if ('undefined' != typeof addthis) {
58		$('.gtr-share-link').each(function() {
59			addthis.button(this, {}, { url: $(this).attr('url'), title: $(this).attr('data-title') });
60		});
61	}
62}*/
63
64function gtrthm_eqHeight($, loaded) {
65
66	if (!$('.gtr-view-grid-posts-item').length) {
67		return;
68	}
69
70	$('.gtr-view-grid-posts-item').matchHeight();
71
72	if (loaded) {
73
74		$.fn.matchHeight._update(true);
75
76		setTimeout(function() {
77			$.fn.matchHeight._update(true);
78		}, 0.5 * 1000);
79
80		setTimeout(function() {
81			$.fn.matchHeight._update(true);
82		}, 1 * 1000);
83
84		setTimeout(function() {
85			$.fn.matchHeight._update(true);
86		}, 1.5 * 1000);
87
88		setTimeout(function() {
89			$.fn.matchHeight._update(true);
90		}, 3 * 1000);
91
92		setTimeout(function() {
93			$.fn.matchHeight._update(true);
94		}, 5 * 1000);
95
96		setTimeout(function() {
97			$.fn.matchHeight._update(true);
98		}, 8 * 1000);
99
100		setTimeout(function() {
101			$.fn.matchHeight._update(true);
102		}, 12 * 1000);
103
104		setTimeout(function() {
105			$.fn.matchHeight._update(true);
106		}, 15 * 1000);
107	}
108}
109
110function gtrthm_sponsors_url2domain(url) {
111	try {
112		const domain = new URL(url)
113		return domain && domain.hostname
114			? domain.hostname.replace(/^(www\.)/i, '').toLowerCase()
115			: null;
116	} catch(e) {
117		return null;
118	}
119}
120
121function gtrthm_sponsors_domains($) {
122
123	let found = false;
124	const domains = {};
125
126	$('.sidebar .logos-partners a').each(function() {
127
128		const sponsorId = $(this).attr('data-sponsor-id');
129		if (!sponsorId) {
130			return;
131		}
132
133		const domain = gtrthm_sponsors_url2domain($(this).attr('href'));
134		if (domain) {
135			found = true;
136			domains[domain] = sponsorId;
137		}
138
139	});
140
141	return found ? domains : null;
142}
143
144function gtrthm_sponsors_domains_match(domains, domain) {
145
146	if (domain in domains) {
147		return domains[domain];
148	}
149
150	for (const sponsorDomain in domains) {
151		if (domain.includes('.' + sponsorDomain) ||
152			sponsorDomain.includes('.' + domain)) {
153			return domains[sponsorDomain];
154		}
155	}
156
157	return false;
158}
159
160function gtrthm_sponsors_click($) {
161
162	if ('function' != typeof gtag &&
163		'function' != typeof ga) {
164		return;
165	}
166
167	const $links = $('body.single article .entry-content a, body.single-empresas article .entry-footer a');
168	if (!$links.length) {
169		return;
170	}
171
172	const domains = gtrthm_sponsors_domains($);
173	if (!domains) {
174		return;
175	}
176
177//console.log(domains);
178//console.log('sponsorclick0');
179
180	$links.click(function() {
181
182//console.log('sponsorclick1');
183
184		const url = $(this).attr('href');
185		const domain = gtrthm_sponsors_url2domain(url);
186		if (!domain) {
187			return;
188		}
189
190		const sponsorId = gtrthm_sponsors_domains_match(domains, domain);
191		if (!sponsorId) {
192			return;
193		}
194
195		let targetAttr = '' + $(this).attr('target');
196
197//console.log('sponsorclick2');
198
199
200		if ('function' == typeof gtag) {
201
202//console.log('sponsorclick2b gtag');
203
204			/**
205			 * https://developers.google.com/analytics/devguides/collection/gtagjs/events
206			 * https://developers.google.com/analytics/devguides/collection/gtagjs/sending-data
207			 */
208			gtag('event', 'SponsorClickContent', {
209
210				'gtr_item_id'	: sponsorId,
211				'gtr_page_path'	: window.location.pathname,
212				'gtr_link_url'	: url,
213
214				transport_type	: 'beacon',
215				event_callback	: function() {
216					if (false !== targetAttr) {
217						'_blank' == targetAttr
218							? window.open(url)
219							: document.location = url;
220						targetAttr = false;
221					}
222				}
223			});
224		}
225
226		if ('function' == typeof ga) {
227
228			//console.log('sponsorclick2a ga');
229
230			/**
231			 * https://developers.google.com/analytics/devguides/collection/analyticsjs/events
232			 * ga('send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject]);
233			 */
234			/* ga('send', 'event', 'SponsorClickContent', window.location.pathname, sponsorId, url, {
235				transport	: 'beacon',
236				hitCallback	: function() {
237					document.location = url;
238				}
239			}); */
240
241			ga('send', {
242				hitType			: 'event',
243				eventCategory	: 'SponsorClickContent',
244				eventAction		: window.location.pathname + '|' + url,
245				eventLabel		: sponsorId,
246				eventValue		: 1,
247
248				transport		: 'beacon',
249				hitCallback		: function() {
250					if (false !== targetAttr) {
251						'_blank' == targetAttr
252							? window.open(url)
253							: document.location = url;
254						targetAttr = false;
255					}
256				}
257			});
258		}
259
260		return false;
261
262	});
263}
264
265/* function gtrthm_sponsored_rel($) {
266	$('a[rel~="sponsored"]').each(function() {
267		!$(this).attr('target') && $(this).attr('target', '_blank');
268	});
269} */
270
271function gtrthm_external_click($) {
272
273	if ('function' != typeof gtag) {
274		return;
275	}
276
277	const $links = $('body.single article .entry-content a, body.single-empresas article .entry-footer a');
278	if (!$links.length) {
279		return;
280	}
281
282	$links.click(function() {
283
284		const href = $(this).attr('href');
285		if (!href) {
286			return;
287		}
288
289		let linkUrl;
290		try {
291			linkUrl = new URL(href, window.location.href);
292		} catch(e) {
293			return;
294		}
295
296		if (linkUrl.hostname === window.location.hostname) {
297			return;
298		}
299
300		gtag('event', 'ExternalClickContent', {
301			'gtr_page_path'	: window.location.pathname,
302			'gtr_link_url'	: href,
303			transport_type	: 'beacon'
304		});
305
306	});
307}
308
309jQuery && jQuery(document).ready(function($) {
310
311	$('.gtr-share-button').show();
312
313	$('.gtr-menu-nolink > a').click(function(e) {
314		e.stopPropagation();
315		return false;
316	});
317
318	gtrthm_sponsors_click($);
319	gtrthm_external_click($);
320
321});
322
323jQuery && (function($) {
324
325	var loaded = false;
326	var started = false;
327
328	$(window).on('load', function() {
329		loaded = true;
330		start();
331	});
332
333	$(window).on('resize', function() {
334		if (loaded && !started) {
335			start();
336		}
337	});
338
339	function start() {
340
341		if ($(window).width() > 480) {
342			started = true;
343			gtrthm_trunk8($);
344			gtrthm_eqHeight($, false);
345		}
346	}
347
348	function sponsorsPosition() {
349
350		const $gold = $('.logos-partners-gold');
351		if (!$gold || !$gold.length) {
352			return;
353		}
354
355		const $coll = $('.logos-partners-collaborator');
356		if (!$coll || !$coll.length) {
357			return;
358		}
359
360		const $goldWrap = $gold.closest('section');
361		if (!$goldWrap || !$goldWrap.length) {
362			return;
363		}
364
365		const $collWrap = $coll.closest('section');
366		if (!$collWrap || !$collWrap.length) {
367			return;
368		}
369
370		const order = Math.floor(Math.random() * 2);
371		if (!order) {
372			return;
373		}
374
375		$collWrap.insertAfter($goldWrap);
376	}
377
378	sponsorsPosition();
379
380})(jQuery);

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.