Changeset 15678 for branches/feature-module-update/html/js/jquery.js
- Timestamp:
- 2007/09/11 20:40:08 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/feature-module-update/html/js/jquery.js
r15652 r15678 1 1 (function(){ 2 2 /* 3 * jQuery 1. 1.4- New Wave Javascript3 * jQuery 1.2 - New Wave Javascript 4 4 * 5 5 * Copyright (c) 2007 John Resig (jquery.com) … … 7 7 * and GPL (GPL-LICENSE.txt) licenses. 8 8 * 9 * $Date: 2007-0 8-23 21:49:27 -0400 (Thu, 23 Aug2007) $10 * $Rev: 2862$9 * $Date: 2007-09-10 15:45:49 -0400 (Mon, 10 Sep 2007) $ 10 * $Rev: 3219 $ 11 11 */ 12 12 13 // Map over jQuery in case of overwrite 13 14 if ( typeof jQuery != "undefined" ) … … 42 43 // HANDLE: $(html) -> $(array) 43 44 if ( m[1] ) 44 a = jQuery.clean( [ m[1] ] );45 a = jQuery.clean( [ m[1] ], c ); 45 46 46 47 // HANDLE: $("#id") … … 81 82 [ a ] ); 82 83 }, 83 jquery: "1.1.4", 84 85 jquery: "1.2", 84 86 85 87 size: function() { … … 98 100 this[num]; 99 101 }, 102 100 103 pushStack: function( a ) { 101 104 var ret = jQuery(a); … … 103 106 return ret; 104 107 }, 108 105 109 setArray: function( a ) { 106 110 this.length = 0; … … 108 112 return this; 109 113 }, 114 110 115 each: function( fn, args ) { 111 116 return jQuery.each( this, fn, args ); 112 117 }, 118 113 119 index: function( obj ) { 114 120 var pos = -1; … … 161 167 }, 162 168 163 wrap: function() { 164 // The elements to wrap the target around 165 var a, args = arguments; 166 167 // Wrap each of the matched elements individually 169 wrapAll: function(html) { 170 if ( this[0] ) 171 // The elements to wrap the target around 172 jQuery(html, this[0].ownerDocument) 173 .clone() 174 .insertBefore(this[0]) 175 .map(function(){ 176 var elem = this; 177 while ( elem.firstChild ) 178 elem = elem.firstChild; 179 return elem; 180 }) 181 .append(this); 182 183 return this; 184 }, 185 186 wrapInner: function(html) { 168 187 return this.each(function(){ 169 if ( !a ) 170 a = jQuery.clean(args, this.ownerDocument); 171 172 // Clone the structure that we're using to wrap 173 var b = a[0].cloneNode(true); 174 175 // Insert it before the element to be wrapped 176 this.parentNode.insertBefore( b, this ); 177 178 // Find the deepest point in the wrap structure 179 while ( b.firstChild ) 180 b = b.firstChild; 181 182 // Move the matched element to within the wrap structure 183 b.appendChild( this ); 188 jQuery(this).contents().wrapAll(html); 184 189 }); 185 190 }, 191 192 wrap: function(html) { 193 return this.each(function(){ 194 jQuery(this).wrapAll(html); 195 }); 196 }, 197 186 198 append: function() { 187 199 return this.domManip(arguments, true, 1, function(a){ … … 189 201 }); 190 202 }, 203 191 204 prepend: function() { 192 205 return this.domManip(arguments, true, -1, function(a){ … … 194 207 }); 195 208 }, 209 196 210 before: function() { 197 211 return this.domManip(arguments, false, 1, function(a){ … … 199 213 }); 200 214 }, 215 201 216 after: function() { 202 217 return this.domManip(arguments, false, -1, function(a){ … … 204 219 }); 205 220 }, 221 206 222 end: function() { 207 223 return this.prevObject || jQuery([]); 208 224 }, 225 209 226 find: function(t) { 210 227 var data = jQuery.map(this, function(a){ return jQuery.find(t,a); }); … … 212 229 jQuery.unique( data ) : data ); 213 230 }, 214 clone: function(deep) { 215 deep = deep != undefined ? deep : true; 216 var $this = this.add(this.find("*")); 217 if (jQuery.browser.msie) { 218 // Need to remove events on the element and its descendants 219 $this.each(function() { 220 this._$events = {}; 221 for (var type in this.$events) 222 this._$events[type] = jQuery.extend({},this.$events[type]); 223 }).unbind(); 224 } 225 231 232 clone: function(events) { 226 233 // Do the clone 227 var r = this.pushStack( jQuery.map( this, function(a){228 return a.cloneNode( deep);229 }) );230 231 if ( jQuery.browser.msie) {232 $this.each(function() {233 // Add the events back to the original and its descendants 234 var events = this._$events;235 for (var type in events)236 for (var handler in events[type])237 jQuery.event.add(this, type, events[type][handler], events[type][handler].data);238 this._$events = null;234 var ret = this.map(function(){ 235 return this.outerHTML ? jQuery(this.outerHTML)[0] : this.cloneNode(true); 236 }); 237 238 if (events === true) { 239 var clone = ret.find("*").andSelf(); 240 241 this.find("*").andSelf().each(function(i) { 242 var events = jQuery.data(this, "events"); 243 for ( var type in events ) 244 for ( var handler in events[type] ) 245 jQuery.event.add(clone[i], type, events[type][handler], events[type][handler].data); 239 246 }); 240 247 } 241 248 242 // copy form values over243 if (deep) {244 var inputs = r.add(r.find('*')).filter('select,input[@type=checkbox]');245 $this.filter('select,input[@type=checkbox]').each(function(i) {246 if (this.selectedIndex)247 inputs[i].selectedIndex = this.selectedIndex;248 if (this.checked)249 inputs[i].checked = true;250 });251 }252 253 249 // Return the cloned set 254 return r ;250 return ret; 255 251 }, 256 252 … … 287 283 ); 288 284 }, 285 289 286 is: function(expr) { 290 287 return expr ? jQuery.multiFilter(expr,this).length > 0 : false; 291 288 }, 292 289 290 hasClass: function(expr) { 291 return this.is("." + expr); 292 }, 293 293 294 val: function( val ) { 294 return val == undefined ? 295 ( this.length ? this[0].value : null ) : 296 this.attr( "value", val ); 297 }, 298 295 if ( val == undefined ) { 296 if ( this.length ) { 297 var elem = this[0]; 298 299 // We need to handle select boxes special 300 if ( jQuery.nodeName(elem, "select") ) { 301 var index = elem.selectedIndex, 302 a = [], 303 options = elem.options, 304 one = elem.type == "select-one"; 305 306 // Nothing was selected 307 if ( index < 0 ) 308 return null; 309 310 // Loop through all the selected options 311 for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { 312 var option = options[i]; 313 if ( option.selected ) { 314 // Get the specifc value for the option 315 var val = jQuery.browser.msie && !option.attributes["value"].specified ? option.text : option.value; 316 317 // We don't need an array for one selects 318 if ( one ) 319 return val; 320 321 // Multi-Selects return an array 322 a.push(val); 323 } 324 } 325 326 return a; 327 328 // Everything else, we just grab the value 329 } else 330 return this[0].value.replace(/\r/g, ""); 331 } 332 } else 333 return this.each(function(){ 334 if ( val.constructor == Array && /radio|checkbox/.test(this.type) ) 335 this.checked = (jQuery.inArray(this.value, val) >= 0 || 336 jQuery.inArray(this.name, val) >= 0); 337 else if ( jQuery.nodeName(this, "select") ) { 338 var tmp = val.constructor == Array ? val : [val]; 339 340 jQuery("option", this).each(function(){ 341 this.selected = (jQuery.inArray(this.value, tmp) >= 0 || 342 jQuery.inArray(this.text, tmp) >= 0); 343 }); 344 345 if ( !tmp.length ) 346 this.selectedIndex = -1; 347 } else 348 this.value = val; 349 }); 350 }, 351 299 352 html: function( val ) { 300 353 return val == undefined ? … … 303 356 }, 304 357 358 replaceWith: function( val ) { 359 return this.after( val ).remove(); 360 }, 361 305 362 slice: function() { 306 363 return this.pushStack( Array.prototype.slice.apply( this, arguments ) ); 307 364 }, 308 domManip: function(args, table, dir, fn){ 365 366 map: function(fn) { 367 return this.pushStack(jQuery.map( this, function(elem,i){ 368 return fn.call( elem, i, elem ); 369 })); 370 }, 371 372 andSelf: function() { 373 return this.add( this.prevObject ); 374 }, 375 376 domManip: function(args, table, dir, fn) { 309 377 var clone = this.length > 1, a; 310 378 … … 374 442 }; 375 443 444 var expando = "jQuery" + (new Date()).getTime(), uuid = 0, win = {}; 445 376 446 jQuery.extend({ 377 447 noConflict: function(deep) { … … 413 483 return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase(); 414 484 }, 485 486 cache: {}, 487 488 data: function( elem, name, data ) { 489 elem = elem == window ? win : elem; 490 491 var id = elem[ expando ]; 492 493 // Compute a unique ID for the element 494 if ( !id ) 495 id = elem[ expando ] = ++uuid; 496 497 // Only generate the data cache if we're 498 // trying to access or manipulate it 499 if ( name && !jQuery.cache[ id ] ) 500 jQuery.cache[ id ] = {}; 501 502 // Prevent overriding the named cache with undefined values 503 if ( data != undefined ) 504 jQuery.cache[ id ][ name ] = data; 505 506 // Return the named cache data, or the ID for the element 507 return name ? jQuery.cache[ id ][ name ] : id; 508 }, 509 510 removeData: function( elem, name ) { 511 elem = elem == window ? win : elem; 512 513 var id = elem[ expando ]; 514 515 // If we want to remove a specific section of the element's data 516 if ( name ) { 517 if ( jQuery.cache[ id ] ) { 518 // Remove the section of cache data 519 delete jQuery.cache[ id ][ name ]; 520 521 // If we've removed all the data, remove the element's cache 522 name = ""; 523 for ( name in jQuery.cache[ id ] ) break; 524 if ( !name ) 525 jQuery.removeData( elem ); 526 } 527 528 // Otherwise, we want to remove all of the element's data 529 } else { 530 // Clean up the element expando 531 try { 532 delete elem[ expando ]; 533 } catch(e){ 534 // IE has trouble directly removing the expando 535 // but it's ok with using removeAttribute 536 if ( elem.removeAttribute ) 537 elem.removeAttribute( expando ); 538 } 539 540 // Completely remove the data cache 541 delete jQuery.cache[ id ]; 542 } 543 }, 544 415 545 // args is for internal usage only 416 546 each: function( obj, fn, args ) { … … 472 602 } 473 603 }, 604 474 605 swap: function(e,o,f) { 475 606 for ( var i in o ) { … … 589 720 var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase();}); 590 721 ret = elem.currentStyle[prop] || elem.currentStyle[newProp]; 722 723 // From the awesome hack by Dean Edwards 724 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 725 726 // If we're not dealing with a regular pixel number 727 // but a number that has a weird ending, we need to convert it to pixels 728 if ( !/^\d+(px)?$/i.test(ret) && /^\d/.test(ret) ) { 729 var style = elem.style.left; 730 var runtimeStyle = elem.runtimeStyle.left; 731 elem.runtimeStyle.left = elem.currentStyle.left; 732 elem.style.left = ret || 0; 733 ret = elem.style.pixelLeft + "px"; 734 elem.style.left = style; 735 elem.runtimeStyle.left = runtimeStyle; 736 } 591 737 } 592 738 … … 606 752 // Convert html string into DOM nodes 607 753 if ( typeof arg == "string" ) { 754 // Fix "XHTML"-style tags in all browsers 755 arg = arg.replace(/(<(\w+)[^>]*?)\/>/g, function(m, all, tag){ 756 return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area)$/i)? m : all+"></"+tag+">"; 757 }); 758 608 759 // Trim whitespace, otherwise indexOf won't work as expected 609 760 var s = jQuery.trim(arg).toLowerCase(), div = doc.createElement("div"), tb = []; … … 701 852 else if ( elem.tagName ) { 702 853 703 if ( value != undefined ) elem.setAttribute( name, value ); 854 if ( value != undefined ) { 855 if ( name == "type" && jQuery.nodeName(elem,"input") && elem.parentNode ) 856 throw "type property can't be changed"; 857 elem.setAttribute( name, value ); 858 } 859 704 860 if ( jQuery.browser.msie && /href|src/.test(name) && !jQuery.isXMLDoc(elem) ) 705 861 return elem.getAttribute( name, 2 ); 862 706 863 return elem.getAttribute( name ); 707 864 … … 728 885 } 729 886 }, 887 730 888 trim: function(t){ 731 889 return (t||"").replace(/^\s+|\s+$/g, ""); … … 751 909 return -1; 752 910 }, 911 753 912 merge: function(first, second) { 754 913 // We have to loop this way because IE & Opera overwrite the length … … 767 926 return first; 768 927 }, 928 769 929 unique: function(first) { 770 var r = [], num = jQuery.mergeNum++;930 var r = [], done = {}; 771 931 772 932 try { 773 for ( var i = 0, fl = first.length; i < fl; i++ ) 774 if ( num != first[i].mergeNum ) { 775 first[i].mergeNum = num; 933 for ( var i = 0, fl = first.length; i < fl; i++ ) { 934 var id = jQuery.data(first[i]); 935 if ( !done[id] ) { 936 done[id] = true; 776 937 r.push(first[i]); 777 938 } 939 } 778 940 } catch(e) { 779 941 r = first; … … 783 945 }, 784 946 785 mergeNum: 0,786 947 grep: function(elems, fn, inv) { 787 948 // If a string is passed in for the function, make a function … … 800 961 return result; 801 962 }, 963 802 964 map: function(elems, fn) { 803 965 // If a string is passed in for the function, make a function … … 822 984 } 823 985 }); 824 825 /* 826 * Whether the W3C compliant box model is being used. 827 * 828 * @property 829 * @name $.boxModel 830 * @type Boolean 831 * @cat JavaScript 832 */ 986 833 987 var userAgent = navigator.userAgent.toLowerCase(); 834 988 … … 869 1023 jQuery.each({ 870 1024 parent: "a.parentNode", 871 parents: "jQuery. parents(a)",1025 parents: "jQuery.dir(a,'parentNode')", 872 1026 next: "jQuery.nth(a,2,'nextSibling')", 873 1027 prev: "jQuery.nth(a,2,'previousSibling')", 1028 nextAll: "jQuery.dir(a,'nextSibling')", 1029 prevAll: "jQuery.dir(a,'previousSibling')", 874 1030 siblings: "jQuery.sibling(a.parentNode.firstChild,a)", 875 children: "jQuery.sibling(a.firstChild)" 1031 children: "jQuery.sibling(a.firstChild)", 1032 contents: "jQuery.nodeName(a,'iframe')?a.contentDocument||a.contentWindow.document:jQuery.makeArray(a.childNodes)" 876 1033 }, function(i,n){ 877 1034 jQuery.fn[ i ] = function(a) { … … 887 1044 prependTo: "prepend", 888 1045 insertBefore: "before", 889 insertAfter: "after" 1046 insertAfter: "after", 1047 replaceAll: "replaceWith" 890 1048 }, function(i,n){ 891 1049 jQuery.fn[ i ] = function(){ … … 913 1071 }, 914 1072 remove: function(a){ 915 if ( !a || jQuery.filter( a, [this] ).r.length ) 1073 if ( !a || jQuery.filter( a, [this] ).r.length ) { 1074 jQuery.removeData( this ); 916 1075 this.parentNode.removeChild( this ); 1076 } 917 1077 }, 918 1078 empty: function() { 1079 // Clean up the cache 1080 jQuery("*", this).each(function(){ jQuery.removeData(this); }); 1081 919 1082 while ( this.firstChild ) 920 1083 this.removeChild( this.firstChild ); … … 926 1089 }); 927 1090 928 // DEPRECATED 929 jQuery.each( [ "eq", "lt", "gt", "contains" ], function(i,n){ 930 jQuery.fn[ n ] = function(num,fn) { 931 return this.filter( ":" + n + "(" + num + ")", fn ); 932 }; 933 }); 934 935 jQuery.each( [ "height", "width" ], function(i,n){ 1091 jQuery.each( [ "Height", "Width" ], function(i,name){ 1092 var n = name.toLowerCase(); 1093 936 1094 jQuery.fn[ n ] = function(h) { 937 return h == undefined ? 938 ( this.length ? jQuery.css( this[0], n ) : null ) : 939 this.css( n, h.constructor == String ? h : h + "px" ); 1095 return this[0] == window ? 1096 jQuery.browser.safari && self["inner" + name] || 1097 jQuery.boxModel && Math.max(document.documentElement["client" + name], document.body["client" + name]) || 1098 document.body["client" + name] : 1099 1100 this[0] == document ? 1101 Math.max( document.body["scroll" + name], document.body["offset" + name] ) : 1102 1103 h == undefined ? 1104 ( this.length ? jQuery.css( this[0], n ) : null ) : 1105 this.css( n, h.constructor == String ? h : h + "px" ); 940 1106 }; 941 1107 }); … … 944 1110 "(?:[\\w*_-]|\\\\.)" : 945 1111 "(?:[\\w\u0128-\uFFFF*_-]|\\\\.)", 946 quickChild = new RegExp("^ [/>]\\s*(" + chars + "+)"),1112 quickChild = new RegExp("^>\\s*(" + chars + "+)"), 947 1113 quickID = new RegExp("^(" + chars + "+)(#)(" + chars + "+)"), 948 1114 quickClass = new RegExp("^([#.]?)(" + chars + "*)"); … … 998 1164 999 1165 // :has() 1000 has: "jQuery.find(m[3],a).length" 1001 }, 1002 // DEPRECATED 1003 "[": "jQuery.find(m[2],a).length" 1166 has: "jQuery.find(m[3],a).length", 1167 1168 // :header 1169 header: "/h\\d/i.test(a.nodeName)", 1170 1171 // :animated 1172 animated: "jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;}).length" 1173 } 1004 1174 }, 1005 1175 … … 1007 1177 parse: [ 1008 1178 // Match: [@value='test'], [@foo] 1009 /^\[ *(@)([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/, 1010 1011 // DEPRECATED 1012 // Match: [div], [div p] 1013 /^(\[)\s*(.*?(\[.*?\])?[^[]*?)\s*\]/, 1179 /^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/, 1014 1180 1015 1181 // Match: :contains('foo') … … 1032 1198 return cur; 1033 1199 }, 1200 1034 1201 find: function( t, context ) { 1035 1202 // Quickly handle non-string expressions … … 1043 1210 // Set the correct context (if none is provided) 1044 1211 context = context || document; 1045 1046 // DEPRECATED1047 // Handle the common XPath // expression1048 if ( !t.indexOf("//") ) {1049 //context = context.documentElement;1050 t = t.substr(2,t.length);1051 1052 // DEPRECATED1053 // And the / root expression1054 } else if ( !t.indexOf("/") && !context.ownerDocument ) {1055 context = context.documentElement;1056 t = t.substr(1,t.length);1057 if ( t.indexOf("/") >= 1 )1058 t = t.substr(t.indexOf("/"),t.length);1059 }1060 1212 1061 1213 // Initialize the search … … 1068 1220 last = t; 1069 1221 1070 // DEPRECATED 1071 t = jQuery.trim(t).replace( /^\/\//, "" ); 1222 t = jQuery.trim(t); 1072 1223 1073 1224 var foundToken = false; … … 1092 1243 foundToken = true; 1093 1244 } else { 1094 // (.. and /) DEPRECATED 1095 re = /^((\/?\.\.)|([>\/+~]))\s*(\w*)/i; 1245 re = /^([>+~])\s*(\w*)/i; 1096 1246 1097 1247 if ( (m = re.exec(t)) != null ) { 1098 1248 r = []; 1099 1249 1100 var nodeName = m[ 4], mergeNum = jQuery.mergeNum++;1250 var nodeName = m[2], merge = {}; 1101 1251 m = m[1]; 1102 1252 1103 for ( var j = 0, rl = ret.length; j < rl; j++ ) 1104 if ( m.indexOf("..") < 0 ) { 1105 var n = m == "~" || m == "+" ? ret[j].nextSibling : ret[j].firstChild; 1106 for ( ; n; n = n.nextSibling ) 1107 if ( n.nodeType == 1 ) { 1108 if ( m == "~" && n.mergeNum == mergeNum ) break; 1109 1110 if (!nodeName || n.nodeName.toUpperCase() == nodeName.toUpperCase() ) { 1111 if ( m == "~" ) n.mergeNum = mergeNum; 1112 r.push( n ); 1113 } 1114 1115 if ( m == "+" ) break; 1253 for ( var j = 0, rl = ret.length; j < rl; j++ ) { 1254 var n = m == "~" || m == "+" ? ret[j].nextSibling : ret[j].firstChild; 1255 for ( ; n; n = n.nextSibling ) 1256 if ( n.nodeType == 1 ) { 1257 var id = jQuery.data(n); 1258 1259 if ( m == "~" && merge[id] ) break; 1260 1261 if (!nodeName || n.nodeName.toUpperCase() == nodeName.toUpperCase() ) { 1262 if ( m == "~" ) merge[id] = true; 1263 r.push( n ); 1116 1264 } 1117 // DEPRECATED 1118 } else 1119 r.push( ret[j].parentNode ); 1265 1266 if ( m == "+" ) break; 1267 } 1268 } 1120 1269 1121 1270 ret = r; … … 1182 1331 for ( var i = 0; ret[i]; i++ ) { 1183 1332 // Grab the tag name being searched for 1184 var tag = m[1] != "" || m[0] == "" ? "*" : m[2];1333 var tag = m[1] == "#" && m[3] ? m[3] : m[1] != "" || m[0] == "" ? "*" : m[2]; 1185 1334 1186 1335 // Handle IE7 being really dumb about <object>s … … 1285 1434 r = jQuery.classFilter(r, m[2], not); 1286 1435 1287 else if ( m[1] == " @" ) {1436 else if ( m[1] == "[" ) { 1288 1437 var tmp = [], type = m[3]; 1289 1438 … … 1307 1456 // We can get a speed boost by handling nth-child here 1308 1457 } else if ( m[1] == ":" && m[2] == "nth-child" ) { 1309 var num = jQuery.mergeNum++, tmp = [],1458 var merge = {}, tmp = [], 1310 1459 test = /(\d*)n\+?(\d*)/.exec( 1311 1460 m[3] == "even" && "2n" || m[3] == "odd" && "2n+1" || … … 1314 1463 1315 1464 for ( var i = 0, rl = r.length; i < rl; i++ ) { 1316 var node = r[i], parentNode = node.parentNode ;1317 1318 if ( num != parentNode.mergeNum) {1465 var node = r[i], parentNode = node.parentNode, id = jQuery.data(parentNode); 1466 1467 if ( !merge[id] ) { 1319 1468 var c = 1; 1320 1469 … … 1323 1472 n.nodeIndex = c++; 1324 1473 1325 parentNode.mergeNum = num;1474 merge[id] = true; 1326 1475 } 1327 1476 … … 1358 1507 return { r: r, t: t }; 1359 1508 }, 1360 parents: function( elem ){ 1509 1510 dir: function( elem, dir ){ 1361 1511 var matched = []; 1362 var cur = elem .parentNode;1512 var cur = elem[dir]; 1363 1513 while ( cur && cur != document ) { 1364 matched.push( cur ); 1365 cur = cur.parentNode; 1514 if ( cur.nodeType == 1 ) 1515 matched.push( cur ); 1516 cur = cur[dir]; 1366 1517 } 1367 1518 return matched; 1368 1519 }, 1520 1369 1521 nth: function(cur,result,dir,elem){ 1370 1522 result = result || 1; … … 1377 1529 return cur; 1378 1530 }, 1531 1379 1532 sibling: function( n, elem ) { 1380 1533 var r = []; … … 1402 1555 if ( jQuery.browser.msie && element.setInterval != undefined ) 1403 1556 element = window; 1404 1557 1405 1558 // Make sure that the function being executed has a unique ID 1406 1559 if ( !handler.guid ) … … 1409 1562 // if data is passed, bind to handler 1410 1563 if( data != undefined ) { 1411 // Create temporary function pointer to original handler1564 // Create temporary function pointer to original handler 1412 1565 var fn = handler; 1413 1566 … … 1425 1578 } 1426 1579 1580 // Namespaced event handlers 1581 var parts = type.split("."); 1582 type = parts[0]; 1583 handler.type = parts[1]; 1584 1427 1585 // Init the element's event structure 1428 if (!element.$events) 1429 element.$events = {}; 1586 var events = jQuery.data(element, "events") || jQuery.data(element, "events", {}); 1430 1587 1431 if (!element.$handle) 1432 element.$handle = function() { 1433 // returned undefined or false 1434 var val; 1435 1436 // Handle the second event of a trigger and when 1437 // an event is called after a page has unloaded 1438 if ( typeof jQuery == "undefined" || jQuery.event.triggered ) 1439 return val; 1440 1441 val = jQuery.event.handle.apply(element, arguments); 1442 1588 var handle = jQuery.data(element, "handle", function(){ 1589 // returned undefined or false 1590 var val; 1591 1592 // Handle the second event of a trigger and when 1593 // an event is called after a page has unloaded 1594 if ( typeof jQuery == "undefined" || jQuery.event.triggered ) 1443 1595 return val; 1444 }; 1596 1597 val = jQuery.event.handle.apply(element, arguments); 1598 1599 return val; 1600 }); 1445 1601 1446 1602 // Get the current list of functions bound to this event 1447 var handlers = e lement.$events[type];1603 var handlers = events[type]; 1448 1604 1449 1605 // Init the event handler queue 1450 1606 if (!handlers) { 1451 handlers = e lement.$events[type] = {};1607 handlers = events[type] = {}; 1452 1608 1453 1609 // And bind the global event handler to the element 1454 1610 if (element.addEventListener) 1455 element.addEventListener(type, element.$handle, false);1611 element.addEventListener(type, handle, false); 1456 1612 else 1457 element.attachEvent("on" + type, element.$handle);1613 element.attachEvent("on" + type, handle); 1458 1614 } 1459 1615 … … 1470 1626 // Detach an event or set of events from an element 1471 1627 remove: function(element, type, handler) { 1472 var events = element.$events, ret, index; 1628 var events = jQuery.data(element, "events"), ret, index; 1629 1630 // Namespaced event handlers 1631 if ( typeof type == "string" ) { 1632 var parts = type.split("."); 1633 type = parts[0]; 1634 } 1473 1635 1474 1636 if ( events ) { … … 1490 1652 // remove all handlers for the given type 1491 1653 else 1492 for ( handler in element.$events[type] ) 1493 delete events[type][handler]; 1654 for ( handler in events[type] ) 1655 // Handle the removal of namespaced events 1656 if ( !parts[1] || events[type][handler].type == parts[1] ) 1657 delete events[type][handler]; 1494 1658 1495 1659 // remove generic event handler if no more handlers exist … … 1497 1661 if ( !ret ) { 1498 1662 if (element.removeEventListener) 1499 element.removeEventListener(type, element.$handle, false);1663 element.removeEventListener(type, jQuery.data(element, "handle"), false); 1500 1664 else 1501 element.detachEvent("on" + type, element.$handle);1665 element.detachEvent("on" + type, jQuery.data(element, "handle")); 1502 1666 ret = null; 1503 1667 delete events[type]; … … 1507 1671 // Remove the expando if it's no longer used 1508 1672 for ( ret in events ) break; 1509 if ( !ret ) 1510 element.$handle = element.$events = null; 1511 } 1512 }, 1513 1514 trigger: function(type, data, element) { 1673 if ( !ret ) { 1674 jQuery.removeData( element, "events" ); 1675 jQuery.removeData( element, "handle" ); 1676 } 1677 } 1678 }, 1679 1680 trigger: function(type, data, element, donative, extra) { 1515 1681 // Clone the incoming data, if any 1516 1682 data = jQuery.makeArray(data || []); … … 1524 1690 // Handle triggering a single element 1525 1691 } else { 1526 var val, ret, fn = jQuery.isFunction( element[ type ] || null ); 1692 var val, ret, fn = jQuery.isFunction( element[ type ] || null ), 1693 // Check to see if we need to provide a fake event, or not 1694 evt = !data[0] || !data[0].preventDefault; 1527 1695 1528 1696 // Pass along a fake event 1529 data.unshift( this.fix({ type: type, target: element }) ); 1697 if ( evt ) 1698 data.unshift( this.fix({ type: type, target: element }) ); 1530 1699 1531 1700 // Trigger the event 1532 if ( jQuery.isFunction( element.$handle ) ) 1533 val = element.$handle.apply( element, data ); 1701 if ( jQuery.isFunction( jQuery.data(element, "handle") ) ) 1702 val = jQuery.data(element, "handle").apply( element, data ); 1703 1704 // Handle triggering native .onfoo handlers 1534 1705 if ( !fn && element["on"+type] && element["on"+type].apply( element, data ) === false ) 1535 1706 val = false; 1536 1707 1537 if ( fn && val !== false && !(jQuery.nodeName(element, 'a') && type == "click") ) { 1708 // Extra functions don't get the custom event object 1709 if ( evt ) 1710 data.shift(); 1711 1712 // Handle triggering of extra function 1713 if ( extra && extra.apply( element, data ) === false ) 1714 val = false; 1715 1716 // Trigger the native events (except for clicks on links) 1717 if ( fn && donative !== false && val !== false && !(jQuery.nodeName(element, 'a') && type == "click") ) { 1538 1718 this.triggered = true; 1539 1719 element[ type ](); … … 1542 1722 this.triggered = false; 1543 1723 } 1724 1725 return val; 1544 1726 }, 1545 1727 … … 1551 1733 event = jQuery.event.fix( event || window.event || {} ); 1552 1734 1553 var c = this.$events && this.$events[event.type], args = Array.prototype.slice.call( arguments, 1 ); 1735 // Namespaced event handlers 1736 var parts = event.type.split("."); 1737 event.type = parts[0]; 1738 1739 var c = jQuery.data(this, "events") && jQuery.data(this, "events")[event.type], args = Array.prototype.slice.call( arguments, 1 ); 1554 1740 args.unshift( event ); 1555 1741 … … 1560 1746 args[0].data = c[j].data; 1561 1747 1562 if ( c[j].apply( this, args ) === false ) { 1563 event.preventDefault(); 1564 event.stopPropagation(); 1565 val = false; 1748 // Filter the functions by class 1749 if ( !parts[1] || c[j].type == parts[1] ) { 1750 var tmp = c[j].apply( this, args ); 1751 1752 if ( val !== false ) 1753 val = tmp; 1754 1755 if ( tmp === false ) { 1756 event.preventDefault(); 1757 event.stopPropagation(); 1758 } 1566 1759 } 1567 1760 } … … 1640 1833 }); 1641 1834 }, 1835 1642 1836 one: function( type, data, fn ) { 1643 1837 return this.each(function(){ … … 1648 1842 }); 1649 1843 }, 1844 1650 1845 unbind: function( type, fn ) { 1651 1846 return this.each(function(){ … … 1653 1848 }); 1654 1849 }, 1655 trigger: function( type, data ) { 1850 1851 trigger: function( type, data, fn ) { 1656 1852 return this.each(function(){ 1657 jQuery.event.trigger( type, data, this );1853 jQuery.event.trigger( type, data, this, true, fn ); 1658 1854 }); 1659 1855 }, 1856 1857 triggerHandler: function( type, data, fn ) { 1858 if ( this[0] ) 1859 return jQuery.event.trigger( type, data, this[0], false, fn ); 1860 }, 1861 1660 1862 toggle: function() { 1661 1863 // Save reference to arguments for access in closure … … 1673 1875 }); 1674 1876 }, 1877 1675 1878 hover: function(f,g) { 1676 1879 … … 1693 1896 return this.mouseover(handleHover).mouseout(handleHover); 1694 1897 }, 1898 1695 1899 ready: function(f) { 1696 1900 // Attach the listeners … … 1746 1950 }); 1747 1951 1748 jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," + 1749 "mousedown,mouseup,mousemove,mouseover,mouseout,change,select," + 1750 "submit,keydown,keypress,keyup,error").split(","), function(i,o){ 1751 1752 // Handle event binding 1753 jQuery.fn[o] = function(f){ 1754 return f ? this.bind(o, f) : this.trigger(o); 1755 }; 1756 1757 }); 1952 jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," + 1953 "mousedown,mouseup,mousemove,mouseover,mouseout,change,select," + 1954 "submit,keydown,keypress,keyup,error").split(","), function(i,o){ 1955 1956 // Handle event binding 1957 jQuery.fn[o] = function(f){ 1958 return f ? this.bind(o, f) : this.trigger(o); 1959 }; 1960 }); 1758 1961 1759 1962 var readyBound = false; … … 1782 1985 if ( script ) 1783 1986 script.onreadystatechange = function() { 1784 if ( document.readyState != "complete" ) return;1987 if ( this.readyState != "complete" ) return; 1785 1988 jQuery.ready(); 1786 1989 }; … … 1810 2013 } 1811 2014 jQuery.fn.extend({ 1812 // DEPRECATED 1813 loadIfModified: function( url, params, callback ) { 1814 this.load( url, params, callback, 1 ); 1815 }, 1816 load: function( url, params, callback, ifModified ) { 2015 load: function( url, params, callback ) { 1817 2016 if ( jQuery.isFunction( url ) ) 1818 2017 return this.bind("load", url); 2018 2019 var off = url.indexOf(" "); 2020 if ( off >= 0 ) { 2021 var selector = url.slice(off, url.length); 2022 url = url.slice(0, off); 2023 } 1819 2024 1820 2025 callback = callback || function(){}; … … 1844 2049 type: type, 1845 2050 data: params, 1846 ifModified: ifModified,1847 2051 complete: function(res, status){ 1848 2052 // If successful, inject the HTML into all the matched elements 1849 if ( status == "success" || !ifModified && status == "notmodified" ) 1850 self.html(res.responseText); 2053 if ( status == "success" || status == "notmodified" ) 2054 // See if a selector was specified 2055 self.html( selector ? 2056 // Create a dummy div to hold the results 2057 jQuery("<div/>") 2058 // inject the contents of the document in, removing the scripts 2059 // to avoid any 'Permission Denied' errors in IE 2060 .append(res.responseText.replace(/<script(.|\s)*?\/script>/g, "")) 2061 2062 // Locate the specified elements 2063 .find(selector) : 2064 2065 // If not, just inject the full result 2066 res.responseText ); 1851 2067 1852 2068 // Add delay to account for Safari's delay in globalEval … … 1858 2074 return this; 1859 2075 }, 2076 1860 2077 serialize: function() { 1861 return jQuery.param( this ); 1862 }, 1863 1864 // DEPRECATED 1865 // This method no longer does anything - all script evaluation is 1866 // taken care of within the HTML injection methods. 1867 evalScripts: function(){} 1868 2078 return jQuery.param(this.serializeArray()); 2079 }, 2080 serializeArray: function() { 2081 return this.map(function(){ 2082 return jQuery.nodeName(this, "form") ? 2083 jQuery.makeArray(this.elements) : this; 2084 }) 2085 .filter(function(){ 2086 return this.name && !this.disabled && 2087 (this.checked || /select|textarea/i.test(this.nodeName) || 2088 /text|hidden|password/i.test(this.type)); 2089 }) 2090 .map(function(i, elem){ 2091 var val = jQuery(this).val(); 2092 return val == null ? null : 2093 val.constructor == Array ? 2094 jQuery.map( val, function(i, val){ 2095 return {name: elem.name, value: val}; 2096 }) : 2097 {name: elem.name, value: val}; 2098 }).get(); 2099 } 1869 2100 }); 1870 2101 1871 2102 // Attach a bunch of functions for handling common AJAX events 1872 1873 2103 jQuery.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","), function(i,o){ 1874 2104 jQuery.fn[o] = function(f){ … … 1877 2107 }); 1878 2108 2109 var jsc = (new Date).getTime(); 2110 1879 2111 jQuery.extend({ 1880 get: function( url, data, callback, type , ifModified) {2112 get: function( url, data, callback, type ) { 1881 2113 // shift arguments if data argument was ommited 1882 2114 if ( jQuery.isFunction( data ) ) { … … 1890 2122 data: data, 1891 2123 success: callback, 1892 dataType: type, 1893 ifModified: ifModified 2124 dataType: type 1894 2125 }); 1895 2126 }, 1896 // DEPRECATED 1897 getIfModified: function( url, data, callback, type ) { 1898 return jQuery.get(url, data, callback, type, 1); 1899 }, 2127 1900 2128 getScript: function( url, callback ) { 1901 2129 return jQuery.get(url, null, callback, "script"); 1902 2130 }, 2131 1903 2132 getJSON: function( url, data, callback ) { 1904 2133 return jQuery.get(url, data, callback, "json"); 1905 2134 }, 2135 1906 2136 post: function( url, data, callback, type ) { 1907 2137 if ( jQuery.isFunction( data ) ) { … … 1918 2148 }); 1919 2149 }, 1920 // DEPRECATED 1921 ajaxTimeout: function( timeout ) { 1922 jQuery.ajaxSettings.timeout = timeout; 1923 }, 2150 1924 2151 ajaxSetup: function( settings ) { 1925 2152 jQuery.extend( jQuery.ajaxSettings, settings ); … … 1938 2165 // Last-Modified header cache for next request 1939 2166 lastModified: {}, 2167 1940 2168 ajax: function( s ) { 2169 var jsonp, jsre = /=(\?|%3F)/g, status, data; 2170 1941 2171 // Extend the settings, but re-extend 's' so that it can be 1942 2172 // checked again later (in the test suite, specifically) 1943 2173 s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s)); 1944 2174 1945 // if data available 1946 if ( s.data ) { 1947 // convert data if not already a string 1948 if ( s.processData && typeof s.data != "string" ) 1949 s.data = jQuery.param(s.data); 1950 1951 // append data to url for get requests 1952 if ( s.type.toLowerCase() == "get" ) { 1953 // "?" + data or "&" + data (in case there are already params) 1954 s.url += (s.url.indexOf("?") > -1 ? "&" : "?") + s.data; 1955 1956 // IE likes to send both get and post data, prevent this 1957 s.data = null; 1958 } 2175 // convert data if not already a string 2176 if ( s.data && s.processData && typeof s.data != "string" ) 2177 s.data = jQuery.param(s.data); 2178 2179 // Break the data into one single string 2180 var q = s.url.indexOf("?"); 2181 if ( q > -1 ) { 2182 s.data = (s.data ? s.data + "&" : "") + s.url.slice(q + 1); 2183 s.url = s.url.slice(0, q); 2184 } 2185 2186 // Handle JSONP Parameter Callbacks 2187 if ( s.dataType == "jsonp" ) { 2188 if ( !s.data || !s.data.match(jsre) ) 2189 s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?"; 2190 s.dataType = "json"; 2191 } 2192 2193 // Build temporary JSONP function 2194 if ( s.dataType == "json" && s.data && s.data.match(jsre) ) { 2195 jsonp = "jsonp" + jsc++; 2196 s.data = s.data.replace(jsre, "=" + jsonp); 2197 2198 // We need to make sure 2199 // that a JSONP style response is executed properly 2200 s.dataType = "script"; 2201 2202 // Handle JSONP-style loading 2203 window[ jsonp ] = function(tmp){ 2204 data = tmp; 2205 success(); 2206 // Garbage collect 2207 window[ jsonp ] = undefined; 2208 try{ delete window[ jsonp ]; } catch(e){} 2209 }; 2210 } 2211 2212 if ( s.dataType == "script" && s.cache == null ) 2213 s.cache = false; 2214 2215 if ( s.cache === false && s.type.toLowerCase() == "get" ) 2216 s.data = (s.data ? s.data + "&" : "") + "_=" + (new Date()).getTime(); 2217 2218 // If data is available, append data to url for get requests 2219 if ( s.data && s.type.toLowerCase() == "get" ) { 2220 s.url += "?" + s.data; 2221 2222 // IE likes to send both get and post data, prevent this 2223 s.data = null; 1959 2224 } 1960 2225 … … 1962 2227 if ( s.global && ! jQuery.active++ ) 1963 2228 jQuery.event.trigger( "ajaxStart" ); 2229 2230 // If we're requesting a remote document 2231 // and trying to load JSON or Script 2232 if ( !s.url.indexOf("http") && s.dataType == "script" ) { 2233 var head = document.getElementsByTagName("head")[0]; 2234 var script = document.createElement("script"); 2235 script.src = s.url; 2236 2237 // Handle Script loading 2238 if ( !jsonp && (s.success || s.complete) ) { 2239 var done = false; 2240 2241 // Attach handlers for all browsers 2242 script.onload = script.onreadystatechange = function(){ 2243 if ( !done && (!this.readyState || 2244 this.readyState == "loaded" || this.readyState == "complete") ) { 2245 done = true; 2246 success(); 2247 complete(); 2248 head.removeChild( script ); 2249 } 2250 }; 2251 } 2252 2253 head.appendChild(script); 2254 2255 // We handle everything using the script element injection 2256 return; 2257 } 1964 2258 1965 2259 var requestDone = false; … … 1985 2279 1986 2280 // Allow custom headers/mimetypes 1987 if ( s.beforeSend )2281 if ( s.beforeSend ) 1988 2282 s.beforeSend(xml); 1989 2283 … … 2003 2297 } 2004 2298 2005 varstatus = isTimeout == "timeout" && "timeout" ||2299 status = isTimeout == "timeout" && "timeout" || 2006 2300 !jQuery.httpSuccess( xml ) && "error" || 2007 2301 s.ifModified && jQuery.httpNotModified( xml, s.url ) && "notmodified" || … … 2012 2306 try { 2013 2307 // process the data (runs the xml through httpData regardless of callback) 2014 vardata = jQuery.httpData( xml, s.dataType );2308 data = jQuery.httpData( xml, s.dataType ); 2015 2309 } catch(e) { 2016 2310 status = "parsererror"; … … 2028 2322 if ( s.ifModified && modRes ) 2029 2323 jQuery.lastModified[s.url] = modRes; 2030 2031 // If a local callback was specified, fire it and pass it the data 2032 if ( s.success ) 2033 s.success( data, status ); 2034 2035 // Fire the global callback 2036 if ( s.global ) 2037 jQuery.event.trigger( "ajaxSuccess", [xml, s] ); 2324 2325 // JSONP handles its own success callback 2326 if ( !jsonp ) 2327 success(); 2038 2328 } else 2039 2329 jQuery.handleError(s, xml, status); 2040 2330 2041 // The request was completed 2042 if( s.global ) 2043 jQuery.event.trigger( "ajaxComplete", [xml, s] ); 2044 2045 // Handle the global AJAX counter 2046 if ( s.global && ! --jQuery.active ) 2047 jQuery.event.trigger( "ajaxStop" ); 2048 2049 // Process result 2050 if ( s.complete ) 2051 s.complete(xml, status); 2331 // Fire the complete handlers 2332 complete(); 2052 2333 2053 2334 // Stop memory leaks 2054 if (s.async)2335 if ( s.async ) 2055 2336 xml = null; 2056 2337 } … … 2088 2369 // return XMLHttpRequest to allow aborting the request etc. 2089 2370 return xml; 2371 2372 function success(){ 2373 // If a local callback was specified, fire it and pass it the data 2374 if ( s.success ) 2375 s.success( data, status ); 2376 2377 // Fire the global callback 2378 if ( s.global ) 2379 jQuery.event.trigger( "ajaxSuccess", [xml, s] ); 2380 } 2381 2382 function complete(){ 2383 // Process result 2384 if ( s.complete ) 2385 s.complete(xml, status); 2386 2387 // The request was completed 2388 if ( s.global ) 2389 jQuery.event.trigger( "ajaxComplete", [xml, s] ); 2390 2391 // Handle the global AJAX counter 2392 if ( s.global && ! --jQuery.active ) 2393 jQuery.event.trigger( "ajaxStop" ); 2394 } 2090 2395 }, 2091 2396 … … 2124 2429 }, 2125 2430 2126 /* Get the data out of an XMLHttpRequest.2127 * Return parsed XML if content-type header is "xml" and type is "xml" or omitted,2128 * otherwise return plain text.2129 * (String) data - The type of data that you're expecting back,2130 * (e.g. "xml", "html", "script")2131 */2132 2431 httpData: function( r, type ) { 2133 2432 var ct = r.getResponseHeader("content-type"); 2134 2433 var xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0; 2135 data = xml ? r.responseXML : r.responseText;2434 var data = xml ? r.responseXML : r.responseText; 2136 2435 2137 2436 if ( xml && data.documentElement.tagName == "parsererror" ) … … 2175 2474 2176 2475 // Return the resulting serialization 2177 return s.join("&") ;2476 return s.join("&").replace(/%20/g, "+"); 2178 2477 } 2179 2478 2180 2479 }); 2181 2480 jQuery.fn.extend({ 2182 2183 2481 show: function(speed,callback){ 2184 2482 return speed ? … … 2193 2491 }).end(); 2194 2492 }, 2195 2493 2196 2494 hide: function(speed,callback){ 2197 2495 return speed ? … … 2210 2508 // Save the old toggle function 2211 2509 _toggle: jQuery.fn.toggle, 2510 2212 2511 toggle: function( fn, fn2 ){ 2213 2512 return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ? … … 2221 2520 }); 2222 2521 }, 2522 2223 2523 slideDown: function(speed,callback){ 2224 2524 return this.animate({height: "show"}, speed, callback); 2225 2525 }, 2526 2226 2527 slideUp: function(speed,callback){ 2227 2528 return this.animate({height: "hide"}, speed, callback); 2228 2529 }, 2530 2229 2531 slideToggle: function(speed, callback){ 2230 2532 return this.animate({height: "toggle"}, speed, callback); 2231 2533 }, 2534 2232 2535 fadeIn: function(speed, callback){ 2233 2536 return this.animate({opacity: "show"}, speed, callback); 2234 2537 }, 2538 2235 2539 fadeOut: function(speed, callback){ 2236 2540 return this.animate({opacity: "hide"}, speed, callback); 2237 2541 }, 2542 2238 2543 fadeTo: function(speed,to,callback){ 2239 2544 return this.animate({opacity: to}, speed, callback); 2240 2545 }, 2546 2241 2547 animate: function( prop, speed, easing, callback ) { 2242 return this.queue(function(){ 2243 var hidden = jQuery(this).is(":hidden"), 2244 opt = jQuery.speed(speed, easing, callback), 2245 self = this; 2548 var opt = jQuery.speed(speed, easing, callback); 2549 2550 return this[ opt.queue === false ? "each" : "queue" ](function(){ 2551 opt = jQuery.extend({}, opt); 2552 var hidden = jQuery(this).is(":hidden"), self = this; 2246 2553 2247 2554 for ( var p in prop ) { … … 2261 2568 this.style.overflow = "hidden"; 2262 2569 2263 this.curAnim = jQuery.extend({}, prop);2570 opt.curAnim = jQuery.extend({}, prop); 2264 2571 2265 2572 jQuery.each( prop, function(name, val){ 2266 2573 var e = new jQuery.fx( self, opt, name ); 2267 if ( val.constructor == Number ) 2268 e.custom( e.cur() || 0, val ); 2269 else 2574 2575 if ( /toggle|show|hide/.test(val) ) 2270 2576 e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop ); 2577 else { 2578 var parts = val.toString().match(/^([+-]?)([\d.]+)(.*)$/), 2579 start = e.cur(true) || 0; 2580 2581 if ( parts ) { 2582 end = parseFloat(parts[2]), 2583 unit = parts[3] || "px"; 2584 2585 // We need to compute starting value 2586 if ( unit != "px" ) { 2587 self.style[ name ] = end + unit; 2588 start = (end / e.cur(true)) * start; 2589 self.style[ name ] = start + unit; 2590 } 2591 2592 // If a +/- token was provided, we're doing a relative animation 2593 if ( parts[1] ) 2594 end = ((parts[1] == "-" ? -1 : 1) * end) + start; 2595 2596 e.custom( start, end, unit ); 2597 } else 2598 e.custom( start, val, "" ); 2599 } 2271 2600 }); 2272 2601 … … 2275 2604 }); 2276 2605 }, 2277 queue: function(type,fn){ 2606 2607 queue: function(type, fn){ 2278 2608 if ( !fn ) { 2279 2609 fn = type; 2280 2610 type = "fx"; 2281 2611 } 2282 2612 2613 if ( !arguments.length ) 2614 return queue( this[0], type ); 2615 2283 2616 return this.each(function(){ 2284 if ( !this.queue ) 2285 this.queue = {}; 2286 2287 if ( !this.queue[type] ) 2288 this.queue[type] = []; 2289 2290 this.queue[type].push( fn ); 2291 2292 if ( this.queue[type].length == 1 ) 2293 fn.apply(this); 2617 if ( fn.constructor == Array ) 2618 queue(this, type, fn); 2619 else { 2620 queue(this, type).push( fn ); 2621 2622 if ( queue(this, type).length == 1 ) 2623 fn.apply(this); 2624 } 2294 2625 }); 2626 }, 2627 2628 stop: function(){ 2629 var timers = jQuery.timers; 2630 2631 return this.each(function(){ 2632 for ( var i = 0; i < timers.length; i++ ) 2633 if ( timers[i].elem == this ) 2634 timers.splice(i--, 1); 2635 }).dequeue(); 2295 2636 } 2296 2637 2297 2638 }); 2639 2640 var queue = function( elem, type, array ) { 2641 if ( !elem ) 2642 return; 2643 2644 var q = jQuery.data( elem, type + "queue" ); 2645 2646 if ( !q || array ) 2647 q = jQuery.data( elem, type + "queue", 2648 array ? jQuery.makeArray(array) : [] ); 2649 2650 return q; 2651 }; 2652 2653 jQuery.fn.dequeue = function(type){ 2654 type = type || "fx"; 2655 2656 return this.each(function(){ 2657 var q = queue(this, type); 2658 2659 q.shift(); 2660 2661 if ( q.length ) 2662 q[0].apply( this ); 2663 }); 2664 }; 2298 2665 2299 2666 jQuery.extend({ … … 2314 2681 opt.old = opt.complete; 2315 2682 opt.complete = function(){ 2316 jQuery .dequeue(this, "fx");2683 jQuery(this).dequeue(); 2317 2684 if ( jQuery.isFunction( opt.old ) ) 2318 2685 opt.old.apply( this ); … … 2331 2698 }, 2332 2699 2333 queue: {}, 2334 2335 dequeue: function(elem,type){ 2336 type = type || "fx"; 2337 2338 if ( elem.queue && elem.queue[type] ) { 2339 // Remove self 2340 elem.queue[type].shift(); 2341 2342 // Get next function 2343 var f = elem.queue[type][0]; 2700 timers: [], 2701 2702 fx: function( elem, options, prop ){ 2703 this.options = options; 2704 this.elem = elem; 2705 this.prop = prop; 2706 2707 if ( !options.orig ) 2708 options.orig = {}; 2709 } 2710 2711 }); 2712 2713 jQuery.fx.prototype = { 2714 2715 // Simple function for setting a style value 2716 update: function(){ 2717 if ( this.options.step ) 2718 this.options.step.apply( this.elem, [ this.now, this ] ); 2719 2720 (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this ); 2721 2722 // Set display property to block for height/width animations 2723 if ( this.prop == "height" || this.prop == "width" ) 2724 this.elem.style.display = "block"; 2725 }, 2726 2727 // Get the current size 2728 cur: function(force){ 2729 if ( this.elem[this.prop] != null && this.elem.style[this.prop] == null ) 2730 return this.elem[ this.prop ]; 2731 2732 var r = parseFloat(jQuery.curCSS(this.elem, this.prop, force)); 2733 return r && r > -10000 ? r : parseFloat(jQuery.css(this.elem, this.prop)) || 0; 2734 }, 2735 2736 // Start an animation from one number to another 2737 custom: function(from, to, unit){ 2738 this.startTime = (new Date()).getTime(); 2739 this.start = from; 2740 this.end = to; 2741 this.unit = unit || this.unit || "px"; 2742 this.now = this.start; 2743 this.pos = this.state = 0; 2744 this.update(); 2745 2746 var self = this; 2747 function t(){ 2748 return self.step(); 2749 } 2750 2751 t.elem = this.elem; 2752 2753 jQuery.timers.push(t); 2754 2755 if ( jQuery.timers.length == 1 ) { 2756 var timer = setInterval(function(){ 2757 var timers = jQuery.timers; 2758 2759 for ( var i = 0; i < timers.length; i++ ) 2760 if ( !timers[i]() ) 2761 timers.splice(i--, 1); 2762 2763 if ( !timers.length ) 2764 clearInterval( timer ); 2765 }, 13); 2766 } 2767 }, 2768 2769 // Simple 'show' function 2770 show: function(){ 2771 // Remember where we started, so that we can go back to it later 2772 this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop ); 2773 this.options.show = true; 2774 2775 // Begin the animation 2776 this.custom(0, this.cur()); 2777 2778 // Make sure that we start at a small width/height to avoid any 2779 // flash of content 2780 if ( this.prop == "width" || this.prop == "height" ) 2781 this.elem.style[this.prop] = "1px"; 2344 2782 2345 if ( f ) f.apply( elem ); 2346 } 2347 }, 2348 2349 timers: [], 2350 2351 /* 2352 * I originally wrote fx() as a clone of moo.fx and in the process 2353 * of making it small in size the code became illegible to sane 2354 * people. You've been warned. 2355 */ 2356 2357 fx: function( elem, options, prop ){ 2358 2359 var z = this; 2360 2361 // The styles 2362 var y = elem.style; 2783 // Start by showing the element 2784 jQuery(this.elem).show(); 2785 }, 2786 2787 // Simple 'hide' function 2788 hide: function(){ 2789 // Remember where we started, so that we can go back to it later 2790 this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop ); 2791 this.options.hide = true; 2792 2793 // Begin the animation 2794 this.custom(this.cur(), 0); 2795 }, 2796 2797 // Each step of an animation 2798 step: function(){ 2799 var t = (new Date()).getTime(); 2800 2801 if ( t > this.options.duration + this.startTime ) { 2802 this.now = this.end; 2803 this.pos = this.state = 1; 2804 this.update(); 2805 2806 this.options.curAnim[ this.prop ] = true; 2807 2808 var done = true; 2809 for ( var i in this.options.curAnim ) 2810 if ( this.options.curAnim[i] !== true ) 2811 done = false; 2812 2813 if ( done ) { 2814 if ( this.options.display != null ) { 2815 // Reset the overflow 2816 this.elem.style.overflow = this.options.overflow; 2817 2818 // Reset the display 2819 this.elem.style.display = this.options.display; 2820 if ( jQuery.css(this.elem, "display") == "none" ) 2821 this.elem.style.display = "block"; 2822 } 2823 2824 // Hide the element if the "hide" operation was done 2825 if ( this.options.hide ) 2826 this.elem.style.display = "none"; 2827 2828 // Reset the properties, if the item has been hidden or shown 2829 if ( this.options.hide || this.options.show ) 2830 for ( var p in this.options.curAnim ) 2831 jQuery.attr(this.elem.style, p, this.options.orig[p]); 2832 } 2833 2834 // If a callback was provided, execute it 2835 if ( done && jQuery.isFunction( this.options.complete ) ) 2836 // Execute the complete function 2837 this.options.complete.apply( this.elem ); 2838 2839 return false; 2840 } else { 2841 var n = t - this.startTime; 2842 this.state = n / this.options.duration; 2843 2844 // Perform the easing function, defaults to swing 2845 this.pos = jQuery.easing[this.options.easing || (jQuery.easing.swing ? "swing" : "linear")](this.state, n, 0, 1, this.options.duration); 2846 this.now = this.start + ((this.end - this.start) * this.pos); 2847 2848 // Perform the next step of the animation 2849 this.update(); 2850 } 2851 2852 return true; 2853 } 2854 2855 }; 2856 2857 jQuery.fx.step = { 2858 scrollLeft: function(fx){ 2859 fx.elem.scrollLeft = fx.now; 2860 }, 2861 2862 scrollTop: function(fx){ 2863 fx.elem.scrollTop = fx.now; 2864 }, 2865 2866 opacity: function(fx){ 2867 jQuery.attr(fx.elem.style, "opacity", fx.now); 2868 }, 2869 2870 _default: function(fx){ 2871 fx.elem.style[ fx.prop ] = fx.now + fx.unit; 2872 } 2873 }; 2874 // The Offset Method 2875 // Originally By Brandon Aaron, part of the Dimension Plugin 2876 // http://jquery.com/plugins/project/dimensions 2877 jQuery.fn.offset = function() { 2878 var left = 0, top = 0, elem = this[0], results; 2879 2880 if ( elem ) with ( jQuery.browser ) { 2881 var absolute = jQuery.css(elem, "position") == "absolute", 2882 parent = elem.parentNode, 2883 offsetParent = elem.offsetParent, 2884 doc = elem.ownerDocument, 2885 safari2 = safari && !absolute && parseInt(version) < 522; 2886 2887 // Use getBoundingClientRect if available 2888 if ( elem.getBoundingClientRect ) { 2889 box = elem.getBoundingClientRect(); 2363 2890 2364 // Simple function for setting a style value 2365 z.a = function(){ 2366 if ( options.step ) 2367 options.step.apply( elem, [ z.now ] ); 2368 2369 if ( prop == "opacity" ) 2370 jQuery.attr(y, "opacity", z.now); // Let attr handle opacity 2371 else { 2372 y[prop] = parseInt(z.now) + "px"; 2373 2374 // Set display property to block for height/width animations 2375 if ( prop == "height" || prop == "width" ) 2376 y.display = "block"; 2377 } 2378 }; 2379 2380 // Figure out the maximum number to run to 2381 z.max = function(){ 2382 return parseFloat( jQuery.css(elem,prop) ); 2383 }; 2384 2385 // Get the current size 2386 z.cur = function(){ 2387 var r = parseFloat( jQuery.curCSS(elem, prop) ); 2388 return r && r > -10000 ? r : z.max(); 2389 }; 2390 2391 // Start an animation from one number to another 2392 z.custom = function(from,to){ 2393 z.startTime = (new Date()).getTime(); 2394 z.now = from; 2395 z.a(); 2396 2397 jQuery.timers.push(function(){ 2398 return z.step(from, to); 2399 }); 2400 2401 if ( jQuery.timers.length == 1 ) { 2402 var timer = setInterval(function(){ 2403 var timers = jQuery.timers; 2404 2405 for ( var i = 0; i < timers.length; i++ ) 2406 if ( !timers[i]() ) 2407 timers.splice(i--, 1); 2408 2409 if ( !timers.length ) 2410 clearInterval( timer ); 2411 }, 13); 2412 } 2413 }; 2414 2415 // Simple 'show' function 2416 z.show = function(){ 2417 if ( !elem.orig ) elem.orig = {}; 2418 2419 // Remember where we started, so that we can go back to it later 2420 elem.orig[prop] = jQuery.attr( elem.style, prop ); 2421 2422 options.show = true; 2423 2424 // Begin the animation 2425 z.custom(0, this.cur()); 2426 2427 // Make sure that we start at a small width/height to avoid any 2428 // flash of content 2429 if ( prop != "opacity" ) 2430 y[prop] = "1px"; 2891 // Add the document scroll offsets 2892 add( 2893 box.left + Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft), 2894 box.top + Math.max(doc.documentElement.scrollTop, doc.body.scrollTop) 2895 ); 2896 2897 // IE adds the HTML element's border, by default it is medium which is 2px 2898 // IE 6 and IE 7 quirks mode the border width is overwritable by the following css html { border: 0; } 2899 // IE 7 standards mode, the border is always 2px 2900 if ( msie ) { 2901 var border = jQuery("html").css("borderWidth"); 2902 border = (border == "medium" || jQuery.boxModel && parseInt(version) >= 7) && 2 || border; 2903 add( -border, -border ); 2904 } 2905 2906 // Otherwise loop through the offsetParents and parentNodes 2907 } else { 2908 2909 // Initial element offsets 2910 add( elem.offsetLeft, elem.offsetTop ); 2911 2912 // Get parent offsets 2913 while ( offsetParent ) { 2914 // Add offsetParent offsets 2915 add( offsetParent.offsetLeft, offsetParent.offsetTop ); 2431 2916 2432 // Start by showing the element 2433 jQuery(elem).show(); 2434 }; 2435 2436 // Simple 'hide' function 2437 z.hide = function(){ 2438 if ( !elem.orig ) elem.orig = {}; 2439 2440 // Remember where we started, so that we can go back to it later 2441 elem.orig[prop] = jQuery.attr( elem.style, prop ); 2442 2443 options.hide = true; 2444 2445 // Begin the animation 2446 z.custom(this.cur(), 0); 2447 }; 2448 2449 // Each step of an animation 2450 z.step = function(firstNum, lastNum){ 2451 var t = (new Date()).getTime(); 2452 2453 if (t > options.duration + z.startTime) { 2454 z.now = lastNum; 2455 z.a(); 2456 2457 if (elem.curAnim) elem.curAnim[ prop ] = true; 2458 2459 var done = true; 2460 for ( var i in elem.curAnim ) 2461 if ( elem.curAnim[i] !== true ) 2462 done = false; 2463 2464 if ( done ) { 2465 if ( options.display != null ) { 2466 // Reset the overflow 2467 y.overflow = options.overflow; 2468 2469 // Reset the display 2470 y.display = options.display; 2471 if ( jQuery.css(elem, "display") == "none" ) 2472 y.display = "block"; 2473 } 2474 2475 // Hide the element if the "hide" operation was done 2476 if ( options.hide ) 2477 y.display = "none"; 2478 2479 // Reset the properties, if the item has been hidden or shown 2480 if ( options.hide || options.show ) 2481 for ( var p in elem.curAnim ) 2482 jQuery.attr(y, p, elem.orig[p]); 2483 } 2484 2485 // If a callback was provided, execute it 2486 if ( done && jQuery.isFunction( options.complete ) ) 2487 // Execute the complete function 2488 options.complete.apply( elem ); 2489 2490 return false; 2491 } else { 2492 var n = t - this.startTime; 2493 // Figure out where in the animation we are and set the number 2494 var p = n / options.duration; 2917 // Mozilla and Safari > 2 does not include the border on offset parents 2918 // However Mozilla adds the border for table cells 2919 if ( mozilla && /^t[d|h]$/i.test(parent.tagName) || !safari2 ) 2920 border( offsetParent ); 2495 2921 2496 // Perform the easing function, defaults to swing 2497 z.now = jQuery.easing[options.easing || (jQuery.easing.swing ? "swing" : "linear")](p, n, firstNum, (lastNum-firstNum), options.duration); 2498 2499 // Perform the next step of the animation 2500 z.a(); 2501 } 2502 2503 return true; 2504 }; 2505 2922 // Safari <= 2 doubles body offsets with an absolutely positioned element or parent 2923 if ( safari2 && !absolute && jQuery.css(offsetParent, "position") == "absolute" ) 2924 absolute = true; 2925 2926 // Get next offsetParent 2927 offsetParent = offsetParent.offsetParent; 2928 } 2929 2930 // Get parent scroll offsets 2931 while ( parent.tagName && /^body|html$/i.test(parent.tagName) ) { 2932 // Work around opera inline/table scrollLeft/Top bug 2933 if ( /^inline|table-row.*$/i.test(jQuery.css(parent, "display")) ) 2934 // Subtract parent scroll offsets 2935 add( -parent.scrollLeft, -parent.scrollTop ); 2936 2937 // Mozilla does not add the border for a parent that has overflow != visible 2938 if ( mozilla && jQuery.css(parent, "overflow") != "visible" ) 2939 border( parent ); 2940 2941 // Get next parent 2942 parent = parent.parentNode; 2943 } 2944 2945 // Safari doubles body offsets with an absolutely positioned element or parent 2946 if ( safari && absolute ) 2947 add( -doc.body.offsetLeft, -doc.body.offsetTop ); 2948 } 2949 2950 // Return an object with top and left properties 2951 results = { top: top, left: left }; 2506 2952 } 2507 }); 2953 2954 return results; 2955 2956 function border(elem) { 2957 add( jQuery.css(elem, "borderLeftWidth"), jQuery.css(elem, "borderTopWidth") ); 2958 } 2959 2960 function add(l, t) { 2961 left += parseInt(l) || 0; 2962 top += parseInt(t) || 0; 2963 } 2964 }; 2508 2965 })();
Note: See TracChangeset
for help on using the changeset viewer.