PageSourceSearch

https://www.micheletansella.org/wp-content/themes/crowley/ev-inc/modules/fonts/v1/js/fonts.js?ver=1.0.0

js micheletansella.org collected 2026-10-03 18:53:56 UTC 3,345 bytes, 151 lines download raw bytes

1( function( window, factory ) {
2	if ( typeof module === 'object' && module.exports ) {
3		module.exports.FontsLoadr = factory();
4	}
5	else {
6		window.FontsLoadr = factory();
7	}
8} )( typeof window !== 'undefined' ? window : this, function() {
9	'use strict';
10
11	var self = {};
12
13	/**
14	 * Configuration.
15	 */
16	self.config = {};
17
18	/**
19	 * Load a font from a custom upload.
20	 *
21	 * @since 1.0.0
22	 * @param {Object} font The font object.
23	 */
24	self.load_custom_font = function( font, webfontloader_config ) {
25		if ( typeof webfontloader_config.custom === 'undefined' ) {
26			webfontloader_config.custom = {
27				families: [],
28				urls: []
29			};
30		}
31
32		if ( font.custom.url ) {
33			webfontloader_config.custom.families.push( font.custom.font_family );
34			webfontloader_config.custom.urls.push( font.custom.url );
35		}
36	};
37
38	/**
39	 * Load a font from the Typekit service.
40	 *
41	 * @since 1.0.0
42	 * @param {Object} font The font object.
43	 */
44	self.load_typekit_font = function( font, webfontloader_config ) {
45		if ( typeof webfontloader_config.typekit === 'undefined' ) {
46			webfontloader_config.typekit = {
47				id: ''
48			};
49		}
50
51		if ( font.typekit.kitId ) {
52			webfontloader_config.typekit.id = font.typekit.kitId;
53		}
54	};
55
56	/**
57	 * Load a font from the Google Fonts service.
58	 *
59	 * @since 1.0.0
60	 * @param {Object} font The font object.
61	 */
62	self.load_google_font = function( font, webfontloader_config ) {
63		if ( typeof webfontloader_config.google === 'undefined' ) {
64			webfontloader_config.google = {
65				families: []
66			};
67		}
68
69		var load = font.google_fonts.font_family;
70
71		if ( font.google_fonts.variants ) {
72			load += ':' + font.google_fonts.variants;
73		}
74
75		if ( font.google_fonts.subsets ) {
76			load += ':' + font.google_fonts.subsets;
77		}
78
79		webfontloader_config.google.families.push( load );
80	};
81
82	/**
83	 * Begin the loading process.
84	 */
85	self.load = function() {
86		var webfontloader_config = {
87			/**
88			 * All fonts have loaded callback.
89			 */
90			'active': function() {
91				var event = new CustomEvent( 'evolvethemes-fonts-active' );
92
93				window.document.documentElement.dispatchEvent( event );
94			},
95
96			/**
97			 * No fonts have loaded callback.
98			 */
99			'inactive': function() {
100				var event = new CustomEvent( 'evolvethemes-fonts-inactive' );
101
102				window.document.documentElement.dispatchEvent( event );
103			}
104		};
105
106		self.config.forEach( function( font ) {
107			switch ( font.source ) {
108				case 'google_fonts':
109					self.load_google_font( font, webfontloader_config );
110					break;
111				case 'typekit':
112					self.load_typekit_font( font, webfontloader_config );
113					break;
114				case 'custom':
115					self.load_custom_font( font, webfontloader_config );
116					break;
117				default:
118					break;
119			}
120		} );
121
122		if ( typeof WebFont !== 'undefined' ) {
123			WebFont.load( webfontloader_config ); // jshint ignore:line
124		}
125	};
126
127	/**
128	 * Initialization.
129	 */
130	self.init = function( config ) {
131		self.config = config;
132
133		( function() {
134			function CustomEvent( event, params ) {
135				params = params || { bubbles: false, cancelable: false, detail: undefined };
136				var evt = document.createEvent( 'CustomEvent' );
137				evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail );
138				return evt;
139			}
140
141			CustomEvent.prototype = window.Event.prototype;
142
143			window.CustomEvent = CustomEvent;
144		} )();
145
146		self.load();
147	};
148
149	return self;
150
151} );

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.