// We're overriding the old toggle function, so
// remember it for later
- //_toggle: jQuery.fn.toggle,
+ _toggle: jQuery.fn.toggle,
/**
* Toggle between two function calls every other click.
toggle: function(a,b) {
// If two functions are passed in, we're
// 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
this.last = this.last == a ? b : a;
}) :
// Otherwise, execute the old toggle function
- this._toggle();
+ this._toggle.apply( this, arguments );
},
/**
jQuery.fn.extend({
// overwrite the old show method
- //_show: jQuery.fn.show,
+ _show: jQuery.fn.show,
/**
* Show all matched elements using a graceful animation.
},
// Overwrite the old hide method
- //_hide: jQuery.fn.hide,
+ _hide: jQuery.fn.hide,
/**
* Hide all matched elements using a graceful animation.
*/
animate: function(prop,speed,callback) {
return this.queue(function(){
- var i = 0;
+
+ this.curAnim = 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 )
e.custom( e.cur(), prop[p] );
else
e[ prop[p] ]( prop );
}
+
});
},
}
},
- speed: function(s,o,i) {
+ speed: function(s,o) {
o = o || {};
if ( o.constructor == Function )
if ( o.oldComplete && o.oldComplete.constructor == Function )
o.oldComplete.apply( this );
};
-
- if ( i > 0 )
- o.complete = null;
return o;
},
// My hate for IE will never die
} else if ( parseInt(z.now) )
y[prop] = parseInt(z.now) + "px";
+
y.display = "block";
};
z.o.hide = true;
// 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
z.el.oldOverflow = jQuery.css( z.el, "overflow" );
// Make sure that nothing sneaks out
- //if ( z.el.oldOverlay == "visible" )
y.overflow = "hidden";
// Each step of an animation
z.now = lastNum;
z.a();
- // Hide the element if the "hide" operation was done
- if ( z.o.hide ) y.display = 'none';
-
- // Reset the overflow
- y.overflow = z.el.oldOverflow;
-
- // Reset the property, if the item has been hidden
- if ( z.o.hide )
- y[ prop ] = z.el.orig[ prop ].constructor == Number && prop != "opacity" ?
- z.el.orig[prop] + "px" : z.el.orig[prop];
-
- // set its height and/or width to auto
- if ( prop == 'height' || prop == 'width' )
- jQuery.setAuto( z.el, prop );
+ z.el.curAnim[ prop ] = true;
+
+ var done = true;
+ for ( var i in z.el.curAnim )
+ if ( z.el.curAnim[i] !== true )
+ done = false;
+
+ if ( done ) {
+ // Reset the overflow
+ y.overflow = z.el.oldOverflow;
+
+ // Hide the element if the "hide" operation was done
+ if ( z.o.hide )
+ y.display = 'none';
+
+ // 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
+ if ( p == 'height' || p == 'width' )
+ jQuery.setAuto( z.el, p );
+ }
+ }
+ }
// 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
z.o.complete.apply( z.el );
} else {
*/
function jQuery(a,c) {
- // Initalize the extra macro functions
- if ( !jQuery.initDone ) jQuery.init();
-
// Shortcut for document ready (because $(document).each() is silly)
if ( a && a.constructor == Function && jQuery.fn.ready )
return jQuery(document).ready(a);
// Make sure that a selection was provided
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
if ( a.jquery )
return $( jQuery.merge( a, [] ) );
// Find the matching elements and save them for later
jQuery.find( a, c ) );
+ // See if an extra function was provided
var fn = arguments[ arguments.length - 1 ];
+
+ // If so, execute it in context
if ( fn && fn.constructor == Function )
this.each(fn);
}
jQuery.extend({
/**
- *
- *
* @private
* @name init
* @type undefined
if (jQuery.css(e,"display") != "none") {
oHeight = e.offsetHeight;
oWidth = e.offsetWidth;
- } else
- jQuery.swap( e, { visibility: "hidden", position: "absolute", display: "block" },
- function(){
- oHeight = e.clientHeight;
- oWidth = e.clientWidth;
- });
+ } else {
+ e = $(e.cloneNode(true)).css({
+ visibility: "hidden", position: "absolute", display: "block"
+ }).prependTo("body")[0];
+
+ oHeight = e.clientHeight;
+ oWidth = e.clientWidth;
+
+ e.parentNode.removeChild(e);
+ }
});
return p == "height" ? oHeight : oWidth;
} else if ( p == "opacity" && jQuery.browser.msie )
- return parseFloat( jQuery.curCSS(e,"filter").replace(/[^0-9.]/,"") ) || 1;
+ return parseFloat( jQuery.curCSS(e,"filter").replace(/[^0-9.]/,"") ) || 1;
return jQuery.curCSS( e, p );
},
* @type jQuery
* @cat Effects
*/
- _show: function(){
+ show: function(){
this.style.display = this.oldblock ? this.oldblock : "";
if ( jQuery.css(this,"display") == "none" )
this.style.display = "block";
* @type jQuery
* @cat Effects
*/
- _hide: function(){
+ hide: function(){
this.oldblock = this.oldblock || jQuery.css(this,"display");
if ( this.oldblock == "none" )
this.oldblock = "block";
* @type jQuery
* @cat Effects
*/
- _toggle: function(){
- var d = jQuery.css(this,"display");
- $(this)[ !d || d == "none" ? "show" : "hide" ]();
+ toggle: function(){
+ $(this)[ $(this).is(":hidden") ? "show" : "hide" ].apply( $(this), arguments );
},
/**
}
}
};
+
+jQuery.init();
\ No newline at end of file