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
48ec1004
Commit
48ec1004
authored
Aug 26, 2006
by
John Resig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added in a bunch of fx fixes - and hide/show/toggle are decoupled from later methods.
parent
a2af24b0
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
64 deletions
+60
-64
event.js
src/event/event.js
+3
-3
fx.js
src/fx/fx.js
+37
-25
jquery.js
src/jquery/jquery.js
+20
-36
No files found.
src/event/event.js
View file @
48ec1004
...
@@ -2,7 +2,7 @@ jQuery.fn.extend({
...
@@ -2,7 +2,7 @@ jQuery.fn.extend({
// We're overriding the old toggle function, so
// We're overriding the old toggle function, so
// remember it for later
// remember it for later
//
_toggle: jQuery.fn.toggle,
_toggle
:
jQuery
.
fn
.
toggle
,
/**
/**
* Toggle between two function calls every other click.
* Toggle between two function calls every other click.
...
@@ -25,7 +25,7 @@ jQuery.fn.extend({
...
@@ -25,7 +25,7 @@ jQuery.fn.extend({
toggle
:
function
(
a
,
b
)
{
toggle
:
function
(
a
,
b
)
{
// If two functions are passed in, we're
// If two functions are passed in, we're
// toggling on a click
// toggling on a click
return
a
&&
b
?
this
.
click
(
function
(
e
){
return
a
&&
b
&&
a
.
constructor
==
Function
&&
b
.
constructor
==
Function
?
this
.
click
(
function
(
e
){
// Figure out which function to execute
// Figure out which function to execute
this
.
last
=
this
.
last
==
a
?
b
:
a
;
this
.
last
=
this
.
last
==
a
?
b
:
a
;
...
@@ -37,7 +37,7 @@ jQuery.fn.extend({
...
@@ -37,7 +37,7 @@ jQuery.fn.extend({
})
:
})
:
// Otherwise, execute the old toggle function
// Otherwise, execute the old toggle function
this
.
_toggle
(
);
this
.
_toggle
.
apply
(
this
,
arguments
);
},
},
/**
/**
...
...
src/fx/fx.js
View file @
48ec1004
jQuery
.
fn
.
extend
({
jQuery
.
fn
.
extend
({
// overwrite the old show method
// overwrite the old show method
//
_show: jQuery.fn.show,
_show
:
jQuery
.
fn
.
show
,
/**
/**
* Show all matched elements using a graceful animation.
* Show all matched elements using a graceful animation.
...
@@ -39,7 +39,7 @@ jQuery.fn.extend({
...
@@ -39,7 +39,7 @@ jQuery.fn.extend({
},
},
// Overwrite the old hide method
// Overwrite the old hide method
//
_hide: jQuery.fn.hide,
_hide
:
jQuery
.
fn
.
hide
,
/**
/**
* Hide all matched elements using a graceful animation.
* Hide all matched elements using a graceful animation.
...
@@ -261,14 +261,17 @@ jQuery.fn.extend({
...
@@ -261,14 +261,17 @@ jQuery.fn.extend({
*/
*/
animate
:
function
(
prop
,
speed
,
callback
)
{
animate
:
function
(
prop
,
speed
,
callback
)
{
return
this
.
queue
(
function
(){
return
this
.
queue
(
function
(){
var
i
=
0
;
this
.
curAnim
=
prop
;
for
(
var
p
in
prop
)
{
for
(
var
p
in
prop
)
{
var
e
=
new
jQuery
.
fx
(
this
,
jQuery
.
speed
(
speed
,
callback
,
i
++
),
p
);
var
e
=
new
jQuery
.
fx
(
this
,
jQuery
.
speed
(
speed
,
callback
),
p
);
if
(
prop
[
p
].
constructor
==
Number
)
if
(
prop
[
p
].
constructor
==
Number
)
e
.
custom
(
e
.
cur
(),
prop
[
p
]
);
e
.
custom
(
e
.
cur
(),
prop
[
p
]
);
else
else
e
[
prop
[
p
]
](
prop
);
e
[
prop
[
p
]
](
prop
);
}
}
});
});
},
},
...
@@ -328,7 +331,7 @@ jQuery.extend({
...
@@ -328,7 +331,7 @@ jQuery.extend({
}
}
},
},
speed
:
function
(
s
,
o
,
i
)
{
speed
:
function
(
s
,
o
)
{
o
=
o
||
{};
o
=
o
||
{};
if
(
o
.
constructor
==
Function
)
if
(
o
.
constructor
==
Function
)
...
@@ -345,9 +348,6 @@ jQuery.extend({
...
@@ -345,9 +348,6 @@ jQuery.extend({
o
.
oldComplete
.
apply
(
this
);
o
.
oldComplete
.
apply
(
this
);
};
};
if
(
i
>
0
)
o
.
complete
=
null
;
return
o
;
return
o
;
},
},
...
@@ -405,6 +405,7 @@ jQuery.extend({
...
@@ -405,6 +405,7 @@ jQuery.extend({
// My hate for IE will never die
// My hate for IE will never die
}
else
if
(
parseInt
(
z
.
now
)
)
}
else
if
(
parseInt
(
z
.
now
)
)
y
[
prop
]
=
parseInt
(
z
.
now
)
+
"px"
;
y
[
prop
]
=
parseInt
(
z
.
now
)
+
"px"
;
y
.
display
=
"block"
;
y
.
display
=
"block"
;
};
};
...
@@ -454,7 +455,7 @@ jQuery.extend({
...
@@ -454,7 +455,7 @@ jQuery.extend({
z
.
o
.
hide
=
true
;
z
.
o
.
hide
=
true
;
// Begin the animation
// Begin the animation
z
.
custom
(
z
.
cur
(),
0
);
z
.
custom
(
z
.
el
.
orig
[
prop
],
0
);
};
};
// IE has trouble with opacity if it does not have layout
// IE has trouble with opacity if it does not have layout
...
@@ -466,7 +467,6 @@ jQuery.extend({
...
@@ -466,7 +467,6 @@ jQuery.extend({
z
.
el
.
oldOverflow
=
jQuery
.
css
(
z
.
el
,
"overflow"
);
z
.
el
.
oldOverflow
=
jQuery
.
css
(
z
.
el
,
"overflow"
);
// Make sure that nothing sneaks out
// Make sure that nothing sneaks out
//if ( z.el.oldOverlay == "visible" )
y
.
overflow
=
"hidden"
;
y
.
overflow
=
"hidden"
;
// Each step of an animation
// Each step of an animation
...
@@ -481,23 +481,35 @@ jQuery.extend({
...
@@ -481,23 +481,35 @@ jQuery.extend({
z
.
now
=
lastNum
;
z
.
now
=
lastNum
;
z
.
a
();
z
.
a
();
// Hide the element if the "hide" operation was done
z
.
el
.
curAnim
[
prop
]
=
true
;
if
(
z
.
o
.
hide
)
y
.
display
=
'none'
;
var
done
=
true
;
for
(
var
i
in
z
.
el
.
curAnim
)
if
(
z
.
el
.
curAnim
[
i
]
!==
true
)
done
=
false
;
if
(
done
)
{
// Reset the overflow
// Reset the overflow
y
.
overflow
=
z
.
el
.
oldOverflow
;
y
.
overflow
=
z
.
el
.
oldOverflow
;
// Reset the property, if the item has been hidden
// Hide the element if the "hide" operation was done
if
(
z
.
o
.
hide
)
if
(
z
.
o
.
hide
)
y
[
prop
]
=
z
.
el
.
orig
[
prop
].
constructor
==
Number
&&
prop
!=
"opacity"
?
y
.
display
=
'none'
;
z
.
el
.
orig
[
prop
]
+
"px"
:
z
.
el
.
orig
[
prop
];
// Reset the property, if the item has been hidden
if
(
z
.
o
.
hide
)
{
for
(
var
p
in
z
.
el
.
curAnim
)
{
y
[
p
]
=
z
.
el
.
orig
[
p
]
+
(
p
==
"opacity"
?
""
:
"px"
);
// set its height and/or width to auto
// set its height and/or width to auto
if
(
prop
==
'height'
||
prop
==
'width'
)
if
(
p
==
'height'
||
p
==
'width'
)
jQuery
.
setAuto
(
z
.
el
,
prop
);
jQuery
.
setAuto
(
z
.
el
,
p
);
}
}
}
// If a callback was provided, execute it
// If a callback was provided, execute it
if
(
z
.
o
.
complete
&&
z
.
o
.
complete
.
constructor
==
Function
)
if
(
done
&&
z
.
o
.
complete
&&
z
.
o
.
complete
.
constructor
==
Function
)
// Execute the complete function
// Execute the complete function
z
.
o
.
complete
.
apply
(
z
.
el
);
z
.
o
.
complete
.
apply
(
z
.
el
);
}
else
{
}
else
{
...
...
src/jquery/jquery.js
View file @
48ec1004
...
@@ -29,9 +29,6 @@ window.undefined = window.undefined;
...
@@ -29,9 +29,6 @@ window.undefined = window.undefined;
*/
*/
function
jQuery
(
a
,
c
)
{
function
jQuery
(
a
,
c
)
{
// Initalize the extra macro functions
if
(
!
jQuery
.
initDone
)
jQuery
.
init
();
// Shortcut for document ready (because $(document).each() is silly)
// Shortcut for document ready (because $(document).each() is silly)
if
(
a
&&
a
.
constructor
==
Function
&&
jQuery
.
fn
.
ready
)
if
(
a
&&
a
.
constructor
==
Function
&&
jQuery
.
fn
.
ready
)
return
jQuery
(
document
).
ready
(
a
);
return
jQuery
(
document
).
ready
(
a
);
...
@@ -39,25 +36,6 @@ function jQuery(a,c) {
...
@@ -39,25 +36,6 @@ function jQuery(a,c) {
// Make sure that a selection was provided
// Make sure that a selection was provided
a
=
a
||
jQuery
.
context
||
document
;
a
=
a
||
jQuery
.
context
||
document
;
/*
* Handle support for overriding other $() functions. Way too many libraries
* provide this function to simply ignore it and overwrite it.
*/
/*
// Check to see if this is a possible collision case
if ( jQuery._$ && !c && a.constructor == String &&
// Make sure that the expression is a colliding one
!/[^a-zA-Z0-9_-]/.test(a) &&
// and that there are no elements that match it
// (this is the one truly ambiguous case)
!document.getElementsByTagName(a).length )
// Use the default method, in case it works some voodoo
return jQuery._$( a );
*/
// Watch for when a jQuery object is passed as the selector
// Watch for when a jQuery object is passed as the selector
if
(
a
.
jquery
)
if
(
a
.
jquery
)
return
$
(
jQuery
.
merge
(
a
,
[]
)
);
return
$
(
jQuery
.
merge
(
a
,
[]
)
);
...
@@ -82,7 +60,10 @@ function jQuery(a,c) {
...
@@ -82,7 +60,10 @@ function jQuery(a,c) {
// Find the matching elements and save them for later
// Find the matching elements and save them for later
jQuery
.
find
(
a
,
c
)
);
jQuery
.
find
(
a
,
c
)
);
// See if an extra function was provided
var
fn
=
arguments
[
arguments
.
length
-
1
];
var
fn
=
arguments
[
arguments
.
length
-
1
];
// If so, execute it in context
if
(
fn
&&
fn
.
constructor
==
Function
)
if
(
fn
&&
fn
.
constructor
==
Function
)
this
.
each
(
fn
);
this
.
each
(
fn
);
}
}
...
@@ -811,8 +792,6 @@ jQuery.extend = jQuery.fn.extend = function(obj,prop) {
...
@@ -811,8 +792,6 @@ jQuery.extend = jQuery.fn.extend = function(obj,prop) {
jQuery
.
extend
({
jQuery
.
extend
({
/**
/**
*
*
* @private
* @private
* @name init
* @name init
* @type undefined
* @type undefined
...
@@ -934,12 +913,16 @@ jQuery.extend({
...
@@ -934,12 +913,16 @@ jQuery.extend({
if
(
jQuery
.
css
(
e
,
"display"
)
!=
"none"
)
{
if
(
jQuery
.
css
(
e
,
"display"
)
!=
"none"
)
{
oHeight
=
e
.
offsetHeight
;
oHeight
=
e
.
offsetHeight
;
oWidth
=
e
.
offsetWidth
;
oWidth
=
e
.
offsetWidth
;
}
else
}
else
{
jQuery
.
swap
(
e
,
{
visibility
:
"hidden"
,
position
:
"absolute"
,
display
:
"block"
},
e
=
$
(
e
.
cloneNode
(
true
)).
css
({
function
(){
visibility
:
"hidden"
,
position
:
"absolute"
,
display
:
"block"
}).
prependTo
(
"body"
)[
0
];
oHeight
=
e
.
clientHeight
;
oHeight
=
e
.
clientHeight
;
oWidth
=
e
.
clientWidth
;
oWidth
=
e
.
clientWidth
;
});
e
.
parentNode
.
removeChild
(
e
);
}
});
});
return
p
==
"height"
?
oHeight
:
oWidth
;
return
p
==
"height"
?
oHeight
:
oWidth
;
...
@@ -2417,7 +2400,7 @@ jQuery.macros = {
...
@@ -2417,7 +2400,7 @@ jQuery.macros = {
* @type jQuery
* @type jQuery
* @cat Effects
* @cat Effects
*/
*/
_
show
:
function
(){
show
:
function
(){
this
.
style
.
display
=
this
.
oldblock
?
this
.
oldblock
:
""
;
this
.
style
.
display
=
this
.
oldblock
?
this
.
oldblock
:
""
;
if
(
jQuery
.
css
(
this
,
"display"
)
==
"none"
)
if
(
jQuery
.
css
(
this
,
"display"
)
==
"none"
)
this
.
style
.
display
=
"block"
;
this
.
style
.
display
=
"block"
;
...
@@ -2440,7 +2423,7 @@ jQuery.macros = {
...
@@ -2440,7 +2423,7 @@ jQuery.macros = {
* @type jQuery
* @type jQuery
* @cat Effects
* @cat Effects
*/
*/
_
hide
:
function
(){
hide
:
function
(){
this
.
oldblock
=
this
.
oldblock
||
jQuery
.
css
(
this
,
"display"
);
this
.
oldblock
=
this
.
oldblock
||
jQuery
.
css
(
this
,
"display"
);
if
(
this
.
oldblock
==
"none"
)
if
(
this
.
oldblock
==
"none"
)
this
.
oldblock
=
"block"
;
this
.
oldblock
=
"block"
;
...
@@ -2460,9 +2443,8 @@ jQuery.macros = {
...
@@ -2460,9 +2443,8 @@ jQuery.macros = {
* @type jQuery
* @type jQuery
* @cat Effects
* @cat Effects
*/
*/
_toggle
:
function
(){
toggle
:
function
(){
var
d
=
jQuery
.
css
(
this
,
"display"
);
$
(
this
)[
$
(
this
).
is
(
":hidden"
)
?
"show"
:
"hide"
].
apply
(
$
(
this
),
arguments
);
$
(
this
)[
!
d
||
d
==
"none"
?
"show"
:
"hide"
]();
},
},
/**
/**
...
@@ -2672,3 +2654,5 @@ jQuery.macros = {
...
@@ -2672,3 +2654,5 @@ jQuery.macros = {
}
}
}
}
};
};
jQuery
.
init
();
\ No newline at end of file
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