PageSourceSearch

https://classifieds.advertiser.ie/wp-content/themes/galadclassifieds/incl/js/utils.js?ver=6.9.9

js advertiser.ie collected 2026-09-24 09:16:49 UTC 7,336 bytes, 206 lines download raw bytes

1/* Make the dropdown show on mouse over */
2jQuery(function($){
3// need this? seems to work without it. If we do need it, we need to only do it on screens < 767px
4//  $('.navbar-collapse .dropdown-toggle').removeAttr('data-toggle');
5});
6
7jQuery(document).ready(function() {
8	//smooth scroll to anchor
9	var jQueryroot = jQuery('html, body');
10	jQuery('a.linktoanchor').click(function(){
11		jQueryroot.animate({ scrollTop: jQuery( jQuery.attr(this, 'href') ).offset().top}, 500);
12		return false;
13	});
14	jQuery('a.anchor').click(function(){
15		jQueryroot.animate({ scrollTop: jQuery( jQuery.attr(this, 'href') ).offset().top}, 500);
16		return false;
17	});
18	// smooth scroll and keep anchor in url
19	jQuery('a.anchorurl').click(function() {
20		var href = jQuery.attr(this, 'href');
21		jQueryroot.animate({ scrollTop: jQuery(href).offset().top}, 500, function () {
22			window.location.hash = href;
23		});
24		return false;
25	});
26
27	var maxHeightForReadMore = 210;
28	addReadMoreExpander(".trib_readmore_container", maxHeightForReadMore);
29
30	addAccordionExpander();
31	jQuery( ".trib-expander-content" ).hide();
32	jQuery( ".trib-expander-toggle" ).click(function() {  doExpand( jQuery(this).next(), this ); });
33
34});
35
36
37
38/* max height expander */
39function addReadMoreExpander(expanderClassName, closedheight){
40	//pass in e.g. ".trib_readmore_container" as expanderClassName
41	var text_expand_text = "Read More...";
42	var text_collapse_text = "Collapse";
43
44	jQuery(expanderClassName).each(function() {
45		if (jQuery(this).height() >= (closedheight) ){
46			jQuery(this).append('<div class= "trib_text-expand-button"><span class= "trib_text-collapse-button">' + text_expand_text + '</span></div>');
47			jQuery(".trib_readmore_text").addClass("trib_text-readmore-collapsed");
48			jQuery(this).find(".trib_text-collapse-button").on("click", function() {
49				jQuery(this).parent().siblings(".trib_readmore_text").toggleClass("trib_text-readmore-expanded").toggleClass("trib_text-readmore-collapsed");
50				if (jQuery(this).parent().siblings(".trib_readmore_text").hasClass("trib_text-readmore-expanded")) {
51					jQuery(this).html(text_collapse_text);
52			   } else {
53					jQuery(this).html(text_expand_text);
54				}
55			})
56		}
57	})
58}
59
60
61
62
63
64
65
66/* max height expander */
67function addReadMoreExpanderEqualHeight(expanderClassName){
68	//pass in e.g. ".trib_readmore_container" as expanderClassName
69	var text_expand_text = "Read More...";
70	var text_collapse_text = "Hide";
71
72	var collapsedClass = "trib_text-readmore-collapsed";
73	var expandedClass = "trib_text-readmore-expanded";
74	
75	var closedheight="";
76	var bHaveCollapsedElement = false;
77	
78	var collapsedelement = window.document.querySelectorAll("*[class^=\"trib_readmore_text collapsedheight_\"]")[0];
79	if(collapsedelement){
80		//console.log("collapsedelement");console.log(collapsedelement);
81		var heightclass = collapsedelement.className;
82		//console.log("heightclass:"+heightclass);
83		if(heightclass)
84			var closedheight=heightclass.substring(heightclass.lastIndexOf("_")+1);
85/*
86		if (closedheight && window.innerWidth <768)
87			closedheight = (parseInt(closedheight)/2)+80;
88		console.log("browser width:"+window.innerWidth);
89*/
90		console.log("height:"+closedheight);
91	}
92	if(closedheight){
93		jQuery(expanderClassName).each(function() {
94				var thiheight = jQuery(this).height();
95	console.log("checking height="+thiheight + " clasedheight="+closedheight );
96			if (jQuery(this).height() >= (closedheight) ){
97				bHaveCollapsedElement = true;
98				jQuery(this).append('<div class= "trib_text-expand-button"><span class= "trib_text-collapse-button">' + text_expand_text + '</span></div>');
99	//		console.log("THIS CLASS="+jQuery(this).attr('class'));
100	
101	//			jQuery(".trib_readmore_text").addClass(collapsedClass);
102				jQuery(this).find(".trib_readmore_text").addClass(collapsedClass);
103	
104				jQuery(this).find(".trib_text-collapse-button").on("click", function() {
105					jQuery(this).parent().siblings(".trib_readmore_text").toggleClass(expandedClass).toggleClass(collapsedClass);
106					
107	//			if (jQuery(this).parent().siblings(".trib_readmore_text").hasClass(expandedClass)) {
108				if (jQuery(this).siblings(".trib_readmore_text").hasClass(expandedClass)) {
109						jQuery(this).html(text_collapse_text);
110				   } else {
111						jQuery(this).html(text_expand_text);
112					}
113				})
114	
115			}
116		})
117	//console.log("after collapsing...");
118	}
119
120	// if we hae a collapsed section, check for others that are not collapsed and make them the same height
121	if (bHaveCollapsedElement && window.innerWidth >= 768){
122		// add height of Read More text as it's added onto the collapsed height
123		siblingHeight = parseInt(closedheight)+30;
124		
125		jQuery(expanderClassName).each(function() {
126			jQuery(this).closest(".row").find(".trib_readmore_text:not(.trib_text-readmore-collapsed)").css('height', siblingHeight + "px");
127		})
128	}
129}
130
131
132function doExpand( elToSlide, expandlink ) {
133	jQuery( elToSlide ).slideToggle("slow");
134	jQuery( expandlink ).children("span.dashicons").toggleClass("dashicons-arrow-down-alt2");
135	jQuery( expandlink ).children("span.dashicons").toggleClass("dashicons-arrow-up-alt2");
136
137//	jQuery( expandlink ).children("span.dashicons").toggleClass("dashicons-plus-alt2");
138//	jQuery( expandlink ).children("span.dashicons").toggleClass("dashicons-minus");
139
140	return false;
141}
142
143function addAccordionExpander(){
144	//pass in e.g. ".trib_expander_container" as expanderClassName
145	var text_expand_text = "Read More...";
146	var text_collapse_text = "Collapse";
147
148
149	jQuery('.trib-expander-sections h3:not(.trib-expander-end)').addClass("trib-expander-toggle");
150	jQuery('.trib-expander-sections h3.trib-expander-toggle').wrapInner( "<span class='linkexpandertext'></span>");
151
152	jQuery('<span class="dashicons dashicons-arrow-down-alt2"></span>').appendTo(jQuery('.trib-expander-sections h3'));
153//	jQuery('<span class="dashicons dashicons-plus-alt2"></span>').prependTo(jQuery('.trib-expander-sections h3'));
154	
155
156
157	jQuery('.trib-expander-sections h3').each(function() {
158	  // Build an array of all nodes (including text nodes) up to and not including the next h3 if any
159	  var nodes = [];
160	  var n = this.nextSibling;
161	
162	  while (n && n.nodeName != "H3") {
163		    console.log(" n.nodeName="+n.nodeName);
164		  nodes.push(n);n = n.nextSibling;}
165	  jQuery(nodes).wrapAll("<div class='trib-expander-content'></div>");
166	});
167}
168/*
169
170jQuery(document).ready(function ($) {
171    const $rows = $(".adverts-grid > .adverts-grid-row");
172    const $subMenus = $(".adverts-grid > .adverts-multi-level");
173
174    // Hide all submenus at start
175    $subMenus.hide();
176
177    function hideAll() {
178        $subMenus.stop(true, true).hide(); // fully stop animations
179    }
180
181    $rows.on("click", function (e) {
182        // prevent following the <a>
183        if ($(e.target).is("a")) {
184            e.preventDefault();
185        }
186        hideAll();
187        // find the next .adverts-multi-level
188        const $next = $(this).nextAll(".adverts-multi-level").first();
189        if ($next.length) {
190
191            // prepare for slide-in
192            $next.css({
193                display: "block",
194                opacity: 0,
195                left: "120px"   // start slightly off-screen inside the container
196            });
197            // animate slide-in from the left
198            $next.stop(true, true).animate({
199                opacity: 1,
200                left: "180px"
201            }, 250);
202        }
203    });
204
205});
206*/

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.