Code Duplication    Length = 103-109 lines in 2 locations

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

@@ 99-207 (lines=109) @@
96
97
jQuery.fn = jQuery.prototype = {
98
	constructor: jQuery,
99
	init: function( selector, context, rootjQuery ) {
100
		var match, elem, ret, doc;
101
102
		// Handle $(""), $(null), or $(undefined)
103
		if ( !selector ) {
104
			return this;
105
		}
106
107
		// Handle $(DOMElement)
108
		if ( selector.nodeType ) {
109
			this.context = this[0] = selector;
110
			this.length = 1;
111
			return this;
112
		}
113
114
		// The body element only exists once, optimize finding it
115
		if ( selector === "body" && !context && document.body ) {
116
			this.context = document;
117
			this[0] = document.body;
118
			this.selector = selector;
119
			this.length = 1;
120
			return this;
121
		}
122
123
		// Handle HTML strings
124
		if ( typeof selector === "string" ) {
125
			// Are we dealing with HTML string or an ID?
126
			if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
127
				// Assume that strings that start and end with <> are HTML and skip the regex check
128
				match = [ null, selector, null ];
129
130
			} else {
131
				match = quickExpr.exec( selector );
132
			}
133
134
			// Verify a match, and that no context was specified for #id
135
			if ( match && (match[1] || !context) ) {
136
137
				// HANDLE: $(html) -> $(array)
138
				if ( match[1] ) {
139
					context = context instanceof jQuery ? context[0] : context;
140
					doc = ( context ? context.ownerDocument || context : document );
141
142
					// If a single string is passed in and it's a single tag
143
					// just do a createElement and skip the rest
144
					ret = rsingleTag.exec( selector );
145
146
					if ( ret ) {
147
						if ( jQuery.isPlainObject( context ) ) {
148
							selector = [ document.createElement( ret[1] ) ];
149
							jQuery.fn.attr.call( selector, context, true );
150
151
						} else {
152
							selector = [ doc.createElement( ret[1] ) ];
153
						}
154
155
					} else {
156
						ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
157
						selector = ( ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment ).childNodes;
158
					}
159
160
					return jQuery.merge( this, selector );
161
162
				// HANDLE: $("#id")
163
				} else {
164
					elem = document.getElementById( match[2] );
165
166
					// Check parentNode to catch when Blackberry 4.6 returns
167
					// nodes that are no longer in the document #6963
168
					if ( elem && elem.parentNode ) {
169
						// Handle the case where IE and Opera return items
170
						// by name instead of ID
171
						if ( elem.id !== match[2] ) {
172
							return rootjQuery.find( selector );
173
						}
174
175
						// Otherwise, we inject the element directly into the jQuery object
176
						this.length = 1;
177
						this[0] = elem;
178
					}
179
180
					this.context = document;
181
					this.selector = selector;
182
					return this;
183
				}
184
185
			// HANDLE: $(expr, $(...))
186
			} else if ( !context || context.jquery ) {
187
				return ( context || rootjQuery ).find( selector );
188
189
			// HANDLE: $(expr, context)
190
			// (which is just equivalent to: $(context).find(expr)
191
			} else {
192
				return this.constructor( context ).find( selector );
193
			}
194
195
		// HANDLE: $(function)
196
		// Shortcut for document ready
197
		} else if ( jQuery.isFunction( selector ) ) {
198
			return rootjQuery.ready( selector );
199
		}
200
201
		if ( selector.selector !== undefined ) {
202
			this.selector = selector.selector;
203
			this.context = selector.context;
204
		}
205
206
		return jQuery.makeArray( selector, this );
207
	},
208
209
	// Start with an empty selector
210
	selector: "",

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

@@ 97-199 (lines=103) @@
94
95
jQuery.fn = jQuery.prototype = {
96
	constructor: jQuery,
97
	init: function( selector, context, rootjQuery ) {
98
		var match, elem, ret, doc;
99
100
		// Handle $(""), $(null), or $(undefined)
101
		if ( !selector ) {
102
			return this;
103
		}
104
105
		// Handle $(DOMElement)
106
		if ( selector.nodeType ) {
107
			this.context = this[0] = selector;
108
			this.length = 1;
109
			return this;
110
		}
111
112
		// The body element only exists once, optimize finding it
113
		if ( selector === "body" && !context && document.body ) {
114
			this.context = document;
115
			this[0] = document.body;
116
			this.selector = "body";
117
			this.length = 1;
118
			return this;
119
		}
120
121
		// Handle HTML strings
122
		if ( typeof selector === "string" ) {
123
			// Are we dealing with HTML string or an ID?
124
			match = quickExpr.exec( selector );
125
126
			// Verify a match, and that no context was specified for #id
127
			if ( match && (match[1] || !context) ) {
128
129
				// HANDLE: $(html) -> $(array)
130
				if ( match[1] ) {
131
					context = context instanceof jQuery ? context[0] : context;
132
					doc = (context ? context.ownerDocument || context : document);
133
134
					// If a single string is passed in and it's a single tag
135
					// just do a createElement and skip the rest
136
					ret = rsingleTag.exec( selector );
137
138
					if ( ret ) {
139
						if ( jQuery.isPlainObject( context ) ) {
140
							selector = [ document.createElement( ret[1] ) ];
141
							jQuery.fn.attr.call( selector, context, true );
142
143
						} else {
144
							selector = [ doc.createElement( ret[1] ) ];
145
						}
146
147
					} else {
148
						ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
149
						selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes;
150
					}
151
152
					return jQuery.merge( this, selector );
153
154
				// HANDLE: $("#id")
155
				} else {
156
					elem = document.getElementById( match[2] );
157
158
					// Check parentNode to catch when Blackberry 4.6 returns
159
					// nodes that are no longer in the document #6963
160
					if ( elem && elem.parentNode ) {
161
						// Handle the case where IE and Opera return items
162
						// by name instead of ID
163
						if ( elem.id !== match[2] ) {
164
							return rootjQuery.find( selector );
165
						}
166
167
						// Otherwise, we inject the element directly into the jQuery object
168
						this.length = 1;
169
						this[0] = elem;
170
					}
171
172
					this.context = document;
173
					this.selector = selector;
174
					return this;
175
				}
176
177
			// HANDLE: $(expr, $(...))
178
			} else if ( !context || context.jquery ) {
179
				return (context || rootjQuery).find( selector );
180
181
			// HANDLE: $(expr, context)
182
			// (which is just equivalent to: $(context).find(expr)
183
			} else {
184
				return this.constructor( context ).find( selector );
185
			}
186
187
		// HANDLE: $(function)
188
		// Shortcut for document ready
189
		} else if ( jQuery.isFunction( selector ) ) {
190
			return rootjQuery.ready( selector );
191
		}
192
193
		if (selector.selector !== undefined) {
194
			this.selector = selector.selector;
195
			this.context = selector.context;
196
		}
197
198
		return jQuery.makeArray( selector, this );
199
	},
200
201
	// Start with an empty selector
202
	selector: "",