3782 obj = type; |
3942 obj = type; |
3783 type = undefined; |
3943 type = undefined; |
3784 } |
3944 } |
3785 type = type || "fx"; |
3945 type = type || "fx"; |
3786 |
3946 |
3787 while( i-- ) { |
3947 while ( i-- ) { |
3788 tmp = data_priv.get( elements[ i ], type + "queueHooks" ); |
3948 tmp = data_priv.get( elements[ i ], type + "queueHooks" ); |
3789 if ( tmp && tmp.empty ) { |
3949 if ( tmp && tmp.empty ) { |
3790 count++; |
3950 count++; |
3791 tmp.empty.add( resolve ); |
3951 tmp.empty.add( resolve ); |
3792 } |
3952 } |
3793 } |
3953 } |
3794 resolve(); |
3954 resolve(); |
3795 return defer.promise( obj ); |
3955 return defer.promise( obj ); |
3796 } |
3956 } |
3797 }); |
3957 }); |
|
3958 var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source; |
|
3959 |
|
3960 var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; |
|
3961 |
|
3962 var isHidden = function( elem, el ) { |
|
3963 // isHidden might be called from jQuery#filter function; |
|
3964 // in that case, element will be second argument |
|
3965 elem = el || elem; |
|
3966 return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem ); |
|
3967 }; |
|
3968 |
|
3969 var rcheckableType = (/^(?:checkbox|radio)$/i); |
|
3970 |
|
3971 |
|
3972 |
|
3973 (function() { |
|
3974 var fragment = document.createDocumentFragment(), |
|
3975 div = fragment.appendChild( document.createElement( "div" ) ); |
|
3976 |
|
3977 // #11217 - WebKit loses check when the name is after the checked attribute |
|
3978 div.innerHTML = "<input type='radio' checked='checked' name='t'/>"; |
|
3979 |
|
3980 // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3 |
|
3981 // old WebKit doesn't clone checked state correctly in fragments |
|
3982 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; |
|
3983 |
|
3984 // Make sure textarea (and checkbox) defaultValue is properly cloned |
|
3985 // Support: IE9-IE11+ |
|
3986 div.innerHTML = "<textarea>x</textarea>"; |
|
3987 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; |
|
3988 })(); |
|
3989 var strundefined = typeof undefined; |
|
3990 |
|
3991 |
|
3992 |
|
3993 support.focusinBubbles = "onfocusin" in window; |
|
3994 |
|
3995 |
|
3996 var |
|
3997 rkeyEvent = /^key/, |
|
3998 rmouseEvent = /^(?:mouse|contextmenu)|click/, |
|
3999 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, |
|
4000 rtypenamespace = /^([^.]*)(?:\.(.+)|)$/; |
|
4001 |
|
4002 function returnTrue() { |
|
4003 return true; |
|
4004 } |
|
4005 |
|
4006 function returnFalse() { |
|
4007 return false; |
|
4008 } |
|
4009 |
|
4010 function safeActiveElement() { |
|
4011 try { |
|
4012 return document.activeElement; |
|
4013 } catch ( err ) { } |
|
4014 } |
|
4015 |
|
4016 /* |
|
4017 * Helper functions for managing events -- not part of the public interface. |
|
4018 * Props to Dean Edwards' addEvent library for many of the ideas. |
|
4019 */ |
|
4020 jQuery.event = { |
|
4021 |
|
4022 global: {}, |
|
4023 |
|
4024 add: function( elem, types, handler, data, selector ) { |
|
4025 |
|
4026 var handleObjIn, eventHandle, tmp, |
|
4027 events, t, handleObj, |
|
4028 special, handlers, type, namespaces, origType, |
|
4029 elemData = data_priv.get( elem ); |
|
4030 |
|
4031 // Don't attach events to noData or text/comment nodes (but allow plain objects) |
|
4032 if ( !elemData ) { |
|
4033 return; |
|
4034 } |
|
4035 |
|
4036 // Caller can pass in an object of custom data in lieu of the handler |
|
4037 if ( handler.handler ) { |
|
4038 handleObjIn = handler; |
|
4039 handler = handleObjIn.handler; |
|
4040 selector = handleObjIn.selector; |
|
4041 } |
|
4042 |
|
4043 // Make sure that the handler has a unique ID, used to find/remove it later |
|
4044 if ( !handler.guid ) { |
|
4045 handler.guid = jQuery.guid++; |
|
4046 } |
|
4047 |
|
4048 // Init the element's event structure and main handler, if this is the first |
|
4049 if ( !(events = elemData.events) ) { |
|
4050 events = elemData.events = {}; |
|
4051 } |
|
4052 if ( !(eventHandle = elemData.handle) ) { |
|
4053 eventHandle = elemData.handle = function( e ) { |
|
4054 // Discard the second event of a jQuery.event.trigger() and |
|
4055 // when an event is called after a page has unloaded |
|
4056 return typeof jQuery !== strundefined && jQuery.event.triggered !== e.type ? |
|
4057 jQuery.event.dispatch.apply( elem, arguments ) : undefined; |
|
4058 }; |
|
4059 } |
|
4060 |
|
4061 // Handle multiple events separated by a space |
|
4062 types = ( types || "" ).match( rnotwhite ) || [ "" ]; |
|
4063 t = types.length; |
|
4064 while ( t-- ) { |
|
4065 tmp = rtypenamespace.exec( types[t] ) || []; |
|
4066 type = origType = tmp[1]; |
|
4067 namespaces = ( tmp[2] || "" ).split( "." ).sort(); |
|
4068 |
|
4069 // There *must* be a type, no attaching namespace-only handlers |
|
4070 if ( !type ) { |
|
4071 continue; |
|
4072 } |
|
4073 |
|
4074 // If event changes its type, use the special event handlers for the changed type |
|
4075 special = jQuery.event.special[ type ] || {}; |
|
4076 |
|
4077 // If selector defined, determine special event api type, otherwise given type |
|
4078 type = ( selector ? special.delegateType : special.bindType ) || type; |
|
4079 |
|
4080 // Update special based on newly reset type |
|
4081 special = jQuery.event.special[ type ] || {}; |
|
4082 |
|
4083 // handleObj is passed to all event handlers |
|
4084 handleObj = jQuery.extend({ |
|
4085 type: type, |
|
4086 origType: origType, |
|
4087 data: data, |
|
4088 handler: handler, |
|
4089 guid: handler.guid, |
|
4090 selector: selector, |
|
4091 needsContext: selector && jQuery.expr.match.needsContext.test( selector ), |
|
4092 namespace: namespaces.join(".") |
|
4093 }, handleObjIn ); |
|
4094 |
|
4095 // Init the event handler queue if we're the first |
|
4096 if ( !(handlers = events[ type ]) ) { |
|
4097 handlers = events[ type ] = []; |
|
4098 handlers.delegateCount = 0; |
|
4099 |
|
4100 // Only use addEventListener if the special events handler returns false |
|
4101 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { |
|
4102 if ( elem.addEventListener ) { |
|
4103 elem.addEventListener( type, eventHandle, false ); |
|
4104 } |
|
4105 } |
|
4106 } |
|
4107 |
|
4108 if ( special.add ) { |
|
4109 special.add.call( elem, handleObj ); |
|
4110 |
|
4111 if ( !handleObj.handler.guid ) { |
|
4112 handleObj.handler.guid = handler.guid; |
|
4113 } |
|
4114 } |
|
4115 |
|
4116 // Add to the element's handler list, delegates in front |
|
4117 if ( selector ) { |
|
4118 handlers.splice( handlers.delegateCount++, 0, handleObj ); |
|
4119 } else { |
|
4120 handlers.push( handleObj ); |
|
4121 } |
|
4122 |
|
4123 // Keep track of which events have ever been used, for event optimization |
|
4124 jQuery.event.global[ type ] = true; |
|
4125 } |
|
4126 |
|
4127 }, |
|
4128 |
|
4129 // Detach an event or set of events from an element |
|
4130 remove: function( elem, types, handler, selector, mappedTypes ) { |
|
4131 |
|
4132 var j, origCount, tmp, |
|
4133 events, t, handleObj, |
|
4134 special, handlers, type, namespaces, origType, |
|
4135 elemData = data_priv.hasData( elem ) && data_priv.get( elem ); |
|
4136 |
|
4137 if ( !elemData || !(events = elemData.events) ) { |
|
4138 return; |
|
4139 } |
|
4140 |
|
4141 // Once for each type.namespace in types; type may be omitted |
|
4142 types = ( types || "" ).match( rnotwhite ) || [ "" ]; |
|
4143 t = types.length; |
|
4144 while ( t-- ) { |
|
4145 tmp = rtypenamespace.exec( types[t] ) || []; |
|
4146 type = origType = tmp[1]; |
|
4147 namespaces = ( tmp[2] || "" ).split( "." ).sort(); |
|
4148 |
|
4149 // Unbind all events (on this namespace, if provided) for the element |
|
4150 if ( !type ) { |
|
4151 for ( type in events ) { |
|
4152 jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); |
|
4153 } |
|
4154 continue; |
|
4155 } |
|
4156 |
|
4157 special = jQuery.event.special[ type ] || {}; |
|
4158 type = ( selector ? special.delegateType : special.bindType ) || type; |
|
4159 handlers = events[ type ] || []; |
|
4160 tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ); |
|
4161 |
|
4162 // Remove matching events |
|
4163 origCount = j = handlers.length; |
|
4164 while ( j-- ) { |
|
4165 handleObj = handlers[ j ]; |
|
4166 |
|
4167 if ( ( mappedTypes || origType === handleObj.origType ) && |
|
4168 ( !handler || handler.guid === handleObj.guid ) && |
|
4169 ( !tmp || tmp.test( handleObj.namespace ) ) && |
|
4170 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { |
|
4171 handlers.splice( j, 1 ); |
|
4172 |
|
4173 if ( handleObj.selector ) { |
|
4174 handlers.delegateCount--; |
|
4175 } |
|
4176 if ( special.remove ) { |
|
4177 special.remove.call( elem, handleObj ); |
|
4178 } |
|
4179 } |
|
4180 } |
|
4181 |
|
4182 // Remove generic event handler if we removed something and no more handlers exist |
|
4183 // (avoids potential for endless recursion during removal of special event handlers) |
|
4184 if ( origCount && !handlers.length ) { |
|
4185 if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) { |
|
4186 jQuery.removeEvent( elem, type, elemData.handle ); |
|
4187 } |
|
4188 |
|
4189 delete events[ type ]; |
|
4190 } |
|
4191 } |
|
4192 |
|
4193 // Remove the expando if it's no longer used |
|
4194 if ( jQuery.isEmptyObject( events ) ) { |
|
4195 delete elemData.handle; |
|
4196 data_priv.remove( elem, "events" ); |
|
4197 } |
|
4198 }, |
|
4199 |
|
4200 trigger: function( event, data, elem, onlyHandlers ) { |
|
4201 |
|
4202 var i, cur, tmp, bubbleType, ontype, handle, special, |
|
4203 eventPath = [ elem || document ], |
|
4204 type = hasOwn.call( event, "type" ) ? event.type : event, |
|
4205 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : []; |
|
4206 |
|
4207 cur = tmp = elem = elem || document; |
|
4208 |
|
4209 // Don't do events on text and comment nodes |
|
4210 if ( elem.nodeType === 3 || elem.nodeType === 8 ) { |
|
4211 return; |
|
4212 } |
|
4213 |
|
4214 // focus/blur morphs to focusin/out; ensure we're not firing them right now |
|
4215 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { |
|
4216 return; |
|
4217 } |
|
4218 |
|
4219 if ( type.indexOf(".") >= 0 ) { |
|
4220 // Namespaced trigger; create a regexp to match event type in handle() |
|
4221 namespaces = type.split("."); |
|
4222 type = namespaces.shift(); |
|
4223 namespaces.sort(); |
|
4224 } |
|
4225 ontype = type.indexOf(":") < 0 && "on" + type; |
|
4226 |
|
4227 // Caller can pass in a jQuery.Event object, Object, or just an event type string |
|
4228 event = event[ jQuery.expando ] ? |
|
4229 event : |
|
4230 new jQuery.Event( type, typeof event === "object" && event ); |
|
4231 |
|
4232 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) |
|
4233 event.isTrigger = onlyHandlers ? 2 : 3; |
|
4234 event.namespace = namespaces.join("."); |
|
4235 event.namespace_re = event.namespace ? |
|
4236 new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) : |
|
4237 null; |
|
4238 |
|
4239 // Clean up the event in case it is being reused |
|
4240 event.result = undefined; |
|
4241 if ( !event.target ) { |
|
4242 event.target = elem; |
|
4243 } |
|
4244 |
|
4245 // Clone any incoming data and prepend the event, creating the handler arg list |
|
4246 data = data == null ? |
|
4247 [ event ] : |
|
4248 jQuery.makeArray( data, [ event ] ); |
|
4249 |
|
4250 // Allow special events to draw outside the lines |
|
4251 special = jQuery.event.special[ type ] || {}; |
|
4252 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { |
|
4253 return; |
|
4254 } |
|
4255 |
|
4256 // Determine event propagation path in advance, per W3C events spec (#9951) |
|
4257 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) |
|
4258 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { |
|
4259 |
|
4260 bubbleType = special.delegateType || type; |
|
4261 if ( !rfocusMorph.test( bubbleType + type ) ) { |
|
4262 cur = cur.parentNode; |
|
4263 } |
|
4264 for ( ; cur; cur = cur.parentNode ) { |
|
4265 eventPath.push( cur ); |
|
4266 tmp = cur; |
|
4267 } |
|
4268 |
|
4269 // Only add window if we got to document (e.g., not plain obj or detached DOM) |
|
4270 if ( tmp === (elem.ownerDocument || document) ) { |
|
4271 eventPath.push( tmp.defaultView || tmp.parentWindow || window ); |
|
4272 } |
|
4273 } |
|
4274 |
|
4275 // Fire handlers on the event path |
|
4276 i = 0; |
|
4277 while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) { |
|
4278 |
|
4279 event.type = i > 1 ? |
|
4280 bubbleType : |
|
4281 special.bindType || type; |
|
4282 |
|
4283 // jQuery handler |
|
4284 handle = ( data_priv.get( cur, "events" ) || {} )[ event.type ] && data_priv.get( cur, "handle" ); |
|
4285 if ( handle ) { |
|
4286 handle.apply( cur, data ); |
|
4287 } |
|
4288 |
|
4289 // Native handler |
|
4290 handle = ontype && cur[ ontype ]; |
|
4291 if ( handle && handle.apply && jQuery.acceptData( cur ) ) { |
|
4292 event.result = handle.apply( cur, data ); |
|
4293 if ( event.result === false ) { |
|
4294 event.preventDefault(); |
|
4295 } |
|
4296 } |
|
4297 } |
|
4298 event.type = type; |
|
4299 |
|
4300 // If nobody prevented the default action, do it now |
|
4301 if ( !onlyHandlers && !event.isDefaultPrevented() ) { |
|
4302 |
|
4303 if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) && |
|
4304 jQuery.acceptData( elem ) ) { |
|
4305 |
|
4306 // Call a native DOM method on the target with the same name name as the event. |
|
4307 // Don't do default actions on window, that's where global variables be (#6170) |
|
4308 if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) { |
|
4309 |
|
4310 // Don't re-trigger an onFOO event when we call its FOO() method |
|
4311 tmp = elem[ ontype ]; |
|
4312 |
|
4313 if ( tmp ) { |
|
4314 elem[ ontype ] = null; |
|
4315 } |
|
4316 |
|
4317 // Prevent re-triggering of the same event, since we already bubbled it above |
|
4318 jQuery.event.triggered = type; |
|
4319 elem[ type ](); |
|
4320 jQuery.event.triggered = undefined; |
|
4321 |
|
4322 if ( tmp ) { |
|
4323 elem[ ontype ] = tmp; |
|
4324 } |
|
4325 } |
|
4326 } |
|
4327 } |
|
4328 |
|
4329 return event.result; |
|
4330 }, |
|
4331 |
|
4332 dispatch: function( event ) { |
|
4333 |
|
4334 // Make a writable jQuery.Event from the native event object |
|
4335 event = jQuery.event.fix( event ); |
|
4336 |
|
4337 var i, j, ret, matched, handleObj, |
|
4338 handlerQueue = [], |
|
4339 args = slice.call( arguments ), |
|
4340 handlers = ( data_priv.get( this, "events" ) || {} )[ event.type ] || [], |
|
4341 special = jQuery.event.special[ event.type ] || {}; |
|
4342 |
|
4343 // Use the fix-ed jQuery.Event rather than the (read-only) native event |
|
4344 args[0] = event; |
|
4345 event.delegateTarget = this; |
|
4346 |
|
4347 // Call the preDispatch hook for the mapped type, and let it bail if desired |
|
4348 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { |
|
4349 return; |
|
4350 } |
|
4351 |
|
4352 // Determine handlers |
|
4353 handlerQueue = jQuery.event.handlers.call( this, event, handlers ); |
|
4354 |
|
4355 // Run delegates first; they may want to stop propagation beneath us |
|
4356 i = 0; |
|
4357 while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) { |
|
4358 event.currentTarget = matched.elem; |
|
4359 |
|
4360 j = 0; |
|
4361 while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) { |
|
4362 |
|
4363 // Triggered event must either 1) have no namespace, or |
|
4364 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). |
|
4365 if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) { |
|
4366 |
|
4367 event.handleObj = handleObj; |
|
4368 event.data = handleObj.data; |
|
4369 |
|
4370 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) |
|
4371 .apply( matched.elem, args ); |
|
4372 |
|
4373 if ( ret !== undefined ) { |
|
4374 if ( (event.result = ret) === false ) { |
|
4375 event.preventDefault(); |
|
4376 event.stopPropagation(); |
|
4377 } |
|
4378 } |
|
4379 } |
|
4380 } |
|
4381 } |
|
4382 |
|
4383 // Call the postDispatch hook for the mapped type |
|
4384 if ( special.postDispatch ) { |
|
4385 special.postDispatch.call( this, event ); |
|
4386 } |
|
4387 |
|
4388 return event.result; |
|
4389 }, |
|
4390 |
|
4391 handlers: function( event, handlers ) { |
|
4392 var i, matches, sel, handleObj, |
|
4393 handlerQueue = [], |
|
4394 delegateCount = handlers.delegateCount, |
|
4395 cur = event.target; |
|
4396 |
|
4397 // Find delegate handlers |
|
4398 // Black-hole SVG <use> instance trees (#13180) |
|
4399 // Avoid non-left-click bubbling in Firefox (#3861) |
|
4400 if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) { |
|
4401 |
|
4402 for ( ; cur !== this; cur = cur.parentNode || this ) { |
|
4403 |
|
4404 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) |
|
4405 if ( cur.disabled !== true || event.type !== "click" ) { |
|
4406 matches = []; |
|
4407 for ( i = 0; i < delegateCount; i++ ) { |
|
4408 handleObj = handlers[ i ]; |
|
4409 |
|
4410 // Don't conflict with Object.prototype properties (#13203) |
|
4411 sel = handleObj.selector + " "; |
|
4412 |
|
4413 if ( matches[ sel ] === undefined ) { |
|
4414 matches[ sel ] = handleObj.needsContext ? |
|
4415 jQuery( sel, this ).index( cur ) >= 0 : |
|
4416 jQuery.find( sel, this, null, [ cur ] ).length; |
|
4417 } |
|
4418 if ( matches[ sel ] ) { |
|
4419 matches.push( handleObj ); |
|
4420 } |
|
4421 } |
|
4422 if ( matches.length ) { |
|
4423 handlerQueue.push({ elem: cur, handlers: matches }); |
|
4424 } |
|
4425 } |
|
4426 } |
|
4427 } |
|
4428 |
|
4429 // Add the remaining (directly-bound) handlers |
|
4430 if ( delegateCount < handlers.length ) { |
|
4431 handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) }); |
|
4432 } |
|
4433 |
|
4434 return handlerQueue; |
|
4435 }, |
|
4436 |
|
4437 // Includes some event props shared by KeyEvent and MouseEvent |
|
4438 props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), |
|
4439 |
|
4440 fixHooks: {}, |
|
4441 |
|
4442 keyHooks: { |
|
4443 props: "char charCode key keyCode".split(" "), |
|
4444 filter: function( event, original ) { |
|
4445 |
|
4446 // Add which for key events |
|
4447 if ( event.which == null ) { |
|
4448 event.which = original.charCode != null ? original.charCode : original.keyCode; |
|
4449 } |
|
4450 |
|
4451 return event; |
|
4452 } |
|
4453 }, |
|
4454 |
|
4455 mouseHooks: { |
|
4456 props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "), |
|
4457 filter: function( event, original ) { |
|
4458 var eventDoc, doc, body, |
|
4459 button = original.button; |
|
4460 |
|
4461 // Calculate pageX/Y if missing and clientX/Y available |
|
4462 if ( event.pageX == null && original.clientX != null ) { |
|
4463 eventDoc = event.target.ownerDocument || document; |
|
4464 doc = eventDoc.documentElement; |
|
4465 body = eventDoc.body; |
|
4466 |
|
4467 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); |
|
4468 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); |
|
4469 } |
|
4470 |
|
4471 // Add which for click: 1 === left; 2 === middle; 3 === right |
|
4472 // Note: button is not normalized, so don't use it |
|
4473 if ( !event.which && button !== undefined ) { |
|
4474 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); |
|
4475 } |
|
4476 |
|
4477 return event; |
|
4478 } |
|
4479 }, |
|
4480 |
|
4481 fix: function( event ) { |
|
4482 if ( event[ jQuery.expando ] ) { |
|
4483 return event; |
|
4484 } |
|
4485 |
|
4486 // Create a writable copy of the event object and normalize some properties |
|
4487 var i, prop, copy, |
|
4488 type = event.type, |
|
4489 originalEvent = event, |
|
4490 fixHook = this.fixHooks[ type ]; |
|
4491 |
|
4492 if ( !fixHook ) { |
|
4493 this.fixHooks[ type ] = fixHook = |
|
4494 rmouseEvent.test( type ) ? this.mouseHooks : |
|
4495 rkeyEvent.test( type ) ? this.keyHooks : |
|
4496 {}; |
|
4497 } |
|
4498 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; |
|
4499 |
|
4500 event = new jQuery.Event( originalEvent ); |
|
4501 |
|
4502 i = copy.length; |
|
4503 while ( i-- ) { |
|
4504 prop = copy[ i ]; |
|
4505 event[ prop ] = originalEvent[ prop ]; |
|
4506 } |
|
4507 |
|
4508 // Support: Cordova 2.5 (WebKit) (#13255) |
|
4509 // All events should have a target; Cordova deviceready doesn't |
|
4510 if ( !event.target ) { |
|
4511 event.target = document; |
|
4512 } |
|
4513 |
|
4514 // Support: Safari 6.0+, Chrome < 28 |
|
4515 // Target should not be a text node (#504, #13143) |
|
4516 if ( event.target.nodeType === 3 ) { |
|
4517 event.target = event.target.parentNode; |
|
4518 } |
|
4519 |
|
4520 return fixHook.filter ? fixHook.filter( event, originalEvent ) : event; |
|
4521 }, |
|
4522 |
|
4523 special: { |
|
4524 load: { |
|
4525 // Prevent triggered image.load events from bubbling to window.load |
|
4526 noBubble: true |
|
4527 }, |
|
4528 focus: { |
|
4529 // Fire native event if possible so blur/focus sequence is correct |
|
4530 trigger: function() { |
|
4531 if ( this !== safeActiveElement() && this.focus ) { |
|
4532 this.focus(); |
|
4533 return false; |
|
4534 } |
|
4535 }, |
|
4536 delegateType: "focusin" |
|
4537 }, |
|
4538 blur: { |
|
4539 trigger: function() { |
|
4540 if ( this === safeActiveElement() && this.blur ) { |
|
4541 this.blur(); |
|
4542 return false; |
|
4543 } |
|
4544 }, |
|
4545 delegateType: "focusout" |
|
4546 }, |
|
4547 click: { |
|
4548 // For checkbox, fire native event so checked state will be right |
|
4549 trigger: function() { |
|
4550 if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) { |
|
4551 this.click(); |
|
4552 return false; |
|
4553 } |
|
4554 }, |
|
4555 |
|
4556 // For cross-browser consistency, don't fire native .click() on links |
|
4557 _default: function( event ) { |
|
4558 return jQuery.nodeName( event.target, "a" ); |
|
4559 } |
|
4560 }, |
|
4561 |
|
4562 beforeunload: { |
|
4563 postDispatch: function( event ) { |
|
4564 |
|
4565 // Support: Firefox 20+ |
|
4566 // Firefox doesn't alert if the returnValue field is not set. |
|
4567 if ( event.result !== undefined ) { |
|
4568 event.originalEvent.returnValue = event.result; |
|
4569 } |
|
4570 } |
|
4571 } |
|
4572 }, |
|
4573 |
|
4574 simulate: function( type, elem, event, bubble ) { |
|
4575 // Piggyback on a donor event to simulate a different one. |
|
4576 // Fake originalEvent to avoid donor's stopPropagation, but if the |
|
4577 // simulated event prevents default then we do the same on the donor. |
|
4578 var e = jQuery.extend( |
|
4579 new jQuery.Event(), |
|
4580 event, |
|
4581 { |
|
4582 type: type, |
|
4583 isSimulated: true, |
|
4584 originalEvent: {} |
|
4585 } |
|
4586 ); |
|
4587 if ( bubble ) { |
|
4588 jQuery.event.trigger( e, null, elem ); |
|
4589 } else { |
|
4590 jQuery.event.dispatch.call( elem, e ); |
|
4591 } |
|
4592 if ( e.isDefaultPrevented() ) { |
|
4593 event.preventDefault(); |
|
4594 } |
|
4595 } |
|
4596 }; |
|
4597 |
|
4598 jQuery.removeEvent = function( elem, type, handle ) { |
|
4599 if ( elem.removeEventListener ) { |
|
4600 elem.removeEventListener( type, handle, false ); |
|
4601 } |
|
4602 }; |
|
4603 |
|
4604 jQuery.Event = function( src, props ) { |
|
4605 // Allow instantiation without the 'new' keyword |
|
4606 if ( !(this instanceof jQuery.Event) ) { |
|
4607 return new jQuery.Event( src, props ); |
|
4608 } |
|
4609 |
|
4610 // Event object |
|
4611 if ( src && src.type ) { |
|
4612 this.originalEvent = src; |
|
4613 this.type = src.type; |
|
4614 |
|
4615 // Events bubbling up the document may have been marked as prevented |
|
4616 // by a handler lower down the tree; reflect the correct value. |
|
4617 this.isDefaultPrevented = src.defaultPrevented || |
|
4618 // Support: Android < 4.0 |
|
4619 src.defaultPrevented === undefined && |
|
4620 src.getPreventDefault && src.getPreventDefault() ? |
|
4621 returnTrue : |
|
4622 returnFalse; |
|
4623 |
|
4624 // Event type |
|
4625 } else { |
|
4626 this.type = src; |
|
4627 } |
|
4628 |
|
4629 // Put explicitly provided properties onto the event object |
|
4630 if ( props ) { |
|
4631 jQuery.extend( this, props ); |
|
4632 } |
|
4633 |
|
4634 // Create a timestamp if incoming event doesn't have one |
|
4635 this.timeStamp = src && src.timeStamp || jQuery.now(); |
|
4636 |
|
4637 // Mark it as fixed |
|
4638 this[ jQuery.expando ] = true; |
|
4639 }; |
|
4640 |
|
4641 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding |
|
4642 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html |
|
4643 jQuery.Event.prototype = { |
|
4644 isDefaultPrevented: returnFalse, |
|
4645 isPropagationStopped: returnFalse, |
|
4646 isImmediatePropagationStopped: returnFalse, |
|
4647 |
|
4648 preventDefault: function() { |
|
4649 var e = this.originalEvent; |
|
4650 |
|
4651 this.isDefaultPrevented = returnTrue; |
|
4652 |
|
4653 if ( e && e.preventDefault ) { |
|
4654 e.preventDefault(); |
|
4655 } |
|
4656 }, |
|
4657 stopPropagation: function() { |
|
4658 var e = this.originalEvent; |
|
4659 |
|
4660 this.isPropagationStopped = returnTrue; |
|
4661 |
|
4662 if ( e && e.stopPropagation ) { |
|
4663 e.stopPropagation(); |
|
4664 } |
|
4665 }, |
|
4666 stopImmediatePropagation: function() { |
|
4667 this.isImmediatePropagationStopped = returnTrue; |
|
4668 this.stopPropagation(); |
|
4669 } |
|
4670 }; |
|
4671 |
|
4672 // Create mouseenter/leave events using mouseover/out and event-time checks |
|
4673 // Support: Chrome 15+ |
|
4674 jQuery.each({ |
|
4675 mouseenter: "mouseover", |
|
4676 mouseleave: "mouseout" |
|
4677 }, function( orig, fix ) { |
|
4678 jQuery.event.special[ orig ] = { |
|
4679 delegateType: fix, |
|
4680 bindType: fix, |
|
4681 |
|
4682 handle: function( event ) { |
|
4683 var ret, |
|
4684 target = this, |
|
4685 related = event.relatedTarget, |
|
4686 handleObj = event.handleObj; |
|
4687 |
|
4688 // For mousenter/leave call the handler if related is outside the target. |
|
4689 // NB: No relatedTarget if the mouse left/entered the browser window |
|
4690 if ( !related || (related !== target && !jQuery.contains( target, related )) ) { |
|
4691 event.type = handleObj.origType; |
|
4692 ret = handleObj.handler.apply( this, arguments ); |
|
4693 event.type = fix; |
|
4694 } |
|
4695 return ret; |
|
4696 } |
|
4697 }; |
|
4698 }); |
|
4699 |
|
4700 // Create "bubbling" focus and blur events |
|
4701 // Support: Firefox, Chrome, Safari |
|
4702 if ( !support.focusinBubbles ) { |
|
4703 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { |
|
4704 |
|
4705 // Attach a single capturing handler on the document while someone wants focusin/focusout |
|
4706 var handler = function( event ) { |
|
4707 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); |
|
4708 }; |
|
4709 |
|
4710 jQuery.event.special[ fix ] = { |
|
4711 setup: function() { |
|
4712 var doc = this.ownerDocument || this, |
|
4713 attaches = data_priv.access( doc, fix ); |
|
4714 |
|
4715 if ( !attaches ) { |
|
4716 doc.addEventListener( orig, handler, true ); |
|
4717 } |
|
4718 data_priv.access( doc, fix, ( attaches || 0 ) + 1 ); |
|
4719 }, |
|
4720 teardown: function() { |
|
4721 var doc = this.ownerDocument || this, |
|
4722 attaches = data_priv.access( doc, fix ) - 1; |
|
4723 |
|
4724 if ( !attaches ) { |
|
4725 doc.removeEventListener( orig, handler, true ); |
|
4726 data_priv.remove( doc, fix ); |
|
4727 |
|
4728 } else { |
|
4729 data_priv.access( doc, fix, attaches ); |
|
4730 } |
|
4731 } |
|
4732 }; |
|
4733 }); |
|
4734 } |
|
4735 |
|
4736 jQuery.fn.extend({ |
|
4737 |
|
4738 on: function( types, selector, data, fn, /*INTERNAL*/ one ) { |
|
4739 var origFn, type; |
|
4740 |
|
4741 // Types can be a map of types/handlers |
|
4742 if ( typeof types === "object" ) { |
|
4743 // ( types-Object, selector, data ) |
|
4744 if ( typeof selector !== "string" ) { |
|
4745 // ( types-Object, data ) |
|
4746 data = data || selector; |
|
4747 selector = undefined; |
|
4748 } |
|
4749 for ( type in types ) { |
|
4750 this.on( type, selector, data, types[ type ], one ); |
|
4751 } |
|
4752 return this; |
|
4753 } |
|
4754 |
|
4755 if ( data == null && fn == null ) { |
|
4756 // ( types, fn ) |
|
4757 fn = selector; |
|
4758 data = selector = undefined; |
|
4759 } else if ( fn == null ) { |
|
4760 if ( typeof selector === "string" ) { |
|
4761 // ( types, selector, fn ) |
|
4762 fn = data; |
|
4763 data = undefined; |
|
4764 } else { |
|
4765 // ( types, data, fn ) |
|
4766 fn = data; |
|
4767 data = selector; |
|
4768 selector = undefined; |
|
4769 } |
|
4770 } |
|
4771 if ( fn === false ) { |
|
4772 fn = returnFalse; |
|
4773 } else if ( !fn ) { |
|
4774 return this; |
|
4775 } |
|
4776 |
|
4777 if ( one === 1 ) { |
|
4778 origFn = fn; |
|
4779 fn = function( event ) { |
|
4780 // Can use an empty set, since event contains the info |
|
4781 jQuery().off( event ); |
|
4782 return origFn.apply( this, arguments ); |
|
4783 }; |
|
4784 // Use same guid so caller can remove using origFn |
|
4785 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); |
|
4786 } |
|
4787 return this.each( function() { |
|
4788 jQuery.event.add( this, types, fn, data, selector ); |
|
4789 }); |
|
4790 }, |
|
4791 one: function( types, selector, data, fn ) { |
|
4792 return this.on( types, selector, data, fn, 1 ); |
|
4793 }, |
|
4794 off: function( types, selector, fn ) { |
|
4795 var handleObj, type; |
|
4796 if ( types && types.preventDefault && types.handleObj ) { |
|
4797 // ( event ) dispatched jQuery.Event |
|
4798 handleObj = types.handleObj; |
|
4799 jQuery( types.delegateTarget ).off( |
|
4800 handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, |
|
4801 handleObj.selector, |
|
4802 handleObj.handler |
|
4803 ); |
|
4804 return this; |
|
4805 } |
|
4806 if ( typeof types === "object" ) { |
|
4807 // ( types-object [, selector] ) |
|
4808 for ( type in types ) { |
|
4809 this.off( type, selector, types[ type ] ); |
|
4810 } |
|
4811 return this; |
|
4812 } |
|
4813 if ( selector === false || typeof selector === "function" ) { |
|
4814 // ( types [, fn] ) |
|
4815 fn = selector; |
|
4816 selector = undefined; |
|
4817 } |
|
4818 if ( fn === false ) { |
|
4819 fn = returnFalse; |
|
4820 } |
|
4821 return this.each(function() { |
|
4822 jQuery.event.remove( this, types, fn, selector ); |
|
4823 }); |
|
4824 }, |
|
4825 |
|
4826 trigger: function( type, data ) { |
|
4827 return this.each(function() { |
|
4828 jQuery.event.trigger( type, data, this ); |
|
4829 }); |
|
4830 }, |
|
4831 triggerHandler: function( type, data ) { |
|
4832 var elem = this[0]; |
|
4833 if ( elem ) { |
|
4834 return jQuery.event.trigger( type, data, elem, true ); |
|
4835 } |
|
4836 } |
|
4837 }); |
|
4838 |
|
4839 |
|
4840 var |
|
4841 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, |
|
4842 rtagName = /<([\w:]+)/, |
|
4843 rhtml = /<|&#?\w+;/, |
|
4844 rnoInnerhtml = /<(?:script|style|link)/i, |
|
4845 // checked="checked" or checked |
|
4846 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, |
|
4847 rscriptType = /^$|\/(?:java|ecma)script/i, |
|
4848 rscriptTypeMasked = /^true\/(.*)/, |
|
4849 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g, |
|
4850 |
|
4851 // We have to close these tags to support XHTML (#13200) |
|
4852 wrapMap = { |
|
4853 |
|
4854 // Support: IE 9 |
|
4855 option: [ 1, "<select multiple='multiple'>", "</select>" ], |
|
4856 |
|
4857 thead: [ 1, "<table>", "</table>" ], |
|
4858 col: [ 2, "<table><colgroup>", "</colgroup></table>" ], |
|
4859 tr: [ 2, "<table><tbody>", "</tbody></table>" ], |
|
4860 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], |
|
4861 |
|
4862 _default: [ 0, "", "" ] |
|
4863 }; |
|
4864 |
|
4865 // Support: IE 9 |
|
4866 wrapMap.optgroup = wrapMap.option; |
|
4867 |
|
4868 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; |
|
4869 wrapMap.th = wrapMap.td; |
|
4870 |
|
4871 // Support: 1.x compatibility |
|
4872 // Manipulating tables requires a tbody |
|
4873 function manipulationTarget( elem, content ) { |
|
4874 return jQuery.nodeName( elem, "table" ) && |
|
4875 jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ? |
|
4876 |
|
4877 elem.getElementsByTagName("tbody")[0] || |
|
4878 elem.appendChild( elem.ownerDocument.createElement("tbody") ) : |
|
4879 elem; |
|
4880 } |
|
4881 |
|
4882 // Replace/restore the type attribute of script elements for safe DOM manipulation |
|
4883 function disableScript( elem ) { |
|
4884 elem.type = (elem.getAttribute("type") !== null) + "/" + elem.type; |
|
4885 return elem; |
|
4886 } |
|
4887 function restoreScript( elem ) { |
|
4888 var match = rscriptTypeMasked.exec( elem.type ); |
|
4889 |
|
4890 if ( match ) { |
|
4891 elem.type = match[ 1 ]; |
|
4892 } else { |
|
4893 elem.removeAttribute("type"); |
|
4894 } |
|
4895 |
|
4896 return elem; |
|
4897 } |
|
4898 |
|
4899 // Mark scripts as having already been evaluated |
|
4900 function setGlobalEval( elems, refElements ) { |
|
4901 var i = 0, |
|
4902 l = elems.length; |
|
4903 |
|
4904 for ( ; i < l; i++ ) { |
|
4905 data_priv.set( |
|
4906 elems[ i ], "globalEval", !refElements || data_priv.get( refElements[ i ], "globalEval" ) |
|
4907 ); |
|
4908 } |
|
4909 } |
|
4910 |
|
4911 function cloneCopyEvent( src, dest ) { |
|
4912 var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events; |
|
4913 |
|
4914 if ( dest.nodeType !== 1 ) { |
|
4915 return; |
|
4916 } |
|
4917 |
|
4918 // 1. Copy private data: events, handlers, etc. |
|
4919 if ( data_priv.hasData( src ) ) { |
|
4920 pdataOld = data_priv.access( src ); |
|
4921 pdataCur = data_priv.set( dest, pdataOld ); |
|
4922 events = pdataOld.events; |
|
4923 |
|
4924 if ( events ) { |
|
4925 delete pdataCur.handle; |
|
4926 pdataCur.events = {}; |
|
4927 |
|
4928 for ( type in events ) { |
|
4929 for ( i = 0, l = events[ type ].length; i < l; i++ ) { |
|
4930 jQuery.event.add( dest, type, events[ type ][ i ] ); |
|
4931 } |
|
4932 } |
|
4933 } |
|
4934 } |
|
4935 |
|
4936 // 2. Copy user data |
|
4937 if ( data_user.hasData( src ) ) { |
|
4938 udataOld = data_user.access( src ); |
|
4939 udataCur = jQuery.extend( {}, udataOld ); |
|
4940 |
|
4941 data_user.set( dest, udataCur ); |
|
4942 } |
|
4943 } |
|
4944 |
|
4945 function getAll( context, tag ) { |
|
4946 var ret = context.getElementsByTagName ? context.getElementsByTagName( tag || "*" ) : |
|
4947 context.querySelectorAll ? context.querySelectorAll( tag || "*" ) : |
|
4948 []; |
|
4949 |
|
4950 return tag === undefined || tag && jQuery.nodeName( context, tag ) ? |
|
4951 jQuery.merge( [ context ], ret ) : |
|
4952 ret; |
|
4953 } |
|
4954 |
|
4955 // Support: IE >= 9 |
|
4956 function fixInput( src, dest ) { |
|
4957 var nodeName = dest.nodeName.toLowerCase(); |
|
4958 |
|
4959 // Fails to persist the checked state of a cloned checkbox or radio button. |
|
4960 if ( nodeName === "input" && rcheckableType.test( src.type ) ) { |
|
4961 dest.checked = src.checked; |
|
4962 |
|
4963 // Fails to return the selected option to the default selected state when cloning options |
|
4964 } else if ( nodeName === "input" || nodeName === "textarea" ) { |
|
4965 dest.defaultValue = src.defaultValue; |
|
4966 } |
|
4967 } |
|
4968 |
|
4969 jQuery.extend({ |
|
4970 clone: function( elem, dataAndEvents, deepDataAndEvents ) { |
|
4971 var i, l, srcElements, destElements, |
|
4972 clone = elem.cloneNode( true ), |
|
4973 inPage = jQuery.contains( elem.ownerDocument, elem ); |
|
4974 |
|
4975 // Support: IE >= 9 |
|
4976 // Fix Cloning issues |
|
4977 if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && |
|
4978 !jQuery.isXMLDoc( elem ) ) { |
|
4979 |
|
4980 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2 |
|
4981 destElements = getAll( clone ); |
|
4982 srcElements = getAll( elem ); |
|
4983 |
|
4984 for ( i = 0, l = srcElements.length; i < l; i++ ) { |
|
4985 fixInput( srcElements[ i ], destElements[ i ] ); |
|
4986 } |
|
4987 } |
|
4988 |
|
4989 // Copy the events from the original to the clone |
|
4990 if ( dataAndEvents ) { |
|
4991 if ( deepDataAndEvents ) { |
|
4992 srcElements = srcElements || getAll( elem ); |
|
4993 destElements = destElements || getAll( clone ); |
|
4994 |
|
4995 for ( i = 0, l = srcElements.length; i < l; i++ ) { |
|
4996 cloneCopyEvent( srcElements[ i ], destElements[ i ] ); |
|
4997 } |
|
4998 } else { |
|
4999 cloneCopyEvent( elem, clone ); |
|
5000 } |
|
5001 } |
|
5002 |
|
5003 // Preserve script evaluation history |
|
5004 destElements = getAll( clone, "script" ); |
|
5005 if ( destElements.length > 0 ) { |
|
5006 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); |
|
5007 } |
|
5008 |
|
5009 // Return the cloned set |
|
5010 return clone; |
|
5011 }, |
|
5012 |
|
5013 buildFragment: function( elems, context, scripts, selection ) { |
|
5014 var elem, tmp, tag, wrap, contains, j, |
|
5015 fragment = context.createDocumentFragment(), |
|
5016 nodes = [], |
|
5017 i = 0, |
|
5018 l = elems.length; |
|
5019 |
|
5020 for ( ; i < l; i++ ) { |
|
5021 elem = elems[ i ]; |
|
5022 |
|
5023 if ( elem || elem === 0 ) { |
|
5024 |
|
5025 // Add nodes directly |
|
5026 if ( jQuery.type( elem ) === "object" ) { |
|
5027 // Support: QtWebKit |
|
5028 // jQuery.merge because push.apply(_, arraylike) throws |
|
5029 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); |
|
5030 |
|
5031 // Convert non-html into a text node |
|
5032 } else if ( !rhtml.test( elem ) ) { |
|
5033 nodes.push( context.createTextNode( elem ) ); |
|
5034 |
|
5035 // Convert html into DOM nodes |
|
5036 } else { |
|
5037 tmp = tmp || fragment.appendChild( context.createElement("div") ); |
|
5038 |
|
5039 // Deserialize a standard representation |
|
5040 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase(); |
|
5041 wrap = wrapMap[ tag ] || wrapMap._default; |
|
5042 tmp.innerHTML = wrap[ 1 ] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[ 2 ]; |
|
5043 |
|
5044 // Descend through wrappers to the right content |
|
5045 j = wrap[ 0 ]; |
|
5046 while ( j-- ) { |
|
5047 tmp = tmp.lastChild; |
|
5048 } |
|
5049 |
|
5050 // Support: QtWebKit |
|
5051 // jQuery.merge because push.apply(_, arraylike) throws |
|
5052 jQuery.merge( nodes, tmp.childNodes ); |
|
5053 |
|
5054 // Remember the top-level container |
|
5055 tmp = fragment.firstChild; |
|
5056 |
|
5057 // Fixes #12346 |
|
5058 // Support: Webkit, IE |
|
5059 tmp.textContent = ""; |
|
5060 } |
|
5061 } |
|
5062 } |
|
5063 |
|
5064 // Remove wrapper from fragment |
|
5065 fragment.textContent = ""; |
|
5066 |
|
5067 i = 0; |
|
5068 while ( (elem = nodes[ i++ ]) ) { |
|
5069 |
|
5070 // #4087 - If origin and destination elements are the same, and this is |
|
5071 // that element, do not do anything |
|
5072 if ( selection && jQuery.inArray( elem, selection ) !== -1 ) { |
|
5073 continue; |
|
5074 } |
|
5075 |
|
5076 contains = jQuery.contains( elem.ownerDocument, elem ); |
|
5077 |
|
5078 // Append to fragment |
|
5079 tmp = getAll( fragment.appendChild( elem ), "script" ); |
|
5080 |
|
5081 // Preserve script evaluation history |
|
5082 if ( contains ) { |
|
5083 setGlobalEval( tmp ); |
|
5084 } |
|
5085 |
|
5086 // Capture executables |
|
5087 if ( scripts ) { |
|
5088 j = 0; |
|
5089 while ( (elem = tmp[ j++ ]) ) { |
|
5090 if ( rscriptType.test( elem.type || "" ) ) { |
|
5091 scripts.push( elem ); |
|
5092 } |
|
5093 } |
|
5094 } |
|
5095 } |
|
5096 |
|
5097 return fragment; |
|
5098 }, |
|
5099 |
|
5100 cleanData: function( elems ) { |
|
5101 var data, elem, events, type, key, j, |
|
5102 special = jQuery.event.special, |
|
5103 i = 0; |
|
5104 |
|
5105 for ( ; (elem = elems[ i ]) !== undefined; i++ ) { |
|
5106 if ( jQuery.acceptData( elem ) ) { |
|
5107 key = elem[ data_priv.expando ]; |
|
5108 |
|
5109 if ( key && (data = data_priv.cache[ key ]) ) { |
|
5110 events = Object.keys( data.events || {} ); |
|
5111 if ( events.length ) { |
|
5112 for ( j = 0; (type = events[j]) !== undefined; j++ ) { |
|
5113 if ( special[ type ] ) { |
|
5114 jQuery.event.remove( elem, type ); |
|
5115 |
|
5116 // This is a shortcut to avoid jQuery.event.remove's overhead |
|
5117 } else { |
|
5118 jQuery.removeEvent( elem, type, data.handle ); |
|
5119 } |
|
5120 } |
|
5121 } |
|
5122 if ( data_priv.cache[ key ] ) { |
|
5123 // Discard any remaining `private` data |
|
5124 delete data_priv.cache[ key ]; |
|
5125 } |
|
5126 } |
|
5127 } |
|
5128 // Discard any remaining `user` data |
|
5129 delete data_user.cache[ elem[ data_user.expando ] ]; |
|
5130 } |
|
5131 } |
|
5132 }); |
|
5133 |
|
5134 jQuery.fn.extend({ |
|
5135 text: function( value ) { |
|
5136 return access( this, function( value ) { |
|
5137 return value === undefined ? |
|
5138 jQuery.text( this ) : |
|
5139 this.empty().each(function() { |
|
5140 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { |
|
5141 this.textContent = value; |
|
5142 } |
|
5143 }); |
|
5144 }, null, value, arguments.length ); |
|
5145 }, |
|
5146 |
|
5147 append: function() { |
|
5148 return this.domManip( arguments, function( elem ) { |
|
5149 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { |
|
5150 var target = manipulationTarget( this, elem ); |
|
5151 target.appendChild( elem ); |
|
5152 } |
|
5153 }); |
|
5154 }, |
|
5155 |
|
5156 prepend: function() { |
|
5157 return this.domManip( arguments, function( elem ) { |
|
5158 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { |
|
5159 var target = manipulationTarget( this, elem ); |
|
5160 target.insertBefore( elem, target.firstChild ); |
|
5161 } |
|
5162 }); |
|
5163 }, |
|
5164 |
|
5165 before: function() { |
|
5166 return this.domManip( arguments, function( elem ) { |
|
5167 if ( this.parentNode ) { |
|
5168 this.parentNode.insertBefore( elem, this ); |
|
5169 } |
|
5170 }); |
|
5171 }, |
|
5172 |
|
5173 after: function() { |
|
5174 return this.domManip( arguments, function( elem ) { |
|
5175 if ( this.parentNode ) { |
|
5176 this.parentNode.insertBefore( elem, this.nextSibling ); |
|
5177 } |
|
5178 }); |
|
5179 }, |
|
5180 |
|
5181 remove: function( selector, keepData /* Internal Use Only */ ) { |
|
5182 var elem, |
|
5183 elems = selector ? jQuery.filter( selector, this ) : this, |
|
5184 i = 0; |
|
5185 |
|
5186 for ( ; (elem = elems[i]) != null; i++ ) { |
|
5187 if ( !keepData && elem.nodeType === 1 ) { |
|
5188 jQuery.cleanData( getAll( elem ) ); |
|
5189 } |
|
5190 |
|
5191 if ( elem.parentNode ) { |
|
5192 if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) { |
|
5193 setGlobalEval( getAll( elem, "script" ) ); |
|
5194 } |
|
5195 elem.parentNode.removeChild( elem ); |
|
5196 } |
|
5197 } |
|
5198 |
|
5199 return this; |
|
5200 }, |
|
5201 |
|
5202 empty: function() { |
|
5203 var elem, |
|
5204 i = 0; |
|
5205 |
|
5206 for ( ; (elem = this[i]) != null; i++ ) { |
|
5207 if ( elem.nodeType === 1 ) { |
|
5208 |
|
5209 // Prevent memory leaks |
|
5210 jQuery.cleanData( getAll( elem, false ) ); |
|
5211 |
|
5212 // Remove any remaining nodes |
|
5213 elem.textContent = ""; |
|
5214 } |
|
5215 } |
|
5216 |
|
5217 return this; |
|
5218 }, |
|
5219 |
|
5220 clone: function( dataAndEvents, deepDataAndEvents ) { |
|
5221 dataAndEvents = dataAndEvents == null ? false : dataAndEvents; |
|
5222 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; |
|
5223 |
|
5224 return this.map(function() { |
|
5225 return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); |
|
5226 }); |
|
5227 }, |
|
5228 |
|
5229 html: function( value ) { |
|
5230 return access( this, function( value ) { |
|
5231 var elem = this[ 0 ] || {}, |
|
5232 i = 0, |
|
5233 l = this.length; |
|
5234 |
|
5235 if ( value === undefined && elem.nodeType === 1 ) { |
|
5236 return elem.innerHTML; |
|
5237 } |
|
5238 |
|
5239 // See if we can take a shortcut and just use innerHTML |
|
5240 if ( typeof value === "string" && !rnoInnerhtml.test( value ) && |
|
5241 !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) { |
|
5242 |
|
5243 value = value.replace( rxhtmlTag, "<$1></$2>" ); |
|
5244 |
|
5245 try { |
|
5246 for ( ; i < l; i++ ) { |
|
5247 elem = this[ i ] || {}; |
|
5248 |
|
5249 // Remove element nodes and prevent memory leaks |
|
5250 if ( elem.nodeType === 1 ) { |
|
5251 jQuery.cleanData( getAll( elem, false ) ); |
|
5252 elem.innerHTML = value; |
|
5253 } |
|
5254 } |
|
5255 |
|
5256 elem = 0; |
|
5257 |
|
5258 // If using innerHTML throws an exception, use the fallback method |
|
5259 } catch( e ) {} |
|
5260 } |
|
5261 |
|
5262 if ( elem ) { |
|
5263 this.empty().append( value ); |
|
5264 } |
|
5265 }, null, value, arguments.length ); |
|
5266 }, |
|
5267 |
|
5268 replaceWith: function() { |
|
5269 var arg = arguments[ 0 ]; |
|
5270 |
|
5271 // Make the changes, replacing each context element with the new content |
|
5272 this.domManip( arguments, function( elem ) { |
|
5273 arg = this.parentNode; |
|
5274 |
|
5275 jQuery.cleanData( getAll( this ) ); |
|
5276 |
|
5277 if ( arg ) { |
|
5278 arg.replaceChild( elem, this ); |
|
5279 } |
|
5280 }); |
|
5281 |
|
5282 // Force removal if there was no new content (e.g., from empty arguments) |
|
5283 return arg && (arg.length || arg.nodeType) ? this : this.remove(); |
|
5284 }, |
|
5285 |
|
5286 detach: function( selector ) { |
|
5287 return this.remove( selector, true ); |
|
5288 }, |
|
5289 |
|
5290 domManip: function( args, callback ) { |
|
5291 |
|
5292 // Flatten any nested arrays |
|
5293 args = concat.apply( [], args ); |
|
5294 |
|
5295 var fragment, first, scripts, hasScripts, node, doc, |
|
5296 i = 0, |
|
5297 l = this.length, |
|
5298 set = this, |
|
5299 iNoClone = l - 1, |
|
5300 value = args[ 0 ], |
|
5301 isFunction = jQuery.isFunction( value ); |
|
5302 |
|
5303 // We can't cloneNode fragments that contain checked, in WebKit |
|
5304 if ( isFunction || |
|
5305 ( l > 1 && typeof value === "string" && |
|
5306 !support.checkClone && rchecked.test( value ) ) ) { |
|
5307 return this.each(function( index ) { |
|
5308 var self = set.eq( index ); |
|
5309 if ( isFunction ) { |
|
5310 args[ 0 ] = value.call( this, index, self.html() ); |
|
5311 } |
|
5312 self.domManip( args, callback ); |
|
5313 }); |
|
5314 } |
|
5315 |
|
5316 if ( l ) { |
|
5317 fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this ); |
|
5318 first = fragment.firstChild; |
|
5319 |
|
5320 if ( fragment.childNodes.length === 1 ) { |
|
5321 fragment = first; |
|
5322 } |
|
5323 |
|
5324 if ( first ) { |
|
5325 scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); |
|
5326 hasScripts = scripts.length; |
|
5327 |
|
5328 // Use the original fragment for the last item instead of the first because it can end up |
|
5329 // being emptied incorrectly in certain situations (#8070). |
|
5330 for ( ; i < l; i++ ) { |
|
5331 node = fragment; |
|
5332 |
|
5333 if ( i !== iNoClone ) { |
|
5334 node = jQuery.clone( node, true, true ); |
|
5335 |
|
5336 // Keep references to cloned scripts for later restoration |
|
5337 if ( hasScripts ) { |
|
5338 // Support: QtWebKit |
|
5339 // jQuery.merge because push.apply(_, arraylike) throws |
|
5340 jQuery.merge( scripts, getAll( node, "script" ) ); |
|
5341 } |
|
5342 } |
|
5343 |
|
5344 callback.call( this[ i ], node, i ); |
|
5345 } |
|
5346 |
|
5347 if ( hasScripts ) { |
|
5348 doc = scripts[ scripts.length - 1 ].ownerDocument; |
|
5349 |
|
5350 // Reenable scripts |
|
5351 jQuery.map( scripts, restoreScript ); |
|
5352 |
|
5353 // Evaluate executable scripts on first document insertion |
|
5354 for ( i = 0; i < hasScripts; i++ ) { |
|
5355 node = scripts[ i ]; |
|
5356 if ( rscriptType.test( node.type || "" ) && |
|
5357 !data_priv.access( node, "globalEval" ) && jQuery.contains( doc, node ) ) { |
|
5358 |
|
5359 if ( node.src ) { |
|
5360 // Optional AJAX dependency, but won't run scripts if not present |
|
5361 if ( jQuery._evalUrl ) { |
|
5362 jQuery._evalUrl( node.src ); |
|
5363 } |
|
5364 } else { |
|
5365 jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) ); |
|
5366 } |
|
5367 } |
|
5368 } |
|
5369 } |
|
5370 } |
|
5371 } |
|
5372 |
|
5373 return this; |
|
5374 } |
|
5375 }); |
|
5376 |
|
5377 jQuery.each({ |
|
5378 appendTo: "append", |
|
5379 prependTo: "prepend", |
|
5380 insertBefore: "before", |
|
5381 insertAfter: "after", |
|
5382 replaceAll: "replaceWith" |
|
5383 }, function( name, original ) { |
|
5384 jQuery.fn[ name ] = function( selector ) { |
|
5385 var elems, |
|
5386 ret = [], |
|
5387 insert = jQuery( selector ), |
|
5388 last = insert.length - 1, |
|
5389 i = 0; |
|
5390 |
|
5391 for ( ; i <= last; i++ ) { |
|
5392 elems = i === last ? this : this.clone( true ); |
|
5393 jQuery( insert[ i ] )[ original ]( elems ); |
|
5394 |
|
5395 // Support: QtWebKit |
|
5396 // .get() because push.apply(_, arraylike) throws |
|
5397 push.apply( ret, elems.get() ); |
|
5398 } |
|
5399 |
|
5400 return this.pushStack( ret ); |
|
5401 }; |
|
5402 }); |
|
5403 |
|
5404 |
|
5405 var iframe, |
|
5406 elemdisplay = {}; |
|
5407 |
|
5408 /** |
|
5409 * Retrieve the actual display of a element |
|
5410 * @param {String} name nodeName of the element |
|
5411 * @param {Object} doc Document object |
|
5412 */ |
|
5413 // Called only from within defaultDisplay |
|
5414 function actualDisplay( name, doc ) { |
|
5415 var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ), |
|
5416 |
|
5417 // getDefaultComputedStyle might be reliably used only on attached element |
|
5418 display = window.getDefaultComputedStyle ? |
|
5419 |
|
5420 // Use of this method is a temporary fix (more like optmization) until something better comes along, |
|
5421 // since it was removed from specification and supported only in FF |
|
5422 window.getDefaultComputedStyle( elem[ 0 ] ).display : jQuery.css( elem[ 0 ], "display" ); |
|
5423 |
|
5424 // We don't have any data stored on the element, |
|
5425 // so use "detach" method as fast way to get rid of the element |
|
5426 elem.detach(); |
|
5427 |
|
5428 return display; |
|
5429 } |
|
5430 |
|
5431 /** |
|
5432 * Try to determine the default display value of an element |
|
5433 * @param {String} nodeName |
|
5434 */ |
|
5435 function defaultDisplay( nodeName ) { |
|
5436 var doc = document, |
|
5437 display = elemdisplay[ nodeName ]; |
|
5438 |
|
5439 if ( !display ) { |
|
5440 display = actualDisplay( nodeName, doc ); |
|
5441 |
|
5442 // If the simple way fails, read from inside an iframe |
|
5443 if ( display === "none" || !display ) { |
|
5444 |
|
5445 // Use the already-created iframe if possible |
|
5446 iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement ); |
|
5447 |
|
5448 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse |
|
5449 doc = iframe[ 0 ].contentDocument; |
|
5450 |
|
5451 // Support: IE |
|
5452 doc.write(); |
|
5453 doc.close(); |
|
5454 |
|
5455 display = actualDisplay( nodeName, doc ); |
|
5456 iframe.detach(); |
|
5457 } |
|
5458 |
|
5459 // Store the correct default display |
|
5460 elemdisplay[ nodeName ] = display; |
|
5461 } |
|
5462 |
|
5463 return display; |
|
5464 } |
|
5465 var rmargin = (/^margin/); |
|
5466 |
|
5467 var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); |
|
5468 |
|
5469 var getStyles = function( elem ) { |
|
5470 return elem.ownerDocument.defaultView.getComputedStyle( elem, null ); |
|
5471 }; |
|
5472 |
|
5473 |
|
5474 |
|
5475 function curCSS( elem, name, computed ) { |
|
5476 var width, minWidth, maxWidth, ret, |
|
5477 style = elem.style; |
|
5478 |
|
5479 computed = computed || getStyles( elem ); |
|
5480 |
|
5481 // Support: IE9 |
|
5482 // getPropertyValue is only needed for .css('filter') in IE9, see #12537 |
|
5483 if ( computed ) { |
|
5484 ret = computed.getPropertyValue( name ) || computed[ name ]; |
|
5485 } |
|
5486 |
|
5487 if ( computed ) { |
|
5488 |
|
5489 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) { |
|
5490 ret = jQuery.style( elem, name ); |
|
5491 } |
|
5492 |
|
5493 // Support: iOS < 6 |
|
5494 // A tribute to the "awesome hack by Dean Edwards" |
|
5495 // iOS < 6 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels |
|
5496 // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values |
|
5497 if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) { |
|
5498 |
|
5499 // Remember the original values |
|
5500 width = style.width; |
|
5501 minWidth = style.minWidth; |
|
5502 maxWidth = style.maxWidth; |
|
5503 |
|
5504 // Put in the new values to get a computed value out |
|
5505 style.minWidth = style.maxWidth = style.width = ret; |
|
5506 ret = computed.width; |
|
5507 |
|
5508 // Revert the changed values |
|
5509 style.width = width; |
|
5510 style.minWidth = minWidth; |
|
5511 style.maxWidth = maxWidth; |
|
5512 } |
|
5513 } |
|
5514 |
|
5515 return ret !== undefined ? |
|
5516 // Support: IE |
|
5517 // IE returns zIndex value as an integer. |
|
5518 ret + "" : |
|
5519 ret; |
|
5520 } |
|
5521 |
|
5522 |
|
5523 function addGetHookIf( conditionFn, hookFn ) { |
|
5524 // Define the hook, we'll check on the first run if it's really needed. |
|
5525 return { |
|
5526 get: function() { |
|
5527 if ( conditionFn() ) { |
|
5528 // Hook not needed (or it's not possible to use it due to missing dependency), |
|
5529 // remove it. |
|
5530 // Since there are no other hooks for marginRight, remove the whole object. |
|
5531 delete this.get; |
|
5532 return; |
|
5533 } |
|
5534 |
|
5535 // Hook needed; redefine it so that the support test is not executed again. |
|
5536 |
|
5537 return (this.get = hookFn).apply( this, arguments ); |
|
5538 } |
|
5539 }; |
|
5540 } |
|
5541 |
|
5542 |
|
5543 (function() { |
|
5544 var pixelPositionVal, boxSizingReliableVal, |
|
5545 // Support: Firefox, Android 2.3 (Prefixed box-sizing versions). |
|
5546 divReset = "padding:0;margin:0;border:0;display:block;-webkit-box-sizing:content-box;" + |
|
5547 "-moz-box-sizing:content-box;box-sizing:content-box", |
|
5548 docElem = document.documentElement, |
|
5549 container = document.createElement( "div" ), |
|
5550 div = document.createElement( "div" ); |
|
5551 |
|
5552 div.style.backgroundClip = "content-box"; |
|
5553 div.cloneNode( true ).style.backgroundClip = ""; |
|
5554 support.clearCloneStyle = div.style.backgroundClip === "content-box"; |
|
5555 |
|
5556 container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;" + |
|
5557 "margin-top:1px"; |
|
5558 container.appendChild( div ); |
|
5559 |
|
5560 // Executing both pixelPosition & boxSizingReliable tests require only one layout |
|
5561 // so they're executed at the same time to save the second computation. |
|
5562 function computePixelPositionAndBoxSizingReliable() { |
|
5563 // Support: Firefox, Android 2.3 (Prefixed box-sizing versions). |
|
5564 div.style.cssText = "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" + |
|
5565 "box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;" + |
|
5566 "position:absolute;top:1%"; |
|
5567 docElem.appendChild( container ); |
|
5568 |
|
5569 var divStyle = window.getComputedStyle( div, null ); |
|
5570 pixelPositionVal = divStyle.top !== "1%"; |
|
5571 boxSizingReliableVal = divStyle.width === "4px"; |
|
5572 |
|
5573 docElem.removeChild( container ); |
|
5574 } |
|
5575 |
|
5576 // Use window.getComputedStyle because jsdom on node.js will break without it. |
|
5577 if ( window.getComputedStyle ) { |
|
5578 jQuery.extend(support, { |
|
5579 pixelPosition: function() { |
|
5580 // This test is executed only once but we still do memoizing |
|
5581 // since we can use the boxSizingReliable pre-computing. |
|
5582 // No need to check if the test was already performed, though. |
|
5583 computePixelPositionAndBoxSizingReliable(); |
|
5584 return pixelPositionVal; |
|
5585 }, |
|
5586 boxSizingReliable: function() { |
|
5587 if ( boxSizingReliableVal == null ) { |
|
5588 computePixelPositionAndBoxSizingReliable(); |
|
5589 } |
|
5590 return boxSizingReliableVal; |
|
5591 }, |
|
5592 reliableMarginRight: function() { |
|
5593 // Support: Android 2.3 |
|
5594 // Check if div with explicit width and no margin-right incorrectly |
|
5595 // gets computed margin-right based on width of container. (#3333) |
|
5596 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right |
|
5597 // This support function is only executed once so no memoizing is needed. |
|
5598 var ret, |
|
5599 marginDiv = div.appendChild( document.createElement( "div" ) ); |
|
5600 marginDiv.style.cssText = div.style.cssText = divReset; |
|
5601 marginDiv.style.marginRight = marginDiv.style.width = "0"; |
|
5602 div.style.width = "1px"; |
|
5603 docElem.appendChild( container ); |
|
5604 |
|
5605 ret = !parseFloat( window.getComputedStyle( marginDiv, null ).marginRight ); |
|
5606 |
|
5607 docElem.removeChild( container ); |
|
5608 |
|
5609 // Clean up the div for other support tests. |
|
5610 div.innerHTML = ""; |
|
5611 |
|
5612 return ret; |
|
5613 } |
|
5614 }); |
|
5615 } |
|
5616 })(); |
|
5617 |
|
5618 |
|
5619 // A method for quickly swapping in/out CSS properties to get correct calculations. |
|
5620 jQuery.swap = function( elem, options, callback, args ) { |
|
5621 var ret, name, |
|
5622 old = {}; |
|
5623 |
|
5624 // Remember the old values, and insert the new ones |
|
5625 for ( name in options ) { |
|
5626 old[ name ] = elem.style[ name ]; |
|
5627 elem.style[ name ] = options[ name ]; |
|
5628 } |
|
5629 |
|
5630 ret = callback.apply( elem, args || [] ); |
|
5631 |
|
5632 // Revert the old values |
|
5633 for ( name in options ) { |
|
5634 elem.style[ name ] = old[ name ]; |
|
5635 } |
|
5636 |
|
5637 return ret; |
|
5638 }; |
|
5639 |
|
5640 |
|
5641 var |
|
5642 // swappable if display is none or starts with table except "table", "table-cell", or "table-caption" |
|
5643 // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display |
|
5644 rdisplayswap = /^(none|table(?!-c[ea]).+)/, |
|
5645 rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ), |
|
5646 rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ), |
|
5647 |
|
5648 cssShow = { position: "absolute", visibility: "hidden", display: "block" }, |
|
5649 cssNormalTransform = { |
|
5650 letterSpacing: 0, |
|
5651 fontWeight: 400 |
|
5652 }, |
|
5653 |
|
5654 cssPrefixes = [ "Webkit", "O", "Moz", "ms" ]; |
|
5655 |
|
5656 // return a css property mapped to a potentially vendor prefixed property |
|
5657 function vendorPropName( style, name ) { |
|
5658 |
|
5659 // shortcut for names that are not vendor prefixed |
|
5660 if ( name in style ) { |
|
5661 return name; |
|
5662 } |
|
5663 |
|
5664 // check for vendor prefixed names |
|
5665 var capName = name[0].toUpperCase() + name.slice(1), |
|
5666 origName = name, |
|
5667 i = cssPrefixes.length; |
|
5668 |
|
5669 while ( i-- ) { |
|
5670 name = cssPrefixes[ i ] + capName; |
|
5671 if ( name in style ) { |
|
5672 return name; |
|
5673 } |
|
5674 } |
|
5675 |
|
5676 return origName; |
|
5677 } |
|
5678 |
|
5679 function setPositiveNumber( elem, value, subtract ) { |
|
5680 var matches = rnumsplit.exec( value ); |
|
5681 return matches ? |
|
5682 // Guard against undefined "subtract", e.g., when used as in cssHooks |
|
5683 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) : |
|
5684 value; |
|
5685 } |
|
5686 |
|
5687 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { |
|
5688 var i = extra === ( isBorderBox ? "border" : "content" ) ? |
|
5689 // If we already have the right measurement, avoid augmentation |
|
5690 4 : |
|
5691 // Otherwise initialize for horizontal or vertical properties |
|
5692 name === "width" ? 1 : 0, |
|
5693 |
|
5694 val = 0; |
|
5695 |
|
5696 for ( ; i < 4; i += 2 ) { |
|
5697 // both box models exclude margin, so add it if we want it |
|
5698 if ( extra === "margin" ) { |
|
5699 val += jQuery.css( elem, extra + cssExpand[ i ], true, styles ); |
|
5700 } |
|
5701 |
|
5702 if ( isBorderBox ) { |
|
5703 // border-box includes padding, so remove it if we want content |
|
5704 if ( extra === "content" ) { |
|
5705 val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); |
|
5706 } |
|
5707 |
|
5708 // at this point, extra isn't border nor margin, so remove border |
|
5709 if ( extra !== "margin" ) { |
|
5710 val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); |
|
5711 } |
|
5712 } else { |
|
5713 // at this point, extra isn't content, so add padding |
|
5714 val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); |
|
5715 |
|
5716 // at this point, extra isn't content nor padding, so add border |
|
5717 if ( extra !== "padding" ) { |
|
5718 val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); |
|
5719 } |
|
5720 } |
|
5721 } |
|
5722 |
|
5723 return val; |
|
5724 } |
|
5725 |
|
5726 function getWidthOrHeight( elem, name, extra ) { |
|
5727 |
|
5728 // Start with offset property, which is equivalent to the border-box value |
|
5729 var valueIsBorderBox = true, |
|
5730 val = name === "width" ? elem.offsetWidth : elem.offsetHeight, |
|
5731 styles = getStyles( elem ), |
|
5732 isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; |
|
5733 |
|
5734 // some non-html elements return undefined for offsetWidth, so check for null/undefined |
|
5735 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 |
|
5736 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 |
|
5737 if ( val <= 0 || val == null ) { |
|
5738 // Fall back to computed then uncomputed css if necessary |
|
5739 val = curCSS( elem, name, styles ); |
|
5740 if ( val < 0 || val == null ) { |
|
5741 val = elem.style[ name ]; |
|
5742 } |
|
5743 |
|
5744 // Computed unit is not pixels. Stop here and return. |
|
5745 if ( rnumnonpx.test(val) ) { |
|
5746 return val; |
|
5747 } |
|
5748 |
|
5749 // we need the check for style in case a browser which returns unreliable values |
|
5750 // for getComputedStyle silently falls back to the reliable elem.style |
|
5751 valueIsBorderBox = isBorderBox && |
|
5752 ( support.boxSizingReliable() || val === elem.style[ name ] ); |
|
5753 |
|
5754 // Normalize "", auto, and prepare for extra |
|
5755 val = parseFloat( val ) || 0; |
|
5756 } |
|
5757 |
|
5758 // use the active box-sizing model to add/subtract irrelevant styles |
|
5759 return ( val + |
|
5760 augmentWidthOrHeight( |
|
5761 elem, |
|
5762 name, |
|
5763 extra || ( isBorderBox ? "border" : "content" ), |
|
5764 valueIsBorderBox, |
|
5765 styles |
|
5766 ) |
|
5767 ) + "px"; |
|
5768 } |
|
5769 |
|
5770 function showHide( elements, show ) { |
|
5771 var display, elem, hidden, |
|
5772 values = [], |
|
5773 index = 0, |
|
5774 length = elements.length; |
|
5775 |
|
5776 for ( ; index < length; index++ ) { |
|
5777 elem = elements[ index ]; |
|
5778 if ( !elem.style ) { |
|
5779 continue; |
|
5780 } |
|
5781 |
|
5782 values[ index ] = data_priv.get( elem, "olddisplay" ); |
|
5783 display = elem.style.display; |
|
5784 if ( show ) { |
|
5785 // Reset the inline display of this element to learn if it is |
|
5786 // being hidden by cascaded rules or not |
|
5787 if ( !values[ index ] && display === "none" ) { |
|
5788 elem.style.display = ""; |
|
5789 } |
|
5790 |
|
5791 // Set elements which have been overridden with display: none |
|
5792 // in a stylesheet to whatever the default browser style is |
|
5793 // for such an element |
|
5794 if ( elem.style.display === "" && isHidden( elem ) ) { |
|
5795 values[ index ] = data_priv.access( elem, "olddisplay", defaultDisplay(elem.nodeName) ); |
|
5796 } |
|
5797 } else { |
|
5798 |
|
5799 if ( !values[ index ] ) { |
|
5800 hidden = isHidden( elem ); |
|
5801 |
|
5802 if ( display && display !== "none" || !hidden ) { |
|
5803 data_priv.set( elem, "olddisplay", hidden ? display : jQuery.css(elem, "display") ); |
|
5804 } |
|
5805 } |
|
5806 } |
|
5807 } |
|
5808 |
|
5809 // Set the display of most of the elements in a second loop |
|
5810 // to avoid the constant reflow |
|
5811 for ( index = 0; index < length; index++ ) { |
|
5812 elem = elements[ index ]; |
|
5813 if ( !elem.style ) { |
|
5814 continue; |
|
5815 } |
|
5816 if ( !show || elem.style.display === "none" || elem.style.display === "" ) { |
|
5817 elem.style.display = show ? values[ index ] || "" : "none"; |
|
5818 } |
|
5819 } |
|
5820 |
|
5821 return elements; |
|
5822 } |
|
5823 |
|
5824 jQuery.extend({ |
|
5825 // Add in style property hooks for overriding the default |
|
5826 // behavior of getting and setting a style property |
|
5827 cssHooks: { |
|
5828 opacity: { |
|
5829 get: function( elem, computed ) { |
|
5830 if ( computed ) { |
|
5831 // We should always get a number back from opacity |
|
5832 var ret = curCSS( elem, "opacity" ); |
|
5833 return ret === "" ? "1" : ret; |
|
5834 } |
|
5835 } |
|
5836 } |
|
5837 }, |
|
5838 |
|
5839 // Don't automatically add "px" to these possibly-unitless properties |
|
5840 cssNumber: { |
|
5841 "columnCount": true, |
|
5842 "fillOpacity": true, |
|
5843 "fontWeight": true, |
|
5844 "lineHeight": true, |
|
5845 "opacity": true, |
|
5846 "order": true, |
|
5847 "orphans": true, |
|
5848 "widows": true, |
|
5849 "zIndex": true, |
|
5850 "zoom": true |
|
5851 }, |
|
5852 |
|
5853 // Add in properties whose names you wish to fix before |
|
5854 // setting or getting the value |
|
5855 cssProps: { |
|
5856 // normalize float css property |
|
5857 "float": "cssFloat" |
|
5858 }, |
|
5859 |
|
5860 // Get and set the style property on a DOM Node |
|
5861 style: function( elem, name, value, extra ) { |
|
5862 // Don't set styles on text and comment nodes |
|
5863 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { |
|
5864 return; |
|
5865 } |
|
5866 |
|
5867 // Make sure that we're working with the right name |
|
5868 var ret, type, hooks, |
|
5869 origName = jQuery.camelCase( name ), |
|
5870 style = elem.style; |
|
5871 |
|
5872 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) ); |
|
5873 |
|
5874 // gets hook for the prefixed version |
|
5875 // followed by the unprefixed version |
|
5876 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; |
|
5877 |
|
5878 // Check if we're setting a value |
|
5879 if ( value !== undefined ) { |
|
5880 type = typeof value; |
|
5881 |
|
5882 // convert relative number strings (+= or -=) to relative numbers. #7345 |
|
5883 if ( type === "string" && (ret = rrelNum.exec( value )) ) { |
|
5884 value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) ); |
|
5885 // Fixes bug #9237 |
|
5886 type = "number"; |
|
5887 } |
|
5888 |
|
5889 // Make sure that null and NaN values aren't set. See: #7116 |
|
5890 if ( value == null || value !== value ) { |
|
5891 return; |
|
5892 } |
|
5893 |
|
5894 // If a number was passed in, add 'px' to the (except for certain CSS properties) |
|
5895 if ( type === "number" && !jQuery.cssNumber[ origName ] ) { |
|
5896 value += "px"; |
|
5897 } |
|
5898 |
|
5899 // Fixes #8908, it can be done more correctly by specifying setters in cssHooks, |
|
5900 // but it would mean to define eight (for every problematic property) identical functions |
|
5901 if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) { |
|
5902 style[ name ] = "inherit"; |
|
5903 } |
|
5904 |
|
5905 // If a hook was provided, use that value, otherwise just set the specified value |
|
5906 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) { |
|
5907 // Support: Chrome, Safari |
|
5908 // Setting style to blank string required to delete "style: x !important;" |
|
5909 style[ name ] = ""; |
|
5910 style[ name ] = value; |
|
5911 } |
|
5912 |
|
5913 } else { |
|
5914 // If a hook was provided get the non-computed value from there |
|
5915 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) { |
|
5916 return ret; |
|
5917 } |
|
5918 |
|
5919 // Otherwise just get the value from the style object |
|
5920 return style[ name ]; |
|
5921 } |
|
5922 }, |
|
5923 |
|
5924 css: function( elem, name, extra, styles ) { |
|
5925 var val, num, hooks, |
|
5926 origName = jQuery.camelCase( name ); |
|
5927 |
|
5928 // Make sure that we're working with the right name |
|
5929 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) ); |
|
5930 |
|
5931 // gets hook for the prefixed version |
|
5932 // followed by the unprefixed version |
|
5933 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; |
|
5934 |
|
5935 // If a hook was provided get the computed value from there |
|
5936 if ( hooks && "get" in hooks ) { |
|
5937 val = hooks.get( elem, true, extra ); |
|
5938 } |
|
5939 |
|
5940 // Otherwise, if a way to get the computed value exists, use that |
|
5941 if ( val === undefined ) { |
|
5942 val = curCSS( elem, name, styles ); |
|
5943 } |
|
5944 |
|
5945 //convert "normal" to computed value |
|
5946 if ( val === "normal" && name in cssNormalTransform ) { |
|
5947 val = cssNormalTransform[ name ]; |
|
5948 } |
|
5949 |
|
5950 // Return, converting to number if forced or a qualifier was provided and val looks numeric |
|
5951 if ( extra === "" || extra ) { |
|
5952 num = parseFloat( val ); |
|
5953 return extra === true || jQuery.isNumeric( num ) ? num || 0 : val; |
|
5954 } |
|
5955 return val; |
|
5956 } |
|
5957 }); |
|
5958 |
|
5959 jQuery.each([ "height", "width" ], function( i, name ) { |
|
5960 jQuery.cssHooks[ name ] = { |
|
5961 get: function( elem, computed, extra ) { |
|
5962 if ( computed ) { |
|
5963 // certain elements can have dimension info if we invisibly show them |
|
5964 // however, it must have a current display style that would benefit from this |
|
5965 return elem.offsetWidth === 0 && rdisplayswap.test( jQuery.css( elem, "display" ) ) ? |
|
5966 jQuery.swap( elem, cssShow, function() { |
|
5967 return getWidthOrHeight( elem, name, extra ); |
|
5968 }) : |
|
5969 getWidthOrHeight( elem, name, extra ); |
|
5970 } |
|
5971 }, |
|
5972 |
|
5973 set: function( elem, value, extra ) { |
|
5974 var styles = extra && getStyles( elem ); |
|
5975 return setPositiveNumber( elem, value, extra ? |
|
5976 augmentWidthOrHeight( |
|
5977 elem, |
|
5978 name, |
|
5979 extra, |
|
5980 jQuery.css( elem, "boxSizing", false, styles ) === "border-box", |
|
5981 styles |
|
5982 ) : 0 |
|
5983 ); |
|
5984 } |
|
5985 }; |
|
5986 }); |
|
5987 |
|
5988 // Support: Android 2.3 |
|
5989 jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight, |
|
5990 function( elem, computed ) { |
|
5991 if ( computed ) { |
|
5992 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right |
|
5993 // Work around by temporarily setting element display to inline-block |
|
5994 return jQuery.swap( elem, { "display": "inline-block" }, |
|
5995 curCSS, [ elem, "marginRight" ] ); |
|
5996 } |
|
5997 } |
|
5998 ); |
|
5999 |
|
6000 // These hooks are used by animate to expand properties |
|
6001 jQuery.each({ |
|
6002 margin: "", |
|
6003 padding: "", |
|
6004 border: "Width" |
|
6005 }, function( prefix, suffix ) { |
|
6006 jQuery.cssHooks[ prefix + suffix ] = { |
|
6007 expand: function( value ) { |
|
6008 var i = 0, |
|
6009 expanded = {}, |
|
6010 |
|
6011 // assumes a single number if not a string |
|
6012 parts = typeof value === "string" ? value.split(" ") : [ value ]; |
|
6013 |
|
6014 for ( ; i < 4; i++ ) { |
|
6015 expanded[ prefix + cssExpand[ i ] + suffix ] = |
|
6016 parts[ i ] || parts[ i - 2 ] || parts[ 0 ]; |
|
6017 } |
|
6018 |
|
6019 return expanded; |
|
6020 } |
|
6021 }; |
|
6022 |
|
6023 if ( !rmargin.test( prefix ) ) { |
|
6024 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; |
|
6025 } |
|
6026 }); |
|
6027 |
|
6028 jQuery.fn.extend({ |
|
6029 css: function( name, value ) { |
|
6030 return access( this, function( elem, name, value ) { |
|
6031 var styles, len, |
|
6032 map = {}, |
|
6033 i = 0; |
|
6034 |
|
6035 if ( jQuery.isArray( name ) ) { |
|
6036 styles = getStyles( elem ); |
|
6037 len = name.length; |
|
6038 |
|
6039 for ( ; i < len; i++ ) { |
|
6040 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles ); |
|
6041 } |
|
6042 |
|
6043 return map; |
|
6044 } |
|
6045 |
|
6046 return value !== undefined ? |
|
6047 jQuery.style( elem, name, value ) : |
|
6048 jQuery.css( elem, name ); |
|
6049 }, name, value, arguments.length > 1 ); |
|
6050 }, |
|
6051 show: function() { |
|
6052 return showHide( this, true ); |
|
6053 }, |
|
6054 hide: function() { |
|
6055 return showHide( this ); |
|
6056 }, |
|
6057 toggle: function( state ) { |
|
6058 if ( typeof state === "boolean" ) { |
|
6059 return state ? this.show() : this.hide(); |
|
6060 } |
|
6061 |
|
6062 return this.each(function() { |
|
6063 if ( isHidden( this ) ) { |
|
6064 jQuery( this ).show(); |
|
6065 } else { |
|
6066 jQuery( this ).hide(); |
|
6067 } |
|
6068 }); |
|
6069 } |
|
6070 }); |
|
6071 |
|
6072 |
|
6073 function Tween( elem, options, prop, end, easing ) { |
|
6074 return new Tween.prototype.init( elem, options, prop, end, easing ); |
|
6075 } |
|
6076 jQuery.Tween = Tween; |
|
6077 |
|
6078 Tween.prototype = { |
|
6079 constructor: Tween, |
|
6080 init: function( elem, options, prop, end, easing, unit ) { |
|
6081 this.elem = elem; |
|
6082 this.prop = prop; |
|
6083 this.easing = easing || "swing"; |
|
6084 this.options = options; |
|
6085 this.start = this.now = this.cur(); |
|
6086 this.end = end; |
|
6087 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" ); |
|
6088 }, |
|
6089 cur: function() { |
|
6090 var hooks = Tween.propHooks[ this.prop ]; |
|
6091 |
|
6092 return hooks && hooks.get ? |
|
6093 hooks.get( this ) : |
|
6094 Tween.propHooks._default.get( this ); |
|
6095 }, |
|
6096 run: function( percent ) { |
|
6097 var eased, |
|
6098 hooks = Tween.propHooks[ this.prop ]; |
|
6099 |
|
6100 if ( this.options.duration ) { |
|
6101 this.pos = eased = jQuery.easing[ this.easing ]( |
|
6102 percent, this.options.duration * percent, 0, 1, this.options.duration |
|
6103 ); |
|
6104 } else { |
|
6105 this.pos = eased = percent; |
|
6106 } |
|
6107 this.now = ( this.end - this.start ) * eased + this.start; |
|
6108 |
|
6109 if ( this.options.step ) { |
|
6110 this.options.step.call( this.elem, this.now, this ); |
|
6111 } |
|
6112 |
|
6113 if ( hooks && hooks.set ) { |
|
6114 hooks.set( this ); |
|
6115 } else { |
|
6116 Tween.propHooks._default.set( this ); |
|
6117 } |
|
6118 return this; |
|
6119 } |
|
6120 }; |
|
6121 |
|
6122 Tween.prototype.init.prototype = Tween.prototype; |
|
6123 |
|
6124 Tween.propHooks = { |
|
6125 _default: { |
|
6126 get: function( tween ) { |
|
6127 var result; |
|
6128 |
|
6129 if ( tween.elem[ tween.prop ] != null && |
|
6130 (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) { |
|
6131 return tween.elem[ tween.prop ]; |
|
6132 } |
|
6133 |
|
6134 // passing an empty string as a 3rd parameter to .css will automatically |
|
6135 // attempt a parseFloat and fallback to a string if the parse fails |
|
6136 // so, simple values such as "10px" are parsed to Float. |
|
6137 // complex values such as "rotate(1rad)" are returned as is. |
|
6138 result = jQuery.css( tween.elem, tween.prop, "" ); |
|
6139 // Empty strings, null, undefined and "auto" are converted to 0. |
|
6140 return !result || result === "auto" ? 0 : result; |
|
6141 }, |
|
6142 set: function( tween ) { |
|
6143 // use step hook for back compat - use cssHook if its there - use .style if its |
|
6144 // available and use plain properties where available |
|
6145 if ( jQuery.fx.step[ tween.prop ] ) { |
|
6146 jQuery.fx.step[ tween.prop ]( tween ); |
|
6147 } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) { |
|
6148 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit ); |
|
6149 } else { |
|
6150 tween.elem[ tween.prop ] = tween.now; |
|
6151 } |
|
6152 } |
|
6153 } |
|
6154 }; |
|
6155 |
|
6156 // Support: IE9 |
|
6157 // Panic based approach to setting things on disconnected nodes |
|
6158 |
|
6159 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { |
|
6160 set: function( tween ) { |
|
6161 if ( tween.elem.nodeType && tween.elem.parentNode ) { |
|
6162 tween.elem[ tween.prop ] = tween.now; |
|
6163 } |
|
6164 } |
|
6165 }; |
|
6166 |
|
6167 jQuery.easing = { |
|
6168 linear: function( p ) { |
|
6169 return p; |
|
6170 }, |
|
6171 swing: function( p ) { |
|
6172 return 0.5 - Math.cos( p * Math.PI ) / 2; |
|
6173 } |
|
6174 }; |
|
6175 |
|
6176 jQuery.fx = Tween.prototype.init; |
|
6177 |
|
6178 // Back Compat <1.8 extension point |
|
6179 jQuery.fx.step = {}; |
|
6180 |
|
6181 |
|
6182 |
|
6183 |
|
6184 var |
|
6185 fxNow, timerId, |
|
6186 rfxtypes = /^(?:toggle|show|hide)$/, |
|
6187 rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ), |
|
6188 rrun = /queueHooks$/, |
|
6189 animationPrefilters = [ defaultPrefilter ], |
|
6190 tweeners = { |
|
6191 "*": [ function( prop, value ) { |
|
6192 var tween = this.createTween( prop, value ), |
|
6193 target = tween.cur(), |
|
6194 parts = rfxnum.exec( value ), |
|
6195 unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), |
|
6196 |
|
6197 // Starting value computation is required for potential unit mismatches |
|
6198 start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) && |
|
6199 rfxnum.exec( jQuery.css( tween.elem, prop ) ), |
|
6200 scale = 1, |
|
6201 maxIterations = 20; |
|
6202 |
|
6203 if ( start && start[ 3 ] !== unit ) { |
|
6204 // Trust units reported by jQuery.css |
|
6205 unit = unit || start[ 3 ]; |
|
6206 |
|
6207 // Make sure we update the tween properties later on |
|
6208 parts = parts || []; |
|
6209 |
|
6210 // Iteratively approximate from a nonzero starting point |
|
6211 start = +target || 1; |
|
6212 |
|
6213 do { |
|
6214 // If previous iteration zeroed out, double until we get *something* |
|
6215 // Use a string for doubling factor so we don't accidentally see scale as unchanged below |
|
6216 scale = scale || ".5"; |
|
6217 |
|
6218 // Adjust and apply |
|
6219 start = start / scale; |
|
6220 jQuery.style( tween.elem, prop, start + unit ); |
|
6221 |
|
6222 // Update scale, tolerating zero or NaN from tween.cur() |
|
6223 // And breaking the loop if scale is unchanged or perfect, or if we've just had enough |
|
6224 } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations ); |
|
6225 } |
|
6226 |
|
6227 // Update tween properties |
|
6228 if ( parts ) { |
|
6229 start = tween.start = +start || +target || 0; |
|
6230 tween.unit = unit; |
|
6231 // If a +=/-= token was provided, we're doing a relative animation |
|
6232 tween.end = parts[ 1 ] ? |
|
6233 start + ( parts[ 1 ] + 1 ) * parts[ 2 ] : |
|
6234 +parts[ 2 ]; |
|
6235 } |
|
6236 |
|
6237 return tween; |
|
6238 } ] |
|
6239 }; |
|
6240 |
|
6241 // Animations created synchronously will run synchronously |
|
6242 function createFxNow() { |
|
6243 setTimeout(function() { |
|
6244 fxNow = undefined; |
|
6245 }); |
|
6246 return ( fxNow = jQuery.now() ); |
|
6247 } |
|
6248 |
|
6249 // Generate parameters to create a standard animation |
|
6250 function genFx( type, includeWidth ) { |
|
6251 var which, |
|
6252 i = 0, |
|
6253 attrs = { height: type }; |
|
6254 |
|
6255 // if we include width, step value is 1 to do all cssExpand values, |
|
6256 // if we don't include width, step value is 2 to skip over Left and Right |
|
6257 includeWidth = includeWidth ? 1 : 0; |
|
6258 for ( ; i < 4 ; i += 2 - includeWidth ) { |
|
6259 which = cssExpand[ i ]; |
|
6260 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type; |
|
6261 } |
|
6262 |
|
6263 if ( includeWidth ) { |
|
6264 attrs.opacity = attrs.width = type; |
|
6265 } |
|
6266 |
|
6267 return attrs; |
|
6268 } |
|
6269 |
|
6270 function createTween( value, prop, animation ) { |
|
6271 var tween, |
|
6272 collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ), |
|
6273 index = 0, |
|
6274 length = collection.length; |
|
6275 for ( ; index < length; index++ ) { |
|
6276 if ( (tween = collection[ index ].call( animation, prop, value )) ) { |
|
6277 |
|
6278 // we're done with this property |
|
6279 return tween; |
|
6280 } |
|
6281 } |
|
6282 } |
|
6283 |
|
6284 function defaultPrefilter( elem, props, opts ) { |
|
6285 /* jshint validthis: true */ |
|
6286 var prop, value, toggle, tween, hooks, oldfire, display, |
|
6287 anim = this, |
|
6288 orig = {}, |
|
6289 style = elem.style, |
|
6290 hidden = elem.nodeType && isHidden( elem ), |
|
6291 dataShow = data_priv.get( elem, "fxshow" ); |
|
6292 |
|
6293 // handle queue: false promises |
|
6294 if ( !opts.queue ) { |
|
6295 hooks = jQuery._queueHooks( elem, "fx" ); |
|
6296 if ( hooks.unqueued == null ) { |
|
6297 hooks.unqueued = 0; |
|
6298 oldfire = hooks.empty.fire; |
|
6299 hooks.empty.fire = function() { |
|
6300 if ( !hooks.unqueued ) { |
|
6301 oldfire(); |
|
6302 } |
|
6303 }; |
|
6304 } |
|
6305 hooks.unqueued++; |
|
6306 |
|
6307 anim.always(function() { |
|
6308 // doing this makes sure that the complete handler will be called |
|
6309 // before this completes |
|
6310 anim.always(function() { |
|
6311 hooks.unqueued--; |
|
6312 if ( !jQuery.queue( elem, "fx" ).length ) { |
|
6313 hooks.empty.fire(); |
|
6314 } |
|
6315 }); |
|
6316 }); |
|
6317 } |
|
6318 |
|
6319 // height/width overflow pass |
|
6320 if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) { |
|
6321 // Make sure that nothing sneaks out |
|
6322 // Record all 3 overflow attributes because IE9-10 do not |
|
6323 // change the overflow attribute when overflowX and |
|
6324 // overflowY are set to the same value |
|
6325 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; |
|
6326 |
|
6327 // Set display property to inline-block for height/width |
|
6328 // animations on inline elements that are having width/height animated |
|
6329 display = jQuery.css( elem, "display" ); |
|
6330 // Get default display if display is currently "none" |
|
6331 if ( display === "none" ) { |
|
6332 display = defaultDisplay( elem.nodeName ); |
|
6333 } |
|
6334 if ( display === "inline" && |
|
6335 jQuery.css( elem, "float" ) === "none" ) { |
|
6336 |
|
6337 style.display = "inline-block"; |
|
6338 } |
|
6339 } |
|
6340 |
|
6341 if ( opts.overflow ) { |
|
6342 style.overflow = "hidden"; |
|
6343 anim.always(function() { |
|
6344 style.overflow = opts.overflow[ 0 ]; |
|
6345 style.overflowX = opts.overflow[ 1 ]; |
|
6346 style.overflowY = opts.overflow[ 2 ]; |
|
6347 }); |
|
6348 } |
|
6349 |
|
6350 // show/hide pass |
|
6351 for ( prop in props ) { |
|
6352 value = props[ prop ]; |
|
6353 if ( rfxtypes.exec( value ) ) { |
|
6354 delete props[ prop ]; |
|
6355 toggle = toggle || value === "toggle"; |
|
6356 if ( value === ( hidden ? "hide" : "show" ) ) { |
|
6357 |
|
6358 // If there is dataShow left over from a stopped hide or show and we are going to proceed with show, we should pretend to be hidden |
|
6359 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { |
|
6360 hidden = true; |
|
6361 } else { |
|
6362 continue; |
|
6363 } |
|
6364 } |
|
6365 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop ); |
|
6366 } |
|
6367 } |
|
6368 |
|
6369 if ( !jQuery.isEmptyObject( orig ) ) { |
|
6370 if ( dataShow ) { |
|
6371 if ( "hidden" in dataShow ) { |
|
6372 hidden = dataShow.hidden; |
|
6373 } |
|
6374 } else { |
|
6375 dataShow = data_priv.access( elem, "fxshow", {} ); |
|
6376 } |
|
6377 |
|
6378 // store state if its toggle - enables .stop().toggle() to "reverse" |
|
6379 if ( toggle ) { |
|
6380 dataShow.hidden = !hidden; |
|
6381 } |
|
6382 if ( hidden ) { |
|
6383 jQuery( elem ).show(); |
|
6384 } else { |
|
6385 anim.done(function() { |
|
6386 jQuery( elem ).hide(); |
|
6387 }); |
|
6388 } |
|
6389 anim.done(function() { |
|
6390 var prop; |
|
6391 |
|
6392 data_priv.remove( elem, "fxshow" ); |
|
6393 for ( prop in orig ) { |
|
6394 jQuery.style( elem, prop, orig[ prop ] ); |
|
6395 } |
|
6396 }); |
|
6397 for ( prop in orig ) { |
|
6398 tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim ); |
|
6399 |
|
6400 if ( !( prop in dataShow ) ) { |
|
6401 dataShow[ prop ] = tween.start; |
|
6402 if ( hidden ) { |
|
6403 tween.end = tween.start; |
|
6404 tween.start = prop === "width" || prop === "height" ? 1 : 0; |
|
6405 } |
|
6406 } |
|
6407 } |
|
6408 } |
|
6409 } |
|
6410 |
|
6411 function propFilter( props, specialEasing ) { |
|
6412 var index, name, easing, value, hooks; |
|
6413 |
|
6414 // camelCase, specialEasing and expand cssHook pass |
|
6415 for ( index in props ) { |
|
6416 name = jQuery.camelCase( index ); |
|
6417 easing = specialEasing[ name ]; |
|
6418 value = props[ index ]; |
|
6419 if ( jQuery.isArray( value ) ) { |
|
6420 easing = value[ 1 ]; |
|
6421 value = props[ index ] = value[ 0 ]; |
|
6422 } |
|
6423 |
|
6424 if ( index !== name ) { |
|
6425 props[ name ] = value; |
|
6426 delete props[ index ]; |
|
6427 } |
|
6428 |
|
6429 hooks = jQuery.cssHooks[ name ]; |
|
6430 if ( hooks && "expand" in hooks ) { |
|
6431 value = hooks.expand( value ); |
|
6432 delete props[ name ]; |
|
6433 |
|
6434 // not quite $.extend, this wont overwrite keys already present. |
|
6435 // also - reusing 'index' from above because we have the correct "name" |
|
6436 for ( index in value ) { |
|
6437 if ( !( index in props ) ) { |
|
6438 props[ index ] = value[ index ]; |
|
6439 specialEasing[ index ] = easing; |
|
6440 } |
|
6441 } |
|
6442 } else { |
|
6443 specialEasing[ name ] = easing; |
|
6444 } |
|
6445 } |
|
6446 } |
|
6447 |
|
6448 function Animation( elem, properties, options ) { |
|
6449 var result, |
|
6450 stopped, |
|
6451 index = 0, |
|
6452 length = animationPrefilters.length, |
|
6453 deferred = jQuery.Deferred().always( function() { |
|
6454 // don't match elem in the :animated selector |
|
6455 delete tick.elem; |
|
6456 }), |
|
6457 tick = function() { |
|
6458 if ( stopped ) { |
|
6459 return false; |
|
6460 } |
|
6461 var currentTime = fxNow || createFxNow(), |
|
6462 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), |
|
6463 // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497) |
|
6464 temp = remaining / animation.duration || 0, |
|
6465 percent = 1 - temp, |
|
6466 index = 0, |
|
6467 length = animation.tweens.length; |
|
6468 |
|
6469 for ( ; index < length ; index++ ) { |
|
6470 animation.tweens[ index ].run( percent ); |
|
6471 } |
|
6472 |
|
6473 deferred.notifyWith( elem, [ animation, percent, remaining ]); |
|
6474 |
|
6475 if ( percent < 1 && length ) { |
|
6476 return remaining; |
|
6477 } else { |
|
6478 deferred.resolveWith( elem, [ animation ] ); |
|
6479 return false; |
|
6480 } |
|
6481 }, |
|
6482 animation = deferred.promise({ |
|
6483 elem: elem, |
|
6484 props: jQuery.extend( {}, properties ), |
|
6485 opts: jQuery.extend( true, { specialEasing: {} }, options ), |
|
6486 originalProperties: properties, |
|
6487 originalOptions: options, |
|
6488 startTime: fxNow || createFxNow(), |
|
6489 duration: options.duration, |
|
6490 tweens: [], |
|
6491 createTween: function( prop, end ) { |
|
6492 var tween = jQuery.Tween( elem, animation.opts, prop, end, |
|
6493 animation.opts.specialEasing[ prop ] || animation.opts.easing ); |
|
6494 animation.tweens.push( tween ); |
|
6495 return tween; |
|
6496 }, |
|
6497 stop: function( gotoEnd ) { |
|
6498 var index = 0, |
|
6499 // if we are going to the end, we want to run all the tweens |
|
6500 // otherwise we skip this part |
|
6501 length = gotoEnd ? animation.tweens.length : 0; |
|
6502 if ( stopped ) { |
|
6503 return this; |
|
6504 } |
|
6505 stopped = true; |
|
6506 for ( ; index < length ; index++ ) { |
|
6507 animation.tweens[ index ].run( 1 ); |
|
6508 } |
|
6509 |
|
6510 // resolve when we played the last frame |
|
6511 // otherwise, reject |
|
6512 if ( gotoEnd ) { |
|
6513 deferred.resolveWith( elem, [ animation, gotoEnd ] ); |
|
6514 } else { |
|
6515 deferred.rejectWith( elem, [ animation, gotoEnd ] ); |
|
6516 } |
|
6517 return this; |
|
6518 } |
|
6519 }), |
|
6520 props = animation.props; |
|
6521 |
|
6522 propFilter( props, animation.opts.specialEasing ); |
|
6523 |
|
6524 for ( ; index < length ; index++ ) { |
|
6525 result = animationPrefilters[ index ].call( animation, elem, props, animation.opts ); |
|
6526 if ( result ) { |
|
6527 return result; |
|
6528 } |
|
6529 } |
|
6530 |
|
6531 jQuery.map( props, createTween, animation ); |
|
6532 |
|
6533 if ( jQuery.isFunction( animation.opts.start ) ) { |
|
6534 animation.opts.start.call( elem, animation ); |
|
6535 } |
|
6536 |
|
6537 jQuery.fx.timer( |
|
6538 jQuery.extend( tick, { |
|
6539 elem: elem, |
|
6540 anim: animation, |
|
6541 queue: animation.opts.queue |
|
6542 }) |
|
6543 ); |
|
6544 |
|
6545 // attach callbacks from options |
|
6546 return animation.progress( animation.opts.progress ) |
|
6547 .done( animation.opts.done, animation.opts.complete ) |
|
6548 .fail( animation.opts.fail ) |
|
6549 .always( animation.opts.always ); |
|
6550 } |
|
6551 |
|
6552 jQuery.Animation = jQuery.extend( Animation, { |
|
6553 |
|
6554 tweener: function( props, callback ) { |
|
6555 if ( jQuery.isFunction( props ) ) { |
|
6556 callback = props; |
|
6557 props = [ "*" ]; |
|
6558 } else { |
|
6559 props = props.split(" "); |
|
6560 } |
|
6561 |
|
6562 var prop, |
|
6563 index = 0, |
|
6564 length = props.length; |
|
6565 |
|
6566 for ( ; index < length ; index++ ) { |
|
6567 prop = props[ index ]; |
|
6568 tweeners[ prop ] = tweeners[ prop ] || []; |
|
6569 tweeners[ prop ].unshift( callback ); |
|
6570 } |
|
6571 }, |
|
6572 |
|
6573 prefilter: function( callback, prepend ) { |
|
6574 if ( prepend ) { |
|
6575 animationPrefilters.unshift( callback ); |
|
6576 } else { |
|
6577 animationPrefilters.push( callback ); |
|
6578 } |
|
6579 } |
|
6580 }); |
|
6581 |
|
6582 jQuery.speed = function( speed, easing, fn ) { |
|
6583 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { |
|
6584 complete: fn || !fn && easing || |
|
6585 jQuery.isFunction( speed ) && speed, |
|
6586 duration: speed, |
|
6587 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing |
|
6588 }; |
|
6589 |
|
6590 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : |
|
6591 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default; |
|
6592 |
|
6593 // normalize opt.queue - true/undefined/null -> "fx" |
|
6594 if ( opt.queue == null || opt.queue === true ) { |
|
6595 opt.queue = "fx"; |
|
6596 } |
|
6597 |
|
6598 // Queueing |
|
6599 opt.old = opt.complete; |
|
6600 |
|
6601 opt.complete = function() { |
|
6602 if ( jQuery.isFunction( opt.old ) ) { |
|
6603 opt.old.call( this ); |
|
6604 } |
|
6605 |
|
6606 if ( opt.queue ) { |
|
6607 jQuery.dequeue( this, opt.queue ); |
|
6608 } |
|
6609 }; |
|
6610 |
|
6611 return opt; |
|
6612 }; |
|
6613 |
|
6614 jQuery.fn.extend({ |
|
6615 fadeTo: function( speed, to, easing, callback ) { |
|
6616 |
|
6617 // show any hidden elements after setting opacity to 0 |
|
6618 return this.filter( isHidden ).css( "opacity", 0 ).show() |
|
6619 |
|
6620 // animate to the value specified |
|
6621 .end().animate({ opacity: to }, speed, easing, callback ); |
|
6622 }, |
|
6623 animate: function( prop, speed, easing, callback ) { |
|
6624 var empty = jQuery.isEmptyObject( prop ), |
|
6625 optall = jQuery.speed( speed, easing, callback ), |
|
6626 doAnimation = function() { |
|
6627 // Operate on a copy of prop so per-property easing won't be lost |
|
6628 var anim = Animation( this, jQuery.extend( {}, prop ), optall ); |
|
6629 |
|
6630 // Empty animations, or finishing resolves immediately |
|
6631 if ( empty || data_priv.get( this, "finish" ) ) { |
|
6632 anim.stop( true ); |
|
6633 } |
|
6634 }; |
|
6635 doAnimation.finish = doAnimation; |
|
6636 |
|
6637 return empty || optall.queue === false ? |
|
6638 this.each( doAnimation ) : |
|
6639 this.queue( optall.queue, doAnimation ); |
|
6640 }, |
|
6641 stop: function( type, clearQueue, gotoEnd ) { |
|
6642 var stopQueue = function( hooks ) { |
|
6643 var stop = hooks.stop; |
|
6644 delete hooks.stop; |
|
6645 stop( gotoEnd ); |
|
6646 }; |
|
6647 |
|
6648 if ( typeof type !== "string" ) { |
|
6649 gotoEnd = clearQueue; |
|
6650 clearQueue = type; |
|
6651 type = undefined; |
|
6652 } |
|
6653 if ( clearQueue && type !== false ) { |
|
6654 this.queue( type || "fx", [] ); |
|
6655 } |
|
6656 |
|
6657 return this.each(function() { |
|
6658 var dequeue = true, |
|
6659 index = type != null && type + "queueHooks", |
|
6660 timers = jQuery.timers, |
|
6661 data = data_priv.get( this ); |
|
6662 |
|
6663 if ( index ) { |
|
6664 if ( data[ index ] && data[ index ].stop ) { |
|
6665 stopQueue( data[ index ] ); |
|
6666 } |
|
6667 } else { |
|
6668 for ( index in data ) { |
|
6669 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) { |
|
6670 stopQueue( data[ index ] ); |
|
6671 } |
|
6672 } |
|
6673 } |
|
6674 |
|
6675 for ( index = timers.length; index--; ) { |
|
6676 if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) { |
|
6677 timers[ index ].anim.stop( gotoEnd ); |
|
6678 dequeue = false; |
|
6679 timers.splice( index, 1 ); |
|
6680 } |
|
6681 } |
|
6682 |
|
6683 // start the next in the queue if the last step wasn't forced |
|
6684 // timers currently will call their complete callbacks, which will dequeue |
|
6685 // but only if they were gotoEnd |
|
6686 if ( dequeue || !gotoEnd ) { |
|
6687 jQuery.dequeue( this, type ); |
|
6688 } |
|
6689 }); |
|
6690 }, |
|
6691 finish: function( type ) { |
|
6692 if ( type !== false ) { |
|
6693 type = type || "fx"; |
|
6694 } |
|
6695 return this.each(function() { |
|
6696 var index, |
|
6697 data = data_priv.get( this ), |
|
6698 queue = data[ type + "queue" ], |
|
6699 hooks = data[ type + "queueHooks" ], |
|
6700 timers = jQuery.timers, |
|
6701 length = queue ? queue.length : 0; |
|
6702 |
|
6703 // enable finishing flag on private data |
|
6704 data.finish = true; |
|
6705 |
|
6706 // empty the queue first |
|
6707 jQuery.queue( this, type, [] ); |
|
6708 |
|
6709 if ( hooks && hooks.stop ) { |
|
6710 hooks.stop.call( this, true ); |
|
6711 } |
|
6712 |
|
6713 // look for any active animations, and finish them |
|
6714 for ( index = timers.length; index--; ) { |
|
6715 if ( timers[ index ].elem === this && timers[ index ].queue === type ) { |
|
6716 timers[ index ].anim.stop( true ); |
|
6717 timers.splice( index, 1 ); |
|
6718 } |
|
6719 } |
|
6720 |
|
6721 // look for any animations in the old queue and finish them |
|
6722 for ( index = 0; index < length; index++ ) { |
|
6723 if ( queue[ index ] && queue[ index ].finish ) { |
|
6724 queue[ index ].finish.call( this ); |
|
6725 } |
|
6726 } |
|
6727 |
|
6728 // turn off finishing flag |
|
6729 delete data.finish; |
|
6730 }); |
|
6731 } |
|
6732 }); |
|
6733 |
|
6734 jQuery.each([ "toggle", "show", "hide" ], function( i, name ) { |
|
6735 var cssFn = jQuery.fn[ name ]; |
|
6736 jQuery.fn[ name ] = function( speed, easing, callback ) { |
|
6737 return speed == null || typeof speed === "boolean" ? |
|
6738 cssFn.apply( this, arguments ) : |
|
6739 this.animate( genFx( name, true ), speed, easing, callback ); |
|
6740 }; |
|
6741 }); |
|
6742 |
|
6743 // Generate shortcuts for custom animations |
|
6744 jQuery.each({ |
|
6745 slideDown: genFx("show"), |
|
6746 slideUp: genFx("hide"), |
|
6747 slideToggle: genFx("toggle"), |
|
6748 fadeIn: { opacity: "show" }, |
|
6749 fadeOut: { opacity: "hide" }, |
|
6750 fadeToggle: { opacity: "toggle" } |
|
6751 }, function( name, props ) { |
|
6752 jQuery.fn[ name ] = function( speed, easing, callback ) { |
|
6753 return this.animate( props, speed, easing, callback ); |
|
6754 }; |
|
6755 }); |
|
6756 |
|
6757 jQuery.timers = []; |
|
6758 jQuery.fx.tick = function() { |
|
6759 var timer, |
|
6760 i = 0, |
|
6761 timers = jQuery.timers; |
|
6762 |
|
6763 fxNow = jQuery.now(); |
|
6764 |
|
6765 for ( ; i < timers.length; i++ ) { |
|
6766 timer = timers[ i ]; |
|
6767 // Checks the timer has not already been removed |
|
6768 if ( !timer() && timers[ i ] === timer ) { |
|
6769 timers.splice( i--, 1 ); |
|
6770 } |
|
6771 } |
|
6772 |
|
6773 if ( !timers.length ) { |
|
6774 jQuery.fx.stop(); |
|
6775 } |
|
6776 fxNow = undefined; |
|
6777 }; |
|
6778 |
|
6779 jQuery.fx.timer = function( timer ) { |
|
6780 jQuery.timers.push( timer ); |
|
6781 if ( timer() ) { |
|
6782 jQuery.fx.start(); |
|
6783 } else { |
|
6784 jQuery.timers.pop(); |
|
6785 } |
|
6786 }; |
|
6787 |
|
6788 jQuery.fx.interval = 13; |
|
6789 |
|
6790 jQuery.fx.start = function() { |
|
6791 if ( !timerId ) { |
|
6792 timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval ); |
|
6793 } |
|
6794 }; |
|
6795 |
|
6796 jQuery.fx.stop = function() { |
|
6797 clearInterval( timerId ); |
|
6798 timerId = null; |
|
6799 }; |
|
6800 |
|
6801 jQuery.fx.speeds = { |
|
6802 slow: 600, |
|
6803 fast: 200, |
|
6804 // Default speed |
|
6805 _default: 400 |
|
6806 }; |
|
6807 |
|
6808 |
|
6809 // Based off of the plugin by Clint Helfers, with permission. |
|
6810 // http://blindsignals.com/index.php/2009/07/jquery-delay/ |
|
6811 jQuery.fn.delay = function( time, type ) { |
|
6812 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; |
|
6813 type = type || "fx"; |
|
6814 |
|
6815 return this.queue( type, function( next, hooks ) { |
|
6816 var timeout = setTimeout( next, time ); |
|
6817 hooks.stop = function() { |
|
6818 clearTimeout( timeout ); |
|
6819 }; |
|
6820 }); |
|
6821 }; |
|
6822 |
|
6823 |
|
6824 (function() { |
|
6825 var input = document.createElement( "input" ), |
|
6826 select = document.createElement( "select" ), |
|
6827 opt = select.appendChild( document.createElement( "option" ) ); |
|
6828 |
|
6829 input.type = "checkbox"; |
|
6830 |
|
6831 // Support: iOS 5.1, Android 4.x, Android 2.3 |
|
6832 // Check the default checkbox/radio value ("" on old WebKit; "on" elsewhere) |
|
6833 support.checkOn = input.value !== ""; |
|
6834 |
|
6835 // Must access the parent to make an option select properly |
|
6836 // Support: IE9, IE10 |
|
6837 support.optSelected = opt.selected; |
|
6838 |
|
6839 // Make sure that the options inside disabled selects aren't marked as disabled |
|
6840 // (WebKit marks them as disabled) |
|
6841 select.disabled = true; |
|
6842 support.optDisabled = !opt.disabled; |
|
6843 |
|
6844 // Check if an input maintains its value after becoming a radio |
|
6845 // Support: IE9, IE10 |
|
6846 input = document.createElement( "input" ); |
|
6847 input.value = "t"; |
|
6848 input.type = "radio"; |
|
6849 support.radioValue = input.value === "t"; |
|
6850 })(); |
|
6851 |
|
6852 |
3798 var nodeHook, boolHook, |
6853 var nodeHook, boolHook, |
3799 rclass = /[\t\r\n\f]/g, |
6854 attrHandle = jQuery.expr.attrHandle; |
3800 rreturn = /\r/g, |
|
3801 rfocusable = /^(?:input|select|textarea|button)$/i; |
|
3802 |
6855 |
3803 jQuery.fn.extend({ |
6856 jQuery.fn.extend({ |
3804 attr: function( name, value ) { |
6857 attr: function( name, value ) { |
3805 return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 ); |
6858 return access( this, jQuery.attr, name, value, arguments.length > 1 ); |
3806 }, |
6859 }, |
3807 |
6860 |
3808 removeAttr: function( name ) { |
6861 removeAttr: function( name ) { |
3809 return this.each(function() { |
6862 return this.each(function() { |
3810 jQuery.removeAttr( this, name ); |
6863 jQuery.removeAttr( this, name ); |
3811 }); |
6864 }); |
3812 }, |
|
3813 |
|
3814 prop: function( name, value ) { |
|
3815 return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 ); |
|
3816 }, |
|
3817 |
|
3818 removeProp: function( name ) { |
|
3819 return this.each(function() { |
|
3820 delete this[ jQuery.propFix[ name ] || name ]; |
|
3821 }); |
|
3822 }, |
|
3823 |
|
3824 addClass: function( value ) { |
|
3825 var classes, elem, cur, clazz, j, |
|
3826 i = 0, |
|
3827 len = this.length, |
|
3828 proceed = typeof value === "string" && value; |
|
3829 |
|
3830 if ( jQuery.isFunction( value ) ) { |
|
3831 return this.each(function( j ) { |
|
3832 jQuery( this ).addClass( value.call( this, j, this.className ) ); |
|
3833 }); |
|
3834 } |
|
3835 |
|
3836 if ( proceed ) { |
|
3837 // The disjunction here is for better compressibility (see removeClass) |
|
3838 classes = ( value || "" ).match( core_rnotwhite ) || []; |
|
3839 |
|
3840 for ( ; i < len; i++ ) { |
|
3841 elem = this[ i ]; |
|
3842 cur = elem.nodeType === 1 && ( elem.className ? |
|
3843 ( " " + elem.className + " " ).replace( rclass, " " ) : |
|
3844 " " |
|
3845 ); |
|
3846 |
|
3847 if ( cur ) { |
|
3848 j = 0; |
|
3849 while ( (clazz = classes[j++]) ) { |
|
3850 if ( cur.indexOf( " " + clazz + " " ) < 0 ) { |
|
3851 cur += clazz + " "; |
|
3852 } |
|
3853 } |
|
3854 elem.className = jQuery.trim( cur ); |
|
3855 |
|
3856 } |
|
3857 } |
|
3858 } |
|
3859 |
|
3860 return this; |
|
3861 }, |
|
3862 |
|
3863 removeClass: function( value ) { |
|
3864 var classes, elem, cur, clazz, j, |
|
3865 i = 0, |
|
3866 len = this.length, |
|
3867 proceed = arguments.length === 0 || typeof value === "string" && value; |
|
3868 |
|
3869 if ( jQuery.isFunction( value ) ) { |
|
3870 return this.each(function( j ) { |
|
3871 jQuery( this ).removeClass( value.call( this, j, this.className ) ); |
|
3872 }); |
|
3873 } |
|
3874 if ( proceed ) { |
|
3875 classes = ( value || "" ).match( core_rnotwhite ) || []; |
|
3876 |
|
3877 for ( ; i < len; i++ ) { |
|
3878 elem = this[ i ]; |
|
3879 // This expression is here for better compressibility (see addClass) |
|
3880 cur = elem.nodeType === 1 && ( elem.className ? |
|
3881 ( " " + elem.className + " " ).replace( rclass, " " ) : |
|
3882 "" |
|
3883 ); |
|
3884 |
|
3885 if ( cur ) { |
|
3886 j = 0; |
|
3887 while ( (clazz = classes[j++]) ) { |
|
3888 // Remove *all* instances |
|
3889 while ( cur.indexOf( " " + clazz + " " ) >= 0 ) { |
|
3890 cur = cur.replace( " " + clazz + " ", " " ); |
|
3891 } |
|
3892 } |
|
3893 elem.className = value ? jQuery.trim( cur ) : ""; |
|
3894 } |
|
3895 } |
|
3896 } |
|
3897 |
|
3898 return this; |
|
3899 }, |
|
3900 |
|
3901 toggleClass: function( value, stateVal ) { |
|
3902 var type = typeof value; |
|
3903 |
|
3904 if ( typeof stateVal === "boolean" && type === "string" ) { |
|
3905 return stateVal ? this.addClass( value ) : this.removeClass( value ); |
|
3906 } |
|
3907 |
|
3908 if ( jQuery.isFunction( value ) ) { |
|
3909 return this.each(function( i ) { |
|
3910 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); |
|
3911 }); |
|
3912 } |
|
3913 |
|
3914 return this.each(function() { |
|
3915 if ( type === "string" ) { |
|
3916 // toggle individual class names |
|
3917 var className, |
|
3918 i = 0, |
|
3919 self = jQuery( this ), |
|
3920 classNames = value.match( core_rnotwhite ) || []; |
|
3921 |
|
3922 while ( (className = classNames[ i++ ]) ) { |
|
3923 // check each className given, space separated list |
|
3924 if ( self.hasClass( className ) ) { |
|
3925 self.removeClass( className ); |
|
3926 } else { |
|
3927 self.addClass( className ); |
|
3928 } |
|
3929 } |
|
3930 |
|
3931 // Toggle whole class name |
|
3932 } else if ( type === core_strundefined || type === "boolean" ) { |
|
3933 if ( this.className ) { |
|
3934 // store className if set |
|
3935 data_priv.set( this, "__className__", this.className ); |
|
3936 } |
|
3937 |
|
3938 // If the element has a class name or if we're passed "false", |
|
3939 // then remove the whole classname (if there was one, the above saved it). |
|
3940 // Otherwise bring back whatever was previously saved (if anything), |
|
3941 // falling back to the empty string if nothing was stored. |
|
3942 this.className = this.className || value === false ? "" : data_priv.get( this, "__className__" ) || ""; |
|
3943 } |
|
3944 }); |
|
3945 }, |
|
3946 |
|
3947 hasClass: function( selector ) { |
|
3948 var className = " " + selector + " ", |
|
3949 i = 0, |
|
3950 l = this.length; |
|
3951 for ( ; i < l; i++ ) { |
|
3952 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) { |
|
3953 return true; |
|
3954 } |
|
3955 } |
|
3956 |
|
3957 return false; |
|
3958 }, |
|
3959 |
|
3960 val: function( value ) { |
|
3961 var hooks, ret, isFunction, |
|
3962 elem = this[0]; |
|
3963 |
|
3964 if ( !arguments.length ) { |
|
3965 if ( elem ) { |
|
3966 hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ]; |
|
3967 |
|
3968 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { |
|
3969 return ret; |
|
3970 } |
|
3971 |
|
3972 ret = elem.value; |
|
3973 |
|
3974 return typeof ret === "string" ? |
|
3975 // handle most common string cases |
|
3976 ret.replace(rreturn, "") : |
|
3977 // handle cases where value is null/undef or number |
|
3978 ret == null ? "" : ret; |
|
3979 } |
|
3980 |
|
3981 return; |
|
3982 } |
|
3983 |
|
3984 isFunction = jQuery.isFunction( value ); |
|
3985 |
|
3986 return this.each(function( i ) { |
|
3987 var val; |
|
3988 |
|
3989 if ( this.nodeType !== 1 ) { |
|
3990 return; |
|
3991 } |
|
3992 |
|
3993 if ( isFunction ) { |
|
3994 val = value.call( this, i, jQuery( this ).val() ); |
|
3995 } else { |
|
3996 val = value; |
|
3997 } |
|
3998 |
|
3999 // Treat null/undefined as ""; convert numbers to string |
|
4000 if ( val == null ) { |
|
4001 val = ""; |
|
4002 } else if ( typeof val === "number" ) { |
|
4003 val += ""; |
|
4004 } else if ( jQuery.isArray( val ) ) { |
|
4005 val = jQuery.map(val, function ( value ) { |
|
4006 return value == null ? "" : value + ""; |
|
4007 }); |
|
4008 } |
|
4009 |
|
4010 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; |
|
4011 |
|
4012 // If set returns undefined, fall back to normal setting |
|
4013 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { |
|
4014 this.value = val; |
|
4015 } |
|
4016 }); |
|
4017 } |
6865 } |
4018 }); |
6866 }); |
4019 |
6867 |
4020 jQuery.extend({ |
6868 jQuery.extend({ |
4021 valHooks: { |
|
4022 option: { |
|
4023 get: function( elem ) { |
|
4024 // attributes.value is undefined in Blackberry 4.7 but |
|
4025 // uses .value. See #6932 |
|
4026 var val = elem.attributes.value; |
|
4027 return !val || val.specified ? elem.value : elem.text; |
|
4028 } |
|
4029 }, |
|
4030 select: { |
|
4031 get: function( elem ) { |
|
4032 var value, option, |
|
4033 options = elem.options, |
|
4034 index = elem.selectedIndex, |
|
4035 one = elem.type === "select-one" || index < 0, |
|
4036 values = one ? null : [], |
|
4037 max = one ? index + 1 : options.length, |
|
4038 i = index < 0 ? |
|
4039 max : |
|
4040 one ? index : 0; |
|
4041 |
|
4042 // Loop through all the selected options |
|
4043 for ( ; i < max; i++ ) { |
|
4044 option = options[ i ]; |
|
4045 |
|
4046 // IE6-9 doesn't update selected after form reset (#2551) |
|
4047 if ( ( option.selected || i === index ) && |
|
4048 // Don't return options that are disabled or in a disabled optgroup |
|
4049 ( jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) && |
|
4050 ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) { |
|
4051 |
|
4052 // Get the specific value for the option |
|
4053 value = jQuery( option ).val(); |
|
4054 |
|
4055 // We don't need an array for one selects |
|
4056 if ( one ) { |
|
4057 return value; |
|
4058 } |
|
4059 |
|
4060 // Multi-Selects return an array |
|
4061 values.push( value ); |
|
4062 } |
|
4063 } |
|
4064 |
|
4065 return values; |
|
4066 }, |
|
4067 |
|
4068 set: function( elem, value ) { |
|
4069 var optionSet, option, |
|
4070 options = elem.options, |
|
4071 values = jQuery.makeArray( value ), |
|
4072 i = options.length; |
|
4073 |
|
4074 while ( i-- ) { |
|
4075 option = options[ i ]; |
|
4076 if ( (option.selected = jQuery.inArray( jQuery(option).val(), values ) >= 0) ) { |
|
4077 optionSet = true; |
|
4078 } |
|
4079 } |
|
4080 |
|
4081 // force browsers to behave consistently when non-matching value is set |
|
4082 if ( !optionSet ) { |
|
4083 elem.selectedIndex = -1; |
|
4084 } |
|
4085 return values; |
|
4086 } |
|
4087 } |
|
4088 }, |
|
4089 |
|
4090 attr: function( elem, name, value ) { |
6869 attr: function( elem, name, value ) { |
4091 var hooks, ret, |
6870 var hooks, ret, |
4092 nType = elem.nodeType; |
6871 nType = elem.nodeType; |
4093 |
6872 |
4094 // don't get/set attributes on text, comment and attribute nodes |
6873 // don't get/set attributes on text, comment and attribute nodes |
4095 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { |
6874 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { |
4096 return; |
6875 return; |
4097 } |
6876 } |
4098 |
6877 |
4099 // Fallback to prop when attributes are not supported |
6878 // Fallback to prop when attributes are not supported |
4100 if ( typeof elem.getAttribute === core_strundefined ) { |
6879 if ( typeof elem.getAttribute === strundefined ) { |
4101 return jQuery.prop( elem, name, value ); |
6880 return jQuery.prop( elem, name, value ); |
4102 } |
6881 } |
4103 |
6882 |
4104 // All attributes are lowercase |
6883 // All attributes are lowercase |
4105 // Grab necessary hook if one is defined |
6884 // Grab necessary hook if one is defined |
4278 "contentEditable" |
7073 "contentEditable" |
4279 ], function() { |
7074 ], function() { |
4280 jQuery.propFix[ this.toLowerCase() ] = this; |
7075 jQuery.propFix[ this.toLowerCase() ] = this; |
4281 }); |
7076 }); |
4282 |
7077 |
|
7078 |
|
7079 |
|
7080 |
|
7081 var rclass = /[\t\r\n\f]/g; |
|
7082 |
|
7083 jQuery.fn.extend({ |
|
7084 addClass: function( value ) { |
|
7085 var classes, elem, cur, clazz, j, finalValue, |
|
7086 proceed = typeof value === "string" && value, |
|
7087 i = 0, |
|
7088 len = this.length; |
|
7089 |
|
7090 if ( jQuery.isFunction( value ) ) { |
|
7091 return this.each(function( j ) { |
|
7092 jQuery( this ).addClass( value.call( this, j, this.className ) ); |
|
7093 }); |
|
7094 } |
|
7095 |
|
7096 if ( proceed ) { |
|
7097 // The disjunction here is for better compressibility (see removeClass) |
|
7098 classes = ( value || "" ).match( rnotwhite ) || []; |
|
7099 |
|
7100 for ( ; i < len; i++ ) { |
|
7101 elem = this[ i ]; |
|
7102 cur = elem.nodeType === 1 && ( elem.className ? |
|
7103 ( " " + elem.className + " " ).replace( rclass, " " ) : |
|
7104 " " |
|
7105 ); |
|
7106 |
|
7107 if ( cur ) { |
|
7108 j = 0; |
|
7109 while ( (clazz = classes[j++]) ) { |
|
7110 if ( cur.indexOf( " " + clazz + " " ) < 0 ) { |
|
7111 cur += clazz + " "; |
|
7112 } |
|
7113 } |
|
7114 |
|
7115 // only assign if different to avoid unneeded rendering. |
|
7116 finalValue = jQuery.trim( cur ); |
|
7117 if ( elem.className !== finalValue ) { |
|
7118 elem.className = finalValue; |
|
7119 } |
|
7120 } |
|
7121 } |
|
7122 } |
|
7123 |
|
7124 return this; |
|
7125 }, |
|
7126 |
|
7127 removeClass: function( value ) { |
|
7128 var classes, elem, cur, clazz, j, finalValue, |
|
7129 proceed = arguments.length === 0 || typeof value === "string" && value, |
|
7130 i = 0, |
|
7131 len = this.length; |
|
7132 |
|
7133 if ( jQuery.isFunction( value ) ) { |
|
7134 return this.each(function( j ) { |
|
7135 jQuery( this ).removeClass( value.call( this, j, this.className ) ); |
|
7136 }); |
|
7137 } |
|
7138 if ( proceed ) { |
|
7139 classes = ( value || "" ).match( rnotwhite ) || []; |
|
7140 |
|
7141 for ( ; i < len; i++ ) { |
|
7142 elem = this[ i ]; |
|
7143 // This expression is here for better compressibility (see addClass) |
|
7144 cur = elem.nodeType === 1 && ( elem.className ? |
|
7145 ( " " + elem.className + " " ).replace( rclass, " " ) : |
|
7146 "" |
|
7147 ); |
|
7148 |
|
7149 if ( cur ) { |
|
7150 j = 0; |
|
7151 while ( (clazz = classes[j++]) ) { |
|
7152 // Remove *all* instances |
|
7153 while ( cur.indexOf( " " + clazz + " " ) >= 0 ) { |
|
7154 cur = cur.replace( " " + clazz + " ", " " ); |
|
7155 } |
|
7156 } |
|
7157 |
|
7158 // only assign if different to avoid unneeded rendering. |
|
7159 finalValue = value ? jQuery.trim( cur ) : ""; |
|
7160 if ( elem.className !== finalValue ) { |
|
7161 elem.className = finalValue; |
|
7162 } |
|
7163 } |
|
7164 } |
|
7165 } |
|
7166 |
|
7167 return this; |
|
7168 }, |
|
7169 |
|
7170 toggleClass: function( value, stateVal ) { |
|
7171 var type = typeof value; |
|
7172 |
|
7173 if ( typeof stateVal === "boolean" && type === "string" ) { |
|
7174 return stateVal ? this.addClass( value ) : this.removeClass( value ); |
|
7175 } |
|
7176 |
|
7177 if ( jQuery.isFunction( value ) ) { |
|
7178 return this.each(function( i ) { |
|
7179 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); |
|
7180 }); |
|
7181 } |
|
7182 |
|
7183 return this.each(function() { |
|
7184 if ( type === "string" ) { |
|
7185 // toggle individual class names |
|
7186 var className, |
|
7187 i = 0, |
|
7188 self = jQuery( this ), |
|
7189 classNames = value.match( rnotwhite ) || []; |
|
7190 |
|
7191 while ( (className = classNames[ i++ ]) ) { |
|
7192 // check each className given, space separated list |
|
7193 if ( self.hasClass( className ) ) { |
|
7194 self.removeClass( className ); |
|
7195 } else { |
|
7196 self.addClass( className ); |
|
7197 } |
|
7198 } |
|
7199 |
|
7200 // Toggle whole class name |
|
7201 } else if ( type === strundefined || type === "boolean" ) { |
|
7202 if ( this.className ) { |
|
7203 // store className if set |
|
7204 data_priv.set( this, "__className__", this.className ); |
|
7205 } |
|
7206 |
|
7207 // If the element has a class name or if we're passed "false", |
|
7208 // then remove the whole classname (if there was one, the above saved it). |
|
7209 // Otherwise bring back whatever was previously saved (if anything), |
|
7210 // falling back to the empty string if nothing was stored. |
|
7211 this.className = this.className || value === false ? "" : data_priv.get( this, "__className__" ) || ""; |
|
7212 } |
|
7213 }); |
|
7214 }, |
|
7215 |
|
7216 hasClass: function( selector ) { |
|
7217 var className = " " + selector + " ", |
|
7218 i = 0, |
|
7219 l = this.length; |
|
7220 for ( ; i < l; i++ ) { |
|
7221 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) { |
|
7222 return true; |
|
7223 } |
|
7224 } |
|
7225 |
|
7226 return false; |
|
7227 } |
|
7228 }); |
|
7229 |
|
7230 |
|
7231 |
|
7232 |
|
7233 var rreturn = /\r/g; |
|
7234 |
|
7235 jQuery.fn.extend({ |
|
7236 val: function( value ) { |
|
7237 var hooks, ret, isFunction, |
|
7238 elem = this[0]; |
|
7239 |
|
7240 if ( !arguments.length ) { |
|
7241 if ( elem ) { |
|
7242 hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ]; |
|
7243 |
|
7244 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { |
|
7245 return ret; |
|
7246 } |
|
7247 |
|
7248 ret = elem.value; |
|
7249 |
|
7250 return typeof ret === "string" ? |
|
7251 // handle most common string cases |
|
7252 ret.replace(rreturn, "") : |
|
7253 // handle cases where value is null/undef or number |
|
7254 ret == null ? "" : ret; |
|
7255 } |
|
7256 |
|
7257 return; |
|
7258 } |
|
7259 |
|
7260 isFunction = jQuery.isFunction( value ); |
|
7261 |
|
7262 return this.each(function( i ) { |
|
7263 var val; |
|
7264 |
|
7265 if ( this.nodeType !== 1 ) { |
|
7266 return; |
|
7267 } |
|
7268 |
|
7269 if ( isFunction ) { |
|
7270 val = value.call( this, i, jQuery( this ).val() ); |
|
7271 } else { |
|
7272 val = value; |
|
7273 } |
|
7274 |
|
7275 // Treat null/undefined as ""; convert numbers to string |
|
7276 if ( val == null ) { |
|
7277 val = ""; |
|
7278 |
|
7279 } else if ( typeof val === "number" ) { |
|
7280 val += ""; |
|
7281 |
|
7282 } else if ( jQuery.isArray( val ) ) { |
|
7283 val = jQuery.map( val, function( value ) { |
|
7284 return value == null ? "" : value + ""; |
|
7285 }); |
|
7286 } |
|
7287 |
|
7288 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; |
|
7289 |
|
7290 // If set returns undefined, fall back to normal setting |
|
7291 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { |
|
7292 this.value = val; |
|
7293 } |
|
7294 }); |
|
7295 } |
|
7296 }); |
|
7297 |
|
7298 jQuery.extend({ |
|
7299 valHooks: { |
|
7300 select: { |
|
7301 get: function( elem ) { |
|
7302 var value, option, |
|
7303 options = elem.options, |
|
7304 index = elem.selectedIndex, |
|
7305 one = elem.type === "select-one" || index < 0, |
|
7306 values = one ? null : [], |
|
7307 max = one ? index + 1 : options.length, |
|
7308 i = index < 0 ? |
|
7309 max : |
|
7310 one ? index : 0; |
|
7311 |
|
7312 // Loop through all the selected options |
|
7313 for ( ; i < max; i++ ) { |
|
7314 option = options[ i ]; |
|
7315 |
|
7316 // IE6-9 doesn't update selected after form reset (#2551) |
|
7317 if ( ( option.selected || i === index ) && |
|
7318 // Don't return options that are disabled or in a disabled optgroup |
|
7319 ( support.optDisabled ? !option.disabled : option.getAttribute( "disabled" ) === null ) && |
|
7320 ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) { |
|
7321 |
|
7322 // Get the specific value for the option |
|
7323 value = jQuery( option ).val(); |
|
7324 |
|
7325 // We don't need an array for one selects |
|
7326 if ( one ) { |
|
7327 return value; |
|
7328 } |
|
7329 |
|
7330 // Multi-Selects return an array |
|
7331 values.push( value ); |
|
7332 } |
|
7333 } |
|
7334 |
|
7335 return values; |
|
7336 }, |
|
7337 |
|
7338 set: function( elem, value ) { |
|
7339 var optionSet, option, |
|
7340 options = elem.options, |
|
7341 values = jQuery.makeArray( value ), |
|
7342 i = options.length; |
|
7343 |
|
7344 while ( i-- ) { |
|
7345 option = options[ i ]; |
|
7346 if ( (option.selected = jQuery.inArray( jQuery(option).val(), values ) >= 0) ) { |
|
7347 optionSet = true; |
|
7348 } |
|
7349 } |
|
7350 |
|
7351 // force browsers to behave consistently when non-matching value is set |
|
7352 if ( !optionSet ) { |
|
7353 elem.selectedIndex = -1; |
|
7354 } |
|
7355 return values; |
|
7356 } |
|
7357 } |
|
7358 } |
|
7359 }); |
|
7360 |
4283 // Radios and checkboxes getter/setter |
7361 // Radios and checkboxes getter/setter |
4284 jQuery.each([ "radio", "checkbox" ], function() { |
7362 jQuery.each([ "radio", "checkbox" ], function() { |
4285 jQuery.valHooks[ this ] = { |
7363 jQuery.valHooks[ this ] = { |
4286 set: function( elem, value ) { |
7364 set: function( elem, value ) { |
4287 if ( jQuery.isArray( value ) ) { |
7365 if ( jQuery.isArray( value ) ) { |
4288 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); |
7366 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); |
4289 } |
7367 } |
4290 } |
7368 } |
4291 }; |
7369 }; |
4292 if ( !jQuery.support.checkOn ) { |
7370 if ( !support.checkOn ) { |
4293 jQuery.valHooks[ this ].get = function( elem ) { |
7371 jQuery.valHooks[ this ].get = function( elem ) { |
4294 // Support: Webkit |
7372 // Support: Webkit |
4295 // "" is returned instead of "on" if a value isn't specified |
7373 // "" is returned instead of "on" if a value isn't specified |
4296 return elem.getAttribute("value") === null ? "on" : elem.value; |
7374 return elem.getAttribute("value") === null ? "on" : elem.value; |
4297 }; |
7375 }; |
4298 } |
7376 } |
4299 }); |
7377 }); |
4300 var rkeyEvent = /^key/, |
7378 |
4301 rmouseEvent = /^(?:mouse|contextmenu)|click/, |
7379 |
4302 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, |
7380 |
4303 rtypenamespace = /^([^.]*)(?:\.(.+)|)$/; |
7381 |
4304 |
7382 // Return jQuery for attributes-only inclusion |
4305 function returnTrue() { |
7383 |
4306 return true; |
7384 |
4307 } |
|
4308 |
|
4309 function returnFalse() { |
|
4310 return false; |
|
4311 } |
|
4312 |
|
4313 function safeActiveElement() { |
|
4314 try { |
|
4315 return document.activeElement; |
|
4316 } catch ( err ) { } |
|
4317 } |
|
4318 |
|
4319 /* |
|
4320 * Helper functions for managing events -- not part of the public interface. |
|
4321 * Props to Dean Edwards' addEvent library for many of the ideas. |
|
4322 */ |
|
4323 jQuery.event = { |
|
4324 |
|
4325 global: {}, |
|
4326 |
|
4327 add: function( elem, types, handler, data, selector ) { |
|
4328 |
|
4329 var handleObjIn, eventHandle, tmp, |
|
4330 events, t, handleObj, |
|
4331 special, handlers, type, namespaces, origType, |
|
4332 elemData = data_priv.get( elem ); |
|
4333 |
|
4334 // Don't attach events to noData or text/comment nodes (but allow plain objects) |
|
4335 if ( !elemData ) { |
|
4336 return; |
|
4337 } |
|
4338 |
|
4339 // Caller can pass in an object of custom data in lieu of the handler |
|
4340 if ( handler.handler ) { |
|
4341 handleObjIn = handler; |
|
4342 handler = handleObjIn.handler; |
|
4343 selector = handleObjIn.selector; |
|
4344 } |
|
4345 |
|
4346 // Make sure that the handler has a unique ID, used to find/remove it later |
|
4347 if ( !handler.guid ) { |
|
4348 handler.guid = jQuery.guid++; |
|
4349 } |
|
4350 |
|
4351 // Init the element's event structure and main handler, if this is the first |
|
4352 if ( !(events = elemData.events) ) { |
|
4353 events = elemData.events = {}; |
|
4354 } |
|
4355 if ( !(eventHandle = elemData.handle) ) { |
|
4356 eventHandle = elemData.handle = function( e ) { |
|
4357 // Discard the second event of a jQuery.event.trigger() and |
|
4358 // when an event is called after a page has unloaded |
|
4359 return typeof jQuery !== core_strundefined && (!e || jQuery.event.triggered !== e.type) ? |
|
4360 jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : |
|
4361 undefined; |
|
4362 }; |
|
4363 // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events |
|
4364 eventHandle.elem = elem; |
|
4365 } |
|
4366 |
|
4367 // Handle multiple events separated by a space |
|
4368 types = ( types || "" ).match( core_rnotwhite ) || [""]; |
|
4369 t = types.length; |
|
4370 while ( t-- ) { |
|
4371 tmp = rtypenamespace.exec( types[t] ) || []; |
|
4372 type = origType = tmp[1]; |
|
4373 namespaces = ( tmp[2] || "" ).split( "." ).sort(); |
|
4374 |
|
4375 // There *must* be a type, no attaching namespace-only handlers |
|
4376 if ( !type ) { |
|
4377 continue; |
|
4378 } |
|
4379 |
|
4380 // If event changes its type, use the special event handlers for the changed type |
|
4381 special = jQuery.event.special[ type ] || {}; |
|
4382 |
|
4383 // If selector defined, determine special event api type, otherwise given type |
|
4384 type = ( selector ? special.delegateType : special.bindType ) || type; |
|
4385 |
|
4386 // Update special based on newly reset type |
|
4387 special = jQuery.event.special[ type ] || {}; |
|
4388 |
|
4389 // handleObj is passed to all event handlers |
|
4390 handleObj = jQuery.extend({ |
|
4391 type: type, |
|
4392 origType: origType, |
|
4393 data: data, |
|
4394 handler: handler, |
|
4395 guid: handler.guid, |
|
4396 selector: selector, |
|
4397 needsContext: selector && jQuery.expr.match.needsContext.test( selector ), |
|
4398 namespace: namespaces.join(".") |
|
4399 }, handleObjIn ); |
|
4400 |
|
4401 // Init the event handler queue if we're the first |
|
4402 if ( !(handlers = events[ type ]) ) { |
|
4403 handlers = events[ type ] = []; |
|
4404 handlers.delegateCount = 0; |
|
4405 |
|
4406 // Only use addEventListener if the special events handler returns false |
|
4407 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { |
|
4408 if ( elem.addEventListener ) { |
|
4409 elem.addEventListener( type, eventHandle, false ); |
|
4410 } |
|
4411 } |
|
4412 } |
|
4413 |
|
4414 if ( special.add ) { |
|
4415 special.add.call( elem, handleObj ); |
|
4416 |
|
4417 if ( !handleObj.handler.guid ) { |
|
4418 handleObj.handler.guid = handler.guid; |
|
4419 } |
|
4420 } |
|
4421 |
|
4422 // Add to the element's handler list, delegates in front |
|
4423 if ( selector ) { |
|
4424 handlers.splice( handlers.delegateCount++, 0, handleObj ); |
|
4425 } else { |
|
4426 handlers.push( handleObj ); |
|
4427 } |
|
4428 |
|
4429 // Keep track of which events have ever been used, for event optimization |
|
4430 jQuery.event.global[ type ] = true; |
|
4431 } |
|
4432 |
|
4433 // Nullify elem to prevent memory leaks in IE |
|
4434 elem = null; |
|
4435 }, |
|
4436 |
|
4437 // Detach an event or set of events from an element |
|
4438 remove: function( elem, types, handler, selector, mappedTypes ) { |
|
4439 |
|
4440 var j, origCount, tmp, |
|
4441 events, t, handleObj, |
|
4442 special, handlers, type, namespaces, origType, |
|
4443 elemData = data_priv.hasData( elem ) && data_priv.get( elem ); |
|
4444 |
|
4445 if ( !elemData || !(events = elemData.events) ) { |
|
4446 return; |
|
4447 } |
|
4448 |
|
4449 // Once for each type.namespace in types; type may be omitted |
|
4450 types = ( types || "" ).match( core_rnotwhite ) || [""]; |
|
4451 t = types.length; |
|
4452 while ( t-- ) { |
|
4453 tmp = rtypenamespace.exec( types[t] ) || []; |
|
4454 type = origType = tmp[1]; |
|
4455 namespaces = ( tmp[2] || "" ).split( "." ).sort(); |
|
4456 |
|
4457 // Unbind all events (on this namespace, if provided) for the element |
|
4458 if ( !type ) { |
|
4459 for ( type in events ) { |
|
4460 jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); |
|
4461 } |
|
4462 continue; |
|
4463 } |
|
4464 |
|
4465 special = jQuery.event.special[ type ] || {}; |
|
4466 type = ( selector ? special.delegateType : special.bindType ) || type; |
|
4467 handlers = events[ type ] || []; |
|
4468 tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ); |
|
4469 |
|
4470 // Remove matching events |
|
4471 origCount = j = handlers.length; |
|
4472 while ( j-- ) { |
|
4473 handleObj = handlers[ j ]; |
|
4474 |
|
4475 if ( ( mappedTypes || origType === handleObj.origType ) && |
|
4476 ( !handler || handler.guid === handleObj.guid ) && |
|
4477 ( !tmp || tmp.test( handleObj.namespace ) ) && |
|
4478 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { |
|
4479 handlers.splice( j, 1 ); |
|
4480 |
|
4481 if ( handleObj.selector ) { |
|
4482 handlers.delegateCount--; |
|
4483 } |
|
4484 if ( special.remove ) { |
|
4485 special.remove.call( elem, handleObj ); |
|
4486 } |
|
4487 } |
|
4488 } |
|
4489 |
|
4490 // Remove generic event handler if we removed something and no more handlers exist |
|
4491 // (avoids potential for endless recursion during removal of special event handlers) |
|
4492 if ( origCount && !handlers.length ) { |
|
4493 if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) { |
|
4494 jQuery.removeEvent( elem, type, elemData.handle ); |
|
4495 } |
|
4496 |
|
4497 delete events[ type ]; |
|
4498 } |
|
4499 } |
|
4500 |
|
4501 // Remove the expando if it's no longer used |
|
4502 if ( jQuery.isEmptyObject( events ) ) { |
|
4503 delete elemData.handle; |
|
4504 data_priv.remove( elem, "events" ); |
|
4505 } |
|
4506 }, |
|
4507 |
|
4508 trigger: function( event, data, elem, onlyHandlers ) { |
|
4509 |
|
4510 var i, cur, tmp, bubbleType, ontype, handle, special, |
|
4511 eventPath = [ elem || document ], |
|
4512 type = core_hasOwn.call( event, "type" ) ? event.type : event, |
|
4513 namespaces = core_hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : []; |
|
4514 |
|
4515 cur = tmp = elem = elem || document; |
|
4516 |
|
4517 // Don't do events on text and comment nodes |
|
4518 if ( elem.nodeType === 3 || elem.nodeType === 8 ) { |
|
4519 return; |
|
4520 } |
|
4521 |
|
4522 // focus/blur morphs to focusin/out; ensure we're not firing them right now |
|
4523 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { |
|
4524 return; |
|
4525 } |
|
4526 |
|
4527 if ( type.indexOf(".") >= 0 ) { |
|
4528 // Namespaced trigger; create a regexp to match event type in handle() |
|
4529 namespaces = type.split("."); |
|
4530 type = namespaces.shift(); |
|
4531 namespaces.sort(); |
|
4532 } |
|
4533 ontype = type.indexOf(":") < 0 && "on" + type; |
|
4534 |
|
4535 // Caller can pass in a jQuery.Event object, Object, or just an event type string |
|
4536 event = event[ jQuery.expando ] ? |
|
4537 event : |
|
4538 new jQuery.Event( type, typeof event === "object" && event ); |
|
4539 |
|
4540 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) |
|
4541 event.isTrigger = onlyHandlers ? 2 : 3; |
|
4542 event.namespace = namespaces.join("."); |
|
4543 event.namespace_re = event.namespace ? |
|
4544 new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) : |
|
4545 null; |
|
4546 |
|
4547 // Clean up the event in case it is being reused |
|
4548 event.result = undefined; |
|
4549 if ( !event.target ) { |
|
4550 event.target = elem; |
|
4551 } |
|
4552 |
|
4553 // Clone any incoming data and prepend the event, creating the handler arg list |
|
4554 data = data == null ? |
|
4555 [ event ] : |
|
4556 jQuery.makeArray( data, [ event ] ); |
|
4557 |
|
4558 // Allow special events to draw outside the lines |
|
4559 special = jQuery.event.special[ type ] || {}; |
|
4560 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { |
|
4561 return; |
|
4562 } |
|
4563 |
|
4564 // Determine event propagation path in advance, per W3C events spec (#9951) |
|
4565 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) |
|
4566 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { |
|
4567 |
|
4568 bubbleType = special.delegateType || type; |
|
4569 if ( !rfocusMorph.test( bubbleType + type ) ) { |
|
4570 cur = cur.parentNode; |
|
4571 } |
|
4572 for ( ; cur; cur = cur.parentNode ) { |
|
4573 eventPath.push( cur ); |
|
4574 tmp = cur; |
|
4575 } |
|
4576 |
|
4577 // Only add window if we got to document (e.g., not plain obj or detached DOM) |
|
4578 if ( tmp === (elem.ownerDocument || document) ) { |
|
4579 eventPath.push( tmp.defaultView || tmp.parentWindow || window ); |
|
4580 } |
|
4581 } |
|
4582 |
|
4583 // Fire handlers on the event path |
|
4584 i = 0; |
|
4585 while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) { |
|
4586 |
|
4587 event.type = i > 1 ? |
|
4588 bubbleType : |
|
4589 special.bindType || type; |
|
4590 |
|
4591 // jQuery handler |
|
4592 handle = ( data_priv.get( cur, "events" ) || {} )[ event.type ] && data_priv.get( cur, "handle" ); |
|
4593 if ( handle ) { |
|
4594 handle.apply( cur, data ); |
|
4595 } |
|
4596 |
|
4597 // Native handler |
|
4598 handle = ontype && cur[ ontype ]; |
|
4599 if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) { |
|
4600 event.preventDefault(); |
|
4601 } |
|
4602 } |
|
4603 event.type = type; |
|
4604 |
|
4605 // If nobody prevented the default action, do it now |
|
4606 if ( !onlyHandlers && !event.isDefaultPrevented() ) { |
|
4607 |
|
4608 if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) && |
|
4609 jQuery.acceptData( elem ) ) { |
|
4610 |
|
4611 // Call a native DOM method on the target with the same name name as the event. |
|
4612 // Don't do default actions on window, that's where global variables be (#6170) |
|
4613 if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) { |
|
4614 |
|
4615 // Don't re-trigger an onFOO event when we call its FOO() method |
|
4616 tmp = elem[ ontype ]; |
|
4617 |
|
4618 if ( tmp ) { |
|
4619 elem[ ontype ] = null; |
|
4620 } |
|
4621 |
|
4622 // Prevent re-triggering of the same event, since we already bubbled it above |
|
4623 jQuery.event.triggered = type; |
|
4624 elem[ type ](); |
|
4625 jQuery.event.triggered = undefined; |
|
4626 |
|
4627 if ( tmp ) { |
|
4628 elem[ ontype ] = tmp; |
|
4629 } |
|
4630 } |
|
4631 } |
|
4632 } |
|
4633 |
|
4634 return event.result; |
|
4635 }, |
|
4636 |
|
4637 dispatch: function( event ) { |
|
4638 |
|
4639 // Make a writable jQuery.Event from the native event object |
|
4640 event = jQuery.event.fix( event ); |
|
4641 |
|
4642 var i, j, ret, matched, handleObj, |
|
4643 handlerQueue = [], |
|
4644 args = core_slice.call( arguments ), |
|
4645 handlers = ( data_priv.get( this, "events" ) || {} )[ event.type ] || [], |
|
4646 special = jQuery.event.special[ event.type ] || {}; |
|
4647 |
|
4648 // Use the fix-ed jQuery.Event rather than the (read-only) native event |
|
4649 args[0] = event; |
|
4650 event.delegateTarget = this; |
|
4651 |
|
4652 // Call the preDispatch hook for the mapped type, and let it bail if desired |
|
4653 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { |
|
4654 return; |
|
4655 } |
|
4656 |
|
4657 // Determine handlers |
|
4658 handlerQueue = jQuery.event.handlers.call( this, event, handlers ); |
|
4659 |
|
4660 // Run delegates first; they may want to stop propagation beneath us |
|
4661 i = 0; |
|
4662 while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) { |
|
4663 event.currentTarget = matched.elem; |
|
4664 |
|
4665 j = 0; |
|
4666 while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) { |
|
4667 |
|
4668 // Triggered event must either 1) have no namespace, or |
|
4669 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). |
|
4670 if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) { |
|
4671 |
|
4672 event.handleObj = handleObj; |
|
4673 event.data = handleObj.data; |
|
4674 |
|
4675 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) |
|
4676 .apply( matched.elem, args ); |
|
4677 |
|
4678 if ( ret !== undefined ) { |
|
4679 if ( (event.result = ret) === false ) { |
|
4680 event.preventDefault(); |
|
4681 event.stopPropagation(); |
|
4682 } |
|
4683 } |
|
4684 } |
|
4685 } |
|
4686 } |
|
4687 |
|
4688 // Call the postDispatch hook for the mapped type |
|
4689 if ( special.postDispatch ) { |
|
4690 special.postDispatch.call( this, event ); |
|
4691 } |
|
4692 |
|
4693 return event.result; |
|
4694 }, |
|
4695 |
|
4696 handlers: function( event, handlers ) { |
|
4697 var i, matches, sel, handleObj, |
|
4698 handlerQueue = [], |
|
4699 delegateCount = handlers.delegateCount, |
|
4700 cur = event.target; |
|
4701 |
|
4702 // Find delegate handlers |
|
4703 // Black-hole SVG <use> instance trees (#13180) |
|
4704 // Avoid non-left-click bubbling in Firefox (#3861) |
|
4705 if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) { |
|
4706 |
|
4707 for ( ; cur !== this; cur = cur.parentNode || this ) { |
|
4708 |
|
4709 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) |
|
4710 if ( cur.disabled !== true || event.type !== "click" ) { |
|
4711 matches = []; |
|
4712 for ( i = 0; i < delegateCount; i++ ) { |
|
4713 handleObj = handlers[ i ]; |
|
4714 |
|
4715 // Don't conflict with Object.prototype properties (#13203) |
|
4716 sel = handleObj.selector + " "; |
|
4717 |
|
4718 if ( matches[ sel ] === undefined ) { |
|
4719 matches[ sel ] = handleObj.needsContext ? |
|
4720 jQuery( sel, this ).index( cur ) >= 0 : |
|
4721 jQuery.find( sel, this, null, [ cur ] ).length; |
|
4722 } |
|
4723 if ( matches[ sel ] ) { |
|
4724 matches.push( handleObj ); |
|
4725 } |
|
4726 } |
|
4727 if ( matches.length ) { |
|
4728 handlerQueue.push({ elem: cur, handlers: matches }); |
|
4729 } |
|
4730 } |
|
4731 } |
|
4732 } |
|
4733 |
|
4734 // Add the remaining (directly-bound) handlers |
|
4735 if ( delegateCount < handlers.length ) { |
|
4736 handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) }); |
|
4737 } |
|
4738 |
|
4739 return handlerQueue; |
|
4740 }, |
|
4741 |
|
4742 // Includes some event props shared by KeyEvent and MouseEvent |
|
4743 props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), |
|
4744 |
|
4745 fixHooks: {}, |
|
4746 |
|
4747 keyHooks: { |
|
4748 props: "char charCode key keyCode".split(" "), |
|
4749 filter: function( event, original ) { |
|
4750 |
|
4751 // Add which for key events |
|
4752 if ( event.which == null ) { |
|
4753 event.which = original.charCode != null ? original.charCode : original.keyCode; |
|
4754 } |
|
4755 |
|
4756 return event; |
|
4757 } |
|
4758 }, |
|
4759 |
|
4760 mouseHooks: { |
|
4761 props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "), |
|
4762 filter: function( event, original ) { |
|
4763 var eventDoc, doc, body, |
|
4764 button = original.button; |
|
4765 |
|
4766 // Calculate pageX/Y if missing and clientX/Y available |
|
4767 if ( event.pageX == null && original.clientX != null ) { |
|
4768 eventDoc = event.target.ownerDocument || document; |
|
4769 doc = eventDoc.documentElement; |
|
4770 body = eventDoc.body; |
|
4771 |
|
4772 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); |
|
4773 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); |
|
4774 } |
|
4775 |
|
4776 // Add which for click: 1 === left; 2 === middle; 3 === right |
|
4777 // Note: button is not normalized, so don't use it |
|
4778 if ( !event.which && button !== undefined ) { |
|
4779 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); |
|
4780 } |
|
4781 |
|
4782 return event; |
|
4783 } |
|
4784 }, |
|
4785 |
|
4786 fix: function( event ) { |
|
4787 if ( event[ jQuery.expando ] ) { |
|
4788 return event; |
|
4789 } |
|
4790 |
|
4791 // Create a writable copy of the event object and normalize some properties |
|
4792 var i, prop, copy, |
|
4793 type = event.type, |
|
4794 originalEvent = event, |
|
4795 fixHook = this.fixHooks[ type ]; |
|
4796 |
|
4797 if ( !fixHook ) { |
|
4798 this.fixHooks[ type ] = fixHook = |
|
4799 rmouseEvent.test( type ) ? this.mouseHooks : |
|
4800 rkeyEvent.test( type ) ? this.keyHooks : |
|
4801 {}; |
|
4802 } |
|
4803 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; |
|
4804 |
|
4805 event = new jQuery.Event( originalEvent ); |
|
4806 |
|
4807 i = copy.length; |
|
4808 while ( i-- ) { |
|
4809 prop = copy[ i ]; |
|
4810 event[ prop ] = originalEvent[ prop ]; |
|
4811 } |
|
4812 |
|
4813 // Support: Cordova 2.5 (WebKit) (#13255) |
|
4814 // All events should have a target; Cordova deviceready doesn't |
|
4815 if ( !event.target ) { |
|
4816 event.target = document; |
|
4817 } |
|
4818 |
|
4819 // Support: Safari 6.0+, Chrome < 28 |
|
4820 // Target should not be a text node (#504, #13143) |
|
4821 if ( event.target.nodeType === 3 ) { |
|
4822 event.target = event.target.parentNode; |
|
4823 } |
|
4824 |
|
4825 return fixHook.filter? fixHook.filter( event, originalEvent ) : event; |
|
4826 }, |
|
4827 |
|
4828 special: { |
|
4829 load: { |
|
4830 // Prevent triggered image.load events from bubbling to window.load |
|
4831 noBubble: true |
|
4832 }, |
|
4833 focus: { |
|
4834 // Fire native event if possible so blur/focus sequence is correct |
|
4835 trigger: function() { |
|
4836 if ( this !== safeActiveElement() && this.focus ) { |
|
4837 this.focus(); |
|
4838 return false; |
|
4839 } |
|
4840 }, |
|
4841 delegateType: "focusin" |
|
4842 }, |
|
4843 blur: { |
|
4844 trigger: function() { |
|
4845 if ( this === safeActiveElement() && this.blur ) { |
|
4846 this.blur(); |
|
4847 return false; |
|
4848 } |
|
4849 }, |
|
4850 delegateType: "focusout" |
|
4851 }, |
|
4852 click: { |
|
4853 // For checkbox, fire native event so checked state will be right |
|
4854 trigger: function() { |
|
4855 if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) { |
|
4856 this.click(); |
|
4857 return false; |
|
4858 } |
|
4859 }, |
|
4860 |
|
4861 // For cross-browser consistency, don't fire native .click() on links |
|
4862 _default: function( event ) { |
|
4863 return jQuery.nodeName( event.target, "a" ); |
|
4864 } |
|
4865 }, |
|
4866 |
|
4867 beforeunload: { |
|
4868 postDispatch: function( event ) { |
|
4869 |
|
4870 // Support: Firefox 20+ |
|
4871 // Firefox doesn't alert if the returnValue field is not set. |
|
4872 if ( event.result !== undefined ) { |
|
4873 event.originalEvent.returnValue = event.result; |
|
4874 } |
|
4875 } |
|
4876 } |
|
4877 }, |
|
4878 |
|
4879 simulate: function( type, elem, event, bubble ) { |
|
4880 // Piggyback on a donor event to simulate a different one. |
|
4881 // Fake originalEvent to avoid donor's stopPropagation, but if the |
|
4882 // simulated event prevents default then we do the same on the donor. |
|
4883 var e = jQuery.extend( |
|
4884 new jQuery.Event(), |
|
4885 event, |
|
4886 { |
|
4887 type: type, |
|
4888 isSimulated: true, |
|
4889 originalEvent: {} |
|
4890 } |
|
4891 ); |
|
4892 if ( bubble ) { |
|
4893 jQuery.event.trigger( e, null, elem ); |
|
4894 } else { |
|
4895 jQuery.event.dispatch.call( elem, e ); |
|
4896 } |
|
4897 if ( e.isDefaultPrevented() ) { |
|
4898 event.preventDefault(); |
|
4899 } |
|
4900 } |
|
4901 }; |
|
4902 |
|
4903 jQuery.removeEvent = function( elem, type, handle ) { |
|
4904 if ( elem.removeEventListener ) { |
|
4905 elem.removeEventListener( type, handle, false ); |
|
4906 } |
|
4907 }; |
|
4908 |
|
4909 jQuery.Event = function( src, props ) { |
|
4910 // Allow instantiation without the 'new' keyword |
|
4911 if ( !(this instanceof jQuery.Event) ) { |
|
4912 return new jQuery.Event( src, props ); |
|
4913 } |
|
4914 |
|
4915 // Event object |
|
4916 if ( src && src.type ) { |
|
4917 this.originalEvent = src; |
|
4918 this.type = src.type; |
|
4919 |
|
4920 // Events bubbling up the document may have been marked as prevented |
|
4921 // by a handler lower down the tree; reflect the correct value. |
|
4922 this.isDefaultPrevented = ( src.defaultPrevented || |
|
4923 src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse; |
|
4924 |
|
4925 // Event type |
|
4926 } else { |
|
4927 this.type = src; |
|
4928 } |
|
4929 |
|
4930 // Put explicitly provided properties onto the event object |
|
4931 if ( props ) { |
|
4932 jQuery.extend( this, props ); |
|
4933 } |
|
4934 |
|
4935 // Create a timestamp if incoming event doesn't have one |
|
4936 this.timeStamp = src && src.timeStamp || jQuery.now(); |
|
4937 |
|
4938 // Mark it as fixed |
|
4939 this[ jQuery.expando ] = true; |
|
4940 }; |
|
4941 |
|
4942 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding |
|
4943 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html |
|
4944 jQuery.Event.prototype = { |
|
4945 isDefaultPrevented: returnFalse, |
|
4946 isPropagationStopped: returnFalse, |
|
4947 isImmediatePropagationStopped: returnFalse, |
|
4948 |
|
4949 preventDefault: function() { |
|
4950 var e = this.originalEvent; |
|
4951 |
|
4952 this.isDefaultPrevented = returnTrue; |
|
4953 |
|
4954 if ( e && e.preventDefault ) { |
|
4955 e.preventDefault(); |
|
4956 } |
|
4957 }, |
|
4958 stopPropagation: function() { |
|
4959 var e = this.originalEvent; |
|
4960 |
|
4961 this.isPropagationStopped = returnTrue; |
|
4962 |
|
4963 if ( e && e.stopPropagation ) { |
|
4964 e.stopPropagation(); |
|
4965 } |
|
4966 }, |
|
4967 stopImmediatePropagation: function() { |
|
4968 this.isImmediatePropagationStopped = returnTrue; |
|
4969 this.stopPropagation(); |
|
4970 } |
|
4971 }; |
|
4972 |
|
4973 // Create mouseenter/leave events using mouseover/out and event-time checks |
|
4974 // Support: Chrome 15+ |
|
4975 jQuery.each({ |
|
4976 mouseenter: "mouseover", |
|
4977 mouseleave: "mouseout" |
|
4978 }, function( orig, fix ) { |
|
4979 jQuery.event.special[ orig ] = { |
|
4980 delegateType: fix, |
|
4981 bindType: fix, |
|
4982 |
|
4983 handle: function( event ) { |
|
4984 var ret, |
|
4985 target = this, |
|
4986 related = event.relatedTarget, |
|
4987 handleObj = event.handleObj; |
|
4988 |
|
4989 // For mousenter/leave call the handler if related is outside the target. |
|
4990 // NB: No relatedTarget if the mouse left/entered the browser window |
|
4991 if ( !related || (related !== target && !jQuery.contains( target, related )) ) { |
|
4992 event.type = handleObj.origType; |
|
4993 ret = handleObj.handler.apply( this, arguments ); |
|
4994 event.type = fix; |
|
4995 } |
|
4996 return ret; |
|
4997 } |
|
4998 }; |
|
4999 }); |
|
5000 |
|
5001 // Create "bubbling" focus and blur events |
|
5002 // Support: Firefox, Chrome, Safari |
|
5003 if ( !jQuery.support.focusinBubbles ) { |
|
5004 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { |
|
5005 |
|
5006 // Attach a single capturing handler while someone wants focusin/focusout |
|
5007 var attaches = 0, |
|
5008 handler = function( event ) { |
|
5009 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); |
|
5010 }; |
|
5011 |
|
5012 jQuery.event.special[ fix ] = { |
|
5013 setup: function() { |
|
5014 if ( attaches++ === 0 ) { |
|
5015 document.addEventListener( orig, handler, true ); |
|
5016 } |
|
5017 }, |
|
5018 teardown: function() { |
|
5019 if ( --attaches === 0 ) { |
|
5020 document.removeEventListener( orig, handler, true ); |
|
5021 } |
|
5022 } |
|
5023 }; |
|
5024 }); |
|
5025 } |
|
5026 |
|
5027 jQuery.fn.extend({ |
|
5028 |
|
5029 on: function( types, selector, data, fn, /*INTERNAL*/ one ) { |
|
5030 var origFn, type; |
|
5031 |
|
5032 // Types can be a map of types/handlers |
|
5033 if ( typeof types === "object" ) { |
|
5034 // ( types-Object, selector, data ) |
|
5035 if ( typeof selector !== "string" ) { |
|
5036 // ( types-Object, data ) |
|
5037 data = data || selector; |
|
5038 selector = undefined; |
|
5039 } |
|
5040 for ( type in types ) { |
|
5041 this.on( type, selector, data, types[ type ], one ); |
|
5042 } |
|
5043 return this; |
|
5044 } |
|
5045 |
|
5046 if ( data == null && fn == null ) { |
|
5047 // ( types, fn ) |
|
5048 fn = selector; |
|
5049 data = selector = undefined; |
|
5050 } else if ( fn == null ) { |
|
5051 if ( typeof selector === "string" ) { |
|
5052 // ( types, selector, fn ) |
|
5053 fn = data; |
|
5054 data = undefined; |
|
5055 } else { |
|
5056 // ( types, data, fn ) |
|
5057 fn = data; |
|
5058 data = selector; |
|
5059 selector = undefined; |
|
5060 } |
|
5061 } |
|
5062 if ( fn === false ) { |
|
5063 fn = returnFalse; |
|
5064 } else if ( !fn ) { |
|
5065 return this; |
|
5066 } |
|
5067 |
|
5068 if ( one === 1 ) { |
|
5069 origFn = fn; |
|
5070 fn = function( event ) { |
|
5071 // Can use an empty set, since event contains the info |
|
5072 jQuery().off( event ); |
|
5073 return origFn.apply( this, arguments ); |
|
5074 }; |
|
5075 // Use same guid so caller can remove using origFn |
|
5076 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); |
|
5077 } |
|
5078 return this.each( function() { |
|
5079 jQuery.event.add( this, types, fn, data, selector ); |
|
5080 }); |
|
5081 }, |
|
5082 one: function( types, selector, data, fn ) { |
|
5083 return this.on( types, selector, data, fn, 1 ); |
|
5084 }, |
|
5085 off: function( types, selector, fn ) { |
|
5086 var handleObj, type; |
|
5087 if ( types && types.preventDefault && types.handleObj ) { |
|
5088 // ( event ) dispatched jQuery.Event |
|
5089 handleObj = types.handleObj; |
|
5090 jQuery( types.delegateTarget ).off( |
|
5091 handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, |
|
5092 handleObj.selector, |
|
5093 handleObj.handler |
|
5094 ); |
|
5095 return this; |
|
5096 } |
|
5097 if ( typeof types === "object" ) { |
|
5098 // ( types-object [, selector] ) |
|
5099 for ( type in types ) { |
|
5100 this.off( type, selector, types[ type ] ); |
|
5101 } |
|
5102 return this; |
|
5103 } |
|
5104 if ( selector === false || typeof selector === "function" ) { |
|
5105 // ( types [, fn] ) |
|
5106 fn = selector; |
|
5107 selector = undefined; |
|
5108 } |
|
5109 if ( fn === false ) { |
|
5110 fn = returnFalse; |
|
5111 } |
|
5112 return this.each(function() { |
|
5113 jQuery.event.remove( this, types, fn, selector ); |
|
5114 }); |
|
5115 }, |
|
5116 |
|
5117 trigger: function( type, data ) { |
|
5118 return this.each(function() { |
|
5119 jQuery.event.trigger( type, data, this ); |
|
5120 }); |
|
5121 }, |
|
5122 triggerHandler: function( type, data ) { |
|
5123 var elem = this[0]; |
|
5124 if ( elem ) { |
|
5125 return jQuery.event.trigger( type, data, elem, true ); |
|
5126 } |
|
5127 } |
|
5128 }); |
|
5129 var isSimple = /^.[^:#\[\.,]*$/, |
|
5130 rparentsprev = /^(?:parents|prev(?:Until|All))/, |
|
5131 rneedsContext = jQuery.expr.match.needsContext, |
|
5132 // methods guaranteed to produce a unique set when starting from a unique set |
|
5133 guaranteedUnique = { |
|
5134 children: true, |
|
5135 contents: true, |
|
5136 next: true, |
|
5137 prev: true |
|
5138 }; |
|
5139 |
|
5140 jQuery.fn.extend({ |
|
5141 find: function( selector ) { |
|
5142 var i, |
|
5143 ret = [], |
|
5144 self = this, |
|
5145 len = self.length; |
|
5146 |
|
5147 if ( typeof selector !== "string" ) { |
|
5148 return this.pushStack( jQuery( selector ).filter(function() { |
|
5149 for ( i = 0; i < len; i++ ) { |
|
5150 if ( jQuery.contains( self[ i ], this ) ) { |
|
5151 return true; |
|
5152 } |
|
5153 } |
|
5154 }) ); |
|
5155 } |
|
5156 |
|
5157 for ( i = 0; i < len; i++ ) { |
|
5158 jQuery.find( selector, self[ i ], ret ); |
|
5159 } |
|
5160 |
|
5161 // Needed because $( selector, context ) becomes $( context ).find( selector ) |
|
5162 ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret ); |
|
5163 ret.selector = this.selector ? this.selector + " " + selector : selector; |
|
5164 return ret; |
|
5165 }, |
|
5166 |
|
5167 has: function( target ) { |
|
5168 var targets = jQuery( target, this ), |
|
5169 l = targets.length; |
|
5170 |
|
5171 return this.filter(function() { |
|
5172 var i = 0; |
|
5173 for ( ; i < l; i++ ) { |
|
5174 if ( jQuery.contains( this, targets[i] ) ) { |
|
5175 return true; |
|
5176 } |
|
5177 } |
|
5178 }); |
|
5179 }, |
|
5180 |
|
5181 not: function( selector ) { |
|
5182 return this.pushStack( winnow(this, selector || [], true) ); |
|
5183 }, |
|
5184 |
|
5185 filter: function( selector ) { |
|
5186 return this.pushStack( winnow(this, selector || [], false) ); |
|
5187 }, |
|
5188 |
|
5189 is: function( selector ) { |
|
5190 return !!winnow( |
|
5191 this, |
|
5192 |
|
5193 // If this is a positional/relative selector, check membership in the returned set |
|
5194 // so $("p:first").is("p:last") won't return true for a doc with two "p". |
|
5195 typeof selector === "string" && rneedsContext.test( selector ) ? |
|
5196 jQuery( selector ) : |
|
5197 selector || [], |
|
5198 false |
|
5199 ).length; |
|
5200 }, |
|
5201 |
|
5202 closest: function( selectors, context ) { |
|
5203 var cur, |
|
5204 i = 0, |
|
5205 l = this.length, |
|
5206 matched = [], |
|
5207 pos = ( rneedsContext.test( selectors ) || typeof selectors !== "string" ) ? |
|
5208 jQuery( selectors, context || this.context ) : |
|
5209 0; |
|
5210 |
|
5211 for ( ; i < l; i++ ) { |
|
5212 for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) { |
|
5213 // Always skip document fragments |
|
5214 if ( cur.nodeType < 11 && (pos ? |
|
5215 pos.index(cur) > -1 : |
|
5216 |
|
5217 // Don't pass non-elements to Sizzle |
|
5218 cur.nodeType === 1 && |
|
5219 jQuery.find.matchesSelector(cur, selectors)) ) { |
|
5220 |
|
5221 cur = matched.push( cur ); |
|
5222 break; |
|
5223 } |
|
5224 } |
|
5225 } |
|
5226 |
|
5227 return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched ); |
|
5228 }, |
|
5229 |
|
5230 // Determine the position of an element within |
|
5231 // the matched set of elements |
|
5232 index: function( elem ) { |
|
5233 |
|
5234 // No argument, return index in parent |
|
5235 if ( !elem ) { |
|
5236 return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1; |
|
5237 } |
|
5238 |
|
5239 // index in selector |
|
5240 if ( typeof elem === "string" ) { |
|
5241 return core_indexOf.call( jQuery( elem ), this[ 0 ] ); |
|
5242 } |
|
5243 |
|
5244 // Locate the position of the desired element |
|
5245 return core_indexOf.call( this, |
|
5246 |
|
5247 // If it receives a jQuery object, the first element is used |
|
5248 elem.jquery ? elem[ 0 ] : elem |
|
5249 ); |
|
5250 }, |
|
5251 |
|
5252 add: function( selector, context ) { |
|
5253 var set = typeof selector === "string" ? |
|
5254 jQuery( selector, context ) : |
|
5255 jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ), |
|
5256 all = jQuery.merge( this.get(), set ); |
|
5257 |
|
5258 return this.pushStack( jQuery.unique(all) ); |
|
5259 }, |
|
5260 |
|
5261 addBack: function( selector ) { |
|
5262 return this.add( selector == null ? |
|
5263 this.prevObject : this.prevObject.filter(selector) |
|
5264 ); |
|
5265 } |
|
5266 }); |
|
5267 |
|
5268 function sibling( cur, dir ) { |
|
5269 while ( (cur = cur[dir]) && cur.nodeType !== 1 ) {} |
|
5270 |
|
5271 return cur; |
|
5272 } |
|
5273 |
|
5274 jQuery.each({ |
|
5275 parent: function( elem ) { |
|
5276 var parent = elem.parentNode; |
|
5277 return parent && parent.nodeType !== 11 ? parent : null; |
|
5278 }, |
|
5279 parents: function( elem ) { |
|
5280 return jQuery.dir( elem, "parentNode" ); |
|
5281 }, |
|
5282 parentsUntil: function( elem, i, until ) { |
|
5283 return jQuery.dir( elem, "parentNode", until ); |
|
5284 }, |
|
5285 next: function( elem ) { |
|
5286 return sibling( elem, "nextSibling" ); |
|
5287 }, |
|
5288 prev: function( elem ) { |
|
5289 return sibling( elem, "previousSibling" ); |
|
5290 }, |
|
5291 nextAll: function( elem ) { |
|
5292 return jQuery.dir( elem, "nextSibling" ); |
|
5293 }, |
|
5294 prevAll: function( elem ) { |
|
5295 return jQuery.dir( elem, "previousSibling" ); |
|
5296 }, |
|
5297 nextUntil: function( elem, i, until ) { |
|
5298 return jQuery.dir( elem, "nextSibling", until ); |
|
5299 }, |
|
5300 prevUntil: function( elem, i, until ) { |
|
5301 return jQuery.dir( elem, "previousSibling", until ); |
|
5302 }, |
|
5303 siblings: function( elem ) { |
|
5304 return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem ); |
|
5305 }, |
|
5306 children: function( elem ) { |
|
5307 return jQuery.sibling( elem.firstChild ); |
|
5308 }, |
|
5309 contents: function( elem ) { |
|
5310 return elem.contentDocument || jQuery.merge( [], elem.childNodes ); |
|
5311 } |
|
5312 }, function( name, fn ) { |
|
5313 jQuery.fn[ name ] = function( until, selector ) { |
|
5314 var matched = jQuery.map( this, fn, until ); |
|
5315 |
|
5316 if ( name.slice( -5 ) !== "Until" ) { |
|
5317 selector = until; |
|
5318 } |
|
5319 |
|
5320 if ( selector && typeof selector === "string" ) { |
|
5321 matched = jQuery.filter( selector, matched ); |
|
5322 } |
|
5323 |
|
5324 if ( this.length > 1 ) { |
|
5325 // Remove duplicates |
|
5326 if ( !guaranteedUnique[ name ] ) { |
|
5327 jQuery.unique( matched ); |
|
5328 } |
|
5329 |
|
5330 // Reverse order for parents* and prev-derivatives |
|
5331 if ( rparentsprev.test( name ) ) { |
|
5332 matched.reverse(); |
|
5333 } |
|
5334 } |
|
5335 |
|
5336 return this.pushStack( matched ); |
|
5337 }; |
|
5338 }); |
|
5339 |
|
5340 jQuery.extend({ |
|
5341 filter: function( expr, elems, not ) { |
|
5342 var elem = elems[ 0 ]; |
|
5343 |
|
5344 if ( not ) { |
|
5345 expr = ":not(" + expr + ")"; |
|
5346 } |
|
5347 |
|
5348 return elems.length === 1 && elem.nodeType === 1 ? |
|
5349 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] : |
|
5350 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { |
|
5351 return elem.nodeType === 1; |
|
5352 })); |
|
5353 }, |
|
5354 |
|
5355 dir: function( elem, dir, until ) { |
|
5356 var matched = [], |
|
5357 truncate = until !== undefined; |
|
5358 |
|
5359 while ( (elem = elem[ dir ]) && elem.nodeType !== 9 ) { |
|
5360 if ( elem.nodeType === 1 ) { |
|
5361 if ( truncate && jQuery( elem ).is( until ) ) { |
|
5362 break; |
|
5363 } |
|
5364 matched.push( elem ); |
|
5365 } |
|
5366 } |
|
5367 return matched; |
|
5368 }, |
|
5369 |
|
5370 sibling: function( n, elem ) { |
|
5371 var matched = []; |
|
5372 |
|
5373 for ( ; n; n = n.nextSibling ) { |
|
5374 if ( n.nodeType === 1 && n !== elem ) { |
|
5375 matched.push( n ); |
|
5376 } |
|
5377 } |
|
5378 |
|
5379 return matched; |
|
5380 } |
|
5381 }); |
|
5382 |
|
5383 // Implement the identical functionality for filter and not |
|
5384 function winnow( elements, qualifier, not ) { |
|
5385 if ( jQuery.isFunction( qualifier ) ) { |
|
5386 return jQuery.grep( elements, function( elem, i ) { |
|
5387 /* jshint -W018 */ |
|
5388 return !!qualifier.call( elem, i, elem ) !== not; |
|
5389 }); |
|
5390 |
|
5391 } |
|
5392 |
|
5393 if ( qualifier.nodeType ) { |
|
5394 return jQuery.grep( elements, function( elem ) { |
|
5395 return ( elem === qualifier ) !== not; |
|
5396 }); |
|
5397 |
|
5398 } |
|
5399 |
|
5400 if ( typeof qualifier === "string" ) { |
|
5401 if ( isSimple.test( qualifier ) ) { |
|
5402 return jQuery.filter( qualifier, elements, not ); |
|
5403 } |
|
5404 |
|
5405 qualifier = jQuery.filter( qualifier, elements ); |
|
5406 } |
|
5407 |
|
5408 return jQuery.grep( elements, function( elem ) { |
|
5409 return ( core_indexOf.call( qualifier, elem ) >= 0 ) !== not; |
|
5410 }); |
|
5411 } |
|
5412 var rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, |
|
5413 rtagName = /<([\w:]+)/, |
|
5414 rhtml = /<|&#?\w+;/, |
|
5415 rnoInnerhtml = /<(?:script|style|link)/i, |
|
5416 manipulation_rcheckableType = /^(?:checkbox|radio)$/i, |
|
5417 // checked="checked" or checked |
|
5418 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, |
|
5419 rscriptType = /^$|\/(?:java|ecma)script/i, |
|
5420 rscriptTypeMasked = /^true\/(.*)/, |
|
5421 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g, |
|
5422 |
|
5423 // We have to close these tags to support XHTML (#13200) |
|
5424 wrapMap = { |
|
5425 |
|
5426 // Support: IE 9 |
|
5427 option: [ 1, "<select multiple='multiple'>", "</select>" ], |
|
5428 |
|
5429 thead: [ 1, "<table>", "</table>" ], |
|
5430 col: [ 2, "<table><colgroup>", "</colgroup></table>" ], |
|
5431 tr: [ 2, "<table><tbody>", "</tbody></table>" ], |
|
5432 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], |
|
5433 |
|
5434 _default: [ 0, "", "" ] |
|
5435 }; |
|
5436 |
|
5437 // Support: IE 9 |
|
5438 wrapMap.optgroup = wrapMap.option; |
|
5439 |
|
5440 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; |
|
5441 wrapMap.th = wrapMap.td; |
|
5442 |
|
5443 jQuery.fn.extend({ |
|
5444 text: function( value ) { |
|
5445 return jQuery.access( this, function( value ) { |
|
5446 return value === undefined ? |
|
5447 jQuery.text( this ) : |
|
5448 this.empty().append( ( this[ 0 ] && this[ 0 ].ownerDocument || document ).createTextNode( value ) ); |
|
5449 }, null, value, arguments.length ); |
|
5450 }, |
|
5451 |
|
5452 append: function() { |
|
5453 return this.domManip( arguments, function( elem ) { |
|
5454 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { |
|
5455 var target = manipulationTarget( this, elem ); |
|
5456 target.appendChild( elem ); |
|
5457 } |
|
5458 }); |
|
5459 }, |
|
5460 |
|
5461 prepend: function() { |
|
5462 return this.domManip( arguments, function( elem ) { |
|
5463 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { |
|
5464 var target = manipulationTarget( this, elem ); |
|
5465 target.insertBefore( elem, target.firstChild ); |
|
5466 } |
|
5467 }); |
|
5468 }, |
|
5469 |
|
5470 before: function() { |
|
5471 return this.domManip( arguments, function( elem ) { |
|
5472 if ( this.parentNode ) { |
|
5473 this.parentNode.insertBefore( elem, this ); |
|
5474 } |
|
5475 }); |
|
5476 }, |
|
5477 |
|
5478 after: function() { |
|
5479 return this.domManip( arguments, function( elem ) { |
|
5480 if ( this.parentNode ) { |
|
5481 this.parentNode.insertBefore( elem, this.nextSibling ); |
|
5482 } |
|
5483 }); |
|
5484 }, |
|
5485 |
|
5486 // keepData is for internal use only--do not document |
|
5487 remove: function( selector, keepData ) { |
|
5488 var elem, |
|
5489 elems = selector ? jQuery.filter( selector, this ) : this, |
|
5490 i = 0; |
|
5491 |
|
5492 for ( ; (elem = elems[i]) != null; i++ ) { |
|
5493 if ( !keepData && elem.nodeType === 1 ) { |
|
5494 jQuery.cleanData( getAll( elem ) ); |
|
5495 } |
|
5496 |
|
5497 if ( elem.parentNode ) { |
|
5498 if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) { |
|
5499 setGlobalEval( getAll( elem, "script" ) ); |
|
5500 } |
|
5501 elem.parentNode.removeChild( elem ); |
|
5502 } |
|
5503 } |
|
5504 |
|
5505 return this; |
|
5506 }, |
|
5507 |
|
5508 empty: function() { |
|
5509 var elem, |
|
5510 i = 0; |
|
5511 |
|
5512 for ( ; (elem = this[i]) != null; i++ ) { |
|
5513 if ( elem.nodeType === 1 ) { |
|
5514 |
|
5515 // Prevent memory leaks |
|
5516 jQuery.cleanData( getAll( elem, false ) ); |
|
5517 |
|
5518 // Remove any remaining nodes |
|
5519 elem.textContent = ""; |
|
5520 } |
|
5521 } |
|
5522 |
|
5523 return this; |
|
5524 }, |
|
5525 |
|
5526 clone: function( dataAndEvents, deepDataAndEvents ) { |
|
5527 dataAndEvents = dataAndEvents == null ? false : dataAndEvents; |
|
5528 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; |
|
5529 |
|
5530 return this.map( function () { |
|
5531 return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); |
|
5532 }); |
|
5533 }, |
|
5534 |
|
5535 html: function( value ) { |
|
5536 return jQuery.access( this, function( value ) { |
|
5537 var elem = this[ 0 ] || {}, |
|
5538 i = 0, |
|
5539 l = this.length; |
|
5540 |
|
5541 if ( value === undefined && elem.nodeType === 1 ) { |
|
5542 return elem.innerHTML; |
|
5543 } |
|
5544 |
|
5545 // See if we can take a shortcut and just use innerHTML |
|
5546 if ( typeof value === "string" && !rnoInnerhtml.test( value ) && |
|
5547 !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) { |
|
5548 |
|
5549 value = value.replace( rxhtmlTag, "<$1></$2>" ); |
|
5550 |
|
5551 try { |
|
5552 for ( ; i < l; i++ ) { |
|
5553 elem = this[ i ] || {}; |
|
5554 |
|
5555 // Remove element nodes and prevent memory leaks |
|
5556 if ( elem.nodeType === 1 ) { |
|
5557 jQuery.cleanData( getAll( elem, false ) ); |
|
5558 elem.innerHTML = value; |
|
5559 } |
|
5560 } |
|
5561 |
|
5562 elem = 0; |
|
5563 |
|
5564 // If using innerHTML throws an exception, use the fallback method |
|
5565 } catch( e ) {} |
|
5566 } |
|
5567 |
|
5568 if ( elem ) { |
|
5569 this.empty().append( value ); |
|
5570 } |
|
5571 }, null, value, arguments.length ); |
|
5572 }, |
|
5573 |
|
5574 replaceWith: function() { |
|
5575 var |
|
5576 // Snapshot the DOM in case .domManip sweeps something relevant into its fragment |
|
5577 args = jQuery.map( this, function( elem ) { |
|
5578 return [ elem.nextSibling, elem.parentNode ]; |
|
5579 }), |
|
5580 i = 0; |
|
5581 |
|
5582 // Make the changes, replacing each context element with the new content |
|
5583 this.domManip( arguments, function( elem ) { |
|
5584 var next = args[ i++ ], |
|
5585 parent = args[ i++ ]; |
|
5586 |
|
5587 if ( parent ) { |
|
5588 // Don't use the snapshot next if it has moved (#13810) |
|
5589 if ( next && next.parentNode !== parent ) { |
|
5590 next = this.nextSibling; |
|
5591 } |
|
5592 jQuery( this ).remove(); |
|
5593 parent.insertBefore( elem, next ); |
|
5594 } |
|
5595 // Allow new content to include elements from the context set |
|
5596 }, true ); |
|
5597 |
|
5598 // Force removal if there was no new content (e.g., from empty arguments) |
|
5599 return i ? this : this.remove(); |
|
5600 }, |
|
5601 |
|
5602 detach: function( selector ) { |
|
5603 return this.remove( selector, true ); |
|
5604 }, |
|
5605 |
|
5606 domManip: function( args, callback, allowIntersection ) { |
|
5607 |
|
5608 // Flatten any nested arrays |
|
5609 args = core_concat.apply( [], args ); |
|
5610 |
|
5611 var fragment, first, scripts, hasScripts, node, doc, |
|
5612 i = 0, |
|
5613 l = this.length, |
|
5614 set = this, |
|
5615 iNoClone = l - 1, |
|
5616 value = args[ 0 ], |
|
5617 isFunction = jQuery.isFunction( value ); |
|
5618 |
|
5619 // We can't cloneNode fragments that contain checked, in WebKit |
|
5620 if ( isFunction || !( l <= 1 || typeof value !== "string" || jQuery.support.checkClone || !rchecked.test( value ) ) ) { |
|
5621 return this.each(function( index ) { |
|
5622 var self = set.eq( index ); |
|
5623 if ( isFunction ) { |
|
5624 args[ 0 ] = value.call( this, index, self.html() ); |
|
5625 } |
|
5626 self.domManip( args, callback, allowIntersection ); |
|
5627 }); |
|
5628 } |
|
5629 |
|
5630 if ( l ) { |
|
5631 fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, !allowIntersection && this ); |
|
5632 first = fragment.firstChild; |
|
5633 |
|
5634 if ( fragment.childNodes.length === 1 ) { |
|
5635 fragment = first; |
|
5636 } |
|
5637 |
|
5638 if ( first ) { |
|
5639 scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); |
|
5640 hasScripts = scripts.length; |
|
5641 |
|
5642 // Use the original fragment for the last item instead of the first because it can end up |
|
5643 // being emptied incorrectly in certain situations (#8070). |
|
5644 for ( ; i < l; i++ ) { |
|
5645 node = fragment; |
|
5646 |
|
5647 if ( i !== iNoClone ) { |
|
5648 node = jQuery.clone( node, true, true ); |
|
5649 |
|
5650 // Keep references to cloned scripts for later restoration |
|
5651 if ( hasScripts ) { |
|
5652 // Support: QtWebKit |
|
5653 // jQuery.merge because core_push.apply(_, arraylike) throws |
|
5654 jQuery.merge( scripts, getAll( node, "script" ) ); |
|
5655 } |
|
5656 } |
|
5657 |
|
5658 callback.call( this[ i ], node, i ); |
|
5659 } |
|
5660 |
|
5661 if ( hasScripts ) { |
|
5662 doc = scripts[ scripts.length - 1 ].ownerDocument; |
|
5663 |
|
5664 // Reenable scripts |
|
5665 jQuery.map( scripts, restoreScript ); |
|
5666 |
|
5667 // Evaluate executable scripts on first document insertion |
|
5668 for ( i = 0; i < hasScripts; i++ ) { |
|
5669 node = scripts[ i ]; |
|
5670 if ( rscriptType.test( node.type || "" ) && |
|
5671 !data_priv.access( node, "globalEval" ) && jQuery.contains( doc, node ) ) { |
|
5672 |
|
5673 if ( node.src ) { |
|
5674 // Hope ajax is available... |
|
5675 jQuery._evalUrl( node.src ); |
|
5676 } else { |
|
5677 jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) ); |
|
5678 } |
|
5679 } |
|
5680 } |
|
5681 } |
|
5682 } |
|
5683 } |
|
5684 |
|
5685 return this; |
|
5686 } |
|
5687 }); |
|
5688 |
|
5689 jQuery.each({ |
|
5690 appendTo: "append", |
|
5691 prependTo: "prepend", |
|
5692 insertBefore: "before", |
|
5693 insertAfter: "after", |
|
5694 replaceAll: "replaceWith" |
|
5695 }, function( name, original ) { |
|
5696 jQuery.fn[ name ] = function( selector ) { |
|
5697 var elems, |
|
5698 ret = [], |
|
5699 insert = jQuery( selector ), |
|
5700 last = insert.length - 1, |
|
5701 i = 0; |
|
5702 |
|
5703 for ( ; i <= last; i++ ) { |
|
5704 elems = i === last ? this : this.clone( true ); |
|
5705 jQuery( insert[ i ] )[ original ]( elems ); |
|
5706 |
|
5707 // Support: QtWebKit |
|
5708 // .get() because core_push.apply(_, arraylike) throws |
|
5709 core_push.apply( ret, elems.get() ); |
|
5710 } |
|
5711 |
|
5712 return this.pushStack( ret ); |
|
5713 }; |
|
5714 }); |
|
5715 |
|
5716 jQuery.extend({ |
|
5717 clone: function( elem, dataAndEvents, deepDataAndEvents ) { |
|
5718 var i, l, srcElements, destElements, |
|
5719 clone = elem.cloneNode( true ), |
|
5720 inPage = jQuery.contains( elem.ownerDocument, elem ); |
|
5721 |
|
5722 // Support: IE >= 9 |
|
5723 // Fix Cloning issues |
|
5724 if ( !jQuery.support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && !jQuery.isXMLDoc( elem ) ) { |
|
5725 |
|
5726 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2 |
|
5727 destElements = getAll( clone ); |
|
5728 srcElements = getAll( elem ); |
|
5729 |
|
5730 for ( i = 0, l = srcElements.length; i < l; i++ ) { |
|
5731 fixInput( srcElements[ i ], destElements[ i ] ); |
|
5732 } |
|
5733 } |
|
5734 |
|
5735 // Copy the events from the original to the clone |
|
5736 if ( dataAndEvents ) { |
|
5737 if ( deepDataAndEvents ) { |
|
5738 srcElements = srcElements || getAll( elem ); |
|
5739 destElements = destElements || getAll( clone ); |
|
5740 |
|
5741 for ( i = 0, l = srcElements.length; i < l; i++ ) { |
|
5742 cloneCopyEvent( srcElements[ i ], destElements[ i ] ); |
|
5743 } |
|
5744 } else { |
|
5745 cloneCopyEvent( elem, clone ); |
|
5746 } |
|
5747 } |
|
5748 |
|
5749 // Preserve script evaluation history |
|
5750 destElements = getAll( clone, "script" ); |
|
5751 if ( destElements.length > 0 ) { |
|
5752 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); |
|
5753 } |
|
5754 |
|
5755 // Return the cloned set |
|
5756 return clone; |
|
5757 }, |
|
5758 |
|
5759 buildFragment: function( elems, context, scripts, selection ) { |
|
5760 var elem, tmp, tag, wrap, contains, j, |
|
5761 i = 0, |
|
5762 l = elems.length, |
|
5763 fragment = context.createDocumentFragment(), |
|
5764 nodes = []; |
|
5765 |
|
5766 for ( ; i < l; i++ ) { |
|
5767 elem = elems[ i ]; |
|
5768 |
|
5769 if ( elem || elem === 0 ) { |
|
5770 |
|
5771 // Add nodes directly |
|
5772 if ( jQuery.type( elem ) === "object" ) { |
|
5773 // Support: QtWebKit |
|
5774 // jQuery.merge because core_push.apply(_, arraylike) throws |
|
5775 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); |
|
5776 |
|
5777 // Convert non-html into a text node |
|
5778 } else if ( !rhtml.test( elem ) ) { |
|
5779 nodes.push( context.createTextNode( elem ) ); |
|
5780 |
|
5781 // Convert html into DOM nodes |
|
5782 } else { |
|
5783 tmp = tmp || fragment.appendChild( context.createElement("div") ); |
|
5784 |
|
5785 // Deserialize a standard representation |
|
5786 tag = ( rtagName.exec( elem ) || ["", ""] )[ 1 ].toLowerCase(); |
|
5787 wrap = wrapMap[ tag ] || wrapMap._default; |
|
5788 tmp.innerHTML = wrap[ 1 ] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[ 2 ]; |
|
5789 |
|
5790 // Descend through wrappers to the right content |
|
5791 j = wrap[ 0 ]; |
|
5792 while ( j-- ) { |
|
5793 tmp = tmp.lastChild; |
|
5794 } |
|
5795 |
|
5796 // Support: QtWebKit |
|
5797 // jQuery.merge because core_push.apply(_, arraylike) throws |
|
5798 jQuery.merge( nodes, tmp.childNodes ); |
|
5799 |
|
5800 // Remember the top-level container |
|
5801 tmp = fragment.firstChild; |
|
5802 |
|
5803 // Fixes #12346 |
|
5804 // Support: Webkit, IE |
|
5805 tmp.textContent = ""; |
|
5806 } |
|
5807 } |
|
5808 } |
|
5809 |
|
5810 // Remove wrapper from fragment |
|
5811 fragment.textContent = ""; |
|
5812 |
|
5813 i = 0; |
|
5814 while ( (elem = nodes[ i++ ]) ) { |
|
5815 |
|
5816 // #4087 - If origin and destination elements are the same, and this is |
|
5817 // that element, do not do anything |
|
5818 if ( selection && jQuery.inArray( elem, selection ) !== -1 ) { |
|
5819 continue; |
|
5820 } |
|
5821 |
|
5822 contains = jQuery.contains( elem.ownerDocument, elem ); |
|
5823 |
|
5824 // Append to fragment |
|
5825 tmp = getAll( fragment.appendChild( elem ), "script" ); |
|
5826 |
|
5827 // Preserve script evaluation history |
|
5828 if ( contains ) { |
|
5829 setGlobalEval( tmp ); |
|
5830 } |
|
5831 |
|
5832 // Capture executables |
|
5833 if ( scripts ) { |
|
5834 j = 0; |
|
5835 while ( (elem = tmp[ j++ ]) ) { |
|
5836 if ( rscriptType.test( elem.type || "" ) ) { |
|
5837 scripts.push( elem ); |
|
5838 } |
|
5839 } |
|
5840 } |
|
5841 } |
|
5842 |
|
5843 return fragment; |
|
5844 }, |
|
5845 |
|
5846 cleanData: function( elems ) { |
|
5847 var data, elem, events, type, key, j, |
|
5848 special = jQuery.event.special, |
|
5849 i = 0; |
|
5850 |
|
5851 for ( ; (elem = elems[ i ]) !== undefined; i++ ) { |
|
5852 if ( Data.accepts( elem ) ) { |
|
5853 key = elem[ data_priv.expando ]; |
|
5854 |
|
5855 if ( key && (data = data_priv.cache[ key ]) ) { |
|
5856 events = Object.keys( data.events || {} ); |
|
5857 if ( events.length ) { |
|
5858 for ( j = 0; (type = events[j]) !== undefined; j++ ) { |
|
5859 if ( special[ type ] ) { |
|
5860 jQuery.event.remove( elem, type ); |
|
5861 |
|
5862 // This is a shortcut to avoid jQuery.event.remove's overhead |
|
5863 } else { |
|
5864 jQuery.removeEvent( elem, type, data.handle ); |
|
5865 } |
|
5866 } |
|
5867 } |
|
5868 if ( data_priv.cache[ key ] ) { |
|
5869 // Discard any remaining `private` data |
|
5870 delete data_priv.cache[ key ]; |
|
5871 } |
|
5872 } |
|
5873 } |
|
5874 // Discard any remaining `user` data |
|
5875 delete data_user.cache[ elem[ data_user.expando ] ]; |
|
5876 } |
|
5877 }, |
|
5878 |
|
5879 _evalUrl: function( url ) { |
|
5880 return jQuery.ajax({ |
|
5881 url: url, |
|
5882 type: "GET", |
|
5883 dataType: "script", |
|
5884 async: false, |
|
5885 global: false, |
|
5886 "throws": true |
|
5887 }); |
|
5888 } |
|
5889 }); |
|
5890 |
|
5891 // Support: 1.x compatibility |
|
5892 // Manipulating tables requires a tbody |
|
5893 function manipulationTarget( elem, content ) { |
|
5894 return jQuery.nodeName( elem, "table" ) && |
|
5895 jQuery.nodeName( content.nodeType === 1 ? content : content.firstChild, "tr" ) ? |
|
5896 |
|
5897 elem.getElementsByTagName("tbody")[0] || |
|
5898 elem.appendChild( elem.ownerDocument.createElement("tbody") ) : |
|
5899 elem; |
|
5900 } |
|
5901 |
|
5902 // Replace/restore the type attribute of script elements for safe DOM manipulation |
|
5903 function disableScript( elem ) { |
|
5904 elem.type = (elem.getAttribute("type") !== null) + "/" + elem.type; |
|
5905 return elem; |
|
5906 } |
|
5907 function restoreScript( elem ) { |
|
5908 var match = rscriptTypeMasked.exec( elem.type ); |
|
5909 |
|
5910 if ( match ) { |
|
5911 elem.type = match[ 1 ]; |
|
5912 } else { |
|
5913 elem.removeAttribute("type"); |
|
5914 } |
|
5915 |
|
5916 return elem; |
|
5917 } |
|
5918 |
|
5919 // Mark scripts as having already been evaluated |
|
5920 function setGlobalEval( elems, refElements ) { |
|
5921 var l = elems.length, |
|
5922 i = 0; |
|
5923 |
|
5924 for ( ; i < l; i++ ) { |
|
5925 data_priv.set( |
|
5926 elems[ i ], "globalEval", !refElements || data_priv.get( refElements[ i ], "globalEval" ) |
|
5927 ); |
|
5928 } |
|
5929 } |
|
5930 |
|
5931 function cloneCopyEvent( src, dest ) { |
|
5932 var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events; |
|
5933 |
|
5934 if ( dest.nodeType !== 1 ) { |
|
5935 return; |
|
5936 } |
|
5937 |
|
5938 // 1. Copy private data: events, handlers, etc. |
|
5939 if ( data_priv.hasData( src ) ) { |
|
5940 pdataOld = data_priv.access( src ); |
|
5941 pdataCur = data_priv.set( dest, pdataOld ); |
|
5942 events = pdataOld.events; |
|
5943 |
|
5944 if ( events ) { |
|
5945 delete pdataCur.handle; |
|
5946 pdataCur.events = {}; |
|
5947 |
|
5948 for ( type in events ) { |
|
5949 for ( i = 0, l = events[ type ].length; i < l; i++ ) { |
|
5950 jQuery.event.add( dest, type, events[ type ][ i ] ); |
|
5951 } |
|
5952 } |
|
5953 } |
|
5954 } |
|
5955 |
|
5956 // 2. Copy user data |
|
5957 if ( data_user.hasData( src ) ) { |
|
5958 udataOld = data_user.access( src ); |
|
5959 udataCur = jQuery.extend( {}, udataOld ); |
|
5960 |
|
5961 data_user.set( dest, udataCur ); |
|
5962 } |
|
5963 } |
|
5964 |
|
5965 |
|
5966 function getAll( context, tag ) { |
|
5967 var ret = context.getElementsByTagName ? context.getElementsByTagName( tag || "*" ) : |
|
5968 context.querySelectorAll ? context.querySelectorAll( tag || "*" ) : |
|
5969 []; |
|
5970 |
|
5971 return tag === undefined || tag && jQuery.nodeName( context, tag ) ? |
|
5972 jQuery.merge( [ context ], ret ) : |
|
5973 ret; |
|
5974 } |
|
5975 |
|
5976 // Support: IE >= 9 |
|
5977 function fixInput( src, dest ) { |
|
5978 var nodeName = dest.nodeName.toLowerCase(); |
|
5979 |
|
5980 // Fails to persist the checked state of a cloned checkbox or radio button. |
|
5981 if ( nodeName === "input" && manipulation_rcheckableType.test( src.type ) ) { |
|
5982 dest.checked = src.checked; |
|
5983 |
|
5984 // Fails to return the selected option to the default selected state when cloning options |
|
5985 } else if ( nodeName === "input" || nodeName === "textarea" ) { |
|
5986 dest.defaultValue = src.defaultValue; |
|
5987 } |
|
5988 } |
|
5989 jQuery.fn.extend({ |
|
5990 wrapAll: function( html ) { |
|
5991 var wrap; |
|
5992 |
|
5993 if ( jQuery.isFunction( html ) ) { |
|
5994 return this.each(function( i ) { |
|
5995 jQuery( this ).wrapAll( html.call(this, i) ); |
|
5996 }); |
|
5997 } |
|
5998 |
|
5999 if ( this[ 0 ] ) { |
|
6000 |
|
6001 // The elements to wrap the target around |
|
6002 wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true ); |
|
6003 |
|
6004 if ( this[ 0 ].parentNode ) { |
|
6005 wrap.insertBefore( this[ 0 ] ); |
|
6006 } |
|
6007 |
|
6008 wrap.map(function() { |
|
6009 var elem = this; |
|
6010 |
|
6011 while ( elem.firstElementChild ) { |
|
6012 elem = elem.firstElementChild; |
|
6013 } |
|
6014 |
|
6015 return elem; |
|
6016 }).append( this ); |
|
6017 } |
|
6018 |
|
6019 return this; |
|
6020 }, |
|
6021 |
|
6022 wrapInner: function( html ) { |
|
6023 if ( jQuery.isFunction( html ) ) { |
|
6024 return this.each(function( i ) { |
|
6025 jQuery( this ).wrapInner( html.call(this, i) ); |
|
6026 }); |
|
6027 } |
|
6028 |
|
6029 return this.each(function() { |
|
6030 var self = jQuery( this ), |
|
6031 contents = self.contents(); |
|
6032 |
|
6033 if ( contents.length ) { |
|
6034 contents.wrapAll( html ); |
|
6035 |
|
6036 } else { |
|
6037 self.append( html ); |
|
6038 } |
|
6039 }); |
|
6040 }, |
|
6041 |
|
6042 wrap: function( html ) { |
|
6043 var isFunction = jQuery.isFunction( html ); |
|
6044 |
|
6045 return this.each(function( i ) { |
|
6046 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html ); |
|
6047 }); |
|
6048 }, |
|
6049 |
|
6050 unwrap: function() { |
|
6051 return this.parent().each(function() { |
|
6052 if ( !jQuery.nodeName( this, "body" ) ) { |
|
6053 jQuery( this ).replaceWith( this.childNodes ); |
|
6054 } |
|
6055 }).end(); |
|
6056 } |
|
6057 }); |
|
6058 var curCSS, iframe, |
|
6059 // swappable if display is none or starts with table except "table", "table-cell", or "table-caption" |
|
6060 // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display |
|
6061 rdisplayswap = /^(none|table(?!-c[ea]).+)/, |
|
6062 rmargin = /^margin/, |
|
6063 rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ), |
|
6064 rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ), |
|
6065 rrelNum = new RegExp( "^([+-])=(" + core_pnum + ")", "i" ), |
|
6066 elemdisplay = { BODY: "block" }, |
|
6067 |
|
6068 cssShow = { position: "absolute", visibility: "hidden", display: "block" }, |
|
6069 cssNormalTransform = { |
|
6070 letterSpacing: 0, |
|
6071 fontWeight: 400 |
|
6072 }, |
|
6073 |
|
6074 cssExpand = [ "Top", "Right", "Bottom", "Left" ], |
|
6075 cssPrefixes = [ "Webkit", "O", "Moz", "ms" ]; |
|
6076 |
|
6077 // return a css property mapped to a potentially vendor prefixed property |
|
6078 function vendorPropName( style, name ) { |
|
6079 |
|
6080 // shortcut for names that are not vendor prefixed |
|
6081 if ( name in style ) { |
|
6082 return name; |
|
6083 } |
|
6084 |
|
6085 // check for vendor prefixed names |
|
6086 var capName = name.charAt(0).toUpperCase() + name.slice(1), |
|
6087 origName = name, |
|
6088 i = cssPrefixes.length; |
|
6089 |
|
6090 while ( i-- ) { |
|
6091 name = cssPrefixes[ i ] + capName; |
|
6092 if ( name in style ) { |
|
6093 return name; |
|
6094 } |
|
6095 } |
|
6096 |
|
6097 return origName; |
|
6098 } |
|
6099 |
|
6100 function isHidden( elem, el ) { |
|
6101 // isHidden might be called from jQuery#filter function; |
|
6102 // in that case, element will be second argument |
|
6103 elem = el || elem; |
|
6104 return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem ); |
|
6105 } |
|
6106 |
|
6107 // NOTE: we've included the "window" in window.getComputedStyle |
|
6108 // because jsdom on node.js will break without it. |
|
6109 function getStyles( elem ) { |
|
6110 return window.getComputedStyle( elem, null ); |
|
6111 } |
|
6112 |
|
6113 function showHide( elements, show ) { |
|
6114 var display, elem, hidden, |
|
6115 values = [], |
|
6116 index = 0, |
|
6117 length = elements.length; |
|
6118 |
|
6119 for ( ; index < length; index++ ) { |
|
6120 elem = elements[ index ]; |
|
6121 if ( !elem.style ) { |
|
6122 continue; |
|
6123 } |
|
6124 |
|
6125 values[ index ] = data_priv.get( elem, "olddisplay" ); |
|
6126 display = elem.style.display; |
|
6127 if ( show ) { |
|
6128 // Reset the inline display of this element to learn if it is |
|
6129 // being hidden by cascaded rules or not |
|
6130 if ( !values[ index ] && display === "none" ) { |
|
6131 elem.style.display = ""; |
|
6132 } |
|
6133 |
|
6134 // Set elements which have been overridden with display: none |
|
6135 // in a stylesheet to whatever the default browser style is |
|
6136 // for such an element |
|
6137 if ( elem.style.display === "" && isHidden( elem ) ) { |
|
6138 values[ index ] = data_priv.access( elem, "olddisplay", css_defaultDisplay(elem.nodeName) ); |
|
6139 } |
|
6140 } else { |
|
6141 |
|
6142 if ( !values[ index ] ) { |
|
6143 hidden = isHidden( elem ); |
|
6144 |
|
6145 if ( display && display !== "none" || !hidden ) { |
|
6146 data_priv.set( elem, "olddisplay", hidden ? display : jQuery.css(elem, "display") ); |
|
6147 } |
|
6148 } |
|
6149 } |
|
6150 } |
|
6151 |
|
6152 // Set the display of most of the elements in a second loop |
|
6153 // to avoid the constant reflow |
|
6154 for ( index = 0; index < length; index++ ) { |
|
6155 elem = elements[ index ]; |
|
6156 if ( !elem.style ) { |
|
6157 continue; |
|
6158 } |
|
6159 if ( !show || elem.style.display === "none" || elem.style.display === "" ) { |
|
6160 elem.style.display = show ? values[ index ] || "" : "none"; |
|
6161 } |
|
6162 } |
|
6163 |
|
6164 return elements; |
|
6165 } |
|
6166 |
|
6167 jQuery.fn.extend({ |
|
6168 css: function( name, value ) { |
|
6169 return jQuery.access( this, function( elem, name, value ) { |
|
6170 var styles, len, |
|
6171 map = {}, |
|
6172 i = 0; |
|
6173 |
|
6174 if ( jQuery.isArray( name ) ) { |
|
6175 styles = getStyles( elem ); |
|
6176 len = name.length; |
|
6177 |
|
6178 for ( ; i < len; i++ ) { |
|
6179 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles ); |
|
6180 } |
|
6181 |
|
6182 return map; |
|
6183 } |
|
6184 |
|
6185 return value !== undefined ? |
|
6186 jQuery.style( elem, name, value ) : |
|
6187 jQuery.css( elem, name ); |
|
6188 }, name, value, arguments.length > 1 ); |
|
6189 }, |
|
6190 show: function() { |
|
6191 return showHide( this, true ); |
|
6192 }, |
|
6193 hide: function() { |
|
6194 return showHide( this ); |
|
6195 }, |
|
6196 toggle: function( state ) { |
|
6197 if ( typeof state === "boolean" ) { |
|
6198 return state ? this.show() : this.hide(); |
|
6199 } |
|
6200 |
|
6201 return this.each(function() { |
|
6202 if ( isHidden( this ) ) { |
|
6203 jQuery( this ).show(); |
|
6204 } else { |
|
6205 jQuery( this ).hide(); |
|
6206 } |
|
6207 }); |
|
6208 } |
|
6209 }); |
|
6210 |
|
6211 jQuery.extend({ |
|
6212 // Add in style property hooks for overriding the default |
|
6213 // behavior of getting and setting a style property |
|
6214 cssHooks: { |
|
6215 opacity: { |
|
6216 get: function( elem, computed ) { |
|
6217 if ( computed ) { |
|
6218 // We should always get a number back from opacity |
|
6219 var ret = curCSS( elem, "opacity" ); |
|
6220 return ret === "" ? "1" : ret; |
|
6221 } |
|
6222 } |
|
6223 } |
|
6224 }, |
|
6225 |
|
6226 // Don't automatically add "px" to these possibly-unitless properties |
|
6227 cssNumber: { |
|
6228 "columnCount": true, |
|
6229 "fillOpacity": true, |
|
6230 "fontWeight": true, |
|
6231 "lineHeight": true, |
|
6232 "opacity": true, |
|
6233 "order": true, |
|
6234 "orphans": true, |
|
6235 "widows": true, |
|
6236 "zIndex": true, |
|
6237 "zoom": true |
|
6238 }, |
|
6239 |
|
6240 // Add in properties whose names you wish to fix before |
|
6241 // setting or getting the value |
|
6242 cssProps: { |
|
6243 // normalize float css property |
|
6244 "float": "cssFloat" |
|
6245 }, |
|
6246 |
|
6247 // Get and set the style property on a DOM Node |
|
6248 style: function( elem, name, value, extra ) { |
|
6249 // Don't set styles on text and comment nodes |
|
6250 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { |
|
6251 return; |
|
6252 } |
|
6253 |
|
6254 // Make sure that we're working with the right name |
|
6255 var ret, type, hooks, |
|
6256 origName = jQuery.camelCase( name ), |
|
6257 style = elem.style; |
|
6258 |
|
6259 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) ); |
|
6260 |
|
6261 // gets hook for the prefixed version |
|
6262 // followed by the unprefixed version |
|
6263 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; |
|
6264 |
|
6265 // Check if we're setting a value |
|
6266 if ( value !== undefined ) { |
|
6267 type = typeof value; |
|
6268 |
|
6269 // convert relative number strings (+= or -=) to relative numbers. #7345 |
|
6270 if ( type === "string" && (ret = rrelNum.exec( value )) ) { |
|
6271 value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) ); |
|
6272 // Fixes bug #9237 |
|
6273 type = "number"; |
|
6274 } |
|
6275 |
|
6276 // Make sure that NaN and null values aren't set. See: #7116 |
|
6277 if ( value == null || type === "number" && isNaN( value ) ) { |
|
6278 return; |
|
6279 } |
|
6280 |
|
6281 // If a number was passed in, add 'px' to the (except for certain CSS properties) |
|
6282 if ( type === "number" && !jQuery.cssNumber[ origName ] ) { |
|
6283 value += "px"; |
|
6284 } |
|
6285 |
|
6286 // Fixes #8908, it can be done more correctly by specifying setters in cssHooks, |
|
6287 // but it would mean to define eight (for every problematic property) identical functions |
|
6288 if ( !jQuery.support.clearCloneStyle && value === "" && name.indexOf("background") === 0 ) { |
|
6289 style[ name ] = "inherit"; |
|
6290 } |
|
6291 |
|
6292 // If a hook was provided, use that value, otherwise just set the specified value |
|
6293 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) { |
|
6294 style[ name ] = value; |
|
6295 } |
|
6296 |
|
6297 } else { |
|
6298 // If a hook was provided get the non-computed value from there |
|
6299 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) { |
|
6300 return ret; |
|
6301 } |
|
6302 |
|
6303 // Otherwise just get the value from the style object |
|
6304 return style[ name ]; |
|
6305 } |
|
6306 }, |
|
6307 |
|
6308 css: function( elem, name, extra, styles ) { |
|
6309 var val, num, hooks, |
|
6310 origName = jQuery.camelCase( name ); |
|
6311 |
|
6312 // Make sure that we're working with the right name |
|
6313 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) ); |
|
6314 |
|
6315 // gets hook for the prefixed version |
|
6316 // followed by the unprefixed version |
|
6317 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; |
|
6318 |
|
6319 // If a hook was provided get the computed value from there |
|
6320 if ( hooks && "get" in hooks ) { |
|
6321 val = hooks.get( elem, true, extra ); |
|
6322 } |
|
6323 |
|
6324 // Otherwise, if a way to get the computed value exists, use that |
|
6325 if ( val === undefined ) { |
|
6326 val = curCSS( elem, name, styles ); |
|
6327 } |
|
6328 |
|
6329 //convert "normal" to computed value |
|
6330 if ( val === "normal" && name in cssNormalTransform ) { |
|
6331 val = cssNormalTransform[ name ]; |
|
6332 } |
|
6333 |
|
6334 // Return, converting to number if forced or a qualifier was provided and val looks numeric |
|
6335 if ( extra === "" || extra ) { |
|
6336 num = parseFloat( val ); |
|
6337 return extra === true || jQuery.isNumeric( num ) ? num || 0 : val; |
|
6338 } |
|
6339 return val; |
|
6340 } |
|
6341 }); |
|
6342 |
|
6343 curCSS = function( elem, name, _computed ) { |
|
6344 var width, minWidth, maxWidth, |
|
6345 computed = _computed || getStyles( elem ), |
|
6346 |
|
6347 // Support: IE9 |
|
6348 // getPropertyValue is only needed for .css('filter') in IE9, see #12537 |
|
6349 ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined, |
|
6350 style = elem.style; |
|
6351 |
|
6352 if ( computed ) { |
|
6353 |
|
6354 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) { |
|
6355 ret = jQuery.style( elem, name ); |
|
6356 } |
|
6357 |
|
6358 // Support: Safari 5.1 |
|
6359 // A tribute to the "awesome hack by Dean Edwards" |
|
6360 // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels |
|
6361 // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values |
|
6362 if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) { |
|
6363 |
|
6364 // Remember the original values |
|
6365 width = style.width; |
|
6366 minWidth = style.minWidth; |
|
6367 maxWidth = style.maxWidth; |
|
6368 |
|
6369 // Put in the new values to get a computed value out |
|
6370 style.minWidth = style.maxWidth = style.width = ret; |
|
6371 ret = computed.width; |
|
6372 |
|
6373 // Revert the changed values |
|
6374 style.width = width; |
|
6375 style.minWidth = minWidth; |
|
6376 style.maxWidth = maxWidth; |
|
6377 } |
|
6378 } |
|
6379 |
|
6380 return ret; |
|
6381 }; |
|
6382 |
|
6383 |
|
6384 function setPositiveNumber( elem, value, subtract ) { |
|
6385 var matches = rnumsplit.exec( value ); |
|
6386 return matches ? |
|
6387 // Guard against undefined "subtract", e.g., when used as in cssHooks |
|
6388 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) : |
|
6389 value; |
|
6390 } |
|
6391 |
|
6392 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { |
|
6393 var i = extra === ( isBorderBox ? "border" : "content" ) ? |
|
6394 // If we already have the right measurement, avoid augmentation |
|
6395 4 : |
|
6396 // Otherwise initialize for horizontal or vertical properties |
|
6397 name === "width" ? 1 : 0, |
|
6398 |
|
6399 val = 0; |
|
6400 |
|
6401 for ( ; i < 4; i += 2 ) { |
|
6402 // both box models exclude margin, so add it if we want it |
|
6403 if ( extra === "margin" ) { |
|
6404 val += jQuery.css( elem, extra + cssExpand[ i ], true, styles ); |
|
6405 } |
|
6406 |
|
6407 if ( isBorderBox ) { |
|
6408 // border-box includes padding, so remove it if we want content |
|
6409 if ( extra === "content" ) { |
|
6410 val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); |
|
6411 } |
|
6412 |
|
6413 // at this point, extra isn't border nor margin, so remove border |
|
6414 if ( extra !== "margin" ) { |
|
6415 val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); |
|
6416 } |
|
6417 } else { |
|
6418 // at this point, extra isn't content, so add padding |
|
6419 val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); |
|
6420 |
|
6421 // at this point, extra isn't content nor padding, so add border |
|
6422 if ( extra !== "padding" ) { |
|
6423 val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); |
|
6424 } |
|
6425 } |
|
6426 } |
|
6427 |
|
6428 return val; |
|
6429 } |
|
6430 |
|
6431 function getWidthOrHeight( elem, name, extra ) { |
|
6432 |
|
6433 // Start with offset property, which is equivalent to the border-box value |
|
6434 var valueIsBorderBox = true, |
|
6435 val = name === "width" ? elem.offsetWidth : elem.offsetHeight, |
|
6436 styles = getStyles( elem ), |
|
6437 isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; |
|
6438 |
|
6439 // some non-html elements return undefined for offsetWidth, so check for null/undefined |
|
6440 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 |
|
6441 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 |
|
6442 if ( val <= 0 || val == null ) { |
|
6443 // Fall back to computed then uncomputed css if necessary |
|
6444 val = curCSS( elem, name, styles ); |
|
6445 if ( val < 0 || val == null ) { |
|
6446 val = elem.style[ name ]; |
|
6447 } |
|
6448 |
|
6449 // Computed unit is not pixels. Stop here and return. |
|
6450 if ( rnumnonpx.test(val) ) { |
|
6451 return val; |
|
6452 } |
|
6453 |
|
6454 // we need the check for style in case a browser which returns unreliable values |
|
6455 // for getComputedStyle silently falls back to the reliable elem.style |
|
6456 valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReliable || val === elem.style[ name ] ); |
|
6457 |
|
6458 // Normalize "", auto, and prepare for extra |
|
6459 val = parseFloat( val ) || 0; |
|
6460 } |
|
6461 |
|
6462 // use the active box-sizing model to add/subtract irrelevant styles |
|
6463 return ( val + |
|
6464 augmentWidthOrHeight( |
|
6465 elem, |
|
6466 name, |
|
6467 extra || ( isBorderBox ? "border" : "content" ), |
|
6468 valueIsBorderBox, |
|
6469 styles |
|
6470 ) |
|
6471 ) + "px"; |
|
6472 } |
|
6473 |
|
6474 // Try to determine the default display value of an element |
|
6475 function css_defaultDisplay( nodeName ) { |
|
6476 var doc = document, |
|
6477 display = elemdisplay[ nodeName ]; |
|
6478 |
|
6479 if ( !display ) { |
|
6480 display = actualDisplay( nodeName, doc ); |
|
6481 |
|
6482 // If the simple way fails, read from inside an iframe |
|
6483 if ( display === "none" || !display ) { |
|
6484 // Use the already-created iframe if possible |
|
6485 iframe = ( iframe || |
|
6486 jQuery("<iframe frameborder='0' width='0' height='0'/>") |
|
6487 .css( "cssText", "display:block !important" ) |
|
6488 ).appendTo( doc.documentElement ); |
|
6489 |
|
6490 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse |
|
6491 doc = ( iframe[0].contentWindow || iframe[0].contentDocument ).document; |
|
6492 doc.write("<!doctype html><html><body>"); |
|
6493 doc.close(); |
|
6494 |
|
6495 display = actualDisplay( nodeName, doc ); |
|
6496 iframe.detach(); |
|
6497 } |
|
6498 |
|
6499 // Store the correct default display |
|
6500 elemdisplay[ nodeName ] = display; |
|
6501 } |
|
6502 |
|
6503 return display; |
|
6504 } |
|
6505 |
|
6506 // Called ONLY from within css_defaultDisplay |
|
6507 function actualDisplay( name, doc ) { |
|
6508 var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ), |
|
6509 display = jQuery.css( elem[0], "display" ); |
|
6510 elem.remove(); |
|
6511 return display; |
|
6512 } |
|
6513 |
|
6514 jQuery.each([ "height", "width" ], function( i, name ) { |
|
6515 jQuery.cssHooks[ name ] = { |
|
6516 get: function( elem, computed, extra ) { |
|
6517 if ( computed ) { |
|
6518 // certain elements can have dimension info if we invisibly show them |
|
6519 // however, it must have a current display style that would benefit from this |
|
6520 return elem.offsetWidth === 0 && rdisplayswap.test( jQuery.css( elem, "display" ) ) ? |
|
6521 jQuery.swap( elem, cssShow, function() { |
|
6522 return getWidthOrHeight( elem, name, extra ); |
|
6523 }) : |
|
6524 getWidthOrHeight( elem, name, extra ); |
|
6525 } |
|
6526 }, |
|
6527 |
|
6528 set: function( elem, value, extra ) { |
|
6529 var styles = extra && getStyles( elem ); |
|
6530 return setPositiveNumber( elem, value, extra ? |
|
6531 augmentWidthOrHeight( |
|
6532 elem, |
|
6533 name, |
|
6534 extra, |
|
6535 jQuery.support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box", |
|
6536 styles |
|
6537 ) : 0 |
|
6538 ); |
|
6539 } |
|
6540 }; |
|
6541 }); |
|
6542 |
|
6543 // These hooks cannot be added until DOM ready because the support test |
|
6544 // for it is not run until after DOM ready |
|
6545 jQuery(function() { |
|
6546 // Support: Android 2.3 |
|
6547 if ( !jQuery.support.reliableMarginRight ) { |
|
6548 jQuery.cssHooks.marginRight = { |
|
6549 get: function( elem, computed ) { |
|
6550 if ( computed ) { |
|
6551 // Support: Android 2.3 |
|
6552 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right |
|
6553 // Work around by temporarily setting element display to inline-block |
|
6554 return jQuery.swap( elem, { "display": "inline-block" }, |
|
6555 curCSS, [ elem, "marginRight" ] ); |
|
6556 } |
|
6557 } |
|
6558 }; |
|
6559 } |
|
6560 |
|
6561 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084 |
|
6562 // getComputedStyle returns percent when specified for top/left/bottom/right |
|
6563 // rather than make the css module depend on the offset module, we just check for it here |
|
6564 if ( !jQuery.support.pixelPosition && jQuery.fn.position ) { |
|
6565 jQuery.each( [ "top", "left" ], function( i, prop ) { |
|
6566 jQuery.cssHooks[ prop ] = { |
|
6567 get: function( elem, computed ) { |
|
6568 if ( computed ) { |
|
6569 computed = curCSS( elem, prop ); |
|
6570 // if curCSS returns percentage, fallback to offset |
|
6571 return rnumnonpx.test( computed ) ? |
|
6572 jQuery( elem ).position()[ prop ] + "px" : |
|
6573 computed; |
|
6574 } |
|
6575 } |
|
6576 }; |
|
6577 }); |
|
6578 } |
|
6579 |
|
6580 }); |
|
6581 |
|
6582 if ( jQuery.expr && jQuery.expr.filters ) { |
|
6583 jQuery.expr.filters.hidden = function( elem ) { |
|
6584 // Support: Opera <= 12.12 |
|
6585 // Opera reports offsetWidths and offsetHeights less than zero on some elements |
|
6586 return elem.offsetWidth <= 0 && elem.offsetHeight <= 0; |
|
6587 }; |
|
6588 |
|
6589 jQuery.expr.filters.visible = function( elem ) { |
|
6590 return !jQuery.expr.filters.hidden( elem ); |
|
6591 }; |
|
6592 } |
|
6593 |
|
6594 // These hooks are used by animate to expand properties |
|
6595 jQuery.each({ |
|
6596 margin: "", |
|
6597 padding: "", |
|
6598 border: "Width" |
|
6599 }, function( prefix, suffix ) { |
|
6600 jQuery.cssHooks[ prefix + suffix ] = { |
|
6601 expand: function( value ) { |
|
6602 var i = 0, |
|
6603 expanded = {}, |
|
6604 |
|
6605 // assumes a single number if not a string |
|
6606 parts = typeof value === "string" ? value.split(" ") : [ value ]; |
|
6607 |
|
6608 for ( ; i < 4; i++ ) { |
|
6609 expanded[ prefix + cssExpand[ i ] + suffix ] = |
|
6610 parts[ i ] || parts[ i - 2 ] || parts[ 0 ]; |
|
6611 } |
|
6612 |
|
6613 return expanded; |
|
6614 } |
|
6615 }; |
|
6616 |
|
6617 if ( !rmargin.test( prefix ) ) { |
|
6618 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; |
|
6619 } |
|
6620 }); |
|
6621 var r20 = /%20/g, |
|
6622 rbracket = /\[\]$/, |
|
6623 rCRLF = /\r?\n/g, |
|
6624 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, |
|
6625 rsubmittable = /^(?:input|select|textarea|keygen)/i; |
|
6626 |
|
6627 jQuery.fn.extend({ |
|
6628 serialize: function() { |
|
6629 return jQuery.param( this.serializeArray() ); |
|
6630 }, |
|
6631 serializeArray: function() { |
|
6632 return this.map(function(){ |
|
6633 // Can add propHook for "elements" to filter or add form elements |
|
6634 var elements = jQuery.prop( this, "elements" ); |
|
6635 return elements ? jQuery.makeArray( elements ) : this; |
|
6636 }) |
|
6637 .filter(function(){ |
|
6638 var type = this.type; |
|
6639 // Use .is(":disabled") so that fieldset[disabled] works |
|
6640 return this.name && !jQuery( this ).is( ":disabled" ) && |
|
6641 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) && |
|
6642 ( this.checked || !manipulation_rcheckableType.test( type ) ); |
|
6643 }) |
|
6644 .map(function( i, elem ){ |
|
6645 var val = jQuery( this ).val(); |
|
6646 |
|
6647 return val == null ? |
|
6648 null : |
|
6649 jQuery.isArray( val ) ? |
|
6650 jQuery.map( val, function( val ){ |
|
6651 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; |
|
6652 }) : |
|
6653 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; |
|
6654 }).get(); |
|
6655 } |
|
6656 }); |
|
6657 |
|
6658 //Serialize an array of form elements or a set of |
|
6659 //key/values into a query string |
|
6660 jQuery.param = function( a, traditional ) { |
|
6661 var prefix, |
|
6662 s = [], |
|
6663 add = function( key, value ) { |
|
6664 // If value is a function, invoke it and return its value |
|
6665 value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value ); |
|
6666 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value ); |
|
6667 }; |
|
6668 |
|
6669 // Set traditional to true for jQuery <= 1.3.2 behavior. |
|
6670 if ( traditional === undefined ) { |
|
6671 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional; |
|
6672 } |
|
6673 |
|
6674 // If an array was passed in, assume that it is an array of form elements. |
|
6675 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { |
|
6676 // Serialize the form elements |
|
6677 jQuery.each( a, function() { |
|
6678 add( this.name, this.value ); |
|
6679 }); |
|
6680 |
|
6681 } else { |
|
6682 // If traditional, encode the "old" way (the way 1.3.2 or older |
|
6683 // did it), otherwise encode params recursively. |
|
6684 for ( prefix in a ) { |
|
6685 buildParams( prefix, a[ prefix ], traditional, add ); |
|
6686 } |
|
6687 } |
|
6688 |
|
6689 // Return the resulting serialization |
|
6690 return s.join( "&" ).replace( r20, "+" ); |
|
6691 }; |
|
6692 |
|
6693 function buildParams( prefix, obj, traditional, add ) { |
|
6694 var name; |
|
6695 |
|
6696 if ( jQuery.isArray( obj ) ) { |
|
6697 // Serialize array item. |
|
6698 jQuery.each( obj, function( i, v ) { |
|
6699 if ( traditional || rbracket.test( prefix ) ) { |
|
6700 // Treat each array item as a scalar. |
|
6701 add( prefix, v ); |
|
6702 |
|
6703 } else { |
|
6704 // Item is non-scalar (array or object), encode its numeric index. |
|
6705 buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add ); |
|
6706 } |
|
6707 }); |
|
6708 |
|
6709 } else if ( !traditional && jQuery.type( obj ) === "object" ) { |
|
6710 // Serialize object item. |
|
6711 for ( name in obj ) { |
|
6712 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); |
|
6713 } |
|
6714 |
|
6715 } else { |
|
6716 // Serialize scalar item. |
|
6717 add( prefix, obj ); |
|
6718 } |
|
6719 } |
|
6720 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + |
7385 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + |
6721 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + |
7386 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + |
6722 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) { |
7387 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) { |
6723 |
7388 |
6724 // Handle event binding |
7389 // Handle event binding |
7739 |
8707 |
7740 // Delegate to script |
8708 // Delegate to script |
7741 return "script"; |
8709 return "script"; |
7742 } |
8710 } |
7743 }); |
8711 }); |
7744 jQuery.ajaxSettings.xhr = function() { |
8712 |
7745 try { |
8713 |
7746 return new XMLHttpRequest(); |
8714 |
7747 } catch( e ) {} |
8715 |
|
8716 // data: string of html |
|
8717 // context (optional): If specified, the fragment will be created in this context, defaults to document |
|
8718 // keepScripts (optional): If true, will include scripts passed in the html string |
|
8719 jQuery.parseHTML = function( data, context, keepScripts ) { |
|
8720 if ( !data || typeof data !== "string" ) { |
|
8721 return null; |
|
8722 } |
|
8723 if ( typeof context === "boolean" ) { |
|
8724 keepScripts = context; |
|
8725 context = false; |
|
8726 } |
|
8727 context = context || document; |
|
8728 |
|
8729 var parsed = rsingleTag.exec( data ), |
|
8730 scripts = !keepScripts && []; |
|
8731 |
|
8732 // Single tag |
|
8733 if ( parsed ) { |
|
8734 return [ context.createElement( parsed[1] ) ]; |
|
8735 } |
|
8736 |
|
8737 parsed = jQuery.buildFragment( [ data ], context, scripts ); |
|
8738 |
|
8739 if ( scripts && scripts.length ) { |
|
8740 jQuery( scripts ).remove(); |
|
8741 } |
|
8742 |
|
8743 return jQuery.merge( [], parsed.childNodes ); |
7748 }; |
8744 }; |
7749 |
8745 |
7750 var xhrSupported = jQuery.ajaxSettings.xhr(), |
8746 |
7751 xhrSuccessStatus = { |
8747 // Keep a copy of the old load method |
7752 // file protocol always yields status code 0, assume 200 |
8748 var _load = jQuery.fn.load; |
7753 0: 200, |
8749 |
7754 // Support: IE9 |
8750 /** |
7755 // #1450: sometimes IE returns 1223 when it should be 204 |
8751 * Load a url into a page |
7756 1223: 204 |
8752 */ |
7757 }, |
8753 jQuery.fn.load = function( url, params, callback ) { |
7758 // Support: IE9 |
8754 if ( typeof url !== "string" && _load ) { |
7759 // We need to keep track of outbound xhr and abort them manually |
8755 return _load.apply( this, arguments ); |
7760 // because IE is not smart enough to do it all by itself |
8756 } |
7761 xhrId = 0, |
8757 |
7762 xhrCallbacks = {}; |
8758 var selector, type, response, |
7763 |
8759 self = this, |
7764 if ( window.ActiveXObject ) { |
8760 off = url.indexOf(" "); |
7765 jQuery( window ).on( "unload", function() { |
8761 |
7766 for( var key in xhrCallbacks ) { |
8762 if ( off >= 0 ) { |
7767 xhrCallbacks[ key ](); |
8763 selector = url.slice( off ); |
7768 } |
8764 url = url.slice( 0, off ); |
7769 xhrCallbacks = undefined; |
8765 } |
7770 }); |
8766 |
|
8767 // If it's a function |
|
8768 if ( jQuery.isFunction( params ) ) { |
|
8769 |
|
8770 // We assume that it's the callback |
|
8771 callback = params; |
|
8772 params = undefined; |
|
8773 |
|
8774 // Otherwise, build a param string |
|
8775 } else if ( params && typeof params === "object" ) { |
|
8776 type = "POST"; |
|
8777 } |
|
8778 |
|
8779 // If we have elements to modify, make the request |
|
8780 if ( self.length > 0 ) { |
|
8781 jQuery.ajax({ |
|
8782 url: url, |
|
8783 |
|
8784 // if "type" variable is undefined, then "GET" method will be used |
|
8785 type: type, |
|
8786 dataType: "html", |
|
8787 data: params |
|
8788 }).done(function( responseText ) { |
|
8789 |
|
8790 // Save response for use in complete callback |
|
8791 response = arguments; |
|
8792 |
|
8793 self.html( selector ? |
|
8794 |
|
8795 // If a selector was specified, locate the right elements in a dummy div |
|
8796 // Exclude scripts to avoid IE 'Permission Denied' errors |
|
8797 jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) : |
|
8798 |
|
8799 // Otherwise use the full result |
|
8800 responseText ); |
|
8801 |
|
8802 }).complete( callback && function( jqXHR, status ) { |
|
8803 self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] ); |
|
8804 }); |
|
8805 } |
|
8806 |
|
8807 return this; |
|
8808 }; |
|
8809 |
|
8810 |
|
8811 |
|
8812 |
|
8813 jQuery.expr.filters.animated = function( elem ) { |
|
8814 return jQuery.grep(jQuery.timers, function( fn ) { |
|
8815 return elem === fn.elem; |
|
8816 }).length; |
|
8817 }; |
|
8818 |
|
8819 |
|
8820 |
|
8821 |
|
8822 var docElem = window.document.documentElement; |
|
8823 |
|
8824 /** |
|
8825 * Gets a window from an element |
|
8826 */ |
|
8827 function getWindow( elem ) { |
|
8828 return jQuery.isWindow( elem ) ? elem : elem.nodeType === 9 && elem.defaultView; |
7771 } |
8829 } |
7772 |
8830 |
7773 jQuery.support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); |
|
7774 jQuery.support.ajax = xhrSupported = !!xhrSupported; |
|
7775 |
|
7776 jQuery.ajaxTransport(function( options ) { |
|
7777 var callback; |
|
7778 // Cross domain only allowed if supported through XMLHttpRequest |
|
7779 if ( jQuery.support.cors || xhrSupported && !options.crossDomain ) { |
|
7780 return { |
|
7781 send: function( headers, complete ) { |
|
7782 var i, id, |
|
7783 xhr = options.xhr(); |
|
7784 xhr.open( options.type, options.url, options.async, options.username, options.password ); |
|
7785 // Apply custom fields if provided |
|
7786 if ( options.xhrFields ) { |
|
7787 for ( i in options.xhrFields ) { |
|
7788 xhr[ i ] = options.xhrFields[ i ]; |
|
7789 } |
|
7790 } |
|
7791 // Override mime type if needed |
|
7792 if ( options.mimeType && xhr.overrideMimeType ) { |
|
7793 xhr.overrideMimeType( options.mimeType ); |
|
7794 } |
|
7795 // X-Requested-With header |
|
7796 // For cross-domain requests, seeing as conditions for a preflight are |
|
7797 // akin to a jigsaw puzzle, we simply never set it to be sure. |
|
7798 // (it can always be set on a per-request basis or even using ajaxSetup) |
|
7799 // For same-domain requests, won't change header if already provided. |
|
7800 if ( !options.crossDomain && !headers["X-Requested-With"] ) { |
|
7801 headers["X-Requested-With"] = "XMLHttpRequest"; |
|
7802 } |
|
7803 // Set headers |
|
7804 for ( i in headers ) { |
|
7805 xhr.setRequestHeader( i, headers[ i ] ); |
|
7806 } |
|
7807 // Callback |
|
7808 callback = function( type ) { |
|
7809 return function() { |
|
7810 if ( callback ) { |
|
7811 delete xhrCallbacks[ id ]; |
|
7812 callback = xhr.onload = xhr.onerror = null; |
|
7813 if ( type === "abort" ) { |
|
7814 xhr.abort(); |
|
7815 } else if ( type === "error" ) { |
|
7816 complete( |
|
7817 // file protocol always yields status 0, assume 404 |
|
7818 xhr.status || 404, |
|
7819 xhr.statusText |
|
7820 ); |
|
7821 } else { |
|
7822 complete( |
|
7823 xhrSuccessStatus[ xhr.status ] || xhr.status, |
|
7824 xhr.statusText, |
|
7825 // Support: IE9 |
|
7826 // #11426: When requesting binary data, IE9 will throw an exception |
|
7827 // on any attempt to access responseText |
|
7828 typeof xhr.responseText === "string" ? { |
|
7829 text: xhr.responseText |
|
7830 } : undefined, |
|
7831 xhr.getAllResponseHeaders() |
|
7832 ); |
|
7833 } |
|
7834 } |
|
7835 }; |
|
7836 }; |
|
7837 // Listen to events |
|
7838 xhr.onload = callback(); |
|
7839 xhr.onerror = callback("error"); |
|
7840 // Create the abort callback |
|
7841 callback = xhrCallbacks[( id = xhrId++ )] = callback("abort"); |
|
7842 // Do send the request |
|
7843 // This may raise an exception which is actually |
|
7844 // handled in jQuery.ajax (so no try/catch here) |
|
7845 xhr.send( options.hasContent && options.data || null ); |
|
7846 }, |
|
7847 abort: function() { |
|
7848 if ( callback ) { |
|
7849 callback(); |
|
7850 } |
|
7851 } |
|
7852 }; |
|
7853 } |
|
7854 }); |
|
7855 var fxNow, timerId, |
|
7856 rfxtypes = /^(?:toggle|show|hide)$/, |
|
7857 rfxnum = new RegExp( "^(?:([+-])=|)(" + core_pnum + ")([a-z%]*)$", "i" ), |
|
7858 rrun = /queueHooks$/, |
|
7859 animationPrefilters = [ defaultPrefilter ], |
|
7860 tweeners = { |
|
7861 "*": [function( prop, value ) { |
|
7862 var tween = this.createTween( prop, value ), |
|
7863 target = tween.cur(), |
|
7864 parts = rfxnum.exec( value ), |
|
7865 unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), |
|
7866 |
|
7867 // Starting value computation is required for potential unit mismatches |
|
7868 start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) && |
|
7869 rfxnum.exec( jQuery.css( tween.elem, prop ) ), |
|
7870 scale = 1, |
|
7871 maxIterations = 20; |
|
7872 |
|
7873 if ( start && start[ 3 ] !== unit ) { |
|
7874 // Trust units reported by jQuery.css |
|
7875 unit = unit || start[ 3 ]; |
|
7876 |
|
7877 // Make sure we update the tween properties later on |
|
7878 parts = parts || []; |
|
7879 |
|
7880 // Iteratively approximate from a nonzero starting point |
|
7881 start = +target || 1; |
|
7882 |
|
7883 do { |
|
7884 // If previous iteration zeroed out, double until we get *something* |
|
7885 // Use a string for doubling factor so we don't accidentally see scale as unchanged below |
|
7886 scale = scale || ".5"; |
|
7887 |
|
7888 // Adjust and apply |
|
7889 start = start / scale; |
|
7890 jQuery.style( tween.elem, prop, start + unit ); |
|
7891 |
|
7892 // Update scale, tolerating zero or NaN from tween.cur() |
|
7893 // And breaking the loop if scale is unchanged or perfect, or if we've just had enough |
|
7894 } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations ); |
|
7895 } |
|
7896 |
|
7897 // Update tween properties |
|
7898 if ( parts ) { |
|
7899 start = tween.start = +start || +target || 0; |
|
7900 tween.unit = unit; |
|
7901 // If a +=/-= token was provided, we're doing a relative animation |
|
7902 tween.end = parts[ 1 ] ? |
|
7903 start + ( parts[ 1 ] + 1 ) * parts[ 2 ] : |
|
7904 +parts[ 2 ]; |
|
7905 } |
|
7906 |
|
7907 return tween; |
|
7908 }] |
|
7909 }; |
|
7910 |
|
7911 // Animations created synchronously will run synchronously |
|
7912 function createFxNow() { |
|
7913 setTimeout(function() { |
|
7914 fxNow = undefined; |
|
7915 }); |
|
7916 return ( fxNow = jQuery.now() ); |
|
7917 } |
|
7918 |
|
7919 function createTween( value, prop, animation ) { |
|
7920 var tween, |
|
7921 collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ), |
|
7922 index = 0, |
|
7923 length = collection.length; |
|
7924 for ( ; index < length; index++ ) { |
|
7925 if ( (tween = collection[ index ].call( animation, prop, value )) ) { |
|
7926 |
|
7927 // we're done with this property |
|
7928 return tween; |
|
7929 } |
|
7930 } |
|
7931 } |
|
7932 |
|
7933 function Animation( elem, properties, options ) { |
|
7934 var result, |
|
7935 stopped, |
|
7936 index = 0, |
|
7937 length = animationPrefilters.length, |
|
7938 deferred = jQuery.Deferred().always( function() { |
|
7939 // don't match elem in the :animated selector |
|
7940 delete tick.elem; |
|
7941 }), |
|
7942 tick = function() { |
|
7943 if ( stopped ) { |
|
7944 return false; |
|
7945 } |
|
7946 var currentTime = fxNow || createFxNow(), |
|
7947 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), |
|
7948 // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497) |
|
7949 temp = remaining / animation.duration || 0, |
|
7950 percent = 1 - temp, |
|
7951 index = 0, |
|
7952 length = animation.tweens.length; |
|
7953 |
|
7954 for ( ; index < length ; index++ ) { |
|
7955 animation.tweens[ index ].run( percent ); |
|
7956 } |
|
7957 |
|
7958 deferred.notifyWith( elem, [ animation, percent, remaining ]); |
|
7959 |
|
7960 if ( percent < 1 && length ) { |
|
7961 return remaining; |
|
7962 } else { |
|
7963 deferred.resolveWith( elem, [ animation ] ); |
|
7964 return false; |
|
7965 } |
|
7966 }, |
|
7967 animation = deferred.promise({ |
|
7968 elem: elem, |
|
7969 props: jQuery.extend( {}, properties ), |
|
7970 opts: jQuery.extend( true, { specialEasing: {} }, options ), |
|
7971 originalProperties: properties, |
|
7972 originalOptions: options, |
|
7973 startTime: fxNow || createFxNow(), |
|
7974 duration: options.duration, |
|
7975 tweens: [], |
|
7976 createTween: function( prop, end ) { |
|
7977 var tween = jQuery.Tween( elem, animation.opts, prop, end, |
|
7978 animation.opts.specialEasing[ prop ] || animation.opts.easing ); |
|
7979 animation.tweens.push( tween ); |
|
7980 return tween; |
|
7981 }, |
|
7982 stop: function( gotoEnd ) { |
|
7983 var index = 0, |
|
7984 // if we are going to the end, we want to run all the tweens |
|
7985 // otherwise we skip this part |
|
7986 length = gotoEnd ? animation.tweens.length : 0; |
|
7987 if ( stopped ) { |
|
7988 return this; |
|
7989 } |
|
7990 stopped = true; |
|
7991 for ( ; index < length ; index++ ) { |
|
7992 animation.tweens[ index ].run( 1 ); |
|
7993 } |
|
7994 |
|
7995 // resolve when we played the last frame |
|
7996 // otherwise, reject |
|
7997 if ( gotoEnd ) { |
|
7998 deferred.resolveWith( elem, [ animation, gotoEnd ] ); |
|
7999 } else { |
|
8000 deferred.rejectWith( elem, [ animation, gotoEnd ] ); |
|
8001 } |
|
8002 return this; |
|
8003 } |
|
8004 }), |
|
8005 props = animation.props; |
|
8006 |
|
8007 propFilter( props, animation.opts.specialEasing ); |
|
8008 |
|
8009 for ( ; index < length ; index++ ) { |
|
8010 result = animationPrefilters[ index ].call( animation, elem, props, animation.opts ); |
|
8011 if ( result ) { |
|
8012 return result; |
|
8013 } |
|
8014 } |
|
8015 |
|
8016 jQuery.map( props, createTween, animation ); |
|
8017 |
|
8018 if ( jQuery.isFunction( animation.opts.start ) ) { |
|
8019 animation.opts.start.call( elem, animation ); |
|
8020 } |
|
8021 |
|
8022 jQuery.fx.timer( |
|
8023 jQuery.extend( tick, { |
|
8024 elem: elem, |
|
8025 anim: animation, |
|
8026 queue: animation.opts.queue |
|
8027 }) |
|
8028 ); |
|
8029 |
|
8030 // attach callbacks from options |
|
8031 return animation.progress( animation.opts.progress ) |
|
8032 .done( animation.opts.done, animation.opts.complete ) |
|
8033 .fail( animation.opts.fail ) |
|
8034 .always( animation.opts.always ); |
|
8035 } |
|
8036 |
|
8037 function propFilter( props, specialEasing ) { |
|
8038 var index, name, easing, value, hooks; |
|
8039 |
|
8040 // camelCase, specialEasing and expand cssHook pass |
|
8041 for ( index in props ) { |
|
8042 name = jQuery.camelCase( index ); |
|
8043 easing = specialEasing[ name ]; |
|
8044 value = props[ index ]; |
|
8045 if ( jQuery.isArray( value ) ) { |
|
8046 easing = value[ 1 ]; |
|
8047 value = props[ index ] = value[ 0 ]; |
|
8048 } |
|
8049 |
|
8050 if ( index !== name ) { |
|
8051 props[ name ] = value; |
|
8052 delete props[ index ]; |
|
8053 } |
|
8054 |
|
8055 hooks = jQuery.cssHooks[ name ]; |
|
8056 if ( hooks && "expand" in hooks ) { |
|
8057 value = hooks.expand( value ); |
|
8058 delete props[ name ]; |
|
8059 |
|
8060 // not quite $.extend, this wont overwrite keys already present. |
|
8061 // also - reusing 'index' from above because we have the correct "name" |
|
8062 for ( index in value ) { |
|
8063 if ( !( index in props ) ) { |
|
8064 props[ index ] = value[ index ]; |
|
8065 specialEasing[ index ] = easing; |
|
8066 } |
|
8067 } |
|
8068 } else { |
|
8069 specialEasing[ name ] = easing; |
|
8070 } |
|
8071 } |
|
8072 } |
|
8073 |
|
8074 jQuery.Animation = jQuery.extend( Animation, { |
|
8075 |
|
8076 tweener: function( props, callback ) { |
|
8077 if ( jQuery.isFunction( props ) ) { |
|
8078 callback = props; |
|
8079 props = [ "*" ]; |
|
8080 } else { |
|
8081 props = props.split(" "); |
|
8082 } |
|
8083 |
|
8084 var prop, |
|
8085 index = 0, |
|
8086 length = props.length; |
|
8087 |
|
8088 for ( ; index < length ; index++ ) { |
|
8089 prop = props[ index ]; |
|
8090 tweeners[ prop ] = tweeners[ prop ] || []; |
|
8091 tweeners[ prop ].unshift( callback ); |
|
8092 } |
|
8093 }, |
|
8094 |
|
8095 prefilter: function( callback, prepend ) { |
|
8096 if ( prepend ) { |
|
8097 animationPrefilters.unshift( callback ); |
|
8098 } else { |
|
8099 animationPrefilters.push( callback ); |
|
8100 } |
|
8101 } |
|
8102 }); |
|
8103 |
|
8104 function defaultPrefilter( elem, props, opts ) { |
|
8105 /* jshint validthis: true */ |
|
8106 var prop, value, toggle, tween, hooks, oldfire, |
|
8107 anim = this, |
|
8108 orig = {}, |
|
8109 style = elem.style, |
|
8110 hidden = elem.nodeType && isHidden( elem ), |
|
8111 dataShow = data_priv.get( elem, "fxshow" ); |
|
8112 |
|
8113 // handle queue: false promises |
|
8114 if ( !opts.queue ) { |
|
8115 hooks = jQuery._queueHooks( elem, "fx" ); |
|
8116 if ( hooks.unqueued == null ) { |
|
8117 hooks.unqueued = 0; |
|
8118 oldfire = hooks.empty.fire; |
|
8119 hooks.empty.fire = function() { |
|
8120 if ( !hooks.unqueued ) { |
|
8121 oldfire(); |
|
8122 } |
|
8123 }; |
|
8124 } |
|
8125 hooks.unqueued++; |
|
8126 |
|
8127 anim.always(function() { |
|
8128 // doing this makes sure that the complete handler will be called |
|
8129 // before this completes |
|
8130 anim.always(function() { |
|
8131 hooks.unqueued--; |
|
8132 if ( !jQuery.queue( elem, "fx" ).length ) { |
|
8133 hooks.empty.fire(); |
|
8134 } |
|
8135 }); |
|
8136 }); |
|
8137 } |
|
8138 |
|
8139 // height/width overflow pass |
|
8140 if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) { |
|
8141 // Make sure that nothing sneaks out |
|
8142 // Record all 3 overflow attributes because IE9-10 do not |
|
8143 // change the overflow attribute when overflowX and |
|
8144 // overflowY are set to the same value |
|
8145 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; |
|
8146 |
|
8147 // Set display property to inline-block for height/width |
|
8148 // animations on inline elements that are having width/height animated |
|
8149 if ( jQuery.css( elem, "display" ) === "inline" && |
|
8150 jQuery.css( elem, "float" ) === "none" ) { |
|
8151 |
|
8152 style.display = "inline-block"; |
|
8153 } |
|
8154 } |
|
8155 |
|
8156 if ( opts.overflow ) { |
|
8157 style.overflow = "hidden"; |
|
8158 anim.always(function() { |
|
8159 style.overflow = opts.overflow[ 0 ]; |
|
8160 style.overflowX = opts.overflow[ 1 ]; |
|
8161 style.overflowY = opts.overflow[ 2 ]; |
|
8162 }); |
|
8163 } |
|
8164 |
|
8165 |
|
8166 // show/hide pass |
|
8167 for ( prop in props ) { |
|
8168 value = props[ prop ]; |
|
8169 if ( rfxtypes.exec( value ) ) { |
|
8170 delete props[ prop ]; |
|
8171 toggle = toggle || value === "toggle"; |
|
8172 if ( value === ( hidden ? "hide" : "show" ) ) { |
|
8173 |
|
8174 // If there is dataShow left over from a stopped hide or show and we are going to proceed with show, we should pretend to be hidden |
|
8175 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { |
|
8176 hidden = true; |
|
8177 } else { |
|
8178 continue; |
|
8179 } |
|
8180 } |
|
8181 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop ); |
|
8182 } |
|
8183 } |
|
8184 |
|
8185 if ( !jQuery.isEmptyObject( orig ) ) { |
|
8186 if ( dataShow ) { |
|
8187 if ( "hidden" in dataShow ) { |
|
8188 hidden = dataShow.hidden; |
|
8189 } |
|
8190 } else { |
|
8191 dataShow = data_priv.access( elem, "fxshow", {} ); |
|
8192 } |
|
8193 |
|
8194 // store state if its toggle - enables .stop().toggle() to "reverse" |
|
8195 if ( toggle ) { |
|
8196 dataShow.hidden = !hidden; |
|
8197 } |
|
8198 if ( hidden ) { |
|
8199 jQuery( elem ).show(); |
|
8200 } else { |
|
8201 anim.done(function() { |
|
8202 jQuery( elem ).hide(); |
|
8203 }); |
|
8204 } |
|
8205 anim.done(function() { |
|
8206 var prop; |
|
8207 |
|
8208 data_priv.remove( elem, "fxshow" ); |
|
8209 for ( prop in orig ) { |
|
8210 jQuery.style( elem, prop, orig[ prop ] ); |
|
8211 } |
|
8212 }); |
|
8213 for ( prop in orig ) { |
|
8214 tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim ); |
|
8215 |
|
8216 if ( !( prop in dataShow ) ) { |
|
8217 dataShow[ prop ] = tween.start; |
|
8218 if ( hidden ) { |
|
8219 tween.end = tween.start; |
|
8220 tween.start = prop === "width" || prop === "height" ? 1 : 0; |
|
8221 } |
|
8222 } |
|
8223 } |
|
8224 } |
|
8225 } |
|
8226 |
|
8227 function Tween( elem, options, prop, end, easing ) { |
|
8228 return new Tween.prototype.init( elem, options, prop, end, easing ); |
|
8229 } |
|
8230 jQuery.Tween = Tween; |
|
8231 |
|
8232 Tween.prototype = { |
|
8233 constructor: Tween, |
|
8234 init: function( elem, options, prop, end, easing, unit ) { |
|
8235 this.elem = elem; |
|
8236 this.prop = prop; |
|
8237 this.easing = easing || "swing"; |
|
8238 this.options = options; |
|
8239 this.start = this.now = this.cur(); |
|
8240 this.end = end; |
|
8241 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" ); |
|
8242 }, |
|
8243 cur: function() { |
|
8244 var hooks = Tween.propHooks[ this.prop ]; |
|
8245 |
|
8246 return hooks && hooks.get ? |
|
8247 hooks.get( this ) : |
|
8248 Tween.propHooks._default.get( this ); |
|
8249 }, |
|
8250 run: function( percent ) { |
|
8251 var eased, |
|
8252 hooks = Tween.propHooks[ this.prop ]; |
|
8253 |
|
8254 if ( this.options.duration ) { |
|
8255 this.pos = eased = jQuery.easing[ this.easing ]( |
|
8256 percent, this.options.duration * percent, 0, 1, this.options.duration |
|
8257 ); |
|
8258 } else { |
|
8259 this.pos = eased = percent; |
|
8260 } |
|
8261 this.now = ( this.end - this.start ) * eased + this.start; |
|
8262 |
|
8263 if ( this.options.step ) { |
|
8264 this.options.step.call( this.elem, this.now, this ); |
|
8265 } |
|
8266 |
|
8267 if ( hooks && hooks.set ) { |
|
8268 hooks.set( this ); |
|
8269 } else { |
|
8270 Tween.propHooks._default.set( this ); |
|
8271 } |
|
8272 return this; |
|
8273 } |
|
8274 }; |
|
8275 |
|
8276 Tween.prototype.init.prototype = Tween.prototype; |
|
8277 |
|
8278 Tween.propHooks = { |
|
8279 _default: { |
|
8280 get: function( tween ) { |
|
8281 var result; |
|
8282 |
|
8283 if ( tween.elem[ tween.prop ] != null && |
|
8284 (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) { |
|
8285 return tween.elem[ tween.prop ]; |
|
8286 } |
|
8287 |
|
8288 // passing an empty string as a 3rd parameter to .css will automatically |
|
8289 // attempt a parseFloat and fallback to a string if the parse fails |
|
8290 // so, simple values such as "10px" are parsed to Float. |
|
8291 // complex values such as "rotate(1rad)" are returned as is. |
|
8292 result = jQuery.css( tween.elem, tween.prop, "" ); |
|
8293 // Empty strings, null, undefined and "auto" are converted to 0. |
|
8294 return !result || result === "auto" ? 0 : result; |
|
8295 }, |
|
8296 set: function( tween ) { |
|
8297 // use step hook for back compat - use cssHook if its there - use .style if its |
|
8298 // available and use plain properties where available |
|
8299 if ( jQuery.fx.step[ tween.prop ] ) { |
|
8300 jQuery.fx.step[ tween.prop ]( tween ); |
|
8301 } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) { |
|
8302 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit ); |
|
8303 } else { |
|
8304 tween.elem[ tween.prop ] = tween.now; |
|
8305 } |
|
8306 } |
|
8307 } |
|
8308 }; |
|
8309 |
|
8310 // Support: IE9 |
|
8311 // Panic based approach to setting things on disconnected nodes |
|
8312 |
|
8313 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { |
|
8314 set: function( tween ) { |
|
8315 if ( tween.elem.nodeType && tween.elem.parentNode ) { |
|
8316 tween.elem[ tween.prop ] = tween.now; |
|
8317 } |
|
8318 } |
|
8319 }; |
|
8320 |
|
8321 jQuery.each([ "toggle", "show", "hide" ], function( i, name ) { |
|
8322 var cssFn = jQuery.fn[ name ]; |
|
8323 jQuery.fn[ name ] = function( speed, easing, callback ) { |
|
8324 return speed == null || typeof speed === "boolean" ? |
|
8325 cssFn.apply( this, arguments ) : |
|
8326 this.animate( genFx( name, true ), speed, easing, callback ); |
|
8327 }; |
|
8328 }); |
|
8329 |
|
8330 jQuery.fn.extend({ |
|
8331 fadeTo: function( speed, to, easing, callback ) { |
|
8332 |
|
8333 // show any hidden elements after setting opacity to 0 |
|
8334 return this.filter( isHidden ).css( "opacity", 0 ).show() |
|
8335 |
|
8336 // animate to the value specified |
|
8337 .end().animate({ opacity: to }, speed, easing, callback ); |
|
8338 }, |
|
8339 animate: function( prop, speed, easing, callback ) { |
|
8340 var empty = jQuery.isEmptyObject( prop ), |
|
8341 optall = jQuery.speed( speed, easing, callback ), |
|
8342 doAnimation = function() { |
|
8343 // Operate on a copy of prop so per-property easing won't be lost |
|
8344 var anim = Animation( this, jQuery.extend( {}, prop ), optall ); |
|
8345 |
|
8346 // Empty animations, or finishing resolves immediately |
|
8347 if ( empty || data_priv.get( this, "finish" ) ) { |
|
8348 anim.stop( true ); |
|
8349 } |
|
8350 }; |
|
8351 doAnimation.finish = doAnimation; |
|
8352 |
|
8353 return empty || optall.queue === false ? |
|
8354 this.each( doAnimation ) : |
|
8355 this.queue( optall.queue, doAnimation ); |
|
8356 }, |
|
8357 stop: function( type, clearQueue, gotoEnd ) { |
|
8358 var stopQueue = function( hooks ) { |
|
8359 var stop = hooks.stop; |
|
8360 delete hooks.stop; |
|
8361 stop( gotoEnd ); |
|
8362 }; |
|
8363 |
|
8364 if ( typeof type !== "string" ) { |
|
8365 gotoEnd = clearQueue; |
|
8366 clearQueue = type; |
|
8367 type = undefined; |
|
8368 } |
|
8369 if ( clearQueue && type !== false ) { |
|
8370 this.queue( type || "fx", [] ); |
|
8371 } |
|
8372 |
|
8373 return this.each(function() { |
|
8374 var dequeue = true, |
|
8375 index = type != null && type + "queueHooks", |
|
8376 timers = jQuery.timers, |
|
8377 data = data_priv.get( this ); |
|
8378 |
|
8379 if ( index ) { |
|
8380 if ( data[ index ] && data[ index ].stop ) { |
|
8381 stopQueue( data[ index ] ); |
|
8382 } |
|
8383 } else { |
|
8384 for ( index in data ) { |
|
8385 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) { |
|
8386 stopQueue( data[ index ] ); |
|
8387 } |
|
8388 } |
|
8389 } |
|
8390 |
|
8391 for ( index = timers.length; index--; ) { |
|
8392 if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) { |
|
8393 timers[ index ].anim.stop( gotoEnd ); |
|
8394 dequeue = false; |
|
8395 timers.splice( index, 1 ); |
|
8396 } |
|
8397 } |
|
8398 |
|
8399 // start the next in the queue if the last step wasn't forced |
|
8400 // timers currently will call their complete callbacks, which will dequeue |
|
8401 // but only if they were gotoEnd |
|
8402 if ( dequeue || !gotoEnd ) { |
|
8403 jQuery.dequeue( this, type ); |
|
8404 } |
|
8405 }); |
|
8406 }, |
|
8407 finish: function( type ) { |
|
8408 if ( type !== false ) { |
|
8409 type = type || "fx"; |
|
8410 } |
|
8411 return this.each(function() { |
|
8412 var index, |
|
8413 data = data_priv.get( this ), |
|
8414 queue = data[ type + "queue" ], |
|
8415 hooks = data[ type + "queueHooks" ], |
|
8416 timers = jQuery.timers, |
|
8417 length = queue ? queue.length : 0; |
|
8418 |
|
8419 // enable finishing flag on private data |
|
8420 data.finish = true; |
|
8421 |
|
8422 // empty the queue first |
|
8423 jQuery.queue( this, type, [] ); |
|
8424 |
|
8425 if ( hooks && hooks.stop ) { |
|
8426 hooks.stop.call( this, true ); |
|
8427 } |
|
8428 |
|
8429 // look for any active animations, and finish them |
|
8430 for ( index = timers.length; index--; ) { |
|
8431 if ( timers[ index ].elem === this && timers[ index ].queue === type ) { |
|
8432 timers[ index ].anim.stop( true ); |
|
8433 timers.splice( index, 1 ); |
|
8434 } |
|
8435 } |
|
8436 |
|
8437 // look for any animations in the old queue and finish them |
|
8438 for ( index = 0; index < length; index++ ) { |
|
8439 if ( queue[ index ] && queue[ index ].finish ) { |
|
8440 queue[ index ].finish.call( this ); |
|
8441 } |
|
8442 } |
|
8443 |
|
8444 // turn off finishing flag |
|
8445 delete data.finish; |
|
8446 }); |
|
8447 } |
|
8448 }); |
|
8449 |
|
8450 // Generate parameters to create a standard animation |
|
8451 function genFx( type, includeWidth ) { |
|
8452 var which, |
|
8453 attrs = { height: type }, |
|
8454 i = 0; |
|
8455 |
|
8456 // if we include width, step value is 1 to do all cssExpand values, |
|
8457 // if we don't include width, step value is 2 to skip over Left and Right |
|
8458 includeWidth = includeWidth? 1 : 0; |
|
8459 for( ; i < 4 ; i += 2 - includeWidth ) { |
|
8460 which = cssExpand[ i ]; |
|
8461 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type; |
|
8462 } |
|
8463 |
|
8464 if ( includeWidth ) { |
|
8465 attrs.opacity = attrs.width = type; |
|
8466 } |
|
8467 |
|
8468 return attrs; |
|
8469 } |
|
8470 |
|
8471 // Generate shortcuts for custom animations |
|
8472 jQuery.each({ |
|
8473 slideDown: genFx("show"), |
|
8474 slideUp: genFx("hide"), |
|
8475 slideToggle: genFx("toggle"), |
|
8476 fadeIn: { opacity: "show" }, |
|
8477 fadeOut: { opacity: "hide" }, |
|
8478 fadeToggle: { opacity: "toggle" } |
|
8479 }, function( name, props ) { |
|
8480 jQuery.fn[ name ] = function( speed, easing, callback ) { |
|
8481 return this.animate( props, speed, easing, callback ); |
|
8482 }; |
|
8483 }); |
|
8484 |
|
8485 jQuery.speed = function( speed, easing, fn ) { |
|
8486 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { |
|
8487 complete: fn || !fn && easing || |
|
8488 jQuery.isFunction( speed ) && speed, |
|
8489 duration: speed, |
|
8490 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing |
|
8491 }; |
|
8492 |
|
8493 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : |
|
8494 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default; |
|
8495 |
|
8496 // normalize opt.queue - true/undefined/null -> "fx" |
|
8497 if ( opt.queue == null || opt.queue === true ) { |
|
8498 opt.queue = "fx"; |
|
8499 } |
|
8500 |
|
8501 // Queueing |
|
8502 opt.old = opt.complete; |
|
8503 |
|
8504 opt.complete = function() { |
|
8505 if ( jQuery.isFunction( opt.old ) ) { |
|
8506 opt.old.call( this ); |
|
8507 } |
|
8508 |
|
8509 if ( opt.queue ) { |
|
8510 jQuery.dequeue( this, opt.queue ); |
|
8511 } |
|
8512 }; |
|
8513 |
|
8514 return opt; |
|
8515 }; |
|
8516 |
|
8517 jQuery.easing = { |
|
8518 linear: function( p ) { |
|
8519 return p; |
|
8520 }, |
|
8521 swing: function( p ) { |
|
8522 return 0.5 - Math.cos( p*Math.PI ) / 2; |
|
8523 } |
|
8524 }; |
|
8525 |
|
8526 jQuery.timers = []; |
|
8527 jQuery.fx = Tween.prototype.init; |
|
8528 jQuery.fx.tick = function() { |
|
8529 var timer, |
|
8530 timers = jQuery.timers, |
|
8531 i = 0; |
|
8532 |
|
8533 fxNow = jQuery.now(); |
|
8534 |
|
8535 for ( ; i < timers.length; i++ ) { |
|
8536 timer = timers[ i ]; |
|
8537 // Checks the timer has not already been removed |
|
8538 if ( !timer() && timers[ i ] === timer ) { |
|
8539 timers.splice( i--, 1 ); |
|
8540 } |
|
8541 } |
|
8542 |
|
8543 if ( !timers.length ) { |
|
8544 jQuery.fx.stop(); |
|
8545 } |
|
8546 fxNow = undefined; |
|
8547 }; |
|
8548 |
|
8549 jQuery.fx.timer = function( timer ) { |
|
8550 if ( timer() && jQuery.timers.push( timer ) ) { |
|
8551 jQuery.fx.start(); |
|
8552 } |
|
8553 }; |
|
8554 |
|
8555 jQuery.fx.interval = 13; |
|
8556 |
|
8557 jQuery.fx.start = function() { |
|
8558 if ( !timerId ) { |
|
8559 timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval ); |
|
8560 } |
|
8561 }; |
|
8562 |
|
8563 jQuery.fx.stop = function() { |
|
8564 clearInterval( timerId ); |
|
8565 timerId = null; |
|
8566 }; |
|
8567 |
|
8568 jQuery.fx.speeds = { |
|
8569 slow: 600, |
|
8570 fast: 200, |
|
8571 // Default speed |
|
8572 _default: 400 |
|
8573 }; |
|
8574 |
|
8575 // Back Compat <1.8 extension point |
|
8576 jQuery.fx.step = {}; |
|
8577 |
|
8578 if ( jQuery.expr && jQuery.expr.filters ) { |
|
8579 jQuery.expr.filters.animated = function( elem ) { |
|
8580 return jQuery.grep(jQuery.timers, function( fn ) { |
|
8581 return elem === fn.elem; |
|
8582 }).length; |
|
8583 }; |
|
8584 } |
|
8585 jQuery.fn.offset = function( options ) { |
|
8586 if ( arguments.length ) { |
|
8587 return options === undefined ? |
|
8588 this : |
|
8589 this.each(function( i ) { |
|
8590 jQuery.offset.setOffset( this, options, i ); |
|
8591 }); |
|
8592 } |
|
8593 |
|
8594 var docElem, win, |
|
8595 elem = this[ 0 ], |
|
8596 box = { top: 0, left: 0 }, |
|
8597 doc = elem && elem.ownerDocument; |
|
8598 |
|
8599 if ( !doc ) { |
|
8600 return; |
|
8601 } |
|
8602 |
|
8603 docElem = doc.documentElement; |
|
8604 |
|
8605 // Make sure it's not a disconnected DOM node |
|
8606 if ( !jQuery.contains( docElem, elem ) ) { |
|
8607 return box; |
|
8608 } |
|
8609 |
|
8610 // If we don't have gBCR, just use 0,0 rather than error |
|
8611 // BlackBerry 5, iOS 3 (original iPhone) |
|
8612 if ( typeof elem.getBoundingClientRect !== core_strundefined ) { |
|
8613 box = elem.getBoundingClientRect(); |
|
8614 } |
|
8615 win = getWindow( doc ); |
|
8616 return { |
|
8617 top: box.top + win.pageYOffset - docElem.clientTop, |
|
8618 left: box.left + win.pageXOffset - docElem.clientLeft |
|
8619 }; |
|
8620 }; |
|
8621 |
|
8622 jQuery.offset = { |
8831 jQuery.offset = { |
8623 |
|
8624 setOffset: function( elem, options, i ) { |
8832 setOffset: function( elem, options, i ) { |
8625 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition, |
8833 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition, |
8626 position = jQuery.css( elem, "position" ), |
8834 position = jQuery.css( elem, "position" ), |
8627 curElem = jQuery( elem ), |
8835 curElem = jQuery( elem ), |
8628 props = {}; |
8836 props = {}; |