Changeset 4280
- Timestamp:
- 12/20/07 18:18:04 (1 year ago)
- Files:
-
- 1 modified
-
trunk/plugins/tooltip/jquery.js (modified) (95 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/tooltip/jquery.js
r3864 r4280 1 1 (function(){ 2 2 /* 3 * jQuery 1.2. 1- New Wave Javascript3 * jQuery 1.2.2b2 - 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- 09-16 23:42:06 -0400 (Sun, 16 Sep2007) $10 * $Rev: 3353$9 * $Date: 2007-12-20 14:36:56 +0100 (Don, 20 Dez 2007) $ 10 * $Rev: 4251 $ 11 11 */ 12 12 13 13 // Map over jQuery in case of overwrite 14 if ( typeof jQuery != "undefined" ) 15 var _jQuery = jQuery; 16 17 var jQuery = window.jQuery = function(selector, context) { 18 // If the context is a namespace object, return a new object 19 return this instanceof jQuery ? 20 this.init(selector, context) : 21 new jQuery(selector, context); 14 if ( window.jQuery ) 15 var _jQuery = window.jQuery; 16 17 var jQuery = window.jQuery = function( selector, context ) { 18 // The jQuery object is actually just the init constructor 'enhanced' 19 return new jQuery.prototype.init( selector, context ); 22 20 }; 23 21 24 22 // Map over the $ in case of overwrite 25 if ( typeof $ != "undefined")26 var _$ = $;23 if ( window.$ ) 24 var _$ = window.$; 27 25 28 26 // Map the jQuery namespace to the '$' one 29 27 window.$ = jQuery; 30 28 29 // A simple way to check for HTML strings or ID strings 30 // (both of which we optimize for) 31 31 var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/; 32 32 33 // Is it a simple selector 34 var isSimple = /^.[^:#\[\.]*$/; 35 33 36 jQuery.fn = jQuery.prototype = { 34 init: function( selector, context) {37 init: function( selector, context ) { 35 38 // Make sure that a selection was provided 36 39 selector = selector || document; 37 40 41 // Handle $(DOMElement) 42 if ( selector.nodeType ) { 43 this[0] = selector; 44 this.length = 1; 45 return this; 46 38 47 // Handle HTML strings 39 if ( typeof selector == "string" ) { 40 var m = quickExpr.exec(selector); 41 if ( m && (m[1] || !context) ) { 48 } else if ( typeof selector == "string" ) { 49 // Are we dealing with HTML string or an ID? 50 var match = quickExpr.exec( selector ); 51 52 // Verify a match, and that no context was specified for #id 53 if ( match && (match[1] || !context) ) { 54 42 55 // HANDLE: $(html) -> $(array) 43 if ( m [1] )44 selector = jQuery.clean( [ m [1] ], context );56 if ( match[1] ) 57 selector = jQuery.clean( [ match[1] ], context ); 45 58 46 59 // HANDLE: $("#id") 47 60 else { 48 var tmp = document.getElementById( m[3] ); 49 if ( tmp ) 61 var elem = document.getElementById( match[3] ); 62 63 // Make sure an element was located 64 if ( elem ) 50 65 // Handle the case where IE and Opera return items 51 66 // by name instead of ID 52 if ( tmp.id != m[3] )67 if ( elem.id != match[3] ) 53 68 return jQuery().find( selector ); 69 70 // Otherwise, we inject the element directly into the jQuery object 54 71 else { 55 this[0] = tmp;72 this[0] = elem; 56 73 this.length = 1; 57 74 return this; 58 75 } 76 59 77 else 60 78 selector = []; 61 79 } 62 80 63 // HANDLE: $(expr) 81 // HANDLE: $(expr, [context]) 82 // (which is just equivalent to: $(content).find(expr) 64 83 } else 65 84 return new jQuery( context ).find( selector ); … … 67 86 // HANDLE: $(function) 68 87 // Shortcut for document ready 69 } else if ( jQuery.isFunction( selector) )70 return new jQuery( document)[ jQuery.fn.ready ? "ready" : "load" ]( selector );88 } else if ( jQuery.isFunction( selector ) ) 89 return new jQuery( document )[ jQuery.fn.ready ? "ready" : "load" ]( selector ); 71 90 72 91 return this.setArray( … … 75 94 76 95 // HANDLE: $(arraylike) 77 // Watch for when an array-like object is passedas the selector96 // Watch for when an array-like object, contains DOM nodes, is passed in as the selector 78 97 (selector.jquery || selector.length && selector != window && !selector.nodeType && selector[0] != undefined && selector[0].nodeType) && jQuery.makeArray( selector ) || 79 98 … … 82 101 }, 83 102 84 jquery: "1.2.1", 85 103 // The current version of jQuery being used 104 jquery: "@VERSION", 105 106 // The number of elements contained in the matched element set 86 107 size: function() { 87 108 return this.length; 88 109 }, 89 110 111 // The number of elements contained in the matched element set 90 112 length: 0, 91 113 114 // Get the Nth element in the matched element set OR 115 // Get the whole matched element set as a clean array 92 116 get: function( num ) { 93 117 return num == undefined ? … … 97 121 98 122 // Return just the object 99 this[num]; 100 }, 101 102 pushStack: function( a ) { 103 var ret = jQuery(a); 123 this[ num ]; 124 }, 125 126 // Take an array of elements and push it onto the stack 127 // (returning the new matched element set) 128 pushStack: function( elems ) { 129 // Build a new jQuery matched element set 130 var ret = jQuery( elems ); 131 132 // Add the old object onto the stack (as a reference) 104 133 ret.prevObject = this; 134 135 // Return the newly-formed element set 105 136 return ret; 106 137 }, 107 138 108 setArray: function( a ) { 139 // Force the current matched set of elements to become 140 // the specified array of elements (destroying the stack in the process) 141 // You should use pushStack() in order to do this, but maintain the stack 142 setArray: function( elems ) { 143 // Resetting the length to 0, then using the native Array push 144 // is a super-fast way to populate an object with array-like properties 109 145 this.length = 0; 110 Array.prototype.push.apply( this, a ); 146 Array.prototype.push.apply( this, elems ); 147 111 148 return this; 112 149 }, 113 150 114 each: function( fn, args ) { 115 return jQuery.each( this, fn, args ); 116 }, 117 118 index: function( obj ) { 119 var pos = -1; 151 // Execute a callback for every element in the matched set. 152 // (You can seed the arguments with an array of args, but this is 153 // only used internally.) 154 each: function( callback, args ) { 155 return jQuery.each( this, callback, args ); 156 }, 157 158 // Determine the position of an element within 159 // the matched set of elements 160 index: function( elem ) { 161 var ret = -1; 162 163 // Locate the position of the desired element 120 164 this.each(function(i){ 121 if ( this == obj ) pos = i; 165 if ( this == elem ) 166 ret = i; 122 167 }); 123 return pos; 124 }, 125 126 attr: function( key, value, type ) { 127 var obj = key; 168 169 return ret; 170 }, 171 172 attr: function( name, value, type ) { 173 var options = name; 128 174 129 175 // Look for the case where we're accessing a style value 130 if ( key.constructor == String )176 if ( name.constructor == String ) 131 177 if ( value == undefined ) 132 return this.length && jQuery[ type || "attr" ]( this[0], key ) || undefined; 178 return this.length && jQuery[ type || "attr" ]( this[0], name ) || undefined; 179 133 180 else { 134 o bj= {};135 o bj[ key] = value;181 options = {}; 182 options[ name ] = value; 136 183 } 137 184 138 185 // Check to see if we're setting style values 139 return this.each(function(i ndex){186 return this.each(function(i){ 140 187 // Set all the styles 141 for ( var prop in obj)188 for ( name in options ) 142 189 jQuery.attr( 143 type ? this.style : this, 144 prop, jQuery.prop(this, obj[prop], type, index, prop) 190 type ? 191 this.style : 192 this, 193 name, jQuery.prop( this, options[ name ], type, i, name ) 145 194 ); 146 195 }); … … 148 197 149 198 css: function( key, value ) { 199 // ignore negative width and height values 200 if ( (key == 'width' || key == 'height') && parseFloat(value) < 0 ) 201 value = undefined; 150 202 return this.attr( key, value, "curCSS" ); 151 203 }, 152 204 153 text: function(e) { 154 if ( typeof e != "object" && e != null ) 155 return this.empty().append( document.createTextNode( e ) ); 156 157 var t = ""; 158 jQuery.each( e || this, function(){ 205 text: function( text ) { 206 if ( typeof text != "object" && text != null ) 207 return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); 208 209 var ret = ""; 210 211 jQuery.each( text || this, function(){ 159 212 jQuery.each( this.childNodes, function(){ 160 213 if ( this.nodeType != 8 ) 161 t += this.nodeType != 1 ? 162 this.nodeValue : jQuery.fn.text([ this ]); 214 ret += this.nodeType != 1 ? 215 this.nodeValue : 216 jQuery.fn.text( [ this ] ); 163 217 }); 164 218 }); 165 return t; 166 }, 167 168 wrapAll: function(html) { 219 220 return ret; 221 }, 222 223 wrapAll: function( html ) { 169 224 if ( this[0] ) 170 225 // The elements to wrap the target around 171 jQuery( html, this[0].ownerDocument)226 jQuery( html, this[0].ownerDocument ) 172 227 .clone() 173 .insertBefore( this[0])228 .insertBefore( this[0] ) 174 229 .map(function(){ 175 230 var elem = this; 231 176 232 while ( elem.firstChild ) 177 233 elem = elem.firstChild; 234 178 235 return elem; 179 236 }) … … 183 240 }, 184 241 185 wrapInner: function( html) {242 wrapInner: function( html ) { 186 243 return this.each(function(){ 187 jQuery( this).contents().wrapAll(html);244 jQuery( this ).contents().wrapAll( html ); 188 245 }); 189 246 }, 190 247 191 wrap: function( html) {248 wrap: function( html ) { 192 249 return this.each(function(){ 193 jQuery( this).wrapAll(html);250 jQuery( this ).wrapAll( html ); 194 251 }); 195 252 }, 196 253 197 254 append: function() { 198 return this.domManip(arguments, true, 1, function(a){ 199 this.appendChild( a ); 255 return this.domManip(arguments, true, false, function(elem){ 256 if (this.nodeType == 1) 257 this.appendChild( elem ); 200 258 }); 201 259 }, 202 260 203 261 prepend: function() { 204 return this.domManip(arguments, true, -1, function(a){ 205 this.insertBefore( a, this.firstChild ); 262 return this.domManip(arguments, true, true, function(elem){ 263 if (this.nodeType == 1) 264 this.insertBefore( elem, this.firstChild ); 206 265 }); 207 266 }, 208 267 209 268 before: function() { 210 return this.domManip(arguments, false, 1, function(a){211 this.parentNode.insertBefore( a, this );269 return this.domManip(arguments, false, false, function(elem){ 270 this.parentNode.insertBefore( elem, this ); 212 271 }); 213 272 }, 214 273 215 274 after: function() { 216 return this.domManip(arguments, false, -1, function(a){217 this.parentNode.insertBefore( a, this.nextSibling );275 return this.domManip(arguments, false, true, function(elem){ 276 this.parentNode.insertBefore( elem, this.nextSibling ); 218 277 }); 219 278 }, 220 279 221 280 end: function() { 222 return this.prevObject || jQuery([]); 223 }, 224 225 find: function(t) { 226 var data = jQuery.map(this, function(a){ return jQuery.find(t,a); }); 227 return this.pushStack( /[^+>] [^+>]/.test( t ) || t.indexOf("..") > -1 ? 228 jQuery.unique( data ) : data ); 229 }, 230 231 clone: function(events) { 281 return this.prevObject || jQuery( [] ); 282 }, 283 284 find: function( selector ) { 285 var elems = jQuery.map(this, function(elem){ 286 return jQuery.find( selector, elem ); 287 }); 288 289 return this.pushStack( /[^+>] [^+>]/.test( selector ) || selector.indexOf("..") > -1 ? 290 jQuery.unique( elems ) : 291 elems ); 292 }, 293 294 clone: function( events ) { 232 295 // Do the clone 233 296 var ret = this.map(function(){ 234 return this.outerHTML ? jQuery(this.outerHTML)[0] : this.cloneNode(true); 297 if ( jQuery.browser.msie && !jQuery.isXMLDoc(this) ) { 298 // IE copies events bound via attachEvent when 299 // using cloneNode. Calling detachEvent on the 300 // clone will also remove the events from the orignal 301 // In order to get around this, we use innerHTML. 302 // Unfortunately, this means some modifications to 303 // attributes in IE that are actually only stored 304 // as properties will not be copied (such as the 305 // the name attribute on an input). 306 var clone = this.cloneNode(true), 307 container = document.createElement("div"), 308 container2 = document.createElement("div"); 309 container.appendChild(clone); 310 container2.innerHTML = container.innerHTML; 311 return container2.firstChild; 312 } else 313 return this.cloneNode(true); 235 314 }); 236 315 … … 244 323 245 324 // Copy the events from the original to the clone 246 if (events === true) 247 this.find("*").andSelf().each(function(i) { 248 var events = jQuery.data(this, "events"); 325 if ( events === true ) 326 this.find("*").andSelf().each(function(i){ 327 var events = jQuery.data( this, "events" ); 328 249 329 for ( var type in events ) 250 for ( var handler in events[ type] )251 jQuery.event.add( clone[i], type, events[type][handler], events[type][handler].data);330 for ( var handler in events[ type ] ) 331 jQuery.event.add( clone[ i ], type, events[ type ][ handler ], events[ type ][ handler ].data ); 252 332 }); 253 333 … … 256 336 }, 257 337 258 filter: function( t) {338 filter: function( selector ) { 259 339 return this.pushStack( 260 jQuery.isFunction( t) &&261 jQuery.grep(this, function(el , index){262 return t.apply(el, [index]);340 jQuery.isFunction( selector ) && 341 jQuery.grep(this, function(elem, i){ 342 return selector.call( elem, i ); 263 343 }) || 264 344 265 jQuery.multiFilter(t,this) ); 266 }, 267 268 not: function(t) { 269 return this.pushStack( 270 t.constructor == String && 271 jQuery.multiFilter(t, this, true) || 272 273 jQuery.grep(this, function(a) { 274 return ( t.constructor == Array || t.jquery ) 275 ? jQuery.inArray( a, t ) < 0 276 : a != t; 277 }) 278 ); 279 }, 280 281 add: function(t) { 282 return this.pushStack( jQuery.merge( 345 jQuery.multiFilter( selector, this ) ); 346 }, 347 348 not: function( selector ) { 349 if ( selector.constructor == String ) 350 // test special case where just one selector is passed in 351 if ( isSimple.test( selector ) ) 352 return this.pushStack( jQuery.multiFilter( selector, this, true ) ); 353 else 354 selector = jQuery.multiFilter( selector, this ); 355 356 var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType; 357 return this.filter(function() { 358 return isArrayLike ? jQuery.inArray( this, selector ) < 0 : this != selector; 359 }); 360 }, 361 362 add: function( selector ) { 363 return !selector ? this : this.pushStack( jQuery.merge( 283 364 this.get(), 284 t.constructor == String ? 285 jQuery(t).get() : 286 t.length != undefined && (!t.nodeName || jQuery.nodeName(t, "form")) ? 287 t : [t] ) 288 ); 289 }, 290 291 is: function(expr) { 292 return expr ? jQuery.multiFilter(expr,this).length > 0 : false; 293 }, 294 295 hasClass: function(expr) { 296 return this.is("." + expr); 297 }, 298 299 val: function( val ) { 300 if ( val == undefined ) { 365 selector.constructor == String ? 366 jQuery( selector ).get() : 367 selector.length != undefined && (!selector.nodeName || jQuery.nodeName(selector, "form")) ? 368 selector : [selector] ) ); 369 }, 370 371 is: function( selector ) { 372 return selector ? 373 jQuery.multiFilter( selector, this ).length > 0 : 374 false; 375 }, 376 377 hasClass: function( selector ) { 378 return this.is( "." + selector ); 379 }, 380 381 val: function( value ) { 382 if ( value == undefined ) { 383 301 384 if ( this.length ) { 302 385 var elem = this[0]; 303 386 304 387 // We need to handle select boxes special 305 if ( jQuery.nodeName( elem, "select") ) {388 if ( jQuery.nodeName( elem, "select" ) ) { 306 389 var index = elem.selectedIndex, 307 a= [],390 values = [], 308 391 options = elem.options, 309 392 one = elem.type == "select-one"; … … 315 398 // Loop through all the selected options 316 399 for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { 317 var option = options[i]; 400 var option = options[ i ]; 401 318 402 if ( option.selected ) { 319 403 // Get the specifc value for the option 320 va r val = jQuery.browser.msie && !option.attributes["value"].specified ? option.text : option.value;404 value = jQuery.browser.msie && !option.attributes.value.specified ? option.text : option.value; 321 405 322 406 // We don't need an array for one selects 323 407 if ( one ) 324 return val ;408 return value; 325 409 326 410 // Multi-Selects return an array 327 a.push(val);411 values.push( value ); 328 412 } 329 413 } 330 414 331 return a;415 return values; 332 416 333 417 // Everything else, we just grab the value 334 418 } else 335 return this[0].value.replace(/\r/g, ""); 336 } 337 } else 338 return this.each(function(){ 339 if ( val.constructor == Array && /radio|checkbox/.test(this.type) ) 340 this.checked = (jQuery.inArray(this.value, val) >= 0 || 341 jQuery.inArray(this.name, val) >= 0); 342 else if ( jQuery.nodeName(this, "select") ) { 343 var tmp = val.constructor == Array ? val : [val]; 344 345 jQuery("option", this).each(function(){ 346 this.selected = (jQuery.inArray(this.value, tmp) >= 0 || 347 jQuery.inArray(this.text, tmp) >= 0); 348 }); 349 350 if ( !tmp.length ) 351 this.selectedIndex = -1; 352 } else 353 this.value = val; 354 }); 355 }, 356 357 html: function( val ) { 358 return val == undefined ? 359 ( this.length ? this[0].innerHTML : null ) : 360 this.empty().append( val ); 361 }, 362 363 replaceWith: function( val ) { 364 return this.after( val ).remove(); 365 }, 366 367 eq: function(i){ 368 return this.slice(i, i+1); 419 return (this[0].value || "").replace(/\r/g, ""); 420 421 } 422 423 return undefined; 424 } 425 426 return this.each(function(){ 427 if ( this.nodeType != 1 ) 428 return; 429 430 if ( value.constructor == Array && /radio|checkbox/.test( this.type ) ) 431 this.checked = (jQuery.inArray(this.value, value) >= 0 || 432 jQuery.inArray(this.name, value) >= 0); 433 434 else if ( jQuery.nodeName( this, "select" ) ) { 435 var values = value.constructor == Array ? 436 value : 437 [ value ]; 438 439 jQuery( "option", this ).each(function(){ 440 this.selected = (jQuery.inArray( this.value, values ) >= 0 || 441 jQuery.inArray( this.text, values ) >= 0); 442 }); 443 444 if ( !values.length ) 445 this.selectedIndex = -1; 446 447 } else 448 this.value = value; 449 }); 450 }, 451 452 html: function( value ) { 453 return value == undefined ? 454 (this.length ? 455 this[0].innerHTML : 456 null) : 457 this.empty().append( value ); 458 }, 459 460 replaceWith: function( value ) { 461 return this.after( value ).remove(); 462 }, 463 464 &
