1 /* prevent execution of jQOld if included more than once */
2 if(typeof window.jQOld == "undefined") {
4 * jQOld 1.1.2 - New Wave Javascript
6 * Copyright (c) 2007 John Resig (jquery.com)
7 * Dual licensed under the MIT (MIT-LICENSE.txt)
8 * and GPL (GPL-LICENSE.txt) licenses.
10 * $Date: 2007-02-28 12:03:00 -0500 (Wed, 28 Feb 2007) $
14 // Global undefined variable
15 window.undefined = window.undefined;
16 var jQOld = function(a,c) {
17 // If the context is global, return a new object
19 return new jQOld(a,c);
21 // Make sure that a selection was provided
24 // HANDLE: $(function)
25 // Shortcut for document ready
26 if ( jQOld.isFunction(a) )
27 return new jQOld(document)[ jQOld.fn.ready ? "ready" : "load" ]( a );
29 // Handle HTML strings
30 if ( typeof a == "string" ) {
31 // HANDLE: $(html) -> $(array)
32 var m = /^[^<]*(<(.|\s)+>)[^>]*$/.exec(a);
34 a = jQOld.clean( [ m[1] ] );
38 return new jQOld( c ).find( a );
43 a.constructor == Array && a ||
45 // HANDLE: $(arraylike)
46 // Watch for when an array-like object is passed as the selector
47 (a.jquery || a.length && a != window && !a.nodeType && a[0] != undefined && a[0].nodeType) && jQOld.makeArray( a ) ||
53 // Map over the $ in case of overwrite
54 if ( typeof $ != "undefined" )
57 // Map the jQOld namespace to the '$' one
60 jQOld.fn = jQOld.prototype = {
69 get: function( num ) {
70 return num == undefined ?
72 // Return a 'clean' array
73 jQOld.makeArray( this ) :
75 // Return just the object
78 pushStack: function( a ) {
80 ret.prevObject = this;
83 setArray: function( a ) {
85 [].push.apply( this, a );
88 each: function( fn, args ) {
89 return jQOld.each( this, fn, args );
91 index: function( obj ) {
93 this.each(function(i){
94 if ( this == obj ) pos = i;
99 attr: function( key, value, type ) {
102 // Look for the case where we're accessing a style value
103 if ( key.constructor == String )
104 if ( value == undefined )
105 return this.length && jQOld[ type || "attr" ]( this[0], key ) || undefined;
111 // Check to see if we're setting style values
112 return this.each(function(index){
113 // Set all the styles
114 for ( var prop in obj )
116 type ? this.style : this,
117 prop, jQOld.prop(this, obj[prop], type, index, prop)
122 css: function( key, value ) {
123 return this.attr( key, value, "curCSS" );
127 if ( typeof e == "string" )
128 return this.empty().append( document.createTextNode( e ) );
131 jQOld.each( e || this, function(){
132 jQOld.each( this.childNodes, function(){
133 if ( this.nodeType != 8 )
134 t += this.nodeType != 1 ?
135 this.nodeValue : jQOld.fn.text([ this ]);
142 // The elements to wrap the target around
143 var a = jQOld.clean(arguments);
145 // Wrap each of the matched elements individually
146 return this.each(function(){
147 // Clone the structure that we're using to wrap
148 var b = a[0].cloneNode(true);
150 // Insert it before the element to be wrapped
151 this.parentNode.insertBefore( b, this );
153 // Find the deepest point in the wrap structure
154 while ( b.firstChild )
157 // Move the matched element to within the wrap structure
158 b.appendChild( this );
162 return this.domManip(arguments, true, 1, function(a){
163 this.appendChild( a );
166 prepend: function() {
167 return this.domManip(arguments, true, -1, function(a){
168 this.insertBefore( a, this.firstChild );
172 return this.domManip(arguments, false, 1, function(a){
173 this.parentNode.insertBefore( a, this );
177 return this.domManip(arguments, false, -1, function(a){
178 this.parentNode.insertBefore( a, this.nextSibling );
182 return this.prevObject || jQOld([]);
185 return this.pushStack( jQOld.map( this, function(a){
186 return jQOld.find(t,a);
189 clone: function(deep) {
190 return this.pushStack( jQOld.map( this, function(a){
191 var a = a.cloneNode( deep != undefined ? deep : true );
192 a.$events = null; // drop $events expando to avoid firing incorrect events
197 filter: function(t) {
198 return this.pushStack(
199 jQOld.isFunction( t ) &&
200 jQOld.grep(this, function(el, index){
201 return t.apply(el, [index])
204 jQOld.multiFilter(t,this) );
208 return this.pushStack(
209 t.constructor == String &&
210 jQOld.multiFilter(t, this, true) ||
212 jQOld.grep(this, function(a) {
213 return ( t.constructor == Array || t.jquery )
214 ? jQOld.inArray( a, t ) < 0
221 return this.pushStack( jQOld.merge(
223 t.constructor == String ?
225 t.length != undefined && (!t.nodeName || t.nodeName == "FORM") ?
230 return expr ? jQOld.filter(expr,this).r.length > 0 : false;
233 val: function( val ) {
234 return val == undefined ?
235 ( this.length ? this[0].value : null ) :
236 this.attr( "value", val );
239 html: function( val ) {
240 return val == undefined ?
241 ( this.length ? this[0].innerHTML : null ) :
242 this.empty().append( val );
244 domManip: function(args, table, dir, fn){
245 var clone = this.length > 1;
246 var a = jQOld.clean(args);
250 return this.each(function(){
253 if ( table && jQOld.nodeName(this, "table") && jQOld.nodeName(a[0], "tr") )
254 obj = this.getElementsByTagName("tbody")[0] || this.appendChild(document.createElement("tbody"));
256 jQOld.each( a, function(){
257 fn.apply( obj, [ clone ? this.cloneNode(true) : this ] );
264 jQOld.extend = jQOld.fn.extend = function() {
265 // copy reference to target object
266 var target = arguments[0],
269 // extend jQOld itself if only one argument is passed
270 if ( arguments.length == 1 ) {
275 while (prop = arguments[a++])
276 // Extend the base object
277 for ( var i in prop ) target[i] = prop[i];
279 // Return the modified object
284 noConflict: function() {
290 // This may seem like some crazy code, but trust me when I say that this
291 // is the only cross-browser way to do this. --John
292 isFunction: function( fn ) {
293 return !!fn && typeof fn != "string" && !fn.nodeName &&
294 typeof fn[0] == "undefined" && /function/i.test( fn + "" );
297 // check if an element is in a XML document
298 isXMLDoc: function(elem) {
299 return elem.tagName && elem.ownerDocument && !elem.ownerDocument.body;
302 nodeName: function( elem, name ) {
303 return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();
305 // args is for internal usage only
306 each: function( obj, fn, args ) {
307 if ( obj.length == undefined )
309 fn.apply( obj[i], args || [i, obj[i]] );
311 for ( var i = 0, ol = obj.length; i < ol; i++ )
312 if ( fn.apply( obj[i], args || [i, obj[i]] ) === false ) break;
316 prop: function(elem, value, type, index, prop){
317 // Handle executable functions
318 if ( jQOld.isFunction( value ) )
319 value = value.call( elem, [index] );
321 // exclude the following css properties to add px
322 var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i;
324 // Handle passing in a number to a CSS property
325 return value && value.constructor == Number && type == "curCSS" && !exclude.test(prop) ?
331 // internal only, use addClass("class")
332 add: function( elem, c ){
333 jQOld.each( c.split(/\s+/), function(i, cur){
334 if ( !jQOld.className.has( elem.className, cur ) )
335 elem.className += ( elem.className ? " " : "" ) + cur;
339 // internal only, use removeClass("class")
340 remove: function( elem, c ){
342 jQOld.grep( elem.className.split(/\s+/), function(cur){
343 return !jQOld.className.has( c, cur );
347 // internal only, use is(".class")
348 has: function( t, c ) {
349 t = t.className || t;
350 // escape regex characters
351 c = c.replace(/([\.\\\+\*\?\[\^\]\$\(\)\{\}\=\!\<\>\|\:])/g, "\\$1");
352 return t && new RegExp("(^|\\s)" + c + "(\\s|$)").test( t );
355 swap: function(e,o,f) {
357 e.style["old"+i] = e.style[i];
362 e.style[i] = e.style["old"+i];
366 if ( p == "height" || p == "width" ) {
367 var old = {}, oHeight, oWidth, d = ["Top","Bottom","Right","Left"];
369 jQOld.each( d, function(){
370 old["padding" + this] = 0;
371 old["border" + this + "Width"] = 0;
374 jQOld.swap( e, old, function() {
375 if (jQOld.css(e,"display") != "none") {
376 oHeight = e.offsetHeight;
377 oWidth = e.offsetWidth;
379 e = jQOld(e.cloneNode(true))
380 .find(":radio").removeAttr("checked").end()
382 visibility: "hidden", position: "absolute", display: "block", right: "0", left: "0"
383 }).appendTo(e.parentNode)[0];
385 var parPos = jQOld.css(e.parentNode,"position");
386 if ( parPos == "" || parPos == "static" )
387 e.parentNode.style.position = "relative";
389 oHeight = e.clientHeight;
390 oWidth = e.clientWidth;
392 if ( parPos == "" || parPos == "static" )
393 e.parentNode.style.position = "static";
395 e.parentNode.removeChild(e);
399 return p == "height" ? oHeight : oWidth;
402 return jQOld.curCSS( e, p );
405 curCSS: function(elem, prop, force) {
408 if (prop == "opacity" && jQOld.browser.msie)
409 return jQOld.attr(elem.style, "opacity");
411 if (prop == "float" || prop == "cssFloat")
412 prop = jQOld.browser.msie ? "styleFloat" : "cssFloat";
414 if (!force && elem.style[prop])
415 ret = elem.style[prop];
417 else if (document.defaultView && document.defaultView.getComputedStyle) {
419 if (prop == "cssFloat" || prop == "styleFloat")
422 prop = prop.replace(/([A-Z])/g,"-$1").toLowerCase();
423 var cur = document.defaultView.getComputedStyle(elem, null);
426 ret = cur.getPropertyValue(prop);
427 else if ( prop == "display" )
430 jQOld.swap(elem, { display: "block" }, function() {
431 var c = document.defaultView.getComputedStyle(this, "");
432 ret = c && c.getPropertyValue(prop) || "";
435 } else if (elem.currentStyle) {
437 var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase();});
438 ret = elem.currentStyle[prop] || elem.currentStyle[newProp];
448 jQOld.each( a, function(i,arg){
451 if ( arg.constructor == Number )
452 arg = arg.toString();
454 // Convert html string into DOM nodes
455 if ( typeof arg == "string" ) {
456 // Trim whitespace, otherwise indexOf won't work as expected
457 var s = jQOld.trim(arg), div = document.createElement("div"), tb = [];
460 // option or optgroup
461 !s.indexOf("<opt") &&
462 [1, "<select>", "</select>"] ||
464 (!s.indexOf("<thead") || !s.indexOf("<tbody") || !s.indexOf("<tfoot")) &&
465 [1, "<table>", "</table>"] ||
468 [2, "<table><tbody>", "</tbody></table>"] ||
470 // <thead> matched above
471 (!s.indexOf("<td") || !s.indexOf("<th")) &&
472 [3, "<table><tbody><tr>", "</tr></tbody></table>"] ||
476 // Go to html and back, then peel off extra wrappers
477 div.innerHTML = wrap[1] + s + wrap[2];
479 // Move to the right depth
481 div = div.firstChild;
483 // Remove IE's autoinserted <tbody> from table fragments
484 if ( jQOld.browser.msie ) {
486 // String was a <table>, *may* have spurious <tbody>
487 if ( !s.indexOf("<table") && s.indexOf("<tbody") < 0 )
488 tb = div.firstChild && div.firstChild.childNodes;
490 // String was a bare <thead> or <tfoot>
491 else if ( wrap[1] == "<table>" && s.indexOf("<tbody") < 0 )
494 for ( var n = tb.length-1; n >= 0 ; --n )
495 if ( jQOld.nodeName(tb[n], "tbody") && !tb[n].childNodes.length )
496 tb[n].parentNode.removeChild(tb[n]);
501 for (var i=0, l=div.childNodes.length; i<l; i++)
502 arg.push(div.childNodes[i]);
505 if ( arg.length === 0 && !jQOld.nodeName(arg, "form") )
508 if ( arg[0] == undefined || jQOld.nodeName(arg, "form") )
511 r = jQOld.merge( r, arg );
518 attr: function(elem, name, value){
519 var fix = jQOld.isXMLDoc(elem) ? {} : {
521 "class": "className",
522 "float": jQOld.browser.msie ? "styleFloat" : "cssFloat",
523 cssFloat: jQOld.browser.msie ? "styleFloat" : "cssFloat",
524 innerHTML: "innerHTML",
525 className: "className",
527 disabled: "disabled",
529 readonly: "readOnly",
533 // IE actually uses filters for opacity ... elem is actually elem.style
534 if ( name == "opacity" && jQOld.browser.msie && value != undefined ) {
535 // IE has trouble with opacity if it does not have layout
536 // Force it by setting the zoom level
539 // Set the alpha filter to set the opacity
540 return elem.filter = elem.filter.replace(/alpha\([^\)]*\)/gi,"") +
541 ( value == 1 ? "" : "alpha(opacity=" + value * 100 + ")" );
543 } else if ( name == "opacity" && jQOld.browser.msie )
545 parseFloat( elem.filter.match(/alpha\(opacity=(.*)\)/)[1] ) / 100 : 1;
547 // Mozilla doesn't play well with opacity 1
548 if ( name == "opacity" && jQOld.browser.mozilla && value == 1 )
552 // Certain attributes only work when accessed via the old DOM 0 way
554 if ( value != undefined ) elem[fix[name]] = value;
555 return elem[fix[name]];
557 } else if ( value == undefined && jQOld.browser.msie && jQOld.nodeName(elem, "form") && (name == "action" || name == "method") )
558 return elem.getAttributeNode(name).nodeValue;
560 // IE elem.getAttribute passes even for style
561 else if ( elem.tagName ) {
562 if ( value != undefined ) elem.setAttribute( name, value );
563 if ( jQOld.browser.msie && /href|src/.test(name) && !jQOld.isXMLDoc(elem) )
564 return elem.getAttribute( name, 2 );
565 return elem.getAttribute( name );
567 // elem is actually elem.style ... set the style
569 name = name.replace(/-([a-z])/ig,function(z,b){return b.toUpperCase();});
570 if ( value != undefined ) elem[name] = value;
575 return t.replace(/^\s+|\s+$/g, "");
578 makeArray: function( a ) {
581 if ( a.constructor != Array )
582 for ( var i = 0, al = a.length; i < al; i++ )
590 inArray: function( b, a ) {
591 for ( var i = 0, al = a.length; i < al; i++ )
596 merge: function(first, second) {
597 var r = [].slice.call( first, 0 );
599 // Now check for duplicates between the two arrays
600 // and only add the unique items
601 for ( var i = 0, sl = second.length; i < sl; i++ )
602 // Check for duplicates
603 if ( jQOld.inArray( second[i], r ) == -1 )
604 // The item is unique, add it
605 first.push( second[i] );
609 grep: function(elems, fn, inv) {
610 // If a string is passed in for the function, make a function
611 // for it (a handy shortcut)
612 if ( typeof fn == "string" )
613 fn = new Function("a","i","return " + fn);
617 // Go through the array, only saving the items
618 // that pass the validator function
619 for ( var i = 0, el = elems.length; i < el; i++ )
620 if ( !inv && fn(elems[i],i) || inv && !fn(elems[i],i) )
621 result.push( elems[i] );
625 map: function(elems, fn) {
626 // If a string is passed in for the function, make a function
627 // for it (a handy shortcut)
628 if ( typeof fn == "string" )
629 fn = new Function("a","return " + fn);
631 var result = [], r = [];
633 // Go through the array, translating each of the items to their
634 // new value (or values).
635 for ( var i = 0, el = elems.length; i < el; i++ ) {
636 var val = fn(elems[i],i);
638 if ( val !== null && val != undefined ) {
639 if ( val.constructor != Array ) val = [val];
640 result = result.concat( val );
644 var r = result.length ? [ result[0] ] : [];
646 check: for ( var i = 1, rl = result.length; i < rl; i++ ) {
647 for ( var j = 0; j < i; j++ )
648 if ( result[i] == r[j] )
659 * Whether the W3C compliant box model is being used.
667 var b = navigator.userAgent.toLowerCase();
669 // Figure out what browser is being used
671 safari: /webkit/.test(b),
672 opera: /opera/.test(b),
673 msie: /msie/.test(b) && !/opera/.test(b),
674 mozilla: /mozilla/.test(b) && !/(compatible|webkit)/.test(b)
677 // Check to see if the W3C box model is being used
678 jQOld.boxModel = !jQOld.browser.msie || document.compatMode == "CSS1Compat";
682 parent: "a.parentNode",
683 parents: "jQOld.parents(a)",
684 next: "jQOld.nth(a,2,'nextSibling')",
685 prev: "jQOld.nth(a,2,'previousSibling')",
686 siblings: "jQOld.sibling(a.parentNode.firstChild,a)",
687 children: "jQOld.sibling(a.firstChild)"
689 jQOld.fn[ i ] = function(a) {
690 var ret = jQOld.map(this,n);
691 if ( a && typeof a == "string" )
692 ret = jQOld.multiFilter(a,ret);
693 return this.pushStack( ret );
699 prependTo: "prepend",
700 insertBefore: "before",
703 jQOld.fn[ i ] = function(){
705 return this.each(function(){
706 for ( var j = 0, al = a.length; j < al; j++ )
707 jQOld(a[j])[n]( this );
713 removeAttr: function( key ) {
714 jQOld.attr( this, key, "" );
715 this.removeAttribute( key );
717 addClass: function(c){
718 jQOld.className.add(this,c);
720 removeClass: function(c){
721 jQOld.className.remove(this,c);
723 toggleClass: function( c ){
724 jQOld.className[ jQOld.className.has(this,c) ? "remove" : "add" ](this, c);
727 if ( !a || jQOld.filter( a, [this] ).r.length )
728 this.parentNode.removeChild( this );
731 while ( this.firstChild )
732 this.removeChild( this.firstChild );
735 jQOld.fn[ i ] = function() {
736 return this.each( n, arguments );
740 jQOld.each( [ "eq", "lt", "gt", "contains" ], function(i,n){
741 jQOld.fn[ n ] = function(num,fn) {
742 return this.filter( ":" + n + "(" + num + ")", fn );
746 jQOld.each( [ "height", "width" ], function(i,n){
747 jQOld.fn[ n ] = function(h) {
748 return h == undefined ?
749 ( this.length ? jQOld.css( this[0], n ) : null ) :
750 this.css( n, h.constructor == String ? h : h + "px" );
755 "": "m[2]=='*'||jQOld.nodeName(a,m[2])",
756 "#": "a.getAttribute('id')==m[2]",
764 last: "i==r.length-1",
769 "nth-child": "jQOld.nth(a.parentNode.firstChild,m[3],'nextSibling',a)==a",
770 "first-child": "jQOld.nth(a.parentNode.firstChild,1,'nextSibling')==a",
771 "last-child": "jQOld.nth(a.parentNode.lastChild,1,'previousSibling')==a",
772 "only-child": "jQOld.sibling(a.parentNode.firstChild).length==1",
775 parent: "a.firstChild",
776 empty: "!a.firstChild",
779 contains: "jQOld.fn.text.apply([a]).indexOf(m[3])>=0",
782 visible: 'a.type!="hidden"&&jQOld.css(a,"display")!="none"&&jQOld.css(a,"visibility")!="hidden"',
783 hidden: 'a.type=="hidden"||jQOld.css(a,"display")=="none"||jQOld.css(a,"visibility")=="hidden"',
786 enabled: "!a.disabled",
787 disabled: "a.disabled",
788 checked: "a.checked",
789 selected: "a.selected||jQOld.attr(a,'selected')",
792 text: "a.type=='text'",
793 radio: "a.type=='radio'",
794 checkbox: "a.type=='checkbox'",
795 file: "a.type=='file'",
796 password: "a.type=='password'",
797 submit: "a.type=='submit'",
798 image: "a.type=='image'",
799 reset: "a.type=='reset'",
800 button: 'a.type=="button"||jQOld.nodeName(a,"button")',
801 input: "/input|select|textarea|button/i.test(a.nodeName)"
803 ".": "jQOld.className.has(a,m[2])",
807 "^=": "z&&!z.indexOf(m[4])",
808 "$=": "z&&z.substr(z.length - m[4].length,m[4].length)==m[4]",
809 "*=": "z&&z.indexOf(m[4])>=0",
811 _resort: function(m){
812 return ["", m[1], m[3], m[2], m[5]];
814 _prefix: "z=a[m[3]];if(!z||/href|src/.test(m[3]))z=jQOld.attr(a,m[3]);"
816 "[": "jQOld.find(m[2],a).length"
819 // The regular expressions that power the parsing engine
821 // Match: [@value='test'], [@foo]
822 /^\[ *(@)([a-z0-9_-]*) *([!*$^=]*) *('?"?)(.*?)\4 *\]/i,
824 // Match: [div], [div p]
825 /^(\[)\s*(.*?(\[.*?\])?[^[]*?)\s*\]/,
827 // Match: :contains('foo')
828 /^(:)([a-z0-9_-]*)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/i,
830 // Match: :even, :last-chlid
831 /^([:.#]*)([a-z0-9_*-]*)/i
835 /^(\/?\.\.)/, "a.parentNode",
836 /^(>|\/)/, "jQOld.sibling(a.firstChild)",
837 /^(\+)/, "jQOld.nth(a,2,'nextSibling')",
839 var s = jQOld.sibling(a.parentNode.firstChild);
840 return s.slice(jQOld.inArray(a,s) + 1);
844 multiFilter: function( expr, elems, not ) {
847 while ( expr && expr != old ) {
849 var f = jQOld.filter( expr, elems, not );
850 expr = f.t.replace(/^\s*,\s*/, "" );
851 cur = not ? elems = f.r : jQOld.merge( cur, f.r );
856 find: function( t, context ) {
857 // Quickly handle non-string expressions
858 if ( typeof t != "string" )
861 // Make sure that the context is a DOM Element
862 if ( context && !context.nodeType )
865 // Set the correct context (if none is provided)
866 context = context || document;
868 // Handle the common XPath // expression
869 if ( !t.indexOf("//") ) {
870 context = context.documentElement;
871 t = t.substr(2,t.length);
873 // And the / root expression
874 } else if ( !t.indexOf("/") ) {
875 context = context.documentElement;
876 t = t.substr(1,t.length);
877 if ( t.indexOf("/") >= 1 )
878 t = t.substr(t.indexOf("/"),t.length);
881 // Initialize the search
882 var ret = [context], done = [], last = null;
884 // Continue while a selector expression exists, and while
885 // we're no longer looping upon ourselves
886 while ( t && last != t ) {
890 t = jQOld.trim(t).replace( /^\/\//i, "" );
892 var foundToken = false;
894 // An attempt at speeding up child selectors that
895 // point to a specific element tag
896 var re = /^[\/>]\s*([a-z0-9*-]+)/i;
900 // Perform our own iteration and filter
901 jQOld.each( ret, function(){
902 for ( var c = this.firstChild; c; c = c.nextSibling )
903 if ( c.nodeType == 1 && ( jQOld.nodeName(c, m[1]) || m[1] == "*" ) )
908 t = t.replace( re, "" );
909 if ( t.indexOf(" ") == 0 ) continue;
912 // Look for pre-defined expression tokens
913 for ( var i = 0; i < jQOld.token.length; i += 2 ) {
914 // Attempt to match each, individual, token in
915 // the specified order
916 var re = jQOld.token[i];
919 // If the token match was found
921 // Map it against the token's handler
922 r = ret = jQOld.map( ret, jQOld.isFunction( jQOld.token[i+1] ) ?
924 function(a){ return eval(jQOld.token[i+1]); });
926 // And remove the token
927 t = jQOld.trim( t.replace( re, "" ) );
934 // See if there's still an expression, and that we haven't already
936 if ( t && !foundToken ) {
937 // Handle multiple expressions
938 if ( !t.indexOf(",") ) {
939 // Clean the result set
940 if ( ret[0] == context ) ret.shift();
942 // Merge the result sets
943 jQOld.merge( done, ret );
948 // Touch up the selector string
949 t = " " + t.substr(1,t.length);
952 // Optomize for the case nodeName#idName
953 var re2 = /^([a-z0-9_-]+)(#)([a-z0-9\\*_-]*)/i;
956 // Re-organize the results, so that they're consistent
958 m = [ 0, m[2], m[3], m[1] ];
961 // Otherwise, do a traditional filter check for
962 // ID, class, and element selectors
963 re2 = /^([#.]?)([a-z0-9\\*_-]*)/i;
967 // Try to do a global search by ID, where we can
968 if ( m[1] == "#" && ret[ret.length-1].getElementById ) {
969 // Optimization for HTML document case
970 var oid = ret[ret.length-1].getElementById(m[2]);
972 // Do a quick check for the existence of the actual ID attribute
973 // to avoid selecting by the name attribute in IE
974 if ( jQOld.browser.msie && oid && oid.id != m[2] )
975 oid = jQOld('[@id="'+m[2]+'"]', ret[ret.length-1])[0];
977 // Do a quick check for node name (where applicable) so
978 // that div#foo searches will be really fast
979 ret = r = oid && (!m[3] || jQOld.nodeName(oid, m[3])) ? [oid] : [];
982 // Pre-compile a regular expression to handle class searches
984 var rec = new RegExp("(^|\\s)" + m[2] + "(\\s|$)");
986 // We need to find all descendant elements, it is more
987 // efficient to use getAll() when we are already further down
988 // the tree - we try to recognize that here
989 jQOld.each( ret, function(){
990 // Grab the tag name being searched for
991 var tag = m[1] != "" || m[0] == "" ? "*" : m[2];
993 // Handle IE7 being really dumb about <object>s
994 if ( jQOld.nodeName(this, "object") && tag == "*" )
998 m[1] != "" && ret.length != 1 ?
999 jQOld.getAll( this, [], m[1], m[2], rec ) :
1000 this.getElementsByTagName( tag )
1004 // It's faster to filter by class and be done with it
1005 if ( m[1] == "." && ret.length == 1 )
1006 r = jQOld.grep( r, function(e) {
1007 return rec.test(e.className);
1010 // Same with ID filtering
1011 if ( m[1] == "#" && ret.length == 1 ) {
1012 // Remember, then wipe out, the result set
1016 // Then try to find the element with the ID
1017 jQOld.each( tmp, function(){
1018 if ( this.getAttribute("id") == m[2] ) {
1028 t = t.replace( re2, "" );
1033 // If a selector string still exists
1035 // Attempt to filter it
1036 var val = jQOld.filter(t,r);
1038 t = jQOld.trim(val.t);
1042 // Remove the root context
1043 if ( ret && ret[0] == context ) ret.shift();
1045 // And combine the results
1046 jQOld.merge( done, ret );
1051 filter: function(t,r,not) {
1052 // Look for common filter expressions
1053 while ( t && /^[a-z[({<*:.#]/i.test(t) ) {
1055 var p = jQOld.parse, m;
1057 jQOld.each( p, function(i,re){
1059 // Look for, and replace, string-like sequences
1060 // and finally build a regexp out of it
1064 // Remove what we just matched
1065 t = t.substring( m[0].length );
1067 // Re-organize the first match
1068 if ( jQOld.expr[ m[1] ]._resort )
1069 m = jQOld.expr[ m[1] ]._resort( m );
1075 // :not() is a special case that can be optimized by
1076 // keeping it out of the expression list
1077 if ( m[1] == ":" && m[2] == "not" )
1078 r = jQOld.filter(m[3], r, true).r;
1080 // Handle classes as a special case (this will help to
1081 // improve the speed, as the regexp will only be compiled once)
1082 else if ( m[1] == "." ) {
1084 var re = new RegExp("(^|\\s)" + m[2] + "(\\s|$)");
1085 r = jQOld.grep( r, function(e){
1086 return re.test(e.className || "");
1089 // Otherwise, find the expression to execute
1091 var f = jQOld.expr[m[1]];
1092 if ( typeof f != "string" )
1093 f = jQOld.expr[m[1]][m[2]];
1095 // Build a custom macro to enclose it
1096 eval("f = function(a,i){" +
1097 ( jQOld.expr[ m[1] ]._prefix || "" ) +
1098 "return " + f + "}");
1100 // Execute it against the current filter
1101 r = jQOld.grep( r, f, not );
1105 // Return an array of filtered elements (r)
1106 // and the modified expression string (t)
1107 return { r: r, t: t };
1110 getAll: function( o, r, token, name, re ) {
1111 for ( var s = o.firstChild; s; s = s.nextSibling )
1112 if ( s.nodeType == 1 ) {
1116 add = s.className && re.test(s.className);
1117 else if ( token == "#" )
1118 add = s.getAttribute("id") == name;
1123 if ( token == "#" && r.length ) break;
1126 jQOld.getAll( s, r, token, name, re );
1131 parents: function( elem ){
1133 var cur = elem.parentNode;
1134 while ( cur && cur != document ) {
1135 matched.push( cur );
1136 cur = cur.parentNode;
1140 nth: function(cur,result,dir,elem){
1141 result = result || 1;
1143 for ( ; cur; cur = cur[dir] ) {
1144 if ( cur.nodeType == 1 ) num++;
1145 if ( num == result || result == "even" && num % 2 == 0 && num > 1 && cur == elem ||
1146 result == "odd" && num % 2 == 1 && cur == elem ) return cur;
1149 sibling: function( n, elem ) {
1152 for ( ; n; n = n.nextSibling ) {
1153 if ( n.nodeType == 1 && (!elem || n != elem) )
1161 * A number of helper functions used for managing events.
1162 * Many of the ideas behind this code orignated from
1163 * Dean Edwards' addEvent library.
1167 // Bind an event to an element
1168 // Original by Dean Edwards
1169 add: function(element, type, handler, data) {
1170 // For whatever reason, IE has trouble passing the window object
1171 // around, causing it to be cloned in the process
1172 if ( jQOld.browser.msie && element.setInterval != undefined )
1175 // if data is passed, bind to handler
1177 handler.data = data;
1179 // Make sure that the function being executed has a unique ID
1180 if ( !handler.guid )
1181 handler.guid = this.guid++;
1183 // Init the element's event structure
1184 if (!element.$events)
1185 element.$events = {};
1187 // Get the current list of functions bound to this event
1188 var handlers = element.$events[type];
1190 // If it hasn't been initialized yet
1192 // Init the event handler queue
1193 handlers = element.$events[type] = {};
1195 // Remember an existing handler, if it's already there
1196 if (element["on" + type])
1197 handlers[0] = element["on" + type];
1200 // Add the function to the element's handler list
1201 handlers[handler.guid] = handler;
1203 // And bind the global event handler to the element
1204 element["on" + type] = this.handle;
1206 // Remember the function in a global list (for triggering)
1207 if (!this.global[type])
1208 this.global[type] = [];
1209 this.global[type].push( element );
1215 // Detach an event or set of events from an element
1216 remove: function(element, type, handler) {
1217 if (element.$events) {
1219 if ( type && type.type ) { // type is actually an event object here
1220 handler = type.handler;
1224 if (type && element.$events[type])
1225 // remove the given handler for the given type
1227 delete element.$events[type][handler.guid];
1229 // remove all handlers for the given type
1231 for ( i in element.$events[type] )
1232 delete element.$events[type][i];
1234 // remove all handlers
1236 for ( j in element.$events )
1237 this.remove( element, j );
1239 // remove event handler if no more handlers exist
1240 for ( k in element.$events[type] )
1245 if (!k) element["on" + type] = null;
1249 trigger: function(type, data, element) {
1250 // Clone the incoming data, if any
1251 data = jQOld.makeArray(data || []);
1253 // Handle a global trigger
1255 jQOld.each( this.global[type] || [], function(){
1256 jQOld.event.trigger( type, data, this );
1259 // Handle triggering a single element
1261 var handler = element["on" + type ], val,
1262 fn = jQOld.isFunction( element[ type ] );
1265 // Pass along a fake event
1266 data.unshift( this.fix({ type: type, target: element }) );
1268 // Trigger the event
1269 if ( (val = handler.apply( element, data )) !== false )
1270 this.triggered = true;
1273 if ( fn && val !== false )
1276 this.triggered = false;
1280 handle: function(event) {
1281 // Handle the second event of a trigger and when
1282 // an event is called after a page has unloaded
1283 if ( typeof jQOld == "undefined" || jQOld.event.triggered ) return;
1285 // Empty object is for triggered events with no data
1286 event = jQOld.event.fix( event || window.event || {} );
1288 // returned undefined or false
1291 var c = this.$events[event.type];
1293 var args = [].slice.call( arguments, 1 );
1294 args.unshift( event );
1296 for ( var j in c ) {
1297 // Pass in a reference to the handler function itself
1298 // So that we can later remove it
1299 args[0].handler = c[j];
1300 args[0].data = c[j].data;
1302 if ( c[j].apply( this, args ) === false ) {
1303 event.preventDefault();
1304 event.stopPropagation();
1305 returnValue = false;
1309 // Clean up added properties in IE to prevent memory leak
1310 if (jQOld.browser.msie) event.target = event.preventDefault = event.stopPropagation = event.handler = event.data = null;
1315 fix: function(event) {
1316 // Fix target property, if necessary
1317 if ( !event.target && event.srcElement )
1318 event.target = event.srcElement;
1320 // Calculate pageX/Y if missing and clientX/Y available
1321 if ( event.pageX == undefined && event.clientX != undefined ) {
1322 var e = document.documentElement, b = document.body;
1323 event.pageX = event.clientX + (e.scrollLeft || b.scrollLeft);
1324 event.pageY = event.clientY + (e.scrollTop || b.scrollTop);
1327 // check if target is a textnode (safari)
1328 if (jQOld.browser.safari && event.target.nodeType == 3) {
1329 // store a copy of the original event object
1330 // and clone because target is read only
1331 var originalEvent = event;
1332 event = jQOld.extend({}, originalEvent);
1334 // get parentnode from textnode
1335 event.target = originalEvent.target.parentNode;
1337 // add preventDefault and stopPropagation since
1338 // they will not work on the clone
1339 event.preventDefault = function() {
1340 return originalEvent.preventDefault();
1342 event.stopPropagation = function() {
1343 return originalEvent.stopPropagation();
1347 // fix preventDefault and stopPropagation
1348 if (!event.preventDefault)
1349 event.preventDefault = function() {
1350 this.returnValue = false;
1353 if (!event.stopPropagation)
1354 event.stopPropagation = function() {
1355 this.cancelBubble = true;
1363 bind: function( type, data, fn ) {
1364 return this.each(function(){
1365 jQOld.event.add( this, type, fn || data, data );
1368 one: function( type, data, fn ) {
1369 return this.each(function(){
1370 jQOld.event.add( this, type, function(event) {
1371 jQOld(this).unbind(event);
1372 return (fn || data).apply( this, arguments);
1376 unbind: function( type, fn ) {
1377 return this.each(function(){
1378 jQOld.event.remove( this, type, fn );
1381 trigger: function( type, data ) {
1382 return this.each(function(){
1383 jQOld.event.trigger( type, data, this );
1386 toggle: function() {
1387 // Save reference to arguments for access in closure
1390 return this.click(function(e) {
1391 // Figure out which function to execute
1392 this.lastToggle = this.lastToggle == 0 ? 1 : 0;
1394 // Make sure that clicks stop
1397 // and execute the function
1398 return a[this.lastToggle].apply( this, [e] ) || false;
1401 hover: function(f,g) {
1403 // A private function for handling mouse 'hovering'
1404 function handleHover(e) {
1405 // Check if mouse(over|out) are still within the same parent element
1406 var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
1408 // Traverse up the tree
1409 while ( p && p != this ) try { p = p.parentNode } catch(e) { p = this; };
1411 // If we actually just moused on to a sub-element, ignore it
1412 if ( p == this ) return false;
1414 // Execute the right function
1415 return (e.type == "mouseover" ? f : g).apply(this, [e]);
1418 // Bind the function to the two event listeners
1419 return this.mouseover(handleHover).mouseout(handleHover);
1421 ready: function(f) {
1422 // If the DOM is already ready
1423 if ( jQOld.isReady )
1424 // Execute the function immediately
1425 f.apply( document, [jQOld] );
1427 // Otherwise, remember the function for later
1429 // Add the function to the wait list
1430 jQOld.readyList.push( function() { return f.apply(this, [jQOld]) } );
1439 * All the code that makes DOM Ready work nicely.
1444 // Handle when the DOM is ready
1446 // Make sure that the DOM is not already loaded
1447 if ( !jQOld.isReady ) {
1448 // Remember that the DOM is ready
1449 jQOld.isReady = true;
1451 // If there are functions bound, to execute
1452 if ( jQOld.readyList ) {
1453 // Execute all of them
1454 jQOld.each( jQOld.readyList, function(){
1455 this.apply( document );
1458 // Reset the list of functions
1459 jQOld.readyList = null;
1461 // Remove event lisenter to avoid memory leak
1462 if ( jQOld.browser.mozilla || jQOld.browser.opera )
1463 document.removeEventListener( "DOMContentLoaded", jQOld.ready, false );
1470 jQOld.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," +
1471 "mousedown,mouseup,mousemove,mouseover,mouseout,change,select," +
1472 "submit,keydown,keypress,keyup,error").split(","), function(i,o){
1474 // Handle event binding
1475 jQOld.fn[o] = function(f){
1476 return f ? this.bind(o, f) : this.trigger(o);
1481 // If Mozilla is used
1482 if ( jQOld.browser.mozilla || jQOld.browser.opera )
1483 // Use the handy event callback
1484 document.addEventListener( "DOMContentLoaded", jQOld.ready, false );
1486 // If IE is used, use the excellent hack by Matthias Miller
1487 // http://www.outofhanwell.com/blog/index.php?title=the_window_onload_problem_revisited
1488 else if ( jQOld.browser.msie ) {
1490 // Only works if you document.write() it
1491 document.write("<scr" + "ipt id=__ie_init defer=true " +
1492 "src=//:><\/script>");
1494 // Use the defer script hack
1495 var script = document.getElementById("__ie_init");
1497 // script does not exist if jQOld is loaded dynamically
1499 script.onreadystatechange = function() {
1500 if ( this.readyState != "complete" ) return;
1501 this.parentNode.removeChild( this );
1505 // Clear from memory
1508 // If Safari is used
1509 } else if ( jQOld.browser.safari )
1510 // Continually check to see if the document.readyState is valid
1511 jQOld.safariTimer = setInterval(function(){
1512 // loaded and complete are both valid states
1513 if ( document.readyState == "loaded" ||
1514 document.readyState == "complete" ) {
1516 // If either one are found, remove the timer
1517 clearInterval( jQOld.safariTimer );
1518 jQOld.safariTimer = null;
1520 // and execute any waiting functions
1525 // A fallback to window.onload, that will always work
1526 jQOld.event.add( window, "load", jQOld.ready );
1530 // Clean up after IE to avoid memory leaks
1531 if (jQOld.browser.msie)
1532 jQOld(window).one("unload", function() {
1533 var global = jQOld.event.global;
1534 for ( var type in global ) {
1535 var els = global[type], i = els.length;
1536 if ( i && type != 'unload' )
1538 jQOld.event.remove(els[i-1], type);
1543 loadIfModified: function( url, params, callback ) {
1544 this.load( url, params, callback, 1 );
1546 load: function( url, params, callback, ifModified ) {
1547 if ( jQOld.isFunction( url ) )
1548 return this.bind("load", url);
1550 callback = callback || function(){};
1552 // Default to a GET request
1555 // If the second parameter was provided
1557 // If it's a function
1558 if ( jQOld.isFunction( params ) ) {
1559 // We assume that it's the callback
1563 // Otherwise, build a param string
1565 params = jQOld.param( params );
1571 // Request the remote document
1576 ifModified: ifModified,
1577 complete: function(res, status){
1578 if ( status == "success" || !ifModified && status == "notmodified" )
1579 // Inject the HTML into all the matched elements
1580 self.attr("innerHTML", res.responseText)
1581 // Execute all the scripts inside of the newly-injected HTML
1584 .each( callback, [res.responseText, status, res] );
1586 callback.apply( self, [res.responseText, status, res] );
1591 serialize: function() {
1592 return jQOld.param( this );
1594 evalScripts: function() {
1595 return this.find("script").each(function(){
1597 jQOld.getScript( this.src );
1599 jQOld.globalEval( this.text || this.textContent || this.innerHTML || "" );
1605 // If IE is used, create a wrapper for the XMLHttpRequest object
1606 if ( !window.XMLHttpRequest )
1607 XMLHttpRequest = function(){
1608 return new ActiveXObject("Microsoft.XMLHTTP");
1611 // Attach a bunch of functions for handling common AJAX events
1613 jQOld.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","), function(i,o){
1614 jQOld.fn[o] = function(f){
1615 return this.bind(o, f);
1620 get: function( url, data, callback, type, ifModified ) {
1621 // shift arguments if data argument was ommited
1622 if ( jQOld.isFunction( data ) ) {
1632 ifModified: ifModified
1635 getIfModified: function( url, data, callback, type ) {
1636 return jQOld.get(url, data, callback, type, 1);
1638 getScript: function( url, callback ) {
1639 return jQOld.get(url, null, callback, "script");
1641 getJSON: function( url, data, callback ) {
1642 return jQOld.get(url, data, callback, "json");
1644 post: function( url, data, callback, type ) {
1645 if ( jQOld.isFunction( data ) ) {
1661 ajaxTimeout: function( timeout ) {
1662 jQOld.ajaxSettings.timeout = timeout;
1664 ajaxSetup: function( settings ) {
1665 jQOld.extend( jQOld.ajaxSettings, settings );
1672 contentType: "application/x-www-form-urlencoded",
1678 // Last-Modified header cache for next request
1680 ajax: function( s ) {
1681 // TODO introduce global settings, allowing the client to modify them for all requests, not only timeout
1682 s = jQOld.extend({}, jQOld.ajaxSettings, s);
1684 // if data available
1686 // convert data if not already a string
1687 if (s.processData && typeof s.data != "string")
1688 s.data = jQOld.param(s.data);
1689 // append data to url for get requests
1690 if( s.type.toLowerCase() == "get" ) {
1691 // "?" + data or "&" + data (in case there are already params)
1692 s.url += ((s.url.indexOf("?") > -1) ? "&" : "?") + s.data;
1693 // IE likes to send both get and post data, prevent this
1698 // Watch for a new set of requests
1699 if ( s.global && ! jQOld.active++ )
1700 jQOld.event.trigger( "ajaxStart" );
1702 var requestDone = false;
1704 // Create the request object
1705 var xml = new XMLHttpRequest();
1708 xml.open(s.type, s.url, s.async);
1710 // Set the correct header, if data is being sent
1712 xml.setRequestHeader("Content-Type", s.contentType);
1714 // Set the If-Modified-Since header, if ifModified mode.
1716 xml.setRequestHeader("If-Modified-Since",
1717 jQOld.lastModified[s.url] || "Thu, 01 Jan 1970 00:00:00 GMT" );
1719 // Set header so the called script knows that it's an XMLHttpRequest
1720 xml.setRequestHeader("X-Requested-With", "XMLHttpRequest");
1722 // Make sure the browser sends the right content length
1723 if ( xml.overrideMimeType )
1724 xml.setRequestHeader("Connection", "close");
1726 // Allow custom headers/mimetypes
1731 jQOld.event.trigger("ajaxSend", [xml, s]);
1733 // Wait for a response to come back
1734 var onreadystatechange = function(isTimeout){
1735 // The transfer is complete and the data is available, or the request timed out
1736 if ( xml && (xml.readyState == 4 || isTimeout == "timeout") ) {
1739 // clear poll interval
1741 clearInterval(ival);
1747 status = jQOld.httpSuccess( xml ) && isTimeout != "timeout" ?
1748 s.ifModified && jQOld.httpNotModified( xml, s.url ) ? "notmodified" : "success" : "error";
1749 // Make sure that the request was successful or notmodified
1750 if ( status != "error" ) {
1751 // Cache Last-Modified header, if ifModified mode.
1754 modRes = xml.getResponseHeader("Last-Modified");
1755 } catch(e) {} // swallow exception thrown by FF if header is not available
1757 if ( s.ifModified && modRes )
1758 jQOld.lastModified[s.url] = modRes;
1760 // process the data (runs the xml through httpData regardless of callback)
1761 var data = jQOld.httpData( xml, s.dataType );
1763 // If a local callback was specified, fire it and pass it the data
1765 s.success( data, status );
1767 // Fire the global callback
1769 jQOld.event.trigger( "ajaxSuccess", [xml, s] );
1771 jQOld.handleError(s, xml, status);
1774 jQOld.handleError(s, xml, status, e);
1777 // The request was completed
1779 jQOld.event.trigger( "ajaxComplete", [xml, s] );
1781 // Handle the global AJAX counter
1782 if ( s.global && ! --jQOld.active )
1783 jQOld.event.trigger( "ajaxStop" );
1787 s.complete(xml, status);
1789 // Stop memory leaks
1795 // don't attach the handler to the request, just poll it instead
1796 var ival = setInterval(onreadystatechange, 13);
1799 if ( s.timeout > 0 )
1800 setTimeout(function(){
1801 // Check to see if the request is still happening
1803 // Cancel the request
1807 onreadystatechange( "timeout" );
1815 jQOld.handleError(s, xml, null, e);
1818 // firefox 1.5 doesn't fire statechange for sync requests
1820 onreadystatechange();
1822 // return XMLHttpRequest to allow aborting the request etc.
1826 handleError: function( s, xml, status, e ) {
1827 // If a local callback was specified, fire it
1828 if ( s.error ) s.error( xml, status, e );
1830 // Fire the global callback
1832 jQOld.event.trigger( "ajaxError", [xml, s, e] );
1835 // Counter for holding the number of active queries
1838 // Determines if an XMLHttpRequest was successful or not
1839 httpSuccess: function( r ) {
1841 return !r.status && location.protocol == "file:" ||
1842 ( r.status >= 200 && r.status < 300 ) || r.status == 304 ||
1843 jQOld.browser.safari && r.status == undefined;
1848 // Determines if an XMLHttpRequest returns NotModified
1849 httpNotModified: function( xml, url ) {
1851 var xmlRes = xml.getResponseHeader("Last-Modified");
1853 // Firefox always returns 200. check Last-Modified date
1854 return xml.status == 304 || xmlRes == jQOld.lastModified[url] ||
1855 jQOld.browser.safari && xml.status == undefined;
1860 /* Get the data out of an XMLHttpRequest.
1861 * Return parsed XML if content-type header is "xml" and type is "xml" or omitted,
1862 * otherwise return plain text.
1863 * (String) data - The type of data that you're expecting back,
1864 * (e.g. "xml", "html", "script")
1866 httpData: function( r, type ) {
1867 var ct = r.getResponseHeader("content-type");
1868 var data = !type && ct && ct.indexOf("xml") >= 0;
1869 data = type == "xml" || data ? r.responseXML : r.responseText;
1871 // If the type is "script", eval it in global context
1872 if ( type == "script" )
1873 jQOld.globalEval( data );
1875 // Get the JavaScript object, if JSON is used.
1876 if ( type == "json" )
1877 eval( "data = " + data );
1879 // evaluate scripts within html
1880 if ( type == "html" )
1881 jQOld("<div>").html(data).evalScripts();
1886 // Serialize an array of form elements or a set of
1887 // key/values into a query string
1888 param: function( a ) {
1891 // If an array was passed in, assume that it is an array
1893 if ( a.constructor == Array || a.jquery )
1894 // Serialize the form elements
1895 jQOld.each( a, function(){
1896 s.push( encodeURIComponent(this.name) + "=" + encodeURIComponent( this.value ) );
1899 // Otherwise, assume that it's an object of key/value pairs
1901 // Serialize the key/values
1903 // If the value is an array then the key names need to be repeated
1904 if ( a[j] && a[j].constructor == Array )
1905 jQOld.each( a[j], function(){
1906 s.push( encodeURIComponent(j) + "=" + encodeURIComponent( this ) );
1909 s.push( encodeURIComponent(j) + "=" + encodeURIComponent( a[j] ) );
1911 // Return the resulting serialization
1915 // evalulates a script in global context
1916 // not reliable for safari
1917 globalEval: function( data ) {
1918 if ( window.execScript )
1919 window.execScript( data );
1920 else if ( jQOld.browser.safari )
1921 // safari doesn't provide a synchronous global eval
1922 window.setTimeout( data, 0 );
1924 eval.call( window, data );
1930 show: function(speed,callback){
1931 var hidden = this.filter(":hidden");
1934 height: "show", width: "show", opacity: "show"
1935 }, speed, callback) :
1937 hidden.each(function(){
1938 this.style.display = this.oldblock ? this.oldblock : "";
1939 if ( jQOld.css(this,"display") == "none" )
1940 this.style.display = "block";
1945 hide: function(speed,callback){
1946 var visible = this.filter(":visible");
1949 height: "hide", width: "hide", opacity: "hide"
1950 }, speed, callback) :
1952 visible.each(function(){
1953 this.oldblock = this.oldblock || jQOld.css(this,"display");
1954 if ( this.oldblock == "none" )
1955 this.oldblock = "block";
1956 this.style.display = "none";
1961 // Save the old toggle function
1962 _toggle: jQOld.fn.toggle,
1963 toggle: function( fn, fn2 ){
1964 var args = arguments;
1965 return jQOld.isFunction(fn) && jQOld.isFunction(fn2) ?
1966 this._toggle( fn, fn2 ) :
1967 this.each(function(){
1968 jQOld(this)[ jQOld(this).is(":hidden") ? "show" : "hide" ]
1969 .apply( jQOld(this), args );
1972 slideDown: function(speed,callback){
1973 return this.animate({height: "show"}, speed, callback);
1975 slideUp: function(speed,callback){
1976 return this.animate({height: "hide"}, speed, callback);
1978 slideToggle: function(speed, callback){
1979 return this.each(function(){
1980 var state = jQOld(this).is(":hidden") ? "show" : "hide";
1981 jQOld(this).animate({height: state}, speed, callback);
1984 fadeIn: function(speed, callback){
1985 return this.animate({opacity: "show"}, speed, callback);
1987 fadeOut: function(speed, callback){
1988 return this.animate({opacity: "hide"}, speed, callback);
1990 fadeTo: function(speed,to,callback){
1991 return this.animate({opacity: to}, speed, callback);
1993 animate: function( prop, speed, easing, callback ) {
1994 return this.queue(function(){
1996 this.curAnim = jQOld.extend({}, prop);
1997 var opt = jQOld.speed(speed, easing, callback);
1999 for ( var p in prop ) {
2000 var e = new jQOld.fx( this, opt, p );
2001 if ( prop[p].constructor == Number )
2002 e.custom( e.cur(), prop[p] );
2004 e[ prop[p] ]( prop );
2009 queue: function(type,fn){
2015 return this.each(function(){
2019 if ( !this.queue[type] )
2020 this.queue[type] = [];
2022 this.queue[type].push( fn );
2024 if ( this.queue[type].length == 1 )
2033 speed: function(speed, easing, fn) {
2034 var opt = speed && speed.constructor == Object ? speed : {
2035 complete: fn || !fn && easing ||
2036 jQOld.isFunction( speed ) && speed,
2038 easing: fn && easing || easing && easing.constructor != Function && easing
2041 opt.duration = (opt.duration && opt.duration.constructor == Number ?
2043 { slow: 600, fast: 200 }[opt.duration]) || 400;
2046 opt.old = opt.complete;
2047 opt.complete = function(){
2048 jQOld.dequeue(this, "fx");
2049 if ( jQOld.isFunction( opt.old ) )
2050 opt.old.apply( this );
2060 dequeue: function(elem,type){
2061 type = type || "fx";
2063 if ( elem.queue && elem.queue[type] ) {
2065 elem.queue[type].shift();
2067 // Get next function
2068 var f = elem.queue[type][0];
2070 if ( f ) f.apply( elem );
2075 * I originally wrote fx() as a clone of moo.fx and in the process
2076 * of making it small in size the code became illegible to sane
2077 * people. You've been warned.
2080 fx: function( elem, options, prop ){
2087 // Store display property
2088 var oldDisplay = jQOld.css(elem, "display");
2090 // Make sure that nothing sneaks out
2091 y.overflow = "hidden";
2093 // Simple function for setting a style value
2096 options.step.apply( elem, [ z.now ] );
2098 if ( prop == "opacity" )
2099 jQOld.attr(y, "opacity", z.now); // Let attr handle opacity
2100 else if ( parseInt(z.now) ) // My hate for IE will never die
2101 y[prop] = parseInt(z.now) + "px";
2103 y.display = "block"; // Set display property to block for animation
2106 // Figure out the maximum number to run to
2108 return parseFloat( jQOld.css(elem,prop) );
2111 // Get the current size
2113 var r = parseFloat( jQOld.curCSS(elem, prop) );
2114 return r && r > -10000 ? r : z.max();
2117 // Start an animation from one number to another
2118 z.custom = function(from,to){
2119 z.startTime = (new Date()).getTime();
2123 z.timer = setInterval(function(){
2128 // Simple 'show' function
2129 z.show = function(){
2130 if ( !elem.orig ) elem.orig = {};
2132 // Remember where we started, so that we can go back to it later
2133 elem.orig[prop] = this.cur();
2135 options.show = true;
2137 // Begin the animation
2138 z.custom(0, elem.orig[prop]);
2140 // Stupid IE, look what you made me do
2141 if ( prop != "opacity" )
2145 // Simple 'hide' function
2146 z.hide = function(){
2147 if ( !elem.orig ) elem.orig = {};
2149 // Remember where we started, so that we can go back to it later
2150 elem.orig[prop] = this.cur();
2152 options.hide = true;
2154 // Begin the animation
2155 z.custom(elem.orig[prop], 0);
2158 //Simple 'toggle' function
2159 z.toggle = function() {
2160 if ( !elem.orig ) elem.orig = {};
2162 // Remember where we started, so that we can go back to it later
2163 elem.orig[prop] = this.cur();
2165 if(oldDisplay == "none") {
2166 options.show = true;
2168 // Stupid IE, look what you made me do
2169 if ( prop != "opacity" )
2172 // Begin the animation
2173 z.custom(0, elem.orig[prop]);
2175 options.hide = true;
2177 // Begin the animation
2178 z.custom(elem.orig[prop], 0);
2182 // Each step of an animation
2183 z.step = function(firstNum, lastNum){
2184 var t = (new Date()).getTime();
2186 if (t > options.duration + z.startTime) {
2188 clearInterval(z.timer);
2194 if (elem.curAnim) elem.curAnim[ prop ] = true;
2197 for ( var i in elem.curAnim )
2198 if ( elem.curAnim[i] !== true )
2202 // Reset the overflow
2205 // Reset the display
2206 y.display = oldDisplay;
2207 if (jQOld.css(elem, "display") == "none")
2208 y.display = "block";
2210 // Hide the element if the "hide" operation was done
2214 // Reset the properties, if the item has been hidden or shown
2215 if ( options.hide || options.show )
2216 for ( var p in elem.curAnim )
2218 jQOld.attr(y, p, elem.orig[p]);
2223 // If a callback was provided, execute it
2224 if ( done && jQOld.isFunction( options.complete ) )
2225 // Execute the complete function
2226 options.complete.apply( elem );
2228 var n = t - this.startTime;
2229 // Figure out where in the animation we are and set the number
2230 var p = n / options.duration;
2232 // If the easing function exists, then use it
2233 z.now = options.easing && jQOld.easing[options.easing] ?
2234 jQOld.easing[options.easing](p, n, firstNum, (lastNum-firstNum), options.duration) :
2235 // else use default linear easing
2236 ((-Math.cos(p*Math.PI)/2) + 0.5) * (lastNum-firstNum) + firstNum;
2238 // Perform the next step of the animation