aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Resig <jeresig@gmail.com>2009-12-10 09:25:25 -0800
committerJohn Resig <jeresig@gmail.com>2009-12-10 09:25:25 -0800
commit474d814076963f41157c0054448984c00fd46c1b (patch)
tree2e47537901b20566181ff5837e5521ac7b6bbe6a /src
parentede2f2c4f76aba3c0a279d8ca26e8176942cd83f (diff)
downloadjquery-474d814076963f41157c0054448984c00fd46c1b.tar.gz
jquery-474d814076963f41157c0054448984c00fd46c1b.zip
Moved some methods around inbetween core.js and traversing.js. Core methods shouldn't rely upon other modules (e.g. the selector engine) wherever possible.
Diffstat (limited to 'src')
-rw-r--r--src/core.js48
-rw-r--r--src/traversing.js48
2 files changed, 48 insertions, 48 deletions
diff --git a/src/core.js b/src/core.js
index 6e41eb9f4..756117c09 100644
--- a/src/core.js
+++ b/src/core.js
@@ -210,25 +210,6 @@ jQuery.fn = jQuery.prototype = {
each: function( callback, args ) {
return jQuery.each( this, callback, args );
},
-
- // Determine the position of an element within
- // the matched set of elements
- index: function( elem ) {
- if ( !elem || typeof elem === "string" ) {
- return jQuery.inArray( this[0],
- // If it receives a string, the selector is used
- // If it receives nothing, the siblings are used
- elem ? jQuery( elem ) : this.parent().children() );
- }
- // Locate the position of the desired element
- return jQuery.inArray(
- // If it receives a jQuery object, the first element is used
- elem.jquery ? elem[0] : elem, this );
- },
-
- is: function( selector ) {
- return !!selector && jQuery.filter( selector, this ).length > 0;
- },
ready: function( fn ) {
// Attach the listeners
@@ -247,6 +228,35 @@ jQuery.fn = jQuery.prototype = {
return this;
},
+
+ eq: function( i ) {
+ return i === -1 ?
+ this.slice( i ) :
+ this.slice( i, +i + 1 );
+ },
+
+ first: function() {
+ return this.eq( 0 );
+ },
+
+ last: function() {
+ return this.eq( -1 );
+ },
+
+ slice: function() {
+ return this.pushStack( slice.apply( this, arguments ),
+ "slice", slice.call(arguments).join(",") );
+ },
+
+ map: function( callback ) {
+ return this.pushStack( jQuery.map(this, function(elem, i){
+ return callback.call( elem, i, elem );
+ }));
+ },
+
+ end: function() {
+ return this.prevObject || jQuery(null);
+ },
// For internal use only.
// Behaves like an Array's method, not like a jQuery method.
diff --git a/src/traversing.js b/src/traversing.js
index 942138c37..6375d9d1f 100644
--- a/src/traversing.js
+++ b/src/traversing.js
@@ -79,6 +79,10 @@ jQuery.fn.extend({
filter: function( selector ) {
return this.pushStack( winnow(this, selector, true), "filter", selector );
},
+
+ is: function( selector ) {
+ return !!selector && jQuery.filter( selector, this ).length > 0;
+ },
closest: function( selectors, context ) {
if ( jQuery.isArray( selectors ) ) {
@@ -124,6 +128,21 @@ jQuery.fn.extend({
return null;
});
},
+
+ // Determine the position of an element within
+ // the matched set of elements
+ index: function( elem ) {
+ if ( !elem || typeof elem === "string" ) {
+ return jQuery.inArray( this[0],
+ // If it receives a string, the selector is used
+ // If it receives nothing, the siblings are used
+ elem ? jQuery( elem ) : this.parent().children() );
+ }
+ // Locate the position of the desired element
+ return jQuery.inArray(
+ // If it receives a jQuery object, the first element is used
+ elem.jquery ? elem[0] : elem, this );
+ },
add: function( selector, context ) {
var set = typeof selector === "string" ?
@@ -136,37 +155,8 @@ jQuery.fn.extend({
all );
},
- eq: function( i ) {
- return i === -1 ?
- this.slice( i ) :
- this.slice( i, +i + 1 );
- },
-
- first: function() {
- return this.eq( 0 );
- },
-
- last: function() {
- return this.eq( -1 );
- },
-
- slice: function() {
- return this.pushStack( slice.apply( this, arguments ),
- "slice", slice.call(arguments).join(",") );
- },
-
- map: function( callback ) {
- return this.pushStack( jQuery.map(this, function(elem, i){
- return callback.call( elem, i, elem );
- }));
- },
-
andSelf: function() {
return this.add( this.prevObject );
- },
-
- end: function() {
- return this.prevObject || jQuery(null);
}
});