Code Duplication    Length = 106-107 lines in 2 locations

api/js/etemplate/test/jquery.js 1 location

@@ 4987-5093 (lines=107) @@
4984
	div = null;
4985
})();
4986
4987
if ( document.querySelectorAll ) {
4988
	(function(){
4989
		var oldSizzle = Sizzle,
4990
			div = document.createElement("div"),
4991
			id = "__sizzle__";
4992
4993
		div.innerHTML = "<p class='TEST'></p>";
4994
4995
		// Safari can't handle uppercase or unicode characters when
4996
		// in quirks mode.
4997
		if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
4998
			return;
4999
		}
5000
	
5001
		Sizzle = function( query, context, extra, seed ) {
5002
			context = context || document;
5003
5004
			// Only use querySelectorAll on non-XML documents
5005
			// (ID selectors don't work in non-HTML documents)
5006
			if ( !seed && !Sizzle.isXML(context) ) {
5007
				// See if we find a selector to speed up
5008
				var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
5009
				
5010
				if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
5011
					// Speed-up: Sizzle("TAG")
5012
					if ( match[1] ) {
5013
						return makeArray( context.getElementsByTagName( query ), extra );
5014
					
5015
					// Speed-up: Sizzle(".CLASS")
5016
					} else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
5017
						return makeArray( context.getElementsByClassName( match[2] ), extra );
5018
					}
5019
				}
5020
				
5021
				if ( context.nodeType === 9 ) {
5022
					// Speed-up: Sizzle("body")
5023
					// The body element only exists once, optimize finding it
5024
					if ( query === "body" && context.body ) {
5025
						return makeArray( [ context.body ], extra );
5026
						
5027
					// Speed-up: Sizzle("#ID")
5028
					} else if ( match && match[3] ) {
5029
						var elem = context.getElementById( match[3] );
5030
5031
						// Check parentNode to catch when Blackberry 4.6 returns
5032
						// nodes that are no longer in the document #6963
5033
						if ( elem && elem.parentNode ) {
5034
							// Handle the case where IE and Opera return items
5035
							// by name instead of ID
5036
							if ( elem.id === match[3] ) {
5037
								return makeArray( [ elem ], extra );
5038
							}
5039
							
5040
						} else {
5041
							return makeArray( [], extra );
5042
						}
5043
					}
5044
					
5045
					try {
5046
						return makeArray( context.querySelectorAll(query), extra );
5047
					} catch(qsaError) {}
5048
5049
				// qSA works strangely on Element-rooted queries
5050
				// We can work around this by specifying an extra ID on the root
5051
				// and working up from there (Thanks to Andrew Dupont for the technique)
5052
				// IE 8 doesn't work on object elements
5053
				} else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
5054
					var oldContext = context,
5055
						old = context.getAttribute( "id" ),
5056
						nid = old || id,
5057
						hasParent = context.parentNode,
5058
						relativeHierarchySelector = /^\s*[+~]/.test( query );
5059
5060
					if ( !old ) {
5061
						context.setAttribute( "id", nid );
5062
					} else {
5063
						nid = nid.replace( /'/g, "\\$&" );
5064
					}
5065
					if ( relativeHierarchySelector && hasParent ) {
5066
						context = context.parentNode;
5067
					}
5068
5069
					try {
5070
						if ( !relativeHierarchySelector || hasParent ) {
5071
							return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra );
5072
						}
5073
5074
					} catch(pseudoError) {
5075
					} finally {
5076
						if ( !old ) {
5077
							oldContext.removeAttribute( "id" );
5078
						}
5079
					}
5080
				}
5081
			}
5082
		
5083
			return oldSizzle(query, context, extra, seed);
5084
		};
5085
5086
		for ( var prop in oldSizzle ) {
5087
			Sizzle[ prop ] = oldSizzle[ prop ];
5088
		}
5089
5090
		// release memory in IE
5091
		div = null;
5092
	})();
5093
}
5094
5095
(function(){
5096
	var html = document.documentElement,

api/js/egw_action/test/js/jquery.js 1 location

@@ 4343-4448 (lines=106) @@
4340
	div = null;
4341
})();
4342
4343
if ( document.querySelectorAll ) {
4344
	(function(){
4345
		var oldSizzle = Sizzle,
4346
			div = document.createElement("div"),
4347
			id = "__sizzle__";
4348
4349
		div.innerHTML = "<p class='TEST'></p>";
4350
4351
		// Safari can't handle uppercase or unicode characters when
4352
		// in quirks mode.
4353
		if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
4354
			return;
4355
		}
4356
	
4357
		Sizzle = function( query, context, extra, seed ) {
4358
			context = context || document;
4359
4360
			// Only use querySelectorAll on non-XML documents
4361
			// (ID selectors don't work in non-HTML documents)
4362
			if ( !seed && !Sizzle.isXML(context) ) {
4363
				// See if we find a selector to speed up
4364
				var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
4365
				
4366
				if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
4367
					// Speed-up: Sizzle("TAG")
4368
					if ( match[1] ) {
4369
						return makeArray( context.getElementsByTagName( query ), extra );
4370
					
4371
					// Speed-up: Sizzle(".CLASS")
4372
					} else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
4373
						return makeArray( context.getElementsByClassName( match[2] ), extra );
4374
					}
4375
				}
4376
				
4377
				if ( context.nodeType === 9 ) {
4378
					// Speed-up: Sizzle("body")
4379
					// The body element only exists once, optimize finding it
4380
					if ( query === "body" && context.body ) {
4381
						return makeArray( [ context.body ], extra );
4382
						
4383
					// Speed-up: Sizzle("#ID")
4384
					} else if ( match && match[3] ) {
4385
						var elem = context.getElementById( match[3] );
4386
4387
						// Check parentNode to catch when Blackberry 4.6 returns
4388
						// nodes that are no longer in the document #6963
4389
						if ( elem && elem.parentNode ) {
4390
							// Handle the case where IE and Opera return items
4391
							// by name instead of ID
4392
							if ( elem.id === match[3] ) {
4393
								return makeArray( [ elem ], extra );
4394
							}
4395
							
4396
						} else {
4397
							return makeArray( [], extra );
4398
						}
4399
					}
4400
					
4401
					try {
4402
						return makeArray( context.querySelectorAll(query), extra );
4403
					} catch(qsaError) {}
4404
4405
				// qSA works strangely on Element-rooted queries
4406
				// We can work around this by specifying an extra ID on the root
4407
				// and working up from there (Thanks to Andrew Dupont for the technique)
4408
				// IE 8 doesn't work on object elements
4409
				} else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
4410
					var old = context.getAttribute( "id" ),
4411
						nid = old || id,
4412
						hasParent = context.parentNode,
4413
						relativeHierarchySelector = /^\s*[+~]/.test( query );
4414
4415
					if ( !old ) {
4416
						context.setAttribute( "id", nid );
4417
					} else {
4418
						nid = nid.replace( /'/g, "\\$&" );
4419
					}
4420
					if ( relativeHierarchySelector && hasParent ) {
4421
						context = context.parentNode;
4422
					}
4423
4424
					try {
4425
						if ( !relativeHierarchySelector || hasParent ) {
4426
							return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra );
4427
						}
4428
4429
					} catch(pseudoError) {
4430
					} finally {
4431
						if ( !old ) {
4432
							context.removeAttribute( "id" );
4433
						}
4434
					}
4435
				}
4436
			}
4437
		
4438
			return oldSizzle(query, context, extra, seed);
4439
		};
4440
4441
		for ( var prop in oldSizzle ) {
4442
			Sizzle[ prop ] = oldSizzle[ prop ];
4443
		}
4444
4445
		// release memory in IE
4446
		div = null;
4447
	})();
4448
}
4449
4450
(function(){
4451
	var html = document.documentElement,