PageSourceSearch

https://thisisintersex.org/wp-content/plugins/al-fb-admin-panel/ar…/scripts/al-main-script.js?ver=2.1.11

js thisisintersex.org collected 2026-10-04 05:47:02 UTC 19,545 bytes, 589 lines download raw bytes

1function setWrapperHeight(slideWrapper, offset, newHeight) {
2	var columns = parseInt(slideWrapper.attr("data-columns"));
3	var nextReviews = null;
4
5	var children = slideWrapper.find(".al-slide-wrapper").children();
6
7	if (offset < 0) {
8		nextReviews = children.slice(offset);
9		nextReviews = nextReviews.add( children.slice(0, columns + offset) );
10	} else {
11		nextReviews = children.slice(offset, columns + offset);
12	}
13
14	if ( typeof newHeight === 'undefined' ) newHeight = 0;
15	var arrHeights = nextReviews.map(function () {
16		return jQuery(this).outerHeight();
17	}).get();
18	arrHeights.push( newHeight );
19	var maxHeight = Math.max.apply(null, arrHeights);
20
21	slideWrapper.find(".al-slide-wrapper").height(maxHeight);
22}
23
24function stopSliderTiming(slideWrapper) {
25	clearTimeout( slideWrapper.data("timer") );
26}
27
28function startSliderTiming(slideWrapper, timing) {
29	stopSliderTiming(slideWrapper);
30
31	if (timing !== 0) {
32		var timer = setTimeout(function() {
33			nextReview(slideWrapper);
34			startSliderTiming(slideWrapper, timing);
35		}, timing);
36
37		slideWrapper.data("timer", timer);
38	} else {
39		slideWrapper.data("timer", null);
40	}
41}
42
43function getShiftIndex(slideWrapper, direction) {
44	var columns = parseInt(slideWrapper.attr("data-columns"));
45	var columnShift = parseInt(slideWrapper.attr("data-shift"));
46
47	if (columnShift == 0) columnShift = columns;
48
49	return slideWrapper.data("index") + columnShift * direction;
50}
51
52function prevReview(slideWrapper) {
53	goToReview(slideWrapper, getShiftIndex(slideWrapper, -1));
54}
55
56function nextReview(slideWrapper) {
57	
58
59	goToReview(slideWrapper, getShiftIndex(slideWrapper, 1));
60}
61
62function goToReview(slideWrapper, index) {
63	if (slideWrapper.data("can-slide")) {
64		var children = slideWrapper.find(".al-slide-wrapper").children();
65		var currentIndex = slideWrapper.data("index");
66		var deltaIndex = index - currentIndex;
67		var newIndex = index % children.length;
68		slideWrapper.data("index", newIndex);
69
70		if (currentIndex == children.length - 1 && newIndex == 0) {
71			deltaIndex = 1;
72		} else if (currentIndex == 0 && newIndex == children.length - 1) {
73			deltaIndex = -1;
74		}
75
76		slideWrapper.find(".al-reviews-slider-pagination li").removeClass("al-current")
77			.eq(newIndex).addClass("al-current");
78
79		var columnShift = Math.abs(deltaIndex);
80
81		if ( slideWrapper.is(":visible") ) {
82			if (deltaIndex > 0) {
83				setWrapperHeight(slideWrapper, columnShift);
84
85				slideWrapper.data("can-slide", false);
86				children.eq(0).on("transitionend", function() {
87					jQuery(this).off("transitionend");
88					slideWrapper.data("can-slide", true);
89
90					children.addClass("notransition");
91					children.css("transform", "");
92					/* jshint ignore:start */
93					children[0].offsetHeight;	// trigger reflow to apply changes
94					/* jshint ignore:end */
95					
96					children.removeClass("notransition");
97
98					children.slice(0, columnShift).appendTo( slideWrapper.find(".al-slide-wrapper") );
99				});
100
101				children.css("transform", "translate(-" + (columnShift * 100) + "%, 0)");
102			} else if (deltaIndex < 0) {
103				setWrapperHeight(slideWrapper, -columnShift);
104
105				slideWrapper.data("can-slide", false);
106				children.eq(0).on("transitionend", function() {
107					jQuery(this).off("transitionend");
108					slideWrapper.data("can-slide", true);
109				});
110
111				children.slice(-columnShift).prependTo( slideWrapper.find(".al-slide-wrapper") );
112				children.addClass("notransition");
113				children.css("transform", "translate(-" + (columnShift * 100) + "%, 0)");
114				/* jshint ignore:start */
115				children[0].offsetHeight;	//trigger reflow to apply changes
116				/* jshint ignore:end */
117
118				children.removeClass("notransition");
119				children.css("transform", "");
120			}
121		} else {
122			children.eq(0).off("transitionend");
123			children.css("transform", "");
124			children.slice(0, columnShift).appendTo( slideWrapper.find(".al-slide-wrapper") );
125		}
126	}
127}
128
129function showMoreReviews(elem, button) {
130	var cols = parseInt(elem.attr("data-columns"));
131	var newRows = parseInt(elem.attr("data-shift"));
132	var visibleReviews = elem.children("div.visible").length;
133
134	var nextVisible = null;
135	if (newRows == 0) {
136		nextVisible = elem.children("div").slice(visibleReviews);
137	} else {
138		nextVisible = elem.children("div").slice(visibleReviews, visibleReviews + newRows * cols);
139	}
140
141	var currHeight = elem.outerHeight();
142	elem.css("max-height", currHeight);
143	elem.addClass("al-transition");
144	nextVisible.addClass("visible");
145	/* jshint ignore:start */
146	elem[0].offsetHeight;	//trigger reflow to apply changes
147	/* jshint ignore:end */
148
149	var maxHeight = elem[0].scrollHeight;
150	elem.css("max-height", maxHeight);
151
152	if ( elem.children("div:not(.visible)").length == 0 ) {
153		if ( !elem.hasClass("fusion-child-element") ) {
154			button.hide();
155		}
156		elem.find(".reviews").children("div").addClass("visible");
157		elem.find(".reviews").css("max-height", "none");
158	}
159}
160
161function truncateTags(elem, charCount) {
162	var grabText = '';
163	var missCount = charCount;
164
165	jQuery(elem).contents().each(function() {
166		if (this.nodeType == Node.TEXT_NODE) {
167			var curText = this.data.replace(/\s\s|\n/g, " ");
168			grabText += curText.substr(0, missCount);
169			missCount -= Math.min(curText.length, missCount);
170		} else if (this.nodeType == Node.ELEMENT_NODE) {
171			var childPart = truncateTags(this, missCount);
172			grabText += childPart.text;
173			missCount -= childPart.count;
174		}
175		if (missCount == 0) {
176			return false;
177		}
178	});
179
180	return {
181		text: elem.outerHTML.match(/^<[^>]+>/m)[0] + grabText + '</' + elem.localName + '>',
182		count: charCount - missCount
183	};
184}
185
186function truncateTagsByWord(elem, wordCount) {
187	var words = jQuery(elem).text().trim().split(/[\s]+/).slice(0, wordCount);
188	var charCount = 0;
189	for (var i = 0; i < words.length; i++) {
190		charCount += words[i].length + 1; //include space between words
191	}
192	//charCount--; //remove last space
193
194	return truncateTags(elem, charCount);
195}
196
197function getAppendingElement(elem) {
198	var node = elem.contents().last();
199
200	try {
201		if (node[0].nodeType == Node.TEXT_NODE || node[0].tagName.toLowerCase() == "a") {
202			return node.parent();
203		} else {
204			return node;
205		}
206	} catch (err) {
207		console.log("[ArcticLune] Appended text is too long.");
208		return null;
209	}
210}
211
212(function($){
213	$.fn.shuffle = function() {
214 
215		var allElems = this.get();
216		var getRandom = function(max) {
217			return Math.floor(Math.random() * max);
218		};
219		var shuffled = $.map(allElems, function() {
220			var random = getRandom(allElems.length),
221				randEl = $(allElems[random]).clone(true)[0];
222			allElems.splice(random, 1);
223			return randEl;
224		});
225 
226		this.each(function(i){
227			$(this).replaceWith($(shuffled[i]));
228		});
229 
230		return $(shuffled);
231	};
232})(jQuery);
233
234function initFB_AL_Reviews( elem ) {
235	elem = jQuery(".al-fb-reviews", elem);
236
237	jQuery(".al-reviews-random").each(function() {
238		jQuery(".review", this).shuffle();
239	});
240
241	jQuery(".al-reviews-slider").each(function() {
242		var slideWrapper = jQuery(this);
243		var slideTiming = slideWrapper.attr("data-timing") * 1000;
244		slideWrapper.data("index", 0);
245		slideWrapper.data("can-slide", true);
246
247		slideWrapper.on("mouseenter", function() {
248			stopSliderTiming(slideWrapper);
249		});
250		slideWrapper.on("mouseleave", function() {
251			startSliderTiming(slideWrapper, slideTiming);
252		});
253
254		slideWrapper.find(".al-reviews-slider-arrow-left").on("click", function() {
255			stopSliderTiming(slideWrapper);
256
257			prevReview(slideWrapper);
258		});
259		slideWrapper.find(".al-reviews-slider-arrow-right").on("click", function() {
260			stopSliderTiming(slideWrapper);
261
262			nextReview(slideWrapper);
263		});
264		slideWrapper.find(".al-reviews-slider-pagination li").eq(0).addClass("al-current");
265		slideWrapper.find(".al-reviews-slider-pagination li").on("click", function() {
266			stopSliderTiming(slideWrapper);
267
268			var index = jQuery(this).index();
269
270			goToReview(slideWrapper, index);
271		});
272
273		setTimeout(setWrapperHeight, 100, slideWrapper, 0);
274		startSliderTiming(slideWrapper, slideTiming);
275	});
276
277	jQuery(".al-reviews-grid").each(function(){
278		var currentContainer = jQuery(this);
279		var initialRows = parseInt(currentContainer.attr("data-initial-rows"));
280
281		if (initialRows == 0) {
282			//show all reviews
283			currentContainer.css("max-height", "none");
284			currentContainer.children(".review, .fusion-builder-live-child-element").addClass("visible");
285		} else {
286			//show initial reviews
287			var cols = parseInt(currentContainer.attr("data-columns"));
288			currentContainer.children(".review, .fusion-builder-live-child-element").slice(0, initialRows * cols).addClass("visible");
289			/* jshint ignore:start */
290			currentContainer[0].offsetHeight;	//trigger reflow to apply changes
291			/* jshint ignore:end */
292			var currHeight = currentContainer[0].scrollHeight;
293			currentContainer.css("max-height", "none");
294
295			var hideButton = false;
296			if ( !currentContainer.hasClass("fusion-child-element") && currentContainer.children(".review:not(.visible), .fusion-builder-live-child-element:not(.visible)").length == 0 ) {
297				hideButton = true;
298			}
299
300			var buttonID = currentContainer.attr("data-button-id");
301			if (buttonID != undefined) {
302				if (hideButton) {
303					jQuery("#" + buttonID).hide();
304				} else {
305					jQuery("#" + buttonID).on("click", function(e) {
306						e.preventDefault();
307						showMoreReviews(currentContainer, jQuery(this));
308					});
309				}
310			} else {
311				if (hideButton) {
312					currentContainer.siblings(".al-grid-show-more").find("> div").hide();
313				} else {
314					currentContainer.siblings(".al-grid-show-more").find("> div").on("click", function() {
315						showMoreReviews(currentContainer, jQuery(this));
316					});
317				}
318			}
319		}
320
321		currentContainer.on("transitionend", function() {
322			currentContainer.removeClass("al-transition");
323			currentContainer.css("max-height", "none");
324		});
325	});
326
327	jQuery(".al-truncate-char", elem).each(function() {
328		var truncLength = parseInt(jQuery(this).attr("data-trunc"));
329		var doShowLess = jQuery(this).hasClass("al-truncate-showless");
330
331		if ( jQuery(".review-body-short", this).text().trim().length > truncLength ) {
332			var truncText = jQuery(this).attr("data-trunc-text");
333			var truncLink = jQuery(this).attr("data-trunc-linktext");
334			var truncTextContent = '<span class="al-trunctext">' + truncText + '</span>';
335			var truncLinkContent = '<a href="javascript:void(0);" class="al-readmore">' + truncLink + '</a>';
336			var truncLinkStyle = jQuery(this).attr("data-trunc-linkstyle");
337
338			var showLessLinkContent = '';
339			var showLessLinkStyle = '';
340			if (doShowLess) {
341				showLessLinkContent = '<a href="javascript:void(0);" class="al-readless">' + jQuery(this).attr("data-showless-text") + '</a>';
342				showLessLinkStyle = jQuery(this).attr("data-showless-style");
343			}
344
345			var truncAppendLength = 0;
346			var truncAppend = "";
347			if (truncLinkStyle == "inline") {
348				truncAppend = truncTextContent + ' ' + truncLinkContent;
349			} else if (truncLinkStyle == "below") {
350				truncAppend = truncTextContent;
351			}
352
353			jQuery(".review-body-short", this).each(function () {
354				var newContent = truncateTags(this, truncLength - truncAppendLength).text;
355				jQuery(this).html(newContent);
356
357				var appElement = getAppendingElement(jQuery(".review-body", this));
358				if (appElement != null) {
359					appElement.append(truncAppend);
360					if (truncLinkStyle == "below") {
361						jQuery(".review-body", this).append("<p>" + truncLinkContent + "</p>");
362					}
363	
364					var newShort = jQuery(".review-body", this).unwrap();
365
366					if (doShowLess) {
367						var appElementFull = getAppendingElement(newShort.siblings(".review-body-full"));
368						if (appElementFull != null) {
369							if (showLessLinkStyle == "below") {
370								newShort.siblings(".review-body-full").append("<p>" + showLessLinkContent + "</p>");
371							} else {
372								appElementFull.append(showLessLinkContent);
373							}
374						}
375					}
376				}
377			});
378		}
379	});
380	jQuery(".al-truncate-word", elem).each(function() {
381		var truncLength = parseInt(jQuery(this).attr("data-trunc"));
382		var doShowLess = jQuery(this).hasClass("al-truncate-showless");
383
384		if ( jQuery(".review-body-short", this).text().trim().split(/[\s]+/).length > truncLength ) {
385			var truncText = jQuery(this).attr("data-trunc-text");
386			var truncLink = jQuery(this).attr("data-trunc-linktext");
387			var truncTextContent = '<span class="al-trunctext">' + truncText + '</span>';
388			var truncLinkContent = '<a href="javascript:void(0);" class="al-readmore">' + truncLink + '</a>';
389			var truncLinkStyle = jQuery(this).attr("data-trunc-linkstyle");
390
391			var showLessLinkContent = '';
392			var showLessLinkStyle = '';
393			if (doShowLess) {
394				showLessLinkContent = '<a href="javascript:void(0);" class="al-readless">' + jQuery(this).attr("data-showless-text") + '</a>';
395				showLessLinkStyle = jQuery(this).attr("data-showless-style");
396			}
397
398			var truncAppendLength = 0;
399			var truncAppend = "";
400			if (truncLinkStyle == "inline") {
401				truncAppend = truncTextContent + ' ' + truncLinkContent;
402			} else if (truncLinkStyle == "below") {
403				truncAppend = truncTextContent;
404			}
405
406			jQuery(".review-body-short", this).each(function () {
407				var newContent = truncateTagsByWord(this, truncLength - truncAppendLength).text;
408				jQuery(this).html(newContent);
409
410				var appElement = getAppendingElement(jQuery(".review-body", this));
411				if (appElement != null) {
412					appElement.append(truncAppend);
413					if (truncLinkStyle == "below") {
414						jQuery(".review-body", this).append("<p>" + truncLinkContent + "</p>");
415					}
416
417					var newShort = jQuery(".review-body", this).unwrap();
418
419					if (doShowLess) {
420						var appElementFull = getAppendingElement(newShort.siblings(".review-body-full"));
421						if (appElementFull != null) {
422							if (showLessLinkStyle == "below") {
423								newShort.siblings(".review-body-full").append("<p>" + showLessLinkContent + "</p>");
424							} else {
425								appElementFull.append(showLessLinkContent);
426							}
427						}
428					}
429				}
430			});
431		}
432	});
433	jQuery(".al-truncate-line", elem).each(function() {
434		var doShowLess = jQuery(this).hasClass("al-truncate-showless");
435
436		var truncText = jQuery(this).attr("data-trunc-text");
437		var truncLink = jQuery(this).attr("data-trunc-linktext");
438		var truncTextContent = '<span class="al-trunctext">' + truncText + '</span>';
439		var truncLinkContent = '<a href="javascript:void(0);" class="al-readmore">' + truncLink + '</a>';
440		var truncLinkStyle = jQuery(this).attr("data-trunc-linkstyle");
441
442		var truncAppendLength = 0;
443		var truncAppend = "";
444		if (truncLinkStyle == "inline") {
445			truncAppendLength = truncText.length + 1 + truncLink.length;
446			truncAppend = truncTextContent + ' ' + truncLinkContent;
447		} else if (truncLinkStyle == "below") {
448			truncAppendLength = truncText.length;
449			truncAppend = truncTextContent;
450		}
451
452		var showLessLinkContent = '';
453		var showLessLinkStyle = '';
454		if (doShowLess) {
455			showLessLinkContent = '<a href="javascript:void(0);" class="al-readless">' + jQuery(this).attr("data-showless-text") + '</a>';
456			showLessLinkStyle = jQuery(this).attr("data-showless-style");
457		}
458
459		//determine if truncation is possible
460		var maxHeight = parseInt(jQuery(".review-body-short", this).css("line-height")) * parseInt(jQuery(this).attr("data-trunc"));
461		jQuery(".review", this).first().append('<div class="review-body review-body-linetest">' + truncAppend + '</div>');
462		if ( parseInt(jQuery(".review-body-linetest", this).height()) > maxHeight ) {
463			console.log("[ArcticLune] Appended text is too long.");
464		} else {
465			//truncate since appended text is short enough
466			jQuery(".review-body-shave", this).each(function () {
467				if ( parseInt(jQuery(this).siblings(".review-body-short").height()) > maxHeight ) {
468					var currentContainer = jQuery(this).parent();
469	
470					jQuery(this).shave(maxHeight, {
471						character: truncAppend,
472					});
473					jQuery(".js-shave", this).remove();
474	
475					var shortContainer = jQuery(this).siblings(".review-body-short");
476					var fullContainer = jQuery(this).siblings(".review-body-full");
477					var curLength = jQuery(this).text().trim().length - truncAppendLength;
478					var curHeight = 0;
479					var newContent = "";
480	
481					var tempContainer = jQuery(this);
482	
483					do {
484						newContent = truncateTags(shortContainer[0], curLength).text;
485	
486						tempContainer.html(newContent);
487						var appElement = getAppendingElement(tempContainer.find(".review-body"));
488						if (appElement != null) {
489							appElement.append(truncAppend);
490							tempContainer = tempContainer.find(".review-body");
491							newContent = tempContainer.contents();
492							tempContainer.addClass("review-body-shave").removeClass("review-body-short").unwrap();
493	
494							curHeight = parseInt(tempContainer.css("height"));
495							curLength--;
496						} else {
497							tempContainer = null;
498							break;
499						}
500					} while (curHeight > maxHeight);
501	
502					if (tempContainer != null) {
503						shortContainer.html(newContent);
504						shortContainer = jQuery(".review-body-short", currentContainer);
505						if (truncLinkStyle == "below") {
506							shortContainer.append("<p>" + truncLinkContent + "</p>");
507						}
508
509						if (doShowLess) {
510							var appElementFull = getAppendingElement(fullContainer);
511							if (appElementFull != null) {
512								if (showLessLinkStyle == "below") {
513									fullContainer.append("<p>" + showLessLinkContent + "</p>");
514								} else {
515									appElementFull.append(showLessLinkContent);
516								}
517							}
518						}
519					}
520				}
521			});
522		}
523		jQuery(".review-body-linetest", this).remove();
524	});
525	jQuery(".al-readmore", elem).on("click", function() {
526		var parent = jQuery(this).closest(".review-body");
527		var fullContainer = parent.siblings(".review-body-full");
528		var height = parent.css("height");
529		var reviewHeight = parseInt(jQuery(this).closest(".review").height());
530		parent.hide();
531
532		fullContainer.css("max-height", height);
533		fullContainer.show();
534		/* jshint ignore:start */
535		fullContainer[0].offsetHeight;	//trigger reflow to apply changes
536		/* jshint ignore:end */
537		var maxHeight = fullContainer[0].scrollHeight;
538		fullContainer.css("max-height", maxHeight);
539
540		fullContainer.on("transitionend", function() {
541			fullContainer.css("max-height", "");
542		});
543
544		var heightDiff = maxHeight - parseInt(height);
545		var sliderHeight = fullContainer.closest(".al-reviews-slider").height();
546		if ( sliderHeight && reviewHeight + heightDiff > sliderHeight ) {
547			fullContainer.closest(".al-reviews-slider").height(sliderHeight + heightDiff);
548		}
549
550		//Fix slider height when viewing more of a review
551		var slider = elem.children('.al-reviews-slider');
552		if ( slider.length > 0 ) {
553			setWrapperHeight(slider, 0, sliderHeight + heightDiff);
554		}
555	});
556	jQuery(".al-readless", elem).on("click", function() {
557		var parent = jQuery(this).closest(".review-body");
558		var shortContainer = parent.siblings(".review-body-short");
559		var height = parent.css("height");
560		var minHeight = shortContainer[0].scrollHeight;
561		parent.hide();
562
563		shortContainer.css("min-height", height);
564		shortContainer.show();
565		/* jshint ignore:start */
566		shortContainer[0].offsetHeight;	//trigger reflow to apply changes
567		/* jshint ignore:end */
568		shortContainer.css("min-height", minHeight);
569
570		shortContainer.on("transitionend", function() {
571			shortContainer.css("min-height", "");
572			//Fix slider height when viewing less of a review
573			var slider = elem.children('.al-reviews-slider');
574			if ( slider.length > 0 ) {
575				setWrapperHeight(slider, 0, minHeight);
576			}
577		});
578	});
579}
580
581jQuery(document).ready(function() {
582	jQuery(window).on("resize", function() {
583		jQuery(".al-reviews-slider").each(function() {
584			setWrapperHeight(jQuery(this), 0);
585		});
586	});
587
588	initFB_AL_Reviews( document.body );
589});

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.