PageSourceSearch

https://glaad.org/wp-content/plugins/maxbuttons-pro/js/maxbuttons_fonts.js?ver=9.8.6

js glaad.org collected 2026-09-27 20:54:14 UTC 3,081 bytes, 140 lines download raw bytes

1'use strict';
2
3class MaxFonts
4{
5		system_fonts = ['', 'Arial', 'Courier New', 'Georgia', 'Tahoma', 'Times New Roman', 'Trebuchet MS',
6		'Verdana' ];
7		base_url = '//fonts.googleapis.com/css?family=';
8
9		Init()
10		{
11
12		}
13
14		CheckFonts()
15		{
16
17		}
18
19		LoadFontFamily()
20		{
21
22		}
23
24		CreateFontFamilyURL(font_family)
25		{
26		//	var system_fonts =
27
28			if (this.system_fonts.indexOf(font_family) >= 0)
29				return ""; // not further action needed
30
31		//	var base_url = ;
32			var family = font_family.replace(/\s/g, '+');
33			return this.base_url + family;
34
35		}
36}
37
38
39jQuery(document).ready(function($) {
40	doFontCheck($);
41	$(document).on('media_button_content_buttons_load', {jq: $}, fontEvent );
42
43}); /* END OF JQUERY */
44
45	//var fonts_loaded = [];
46
47function fontEvent(e)
48{
49	doFontCheck(e.data.jq);
50}
51
52function doFontCheck($)
53{
54	var modal = document.querySelector('.max-modal');
55	var check_fonts = [];
56	// could happen w/ page builders like elementor, or no-footer sites.
57	if (typeof fonts_loaded == 'undefined') // Maxbuttons PRO Class output - should prob. be removed there
58				fonts_loaded = [];
59
60
61	/* This is overly complicated since this is the only way to pull pseudo-elements via JS */
62	if(modal)
63	{
64		var nodeList = modal.querySelectorAll('.maxbutton');
65		for (var i = 0; i < nodeList.length; i++)
66		{
67			var item = nodeList[i];
68			var ff = window.getComputedStyle(
69			    item, ':after'
70			).getPropertyValue('font-family');
71
72			if (ff && ff.length > 0 )
73				check_fonts.push(ff);
74		}
75	}
76
77	$('.mb-text, .mb-text2').each(function () {
78		var ff = $(this).css('fontFamily');
79		var weight = $(this).css('fontWeight');
80
81		if (typeof $(this).data('nofont') !== 'undefined')
82		{
83			return;
84		}
85
86		if (typeof ff === 'undefined') // can happen in page builders
87			return;
88
89		check_fonts.push(ff);
90	});
91
92	// check found fonts.
93	for (var i = 0; i < check_fonts.length; i++)
94	{
95		var ff = check_fonts[i];
96		ff = ff.replace(/\'|\"|/g,''); // Chrome returns font family with ' in it.
97
98		var font_found = false;
99		for (var j=0; j < fonts_loaded.length; j++) // prevent double loading
100		{
101			if (fonts_loaded[j] == ff)
102			{
103				font_found = true;
104				continue;
105			}
106		}
107
108		if (false === font_found)
109		{
110			fonts_loaded.push(ff);
111	 		mbpro_loadFontFamilyStylesheet(ff);
112		}
113	}
114
115
116} // doFontCheck
117
118function mbpro_loadFontFamilyStylesheet(font_family) {
119	if (font_family.indexOf(",", font_family) >= 0)
120		return; // a non-google font with comma, probably set by theme. This can happen if button doens't have font preference.
121
122	var font_family_url = mbpro_getFontFamilyUrl(font_family);
123	if (font_family_url != "") {
124
125		jQuery("head").append("<link rel='stylesheet' type='text/css' href='" + font_family_url + "' />");
126	}
127}
128
129function mbpro_getFontFamilyUrl(font_family) {
130	var system_fonts = ['', 'Arial', 'Courier New', 'Georgia', 'Tahoma', 'Times New Roman', 'Trebuchet MS',
131	'Verdana' ];
132
133	if (system_fonts.indexOf(font_family) >= 0)
134		return ""; // not further action needed
135
136	var base_url = '//fonts.googleapis.com/css?family=';
137	var family = font_family.replace(/\s/g, '+');
138	return base_url + family;
139
140}

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.