Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
ccf9d440
Commit
ccf9d440
authored
Aug 24, 2006
by
John Resig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed some bugs, improved the quality of some of the variables.
parent
874e4f65
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
56 deletions
+69
-56
doc.js
build/docs/js/doc.js
+1
-1
fx.js
src/fx/fx.js
+2
-1
jquery.js
src/jquery/jquery.js
+66
-54
No files found.
build/docs/js/doc.js
View file @
ccf9d440
...
@@ -17,7 +17,7 @@ $(document).ready(function(){
...
@@ -17,7 +17,7 @@ $(document).ready(function(){
}).
ToolTipDemo
(
'#fff'
);
}).
ToolTipDemo
(
'#fff'
);
$
(
"a.name"
).
click
(
function
(){
$
(
"a.name"
).
click
(
function
(){
$
(
"div.more,div.short"
,
this
.
parentNode
.
parentNode
).
toggle
().
find
(
"div.desc"
,
function
(){
$
(
"div.more,div.short"
,
this
.
parentNode
.
parentNode
).
toggle
(
'slow'
).
find
(
"div.desc"
,
function
(){
$
(
this
).
html
(
$
(
this
).
html
().
replace
(
/
\n\n
/g
,
"<br/><br/>"
)
);
$
(
this
).
html
(
$
(
this
).
html
().
replace
(
/
\n\n
/g
,
"<br/><br/>"
)
);
});
});
return
false
;
return
false
;
...
...
src/fx/fx.js
View file @
ccf9d440
...
@@ -485,7 +485,8 @@ jQuery.extend({
...
@@ -485,7 +485,8 @@ jQuery.extend({
z
.
el
.
orig
[
prop
]
+
"px"
:
z
.
el
.
orig
[
prop
];
z
.
el
.
orig
[
prop
]
+
"px"
:
z
.
el
.
orig
[
prop
];
// set its height and/or width to auto
// set its height and/or width to auto
jQuery
.
setAuto
(
z
.
el
,
prop
);
if
(
prop
==
'height'
||
prop
==
'width'
)
jQuery
.
setAuto
(
z
.
el
,
prop
);
// If a callback was provided, execute it
// If a callback was provided, execute it
if
(
z
.
o
.
complete
&&
z
.
o
.
complete
.
constructor
==
Function
)
if
(
z
.
o
.
complete
&&
z
.
o
.
complete
.
constructor
==
Function
)
...
...
src/jquery/jquery.js
View file @
ccf9d440
...
@@ -232,6 +232,14 @@ jQuery.fn = jQuery.prototype = {
...
@@ -232,6 +232,14 @@ jQuery.fn = jQuery.prototype = {
each
:
function
(
fn
,
args
)
{
each
:
function
(
fn
,
args
)
{
return
jQuery
.
each
(
this
,
fn
,
args
);
return
jQuery
.
each
(
this
,
fn
,
args
);
},
},
index
:
function
(
obj
)
{
var
pos
=
-
1
;
this
.
each
(
function
(
i
){
if
(
this
==
obj
)
pos
=
i
;
});
return
pos
;
},
/**
/**
* Access a property on the first matched element.
* Access a property on the first matched element.
...
@@ -895,7 +903,7 @@ jQuery.extend({
...
@@ -895,7 +903,7 @@ jQuery.extend({
new
RegExp
(
"(^|
\\
s*
\\
b[^-])"
+
c
+
"($|
\\
b(?=[^-]))"
,
"g"
),
""
);
new
RegExp
(
"(^|
\\
s*
\\
b[^-])"
+
c
+
"($|
\\
b(?=[^-]))"
,
"g"
),
""
);
},
},
has
:
function
(
e
,
a
)
{
has
:
function
(
e
,
a
)
{
if
(
e
.
className
)
if
(
e
.
className
!=
undefined
)
e
=
e
.
className
;
e
=
e
.
className
;
return
new
RegExp
(
"(^|
\\
s)"
+
a
+
"(
\\
s|$)"
).
test
(
e
);
return
new
RegExp
(
"(^|
\\
s)"
+
a
+
"(
\\
s|$)"
).
test
(
e
);
}
}
...
@@ -1364,14 +1372,14 @@ jQuery.extend({
...
@@ -1364,14 +1372,14 @@ jQuery.extend({
* @type Array<Element>
* @type Array<Element>
* @param Element elem The element to find the ancestors of.
* @param Element elem The element to find the ancestors of.
*/
*/
parents
:
function
(
a
){
parents
:
function
(
elem
){
var
b
=
[];
var
matched
=
[];
var
c
=
a
.
parentNode
;
var
c
ur
=
elem
.
parentNode
;
while
(
c
&&
c
!=
document
)
{
while
(
c
ur
&&
cur
!=
document
)
{
b
.
push
(
c
);
matched
.
push
(
cur
);
c
=
c
.
parentNode
;
c
ur
=
cur
.
parentNode
;
}
}
return
b
;
return
matched
;
},
},
/**
/**
...
@@ -1382,23 +1390,25 @@ jQuery.extend({
...
@@ -1382,23 +1390,25 @@ jQuery.extend({
* @type Array
* @type Array
* @param Element elem The element to find all the siblings of (including itself).
* @param Element elem The element to find all the siblings of (including itself).
*/
*/
sibling
:
function
(
a
,
n
)
{
sibling
:
function
(
elem
,
pos
,
not
)
{
var
type
=
[];
var
elems
=
[];
var
tmp
=
a
.
parentNode
.
childNodes
;
for
(
var
i
=
0
;
i
<
tmp
.
length
;
i
++
)
{
var
siblings
=
elem
.
parentNode
.
childNodes
;
if
(
tmp
[
i
].
nodeType
==
1
)
for
(
var
i
=
0
;
i
<
siblings
.
length
;
i
++
)
{
type
.
push
(
tmp
[
i
]
);
if
(
not
===
true
&&
siblings
[
i
]
==
elem
)
continue
;
if
(
tmp
[
i
]
==
a
)
type
.
n
=
type
.
length
-
1
;
if
(
siblings
[
i
].
nodeType
==
1
)
elems
.
push
(
siblings
[
i
]
);
if
(
siblings
[
i
]
==
elem
)
elems
.
n
=
elems
.
length
-
1
;
}
}
type
.
last
=
type
.
n
==
type
.
length
-
1
;
type
.
cur
=
return
jQuery
.
extend
(
elems
,
{
n
==
"even"
&&
type
.
n
%
2
==
0
||
last
:
elems
.
n
==
elems
.
length
-
1
,
n
==
"odd"
&&
type
.
n
%
2
||
cur
:
n
==
"even"
&&
elems
.
n
%
2
==
0
||
n
==
"odd"
&&
elems
.
n
%
2
||
elems
[
pos
]
==
a
,
type
[
n
]
==
a
;
prev
:
elems
[
elems
.
n
-
1
],
type
.
prev
=
type
[
type
.
n
-
1
];
next
:
elems
[
elems
.
n
+
1
]
type
.
next
=
type
[
type
.
n
+
1
];
});
return
type
;
},
},
/**
/**
...
@@ -1410,30 +1420,30 @@ jQuery.extend({
...
@@ -1410,30 +1420,30 @@ jQuery.extend({
* @param Array a The first array to merge.
* @param Array a The first array to merge.
* @param Array b The second array to merge.
* @param Array b The second array to merge.
*/
*/
merge
:
function
(
a
,
b
)
{
merge
:
function
(
first
,
second
)
{
var
d
=
[];
var
result
=
[];
// Move b over to the new array (this helps to avoid
// Move b over to the new array (this helps to avoid
// StaticNodeList instances)
// StaticNodeList instances)
for
(
var
k
=
0
;
k
<
a
.
length
;
k
++
)
for
(
var
k
=
0
;
k
<
first
.
length
;
k
++
)
d
[
k
]
=
a
[
k
];
result
[
k
]
=
second
[
k
];
// Now check for duplicates between a and b and only
// Now check for duplicates between a and b and only
// add the unique items
// add the unique items
for
(
var
i
=
0
;
i
<
b
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
second
.
length
;
i
++
)
{
var
c
=
true
;
var
noCollision
=
true
;
// The collision-checking process
// The collision-checking process
for
(
var
j
=
0
;
j
<
a
.
length
;
j
++
)
for
(
var
j
=
0
;
j
<
first
.
length
;
j
++
)
if
(
b
[
i
]
==
a
[
j
]
)
if
(
second
[
i
]
==
first
[
j
]
)
c
=
false
;
noCollision
=
false
;
// If the item is unique, add it
// If the item is unique, add it
if
(
c
)
if
(
noCollision
)
d
.
push
(
b
[
i
]
);
result
.
push
(
second
[
i
]
);
}
}
return
d
;
return
result
;
},
},
/**
/**
...
@@ -1448,21 +1458,21 @@ jQuery.extend({
...
@@ -1448,21 +1458,21 @@ jQuery.extend({
* @param Function fn The function to process each item against.
* @param Function fn The function to process each item against.
* @param Boolean inv Invert the selection - select the opposite of the function.
* @param Boolean inv Invert the selection - select the opposite of the function.
*/
*/
grep
:
function
(
a
,
f
,
s
)
{
grep
:
function
(
elems
,
fn
,
inv
)
{
// If a string is passed in for the function, make a function
// If a string is passed in for the function, make a function
// for it (a handy shortcut)
// for it (a handy shortcut)
if
(
f
.
constructor
==
String
)
if
(
f
n
.
constructor
==
String
)
f
=
new
Function
(
"a"
,
"i"
,
"return "
+
f
);
f
n
=
new
Function
(
"a"
,
"i"
,
"return "
+
fn
);
var
r
=
[];
var
r
esult
=
[];
// Go through the array, only saving the items
// Go through the array, only saving the items
// that pass the validator function
// that pass the validator function
for
(
var
i
=
0
;
i
<
a
.
length
;
i
++
)
for
(
var
i
=
0
;
i
<
elems
.
length
;
i
++
)
if
(
!
s
&&
f
(
a
[
i
],
i
)
||
s
&&
!
f
(
a
[
i
],
i
)
)
if
(
!
inv
&&
fn
(
elems
[
i
],
i
)
||
inv
&&
!
fn
(
elems
[
i
],
i
)
)
r
.
push
(
a
[
i
]
);
r
esult
.
push
(
elems
[
i
]
);
return
r
;
return
r
esult
;
},
},
/**
/**
...
@@ -1479,24 +1489,26 @@ jQuery.extend({
...
@@ -1479,24 +1489,26 @@ jQuery.extend({
* @param Array array The Array to translate.
* @param Array array The Array to translate.
* @param Function fn The function to process each item against.
* @param Function fn The function to process each item against.
*/
*/
map
:
function
(
a
,
f
)
{
map
:
function
(
elems
,
fn
)
{
// If a string is passed in for the function, make a function
// If a string is passed in for the function, make a function
// for it (a handy shortcut)
// for it (a handy shortcut)
if
(
f
.
constructor
==
String
)
if
(
f
n
.
constructor
==
String
)
f
=
new
Function
(
"a"
,
"return "
+
f
);
f
n
=
new
Function
(
"a"
,
"return "
+
fn
);
var
r
=
[];
var
r
esult
=
[];
// Go through the array, translating each of the items to their
// Go through the array, translating each of the items to their
// new value (or values).
// new value (or values).
for
(
var
i
=
0
;
i
<
a
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
elems
.
length
;
i
++
)
{
var
t
=
f
(
a
[
i
],
i
);
var
val
=
fn
(
elems
[
i
],
i
);
if
(
t
!==
null
&&
t
!=
undefined
)
{
if
(
t
.
constructor
!=
Array
)
t
=
[
t
];
if
(
val
!==
null
&&
val
!=
undefined
)
{
r
=
jQuery
.
merge
(
r
,
t
);
if
(
val
.
constructor
!=
Array
)
val
=
[
val
];
result
=
jQuery
.
merge
(
result
,
val
);
}
}
}
}
return
r
;
return
result
;
},
},
/*
/*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment