PageSourceSearch

https://greenkonnect.co.jp/templates/beez3/javascript/respond.src.js

js greenkonnect.co.jp collected 2026-10-06 07:18:53 UTC 9,481 bytes, 329 lines download raw bytes

vendor: 4,638 bytes, lines 1-152
1/*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas. Dual MIT/BSD license */
2/*! NOTE: If you're already including a window.matchMedia polyfill via Modernizr or otherwise, you don't need this part */
3window.matchMedia = window.matchMedia || (function(doc, undefined){
4
5  var bool,
6      docElem  = doc.documentElement,
7      refNode  = docElem.firstElementChild || docElem.firstChild,
8      // fakeBody required for <FF4 when executed in <head>
9      fakeBody = doc.createElement('body'),
10      div      = doc.createElement('div');
11
12  div.id = 'mq-test-1';
13  div.style.cssText = "position:absolute;top:-100em";
14  fakeBody.style.background = "none";
15  fakeBody.appendChild(div);
16
17  return function(q){
18
19    div.innerHTML = '&shy;<style media="'+q+'"> #mq-test-1 { width: 42px; }</style>';
20
21    docElem.insertBefore(fakeBody, refNode);
22    bool = div.offsetWidth == 42;
23    docElem.removeChild(fakeBody);
24
25    return { matches: bool, media: q };
26  };
27
28})(document);
29
30
31
32
33/*! Respond.js v1.1.0: min/max-width media query polyfill. (c) Scott Jehl. MIT/GPLv2 Lic. j.mp/respondjs  */
34(function( win ){
35	// Exposed namespace
36	win.respond = {};
37
38	// Define update even in native-mq-supporting browsers, to avoid errors
39	respond.update = function(){};
40
41	// Expose media query support flag for external use
42	respond.mediaQueriesSupported = win.matchMedia && win.matchMedia( "only all" ).matches;
43
44	// If media queries are supported, exit here
45	if ( respond.mediaQueriesSupported ){ return; }
46
47	// Define vars
48	var doc            = win.document,
49		docElem        = doc.documentElement,
50		mediastyles    = [],
51		rules          = [],
52		appendedEls    = [],
53		parsedSheets   = {},
54		resizeThrottle = 30,
55		head           = doc.getElementsByTagName( "head" )[0] || docElem,
56		base           = doc.getElementsByTagName( "base" )[0],
57		links          = head.getElementsByTagName( "link" ),
58		requestQueue   = [],
59
60		// Loop stylesheets, send text content to translate
61		ripCSS = function(){
62
63			var sheets = links,
64				sl     = sheets.length,
65				i      = 0,
66				// Vars for loop:
67				sheet, href, media, isCSS;
68
69			for( ; i < sl; i++ ){
70				sheet = sheets[ i ],
71				href  = sheet.href,
72				media = sheet.media,
73				isCSS = sheet.rel && sheet.rel.toLowerCase() === "stylesheet";
74
75				//only links plz and prevent re-parsing
76				if ( !!href && isCSS && !parsedSheets[ href ] ){
77					// selectivizr exposes css through the rawCssText expando
78					if (sheet.styleSheet && sheet.styleSheet.rawCssText) {
79						translate( sheet.styleSheet.rawCssText, href, media );
80						parsedSheets[ href ] = true;
81					} else {
82
83						if ( (!/^([a-zA-Z:]*\/\/)/.test( href ) && !base)
84							|| href.replace( RegExp.$1, "" ).split( "/" )[0] === win.location.host ){
85							requestQueue.push( {
86								href: href,
87								media: media
88							} );
89						}
90					}
91				}
92			}
93			makeRequests();
94		},
95
96		// Recurse through request queue, get css text
97		makeRequests = function(){
98
99			if ( requestQueue.length ){
100				var thisRequest = requestQueue.shift();
101
102				ajax( thisRequest.href, function( styles ){
103
104					translate( styles, thisRequest.href, thisRequest.media );
105					parsedSheets[ thisRequest.href ] = true;
106					makeRequests();
107				} );
108			}
109		},
110
111		// Find media blocks in css text, convert to style blocks
112		translate       = function( styles, href, media ){
113			var qs      = styles.match(  /@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi ),
114				ql      = qs && qs.length || 0,
115				// Try to get CSS path
116				href    = href.substring( 0, href.lastIndexOf( "/" )),
117				repUrls = function( css ){
118					return css.replace( /(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g, "$1" + href + "$2$3" );
119				},
120				useMedia = !ql && media,
121				// Vars used in loop
122				i        = 0,
123				j, fullq, thisq, eachq, eql;
124
125			// If path exists, tack on trailing slash
126			if ( href.length ){ href += "/"; }
127
128			//if no internal queries exist, but media attr does, use that
129			//note: this currently lacks support for situations where a media attr is specified on a link AND
130				//its associated stylesheet has internal CSS media queries.
131				//In those cases, the media attribute will currently be ignored.
132			if ( useMedia ){
133				ql = 1;
134			}
135
136			for( ; i < ql; i++ ){
137				j = 0;
138
139				// Media attr
140				if ( useMedia ){
141					fullq = media;
142					rules.push( repUrls( styles ) );
143				}
144				// Parse for styles
145				else{
146					fullq = qs[ i ].match( /@media *([^\{]+)\{([\S\s]+?)$/ ) && RegExp.$1;
147					rules.push( RegExp.$2 && repUrls( RegExp.$2 ) );
148				}
149
150				eachq = fullq.split( "," );
151				eql   = eachq.length;
152
153				for( ; j < eql; j++ ){
154					thisq = eachq[ j ];
155					mediastyles.push( {
156						media    : thisq.split( "(" )[ 0 ].match( /(only\s+)?([a-zA-Z]+)\s?/ ) && RegExp.$2 || "all",
157						rules    : rules.length - 1,
158						hasquery : thisq.indexOf("(") > -1,
159						minw     : thisq.match( /\(min\-width:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/ ) && parseFloat( RegExp.$1 ) + ( RegExp.$2 || "" ),
160						maxw     : thisq.match( /\(max\-width:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/ ) && parseFloat( RegExp.$1 ) + ( RegExp.$2 || "" )
161					} );
162				}
163			}
164
165			applyMedia();
166		},
167
168		lastCall,
169
170		resizeDefer,
171
172		// returns the value of 1em in pixels
173		getEmValue = function() {
174			var ret,
175				div      = doc.createElement('div'),
176				body     = doc.body,
177				fakeUsed = false;
178
179			div.style.cssText = "position:absolute;font-size:1em;width:1em";
180
181			if ( !body ){
182				body = fakeUsed = doc.createElement( "body" );
183				body.style.background = "none";
184			}
185
186			body.appendChild( div );
187
188			docElem.insertBefore( body, docElem.firstChild );
189
190			ret = div.offsetWidth;
191
192			if ( fakeUsed ){
193				docElem.removeChild( body );
194			}
195			else {
196				body.removeChild( div );
197			}
198
199			// Also update eminpx before returning
200			ret = eminpx = parseFloat(ret);
201
202			return ret;
203		},
204
205		// Cached container for 1em value, populated the first time it's needed
206		eminpx,
207
208		// Enable/disable styles
209		applyMedia          = function( fromResize ){
210			var name        = "clientWidth",
211				docElemProp = docElem[ name ],
212				currWidth   = doc.compatMode === "CSS1Compat" && docElemProp || doc.body[ name ] || docElemProp,
213				styleBlocks = {},
214				lastLink    = links[ links.length-1 ],
215				now         = (new Date()).getTime();
216
217			// Throttle resize calls
218			if ( fromResize && lastCall && now - lastCall < resizeThrottle ){
219				clearTimeout( resizeDefer );
220				resizeDefer = setTimeout( applyMedia, resizeThrottle );
221				return;
222			}
223			else {
224				lastCall = now;
225			}
226
227			for( var i in mediastyles ){
228				var thisstyle = mediastyles[ i ],
229					min = thisstyle.minw,
230					max = thisstyle.maxw,
231					minnull = min === null,
232					maxnull = max === null,
233					em = "em";
234
235				if ( !!min ){
236					min = parseFloat( min ) * ( min.indexOf( em ) > -1 ? ( eminpx || getEmValue() ) : 1 );
237				}
238				if ( !!max ){
239					max = parseFloat( max ) * ( max.indexOf( em ) > -1 ? ( eminpx || getEmValue() ) : 1 );
240				}
241
242				// If there's no media query at all (the () part), or min or max is not null, and if either is present, they're true
243				if ( !thisstyle.hasquery || ( !minnull || !maxnull ) && ( minnull || currWidth >= min ) && ( maxnull || currWidth <= max ) ){
244						if ( !styleBlocks[ thisstyle.media ] ){
245							styleBlocks[ thisstyle.media ] = [];
246						}
247						styleBlocks[ thisstyle.media ].push( rules[ thisstyle.rules ] );
248				}
249			}
250
251			// Remove any existing respond style element(s)
252			for( var i in appendedEls ){
253				if ( appendedEls[ i ] && appendedEls[ i ].parentNode === head ){
254					head.removeChild( appendedEls[ i ] );
255				}
256			}
257
258			// Inject active styles, grouped by media type
259			for( var i in styleBlocks ){
260				var ss  = doc.createElement( "style" ),
261					css = styleBlocks[ i ].join( "\n" );
262
263				ss.type  = "text/css";
264				ss.media = i;
265
266				// Originally, ss was appended to a documentFragment and sheets were appended in bulk.
267				// This caused crashes in IE in a number of circumstances, such as when the HTML element had a bg image set, so appending beforehand seems best. Thanks to @dvelyk for the initial research on this one!
268				head.insertBefore( ss, lastLink.nextSibling );
269
270				if ( ss.styleSheet ){
271					ss.styleSheet.cssText = css;
272				}
273				else{
274					ss.appendChild( doc.createTextNode( css ) );
275		        }
276
277				// Push to appendedEls to track for later removal
278				appendedEls.push( ss );
279			}
280		},
281		// Tweaked Ajax functions from Quirksmode
282		ajax = function( url, callback ) {
283			var req = xmlHttp();
284			if (!req){
285				return;
286			}
287			req.open( "GET", url, true );
288			req.onreadystatechange = function () {
289				if ( req.readyState != 4 || req.status != 200 && req.status != 304 ){
290					return;
291				}
292				callback( req.responseText );
293			}
294			if ( req.readyState == 4 ){
295				return;
296			}
297			req.send( null );
298		},
299		// Define ajax obj
300		xmlHttp = (function() {
301			var xmlhttpmethod = false;
302			try {
303				xmlhttpmethod = new XMLHttpRequest();
304			}
305			catch( e ){
306				xmlhttpmethod = new ActiveXObject( "Microsoft.XMLHTTP" );
307			}
308			return function(){
309				return xmlhttpmethod;
310			};
311		})();
312
313	// Translate CSS
314	ripCSS();
315
316	// Expose update for re-running respond later on
317	respond.update = ripCSS;
318
319	// Adjust on resize
320	function callMedia(){
321		applyMedia( true );
322	}
323	if ( win.addEventListener ){
324		win.addEventListener( "resize", callMedia, false );
325	}
326	else if( win.attachEvent ){
327		win.attachEvent( "onresize", callMedia );
328	}
329})(this);

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.