3 Copyright © 2018 Basecamp, LLC
6 (function(){var t
=this;(function(){(function(){this.Turbolinks
={supported:function(){return null!=window
.history
.pushState
&&null!=window
.requestAnimationFrame
&&null!=window
.addEventListener
}(),visit:function(t
,r
){return e
.controller
.visit(t
,r
)},clearCache:function(){return e
.controller
.clearCache()},setProgressBarDelay:function(t
){return e
.controller
.setProgressBarDelay(t
)}}}).call(this)}).call(t
);var e
=t
.Turbolinks
;(function(){(function(){var t
,r
,n
,o
=[].slice
;e
.copyObject=function(t
){var e
,r
,n
;r
={};for(e
in t
)n
=t
[e
],r
[e
]=n
;return r
},e
.closest=function(e
,r
){return t
.call(e
,r
)},t=function(){var t
,e
;return t
=document
.documentElement
,null!=(e
=t
.closest
)?e:function(t
){var e
;for(e
=this;e
;){if(e
.nodeType
===Node
.ELEMENT_NODE
&&r
.call(e
,t
))return e
;e
=e
.parentNode
}}}(),e
.defer=function(t
){return setTimeout(t
,1)},e
.throttle=function(t
){var e
;return e
=null,function(){var r
;return r
=1<=arguments
.length
?o
.call(arguments
,0):[],null!=e
?e:e
=requestAnimationFrame(function(n
){return function(){return e
=null,t
.apply(n
,r
)}}(this))}},e
.dispatch=function(t
,e
){var r
,o
,i
,s
,a
,u
;return a
=null!=e
?e:{},u
=a
.target
,r
=a
.cancelable
,o
=a
.data
,i
=document
.createEvent("Events"),i
.initEvent(t
,!0,r
===!0),i
.data
=null!=o
?o:{},i
.cancelable
&&!n
&&(s
=i
.preventDefault
,i
.preventDefault=function(){return this.defaultPrevented
||Object
.defineProperty(this,"defaultPrevented",{get:function(){return!0}}),s
.call(this)}),(null!=u
?u:document
).dispatchEvent(i
),i
},n=function(){var t
;return t
=document
.createEvent("Events"),t
.initEvent("test",!0,!0),t
.preventDefault(),t
.defaultPrevented
}(),e
.match=function(t
,e
){return r
.call(t
,e
)},r=function(){var t
,e
,r
,n
;return t
=document
.documentElement
,null!=(e
=null!=(r
=null!=(n
=t
.matchesSelector
)?n:t
.webkitMatchesSelector
)?r:t
.msMatchesSelector
)?e:t
.mozMatchesSelector
}(),e
.uuid=function(){var t
,e
,r
;for(r
="",t
=e
=1;36>=e
;t
=++e
)r
+=9===t
||14===t
||19===t
||24===t
?"-":15===t
?"4":20===t
?(Math
.floor(4*Math
.random())+8).toString(16):Math
.floor(15*Math
.random()).toString(16);return r
}}).call(this),function(){e
.Location=function(){function t(t
){var e
,r
;null==t
&&(t
=""),r
=document
.createElement("a"),r
.href
=t
.toString(),this.absoluteURL
=r
.href
,e
=r
.hash
.length
,2>e
?this.requestURL
=this.absoluteURL:(this.requestURL
=this.absoluteURL
.slice(0,-e
),this.anchor
=r
.hash
.slice(1))}var e
,r
,n
,o
;return t
.wrap=function(t
){return t
instanceof this?t:new this(t
)},t
.prototype.getOrigin=function(){return this.absoluteURL
.split("/",3).join("/")},t
.prototype.getPath=function(){var t
,e
;return null!=(t
=null!=(e
=this.requestURL
.match(/\/\/[^\/]*(\/[^?;]*)/))?e
[1]:void 0)?t:"/"},t
.prototype.getPathComponents=function(){return this.getPath().split("/").slice(1)},t
.prototype.getLastPathComponent=function(){return this.getPathComponents().slice(-1)[0]},t
.prototype.getExtension=function(){var t
,e
;return null!=(t
=null!=(e
=this.getLastPathComponent().match(/\.[^.]*$/))?e
[0]:void 0)?t:""},t
.prototype.isHTML=function(){return this.getExtension().match(/^(?:|\.(?:htm|html|xhtml))$/)},t
.prototype.isPrefixedBy=function(t
){var e
;return e
=r(t
),this.isEqualTo(t
)||o(this.absoluteURL
,e
)},t
.prototype.isEqualTo=function(t
){return this.absoluteURL
===(null!=t
?t
.absoluteURL:void 0)},t
.prototype.toCacheKey=function(){return this.requestURL
},t
.prototype.toJSON=function(){return this.absoluteURL
},t
.prototype.toString=function(){return this.absoluteURL
},t
.prototype.valueOf=function(){return this.absoluteURL
},r=function(t
){return e(t
.getOrigin()+t
.getPath())},e=function(t
){return n(t
,"/")?t:t
+"/"},o=function(t
,e
){return t
.slice(0,e
.length
)===e
},n=function(t
,e
){return t
.slice(-e
.length
)===e
},t
}()}.call(this),function(){var t=function(t
,e
){return function(){return t
.apply(e
,arguments
)}};e
.HttpRequest=function(){function r(r
,n
,o
){this.delegate
=r
,this.requestCanceled
=t(this.requestCanceled
,this),this.requestTimedOut
=t(this.requestTimedOut
,this),this.requestFailed
=t(this.requestFailed
,this),this.requestLoaded
=t(this.requestLoaded
,this),this.requestProgressed
=t(this.requestProgressed
,this),this.url
=e
.Location
.wrap(n
).requestURL
,this.referrer
=e
.Location
.wrap(o
).absoluteURL
,this.createXHR()}return r
.NETWORK_FAILURE
=0,r
.TIMEOUT_FAILURE
=-1,r
.timeout
=60,r
.prototype.send=function(){var t
;return this.xhr
&&!this.sent
?(this.notifyApplicationBeforeRequestStart(),this.setProgress(0),this.xhr
.send(),this.sent
=!0,"function"==typeof(t
=this.delegate
).requestStarted
?t
.requestStarted():void 0):void 0},r
.prototype.cancel=function(){return this.xhr
&&this.sent
?this.xhr
.abort():void 0},r
.prototype.requestProgressed=function(t
){return t
.lengthComputable
?this.setProgress(t
.loaded
/t
.total
):void 0},r
.prototype.requestLoaded=function(){return this.endRequest(function(t
){return function(){var e
;return 200<=(e
=t
.xhr
.status
)&&300>e
?t
.delegate
.requestCompletedWithResponse(t
.xhr
.responseText
,t
.xhr
.getResponseHeader("Turbolinks-Location")):(t
.failed
=!0,t
.delegate
.requestFailedWithStatusCode(t
.xhr
.status
,t
.xhr
.responseText
))}}(this))},r
.prototype.requestFailed=function(){return this.endRequest(function(t
){return function(){return t
.failed
=!0,t
.delegate
.requestFailedWithStatusCode(t
.constructor.NETWORK_FAILURE
)}}(this))},r
.prototype.requestTimedOut=function(){return this.endRequest(function(t
){return function(){return t
.failed
=!0,t
.delegate
.requestFailedWithStatusCode(t
.constructor.TIMEOUT_FAILURE
)}}(this))},r
.prototype.requestCanceled=function(){return this.endRequest()},r
.prototype.notifyApplicationBeforeRequestStart=function(){return e
.dispatch("turbolinks:request-start",{data:{url:this.url
,xhr:this.xhr
}})},r
.prototype.notifyApplicationAfterRequestEnd=function(){return e
.dispatch("turbolinks:request-end",{data:{url:this.url
,xhr:this.xhr
}})},r
.prototype.createXHR=function(){return this.xhr
=new XMLHttpRequest
,this.xhr
.open("GET",this.url
,!0),this.xhr
.timeout
=1e3
*this.constructor.timeout
,this.xhr
.setRequestHeader("Accept","text/html, application/xhtml+xml"),this.xhr
.setRequestHeader("Turbolinks-Referrer",this.referrer
),this.xhr
.onprogress
=this.requestProgressed
,this.xhr
.onload
=this.requestLoaded
,this.xhr
.onerror
=this.requestFailed
,this.xhr
.ontimeout
=this.requestTimedOut
,this.xhr
.onabort
=this.requestCanceled
},r
.prototype.endRequest=function(t
){return this.xhr
?(this.notifyApplicationAfterRequestEnd(),null!=t
&&t
.call(this),this.destroy()):void 0},r
.prototype.setProgress=function(t
){var e
;return this.progress
=t
,"function"==typeof(e
=this.delegate
).requestProgressed
?e
.requestProgressed(this.progress
):void 0},r
.prototype.destroy=function(){var t
;return this.setProgress(1),"function"==typeof(t
=this.delegate
).requestFinished
&&t
.requestFinished(),this.delegate
=null,this.xhr
=null},r
}()}.call(this),function(){var t=function(t
,e
){return function(){return t
.apply(e
,arguments
)}};e
.ProgressBar=function(){function e(){this.trickle
=t(this.trickle
,this),this.stylesheetElement
=this.createStylesheetElement(),this.progressElement
=this.createProgressElement()}var r
;return r
=300,e
.defaultCSS
=".turbolinks-progress-bar {\n position: fixed;\n display: block;\n top: 0;\n left: 0;\n height: 3px;\n background: #0076ff;\n z-index: 9999;\n transition: width "+r
+"ms ease-out, opacity "+r
/2+"ms "+r
/2+"ms ease-in;\n transform: translate3d(0, 0, 0);\n}",e
.prototype.show=function(){return this.visible
?void 0:(this.visible
=!0,this.installStylesheetElement(),this.installProgressElement(),this.startTrickling())},e
.prototype.hide=function(){return this.visible
&&!this.hiding
?(this.hiding
=!0,this.fadeProgressElement(function(t
){return function(){return t
.uninstallProgressElement(),t
.stopTrickling(),t
.visible
=!1,t
.hiding
=!1}}(this))):void 0},e
.prototype.setValue=function(t
){return this.value
=t
,this.refresh()},e
.prototype.installStylesheetElement=function(){return document
.head
.insertBefore(this.stylesheetElement
,document
.head
.firstChild
)},e
.prototype.installProgressElement=function(){return this.progressElement
.style
.width
=0,this.progressElement
.style
.opacity
=1,document
.documentElement
.insertBefore(this.progressElement
,document
.body
),this.refresh()},e
.prototype.fadeProgressElement=function(t
){return this.progressElement
.style
.opacity
=0,setTimeout(t
,1.5*r
)},e
.prototype.uninstallProgressElement=function(){return this.progressElement
.parentNode
?document
.documentElement
.removeChild(this.progressElement
):void 0},e
.prototype.startTrickling=function(){return null!=this.trickleInterval
?this.trickleInterval:this.trickleInterval
=setInterval(this.trickle
,r
)},e
.prototype.stopTrickling=function(){return clearInterval(this.trickleInterval
),this.trickleInterval
=null},e
.prototype.trickle=function(){return this.setValue(this.value
+Math
.random()/100)},e
.prototype.refresh=function(){return requestAnimationFrame(function(t
){return function(){return t
.progressElement
.style
.width
=10+90*t
.value
+"%"}}(this))},e
.prototype.createStylesheetElement=function(){var t
;return t
=document
.createElement("style"),t
.type
="text/css",t
.textContent
=this.constructor.defaultCSS
,t
},e
.prototype.createProgressElement=function(){var t
;return t
=document
.createElement("div"),t
.className
="turbolinks-progress-bar",t
},e
}()}.call(this),function(){var t=function(t
,e
){return function(){return t
.apply(e
,arguments
)}};e
.BrowserAdapter=function(){function r(r
){this.controller
=r
,this.showProgressBar
=t(this.showProgressBar
,this),this.progressBar
=new e
.ProgressBar
}var n
,o
,i
;return i
=e
.HttpRequest
,n
=i
.NETWORK_FAILURE
,o
=i
.TIMEOUT_FAILURE
,r
.prototype.visitProposedToLocationWithAction=function(t
,e
){return this.controller
.startVisitToLocationWithAction(t
,e
)},r
.prototype.visitStarted=function(t
){return t
.issueRequest(),t
.changeHistory(),t
.loadCachedSnapshot()},r
.prototype.visitRequestStarted=function(t
){return this.progressBar
.setValue(0),t
.hasCachedSnapshot()||"restore"!==t
.action
?this.showProgressBarAfterDelay():this.showProgressBar()},r
.prototype.visitRequestProgressed=function(t
){return this.progressBar
.setValue(t
.progress
)},r
.prototype.visitRequestCompleted=function(t
){return t
.loadResponse()},r
.prototype.visitRequestFailedWithStatusCode=function(t
,e
){switch(e
){case n:case o:return this.reload();default:return t
.loadResponse()}},r
.prototype.visitRequestFinished=function(t
){return this.hideProgressBar()},r
.prototype.visitCompleted=function(t
){return t
.followRedirect()},r
.prototype.pageInvalidated=function(){return this.reload()},r
.prototype.showProgressBarAfterDelay=function(){return this.progressBarTimeout
=setTimeout(this.showProgressBar
,this.controller
.progressBarDelay
)},r
.prototype.showProgressBar=function(){return this.progressBar
.show()},r
.prototype.hideProgressBar=function(){return this.progressBar
.hide(),clearTimeout(this.progressBarTimeout
)},r
.prototype.reload=function(){return window
.location
.reload()},r
}()}.call(this),function(){var t=function(t
,e
){return function(){return t
.apply(e
,arguments
)}};e
.History=function(){function r(e
){this.delegate
=e
,this.onPageLoad
=t(this.onPageLoad
,this),this.onPopState
=t(this.onPopState
,this)}return r
.prototype.start=function(){return this.started
?void 0:(addEventListener("popstate",this.onPopState
,!1),addEventListener("load",this.onPageLoad
,!1),this.started
=!0)},r
.prototype.stop=function(){return this.started
?(removeEventListener("popstate",this.onPopState
,!1),removeEventListener("load",this.onPageLoad
,!1),this.started
=!1):void 0},r
.prototype.push=function(t
,r
){return t
=e
.Location
.wrap(t
),this.update("push",t
,r
)},r
.prototype.replace=function(t
,r
){return t
=e
.Location
.wrap(t
),this.update("replace",t
,r
)},r
.prototype.onPopState=function(t
){var r
,n
,o
,i
;return this.shouldHandlePopState()&&(i
=null!=(n
=t
.state
)?n
.turbolinks:void 0)?(r
=e
.Location
.wrap(window
.location
),o
=i
.restorationIdentifier
,this.delegate
.historyPoppedToLocationWithRestorationIdentifier(r
,o
)):void 0},r
.prototype.onPageLoad=function(t
){return e
.defer(function(t
){return function(){return t
.pageLoaded
=!0}}(this))},r
.prototype.shouldHandlePopState=function(){return this.pageIsLoaded()},r
.prototype.pageIsLoaded=function(){return this.pageLoaded
||"complete"===document
.readyState
},r
.prototype.update=function(t
,e
,r
){var n
;return n
={turbolinks:{restorationIdentifier:r
}},history
[t
+"State"](n
,null,e
)},r
}()}.call(this),function(){e
.HeadDetails=function(){function t(t
){var e
,r
,n
,s
,a
,u
;for(this.elements
={},n
=0,a
=t
.length
;a
>n
;n
++)u
=t
[n
],u
.nodeType
===Node
.ELEMENT_NODE
&&(s
=u
.outerHTML
,r
=null!=(e
=this.elements
)[s
]?e
[s
]:e
[s
]={type:i(u
),tracked:o(u
),elements:[]},r
.elements
.push(u
))}var e
,r
,n
,o
,i
;return t
.fromHeadElement=function(t
){var e
;return new this(null!=(e
=null!=t
?t
.childNodes:void 0)?e:[])},t
.prototype.hasElementWithKey=function(t
){return t
in this.elements
},t
.prototype.getTrackedElementSignature=function(){var t
,e
;return function(){var r
,n
;r
=this.elements
,n
=[];for(t
in r
)e
=r
[t
].tracked
,e
&&n
.push(t
);return n
}.call(this).join("")},t
.prototype.getScriptElementsNotInDetails=function(t
){return this.getElementsMatchingTypeNotInDetails("script",t
)},t
.prototype.getStylesheetElementsNotInDetails=function(t
){return this.getElementsMatchingTypeNotInDetails("stylesheet",t
)},t
.prototype.getElementsMatchingTypeNotInDetails=function(t
,e
){var r
,n
,o
,i
,s
,a
;o
=this.elements
,s
=[];for(n
in o
)i
=o
[n
],a
=i
.type
,r
=i
.elements
,a
!==t
||e
.hasElementWithKey(n
)||s
.push(r
[0]);return s
},t
.prototype.getProvisionalElements=function(){var t
,e
,r
,n
,o
,i
,s
;r
=[],n
=this.elements
;for(e
in n
)o
=n
[e
],s
=o
.type
,i
=o
.tracked
,t
=o
.elements
,null!=s
||i
?t
.length
>1&&r
.push
.apply(r
,t
.slice(1)):r
.push
.apply(r
,t
);return r
},t
.prototype.getMetaValue=function(t
){var e
;return null!=(e
=this.findMetaElementByName(t
))?e
.getAttribute("content"):void 0},t
.prototype.findMetaElementByName=function(t
){var r
,n
,o
,i
;r
=void 0,i
=this.elements
;for(o
in i
)n
=i
[o
].elements
,e(n
[0],t
)&&(r
=n
[0]);return r
},i=function(t
){return r(t
)?"script":n(t
)?"stylesheet":void 0},o=function(t
){return"reload"===t
.getAttribute("data-turbolinks-track")},r=function(t
){var e
;return e
=t
.tagName
.toLowerCase(),"script"===e
},n=function(t
){var e
;return e
=t
.tagName
.toLowerCase(),"style"===e
||"link"===e
&&"stylesheet"===t
.getAttribute("rel")},e=function(t
,e
){var r
;return r
=t
.tagName
.toLowerCase(),"meta"===r
&&t
.getAttribute("name")===e
},t
}()}.call(this),function(){e
.Snapshot=function(){function t(t
,e
){this.headDetails
=t
,this.bodyElement
=e
}return t
.wrap=function(t
){return t
instanceof this?t:"string"==typeof t
?this.fromHTMLString(t
):this.fromHTMLElement(t
)},t
.fromHTMLString=function(t
){var e
;return e
=document
.createElement("html"),e
.innerHTML
=t
,this.fromHTMLElement(e
)},t
.fromHTMLElement=function(t
){var r
,n
,o
,i
;return o
=t
.querySelector("head"),r
=null!=(i
=t
.querySelector("body"))?i:document
.createElement("body"),n
=e
.HeadDetails
.fromHeadElement(o
),new this(n
,r
)},t
.prototype.clone=function(){return new this.constructor(this.headDetails
,this.bodyElement
.cloneNode(!0))},t
.prototype.getRootLocation=function(){var t
,r
;return r
=null!=(t
=this.getSetting("root"))?t:"/",new e
.Location(r
)},t
.prototype.getCacheControlValue=function(){return this.getSetting("cache-control")},t
.prototype.getElementForAnchor=function(t
){try{return this.bodyElement
.querySelector("[id='"+t
+"'], a[name='"+t
+"']")}catch(e
){}},t
.prototype.getPermanentElements=function(){return this.bodyElement
.querySelectorAll("[id][data-turbolinks-permanent]")},t
.prototype.getPermanentElementById=function(t
){return this.bodyElement
.querySelector("#"+t
+"[data-turbolinks-permanent]")},t
.prototype.getPermanentElementsPresentInSnapshot=function(t
){var e
,r
,n
,o
,i
;for(o
=this.getPermanentElements(),i
=[],r
=0,n
=o
.length
;n
>r
;r
++)e
=o
[r
],t
.getPermanentElementById(e
.id
)&&i
.push(e
);return i
},t
.prototype.findFirstAutofocusableElement=function(){return this.bodyElement
.querySelector("[autofocus]")},t
.prototype.hasAnchor=function(t
){return null!=this.getElementForAnchor(t
)},t
.prototype.isPreviewable=function(){return"no-preview"!==this.getCacheControlValue()},t
.prototype.isCacheable=function(){return"no-cache"!==this.getCacheControlValue()},t
.prototype.isVisitable=function(){return"reload"!==this.getSetting("visit-control")},t
.prototype.getSetting=function(t
){return this.headDetails
.getMetaValue("turbolinks-"+t
)},t
}()}.call(this),function(){var t
=[].slice
;e
.Renderer=function(){function e(){}var r
;return e
.render=function(){var e
,r
,n
,o
;return n
=arguments
[0],r
=arguments
[1],e
=3<=arguments
.length
?t
.call(arguments
,2):[],o=function(t
,e
,r
){r
.prototype=t
.prototype;var n
=new r
,o
=t
.apply(n
,e
);return Object(o
)===o
?o:n
}(this,e
,function(){}),o
.delegate
=n
,o
.render(r
),o
},e
.prototype.renderView=function(t
){return this.delegate
.viewWillRender(this.newBody
),t(),this.delegate
.viewRendered(this.newBody
)},e
.prototype.invalidateView=function(){return this.delegate
.viewInvalidated()},e
.prototype.createScriptElement=function(t
){var e
;return"false"===t
.getAttribute("data-turbolinks-eval")?t:(e
=document
.createElement("script"),e
.textContent
=t
.textContent
,e
.async
=!1,r(e
,t
),e
)},r=function(t
,e
){var r
,n
,o
,i
,s
,a
,u
;for(i
=e
.attributes
,a
=[],r
=0,n
=i
.length
;n
>r
;r
++)s
=i
[r
],o
=s
.name
,u
=s
.value
,a
.push(t
.setAttribute(o
,u
));return a
},e
}()}.call(this),function(){var t
,r
,n=function(t
,e
){function r(){this.constructor=t
}for(var n
in e
)o
.call(e
,n
)&&(t
[n
]=e
[n
]);return r
.prototype=e
.prototype,t
.prototype=new r
,t
.__super__
=e
.prototype,t
},o
={}.hasOwnProperty
;e
.SnapshotRenderer=function(e
){function o(t
,e
,r
){this.currentSnapshot
=t
,this.newSnapshot
=e
,this.isPreview
=r
,this.currentHeadDetails
=this.currentSnapshot
.headDetails
,this.newHeadDetails
=this.newSnapshot
.headDetails
,this.currentBody
=this.currentSnapshot
.bodyElement
,this.newBody
=this.newSnapshot
.bodyElement
}return n(o
,e
),o
.prototype.render=function(t
){return this.shouldRender()?(this.mergeHead(),this.renderView(function(e
){return function(){return e
.replaceBody(),e
.isPreview
||e
.focusFirstAutofocusableElement(),t()}}(this))):this.invalidateView()},o
.prototype.mergeHead=function(){return this.copyNewHeadStylesheetElements(),this.copyNewHeadScriptElements(),this.removeCurrentHeadProvisionalElements(),this.copyNewHeadProvisionalElements()},o
.prototype.replaceBody=function(){var t
;return t
=this.relocateCurrentBodyPermanentElements(),this.activateNewBodyScriptElements(),this.assignNewBody(),this.replacePlaceholderElementsWithClonedPermanentElements(t
)},o
.prototype.shouldRender=function(){return this.newSnapshot
.isVisitable()&&this.trackedElementsAreIdentical()},o
.prototype.trackedElementsAreIdentical=function(){return this.currentHeadDetails
.getTrackedElementSignature()===this.newHeadDetails
.getTrackedElementSignature()},o
.prototype.copyNewHeadStylesheetElements=function(){var t
,e
,r
,n
,o
;for(n
=this.getNewHeadStylesheetElements(),o
=[],e
=0,r
=n
.length
;r
>e
;e
++)t
=n
[e
],o
.push(document
.head
.appendChild(t
));return o
},o
.prototype.copyNewHeadScriptElements=function(){var t
,e
,r
,n
,o
;for(n
=this.getNewHeadScriptElements(),o
=[],e
=0,r
=n
.length
;r
>e
;e
++)t
=n
[e
],o
.push(document
.head
.appendChild(this.createScriptElement(t
)));return o
},o
.prototype.removeCurrentHeadProvisionalElements=function(){var t
,e
,r
,n
,o
;for(n
=this.getCurrentHeadProvisionalElements(),o
=[],e
=0,r
=n
.length
;r
>e
;e
++)t
=n
[e
],o
.push(document
.head
.removeChild(t
));return o
},o
.prototype.copyNewHeadProvisionalElements=function(){var t
,e
,r
,n
,o
;for(n
=this.getNewHeadProvisionalElements(),o
=[],e
=0,r
=n
.length
;r
>e
;e
++)t
=n
[e
],o
.push(document
.head
.appendChild(t
));return o
},o
.prototype.relocateCurrentBodyPermanentElements=function(){var e
,n
,o
,i
,s
,a
,u
;for(a
=this.getCurrentBodyPermanentElements(),u
=[],e
=0,n
=a
.length
;n
>e
;e
++)i
=a
[e
],s
=t(i
),o
=this.newSnapshot
.getPermanentElementById(i
.id
),r(i
,s
.element
),r(o
,i
),u
.push(s
);return u
},o
.prototype.replacePlaceholderElementsWithClonedPermanentElements=function(t
){var e
,n
,o
,i
,s
,a
,u
;for(u
=[],o
=0,i
=t
.length
;i
>o
;o
++)a
=t
[o
],n
=a
.element
,s
=a
.permanentElement
,e
=s
.cloneNode(!0),u
.push(r(n
,e
));return u
},o
.prototype.activateNewBodyScriptElements=function(){var t
,e
,n
,o
,i
,s
;for(i
=this.getNewBodyScriptElements(),s
=[],e
=0,o
=i
.length
;o
>e
;e
++)n
=i
[e
],t
=this.createScriptElement(n
),s
.push(r(n
,t
));return s
},o
.prototype.assignNewBody=function(){return document
.body
=this.newBody
},o
.prototype.focusFirstAutofocusableElement=function(){var t
;return null!=(t
=this.newSnapshot
.findFirstAutofocusableElement())?t
.focus():void 0},o
.prototype.getNewHeadStylesheetElements=function(){return this.newHeadDetails
.getStylesheetElementsNotInDetails(this.currentHeadDetails
)},o
.prototype.getNewHeadScriptElements=function(){return this.newHeadDetails
.getScriptElementsNotInDetails(this.currentHeadDetails
)},o
.prototype.getCurrentHeadProvisionalElements=function(){return this.currentHeadDetails
.getProvisionalElements()},o
.prototype.getNewHeadProvisionalElements=function(){return this.newHeadDetails
.getProvisionalElements()},o
.prototype.getCurrentBodyPermanentElements=function(){return this.currentSnapshot
.getPermanentElementsPresentInSnapshot(this.newSnapshot
)},o
.prototype.getNewBodyScriptElements=function(){return this.newBody
.querySelectorAll("script")},o
}(e
.Renderer
),t=function(t
){var e
;return e
=document
.createElement("meta"),e
.setAttribute("name","turbolinks-permanent-placeholder"),e
.setAttribute("content",t
.id
),{element:e
,permanentElement:t
}},r=function(t
,e
){var r
;return(r
=t
.parentNode
)?r
.replaceChild(e
,t
):void 0}}.call(this),function(){var t=function(t
,e
){function n(){this.constructor=t
}for(var o
in e
)r
.call(e
,o
)&&(t
[o
]=e
[o
]);return n
.prototype=e
.prototype,t
.prototype=new n
,t
.__super__
=e
.prototype,t
},r
={}.hasOwnProperty
;e
.ErrorRenderer=function(e
){function r(t
){var e
;e
=document
.createElement("html"),e
.innerHTML
=t
,this.newHead
=e
.querySelector("head"),this.newBody
=e
.querySelector("body")}return t(r
,e
),r
.prototype.render=function(t
){return this.renderView(function(e
){return function(){return e
.replaceHeadAndBody(),e
.activateBodyScriptElements(),t()}}(this))},r
.prototype.replaceHeadAndBody=function(){var t
,e
;return e
=document
.head
,t
=document
.body
,e
.parentNode
.replaceChild(this.newHead
,e
),t
.parentNode
.replaceChild(this.newBody
,t
)},r
.prototype.activateBodyScriptElements=function(){var t
,e
,r
,n
,o
,i
;for(n
=this.getScriptElements(),i
=[],e
=0,r
=n
.length
;r
>e
;e
++)o
=n
[e
],t
=this.createScriptElement(o
),i
.push(o
.parentNode
.replaceChild(t
,o
));return i
},r
.prototype.getScriptElements=function(){return document
.documentElement
.querySelectorAll("script")},r
}(e
.Renderer
)}.call(this),function(){e
.View=function(){function t(t
){this.delegate
=t
,this.htmlElement
=document
.documentElement
}return t
.prototype.getRootLocation=function(){return this.getSnapshot().getRootLocation()},t
.prototype.getElementForAnchor=function(t
){return this.getSnapshot().getElementForAnchor(t
)},t
.prototype.getSnapshot=function(){return e
.Snapshot
.fromHTMLElement(this.htmlElement
)},t
.prototype.render=function(t
,e
){var r
,n
,o
;return o
=t
.snapshot
,r
=t
.error
,n
=t
.isPreview
,this.markAsPreview(n
),null!=o
?this.renderSnapshot(o
,n
,e
):this.renderError(r
,e
)},t
.prototype.markAsPreview=function(t
){return t
?this.htmlElement
.setAttribute("data-turbolinks-preview",""):this.htmlElement
.removeAttribute("data-turbolinks-preview")},t
.prototype.renderSnapshot=function(t
,r
,n
){return e
.SnapshotRenderer
.render(this.delegate
,n
,this.getSnapshot(),e
.Snapshot
.wrap(t
),r
)},t
.prototype.renderError=function(t
,r
){return e
.ErrorRenderer
.render(this.delegate
,r
,t
)},t
}()}.call(this),function(){var t=function(t
,e
){return function(){return t
.apply(e
,arguments
)}};e
.ScrollManager=function(){function r(r
){this.delegate
=r
,this.onScroll
=t(this.onScroll
,this),this.onScroll
=e
.throttle(this.onScroll
)}return r
.prototype.start=function(){return this.started
?void 0:(addEventListener("scroll",this.onScroll
,!1),this.onScroll(),this.started
=!0)},r
.prototype.stop=function(){return this.started
?(removeEventListener("scroll",this.onScroll
,!1),this.started
=!1):void 0},r
.prototype.scrollToElement=function(t
){return t
.scrollIntoView()},r
.prototype.scrollToPosition=function(t
){var e
,r
;return e
=t
.x
,r
=t
.y
,window
.scrollTo(e
,r
)},r
.prototype.onScroll=function(t
){return this.updatePosition({x:window
.pageXOffset
,y:window
.pageYOffset
})},r
.prototype.updatePosition=function(t
){var e
;return this.position
=t
,null!=(e
=this.delegate
)?e
.scrollPositionChanged(this.position
):void 0},r
}()}.call(this),function(){e
.SnapshotCache=function(){function t(t
){this.size
=t
,this.keys
=[],this.snapshots
={}}var r
;return t
.prototype.has=function(t
){var e
;return e
=r(t
),e
in this.snapshots
},t
.prototype.get=function(t
){var e
;if(this.has(t
))return e
=this.read(t
),this.touch(t
),e
},t
.prototype.put=function(t
,e
){return this.write(t
,e
),this.touch(t
),e
},t
.prototype.read=function(t
){var e
;return e
=r(t
),this.snapshots
[e
]},t
.prototype.write=function(t
,e
){var n
;return n
=r(t
),this.snapshots
[n
]=e
},t
.prototype.touch=function(t
){var e
,n
;return n
=r(t
),e
=this.keys
.indexOf(n
),e
>-1&&this.keys
.splice(e
,1),this.keys
.unshift(n
),this.trim()},t
.prototype.trim=function(){var t
,e
,r
,n
,o
;for(n
=this.keys
.splice(this.size
),o
=[],t
=0,r
=n
.length
;r
>t
;t
++)e
=n
[t
],o
.push(delete this.snapshots
[e
]);return o
},r=function(t
){return e
.Location
.wrap(t
).toCacheKey()},t
}()}.call(this),function(){var t=function(t
,e
){return function(){return t
.apply(e
,arguments
)}};e
.Visit=function(){function r(r
,n
,o
){this.controller
=r
,this.action
=o
,this.performScroll
=t(this.performScroll
,this),this.identifier
=e
.uuid(),this.location
=e
.Location
.wrap(n
),this.adapter
=this.controller
.adapter
,this.state
="initialized",this.timingMetrics
={}}var n
;return r
.prototype.start=function(){return"initialized"===this.state
?(this.recordTimingMetric("visitStart"),this.state
="started",this.adapter
.visitStarted(this)):void 0},r
.prototype.cancel=function(){var t
;return"started"===this.state
?(null!=(t
=this.request
)&&t
.cancel(),this.cancelRender(),this.state
="canceled"):void 0},r
.prototype.complete=function(){var t
;return"started"===this.state
?(this.recordTimingMetric("visitEnd"),this.state
="completed","function"==typeof(t
=this.adapter
).visitCompleted
&&t
.visitCompleted(this),this.controller
.visitCompleted(this)):void 0},r
.prototype.fail=function(){var t
;return"started"===this.state
?(this.state
="failed","function"==typeof(t
=this.adapter
).visitFailed
?t
.visitFailed(this):void 0):void 0},r
.prototype.changeHistory=function(){var t
,e
;return this.historyChanged
?void 0:(t
=this.location
.isEqualTo(this.referrer
)?"replace":this.action
,e
=n(t
),this.controller
[e
](this.location
,this.restorationIdentifier
),this.historyChanged
=!0)},r
.prototype.issueRequest=function(){return this.shouldIssueRequest()&&null==this.request
?(this.progress
=0,this.request
=new e
.HttpRequest(this,this.location
,this.referrer
),this.request
.send()):void 0},r
.prototype.getCachedSnapshot=function(){var t
;return!(t
=this.controller
.getCachedSnapshotForLocation(this.location
))||null!=this.location
.anchor
&&!t
.hasAnchor(this.location
.anchor
)||"restore"!==this.action
&&!t
.isPreviewable()?void 0:t
},r
.prototype.hasCachedSnapshot=function(){return null!=this.getCachedSnapshot()},r
.prototype.loadCachedSnapshot=function(){var t
,e
;return(e
=this.getCachedSnapshot())?(t
=this.shouldIssueRequest(),this.render(function(){var r
;return this.cacheSnapshot(),this.controller
.render({snapshot:e
,isPreview:t
},this.performScroll
),"function"==typeof(r
=this.adapter
).visitRendered
&&r
.visitRendered(this),t
?void 0:this.complete()})):void 0},r
.prototype.loadResponse=function(){return null!=this.response
?this.render(function(){var t
,e
;return this.cacheSnapshot(),this.request
.failed
?(this.controller
.render({error:this.response
},this.performScroll
),"function"==typeof(t
=this.adapter
).visitRendered
&&t
.visitRendered(this),this.fail()):(this.controller
.render({snapshot:this.response
},this.performScroll
),"function"==typeof(e
=this.adapter
).visitRendered
&&e
.visitRendered(this),this.complete())}):void 0},r
.prototype.followRedirect=function(){return this.redirectedToLocation
&&!this.followedRedirect
?(this.location
=this.redirectedToLocation
,this.controller
.replaceHistoryWithLocationAndRestorationIdentifier(this.redirectedToLocation
,this.restorationIdentifier
),this.followedRedirect
=!0):void 0},r
.prototype.requestStarted=function(){var t
;return this.recordTimingMetric("requestStart"),"function"==typeof(t
=this.adapter
).visitRequestStarted
?t
.visitRequestStarted(this):void 0},r
.prototype.requestProgressed=function(t
){var e
;return this.progress
=t
,"function"==typeof(e
=this.adapter
).visitRequestProgressed
?e
.visitRequestProgressed(this):void 0},r
.prototype.requestCompletedWithResponse=function(t
,r
){return this.response
=t
,null!=r
&&(this.redirectedToLocation
=e
.Location
.wrap(r
)),this.adapter
.visitRequestCompleted(this)},r
.prototype.requestFailedWithStatusCode=function(t
,e
){return this.response
=e
,this.adapter
.visitRequestFailedWithStatusCode(this,t
)},r
.prototype.requestFinished=function(){var t
;return this.recordTimingMetric("requestEnd"),"function"==typeof(t
=this.adapter
).visitRequestFinished
?t
.visitRequestFinished(this):void 0},r
.prototype.performScroll=function(){return this.scrolled
?void 0:("restore"===this.action
?this.scrollToRestoredPosition()||this.scrollToTop():this.scrollToAnchor()||this.scrollToTop(),this.scrolled
=!0)},r
.prototype.scrollToRestoredPosition=function(){var t
,e
;return t
=null!=(e
=this.restorationData
)?e
.scrollPosition:void 0,null!=t
?(this.controller
.scrollToPosition(t
),!0):void 0},r
.prototype.scrollToAnchor=function(){return null!=this.location
.anchor
?(this.controller
.scrollToAnchor(this.location
.anchor
),!0):void 0},r
.prototype.scrollToTop=function(){return this.controller
.scrollToPosition({x:0,y:0})},r
.prototype.recordTimingMetric=function(t
){var e
;return null!=(e
=this.timingMetrics
)[t
]?e
[t
]:e
[t
]=(new Date
).getTime()},r
.prototype.getTimingMetrics=function(){return e
.copyObject(this.timingMetrics
)},n=function(t
){switch(t
){case"replace":return"replaceHistoryWithLocationAndRestorationIdentifier";case"advance":case"restore":return"pushHistoryWithLocationAndRestorationIdentifier"}},r
.prototype.shouldIssueRequest=function(){return"restore"===this.action
?!this.hasCachedSnapshot():!0},r
.prototype.cacheSnapshot=function(){return this.snapshotCached
?void 0:(this.controller
.cacheSnapshot(),this.snapshotCached
=!0)},r
.prototype.render=function(t
){return this.cancelRender(),this.frame
=requestAnimationFrame(function(e
){return function(){return e
.frame
=null,t
.call(e
)}}(this))},r
.prototype.cancelRender=function(){return this.frame
?cancelAnimationFrame(this.frame
):void 0},r
}()}.call(this),function(){var t=function(t
,e
){return function(){return t
.apply(e
,arguments
)}};e
.Controller=function(){function r(){this.clickBubbled
=t(this.clickBubbled
,this),this.clickCaptured
=t(this.clickCaptured
,this),this.pageLoaded
=t(this.pageLoaded
,this),this.history
=new e
.History(this),this.view
=new e
.View(this),this.scrollManager
=new e
.ScrollManager(this),this.restorationData
={},this.clearCache(),this.setProgressBarDelay(500)}return r
.prototype.start=function(){return e
.supported
&&!this.started
?(addEventListener("click",this.clickCaptured
,!0),addEventListener("DOMContentLoaded",this.pageLoaded
,!1),this.scrollManager
.start(),this.startHistory(),this.started
=!0,this.enabled
=!0):void 0},r
.prototype.disable=function(){return this.enabled
=!1},r
.prototype.stop=function(){return this.started
?(removeEventListener("click",this.clickCaptured
,!0),removeEventListener("DOMContentLoaded",this.pageLoaded
,!1),this.scrollManager
.stop(),this.stopHistory(),this.started
=!1):void 0},r
.prototype.clearCache=function(){return this.cache
=new e
.SnapshotCache(10)},r
.prototype.visit=function(t
,r
){var n
,o
;return null==r
&&(r
={}),t
=e
.Location
.wrap(t
),this.applicationAllowsVisitingLocation(t
)?this.locationIsVisitable(t
)?(n
=null!=(o
=r
.action
)?o:"advance",this.adapter
.visitProposedToLocationWithAction(t
,n
)):window
.location
=t:void 0},r
.prototype.startVisitToLocationWithAction=function(t
,r
,n
){var o
;return e
.supported
?(o
=this.getRestorationDataForIdentifier(n
),this.startVisit(t
,r
,{restorationData:o
})):window
.location
=t
},r
.prototype.setProgressBarDelay=function(t
){return this.progressBarDelay
=t
},r
.prototype.startHistory=function(){return this.location
=e
.Location
.wrap(window
.location
),this.restorationIdentifier
=e
.uuid(),this.history
.start(),this.history
.replace(this.location
,this.restorationIdentifier
)},r
.prototype.stopHistory=function(){return this.history
.stop()},r
.prototype.pushHistoryWithLocationAndRestorationIdentifier=function(t
,r
){return this.restorationIdentifier
=r
,this.location
=e
.Location
.wrap(t
),this.history
.push(this.location
,this.restorationIdentifier
)},r
.prototype.replaceHistoryWithLocationAndRestorationIdentifier=function(t
,r
){return this.restorationIdentifier
=r
,this.location
=e
.Location
.wrap(t
),this.history
.replace(this.location
,this.restorationIdentifier
)},r
.prototype.historyPoppedToLocationWithRestorationIdentifier=function(t
,r
){var n
;return this.restorationIdentifier
=r
,this.enabled
?(n
=this.getRestorationDataForIdentifier(this.restorationIdentifier
),this.startVisit(t
,"restore",{restorationIdentifier:this.restorationIdentifier
,restorationData:n
,historyChanged:!0}),this.location
=e
.Location
.wrap(t
)):this.adapter
.pageInvalidated()},r
.prototype.getCachedSnapshotForLocation=function(t
){var e
;return null!=(e
=this.cache
.get(t
))?e
.clone():void 0},r
.prototype.shouldCacheSnapshot=function(){return this.view
.getSnapshot().isCacheable();
7 },r
.prototype.cacheSnapshot=function(){var t
,r
;return this.shouldCacheSnapshot()?(this.notifyApplicationBeforeCachingSnapshot(),r
=this.view
.getSnapshot(),t
=this.lastRenderedLocation
,e
.defer(function(e
){return function(){return e
.cache
.put(t
,r
.clone())}}(this))):void 0},r
.prototype.scrollToAnchor=function(t
){var e
;return(e
=this.view
.getElementForAnchor(t
))?this.scrollToElement(e
):this.scrollToPosition({x:0,y:0})},r
.prototype.scrollToElement=function(t
){return this.scrollManager
.scrollToElement(t
)},r
.prototype.scrollToPosition=function(t
){return this.scrollManager
.scrollToPosition(t
)},r
.prototype.scrollPositionChanged=function(t
){var e
;return e
=this.getCurrentRestorationData(),e
.scrollPosition
=t
},r
.prototype.render=function(t
,e
){return this.view
.render(t
,e
)},r
.prototype.viewInvalidated=function(){return this.adapter
.pageInvalidated()},r
.prototype.viewWillRender=function(t
){return this.notifyApplicationBeforeRender(t
)},r
.prototype.viewRendered=function(){return this.lastRenderedLocation
=this.currentVisit
.location
,this.notifyApplicationAfterRender()},r
.prototype.pageLoaded=function(){return this.lastRenderedLocation
=this.location
,this.notifyApplicationAfterPageLoad()},r
.prototype.clickCaptured=function(){return removeEventListener("click",this.clickBubbled
,!1),addEventListener("click",this.clickBubbled
,!1)},r
.prototype.clickBubbled=function(t
){var e
,r
,n
;return this.enabled
&&this.clickEventIsSignificant(t
)&&(r
=this.getVisitableLinkForNode(t
.target
))&&(n
=this.getVisitableLocationForLink(r
))&&this.applicationAllowsFollowingLinkToLocation(r
,n
)?(t
.preventDefault(),e
=this.getActionForLink(r
),this.visit(n
,{action:e
})):void 0},r
.prototype.applicationAllowsFollowingLinkToLocation=function(t
,e
){var r
;return r
=this.notifyApplicationAfterClickingLinkToLocation(t
,e
),!r
.defaultPrevented
},r
.prototype.applicationAllowsVisitingLocation=function(t
){var e
;return e
=this.notifyApplicationBeforeVisitingLocation(t
),!e
.defaultPrevented
},r
.prototype.notifyApplicationAfterClickingLinkToLocation=function(t
,r
){return e
.dispatch("turbolinks:click",{target:t
,data:{url:r
.absoluteURL
},cancelable:!0})},r
.prototype.notifyApplicationBeforeVisitingLocation=function(t
){return e
.dispatch("turbolinks:before-visit",{data:{url:t
.absoluteURL
},cancelable:!0})},r
.prototype.notifyApplicationAfterVisitingLocation=function(t
){return e
.dispatch("turbolinks:visit",{data:{url:t
.absoluteURL
}})},r
.prototype.notifyApplicationBeforeCachingSnapshot=function(){return e
.dispatch("turbolinks:before-cache")},r
.prototype.notifyApplicationBeforeRender=function(t
){return e
.dispatch("turbolinks:before-render",{data:{newBody:t
}})},r
.prototype.notifyApplicationAfterRender=function(){return e
.dispatch("turbolinks:render")},r
.prototype.notifyApplicationAfterPageLoad=function(t
){return null==t
&&(t
={}),e
.dispatch("turbolinks:load",{data:{url:this.location
.absoluteURL
,timing:t
}})},r
.prototype.startVisit=function(t
,e
,r
){var n
;return null!=(n
=this.currentVisit
)&&n
.cancel(),this.currentVisit
=this.createVisit(t
,e
,r
),this.currentVisit
.start(),this.notifyApplicationAfterVisitingLocation(t
)},r
.prototype.createVisit=function(t
,r
,n
){var o
,i
,s
,a
,u
;return i
=null!=n
?n:{},a
=i
.restorationIdentifier
,s
=i
.restorationData
,o
=i
.historyChanged
,u
=new e
.Visit(this,t
,r
),u
.restorationIdentifier
=null!=a
?a:e
.uuid(),u
.restorationData
=e
.copyObject(s
),u
.historyChanged
=o
,u
.referrer
=this.location
,u
},r
.prototype.visitCompleted=function(t
){return this.notifyApplicationAfterPageLoad(t
.getTimingMetrics())},r
.prototype.clickEventIsSignificant=function(t
){return!(t
.defaultPrevented
||t
.target
.isContentEditable
||t
.which
>1||t
.altKey
||t
.ctrlKey
||t
.metaKey
||t
.shiftKey
)},r
.prototype.getVisitableLinkForNode=function(t
){return this.nodeIsVisitable(t
)?e
.closest(t
,"a[href]:not([target]):not([download])"):void 0},r
.prototype.getVisitableLocationForLink=function(t
){var r
;return r
=new e
.Location(t
.getAttribute("href")),this.locationIsVisitable(r
)?r:void 0},r
.prototype.getActionForLink=function(t
){var e
;return null!=(e
=t
.getAttribute("data-turbolinks-action"))?e:"advance"},r
.prototype.nodeIsVisitable=function(t
){var r
;return(r
=e
.closest(t
,"[data-turbolinks]"))?"false"!==r
.getAttribute("data-turbolinks"):!0},r
.prototype.locationIsVisitable=function(t
){return t
.isPrefixedBy(this.view
.getRootLocation())&&t
.isHTML()},r
.prototype.getCurrentRestorationData=function(){return this.getRestorationDataForIdentifier(this.restorationIdentifier
)},r
.prototype.getRestorationDataForIdentifier=function(t
){var e
;return null!=(e
=this.restorationData
)[t
]?e
[t
]:e
[t
]={}},r
}()}.call(this),function(){!function(){var t
,e
;if((t
=e
=document
.currentScript
)&&!e
.hasAttribute("data-turbolinks-suppress-warning"))for(;t
=t
.parentNode
;)if(t
===document
.body
)return console
.warn("You are loading Turbolinks from a <script> element inside the <body> element. This is probably not what you meant to do!\n\nLoad your application\u2019s JavaScript bundle inside the <head> element instead. <script> elements in <body> are evaluated with each page change.\n\nFor more information, see: https://github.com/turbolinks/turbolinks#working-with-script-elements\n\n\u2014\u2014\nSuppress this warning by adding a `data-turbolinks-suppress-warning` attribute to: %s",e
.outerHTML
)}()}.call(this),function(){var t
,r
,n
;e
.start=function(){return r()?(null==e
.controller
&&(e
.controller
=t()),e
.controller
.start()):void 0},r=function(){return null==window
.Turbolinks
&&(window
.Turbolinks
=e
),n()},t=function(){var t
;return t
=new e
.Controller
,t
.adapter
=new e
.BrowserAdapter(t
),t
},n=function(){return window
.Turbolinks
===e
},n()&&e
.start()}.call(this)}).call(this),"object"==typeof module
&&module
.exports
?module
.exports
=e:"function"==typeof define
&&define
.amd
&&define(e
)}).call(this);
9 * jQuery JavaScript Library v2.1.1
13 * http://sizzlejs.com/
15 * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
16 * Released under the MIT license
17 * http://jquery.org/license
19 * Date: 2014-05-01T17:11Z
23 (function( global
, factory
) {
25 if ( typeof module
=== "object" && typeof module
.exports
=== "object" ) {
26 // For CommonJS and CommonJS-like environments where a proper window is present,
27 // execute the factory and get jQuery
28 // For environments that do not inherently posses a window with a document
29 // (such as Node.js), expose a jQuery-making factory as module.exports
30 // This accentuates the need for the creation of a real window
31 // e.g. var jQuery = require("jquery")(window);
32 // See ticket #14549 for more info
33 module
.exports
= global
.document
?
34 factory( global
, true ) :
37 throw new Error( "jQuery requires a window with a document" );
45 // Pass this if window is not defined yet
46 }(typeof window
!== "undefined" ? window : this, function( window
, noGlobal
) {
48 // Can't do this because several apps including ASP.NET trace
49 // the stack via arguments.caller.callee and Firefox dies if
50 // you try to trace through "use strict" call chains. (#13335)
51 // Support: Firefox 18+
56 var slice
= arr
.slice
;
58 var concat
= arr
.concat
;
62 var indexOf
= arr
.indexOf
;
66 var toString
= class2type
.toString
;
68 var hasOwn
= class2type
.hasOwnProperty
;
75 // Use the correct document accordingly with window argument (sandbox)
76 document
= window
.document
,
80 // Define a local copy of jQuery
81 jQuery = function( selector
, context
) {
82 // The jQuery object is actually just the init constructor 'enhanced'
83 // Need init if jQuery is called (just allow error to be thrown if not included)
84 return new jQuery
.fn
.init( selector
, context
);
87 // Support: Android<4.1
88 // Make sure we trim BOM and NBSP
89 rtrim
= /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
91 // Matches dashed string for camelizing
93 rdashAlpha
= /-([\da-z])/gi,
95 // Used by jQuery.camelCase as callback to replace()
96 fcamelCase = function( all
, letter
) {
97 return letter
.toUpperCase();
100 jQuery
.fn
= jQuery
.prototype = {
101 // The current version of jQuery being used
106 // Start with an empty selector
109 // The default length of a jQuery object is 0
112 toArray: function() {
113 return slice
.call( this );
116 // Get the Nth element in the matched element set OR
117 // Get the whole matched element set as a clean array
118 get: function( num
) {
121 // Return just the one element from the set
122 ( num
< 0 ? this[ num
+ this.length
] : this[ num
] ) :
124 // Return all the elements in a clean array
128 // Take an array of elements and push it onto the stack
129 // (returning the new matched element set)
130 pushStack: function( elems
) {
132 // Build a new jQuery matched element set
133 var ret
= jQuery
.merge( this.constructor(), elems
);
135 // Add the old object onto the stack (as a reference)
136 ret
.prevObject
= this;
137 ret
.context
= this.context
;
139 // Return the newly-formed element set
143 // Execute a callback for every element in the matched set.
144 // (You can seed the arguments with an array of args, but this is
145 // only used internally.)
146 each: function( callback
, args
) {
147 return jQuery
.each( this, callback
, args
);
150 map: function( callback
) {
151 return this.pushStack( jQuery
.map(this, function( elem
, i
) {
152 return callback
.call( elem
, i
, elem
);
157 return this.pushStack( slice
.apply( this, arguments
) );
165 return this.eq( -1 );
169 var len
= this.length
,
170 j
= +i
+ ( i
< 0 ? len : 0 );
171 return this.pushStack( j
>= 0 && j
< len
? [ this[j
] ] : [] );
175 return this.prevObject
|| this.constructor(null);
178 // For internal use only.
179 // Behaves like an Array's method, not like a jQuery method.
185 jQuery
.extend
= jQuery
.fn
.extend = function() {
186 var options
, name
, src
, copy
, copyIsArray
, clone
,
187 target
= arguments
[0] || {},
189 length
= arguments
.length
,
192 // Handle a deep copy situation
193 if ( typeof target
=== "boolean" ) {
196 // skip the boolean and the target
197 target
= arguments
[ i
] || {};
201 // Handle case when target is a string or something (possible in deep copy)
202 if ( typeof target
!== "object" && !jQuery
.isFunction(target
) ) {
206 // extend jQuery itself if only one argument is passed
207 if ( i
=== length
) {
212 for ( ; i
< length
; i
++ ) {
213 // Only deal with non-null/undefined values
214 if ( (options
= arguments
[ i
]) != null ) {
215 // Extend the base object
216 for ( name
in options
) {
217 src
= target
[ name
];
218 copy
= options
[ name
];
220 // Prevent never-ending loop
221 if ( target
=== copy
) {
225 // Recurse if we're merging plain objects or arrays
226 if ( deep
&& copy
&& ( jQuery
.isPlainObject(copy
) || (copyIsArray
= jQuery
.isArray(copy
)) ) ) {
229 clone
= src
&& jQuery
.isArray(src
) ? src : [];
232 clone
= src
&& jQuery
.isPlainObject(src
) ? src : {};
235 // Never move original objects, clone them
236 target
[ name
] = jQuery
.extend( deep
, clone
, copy
);
238 // Don't bring in undefined values
239 } else if ( copy
!== undefined ) {
240 target
[ name
] = copy
;
246 // Return the modified object
251 // Unique for each copy of jQuery on the page
252 expando: "jQuery" + ( version
+ Math
.random() ).replace( /\D/g, "" ),
254 // Assume jQuery is ready without the ready module
257 error: function( msg
) {
258 throw new Error( msg
);
263 // See test/unit/core.js for details concerning isFunction.
264 // Since version 1.3, DOM methods and functions like alert
265 // aren't supported. They return false on IE (#2968).
266 isFunction: function( obj
) {
267 return jQuery
.type(obj
) === "function";
270 isArray: Array
.isArray
,
272 isWindow: function( obj
) {
273 return obj
!= null && obj
=== obj
.window
;
276 isNumeric: function( obj
) {
277 // parseFloat NaNs numeric-cast false positives (null|true|false|"")
278 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
279 // subtraction forces infinities to NaN
280 return !jQuery
.isArray( obj
) && obj
- parseFloat( obj
) >= 0;
283 isPlainObject: function( obj
) {
284 // Not plain objects:
285 // - Any object or value whose internal [[Class]] property is not "[object Object]"
288 if ( jQuery
.type( obj
) !== "object" || obj
.nodeType
|| jQuery
.isWindow( obj
) ) {
292 if ( obj
.constructor &&
293 !hasOwn
.call( obj
.constructor.prototype, "isPrototypeOf" ) ) {
297 // If the function hasn't returned already, we're confident that
298 // |obj| is a plain object, created by {} or constructed with new Object
302 isEmptyObject: function( obj
) {
304 for ( name
in obj
) {
310 type: function( obj
) {
314 // Support: Android < 4.0, iOS < 6 (functionish RegExp)
315 return typeof obj
=== "object" || typeof obj
=== "function" ?
316 class2type
[ toString
.call(obj
) ] || "object" :
320 // Evaluates a script in a global context
321 globalEval: function( code
) {
325 code
= jQuery
.trim( code
);
328 // If the code includes a valid, prologue position
329 // strict mode pragma, execute code by injecting a
330 // script tag into the document.
331 if ( code
.indexOf("use strict") === 1 ) {
332 script
= document
.createElement("script");
334 document
.head
.appendChild( script
).parentNode
.removeChild( script
);
336 // Otherwise, avoid the DOM node creation, insertion
337 // and removal by using an indirect global eval
343 // Convert dashed to camelCase; used by the css and data modules
344 // Microsoft forgot to hump their vendor prefix (#9572)
345 camelCase: function( string
) {
346 return string
.replace( rmsPrefix
, "ms-" ).replace( rdashAlpha
, fcamelCase
);
349 nodeName: function( elem
, name
) {
350 return elem
.nodeName
&& elem
.nodeName
.toLowerCase() === name
.toLowerCase();
353 // args is for internal usage only
354 each: function( obj
, callback
, args
) {
358 isArray
= isArraylike( obj
);
362 for ( ; i
< length
; i
++ ) {
363 value
= callback
.apply( obj
[ i
], args
);
365 if ( value
=== false ) {
371 value
= callback
.apply( obj
[ i
], args
);
373 if ( value
=== false ) {
379 // A special, fast, case for the most common use of each
382 for ( ; i
< length
; i
++ ) {
383 value
= callback
.call( obj
[ i
], i
, obj
[ i
] );
385 if ( value
=== false ) {
391 value
= callback
.call( obj
[ i
], i
, obj
[ i
] );
393 if ( value
=== false ) {
403 // Support: Android<4.1
404 trim: function( text
) {
405 return text
== null ?
407 ( text
+ "" ).replace( rtrim
, "" );
410 // results is for internal usage only
411 makeArray: function( arr
, results
) {
412 var ret
= results
|| [];
415 if ( isArraylike( Object(arr
) ) ) {
417 typeof arr
=== "string" ?
421 push
.call( ret
, arr
);
428 inArray: function( elem
, arr
, i
) {
429 return arr
== null ? -1 : indexOf
.call( arr
, elem
, i
);
432 merge: function( first
, second
) {
433 var len
= +second
.length
,
437 for ( ; j
< len
; j
++ ) {
438 first
[ i
++ ] = second
[ j
];
446 grep: function( elems
, callback
, invert
) {
450 length
= elems
.length
,
451 callbackExpect
= !invert
;
453 // Go through the array, only saving the items
454 // that pass the validator function
455 for ( ; i
< length
; i
++ ) {
456 callbackInverse
= !callback( elems
[ i
], i
);
457 if ( callbackInverse
!== callbackExpect
) {
458 matches
.push( elems
[ i
] );
465 // arg is for internal usage only
466 map: function( elems
, callback
, arg
) {
469 length
= elems
.length
,
470 isArray
= isArraylike( elems
),
473 // Go through the array, translating each of the items to their new values
475 for ( ; i
< length
; i
++ ) {
476 value
= callback( elems
[ i
], i
, arg
);
478 if ( value
!= null ) {
483 // Go through every key on the object,
486 value
= callback( elems
[ i
], i
, arg
);
488 if ( value
!= null ) {
494 // Flatten any nested arrays
495 return concat
.apply( [], ret
);
498 // A global GUID counter for objects
501 // Bind a function to a context, optionally partially applying any
503 proxy: function( fn
, context
) {
504 var tmp
, args
, proxy
;
506 if ( typeof context
=== "string" ) {
512 // Quick check to determine if target is callable, in the spec
513 // this throws a TypeError, but we will just return undefined.
514 if ( !jQuery
.isFunction( fn
) ) {
519 args
= slice
.call( arguments
, 2 );
521 return fn
.apply( context
|| this, args
.concat( slice
.call( arguments
) ) );
524 // Set the guid of unique handler to the same of original handler, so it can be removed
525 proxy
.guid
= fn
.guid
= fn
.guid
|| jQuery
.guid
++;
532 // jQuery.support is not used in Core but other projects attach their
533 // properties to it so it needs to exist.
537 // Populate the class2type map
538 jQuery
.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i
, name
) {
539 class2type
[ "[object " + name
+ "]" ] = name
.toLowerCase();
542 function isArraylike( obj
) {
543 var length
= obj
.length
,
544 type
= jQuery
.type( obj
);
546 if ( type
=== "function" || jQuery
.isWindow( obj
) ) {
550 if ( obj
.nodeType
=== 1 && length
) {
554 return type
=== "array" || length
=== 0 ||
555 typeof length
=== "number" && length
> 0 && ( length
- 1 ) in obj
;
559 * Sizzle CSS Selector Engine v1.10.19
560 * http://sizzlejs.com/
562 * Copyright 2013 jQuery Foundation, Inc. and other contributors
563 * Released under the MIT license
564 * http://jquery.org/license
568 (function( window
) {
582 // Local document vars
592 // Instance-specific data
593 expando
= "sizzle" + -(new Date()),
594 preferredDoc
= window
.document
,
597 classCache
= createCache(),
598 tokenCache
= createCache(),
599 compilerCache
= createCache(),
600 sortOrder = function( a
, b
) {
607 // General-purpose constants
608 strundefined
= typeof undefined,
609 MAX_NEGATIVE
= 1 << 31,
612 hasOwn
= ({}).hasOwnProperty
,
615 push_native
= arr
.push
,
618 // Use a stripped-down indexOf if we can't use a native one
619 indexOf
= arr
.indexOf
|| function( elem
) {
622 for ( ; i
< len
; i
++ ) {
623 if ( this[i
] === elem
) {
630 booleans
= "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
632 // Regular expressions
634 // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
635 whitespace
= "[\\x20\\t\\r\\n\\f]",
636 // http://www.w3.org/TR/css3-syntax/#characters
637 characterEncoding
= "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
639 // Loosely modeled on CSS identifier characters
640 // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
641 // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
642 identifier
= characterEncoding
.replace( "w", "w#" ),
644 // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
645 attributes
= "\\[" + whitespace
+ "*(" + characterEncoding
+ ")(?:" + whitespace
+
646 // Operator (capture 2)
647 "*([*^$|!~]?=)" + whitespace
+
648 // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
649 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier
+ "))|)" + whitespace
+
652 pseudos
= ":(" + characterEncoding
+ ")(?:\\((" +
653 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
654 // 1. quoted (capture 3; capture 4 or capture 5)
655 "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
656 // 2. simple (capture 6)
657 "((?:\\\\.|[^\\\\()[\\]]|" + attributes
+ ")*)|" +
658 // 3. anything else (capture 2)
662 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
663 rtrim
= new RegExp( "^" + whitespace
+ "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace
+ "+$", "g" ),
665 rcomma
= new RegExp( "^" + whitespace
+ "*," + whitespace
+ "*" ),
666 rcombinators
= new RegExp( "^" + whitespace
+ "*([>+~]|" + whitespace
+ ")" + whitespace
+ "*" ),
668 rattributeQuotes
= new RegExp( "=" + whitespace
+ "*([^\\]'\"]*?)" + whitespace
+ "*\\]", "g" ),
670 rpseudo
= new RegExp( pseudos
),
671 ridentifier
= new RegExp( "^" + identifier
+ "$" ),
674 "ID": new RegExp( "^#(" + characterEncoding
+ ")" ),
675 "CLASS": new RegExp( "^\\.(" + characterEncoding
+ ")" ),
676 "TAG": new RegExp( "^(" + characterEncoding
.replace( "w", "w*" ) + ")" ),
677 "ATTR": new RegExp( "^" + attributes
),
678 "PSEUDO": new RegExp( "^" + pseudos
),
679 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace
+
680 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace
+ "*(?:([+-]|)" + whitespace
+
681 "*(\\d+)|))" + whitespace
+ "*\\)|)", "i" ),
682 "bool": new RegExp( "^(?:" + booleans
+ ")$", "i" ),
683 // For use in libraries implementing .is()
684 // We use this for POS matching in `select`
685 "needsContext": new RegExp( "^" + whitespace
+ "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
686 whitespace
+ "*((?:-\\d)?\\d*)" + whitespace
+ "*\\)|)(?=[^-]|$)", "i" )
689 rinputs
= /^(?:input|select|textarea|button)$/i,
692 rnative
= /^[^{]+\{\s
*\[native \w
/,
694 // Easily-parseable/retrievable ID or TAG or CLASS selectors
695 rquickExpr
= /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
700 // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
701 runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
702 funescape = function( _, escaped, escapedWhitespace ) {
703 var high = "0x" + escaped - 0x10000;
704 // NaN means non-codepoint
705 // Support: Firefox<24
706 // Workaround erroneous numeric interpretation of +"0x"
707 return high !== high || escapedWhitespace ?
711 String.fromCharCode( high + 0x10000 ) :
712 // Supplemental Plane codepoint (surrogate pair)
713 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
716 // Optimize for push.apply( _, NodeList )
719 (arr = slice.call( preferredDoc.childNodes )),
720 preferredDoc.childNodes
722 // Support: Android<4.0
723 // Detect silently failing push.apply
724 arr[ preferredDoc.childNodes.length ].nodeType;
726 push = { apply: arr.length ?
728 // Leverage slice if possible
729 function( target, els ) {
730 push_native.apply( target, slice.call(els) );
734 // Otherwise append directly
735 function( target, els ) {
736 var j = target.length,
738 // Can't trust NodeList
.length
739 while ( (target
[j
++] = els
[i
++]) ) {}
740 target
.length
= j
- 1;
745 function Sizzle( selector
, context
, results
, seed
) {
746 var match
, elem
, m
, nodeType
,
748 i
, groups
, old
, nid
, newContext
, newSelector
;
750 if ( ( context
? context
.ownerDocument
|| context : preferredDoc
) !== document
) {
751 setDocument( context
);
754 context
= context
|| document
;
755 results
= results
|| [];
757 if ( !selector
|| typeof selector
!== "string" ) {
761 if ( (nodeType
= context
.nodeType
) !== 1 && nodeType
!== 9 ) {
765 if ( documentIsHTML
&& !seed
) {
768 if ( (match
= rquickExpr
.exec( selector
)) ) {
769 // Speed-up: Sizzle("#ID")
770 if ( (m
= match
[1]) ) {
771 if ( nodeType
=== 9 ) {
772 elem
= context
.getElementById( m
);
773 // Check parentNode to catch when Blackberry 4.6 returns
774 // nodes that are no longer in the document (jQuery #6963)
775 if ( elem
&& elem
.parentNode
) {
776 // Handle the case where IE, Opera, and Webkit return items
777 // by name instead of ID
778 if ( elem
.id
=== m
) {
779 results
.push( elem
);
786 // Context is not a document
787 if ( context
.ownerDocument
&& (elem
= context
.ownerDocument
.getElementById( m
)) &&
788 contains( context
, elem
) && elem
.id
=== m
) {
789 results
.push( elem
);
794 // Speed-up: Sizzle("TAG")
795 } else if ( match
[2] ) {
796 push
.apply( results
, context
.getElementsByTagName( selector
) );
799 // Speed-up: Sizzle(".CLASS")
800 } else if ( (m
= match
[3]) && support
.getElementsByClassName
&& context
.getElementsByClassName
) {
801 push
.apply( results
, context
.getElementsByClassName( m
) );
807 if ( support
.qsa
&& (!rbuggyQSA
|| !rbuggyQSA
.test( selector
)) ) {
809 newContext
= context
;
810 newSelector
= nodeType
=== 9 && selector
;
812 // qSA works strangely on Element-rooted queries
813 // We can work around this by specifying an extra ID on the root
814 // and working up from there (Thanks to Andrew Dupont for the technique)
815 // IE 8 doesn't work on object elements
816 if ( nodeType
=== 1 && context
.nodeName
.toLowerCase() !== "object" ) {
817 groups
= tokenize( selector
);
819 if ( (old
= context
.getAttribute("id")) ) {
820 nid
= old
.replace( rescape
, "\\$&" );
822 context
.setAttribute( "id", nid
);
824 nid
= "[id='" + nid
+ "'] ";
828 groups
[i
] = nid
+ toSelector( groups
[i
] );
830 newContext
= rsibling
.test( selector
) && testContext( context
.parentNode
) || context
;
831 newSelector
= groups
.join(",");
837 newContext
.querySelectorAll( newSelector
)
843 context
.removeAttribute("id");
851 return select( selector
.replace( rtrim
, "$1" ), context
, results
, seed
);
855 * Create key-value caches of limited size
856 * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
857 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
858 * deleting the oldest entry
860 function createCache() {
863 function cache( key
, value
) {
864 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
865 if ( keys
.push( key
+ " " ) > Expr
.cacheLength
) {
866 // Only keep the most recent entries
867 delete cache
[ keys
.shift() ];
869 return (cache
[ key
+ " " ] = value
);
875 * Mark a function for special use by Sizzle
876 * @param {Function} fn The function to mark
878 function markFunction( fn
) {
879 fn
[ expando
] = true;
884 * Support testing using an element
885 * @param {Function} fn Passed the created div and expects a boolean result
887 function assert( fn
) {
888 var div
= document
.createElement("div");
895 // Remove from its parent by default
896 if ( div
.parentNode
) {
897 div
.parentNode
.removeChild( div
);
899 // release memory in IE
905 * Adds the same handler for all of the specified attrs
906 * @param {String} attrs Pipe-separated list of attributes
907 * @param {Function} handler The method that will be applied
909 function addHandle( attrs
, handler
) {
910 var arr
= attrs
.split("|"),
914 Expr
.attrHandle
[ arr
[i
] ] = handler
;
919 * Checks document order of two siblings
922 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
924 function siblingCheck( a
, b
) {
926 diff
= cur
&& a
.nodeType
=== 1 && b
.nodeType
=== 1 &&
927 ( ~b
.sourceIndex
|| MAX_NEGATIVE
) -
928 ( ~a
.sourceIndex
|| MAX_NEGATIVE
);
930 // Use IE sourceIndex if available on both nodes
935 // Check if b follows a
937 while ( (cur
= cur
.nextSibling
) ) {
948 * Returns a function to use in pseudos for input types
949 * @param {String} type
951 function createInputPseudo( type
) {
952 return function( elem
) {
953 var name
= elem
.nodeName
.toLowerCase();
954 return name
=== "input" && elem
.type
=== type
;
959 * Returns a function to use in pseudos for buttons
960 * @param {String} type
962 function createButtonPseudo( type
) {
963 return function( elem
) {
964 var name
= elem
.nodeName
.toLowerCase();
965 return (name
=== "input" || name
=== "button") && elem
.type
=== type
;
970 * Returns a function to use in pseudos for positionals
971 * @param {Function} fn
973 function createPositionalPseudo( fn
) {
974 return markFunction(function( argument
) {
975 argument
= +argument
;
976 return markFunction(function( seed
, matches
) {
978 matchIndexes
= fn( [], seed
.length
, argument
),
979 i
= matchIndexes
.length
;
981 // Match elements found at the specified indexes
983 if ( seed
[ (j
= matchIndexes
[i
]) ] ) {
984 seed
[j
] = !(matches
[j
] = seed
[j
]);
992 * Checks a node for validity as a Sizzle context
993 * @param {Element|Object=} context
994 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
996 function testContext( context
) {
997 return context
&& typeof context
.getElementsByTagName
!== strundefined
&& context
;
1000 // Expose support vars for convenience
1001 support
= Sizzle
.support
= {};
1005 * @param {Element|Object} elem An element or a document
1006 * @returns {Boolean} True iff elem is a non-HTML XML node
1008 isXML
= Sizzle
.isXML = function( elem
) {
1009 // documentElement is verified for cases where it doesn't yet exist
1010 // (such as loading iframes in IE - #4833)
1011 var documentElement
= elem
&& (elem
.ownerDocument
|| elem
).documentElement
;
1012 return documentElement
? documentElement
.nodeName
!== "HTML" : false;
1016 * Sets document-related variables once based on the current document
1017 * @param {Element|Object} [doc] An element or document object to use to set the document
1018 * @returns {Object} Returns the current document
1020 setDocument
= Sizzle
.setDocument = function( node
) {
1022 doc
= node
? node
.ownerDocument
|| node : preferredDoc
,
1023 parent
= doc
.defaultView
;
1025 // If no document and documentElement is available, return
1026 if ( doc
=== document
|| doc
.nodeType
!== 9 || !doc
.documentElement
) {
1032 docElem
= doc
.documentElement
;
1035 documentIsHTML
= !isXML( doc
);
1038 // If iframe document is assigned to "document" variable and if iframe has been reloaded,
1039 // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
1040 // IE6-8 do not support the defaultView property so parent will be undefined
1041 if ( parent
&& parent
!== parent
.top
) {
1042 // IE11 does not have attachEvent, so all must suffer
1043 if ( parent
.addEventListener
) {
1044 parent
.addEventListener( "unload", function() {
1047 } else if ( parent
.attachEvent
) {
1048 parent
.attachEvent( "onunload", function() {
1055 ---------------------------------------------------------------------- */
1058 // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
1059 support
.attributes
= assert(function( div
) {
1060 div
.className
= "i";
1061 return !div
.getAttribute("className");
1065 ---------------------------------------------------------------------- */
1067 // Check if getElementsByTagName("*") returns only elements
1068 support
.getElementsByTagName
= assert(function( div
) {
1069 div
.appendChild( doc
.createComment("") );
1070 return !div
.getElementsByTagName("*").length
;
1073 // Check if getElementsByClassName can be trusted
1074 support
.getElementsByClassName
= rnative
.test( doc
.getElementsByClassName
) && assert(function( div
) {
1075 div
.innerHTML
= "<div class='a'></div><div class='a i'></div>";
1077 // Support: Safari<4
1078 // Catch class over-caching
1079 div
.firstChild
.className
= "i";
1080 // Support: Opera<10
1081 // Catch gEBCN failure to find non-leading classes
1082 return div
.getElementsByClassName("i").length
=== 2;
1086 // Check if getElementById returns elements by name
1087 // The broken getElementById methods don't pick up programatically-set names,
1088 // so use a roundabout getElementsByName test
1089 support
.getById
= assert(function( div
) {
1090 docElem
.appendChild( div
).id
= expando
;
1091 return !doc
.getElementsByName
|| !doc
.getElementsByName( expando
).length
;
1094 // ID find and filter
1095 if ( support
.getById
) {
1096 Expr
.find
["ID"] = function( id
, context
) {
1097 if ( typeof context
.getElementById
!== strundefined
&& documentIsHTML
) {
1098 var m
= context
.getElementById( id
);
1099 // Check parentNode to catch when Blackberry 4.6 returns
1100 // nodes that are no longer in the document #6963
1101 return m
&& m
.parentNode
? [ m
] : [];
1104 Expr
.filter
["ID"] = function( id
) {
1105 var attrId
= id
.replace( runescape
, funescape
);
1106 return function( elem
) {
1107 return elem
.getAttribute("id") === attrId
;
1112 // getElementById is not reliable as a find shortcut
1113 delete Expr
.find
["ID"];
1115 Expr
.filter
["ID"] = function( id
) {
1116 var attrId
= id
.replace( runescape
, funescape
);
1117 return function( elem
) {
1118 var node
= typeof elem
.getAttributeNode
!== strundefined
&& elem
.getAttributeNode("id");
1119 return node
&& node
.value
=== attrId
;
1125 Expr
.find
["TAG"] = support
.getElementsByTagName
?
1126 function( tag
, context
) {
1127 if ( typeof context
.getElementsByTagName
!== strundefined
) {
1128 return context
.getElementsByTagName( tag
);
1131 function( tag
, context
) {
1135 results
= context
.getElementsByTagName( tag
);
1137 // Filter out possible comments
1138 if ( tag
=== "*" ) {
1139 while ( (elem
= results
[i
++]) ) {
1140 if ( elem
.nodeType
=== 1 ) {
1151 Expr
.find
["CLASS"] = support
.getElementsByClassName
&& function( className
, context
) {
1152 if ( typeof context
.getElementsByClassName
!== strundefined
&& documentIsHTML
) {
1153 return context
.getElementsByClassName( className
);
1157 /* QSA/matchesSelector
1158 ---------------------------------------------------------------------- */
1160 // QSA and matchesSelector support
1162 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
1165 // qSa(:focus) reports false when true (Chrome 21)
1166 // We allow this because of a bug in IE8/9 that throws an error
1167 // whenever `document.activeElement` is accessed on an iframe
1168 // So, we allow :focus to pass through QSA all the time to avoid the IE error
1169 // See http://bugs.jquery.com/ticket/13378
1172 if ( (support
.qsa
= rnative
.test( doc
.querySelectorAll
)) ) {
1174 // Regex strategy adopted from Diego Perini
1175 assert(function( div
) {
1176 // Select is set to empty string on purpose
1177 // This is to test IE's treatment of not explicitly
1178 // setting a boolean content attribute,
1179 // since its presence should be enough
1180 // http://bugs.jquery.com/ticket/12359
1181 div
.innerHTML
= "<select msallowclip=''><option selected=''></option></select>";
1183 // Support: IE8, Opera 11-12.16
1184 // Nothing should be selected when empty strings follow ^= or $= or *=
1185 // The test attribute must be unknown in Opera but "safe" for WinRT
1186 // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
1187 if ( div
.querySelectorAll("[msallowclip^='']").length
) {
1188 rbuggyQSA
.push( "[*^$]=" + whitespace
+ "*(?:''|\"\")" );
1192 // Boolean attributes and "value" are not treated correctly
1193 if ( !div
.querySelectorAll("[selected]").length
) {
1194 rbuggyQSA
.push( "\\[" + whitespace
+ "*(?:value|" + booleans
+ ")" );
1197 // Webkit/Opera - :checked should return selected option elements
1198 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1199 // IE8 throws error here and will not see later tests
1200 if ( !div
.querySelectorAll(":checked").length
) {
1201 rbuggyQSA
.push(":checked");
1205 assert(function( div
) {
1206 // Support: Windows 8 Native Apps
1207 // The type and name attributes are restricted during .innerHTML assignment
1208 var input
= doc
.createElement("input");
1209 input
.setAttribute( "type", "hidden" );
1210 div
.appendChild( input
).setAttribute( "name", "D" );
1213 // Enforce case-sensitivity of name attribute
1214 if ( div
.querySelectorAll("[name=d]").length
) {
1215 rbuggyQSA
.push( "name" + whitespace
+ "*[*^$|!~]?=" );
1218 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
1219 // IE8 throws error here and will not see later tests
1220 if ( !div
.querySelectorAll(":enabled").length
) {
1221 rbuggyQSA
.push( ":enabled", ":disabled" );
1224 // Opera 10-11 does not throw on post-comma invalid pseudos
1225 div
.querySelectorAll("*,:x");
1226 rbuggyQSA
.push(",.*:");
1230 if ( (support
.matchesSelector
= rnative
.test( (matches
= docElem
.matches
||
1231 docElem
.webkitMatchesSelector
||
1232 docElem
.mozMatchesSelector
||
1233 docElem
.oMatchesSelector
||
1234 docElem
.msMatchesSelector
) )) ) {
1236 assert(function( div
) {
1237 // Check to see if it's possible to do matchesSelector
1238 // on a disconnected node (IE 9)
1239 support
.disconnectedMatch
= matches
.call( div
, "div" );
1241 // This should fail with an exception
1242 // Gecko does not error, returns false instead
1243 matches
.call( div
, "[s!='']:x" );
1244 rbuggyMatches
.push( "!=", pseudos
);
1248 rbuggyQSA
= rbuggyQSA
.length
&& new RegExp( rbuggyQSA
.join("|") );
1249 rbuggyMatches
= rbuggyMatches
.length
&& new RegExp( rbuggyMatches
.join("|") );
1252 ---------------------------------------------------------------------- */
1253 hasCompare
= rnative
.test( docElem
.compareDocumentPosition
);
1255 // Element contains another
1256 // Purposefully does not implement inclusive descendent
1257 // As in, an element does not contain itself
1258 contains
= hasCompare
|| rnative
.test( docElem
.contains
) ?
1260 var adown
= a
.nodeType
=== 9 ? a
.documentElement : a
,
1261 bup
= b
&& b
.parentNode
;
1262 return a
=== bup
|| !!( bup
&& bup
.nodeType
=== 1 && (
1264 adown
.contains( bup
) :
1265 a
.compareDocumentPosition
&& a
.compareDocumentPosition( bup
) & 16
1270 while ( (b
= b
.parentNode
) ) {
1280 ---------------------------------------------------------------------- */
1282 // Document order sorting
1283 sortOrder
= hasCompare
?
1286 // Flag for duplicate removal
1288 hasDuplicate
= true;
1292 // Sort on method existence if only one input has compareDocumentPosition
1293 var compare
= !a
.compareDocumentPosition
- !b
.compareDocumentPosition
;
1298 // Calculate position if both inputs belong to the same document
1299 compare
= ( a
.ownerDocument
|| a
) === ( b
.ownerDocument
|| b
) ?
1300 a
.compareDocumentPosition( b
) :
1302 // Otherwise we know they are disconnected
1305 // Disconnected nodes
1307 (!support
.sortDetached
&& b
.compareDocumentPosition( a
) === compare
) ) {
1309 // Choose the first element that is related to our preferred document
1310 if ( a
=== doc
|| a
.ownerDocument
=== preferredDoc
&& contains(preferredDoc
, a
) ) {
1313 if ( b
=== doc
|| b
.ownerDocument
=== preferredDoc
&& contains(preferredDoc
, b
) ) {
1317 // Maintain original order
1319 ( indexOf
.call( sortInput
, a
) - indexOf
.call( sortInput
, b
) ) :
1323 return compare
& 4 ? -1 : 1;
1326 // Exit early if the nodes are identical
1328 hasDuplicate
= true;
1339 // Parentless nodes are either documents or disconnected
1340 if ( !aup
|| !bup
) {
1341 return a
=== doc
? -1 :
1346 ( indexOf
.call( sortInput
, a
) - indexOf
.call( sortInput
, b
) ) :
1349 // If the nodes are siblings, we can do a quick check
1350 } else if ( aup
=== bup
) {
1351 return siblingCheck( a
, b
);
1354 // Otherwise we need full lists of their ancestors for comparison
1356 while ( (cur
= cur
.parentNode
) ) {
1360 while ( (cur
= cur
.parentNode
) ) {
1364 // Walk down the tree looking for a discrepancy
1365 while ( ap
[i
] === bp
[i
] ) {
1370 // Do a sibling check if the nodes have a common ancestor
1371 siblingCheck( ap
[i
], bp
[i
] ) :
1373 // Otherwise nodes in our document sort first
1374 ap
[i
] === preferredDoc
? -1 :
1375 bp
[i
] === preferredDoc
? 1 :
1382 Sizzle
.matches = function( expr
, elements
) {
1383 return Sizzle( expr
, null, null, elements
);
1386 Sizzle
.matchesSelector = function( elem
, expr
) {
1387 // Set document vars if needed
1388 if ( ( elem
.ownerDocument
|| elem
) !== document
) {
1389 setDocument( elem
);
1392 // Make sure that attribute selectors are quoted
1393 expr
= expr
.replace( rattributeQuotes
, "='$1']" );
1395 if ( support
.matchesSelector
&& documentIsHTML
&&
1396 ( !rbuggyMatches
|| !rbuggyMatches
.test( expr
) ) &&
1397 ( !rbuggyQSA
|| !rbuggyQSA
.test( expr
) ) ) {
1400 var ret
= matches
.call( elem
, expr
);
1402 // IE 9's matchesSelector returns false on disconnected nodes
1403 if ( ret
|| support
.disconnectedMatch
||
1404 // As well, disconnected nodes are said to be in a document
1406 elem
.document
&& elem
.document
.nodeType
!== 11 ) {
1412 return Sizzle( expr
, document
, null, [ elem
] ).length
> 0;
1415 Sizzle
.contains = function( context
, elem
) {
1416 // Set document vars if needed
1417 if ( ( context
.ownerDocument
|| context
) !== document
) {
1418 setDocument( context
);
1420 return contains( context
, elem
);
1423 Sizzle
.attr = function( elem
, name
) {
1424 // Set document vars if needed
1425 if ( ( elem
.ownerDocument
|| elem
) !== document
) {
1426 setDocument( elem
);
1429 var fn
= Expr
.attrHandle
[ name
.toLowerCase() ],
1430 // Don't get fooled by Object.prototype properties (jQuery #13807)
1431 val
= fn
&& hasOwn
.call( Expr
.attrHandle
, name
.toLowerCase() ) ?
1432 fn( elem
, name
, !documentIsHTML
) :
1435 return val
!== undefined ?
1437 support
.attributes
|| !documentIsHTML
?
1438 elem
.getAttribute( name
) :
1439 (val
= elem
.getAttributeNode(name
)) && val
.specified
?
1444 Sizzle
.error = function( msg
) {
1445 throw new Error( "Syntax error, unrecognized expression: " + msg
);
1449 * Document sorting and removing duplicates
1450 * @param {ArrayLike} results
1452 Sizzle
.uniqueSort = function( results
) {
1458 // Unless we *know* we can detect duplicates, assume their presence
1459 hasDuplicate
= !support
.detectDuplicates
;
1460 sortInput
= !support
.sortStable
&& results
.slice( 0 );
1461 results
.sort( sortOrder
);
1463 if ( hasDuplicate
) {
1464 while ( (elem
= results
[i
++]) ) {
1465 if ( elem
=== results
[ i
] ) {
1466 j
= duplicates
.push( i
);
1470 results
.splice( duplicates
[ j
], 1 );
1474 // Clear input after sorting to release objects
1475 // See https://github.com/jquery/sizzle/pull/225
1482 * Utility function for retrieving the text value of an array of DOM nodes
1483 * @param {Array|Element} elem
1485 getText
= Sizzle
.getText = function( elem
) {
1489 nodeType
= elem
.nodeType
;
1492 // If no nodeType, this is expected to be an array
1493 while ( (node
= elem
[i
++]) ) {
1494 // Do not traverse comment nodes
1495 ret
+= getText( node
);
1497 } else if ( nodeType
=== 1 || nodeType
=== 9 || nodeType
=== 11 ) {
1498 // Use textContent for elements
1499 // innerText usage removed for consistency of new lines (jQuery #11153)
1500 if ( typeof elem
.textContent
=== "string" ) {
1501 return elem
.textContent
;
1503 // Traverse its children
1504 for ( elem
= elem
.firstChild
; elem
; elem
= elem
.nextSibling
) {
1505 ret
+= getText( elem
);
1508 } else if ( nodeType
=== 3 || nodeType
=== 4 ) {
1509 return elem
.nodeValue
;
1511 // Do not include comment or processing instruction nodes
1516 Expr
= Sizzle
.selectors
= {
1518 // Can be adjusted by the user
1521 createPseudo: markFunction
,
1530 ">": { dir: "parentNode", first: true },
1531 " ": { dir: "parentNode" },
1532 "+": { dir: "previousSibling", first: true },
1533 "~": { dir: "previousSibling" }
1537 "ATTR": function( match
) {
1538 match
[1] = match
[1].replace( runescape
, funescape
);
1540 // Move the given value to match[3] whether quoted or unquoted
1541 match
[3] = ( match
[3] || match
[4] || match
[5] || "" ).replace( runescape
, funescape
);
1543 if ( match
[2] === "~=" ) {
1544 match
[3] = " " + match
[3] + " ";
1547 return match
.slice( 0, 4 );
1550 "CHILD": function( match
) {
1551 /* matches from matchExpr["CHILD"]
1552 1 type (only|nth|...)
1553 2 what (child|of-type)
1554 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
1555 4 xn-component of xn+y argument ([+-]?\d*n|)
1556 5 sign of xn-component
1558 7 sign of y-component
1561 match
[1] = match
[1].toLowerCase();
1563 if ( match
[1].slice( 0, 3 ) === "nth" ) {
1564 // nth-* requires argument
1566 Sizzle
.error( match
[0] );
1569 // numeric x and y parameters for Expr.filter.CHILD
1570 // remember that false/true cast respectively to 0/1
1571 match
[4] = +( match
[4] ? match
[5] + (match
[6] || 1) : 2 * ( match
[3] === "even" || match
[3] === "odd" ) );
1572 match
[5] = +( ( match
[7] + match
[8] ) || match
[3] === "odd" );
1574 // other types prohibit arguments
1575 } else if ( match
[3] ) {
1576 Sizzle
.error( match
[0] );
1582 "PSEUDO": function( match
) {
1584 unquoted
= !match
[6] && match
[2];
1586 if ( matchExpr
["CHILD"].test( match
[0] ) ) {
1590 // Accept quoted arguments as-is
1592 match
[2] = match
[4] || match
[5] || "";
1594 // Strip excess characters from unquoted arguments
1595 } else if ( unquoted
&& rpseudo
.test( unquoted
) &&
1596 // Get excess from tokenize (recursively)
1597 (excess
= tokenize( unquoted
, true )) &&
1598 // advance to the next closing parenthesis
1599 (excess
= unquoted
.indexOf( ")", unquoted
.length
- excess
) - unquoted
.length
) ) {
1601 // excess is a negative index
1602 match
[0] = match
[0].slice( 0, excess
);
1603 match
[2] = unquoted
.slice( 0, excess
);
1606 // Return only captures needed by the pseudo filter method (type and argument)
1607 return match
.slice( 0, 3 );
1613 "TAG": function( nodeNameSelector
) {
1614 var nodeName
= nodeNameSelector
.replace( runescape
, funescape
).toLowerCase();
1615 return nodeNameSelector
=== "*" ?
1616 function() { return true; } :
1618 return elem
.nodeName
&& elem
.nodeName
.toLowerCase() === nodeName
;
1622 "CLASS": function( className
) {
1623 var pattern
= classCache
[ className
+ " " ];
1626 (pattern
= new RegExp( "(^|" + whitespace
+ ")" + className
+ "(" + whitespace
+ "|$)" )) &&
1627 classCache( className
, function( elem
) {
1628 return pattern
.test( typeof elem
.className
=== "string" && elem
.className
|| typeof elem
.getAttribute
!== strundefined
&& elem
.getAttribute("class") || "" );
1632 "ATTR": function( name
, operator
, check
) {
1633 return function( elem
) {
1634 var result
= Sizzle
.attr( elem
, name
);
1636 if ( result
== null ) {
1637 return operator
=== "!=";
1645 return operator
=== "=" ? result
=== check :
1646 operator
=== "!=" ? result
!== check :
1647 operator
=== "^=" ? check
&& result
.indexOf( check
) === 0 :
1648 operator
=== "*=" ? check
&& result
.indexOf( check
) > -1 :
1649 operator
=== "$=" ? check
&& result
.slice( -check
.length
) === check :
1650 operator
=== "~=" ? ( " " + result
+ " " ).indexOf( check
) > -1 :
1651 operator
=== "|=" ? result
=== check
|| result
.slice( 0, check
.length
+ 1 ) === check
+ "-" :
1656 "CHILD": function( type
, what
, argument
, first
, last
) {
1657 var simple
= type
.slice( 0, 3 ) !== "nth",
1658 forward
= type
.slice( -4 ) !== "last",
1659 ofType
= what
=== "of-type";
1661 return first
=== 1 && last
=== 0 ?
1663 // Shortcut for :nth-*(n)
1665 return !!elem
.parentNode
;
1668 function( elem
, context
, xml
) {
1669 var cache
, outerCache
, node
, diff
, nodeIndex
, start
,
1670 dir
= simple
!== forward
? "nextSibling" : "previousSibling",
1671 parent
= elem
.parentNode
,
1672 name
= ofType
&& elem
.nodeName
.toLowerCase(),
1673 useCache
= !xml
&& !ofType
;
1677 // :(first|last|only)-(child|of-type)
1681 while ( (node
= node
[ dir
]) ) {
1682 if ( ofType
? node
.nodeName
.toLowerCase() === name : node
.nodeType
=== 1 ) {
1686 // Reverse direction for :only-* (if we haven't yet done so)
1687 start
= dir
= type
=== "only" && !start
&& "nextSibling";
1692 start
= [ forward
? parent
.firstChild : parent
.lastChild
];
1694 // non-xml :nth-child(...) stores cache data on `parent`
1695 if ( forward
&& useCache
) {
1696 // Seek `elem` from a previously-cached index
1697 outerCache
= parent
[ expando
] || (parent
[ expando
] = {});
1698 cache
= outerCache
[ type
] || [];
1699 nodeIndex
= cache
[0] === dirruns
&& cache
[1];
1700 diff
= cache
[0] === dirruns
&& cache
[2];
1701 node
= nodeIndex
&& parent
.childNodes
[ nodeIndex
];
1703 while ( (node
= ++nodeIndex
&& node
&& node
[ dir
] ||
1705 // Fallback to seeking `elem` from the start
1706 (diff
= nodeIndex
= 0) || start
.pop()) ) {
1708 // When found, cache indexes on `parent` and break
1709 if ( node
.nodeType
=== 1 && ++diff
&& node
=== elem
) {
1710 outerCache
[ type
] = [ dirruns
, nodeIndex
, diff
];
1715 // Use previously-cached element index if available
1716 } else if ( useCache
&& (cache
= (elem
[ expando
] || (elem
[ expando
] = {}))[ type
]) && cache
[0] === dirruns
) {
1719 // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
1721 // Use the same loop as above to seek `elem` from the start
1722 while ( (node
= ++nodeIndex
&& node
&& node
[ dir
] ||
1723 (diff
= nodeIndex
= 0) || start
.pop()) ) {
1725 if ( ( ofType
? node
.nodeName
.toLowerCase() === name : node
.nodeType
=== 1 ) && ++diff
) {
1726 // Cache the index of each encountered element
1728 (node
[ expando
] || (node
[ expando
] = {}))[ type
] = [ dirruns
, diff
];
1731 if ( node
=== elem
) {
1738 // Incorporate the offset, then check against cycle size
1740 return diff
=== first
|| ( diff
% first
=== 0 && diff
/ first
>= 0 );
1745 "PSEUDO": function( pseudo
, argument
) {
1746 // pseudo-class names are case-insensitive
1747 // http://www.w3.org/TR/selectors/#pseudo-classes
1748 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
1749 // Remember that setFilters inherits from pseudos
1751 fn
= Expr
.pseudos
[ pseudo
] || Expr
.setFilters
[ pseudo
.toLowerCase() ] ||
1752 Sizzle
.error( "unsupported pseudo: " + pseudo
);
1754 // The user may use createPseudo to indicate that
1755 // arguments are needed to create the filter function
1756 // just as Sizzle does
1757 if ( fn
[ expando
] ) {
1758 return fn( argument
);
1761 // But maintain support for old signatures
1762 if ( fn
.length
> 1 ) {
1763 args
= [ pseudo
, pseudo
, "", argument
];
1764 return Expr
.setFilters
.hasOwnProperty( pseudo
.toLowerCase() ) ?
1765 markFunction(function( seed
, matches
) {
1767 matched
= fn( seed
, argument
),
1770 idx
= indexOf
.call( seed
, matched
[i
] );
1771 seed
[ idx
] = !( matches
[ idx
] = matched
[i
] );
1775 return fn( elem
, 0, args
);
1784 // Potentially complex pseudos
1785 "not": markFunction(function( selector
) {
1786 // Trim the selector passed to compile
1787 // to avoid treating leading and trailing
1788 // spaces as combinators
1791 matcher
= compile( selector
.replace( rtrim
, "$1" ) );
1793 return matcher
[ expando
] ?
1794 markFunction(function( seed
, matches
, context
, xml
) {
1796 unmatched
= matcher( seed
, null, xml
, [] ),
1799 // Match elements unmatched by `matcher`
1801 if ( (elem
= unmatched
[i
]) ) {
1802 seed
[i
] = !(matches
[i
] = elem
);
1806 function( elem
, context
, xml
) {
1808 matcher( input
, null, xml
, results
);
1809 return !results
.pop();
1813 "has": markFunction(function( selector
) {
1814 return function( elem
) {
1815 return Sizzle( selector
, elem
).length
> 0;
1819 "contains": markFunction(function( text
) {
1820 return function( elem
) {
1821 return ( elem
.textContent
|| elem
.innerText
|| getText( elem
) ).indexOf( text
) > -1;
1825 // "Whether an element is represented by a :lang() selector
1826 // is based solely on the element's language value
1827 // being equal to the identifier C,
1828 // or beginning with the identifier C immediately followed by "-".
1829 // The matching of C against the element's language value is performed case-insensitively.
1830 // The identifier C does not have to be a valid language name."
1831 // http://www.w3.org/TR/selectors/#lang-pseudo
1832 "lang": markFunction( function( lang
) {
1833 // lang value must be a valid identifier
1834 if ( !ridentifier
.test(lang
|| "") ) {
1835 Sizzle
.error( "unsupported lang: " + lang
);
1837 lang
= lang
.replace( runescape
, funescape
).toLowerCase();
1838 return function( elem
) {
1841 if ( (elemLang
= documentIsHTML
?
1843 elem
.getAttribute("xml:lang") || elem
.getAttribute("lang")) ) {
1845 elemLang
= elemLang
.toLowerCase();
1846 return elemLang
=== lang
|| elemLang
.indexOf( lang
+ "-" ) === 0;
1848 } while ( (elem
= elem
.parentNode
) && elem
.nodeType
=== 1 );
1854 "target": function( elem
) {
1855 var hash
= window
.location
&& window
.location
.hash
;
1856 return hash
&& hash
.slice( 1 ) === elem
.id
;
1859 "root": function( elem
) {
1860 return elem
=== docElem
;
1863 "focus": function( elem
) {
1864 return elem
=== document
.activeElement
&& (!document
.hasFocus
|| document
.hasFocus()) && !!(elem
.type
|| elem
.href
|| ~elem
.tabIndex
);
1867 // Boolean properties
1868 "enabled": function( elem
) {
1869 return elem
.disabled
=== false;
1872 "disabled": function( elem
) {
1873 return elem
.disabled
=== true;
1876 "checked": function( elem
) {
1877 // In CSS3, :checked should return both checked and selected elements
1878 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1879 var nodeName
= elem
.nodeName
.toLowerCase();
1880 return (nodeName
=== "input" && !!elem
.checked
) || (nodeName
=== "option" && !!elem
.selected
);
1883 "selected": function( elem
) {
1884 // Accessing this property makes selected-by-default
1885 // options in Safari work properly
1886 if ( elem
.parentNode
) {
1887 elem
.parentNode
.selectedIndex
;
1890 return elem
.selected
=== true;
1894 "empty": function( elem
) {
1895 // http://www.w3.org/TR/selectors/#empty-pseudo
1896 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
1897 // but not by others (comment: 8; processing instruction: 7; etc.)
1898 // nodeType < 6 works because attributes (2) do not appear as children
1899 for ( elem
= elem
.firstChild
; elem
; elem
= elem
.nextSibling
) {
1900 if ( elem
.nodeType
< 6 ) {
1907 "parent": function( elem
) {
1908 return !Expr
.pseudos
["empty"]( elem
);
1911 // Element/input types
1912 "header": function( elem
) {
1913 return rheader
.test( elem
.nodeName
);
1916 "input": function( elem
) {
1917 return rinputs
.test( elem
.nodeName
);
1920 "button": function( elem
) {
1921 var name
= elem
.nodeName
.toLowerCase();
1922 return name
=== "input" && elem
.type
=== "button" || name
=== "button";
1925 "text": function( elem
) {
1927 return elem
.nodeName
.toLowerCase() === "input" &&
1928 elem
.type
=== "text" &&
1931 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
1932 ( (attr
= elem
.getAttribute("type")) == null || attr
.toLowerCase() === "text" );
1935 // Position-in-collection
1936 "first": createPositionalPseudo(function() {
1940 "last": createPositionalPseudo(function( matchIndexes
, length
) {
1941 return [ length
- 1 ];
1944 "eq": createPositionalPseudo(function( matchIndexes
, length
, argument
) {
1945 return [ argument
< 0 ? argument
+ length : argument
];
1948 "even": createPositionalPseudo(function( matchIndexes
, length
) {
1950 for ( ; i
< length
; i
+= 2 ) {
1951 matchIndexes
.push( i
);
1953 return matchIndexes
;
1956 "odd": createPositionalPseudo(function( matchIndexes
, length
) {
1958 for ( ; i
< length
; i
+= 2 ) {
1959 matchIndexes
.push( i
);
1961 return matchIndexes
;
1964 "lt": createPositionalPseudo(function( matchIndexes
, length
, argument
) {
1965 var i
= argument
< 0 ? argument
+ length : argument
;
1966 for ( ; --i
>= 0; ) {
1967 matchIndexes
.push( i
);
1969 return matchIndexes
;
1972 "gt": createPositionalPseudo(function( matchIndexes
, length
, argument
) {
1973 var i
= argument
< 0 ? argument
+ length : argument
;
1974 for ( ; ++i
< length
; ) {
1975 matchIndexes
.push( i
);
1977 return matchIndexes
;
1982 Expr
.pseudos
["nth"] = Expr
.pseudos
["eq"];
1984 // Add button/input type pseudos
1985 for ( i
in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
1986 Expr
.pseudos
[ i
] = createInputPseudo( i
);
1988 for ( i
in { submit: true, reset: true } ) {
1989 Expr
.pseudos
[ i
] = createButtonPseudo( i
);
1992 // Easy API for creating new setFilters
1993 function setFilters() {}
1994 setFilters
.prototype = Expr
.filters
= Expr
.pseudos
;
1995 Expr
.setFilters
= new setFilters();
1997 tokenize
= Sizzle
.tokenize = function( selector
, parseOnly
) {
1998 var matched
, match
, tokens
, type
,
1999 soFar
, groups
, preFilters
,
2000 cached
= tokenCache
[ selector
+ " " ];
2003 return parseOnly
? 0 : cached
.slice( 0 );
2008 preFilters
= Expr
.preFilter
;
2012 // Comma and first run
2013 if ( !matched
|| (match
= rcomma
.exec( soFar
)) ) {
2015 // Don't consume trailing commas as valid
2016 soFar
= soFar
.slice( match
[0].length
) || soFar
;
2018 groups
.push( (tokens
= []) );
2024 if ( (match
= rcombinators
.exec( soFar
)) ) {
2025 matched
= match
.shift();
2028 // Cast descendant combinators to space
2029 type: match
[0].replace( rtrim
, " " )
2031 soFar
= soFar
.slice( matched
.length
);
2035 for ( type
in Expr
.filter
) {
2036 if ( (match
= matchExpr
[ type
].exec( soFar
)) && (!preFilters
[ type
] ||
2037 (match
= preFilters
[ type
]( match
))) ) {
2038 matched
= match
.shift();
2044 soFar
= soFar
.slice( matched
.length
);
2053 // Return the length of the invalid excess
2054 // if we're just parsing
2055 // Otherwise, throw an error or return tokens
2059 Sizzle
.error( selector
) :
2061 tokenCache( selector
, groups
).slice( 0 );
2064 function toSelector( tokens
) {
2066 len
= tokens
.length
,
2068 for ( ; i
< len
; i
++ ) {
2069 selector
+= tokens
[i
].value
;
2074 function addCombinator( matcher
, combinator
, base
) {
2075 var dir
= combinator
.dir
,
2076 checkNonElements
= base
&& dir
=== "parentNode",
2079 return combinator
.first
?
2080 // Check against closest ancestor/preceding element
2081 function( elem
, context
, xml
) {
2082 while ( (elem
= elem
[ dir
]) ) {
2083 if ( elem
.nodeType
=== 1 || checkNonElements
) {
2084 return matcher( elem
, context
, xml
);
2089 // Check against all ancestor/preceding elements
2090 function( elem
, context
, xml
) {
2091 var oldCache
, outerCache
,
2092 newCache
= [ dirruns
, doneName
];
2094 // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
2096 while ( (elem
= elem
[ dir
]) ) {
2097 if ( elem
.nodeType
=== 1 || checkNonElements
) {
2098 if ( matcher( elem
, context
, xml
) ) {
2104 while ( (elem
= elem
[ dir
]) ) {
2105 if ( elem
.nodeType
=== 1 || checkNonElements
) {
2106 outerCache
= elem
[ expando
] || (elem
[ expando
] = {});
2107 if ( (oldCache
= outerCache
[ dir
]) &&
2108 oldCache
[ 0 ] === dirruns
&& oldCache
[ 1 ] === doneName
) {
2110 // Assign to newCache so results back-propagate to previous elements
2111 return (newCache
[ 2 ] = oldCache
[ 2 ]);
2113 // Reuse newcache so results back-propagate to previous elements
2114 outerCache
[ dir
] = newCache
;
2116 // A match means we're done; a fail means we have to keep checking
2117 if ( (newCache
[ 2 ] = matcher( elem
, context
, xml
)) ) {
2127 function elementMatcher( matchers
) {
2128 return matchers
.length
> 1 ?
2129 function( elem
, context
, xml
) {
2130 var i
= matchers
.length
;
2132 if ( !matchers
[i
]( elem
, context
, xml
) ) {
2141 function multipleContexts( selector
, contexts
, results
) {
2143 len
= contexts
.length
;
2144 for ( ; i
< len
; i
++ ) {
2145 Sizzle( selector
, contexts
[i
], results
);
2150 function condense( unmatched
, map
, filter
, context
, xml
) {
2154 len
= unmatched
.length
,
2155 mapped
= map
!= null;
2157 for ( ; i
< len
; i
++ ) {
2158 if ( (elem
= unmatched
[i
]) ) {
2159 if ( !filter
|| filter( elem
, context
, xml
) ) {
2160 newUnmatched
.push( elem
);
2168 return newUnmatched
;
2171 function setMatcher( preFilter
, selector
, matcher
, postFilter
, postFinder
, postSelector
) {
2172 if ( postFilter
&& !postFilter
[ expando
] ) {
2173 postFilter
= setMatcher( postFilter
);
2175 if ( postFinder
&& !postFinder
[ expando
] ) {
2176 postFinder
= setMatcher( postFinder
, postSelector
);
2178 return markFunction(function( seed
, results
, context
, xml
) {
2182 preexisting
= results
.length
,
2184 // Get initial elements from seed or context
2185 elems
= seed
|| multipleContexts( selector
|| "*", context
.nodeType
? [ context
] : context
, [] ),
2187 // Prefilter to get matcher input, preserving a map for seed-results synchronization
2188 matcherIn
= preFilter
&& ( seed
|| !selector
) ?
2189 condense( elems
, preMap
, preFilter
, context
, xml
) :
2192 matcherOut
= matcher
?
2193 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
2194 postFinder
|| ( seed
? preFilter : preexisting
|| postFilter
) ?
2196 // ...intermediate processing is necessary
2199 // ...otherwise use results directly
2203 // Find primary matches
2205 matcher( matcherIn
, matcherOut
, context
, xml
);
2210 temp
= condense( matcherOut
, postMap
);
2211 postFilter( temp
, [], context
, xml
);
2213 // Un-match failing elements by moving them back to matcherIn
2216 if ( (elem
= temp
[i
]) ) {
2217 matcherOut
[ postMap
[i
] ] = !(matcherIn
[ postMap
[i
] ] = elem
);
2223 if ( postFinder
|| preFilter
) {
2225 // Get the final matcherOut by condensing this intermediate into postFinder contexts
2227 i
= matcherOut
.length
;
2229 if ( (elem
= matcherOut
[i
]) ) {
2230 // Restore matcherIn since elem is not yet a final match
2231 temp
.push( (matcherIn
[i
] = elem
) );
2234 postFinder( null, (matcherOut
= []), temp
, xml
);
2237 // Move matched elements from seed to results to keep them synchronized
2238 i
= matcherOut
.length
;
2240 if ( (elem
= matcherOut
[i
]) &&
2241 (temp
= postFinder
? indexOf
.call( seed
, elem
) : preMap
[i
]) > -1 ) {
2243 seed
[temp
] = !(results
[temp
] = elem
);
2248 // Add elements to results, through postFinder if defined
2250 matcherOut
= condense(
2251 matcherOut
=== results
?
2252 matcherOut
.splice( preexisting
, matcherOut
.length
) :
2256 postFinder( null, results
, matcherOut
, xml
);
2258 push
.apply( results
, matcherOut
);
2264 function matcherFromTokens( tokens
) {
2265 var checkContext
, matcher
, j
,
2266 len
= tokens
.length
,
2267 leadingRelative
= Expr
.relative
[ tokens
[0].type
],
2268 implicitRelative
= leadingRelative
|| Expr
.relative
[" "],
2269 i
= leadingRelative
? 1 : 0,
2271 // The foundational matcher ensures that elements are reachable from top-level context(s)
2272 matchContext
= addCombinator( function( elem
) {
2273 return elem
=== checkContext
;
2274 }, implicitRelative
, true ),
2275 matchAnyContext
= addCombinator( function( elem
) {
2276 return indexOf
.call( checkContext
, elem
) > -1;
2277 }, implicitRelative
, true ),
2278 matchers
= [ function( elem
, context
, xml
) {
2279 return ( !leadingRelative
&& ( xml
|| context
!== outermostContext
) ) || (
2280 (checkContext
= context
).nodeType
?
2281 matchContext( elem
, context
, xml
) :
2282 matchAnyContext( elem
, context
, xml
) );
2285 for ( ; i
< len
; i
++ ) {
2286 if ( (matcher
= Expr
.relative
[ tokens
[i
].type
]) ) {
2287 matchers
= [ addCombinator(elementMatcher( matchers
), matcher
) ];
2289 matcher
= Expr
.filter
[ tokens
[i
].type
].apply( null, tokens
[i
].matches
);
2291 // Return special upon seeing a positional matcher
2292 if ( matcher
[ expando
] ) {
2293 // Find the next relative operator (if any) for proper handling
2295 for ( ; j
< len
; j
++ ) {
2296 if ( Expr
.relative
[ tokens
[j
].type
] ) {
2301 i
> 1 && elementMatcher( matchers
),
2302 i
> 1 && toSelector(
2303 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
2304 tokens
.slice( 0, i
- 1 ).concat({ value: tokens
[ i
- 2 ].type
=== " " ? "*" : "" })
2305 ).replace( rtrim
, "$1" ),
2307 i
< j
&& matcherFromTokens( tokens
.slice( i
, j
) ),
2308 j
< len
&& matcherFromTokens( (tokens
= tokens
.slice( j
)) ),
2309 j
< len
&& toSelector( tokens
)
2312 matchers
.push( matcher
);
2316 return elementMatcher( matchers
);
2319 function matcherFromGroupMatchers( elementMatchers
, setMatchers
) {
2320 var bySet
= setMatchers
.length
> 0,
2321 byElement
= elementMatchers
.length
> 0,
2322 superMatcher = function( seed
, context
, xml
, results
, outermost
) {
2323 var elem
, j
, matcher
,
2326 unmatched
= seed
&& [],
2328 contextBackup
= outermostContext
,
2329 // We must always have either seed elements or outermost context
2330 elems
= seed
|| byElement
&& Expr
.find
["TAG"]( "*", outermost
),
2331 // Use integer dirruns iff this is the outermost matcher
2332 dirrunsUnique
= (dirruns
+= contextBackup
== null ? 1 : Math
.random() || 0.1),
2336 outermostContext
= context
!== document
&& context
;
2339 // Add elements passing elementMatchers directly to results
2340 // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
2341 // Support: IE<9, Safari
2342 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
2343 for ( ; i
!== len
&& (elem
= elems
[i
]) != null; i
++ ) {
2344 if ( byElement
&& elem
) {
2346 while ( (matcher
= elementMatchers
[j
++]) ) {
2347 if ( matcher( elem
, context
, xml
) ) {
2348 results
.push( elem
);
2353 dirruns
= dirrunsUnique
;
2357 // Track unmatched elements for set filters
2359 // They will have gone through all possible matchers
2360 if ( (elem
= !matcher
&& elem
) ) {
2364 // Lengthen the array for every element, matched or not
2366 unmatched
.push( elem
);
2371 // Apply set filters to unmatched elements
2373 if ( bySet
&& i
!== matchedCount
) {
2375 while ( (matcher
= setMatchers
[j
++]) ) {
2376 matcher( unmatched
, setMatched
, context
, xml
);
2380 // Reintegrate element matches to eliminate the need for sorting
2381 if ( matchedCount
> 0 ) {
2383 if ( !(unmatched
[i
] || setMatched
[i
]) ) {
2384 setMatched
[i
] = pop
.call( results
);
2389 // Discard index placeholder values to get only actual matches
2390 setMatched
= condense( setMatched
);
2393 // Add matches to results
2394 push
.apply( results
, setMatched
);
2396 // Seedless set matches succeeding multiple successful matchers stipulate sorting
2397 if ( outermost
&& !seed
&& setMatched
.length
> 0 &&
2398 ( matchedCount
+ setMatchers
.length
) > 1 ) {
2400 Sizzle
.uniqueSort( results
);
2404 // Override manipulation of globals by nested matchers
2406 dirruns
= dirrunsUnique
;
2407 outermostContext
= contextBackup
;
2414 markFunction( superMatcher
) :
2418 compile
= Sizzle
.compile = function( selector
, match
/* Internal Use Only */ ) {
2421 elementMatchers
= [],
2422 cached
= compilerCache
[ selector
+ " " ];
2425 // Generate a function of recursive functions that can be used to check each element
2427 match
= tokenize( selector
);
2431 cached
= matcherFromTokens( match
[i
] );
2432 if ( cached
[ expando
] ) {
2433 setMatchers
.push( cached
);
2435 elementMatchers
.push( cached
);
2439 // Cache the compiled function
2440 cached
= compilerCache( selector
, matcherFromGroupMatchers( elementMatchers
, setMatchers
) );
2442 // Save selector and tokenization
2443 cached
.selector
= selector
;
2449 * A low-level selection function that works with Sizzle's compiled
2450 * selector functions
2451 * @param {String|Function} selector A selector or a pre-compiled
2452 * selector function built with Sizzle.compile
2453 * @param {Element} context
2454 * @param {Array} [results]
2455 * @param {Array} [seed] A set of elements to match against
2457 select
= Sizzle
.select = function( selector
, context
, results
, seed
) {
2458 var i
, tokens
, token
, type
, find
,
2459 compiled
= typeof selector
=== "function" && selector
,
2460 match
= !seed
&& tokenize( (selector
= compiled
.selector
|| selector
) );
2462 results
= results
|| [];
2464 // Try to minimize operations if there is no seed and only one group
2465 if ( match
.length
=== 1 ) {
2467 // Take a shortcut and set the context if the root selector is an ID
2468 tokens
= match
[0] = match
[0].slice( 0 );
2469 if ( tokens
.length
> 2 && (token
= tokens
[0]).type
=== "ID" &&
2470 support
.getById
&& context
.nodeType
=== 9 && documentIsHTML
&&
2471 Expr
.relative
[ tokens
[1].type
] ) {
2473 context
= ( Expr
.find
["ID"]( token
.matches
[0].replace(runescape
, funescape
), context
) || [] )[0];
2477 // Precompiled matchers will still verify ancestry, so step up a level
2478 } else if ( compiled
) {
2479 context
= context
.parentNode
;
2482 selector
= selector
.slice( tokens
.shift().value
.length
);
2485 // Fetch a seed set for right-to-left matching
2486 i
= matchExpr
["needsContext"].test( selector
) ? 0 : tokens
.length
;
2490 // Abort if we hit a combinator
2491 if ( Expr
.relative
[ (type
= token
.type
) ] ) {
2494 if ( (find
= Expr
.find
[ type
]) ) {
2495 // Search, expanding context for leading sibling combinators
2497 token
.matches
[0].replace( runescape
, funescape
),
2498 rsibling
.test( tokens
[0].type
) && testContext( context
.parentNode
) || context
2501 // If seed is empty or no tokens remain, we can return early
2502 tokens
.splice( i
, 1 );
2503 selector
= seed
.length
&& toSelector( tokens
);
2505 push
.apply( results
, seed
);
2515 // Compile and execute a filtering function if one is not provided
2516 // Provide `match` to avoid retokenization if we modified the selector above
2517 ( compiled
|| compile( selector
, match
) )(
2522 rsibling
.test( selector
) && testContext( context
.parentNode
) || context
2527 // One-time assignments
2530 support
.sortStable
= expando
.split("").sort( sortOrder
).join("") === expando
;
2532 // Support: Chrome<14
2533 // Always assume duplicates if they aren't passed to the comparison function
2534 support
.detectDuplicates
= !!hasDuplicate
;
2536 // Initialize against the default document
2539 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
2540 // Detached nodes confoundingly follow *each other*
2541 support
.sortDetached
= assert(function( div1
) {
2542 // Should return 1, but returns 4 (following)
2543 return div1
.compareDocumentPosition( document
.createElement("div") ) & 1;
2547 // Prevent attribute/property "interpolation"
2548 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
2549 if ( !assert(function( div
) {
2550 div
.innerHTML
= "<a href='#'></a>";
2551 return div
.firstChild
.getAttribute("href") === "#" ;
2553 addHandle( "type|href|height|width", function( elem
, name
, isXML
) {
2555 return elem
.getAttribute( name
, name
.toLowerCase() === "type" ? 1 : 2 );
2561 // Use defaultValue in place of getAttribute("value")
2562 if ( !support
.attributes
|| !assert(function( div
) {
2563 div
.innerHTML
= "<input/>";
2564 div
.firstChild
.setAttribute( "value", "" );
2565 return div
.firstChild
.getAttribute( "value" ) === "";
2567 addHandle( "value", function( elem
, name
, isXML
) {
2568 if ( !isXML
&& elem
.nodeName
.toLowerCase() === "input" ) {
2569 return elem
.defaultValue
;
2575 // Use getAttributeNode to fetch booleans when getAttribute lies
2576 if ( !assert(function( div
) {
2577 return div
.getAttribute("disabled") == null;
2579 addHandle( booleans
, function( elem
, name
, isXML
) {
2582 return elem
[ name
] === true ? name
.toLowerCase() :
2583 (val
= elem
.getAttributeNode( name
)) && val
.specified
?
2596 jQuery
.find
= Sizzle
;
2597 jQuery
.expr
= Sizzle
.selectors
;
2598 jQuery
.expr
[":"] = jQuery
.expr
.pseudos
;
2599 jQuery
.unique
= Sizzle
.uniqueSort
;
2600 jQuery
.text
= Sizzle
.getText
;
2601 jQuery
.isXMLDoc
= Sizzle
.isXML
;
2602 jQuery
.contains
= Sizzle
.contains
;
2606 var rneedsContext
= jQuery
.expr
.match
.needsContext
;
2608 var rsingleTag
= (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
2612 var risSimple
= /^.[^:#\[\.,]*$/;
2614 // Implement the identical functionality for filter and not
2615 function winnow( elements
, qualifier
, not
) {
2616 if ( jQuery
.isFunction( qualifier
) ) {
2617 return jQuery
.grep( elements
, function( elem
, i
) {
2619 return !!qualifier
.call( elem
, i
, elem
) !== not
;
2624 if ( qualifier
.nodeType
) {
2625 return jQuery
.grep( elements
, function( elem
) {
2626 return ( elem
=== qualifier
) !== not
;
2631 if ( typeof qualifier
=== "string" ) {
2632 if ( risSimple
.test( qualifier
) ) {
2633 return jQuery
.filter( qualifier
, elements
, not
);
2636 qualifier
= jQuery
.filter( qualifier
, elements
);
2639 return jQuery
.grep( elements
, function( elem
) {
2640 return ( indexOf
.call( qualifier
, elem
) >= 0 ) !== not
;
2644 jQuery
.filter = function( expr
, elems
, not
) {
2645 var elem
= elems
[ 0 ];
2648 expr
= ":not(" + expr
+ ")";
2651 return elems
.length
=== 1 && elem
.nodeType
=== 1 ?
2652 jQuery
.find
.matchesSelector( elem
, expr
) ? [ elem
] : [] :
2653 jQuery
.find
.matches( expr
, jQuery
.grep( elems
, function( elem
) {
2654 return elem
.nodeType
=== 1;
2659 find: function( selector
) {
2665 if ( typeof selector
!== "string" ) {
2666 return this.pushStack( jQuery( selector
).filter(function() {
2667 for ( i
= 0; i
< len
; i
++ ) {
2668 if ( jQuery
.contains( self
[ i
], this ) ) {
2675 for ( i
= 0; i
< len
; i
++ ) {
2676 jQuery
.find( selector
, self
[ i
], ret
);
2679 // Needed because $( selector, context ) becomes $( context ).find( selector )
2680 ret
= this.pushStack( len
> 1 ? jQuery
.unique( ret
) : ret
);
2681 ret
.selector
= this.selector
? this.selector
+ " " + selector : selector
;
2684 filter: function( selector
) {
2685 return this.pushStack( winnow(this, selector
|| [], false) );
2687 not: function( selector
) {
2688 return this.pushStack( winnow(this, selector
|| [], true) );
2690 is: function( selector
) {
2694 // If this is a positional/relative selector, check membership in the returned set
2695 // so $("p:first").is("p:last") won't return true for a doc with two "p".
2696 typeof selector
=== "string" && rneedsContext
.test( selector
) ?
2697 jQuery( selector
) :
2705 // Initialize a jQuery object
2708 // A central reference to the root jQuery(document)
2711 // A simple way to check for HTML strings
2712 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
2713 // Strict HTML recognition (#11290: must start with <)
2714 rquickExpr
= /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
2716 init
= jQuery
.fn
.init = function( selector
, context
) {
2719 // HANDLE: $(""), $(null), $(undefined), $(false)
2724 // Handle HTML strings
2725 if ( typeof selector
=== "string" ) {
2726 if ( selector
[0] === "<" && selector
[ selector
.length
- 1 ] === ">" && selector
.length
>= 3 ) {
2727 // Assume that strings that start and end with <> are HTML and skip the regex check
2728 match
= [ null, selector
, null ];
2731 match
= rquickExpr
.exec( selector
);
2734 // Match html or make sure no context is specified for #id
2735 if ( match
&& (match
[1] || !context
) ) {
2737 // HANDLE: $(html) -> $(array)
2739 context
= context
instanceof jQuery
? context
[0] : context
;
2741 // scripts is true for back-compat
2742 // Intentionally let the error be thrown if parseHTML is not present
2743 jQuery
.merge( this, jQuery
.parseHTML(
2745 context
&& context
.nodeType
? context
.ownerDocument
|| context : document
,
2749 // HANDLE: $(html, props)
2750 if ( rsingleTag
.test( match
[1] ) && jQuery
.isPlainObject( context
) ) {
2751 for ( match
in context
) {
2752 // Properties of context are called as methods if possible
2753 if ( jQuery
.isFunction( this[ match
] ) ) {
2754 this[ match
]( context
[ match
] );
2756 // ...and otherwise set as attributes
2758 this.attr( match
, context
[ match
] );
2767 elem
= document
.getElementById( match
[2] );
2769 // Check parentNode to catch when Blackberry 4.6 returns
2770 // nodes that are no longer in the document #6963
2771 if ( elem
&& elem
.parentNode
) {
2772 // Inject the element directly into the jQuery object
2777 this.context
= document
;
2778 this.selector
= selector
;
2782 // HANDLE: $(expr, $(...))
2783 } else if ( !context
|| context
.jquery
) {
2784 return ( context
|| rootjQuery
).find( selector
);
2786 // HANDLE: $(expr, context)
2787 // (which is just equivalent to: $(context).find(expr)
2789 return this.constructor( context
).find( selector
);
2792 // HANDLE: $(DOMElement)
2793 } else if ( selector
.nodeType
) {
2794 this.context
= this[0] = selector
;
2798 // HANDLE: $(function)
2799 // Shortcut for document ready
2800 } else if ( jQuery
.isFunction( selector
) ) {
2801 return typeof rootjQuery
.ready
!== "undefined" ?
2802 rootjQuery
.ready( selector
) :
2803 // Execute immediately if ready is not present
2807 if ( selector
.selector
!== undefined ) {
2808 this.selector
= selector
.selector
;
2809 this.context
= selector
.context
;
2812 return jQuery
.makeArray( selector
, this );
2815 // Give the init function the jQuery prototype for later instantiation
2816 init
.prototype = jQuery
.fn
;
2818 // Initialize central reference
2819 rootjQuery
= jQuery( document
);
2822 var rparentsprev
= /^(?:parents|prev(?:Until|All))/,
2823 // methods guaranteed to produce a unique set when starting from a unique set
2824 guaranteedUnique
= {
2832 dir: function( elem
, dir
, until
) {
2834 truncate
= until
!== undefined;
2836 while ( (elem
= elem
[ dir
]) && elem
.nodeType
!== 9 ) {
2837 if ( elem
.nodeType
=== 1 ) {
2838 if ( truncate
&& jQuery( elem
).is( until
) ) {
2841 matched
.push( elem
);
2847 sibling: function( n
, elem
) {
2850 for ( ; n
; n
= n
.nextSibling
) {
2851 if ( n
.nodeType
=== 1 && n
!== elem
) {
2861 has: function( target
) {
2862 var targets
= jQuery( target
, this ),
2865 return this.filter(function() {
2867 for ( ; i
< l
; i
++ ) {
2868 if ( jQuery
.contains( this, targets
[i
] ) ) {
2875 closest: function( selectors
, context
) {
2880 pos
= rneedsContext
.test( selectors
) || typeof selectors
!== "string" ?
2881 jQuery( selectors
, context
|| this.context
) :
2884 for ( ; i
< l
; i
++ ) {
2885 for ( cur
= this[i
]; cur
&& cur
!== context
; cur
= cur
.parentNode
) {
2886 // Always skip document fragments
2887 if ( cur
.nodeType
< 11 && (pos
?
2888 pos
.index(cur
) > -1 :
2890 // Don't pass non-elements to Sizzle
2891 cur
.nodeType
=== 1 &&
2892 jQuery
.find
.matchesSelector(cur
, selectors
)) ) {
2894 matched
.push( cur
);
2900 return this.pushStack( matched
.length
> 1 ? jQuery
.unique( matched
) : matched
);
2903 // Determine the position of an element within
2904 // the matched set of elements
2905 index: function( elem
) {
2907 // No argument, return index in parent
2909 return ( this[ 0 ] && this[ 0 ].parentNode
) ? this.first().prevAll().length : -1;
2912 // index in selector
2913 if ( typeof elem
=== "string" ) {
2914 return indexOf
.call( jQuery( elem
), this[ 0 ] );
2917 // Locate the position of the desired element
2918 return indexOf
.call( this,
2920 // If it receives a jQuery object, the first element is used
2921 elem
.jquery
? elem
[ 0 ] : elem
2925 add: function( selector
, context
) {
2926 return this.pushStack(
2928 jQuery
.merge( this.get(), jQuery( selector
, context
) )
2933 addBack: function( selector
) {
2934 return this.add( selector
== null ?
2935 this.prevObject : this.prevObject
.filter(selector
)
2940 function sibling( cur
, dir
) {
2941 while ( (cur
= cur
[dir
]) && cur
.nodeType
!== 1 ) {}
2946 parent: function( elem
) {
2947 var parent
= elem
.parentNode
;
2948 return parent
&& parent
.nodeType
!== 11 ? parent : null;
2950 parents: function( elem
) {
2951 return jQuery
.dir( elem
, "parentNode" );
2953 parentsUntil: function( elem
, i
, until
) {
2954 return jQuery
.dir( elem
, "parentNode", until
);
2956 next: function( elem
) {
2957 return sibling( elem
, "nextSibling" );
2959 prev: function( elem
) {
2960 return sibling( elem
, "previousSibling" );
2962 nextAll: function( elem
) {
2963 return jQuery
.dir( elem
, "nextSibling" );
2965 prevAll: function( elem
) {
2966 return jQuery
.dir( elem
, "previousSibling" );
2968 nextUntil: function( elem
, i
, until
) {
2969 return jQuery
.dir( elem
, "nextSibling", until
);
2971 prevUntil: function( elem
, i
, until
) {
2972 return jQuery
.dir( elem
, "previousSibling", until
);
2974 siblings: function( elem
) {
2975 return jQuery
.sibling( ( elem
.parentNode
|| {} ).firstChild
, elem
);
2977 children: function( elem
) {
2978 return jQuery
.sibling( elem
.firstChild
);
2980 contents: function( elem
) {
2981 return elem
.contentDocument
|| jQuery
.merge( [], elem
.childNodes
);
2983 }, function( name
, fn
) {
2984 jQuery
.fn
[ name
] = function( until
, selector
) {
2985 var matched
= jQuery
.map( this, fn
, until
);
2987 if ( name
.slice( -5 ) !== "Until" ) {
2991 if ( selector
&& typeof selector
=== "string" ) {
2992 matched
= jQuery
.filter( selector
, matched
);
2995 if ( this.length
> 1 ) {
2996 // Remove duplicates
2997 if ( !guaranteedUnique
[ name
] ) {
2998 jQuery
.unique( matched
);
3001 // Reverse order for parents* and prev-derivatives
3002 if ( rparentsprev
.test( name
) ) {
3007 return this.pushStack( matched
);
3010 var rnotwhite
= (/\S+/g);
3014 // String to Object options format cache
3015 var optionsCache
= {};
3017 // Convert String-formatted options into Object-formatted ones and store in cache
3018 function createOptions( options
) {
3019 var object
= optionsCache
[ options
] = {};
3020 jQuery
.each( options
.match( rnotwhite
) || [], function( _
, flag
) {
3021 object
[ flag
] = true;
3027 * Create a callback list using the following parameters:
3029 * options: an optional list of space-separated options that will change how
3030 * the callback list behaves or a more traditional option object
3032 * By default a callback list will act like an event callback list and can be
3033 * "fired" multiple times.
3037 * once: will ensure the callback list can only be fired once (like a Deferred)
3039 * memory: will keep track of previous values and will call any callback added
3040 * after the list has been fired right away with the latest "memorized"
3041 * values (like a Deferred)
3043 * unique: will ensure a callback can only be added once (no duplicate in the list)
3045 * stopOnFalse: interrupt callings when a callback returns false
3048 jQuery
.Callbacks = function( options
) {
3050 // Convert options from String-formatted to Object-formatted if needed
3051 // (we check in cache first)
3052 options
= typeof options
=== "string" ?
3053 ( optionsCache
[ options
] || createOptions( options
) ) :
3054 jQuery
.extend( {}, options
);
3056 var // Last fire value (for non-forgettable lists)
3058 // Flag to know if list was already fired
3060 // Flag to know if list is currently firing
3062 // First callback to fire (used internally by add and fireWith)
3064 // End of the loop when firing
3066 // Index of currently firing callback (modified by remove if needed)
3068 // Actual callback list
3070 // Stack of fire calls for repeatable lists
3071 stack
= !options
.once
&& [],
3073 fire = function( data
) {
3074 memory
= options
.memory
&& data
;
3076 firingIndex
= firingStart
|| 0;
3078 firingLength
= list
.length
;
3080 for ( ; list
&& firingIndex
< firingLength
; firingIndex
++ ) {
3081 if ( list
[ firingIndex
].apply( data
[ 0 ], data
[ 1 ] ) === false && options
.stopOnFalse
) {
3082 memory
= false; // To prevent further calls using add
3089 if ( stack
.length
) {
3090 fire( stack
.shift() );
3092 } else if ( memory
) {
3099 // Actual Callbacks object
3101 // Add a callback or a collection of callbacks to the list
3104 // First, we save the current length
3105 var start
= list
.length
;
3106 (function add( args
) {
3107 jQuery
.each( args
, function( _
, arg
) {
3108 var type
= jQuery
.type( arg
);
3109 if ( type
=== "function" ) {
3110 if ( !options
.unique
|| !self
.has( arg
) ) {
3113 } else if ( arg
&& arg
.length
&& type
!== "string" ) {
3114 // Inspect recursively
3119 // Do we need to add the callbacks to the
3120 // current firing batch?
3122 firingLength
= list
.length
;
3123 // With memory, if we're not firing then
3124 // we should call right away
3125 } else if ( memory
) {
3126 firingStart
= start
;
3132 // Remove a callback from the list
3133 remove: function() {
3135 jQuery
.each( arguments
, function( _
, arg
) {
3137 while ( ( index
= jQuery
.inArray( arg
, list
, index
) ) > -1 ) {
3138 list
.splice( index
, 1 );
3139 // Handle firing indexes
3141 if ( index
<= firingLength
) {
3144 if ( index
<= firingIndex
) {
3153 // Check if a given callback is in the list.
3154 // If no argument is given, return whether or not list has callbacks attached.
3155 has: function( fn
) {
3156 return fn
? jQuery
.inArray( fn
, list
) > -1 : !!( list
&& list
.length
);
3158 // Remove all callbacks from the list
3164 // Have the list do nothing anymore
3165 disable: function() {
3166 list
= stack
= memory
= undefined;
3170 disabled: function() {
3173 // Lock the list in its current state
3182 locked: function() {
3185 // Call all callbacks with the given context and arguments
3186 fireWith: function( context
, args
) {
3187 if ( list
&& ( !fired
|| stack
) ) {
3189 args
= [ context
, args
.slice
? args
.slice() : args
];
3198 // Call all the callbacks with the given arguments
3200 self
.fireWith( this, arguments
);
3203 // To know if the callbacks have already been called at least once
3215 Deferred: function( func
) {
3217 // action, add listener, listener list, final state
3218 [ "resolve", "done", jQuery
.Callbacks("once memory"), "resolved" ],
3219 [ "reject", "fail", jQuery
.Callbacks("once memory"), "rejected" ],
3220 [ "notify", "progress", jQuery
.Callbacks("memory") ]
3227 always: function() {
3228 deferred
.done( arguments
).fail( arguments
);
3231 then: function( /* fnDone, fnFail, fnProgress */ ) {
3232 var fns
= arguments
;
3233 return jQuery
.Deferred(function( newDefer
) {
3234 jQuery
.each( tuples
, function( i
, tuple
) {
3235 var fn
= jQuery
.isFunction( fns
[ i
] ) && fns
[ i
];
3236 // deferred[ done | fail | progress ] for forwarding actions to newDefer
3237 deferred
[ tuple
[1] ](function() {
3238 var returned
= fn
&& fn
.apply( this, arguments
);
3239 if ( returned
&& jQuery
.isFunction( returned
.promise
) ) {
3241 .done( newDefer
.resolve
)
3242 .fail( newDefer
.reject
)
3243 .progress( newDefer
.notify
);
3245 newDefer
[ tuple
[ 0 ] + "With" ]( this === promise
? newDefer
.promise() : this, fn
? [ returned
] : arguments
);
3252 // Get a promise for this deferred
3253 // If obj is provided, the promise aspect is added to the object
3254 promise: function( obj
) {
3255 return obj
!= null ? jQuery
.extend( obj
, promise
) : promise
;
3260 // Keep pipe for back-compat
3261 promise
.pipe
= promise
.then
;
3263 // Add list-specific methods
3264 jQuery
.each( tuples
, function( i
, tuple
) {
3265 var list
= tuple
[ 2 ],
3266 stateString
= tuple
[ 3 ];
3268 // promise[ done | fail | progress ] = list.add
3269 promise
[ tuple
[1] ] = list
.add
;
3272 if ( stateString
) {
3273 list
.add(function() {
3274 // state = [ resolved | rejected ]
3275 state
= stateString
;
3277 // [ reject_list | resolve_list ].disable; progress_list.lock
3278 }, tuples
[ i
^ 1 ][ 2 ].disable
, tuples
[ 2 ][ 2 ].lock
);
3281 // deferred[ resolve | reject | notify ]
3282 deferred
[ tuple
[0] ] = function() {
3283 deferred
[ tuple
[0] + "With" ]( this === deferred
? promise : this, arguments
);
3286 deferred
[ tuple
[0] + "With" ] = list
.fireWith
;
3289 // Make the deferred a promise
3290 promise
.promise( deferred
);
3292 // Call given func if any
3294 func
.call( deferred
, deferred
);
3302 when: function( subordinate
/* , ..., subordinateN */ ) {
3304 resolveValues
= slice
.call( arguments
),
3305 length
= resolveValues
.length
,
3307 // the count of uncompleted subordinates
3308 remaining
= length
!== 1 || ( subordinate
&& jQuery
.isFunction( subordinate
.promise
) ) ? length : 0,
3310 // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
3311 deferred
= remaining
=== 1 ? subordinate : jQuery
.Deferred(),
3313 // Update function for both resolve and progress values
3314 updateFunc = function( i
, contexts
, values
) {
3315 return function( value
) {
3316 contexts
[ i
] = this;
3317 values
[ i
] = arguments
.length
> 1 ? slice
.call( arguments
) : value
;
3318 if ( values
=== progressValues
) {
3319 deferred
.notifyWith( contexts
, values
);
3320 } else if ( !( --remaining
) ) {
3321 deferred
.resolveWith( contexts
, values
);
3326 progressValues
, progressContexts
, resolveContexts
;
3328 // add listeners to Deferred subordinates; treat others as resolved
3330 progressValues
= new Array( length
);
3331 progressContexts
= new Array( length
);
3332 resolveContexts
= new Array( length
);
3333 for ( ; i
< length
; i
++ ) {
3334 if ( resolveValues
[ i
] && jQuery
.isFunction( resolveValues
[ i
].promise
) ) {
3335 resolveValues
[ i
].promise()
3336 .done( updateFunc( i
, resolveContexts
, resolveValues
) )
3337 .fail( deferred
.reject
)
3338 .progress( updateFunc( i
, progressContexts
, progressValues
) );
3345 // if we're not waiting on anything, resolve the master
3347 deferred
.resolveWith( resolveContexts
, resolveValues
);
3350 return deferred
.promise();
3355 // The deferred used on DOM ready
3358 jQuery
.fn
.ready = function( fn
) {
3360 jQuery
.ready
.promise().done( fn
);
3366 // Is the DOM ready to be used? Set to true once it occurs.
3369 // A counter to track how many items to wait for before
3370 // the ready event fires. See #6781
3373 // Hold (or release) the ready event
3374 holdReady: function( hold
) {
3378 jQuery
.ready( true );
3382 // Handle when the DOM is ready
3383 ready: function( wait
) {
3385 // Abort if there are pending holds or we're already ready
3386 if ( wait
=== true ? --jQuery
.readyWait : jQuery
.isReady
) {
3390 // Remember that the DOM is ready
3391 jQuery
.isReady
= true;
3393 // If a normal DOM Ready event fired, decrement, and wait if need be
3394 if ( wait
!== true && --jQuery
.readyWait
> 0 ) {
3398 // If there are functions bound, to execute
3399 readyList
.resolveWith( document
, [ jQuery
] );
3401 // Trigger any bound ready events
3402 if ( jQuery
.fn
.triggerHandler
) {
3403 jQuery( document
).triggerHandler( "ready" );
3404 jQuery( document
).off( "ready" );
3410 * The ready event handler and self cleanup method
3412 function completed() {
3413 document
.removeEventListener( "DOMContentLoaded", completed
, false );
3414 window
.removeEventListener( "load", completed
, false );
3418 jQuery
.ready
.promise = function( obj
) {
3421 readyList
= jQuery
.Deferred();
3423 // Catch cases where $(document).ready() is called after the browser event has already occurred.
3424 // we once tried to use readyState "interactive" here, but it caused issues like the one
3425 // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
3426 if ( document
.readyState
=== "complete" ) {
3427 // Handle it asynchronously to allow scripts the opportunity to delay ready
3428 setTimeout( jQuery
.ready
);
3432 // Use the handy event callback
3433 document
.addEventListener( "DOMContentLoaded", completed
, false );
3435 // A fallback to window.onload, that will always work
3436 window
.addEventListener( "load", completed
, false );
3439 return readyList
.promise( obj
);
3442 // Kick off the DOM ready check even if the user does not
3443 jQuery
.ready
.promise();
3448 // Multifunctional method to get and set values of a collection
3449 // The value/s can optionally be executed if it's a function
3450 var access
= jQuery
.access = function( elems
, fn
, key
, value
, chainable
, emptyGet
, raw
) {
3456 if ( jQuery
.type( key
) === "object" ) {
3459 jQuery
.access( elems
, fn
, i
, key
[i
], true, emptyGet
, raw
);
3463 } else if ( value
!== undefined ) {
3466 if ( !jQuery
.isFunction( value
) ) {
3471 // Bulk operations run against the entire set
3473 fn
.call( elems
, value
);
3476 // ...except when executing function values
3479 fn = function( elem
, key
, value
) {
3480 return bulk
.call( jQuery( elem
), value
);
3486 for ( ; i
< len
; i
++ ) {
3487 fn( elems
[i
], key
, raw
? value : value
.call( elems
[i
], i
, fn( elems
[i
], key
) ) );
3498 len
? fn( elems
[0], key
) : emptyGet
;
3503 * Determines whether an object can have data
3505 jQuery
.acceptData = function( owner
) {
3508 // - Node.ELEMENT_NODE
3509 // - Node.DOCUMENT_NODE
3513 return owner
.nodeType
=== 1 || owner
.nodeType
=== 9 || !( +owner
.nodeType
);
3518 // Support: Android < 4,
3519 // Old WebKit does not have Object.preventExtensions/freeze method,
3520 // return new empty object instead with no [[set]] accessor
3521 Object
.defineProperty( this.cache
= {}, 0, {
3527 this.expando
= jQuery
.expando
+ Math
.random();
3531 Data
.accepts
= jQuery
.acceptData
;
3534 key: function( owner
) {
3535 // We can accept data for non-element nodes in modern browsers,
3536 // but we should not, see #8335.
3537 // Always return the key for a frozen object.
3538 if ( !Data
.accepts( owner
) ) {
3542 var descriptor
= {},
3543 // Check if the owner object already has a cache key
3544 unlock
= owner
[ this.expando
];
3546 // If not, create one
3548 unlock
= Data
.uid
++;
3550 // Secure it in a non-enumerable, non-writable property
3552 descriptor
[ this.expando
] = { value: unlock
};
3553 Object
.defineProperties( owner
, descriptor
);
3555 // Support: Android < 4
3556 // Fallback to a less secure definition
3558 descriptor
[ this.expando
] = unlock
;
3559 jQuery
.extend( owner
, descriptor
);
3563 // Ensure the cache object
3564 if ( !this.cache
[ unlock
] ) {
3565 this.cache
[ unlock
] = {};
3570 set: function( owner
, data
, value
) {
3572 // There may be an unlock assigned to this node,
3573 // if there is no entry for this "owner", create one inline
3574 // and set the unlock as though an owner entry had always existed
3575 unlock
= this.key( owner
),
3576 cache
= this.cache
[ unlock
];
3578 // Handle: [ owner, key, value ] args
3579 if ( typeof data
=== "string" ) {
3580 cache
[ data
] = value
;
3582 // Handle: [ owner, { properties } ] args
3584 // Fresh assignments by object are shallow copied
3585 if ( jQuery
.isEmptyObject( cache
) ) {
3586 jQuery
.extend( this.cache
[ unlock
], data
);
3587 // Otherwise, copy the properties one-by-one to the cache object
3589 for ( prop
in data
) {
3590 cache
[ prop
] = data
[ prop
];
3596 get: function( owner
, key
) {
3597 // Either a valid cache is found, or will be created.
3598 // New caches will be created and the unlock returned,
3599 // allowing direct access to the newly created
3600 // empty data object. A valid owner object must be provided.
3601 var cache
= this.cache
[ this.key( owner
) ];
3603 return key
=== undefined ?
3604 cache : cache
[ key
];
3606 access: function( owner
, key
, value
) {
3608 // In cases where either:
3610 // 1. No key was specified
3611 // 2. A string key was specified, but no value provided
3613 // Take the "read" path and allow the get method to determine
3614 // which value to return, respectively either:
3616 // 1. The entire cache object
3617 // 2. The data stored at the key
3619 if ( key
=== undefined ||
3620 ((key
&& typeof key
=== "string") && value
=== undefined) ) {
3622 stored
= this.get( owner
, key
);
3624 return stored
!== undefined ?
3625 stored : this.get( owner
, jQuery
.camelCase(key
) );
3628 // [*]When the key is not a string, or both a key and value
3629 // are specified, set or extend (existing objects) with either:
3631 // 1. An object of properties
3632 // 2. A key and value
3634 this.set( owner
, key
, value
);
3636 // Since the "set" path can have two possible entry points
3637 // return the expected data based on which path was taken[*]
3638 return value
!== undefined ? value : key
;
3640 remove: function( owner
, key
) {
3642 unlock
= this.key( owner
),
3643 cache
= this.cache
[ unlock
];
3645 if ( key
=== undefined ) {
3646 this.cache
[ unlock
] = {};
3649 // Support array or space separated string of keys
3650 if ( jQuery
.isArray( key
) ) {
3651 // If "name" is an array of keys...
3652 // When data is initially created, via ("key", "val") signature,
3653 // keys will be converted to camelCase.
3654 // Since there is no way to tell _how_ a key was added, remove
3655 // both plain key and camelCase key. #12786
3656 // This will only penalize the array argument path.
3657 name
= key
.concat( key
.map( jQuery
.camelCase
) );
3659 camel
= jQuery
.camelCase( key
);
3660 // Try the string as a key before any manipulation
3661 if ( key
in cache
) {
3662 name
= [ key
, camel
];
3664 // If a key with the spaces exists, use it.
3665 // Otherwise, create an array by matching non-whitespace
3667 name
= name
in cache
?
3668 [ name
] : ( name
.match( rnotwhite
) || [] );
3674 delete cache
[ name
[ i
] ];
3678 hasData: function( owner
) {
3679 return !jQuery
.isEmptyObject(
3680 this.cache
[ owner
[ this.expando
] ] || {}
3683 discard: function( owner
) {
3684 if ( owner
[ this.expando
] ) {
3685 delete this.cache
[ owner
[ this.expando
] ];
3689 var data_priv
= new Data();
3691 var data_user
= new Data();
3696 Implementation Summary
3698 1. Enforce API surface and semantic compatibility with 1.9.x branch
3699 2. Improve the module's maintainability by reducing the storage
3700 paths to a single mechanism.
3701 3. Use the same single mechanism to support "private" and "user" data.
3702 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
3703 5. Avoid exposing implementation details on user objects (eg. expando properties)
3704 6. Provide a clear path for implementation upgrade to WeakMap in 2014
3706 var rbrace
= /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
3707 rmultiDash
= /([A-Z])/g;
3709 function dataAttr( elem
, key
, data
) {
3712 // If nothing was found internally, try to fetch any
3713 // data from the HTML5 data-* attribute
3714 if ( data
=== undefined && elem
.nodeType
=== 1 ) {
3715 name
= "data-" + key
.replace( rmultiDash
, "-$1" ).toLowerCase();
3716 data
= elem
.getAttribute( name
);
3718 if ( typeof data
=== "string" ) {
3720 data
= data
=== "true" ? true :
3721 data
=== "false" ? false :
3722 data
=== "null" ? null :
3723 // Only convert to a number if it doesn't change the string
3724 +data
+ "" === data
? +data :
3725 rbrace
.test( data
) ? jQuery
.parseJSON( data
) :
3729 // Make sure we set the data so it isn't changed later
3730 data_user
.set( elem
, key
, data
);
3739 hasData: function( elem
) {
3740 return data_user
.hasData( elem
) || data_priv
.hasData( elem
);
3743 data: function( elem
, name
, data
) {
3744 return data_user
.access( elem
, name
, data
);
3747 removeData: function( elem
, name
) {
3748 data_user
.remove( elem
, name
);
3751 // TODO: Now that all calls to _data and _removeData have been replaced
3752 // with direct calls to data_priv methods, these can be deprecated.
3753 _data: function( elem
, name
, data
) {
3754 return data_priv
.access( elem
, name
, data
);
3757 _removeData: function( elem
, name
) {
3758 data_priv
.remove( elem
, name
);
3763 data: function( key
, value
) {
3766 attrs
= elem
&& elem
.attributes
;
3769 if ( key
=== undefined ) {
3770 if ( this.length
) {
3771 data
= data_user
.get( elem
);
3773 if ( elem
.nodeType
=== 1 && !data_priv
.get( elem
, "hasDataAttrs" ) ) {
3778 // The attrs elements can be null (#14894)
3780 name
= attrs
[ i
].name
;
3781 if ( name
.indexOf( "data-" ) === 0 ) {
3782 name
= jQuery
.camelCase( name
.slice(5) );
3783 dataAttr( elem
, name
, data
[ name
] );
3787 data_priv
.set( elem
, "hasDataAttrs", true );
3794 // Sets multiple values
3795 if ( typeof key
=== "object" ) {
3796 return this.each(function() {
3797 data_user
.set( this, key
);
3801 return access( this, function( value
) {
3803 camelKey
= jQuery
.camelCase( key
);
3805 // The calling jQuery object (element matches) is not empty
3806 // (and therefore has an element appears at this[ 0 ]) and the
3807 // `value` parameter was not undefined. An empty jQuery object
3808 // will result in `undefined` for elem = this[ 0 ] which will
3809 // throw an exception if an attempt to read a data cache is made.
3810 if ( elem
&& value
=== undefined ) {
3811 // Attempt to get data from the cache
3812 // with the key as-is
3813 data
= data_user
.get( elem
, key
);
3814 if ( data
!== undefined ) {
3818 // Attempt to get data from the cache
3819 // with the key camelized
3820 data
= data_user
.get( elem
, camelKey
);
3821 if ( data
!== undefined ) {
3825 // Attempt to "discover" the data in
3826 // HTML5 custom data-* attrs
3827 data
= dataAttr( elem
, camelKey
, undefined );
3828 if ( data
!== undefined ) {
3832 // We tried really hard, but the data doesn't exist.
3837 this.each(function() {
3838 // First, attempt to store a copy or reference of any
3839 // data that might've been store with a camelCased key.
3840 var data
= data_user
.get( this, camelKey
);
3842 // For HTML5 data-* attribute interop, we have to
3843 // store property names with dashes in a camelCase form.
3844 // This might not apply to all properties...*
3845 data_user
.set( this, camelKey
, value
);
3847 // *... In the case of properties that might _actually_
3848 // have dashes, we need to also store a copy of that
3849 // unchanged property.
3850 if ( key
.indexOf("-") !== -1 && data
!== undefined ) {
3851 data_user
.set( this, key
, value
);
3854 }, null, value
, arguments
.length
> 1, null, true );
3857 removeData: function( key
) {
3858 return this.each(function() {
3859 data_user
.remove( this, key
);
3866 queue: function( elem
, type
, data
) {
3870 type
= ( type
|| "fx" ) + "queue";
3871 queue
= data_priv
.get( elem
, type
);
3873 // Speed up dequeue by getting out quickly if this is just a lookup
3875 if ( !queue
|| jQuery
.isArray( data
) ) {
3876 queue
= data_priv
.access( elem
, type
, jQuery
.makeArray(data
) );
3885 dequeue: function( elem
, type
) {
3886 type
= type
|| "fx";
3888 var queue
= jQuery
.queue( elem
, type
),
3889 startLength
= queue
.length
,
3891 hooks
= jQuery
._queueHooks( elem
, type
),
3893 jQuery
.dequeue( elem
, type
);
3896 // If the fx queue is dequeued, always remove the progress sentinel
3897 if ( fn
=== "inprogress" ) {
3904 // Add a progress sentinel to prevent the fx queue from being
3905 // automatically dequeued
3906 if ( type
=== "fx" ) {
3907 queue
.unshift( "inprogress" );
3910 // clear up the last queue stop function
3912 fn
.call( elem
, next
, hooks
);
3915 if ( !startLength
&& hooks
) {
3920 // not intended for public consumption - generates a queueHooks object, or returns the current one
3921 _queueHooks: function( elem
, type
) {
3922 var key
= type
+ "queueHooks";
3923 return data_priv
.get( elem
, key
) || data_priv
.access( elem
, key
, {
3924 empty: jQuery
.Callbacks("once memory").add(function() {
3925 data_priv
.remove( elem
, [ type
+ "queue", key
] );
3932 queue: function( type
, data
) {
3935 if ( typeof type
!== "string" ) {
3941 if ( arguments
.length
< setter
) {
3942 return jQuery
.queue( this[0], type
);
3945 return data
=== undefined ?
3947 this.each(function() {
3948 var queue
= jQuery
.queue( this, type
, data
);
3950 // ensure a hooks for this queue
3951 jQuery
._queueHooks( this, type
);
3953 if ( type
=== "fx" && queue
[0] !== "inprogress" ) {
3954 jQuery
.dequeue( this, type
);
3958 dequeue: function( type
) {
3959 return this.each(function() {
3960 jQuery
.dequeue( this, type
);
3963 clearQueue: function( type
) {
3964 return this.queue( type
|| "fx", [] );
3966 // Get a promise resolved when queues of a certain type
3967 // are emptied (fx is the type by default)
3968 promise: function( type
, obj
) {
3971 defer
= jQuery
.Deferred(),
3974 resolve = function() {
3975 if ( !( --count
) ) {
3976 defer
.resolveWith( elements
, [ elements
] );
3980 if ( typeof type
!== "string" ) {
3984 type
= type
|| "fx";
3987 tmp
= data_priv
.get( elements
[ i
], type
+ "queueHooks" );
3988 if ( tmp
&& tmp
.empty
) {
3990 tmp
.empty
.add( resolve
);
3994 return defer
.promise( obj
);
3997 var pnum
= (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source
;
3999 var cssExpand
= [ "Top", "Right", "Bottom", "Left" ];
4001 var isHidden = function( elem
, el
) {
4002 // isHidden might be called from jQuery#filter function;
4003 // in that case, element will be second argument
4005 return jQuery
.css( elem
, "display" ) === "none" || !jQuery
.contains( elem
.ownerDocument
, elem
);
4008 var rcheckableType
= (/^(?:checkbox|radio)$/i);
4013 var fragment
= document
.createDocumentFragment(),
4014 div
= fragment
.appendChild( document
.createElement( "div" ) ),
4015 input
= document
.createElement( "input" );
4017 // #11217 - WebKit loses check when the name is after the checked attribute
4018 // Support: Windows Web Apps (WWA)
4019 // `name` and `type` need .setAttribute for WWA
4020 input
.setAttribute( "type", "radio" );
4021 input
.setAttribute( "checked", "checked" );
4022 input
.setAttribute( "name", "t" );
4024 div
.appendChild( input
);
4026 // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
4027 // old WebKit doesn't clone checked state correctly in fragments
4028 support
.checkClone
= div
.cloneNode( true ).cloneNode( true ).lastChild
.checked
;
4030 // Make sure textarea (and checkbox) defaultValue is properly cloned
4031 // Support: IE9-IE11+
4032 div
.innerHTML
= "<textarea>x</textarea>";
4033 support
.noCloneChecked
= !!div
.cloneNode( true ).lastChild
.defaultValue
;
4035 var strundefined
= typeof undefined;
4039 support
.focusinBubbles
= "onfocusin" in window
;
4044 rmouseEvent
= /^(?:mouse|pointer|contextmenu)|click/,
4045 rfocusMorph
= /^(?:focusinfocus|focusoutblur)$/,
4046 rtypenamespace
= /^([^.]*)(?:\.(.+)|)$/;
4048 function returnTrue() {
4052 function returnFalse() {
4056 function safeActiveElement() {
4058 return document
.activeElement
;
4063 * Helper functions for managing events -- not part of the public interface.
4064 * Props to Dean Edwards' addEvent library for many of the ideas.
4070 add: function( elem
, types
, handler
, data
, selector
) {
4072 var handleObjIn
, eventHandle
, tmp
,
4073 events
, t
, handleObj
,
4074 special
, handlers
, type
, namespaces
, origType
,
4075 elemData
= data_priv
.get( elem
);
4077 // Don't attach events to noData or text/comment nodes (but allow plain objects)
4082 // Caller can pass in an object of custom data in lieu of the handler
4083 if ( handler
.handler
) {
4084 handleObjIn
= handler
;
4085 handler
= handleObjIn
.handler
;
4086 selector
= handleObjIn
.selector
;
4089 // Make sure that the handler has a unique ID, used to find/remove it later
4090 if ( !handler
.guid
) {
4091 handler
.guid
= jQuery
.guid
++;
4094 // Init the element's event structure and main handler, if this is the first
4095 if ( !(events
= elemData
.events
) ) {
4096 events
= elemData
.events
= {};
4098 if ( !(eventHandle
= elemData
.handle
) ) {
4099 eventHandle
= elemData
.handle = function( e
) {
4100 // Discard the second event of a jQuery.event.trigger() and
4101 // when an event is called after a page has unloaded
4102 return typeof jQuery
!== strundefined
&& jQuery
.event
.triggered
!== e
.type
?
4103 jQuery
.event
.dispatch
.apply( elem
, arguments
) : undefined;
4107 // Handle multiple events separated by a space
4108 types
= ( types
|| "" ).match( rnotwhite
) || [ "" ];
4111 tmp
= rtypenamespace
.exec( types
[t
] ) || [];
4112 type
= origType
= tmp
[1];
4113 namespaces
= ( tmp
[2] || "" ).split( "." ).sort();
4115 // There *must* be a type, no attaching namespace-only handlers
4120 // If event changes its type, use the special event handlers for the changed type
4121 special
= jQuery
.event
.special
[ type
] || {};
4123 // If selector defined, determine special event api type, otherwise given type
4124 type
= ( selector
? special
.delegateType : special
.bindType
) || type
;
4126 // Update special based on newly reset type
4127 special
= jQuery
.event
.special
[ type
] || {};
4129 // handleObj is passed to all event handlers
4130 handleObj
= jQuery
.extend({
4137 needsContext: selector
&& jQuery
.expr
.match
.needsContext
.test( selector
),
4138 namespace: namespaces
.join(".")
4141 // Init the event handler queue if we're the first
4142 if ( !(handlers
= events
[ type
]) ) {
4143 handlers
= events
[ type
] = [];
4144 handlers
.delegateCount
= 0;
4146 // Only use addEventListener if the special events handler returns false
4147 if ( !special
.setup
|| special
.setup
.call( elem
, data
, namespaces
, eventHandle
) === false ) {
4148 if ( elem
.addEventListener
) {
4149 elem
.addEventListener( type
, eventHandle
, false );
4154 if ( special
.add
) {
4155 special
.add
.call( elem
, handleObj
);
4157 if ( !handleObj
.handler
.guid
) {
4158 handleObj
.handler
.guid
= handler
.guid
;
4162 // Add to the element's handler list, delegates in front
4164 handlers
.splice( handlers
.delegateCount
++, 0, handleObj
);
4166 handlers
.push( handleObj
);
4169 // Keep track of which events have ever been used, for event optimization
4170 jQuery
.event
.global
[ type
] = true;
4175 // Detach an event or set of events from an element
4176 remove: function( elem
, types
, handler
, selector
, mappedTypes
) {
4178 var j
, origCount
, tmp
,
4179 events
, t
, handleObj
,
4180 special
, handlers
, type
, namespaces
, origType
,
4181 elemData
= data_priv
.hasData( elem
) && data_priv
.get( elem
);
4183 if ( !elemData
|| !(events
= elemData
.events
) ) {
4187 // Once for each type.namespace in types; type may be omitted
4188 types
= ( types
|| "" ).match( rnotwhite
) || [ "" ];
4191 tmp
= rtypenamespace
.exec( types
[t
] ) || [];
4192 type
= origType
= tmp
[1];
4193 namespaces
= ( tmp
[2] || "" ).split( "." ).sort();
4195 // Unbind all events (on this namespace, if provided) for the element
4197 for ( type
in events
) {
4198 jQuery
.event
.remove( elem
, type
+ types
[ t
], handler
, selector
, true );
4203 special
= jQuery
.event
.special
[ type
] || {};
4204 type
= ( selector
? special
.delegateType : special
.bindType
) || type
;
4205 handlers
= events
[ type
] || [];
4206 tmp
= tmp
[2] && new RegExp( "(^|\\.)" + namespaces
.join("\\.(?:.*\\.|)") + "(\\.|$)" );
4208 // Remove matching events
4209 origCount
= j
= handlers
.length
;
4211 handleObj
= handlers
[ j
];
4213 if ( ( mappedTypes
|| origType
=== handleObj
.origType
) &&
4214 ( !handler
|| handler
.guid
=== handleObj
.guid
) &&
4215 ( !tmp
|| tmp
.test( handleObj
.namespace ) ) &&
4216 ( !selector
|| selector
=== handleObj
.selector
|| selector
=== "**" && handleObj
.selector
) ) {
4217 handlers
.splice( j
, 1 );
4219 if ( handleObj
.selector
) {
4220 handlers
.delegateCount
--;
4222 if ( special
.remove
) {
4223 special
.remove
.call( elem
, handleObj
);
4228 // Remove generic event handler if we removed something and no more handlers exist
4229 // (avoids potential for endless recursion during removal of special event handlers)
4230 if ( origCount
&& !handlers
.length
) {
4231 if ( !special
.teardown
|| special
.teardown
.call( elem
, namespaces
, elemData
.handle
) === false ) {
4232 jQuery
.removeEvent( elem
, type
, elemData
.handle
);
4235 delete events
[ type
];
4239 // Remove the expando if it's no longer used
4240 if ( jQuery
.isEmptyObject( events
) ) {
4241 delete elemData
.handle
;
4242 data_priv
.remove( elem
, "events" );
4246 trigger: function( event
, data
, elem
, onlyHandlers
) {
4248 var i
, cur
, tmp
, bubbleType
, ontype
, handle
, special
,
4249 eventPath
= [ elem
|| document
],
4250 type
= hasOwn
.call( event
, "type" ) ? event
.type : event
,
4251 namespaces
= hasOwn
.call( event
, "namespace" ) ? event
.namespace.split(".") : [];
4253 cur
= tmp
= elem
= elem
|| document
;
4255 // Don't do events on text and comment nodes
4256 if ( elem
.nodeType
=== 3 || elem
.nodeType
=== 8 ) {
4260 // focus/blur morphs to focusin/out; ensure we're not firing them right now
4261 if ( rfocusMorph
.test( type
+ jQuery
.event
.triggered
) ) {
4265 if ( type
.indexOf(".") >= 0 ) {
4266 // Namespaced trigger; create a regexp to match event type in handle()
4267 namespaces
= type
.split(".");
4268 type
= namespaces
.shift();
4271 ontype
= type
.indexOf(":") < 0 && "on" + type
;
4273 // Caller can pass in a jQuery.Event object, Object, or just an event type string
4274 event
= event
[ jQuery
.expando
] ?
4276 new jQuery
.Event( type
, typeof event
=== "object" && event
);
4278 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
4279 event
.isTrigger
= onlyHandlers
? 2 : 3;
4280 event
.namespace = namespaces
.join(".");
4281 event
.namespace_re
= event
.namespace ?
4282 new RegExp( "(^|\\.)" + namespaces
.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
4285 // Clean up the event in case it is being reused
4286 event
.result
= undefined;
4287 if ( !event
.target
) {
4288 event
.target
= elem
;
4291 // Clone any incoming data and prepend the event, creating the handler arg list
4292 data
= data
== null ?
4294 jQuery
.makeArray( data
, [ event
] );
4296 // Allow special events to draw outside the lines
4297 special
= jQuery
.event
.special
[ type
] || {};
4298 if ( !onlyHandlers
&& special
.trigger
&& special
.trigger
.apply( elem
, data
) === false ) {
4302 // Determine event propagation path in advance, per W3C events spec (#9951)
4303 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
4304 if ( !onlyHandlers
&& !special
.noBubble
&& !jQuery
.isWindow( elem
) ) {
4306 bubbleType
= special
.delegateType
|| type
;
4307 if ( !rfocusMorph
.test( bubbleType
+ type
) ) {
4308 cur
= cur
.parentNode
;
4310 for ( ; cur
; cur
= cur
.parentNode
) {
4311 eventPath
.push( cur
);
4315 // Only add window if we got to document (e.g., not plain obj or detached DOM)
4316 if ( tmp
=== (elem
.ownerDocument
|| document
) ) {
4317 eventPath
.push( tmp
.defaultView
|| tmp
.parentWindow
|| window
);
4321 // Fire handlers on the event path
4323 while ( (cur
= eventPath
[i
++]) && !event
.isPropagationStopped() ) {
4325 event
.type
= i
> 1 ?
4327 special
.bindType
|| type
;
4330 handle
= ( data_priv
.get( cur
, "events" ) || {} )[ event
.type
] && data_priv
.get( cur
, "handle" );
4332 handle
.apply( cur
, data
);
4336 handle
= ontype
&& cur
[ ontype
];
4337 if ( handle
&& handle
.apply
&& jQuery
.acceptData( cur
) ) {
4338 event
.result
= handle
.apply( cur
, data
);
4339 if ( event
.result
=== false ) {
4340 event
.preventDefault();
4346 // If nobody prevented the default action, do it now
4347 if ( !onlyHandlers
&& !event
.isDefaultPrevented() ) {
4349 if ( (!special
._default
|| special
._default
.apply( eventPath
.pop(), data
) === false) &&
4350 jQuery
.acceptData( elem
) ) {
4352 // Call a native DOM method on the target with the same name name as the event.
4353 // Don't do default actions on window, that's where global variables be (#6170)
4354 if ( ontype
&& jQuery
.isFunction( elem
[ type
] ) && !jQuery
.isWindow( elem
) ) {
4356 // Don't re-trigger an onFOO event when we call its FOO() method
4357 tmp
= elem
[ ontype
];
4360 elem
[ ontype
] = null;
4363 // Prevent re-triggering of the same event, since we already bubbled it above
4364 jQuery
.event
.triggered
= type
;
4366 jQuery
.event
.triggered
= undefined;
4369 elem
[ ontype
] = tmp
;
4375 return event
.result
;
4378 dispatch: function( event
) {
4380 // Make a writable jQuery.Event from the native event object
4381 event
= jQuery
.event
.fix( event
);
4383 var i
, j
, ret
, matched
, handleObj
,
4385 args
= slice
.call( arguments
),
4386 handlers
= ( data_priv
.get( this, "events" ) || {} )[ event
.type
] || [],
4387 special
= jQuery
.event
.special
[ event
.type
] || {};
4389 // Use the fix-ed jQuery.Event rather than the (read-only) native event
4391 event
.delegateTarget
= this;
4393 // Call the preDispatch hook for the mapped type, and let it bail if desired
4394 if ( special
.preDispatch
&& special
.preDispatch
.call( this, event
) === false ) {
4398 // Determine handlers
4399 handlerQueue
= jQuery
.event
.handlers
.call( this, event
, handlers
);
4401 // Run delegates first; they may want to stop propagation beneath us
4403 while ( (matched
= handlerQueue
[ i
++ ]) && !event
.isPropagationStopped() ) {
4404 event
.currentTarget
= matched
.elem
;
4407 while ( (handleObj
= matched
.handlers
[ j
++ ]) && !event
.isImmediatePropagationStopped() ) {
4409 // Triggered event must either 1) have no namespace, or
4410 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
4411 if ( !event
.namespace_re
|| event
.namespace_re
.test( handleObj
.namespace ) ) {
4413 event
.handleObj
= handleObj
;
4414 event
.data
= handleObj
.data
;
4416 ret
= ( (jQuery
.event
.special
[ handleObj
.origType
] || {}).handle
|| handleObj
.handler
)
4417 .apply( matched
.elem
, args
);
4419 if ( ret
!== undefined ) {
4420 if ( (event
.result
= ret
) === false ) {
4421 event
.preventDefault();
4422 event
.stopPropagation();
4429 // Call the postDispatch hook for the mapped type
4430 if ( special
.postDispatch
) {
4431 special
.postDispatch
.call( this, event
);
4434 return event
.result
;
4437 handlers: function( event
, handlers
) {
4438 var i
, matches
, sel
, handleObj
,
4440 delegateCount
= handlers
.delegateCount
,
4443 // Find delegate handlers
4444 // Black-hole SVG <use> instance trees (#13180)
4445 // Avoid non-left-click bubbling in Firefox (#3861)
4446 if ( delegateCount
&& cur
.nodeType
&& (!event
.button
|| event
.type
!== "click") ) {
4448 for ( ; cur
!== this; cur
= cur
.parentNode
|| this ) {
4450 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
4451 if ( cur
.disabled
!== true || event
.type
!== "click" ) {
4453 for ( i
= 0; i
< delegateCount
; i
++ ) {
4454 handleObj
= handlers
[ i
];
4456 // Don't conflict with Object.prototype properties (#13203)
4457 sel
= handleObj
.selector
+ " ";
4459 if ( matches
[ sel
] === undefined ) {
4460 matches
[ sel
] = handleObj
.needsContext
?
4461 jQuery( sel
, this ).index( cur
) >= 0 :
4462 jQuery
.find( sel
, this, null, [ cur
] ).length
;
4464 if ( matches
[ sel
] ) {
4465 matches
.push( handleObj
);
4468 if ( matches
.length
) {
4469 handlerQueue
.push({ elem: cur
, handlers: matches
});
4475 // Add the remaining (directly-bound) handlers
4476 if ( delegateCount
< handlers
.length
) {
4477 handlerQueue
.push({ elem: this, handlers: handlers
.slice( delegateCount
) });
4480 return handlerQueue
;
4483 // Includes some event props shared by KeyEvent and MouseEvent
4484 props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
4489 props: "char charCode key keyCode".split(" "),
4490 filter: function( event
, original
) {
4492 // Add which for key events
4493 if ( event
.which
== null ) {
4494 event
.which
= original
.charCode
!= null ? original
.charCode : original
.keyCode
;
4502 props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
4503 filter: function( event
, original
) {
4504 var eventDoc
, doc
, body
,
4505 button
= original
.button
;
4507 // Calculate pageX/Y if missing and clientX/Y available
4508 if ( event
.pageX
== null && original
.clientX
!= null ) {
4509 eventDoc
= event
.target
.ownerDocument
|| document
;
4510 doc
= eventDoc
.documentElement
;
4511 body
= eventDoc
.body
;
4513 event
.pageX
= original
.clientX
+ ( doc
&& doc
.scrollLeft
|| body
&& body
.scrollLeft
|| 0 ) - ( doc
&& doc
.clientLeft
|| body
&& body
.clientLeft
|| 0 );
4514 event
.pageY
= original
.clientY
+ ( doc
&& doc
.scrollTop
|| body
&& body
.scrollTop
|| 0 ) - ( doc
&& doc
.clientTop
|| body
&& body
.clientTop
|| 0 );
4517 // Add which for click: 1 === left; 2 === middle; 3 === right
4518 // Note: button is not normalized, so don't use it
4519 if ( !event
.which
&& button
!== undefined ) {
4520 event
.which
= ( button
& 1 ? 1 : ( button
& 2 ? 3 : ( button
& 4 ? 2 : 0 ) ) );
4527 fix: function( event
) {
4528 if ( event
[ jQuery
.expando
] ) {
4532 // Create a writable copy of the event object and normalize some properties
4535 originalEvent
= event
,
4536 fixHook
= this.fixHooks
[ type
];
4539 this.fixHooks
[ type
] = fixHook
=
4540 rmouseEvent
.test( type
) ? this.mouseHooks :
4541 rkeyEvent
.test( type
) ? this.keyHooks :
4544 copy
= fixHook
.props
? this.props
.concat( fixHook
.props
) : this.props
;
4546 event
= new jQuery
.Event( originalEvent
);
4551 event
[ prop
] = originalEvent
[ prop
];
4554 // Support: Cordova 2.5 (WebKit) (#13255)
4555 // All events should have a target; Cordova deviceready doesn't
4556 if ( !event
.target
) {
4557 event
.target
= document
;
4560 // Support: Safari 6.0+, Chrome < 28
4561 // Target should not be a text node (#504, #13143)
4562 if ( event
.target
.nodeType
=== 3 ) {
4563 event
.target
= event
.target
.parentNode
;
4566 return fixHook
.filter
? fixHook
.filter( event
, originalEvent
) : event
;
4571 // Prevent triggered image.load events from bubbling to window.load
4575 // Fire native event if possible so blur/focus sequence is correct
4576 trigger: function() {
4577 if ( this !== safeActiveElement() && this.focus
) {
4582 delegateType: "focusin"
4585 trigger: function() {
4586 if ( this === safeActiveElement() && this.blur
) {
4591 delegateType: "focusout"
4594 // For checkbox, fire native event so checked state will be right
4595 trigger: function() {
4596 if ( this.type
=== "checkbox" && this.click
&& jQuery
.nodeName( this, "input" ) ) {
4602 // For cross-browser consistency, don't fire native .click() on links
4603 _default: function( event
) {
4604 return jQuery
.nodeName( event
.target
, "a" );
4609 postDispatch: function( event
) {
4611 // Support: Firefox 20+
4612 // Firefox doesn't alert if the returnValue field is not set.
4613 if ( event
.result
!== undefined && event
.originalEvent
) {
4614 event
.originalEvent
.returnValue
= event
.result
;
4620 simulate: function( type
, elem
, event
, bubble
) {
4621 // Piggyback on a donor event to simulate a different one.
4622 // Fake originalEvent to avoid donor's stopPropagation, but if the
4623 // simulated event prevents default then we do the same on the donor.
4624 var e
= jQuery
.extend(
4634 jQuery
.event
.trigger( e
, null, elem
);
4636 jQuery
.event
.dispatch
.call( elem
, e
);
4638 if ( e
.isDefaultPrevented() ) {
4639 event
.preventDefault();
4644 jQuery
.removeEvent = function( elem
, type
, handle
) {
4645 if ( elem
.removeEventListener
) {
4646 elem
.removeEventListener( type
, handle
, false );
4650 jQuery
.Event = function( src
, props
) {
4651 // Allow instantiation without the 'new' keyword
4652 if ( !(this instanceof jQuery
.Event
) ) {
4653 return new jQuery
.Event( src
, props
);
4657 if ( src
&& src
.type
) {
4658 this.originalEvent
= src
;
4659 this.type
= src
.type
;
4661 // Events bubbling up the document may have been marked as prevented
4662 // by a handler lower down the tree; reflect the correct value.
4663 this.isDefaultPrevented
= src
.defaultPrevented
||
4664 src
.defaultPrevented
=== undefined &&
4665 // Support: Android < 4.0
4666 src
.returnValue
=== false ?
4675 // Put explicitly provided properties onto the event object
4677 jQuery
.extend( this, props
);
4680 // Create a timestamp if incoming event doesn't have one
4681 this.timeStamp
= src
&& src
.timeStamp
|| jQuery
.now();
4684 this[ jQuery
.expando
] = true;
4687 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
4688 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
4689 jQuery
.Event
.prototype = {
4690 isDefaultPrevented: returnFalse
,
4691 isPropagationStopped: returnFalse
,
4692 isImmediatePropagationStopped: returnFalse
,
4694 preventDefault: function() {
4695 var e
= this.originalEvent
;
4697 this.isDefaultPrevented
= returnTrue
;
4699 if ( e
&& e
.preventDefault
) {
4703 stopPropagation: function() {
4704 var e
= this.originalEvent
;
4706 this.isPropagationStopped
= returnTrue
;
4708 if ( e
&& e
.stopPropagation
) {
4709 e
.stopPropagation();
4712 stopImmediatePropagation: function() {
4713 var e
= this.originalEvent
;
4715 this.isImmediatePropagationStopped
= returnTrue
;
4717 if ( e
&& e
.stopImmediatePropagation
) {
4718 e
.stopImmediatePropagation();
4721 this.stopPropagation();
4725 // Create mouseenter/leave events using mouseover/out and event-time checks
4726 // Support: Chrome 15+
4728 mouseenter: "mouseover",
4729 mouseleave: "mouseout",
4730 pointerenter: "pointerover",
4731 pointerleave: "pointerout"
4732 }, function( orig
, fix
) {
4733 jQuery
.event
.special
[ orig
] = {
4737 handle: function( event
) {
4740 related
= event
.relatedTarget
,
4741 handleObj
= event
.handleObj
;
4743 // For mousenter/leave call the handler if related is outside the target.
4744 // NB: No relatedTarget if the mouse left/entered the browser window
4745 if ( !related
|| (related
!== target
&& !jQuery
.contains( target
, related
)) ) {
4746 event
.type
= handleObj
.origType
;
4747 ret
= handleObj
.handler
.apply( this, arguments
);
4755 // Create "bubbling" focus and blur events
4756 // Support: Firefox, Chrome, Safari
4757 if ( !support
.focusinBubbles
) {
4758 jQuery
.each({ focus: "focusin", blur: "focusout" }, function( orig
, fix
) {
4760 // Attach a single capturing handler on the document while someone wants focusin/focusout
4761 var handler = function( event
) {
4762 jQuery
.event
.simulate( fix
, event
.target
, jQuery
.event
.fix( event
), true );
4765 jQuery
.event
.special
[ fix
] = {
4767 var doc
= this.ownerDocument
|| this,
4768 attaches
= data_priv
.access( doc
, fix
);
4771 doc
.addEventListener( orig
, handler
, true );
4773 data_priv
.access( doc
, fix
, ( attaches
|| 0 ) + 1 );
4775 teardown: function() {
4776 var doc
= this.ownerDocument
|| this,
4777 attaches
= data_priv
.access( doc
, fix
) - 1;
4780 doc
.removeEventListener( orig
, handler
, true );
4781 data_priv
.remove( doc
, fix
);
4784 data_priv
.access( doc
, fix
, attaches
);
4793 on: function( types
, selector
, data
, fn
, /*INTERNAL*/ one
) {
4796 // Types can be a map of types/handlers
4797 if ( typeof types
=== "object" ) {
4798 // ( types-Object, selector, data )
4799 if ( typeof selector
!== "string" ) {
4800 // ( types-Object, data )
4801 data
= data
|| selector
;
4802 selector
= undefined;
4804 for ( type
in types
) {
4805 this.on( type
, selector
, data
, types
[ type
], one
);
4810 if ( data
== null && fn
== null ) {
4813 data
= selector
= undefined;
4814 } else if ( fn
== null ) {
4815 if ( typeof selector
=== "string" ) {
4816 // ( types, selector, fn )
4820 // ( types, data, fn )
4823 selector
= undefined;
4826 if ( fn
=== false ) {
4834 fn = function( event
) {
4835 // Can use an empty set, since event contains the info
4836 jQuery().off( event
);
4837 return origFn
.apply( this, arguments
);
4839 // Use same guid so caller can remove using origFn
4840 fn
.guid
= origFn
.guid
|| ( origFn
.guid
= jQuery
.guid
++ );
4842 return this.each( function() {
4843 jQuery
.event
.add( this, types
, fn
, data
, selector
);
4846 one: function( types
, selector
, data
, fn
) {
4847 return this.on( types
, selector
, data
, fn
, 1 );
4849 off: function( types
, selector
, fn
) {
4850 var handleObj
, type
;
4851 if ( types
&& types
.preventDefault
&& types
.handleObj
) {
4852 // ( event ) dispatched jQuery.Event
4853 handleObj
= types
.handleObj
;
4854 jQuery( types
.delegateTarget
).off(
4855 handleObj
.namespace ? handleObj
.origType
+ "." + handleObj
.namespace : handleObj
.origType
,
4861 if ( typeof types
=== "object" ) {
4862 // ( types-object [, selector] )
4863 for ( type
in types
) {
4864 this.off( type
, selector
, types
[ type
] );
4868 if ( selector
=== false || typeof selector
=== "function" ) {
4871 selector
= undefined;
4873 if ( fn
=== false ) {
4876 return this.each(function() {
4877 jQuery
.event
.remove( this, types
, fn
, selector
);
4881 trigger: function( type
, data
) {
4882 return this.each(function() {
4883 jQuery
.event
.trigger( type
, data
, this );
4886 triggerHandler: function( type
, data
) {
4889 return jQuery
.event
.trigger( type
, data
, elem
, true );
4896 rxhtmlTag
= /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
4897 rtagName
= /<([\w:]+)/,
4898 rhtml
= /<|&#?\w+;/,
4899 rnoInnerhtml
= /<(?:script|style|link)/i,
4900 // checked="checked" or checked
4901 rchecked
= /checked\s*(?:[^=]|=\s*.checked.)/i,
4902 rscriptType
= /^$|\/(?:java|ecma)script/i,
4903 rscriptTypeMasked
= /^true\/(.*)/,
4904 rcleanScript
= /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
4906 // We have to close these tags to support XHTML (#13200)
4910 option: [ 1, "<select multiple='multiple'>", "</select>" ],
4912 thead: [ 1, "<table>", "</table>" ],
4913 col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
4914 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
4915 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
4917 _default: [ 0, "", "" ]
4921 wrapMap
.optgroup
= wrapMap
.option
;
4923 wrapMap
.tbody
= wrapMap
.tfoot
= wrapMap
.colgroup
= wrapMap
.caption
= wrapMap
.thead
;
4924 wrapMap
.th
= wrapMap
.td
;
4926 // Support: 1.x compatibility
4927 // Manipulating tables requires a tbody
4928 function manipulationTarget( elem
, content
) {
4929 return jQuery
.nodeName( elem
, "table" ) &&
4930 jQuery
.nodeName( content
.nodeType
!== 11 ? content : content
.firstChild
, "tr" ) ?
4932 elem
.getElementsByTagName("tbody")[0] ||
4933 elem
.appendChild( elem
.ownerDocument
.createElement("tbody") ) :
4937 // Replace/restore the type attribute of script elements for safe DOM manipulation
4938 function disableScript( elem
) {
4939 elem
.type
= (elem
.getAttribute("type") !== null) + "/" + elem
.type
;
4942 function restoreScript( elem
) {
4943 var match
= rscriptTypeMasked
.exec( elem
.type
);
4946 elem
.type
= match
[ 1 ];
4948 elem
.removeAttribute("type");
4954 // Mark scripts as having already been evaluated
4955 function setGlobalEval( elems
, refElements
) {
4959 for ( ; i
< l
; i
++ ) {
4961 elems
[ i
], "globalEval", !refElements
|| data_priv
.get( refElements
[ i
], "globalEval" )
4966 function cloneCopyEvent( src
, dest
) {
4967 var i
, l
, type
, pdataOld
, pdataCur
, udataOld
, udataCur
, events
;
4969 if ( dest
.nodeType
!== 1 ) {
4973 // 1. Copy private data: events, handlers, etc.
4974 if ( data_priv
.hasData( src
) ) {
4975 pdataOld
= data_priv
.access( src
);
4976 pdataCur
= data_priv
.set( dest
, pdataOld
);
4977 events
= pdataOld
.events
;
4980 delete pdataCur
.handle
;
4981 pdataCur
.events
= {};
4983 for ( type
in events
) {
4984 for ( i
= 0, l
= events
[ type
].length
; i
< l
; i
++ ) {
4985 jQuery
.event
.add( dest
, type
, events
[ type
][ i
] );
4991 // 2. Copy user data
4992 if ( data_user
.hasData( src
) ) {
4993 udataOld
= data_user
.access( src
);
4994 udataCur
= jQuery
.extend( {}, udataOld
);
4996 data_user
.set( dest
, udataCur
);
5000 function getAll( context
, tag
) {
5001 var ret
= context
.getElementsByTagName
? context
.getElementsByTagName( tag
|| "*" ) :
5002 context
.querySelectorAll
? context
.querySelectorAll( tag
|| "*" ) :
5005 return tag
=== undefined || tag
&& jQuery
.nodeName( context
, tag
) ?
5006 jQuery
.merge( [ context
], ret
) :
5011 function fixInput( src
, dest
) {
5012 var nodeName
= dest
.nodeName
.toLowerCase();
5014 // Fails to persist the checked state of a cloned checkbox or radio button.
5015 if ( nodeName
=== "input" && rcheckableType
.test( src
.type
) ) {
5016 dest
.checked
= src
.checked
;
5018 // Fails to return the selected option to the default selected state when cloning options
5019 } else if ( nodeName
=== "input" || nodeName
=== "textarea" ) {
5020 dest
.defaultValue
= src
.defaultValue
;
5025 clone: function( elem
, dataAndEvents
, deepDataAndEvents
) {
5026 var i
, l
, srcElements
, destElements
,
5027 clone
= elem
.cloneNode( true ),
5028 inPage
= jQuery
.contains( elem
.ownerDocument
, elem
);
5031 // Fix Cloning issues
5032 if ( !support
.noCloneChecked
&& ( elem
.nodeType
=== 1 || elem
.nodeType
=== 11 ) &&
5033 !jQuery
.isXMLDoc( elem
) ) {
5035 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
5036 destElements
= getAll( clone
);
5037 srcElements
= getAll( elem
);
5039 for ( i
= 0, l
= srcElements
.length
; i
< l
; i
++ ) {
5040 fixInput( srcElements
[ i
], destElements
[ i
] );
5044 // Copy the events from the original to the clone
5045 if ( dataAndEvents
) {
5046 if ( deepDataAndEvents
) {
5047 srcElements
= srcElements
|| getAll( elem
);
5048 destElements
= destElements
|| getAll( clone
);
5050 for ( i
= 0, l
= srcElements
.length
; i
< l
; i
++ ) {
5051 cloneCopyEvent( srcElements
[ i
], destElements
[ i
] );
5054 cloneCopyEvent( elem
, clone
);
5058 // Preserve script evaluation history
5059 destElements
= getAll( clone
, "script" );
5060 if ( destElements
.length
> 0 ) {
5061 setGlobalEval( destElements
, !inPage
&& getAll( elem
, "script" ) );
5064 // Return the cloned set
5068 buildFragment: function( elems
, context
, scripts
, selection
) {
5069 var elem
, tmp
, tag
, wrap
, contains
, j
,
5070 fragment
= context
.createDocumentFragment(),
5075 for ( ; i
< l
; i
++ ) {
5078 if ( elem
|| elem
=== 0 ) {
5080 // Add nodes directly
5081 if ( jQuery
.type( elem
) === "object" ) {
5082 // Support: QtWebKit
5083 // jQuery.merge because push.apply(_, arraylike) throws
5084 jQuery
.merge( nodes
, elem
.nodeType
? [ elem
] : elem
);
5086 // Convert non-html into a text node
5087 } else if ( !rhtml
.test( elem
) ) {
5088 nodes
.push( context
.createTextNode( elem
) );
5090 // Convert html into DOM nodes
5092 tmp
= tmp
|| fragment
.appendChild( context
.createElement("div") );
5094 // Deserialize a standard representation
5095 tag
= ( rtagName
.exec( elem
) || [ "", "" ] )[ 1 ].toLowerCase();
5096 wrap
= wrapMap
[ tag
] || wrapMap
._default
;
5097 tmp
.innerHTML
= wrap
[ 1 ] + elem
.replace( rxhtmlTag
, "<$1></$2>" ) + wrap
[ 2 ];
5099 // Descend through wrappers to the right content
5102 tmp
= tmp
.lastChild
;
5105 // Support: QtWebKit
5106 // jQuery.merge because push.apply(_, arraylike) throws
5107 jQuery
.merge( nodes
, tmp
.childNodes
);
5109 // Remember the top-level container
5110 tmp
= fragment
.firstChild
;
5113 // Support: Webkit, IE
5114 tmp
.textContent
= "";
5119 // Remove wrapper from fragment
5120 fragment
.textContent
= "";
5123 while ( (elem
= nodes
[ i
++ ]) ) {
5125 // #4087 - If origin and destination elements are the same, and this is
5126 // that element, do not do anything
5127 if ( selection
&& jQuery
.inArray( elem
, selection
) !== -1 ) {
5131 contains
= jQuery
.contains( elem
.ownerDocument
, elem
);
5133 // Append to fragment
5134 tmp
= getAll( fragment
.appendChild( elem
), "script" );
5136 // Preserve script evaluation history
5138 setGlobalEval( tmp
);
5141 // Capture executables
5144 while ( (elem
= tmp
[ j
++ ]) ) {
5145 if ( rscriptType
.test( elem
.type
|| "" ) ) {
5146 scripts
.push( elem
);
5155 cleanData: function( elems
) {
5156 var data
, elem
, type
, key
,
5157 special
= jQuery
.event
.special
,
5160 for ( ; (elem
= elems
[ i
]) !== undefined; i
++ ) {
5161 if ( jQuery
.acceptData( elem
) ) {
5162 key
= elem
[ data_priv
.expando
];
5164 if ( key
&& (data
= data_priv
.cache
[ key
]) ) {
5165 if ( data
.events
) {
5166 for ( type
in data
.events
) {
5167 if ( special
[ type
] ) {
5168 jQuery
.event
.remove( elem
, type
);
5170 // This is a shortcut to avoid jQuery.event.remove's overhead
5172 jQuery
.removeEvent( elem
, type
, data
.handle
);
5176 if ( data_priv
.cache
[ key
] ) {
5177 // Discard any remaining `private` data
5178 delete data_priv
.cache
[ key
];
5182 // Discard any remaining `user` data
5183 delete data_user
.cache
[ elem
[ data_user
.expando
] ];
5189 text: function( value
) {
5190 return access( this, function( value
) {
5191 return value
=== undefined ?
5192 jQuery
.text( this ) :
5193 this.empty().each(function() {
5194 if ( this.nodeType
=== 1 || this.nodeType
=== 11 || this.nodeType
=== 9 ) {
5195 this.textContent
= value
;
5198 }, null, value
, arguments
.length
);
5201 append: function() {
5202 return this.domManip( arguments
, function( elem
) {
5203 if ( this.nodeType
=== 1 || this.nodeType
=== 11 || this.nodeType
=== 9 ) {
5204 var target
= manipulationTarget( this, elem
);
5205 target
.appendChild( elem
);
5210 prepend: function() {
5211 return this.domManip( arguments
, function( elem
) {
5212 if ( this.nodeType
=== 1 || this.nodeType
=== 11 || this.nodeType
=== 9 ) {
5213 var target
= manipulationTarget( this, elem
);
5214 target
.insertBefore( elem
, target
.firstChild
);
5219 before: function() {
5220 return this.domManip( arguments
, function( elem
) {
5221 if ( this.parentNode
) {
5222 this.parentNode
.insertBefore( elem
, this );
5228 return this.domManip( arguments
, function( elem
) {
5229 if ( this.parentNode
) {
5230 this.parentNode
.insertBefore( elem
, this.nextSibling
);
5235 remove: function( selector
, keepData
/* Internal Use Only */ ) {
5237 elems
= selector
? jQuery
.filter( selector
, this ) : this,
5240 for ( ; (elem
= elems
[i
]) != null; i
++ ) {
5241 if ( !keepData
&& elem
.nodeType
=== 1 ) {
5242 jQuery
.cleanData( getAll( elem
) );
5245 if ( elem
.parentNode
) {
5246 if ( keepData
&& jQuery
.contains( elem
.ownerDocument
, elem
) ) {
5247 setGlobalEval( getAll( elem
, "script" ) );
5249 elem
.parentNode
.removeChild( elem
);
5260 for ( ; (elem
= this[i
]) != null; i
++ ) {
5261 if ( elem
.nodeType
=== 1 ) {
5263 // Prevent memory leaks
5264 jQuery
.cleanData( getAll( elem
, false ) );
5266 // Remove any remaining nodes
5267 elem
.textContent
= "";
5274 clone: function( dataAndEvents
, deepDataAndEvents
) {
5275 dataAndEvents
= dataAndEvents
== null ? false : dataAndEvents
;
5276 deepDataAndEvents
= deepDataAndEvents
== null ? dataAndEvents : deepDataAndEvents
;
5278 return this.map(function() {
5279 return jQuery
.clone( this, dataAndEvents
, deepDataAndEvents
);
5283 html: function( value
) {
5284 return access( this, function( value
) {
5285 var elem
= this[ 0 ] || {},
5289 if ( value
=== undefined && elem
.nodeType
=== 1 ) {
5290 return elem
.innerHTML
;
5293 // See if we can take a shortcut and just use innerHTML
5294 if ( typeof value
=== "string" && !rnoInnerhtml
.test( value
) &&
5295 !wrapMap
[ ( rtagName
.exec( value
) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
5297 value
= value
.replace( rxhtmlTag
, "<$1></$2>" );
5300 for ( ; i
< l
; i
++ ) {
5301 elem
= this[ i
] || {};
5303 // Remove element nodes and prevent memory leaks
5304 if ( elem
.nodeType
=== 1 ) {
5305 jQuery
.cleanData( getAll( elem
, false ) );
5306 elem
.innerHTML
= value
;
5312 // If using innerHTML throws an exception, use the fallback method
5317 this.empty().append( value
);
5319 }, null, value
, arguments
.length
);
5322 replaceWith: function() {
5323 var arg
= arguments
[ 0 ];
5325 // Make the changes, replacing each context element with the new content
5326 this.domManip( arguments
, function( elem
) {
5327 arg
= this.parentNode
;
5329 jQuery
.cleanData( getAll( this ) );
5332 arg
.replaceChild( elem
, this );
5336 // Force removal if there was no new content (e.g., from empty arguments)
5337 return arg
&& (arg
.length
|| arg
.nodeType
) ? this : this.remove();
5340 detach: function( selector
) {
5341 return this.remove( selector
, true );
5344 domManip: function( args
, callback
) {
5346 // Flatten any nested arrays
5347 args
= concat
.apply( [], args
);
5349 var fragment
, first
, scripts
, hasScripts
, node
, doc
,
5355 isFunction
= jQuery
.isFunction( value
);
5357 // We can't cloneNode fragments that contain checked, in WebKit
5359 ( l
> 1 && typeof value
=== "string" &&
5360 !support
.checkClone
&& rchecked
.test( value
) ) ) {
5361 return this.each(function( index
) {
5362 var self
= set.eq( index
);
5364 args
[ 0 ] = value
.call( this, index
, self
.html() );
5366 self
.domManip( args
, callback
);
5371 fragment
= jQuery
.buildFragment( args
, this[ 0 ].ownerDocument
, false, this );
5372 first
= fragment
.firstChild
;
5374 if ( fragment
.childNodes
.length
=== 1 ) {
5379 scripts
= jQuery
.map( getAll( fragment
, "script" ), disableScript
);
5380 hasScripts
= scripts
.length
;
5382 // Use the original fragment for the last item instead of the first because it can end up
5383 // being emptied incorrectly in certain situations (#8070).
5384 for ( ; i
< l
; i
++ ) {
5387 if ( i
!== iNoClone
) {
5388 node
= jQuery
.clone( node
, true, true );
5390 // Keep references to cloned scripts for later restoration
5392 // Support: QtWebKit
5393 // jQuery.merge because push.apply(_, arraylike) throws
5394 jQuery
.merge( scripts
, getAll( node
, "script" ) );
5398 callback
.call( this[ i
], node
, i
);
5402 doc
= scripts
[ scripts
.length
- 1 ].ownerDocument
;
5405 jQuery
.map( scripts
, restoreScript
);
5407 // Evaluate executable scripts on first document insertion
5408 for ( i
= 0; i
< hasScripts
; i
++ ) {
5409 node
= scripts
[ i
];
5410 if ( rscriptType
.test( node
.type
|| "" ) &&
5411 !data_priv
.access( node
, "globalEval" ) && jQuery
.contains( doc
, node
) ) {
5414 // Optional AJAX dependency, but won't run scripts if not present
5415 if ( jQuery
._evalUrl
) {
5416 jQuery
._evalUrl( node
.src
);
5419 jQuery
.globalEval( node
.textContent
.replace( rcleanScript
, "" ) );
5433 prependTo: "prepend",
5434 insertBefore: "before",
5435 insertAfter: "after",
5436 replaceAll: "replaceWith"
5437 }, function( name
, original
) {
5438 jQuery
.fn
[ name
] = function( selector
) {
5441 insert
= jQuery( selector
),
5442 last
= insert
.length
- 1,
5445 for ( ; i
<= last
; i
++ ) {
5446 elems
= i
=== last
? this : this.clone( true );
5447 jQuery( insert
[ i
] )[ original
]( elems
);
5449 // Support: QtWebKit
5450 // .get() because push.apply(_, arraylike) throws
5451 push
.apply( ret
, elems
.get() );
5454 return this.pushStack( ret
);
5463 * Retrieve the actual display of a element
5464 * @param {String} name nodeName of the element
5465 * @param {Object} doc Document object
5467 // Called only from within defaultDisplay
5468 function actualDisplay( name
, doc
) {
5470 elem
= jQuery( doc
.createElement( name
) ).appendTo( doc
.body
),
5472 // getDefaultComputedStyle might be reliably used only on attached element
5473 display
= window
.getDefaultComputedStyle
&& ( style
= window
.getDefaultComputedStyle( elem
[ 0 ] ) ) ?
5475 // Use of this method is a temporary fix (more like optmization) until something better comes along,
5476 // since it was removed from specification and supported only in FF
5477 style
.display : jQuery
.css( elem
[ 0 ], "display" );
5479 // We don't have any data stored on the element,
5480 // so use "detach" method as fast way to get rid of the element
5487 * Try to determine the default display value of an element
5488 * @param {String} nodeName
5490 function defaultDisplay( nodeName
) {
5492 display
= elemdisplay
[ nodeName
];
5495 display
= actualDisplay( nodeName
, doc
);
5497 // If the simple way fails, read from inside an iframe
5498 if ( display
=== "none" || !display
) {
5500 // Use the already-created iframe if possible
5501 iframe
= (iframe
|| jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc
.documentElement
);
5503 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
5504 doc
= iframe
[ 0 ].contentDocument
;
5510 display
= actualDisplay( nodeName
, doc
);
5514 // Store the correct default display
5515 elemdisplay
[ nodeName
] = display
;
5520 var rmargin
= (/^margin/);
5522 var rnumnonpx
= new RegExp( "^(" + pnum
+ ")(?!px)[a-z%]+$", "i" );
5524 var getStyles = function( elem
) {
5525 return elem
.ownerDocument
.defaultView
.getComputedStyle( elem
, null );
5530 function curCSS( elem
, name
, computed
) {
5531 var width
, minWidth
, maxWidth
, ret
,
5534 computed
= computed
|| getStyles( elem
);
5537 // getPropertyValue is only needed for .css('filter') in IE9, see #12537
5539 ret
= computed
.getPropertyValue( name
) || computed
[ name
];
5544 if ( ret
=== "" && !jQuery
.contains( elem
.ownerDocument
, elem
) ) {
5545 ret
= jQuery
.style( elem
, name
);
5549 // A tribute to the "awesome hack by Dean Edwards"
5550 // iOS < 6 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
5551 // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
5552 if ( rnumnonpx
.test( ret
) && rmargin
.test( name
) ) {
5554 // Remember the original values
5555 width
= style
.width
;
5556 minWidth
= style
.minWidth
;
5557 maxWidth
= style
.maxWidth
;
5559 // Put in the new values to get a computed value out
5560 style
.minWidth
= style
.maxWidth
= style
.width
= ret
;
5561 ret
= computed
.width
;
5563 // Revert the changed values
5564 style
.width
= width
;
5565 style
.minWidth
= minWidth
;
5566 style
.maxWidth
= maxWidth
;
5570 return ret
!== undefined ?
5572 // IE returns zIndex value as an integer.
5578 function addGetHookIf( conditionFn
, hookFn
) {
5579 // Define the hook, we'll check on the first run if it's really needed.
5582 if ( conditionFn() ) {
5583 // Hook not needed (or it's not possible to use it due to missing dependency),
5585 // Since there are no other hooks for marginRight, remove the whole object.
5590 // Hook needed; redefine it so that the support test is not executed again.
5592 return (this.get = hookFn
).apply( this, arguments
);
5599 var pixelPositionVal
, boxSizingReliableVal
,
5600 docElem
= document
.documentElement
,
5601 container
= document
.createElement( "div" ),
5602 div
= document
.createElement( "div" );
5608 div
.style
.backgroundClip
= "content-box";
5609 div
.cloneNode( true ).style
.backgroundClip
= "";
5610 support
.clearCloneStyle
= div
.style
.backgroundClip
=== "content-box";
5612 container
.style
.cssText
= "border:0;width:0;height:0;top:0;left:-9999px;margin-top:1px;" +
5613 "position:absolute";
5614 container
.appendChild( div
);
5616 // Executing both pixelPosition & boxSizingReliable tests require only one layout
5617 // so they're executed at the same time to save the second computation.
5618 function computePixelPositionAndBoxSizingReliable() {
5620 // Support: Firefox<29, Android 2.3
5621 // Vendor-prefix box-sizing
5622 "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" +
5623 "box-sizing:border-box;display:block;margin-top:1%;top:1%;" +
5624 "border:1px;padding:1px;width:4px;position:absolute";
5626 docElem
.appendChild( container
);
5628 var divStyle
= window
.getComputedStyle( div
, null );
5629 pixelPositionVal
= divStyle
.top
!== "1%";
5630 boxSizingReliableVal
= divStyle
.width
=== "4px";
5632 docElem
.removeChild( container
);
5635 // Support: node.js jsdom
5636 // Don't assume that getComputedStyle is a property of the global object
5637 if ( window
.getComputedStyle
) {
5638 jQuery
.extend( support
, {
5639 pixelPosition: function() {
5640 // This test is executed only once but we still do memoizing
5641 // since we can use the boxSizingReliable pre-computing.
5642 // No need to check if the test was already performed, though.
5643 computePixelPositionAndBoxSizingReliable();
5644 return pixelPositionVal
;
5646 boxSizingReliable: function() {
5647 if ( boxSizingReliableVal
== null ) {
5648 computePixelPositionAndBoxSizingReliable();
5650 return boxSizingReliableVal
;
5652 reliableMarginRight: function() {
5653 // Support: Android 2.3
5654 // Check if div with explicit width and no margin-right incorrectly
5655 // gets computed margin-right based on width of container. (#3333)
5656 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
5657 // This support function is only executed once so no memoizing is needed.
5659 marginDiv
= div
.appendChild( document
.createElement( "div" ) );
5661 // Reset CSS: box-sizing; display; margin; border; padding
5662 marginDiv
.style
.cssText
= div
.style
.cssText
=
5663 // Support: Firefox<29, Android 2.3
5664 // Vendor-prefix box-sizing
5665 "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
5666 "box-sizing:content-box;display:block;margin:0;border:0;padding:0";
5667 marginDiv
.style
.marginRight
= marginDiv
.style
.width
= "0";
5668 div
.style
.width
= "1px";
5669 docElem
.appendChild( container
);
5671 ret
= !parseFloat( window
.getComputedStyle( marginDiv
, null ).marginRight
);
5673 docElem
.removeChild( container
);
5682 // A method for quickly swapping in/out CSS properties to get correct calculations.
5683 jQuery
.swap = function( elem
, options
, callback
, args
) {
5687 // Remember the old values, and insert the new ones
5688 for ( name
in options
) {
5689 old
[ name
] = elem
.style
[ name
];
5690 elem
.style
[ name
] = options
[ name
];
5693 ret
= callback
.apply( elem
, args
|| [] );
5695 // Revert the old values
5696 for ( name
in options
) {
5697 elem
.style
[ name
] = old
[ name
];
5705 // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
5706 // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
5707 rdisplayswap
= /^(none|table(?!-c[ea]).+)/,
5708 rnumsplit
= new RegExp( "^(" + pnum
+ ")(.*)$", "i" ),
5709 rrelNum
= new RegExp( "^([+-])=(" + pnum
+ ")", "i" ),
5711 cssShow
= { position: "absolute", visibility: "hidden", display: "block" },
5712 cssNormalTransform
= {
5717 cssPrefixes
= [ "Webkit", "O", "Moz", "ms" ];
5719 // return a css property mapped to a potentially vendor prefixed property
5720 function vendorPropName( style
, name
) {
5722 // shortcut for names that are not vendor prefixed
5723 if ( name
in style
) {
5727 // check for vendor prefixed names
5728 var capName
= name
[0].toUpperCase() + name
.slice(1),
5730 i
= cssPrefixes
.length
;
5733 name
= cssPrefixes
[ i
] + capName
;
5734 if ( name
in style
) {
5742 function setPositiveNumber( elem
, value
, subtract
) {
5743 var matches
= rnumsplit
.exec( value
);
5745 // Guard against undefined "subtract", e.g., when used as in cssHooks
5746 Math
.max( 0, matches
[ 1 ] - ( subtract
|| 0 ) ) + ( matches
[ 2 ] || "px" ) :
5750 function augmentWidthOrHeight( elem
, name
, extra
, isBorderBox
, styles
) {
5751 var i
= extra
=== ( isBorderBox
? "border" : "content" ) ?
5752 // If we already have the right measurement, avoid augmentation
5754 // Otherwise initialize for horizontal or vertical properties
5755 name
=== "width" ? 1 : 0,
5759 for ( ; i
< 4; i
+= 2 ) {
5760 // both box models exclude margin, so add it if we want it
5761 if ( extra
=== "margin" ) {
5762 val
+= jQuery
.css( elem
, extra
+ cssExpand
[ i
], true, styles
);
5765 if ( isBorderBox
) {
5766 // border-box includes padding, so remove it if we want content
5767 if ( extra
=== "content" ) {
5768 val
-= jQuery
.css( elem
, "padding" + cssExpand
[ i
], true, styles
);
5771 // at this point, extra isn't border nor margin, so remove border
5772 if ( extra
!== "margin" ) {
5773 val
-= jQuery
.css( elem
, "border" + cssExpand
[ i
] + "Width", true, styles
);
5776 // at this point, extra isn't content, so add padding
5777 val
+= jQuery
.css( elem
, "padding" + cssExpand
[ i
], true, styles
);
5779 // at this point, extra isn't content nor padding, so add border
5780 if ( extra
!== "padding" ) {
5781 val
+= jQuery
.css( elem
, "border" + cssExpand
[ i
] + "Width", true, styles
);
5789 function getWidthOrHeight( elem
, name
, extra
) {
5791 // Start with offset property, which is equivalent to the border-box value
5792 var valueIsBorderBox
= true,
5793 val
= name
=== "width" ? elem
.offsetWidth : elem
.offsetHeight
,
5794 styles
= getStyles( elem
),
5795 isBorderBox
= jQuery
.css( elem
, "boxSizing", false, styles
) === "border-box";
5797 // some non-html elements return undefined for offsetWidth, so check for null/undefined
5798 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
5799 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
5800 if ( val
<= 0 || val
== null ) {
5801 // Fall back to computed then uncomputed css if necessary
5802 val
= curCSS( elem
, name
, styles
);
5803 if ( val
< 0 || val
== null ) {
5804 val
= elem
.style
[ name
];
5807 // Computed unit is not pixels. Stop here and return.
5808 if ( rnumnonpx
.test(val
) ) {
5812 // we need the check for style in case a browser which returns unreliable values
5813 // for getComputedStyle silently falls back to the reliable elem.style
5814 valueIsBorderBox
= isBorderBox
&&
5815 ( support
.boxSizingReliable() || val
=== elem
.style
[ name
] );
5817 // Normalize "", auto, and prepare for extra
5818 val
= parseFloat( val
) || 0;
5821 // use the active box-sizing model to add/subtract irrelevant styles
5823 augmentWidthOrHeight(
5826 extra
|| ( isBorderBox
? "border" : "content" ),
5833 function showHide( elements
, show
) {
5834 var display
, elem
, hidden
,
5837 length
= elements
.length
;
5839 for ( ; index
< length
; index
++ ) {
5840 elem
= elements
[ index
];
5841 if ( !elem
.style
) {
5845 values
[ index
] = data_priv
.get( elem
, "olddisplay" );
5846 display
= elem
.style
.display
;
5848 // Reset the inline display of this element to learn if it is
5849 // being hidden by cascaded rules or not
5850 if ( !values
[ index
] && display
=== "none" ) {
5851 elem
.style
.display
= "";
5854 // Set elements which have been overridden with display: none
5855 // in a stylesheet to whatever the default browser style is
5856 // for such an element
5857 if ( elem
.style
.display
=== "" && isHidden( elem
) ) {
5858 values
[ index
] = data_priv
.access( elem
, "olddisplay", defaultDisplay(elem
.nodeName
) );
5861 hidden
= isHidden( elem
);
5863 if ( display
!== "none" || !hidden
) {
5864 data_priv
.set( elem
, "olddisplay", hidden
? display : jQuery
.css( elem
, "display" ) );
5869 // Set the display of most of the elements in a second loop
5870 // to avoid the constant reflow
5871 for ( index
= 0; index
< length
; index
++ ) {
5872 elem
= elements
[ index
];
5873 if ( !elem
.style
) {
5876 if ( !show
|| elem
.style
.display
=== "none" || elem
.style
.display
=== "" ) {
5877 elem
.style
.display
= show
? values
[ index
] || "" : "none";
5885 // Add in style property hooks for overriding the default
5886 // behavior of getting and setting a style property
5889 get: function( elem
, computed
) {
5891 // We should always get a number back from opacity
5892 var ret
= curCSS( elem
, "opacity" );
5893 return ret
=== "" ? "1" : ret
;
5899 // Don't automatically add "px" to these possibly-unitless properties
5901 "columnCount": true,
5902 "fillOpacity": true,
5915 // Add in properties whose names you wish to fix before
5916 // setting or getting the value
5918 // normalize float css property
5922 // Get and set the style property on a DOM Node
5923 style: function( elem
, name
, value
, extra
) {
5924 // Don't set styles on text and comment nodes
5925 if ( !elem
|| elem
.nodeType
=== 3 || elem
.nodeType
=== 8 || !elem
.style
) {
5929 // Make sure that we're working with the right name
5930 var ret
, type
, hooks
,
5931 origName
= jQuery
.camelCase( name
),
5934 name
= jQuery
.cssProps
[ origName
] || ( jQuery
.cssProps
[ origName
] = vendorPropName( style
, origName
) );
5936 // gets hook for the prefixed version
5937 // followed by the unprefixed version
5938 hooks
= jQuery
.cssHooks
[ name
] || jQuery
.cssHooks
[ origName
];
5940 // Check if we're setting a value
5941 if ( value
!== undefined ) {
5942 type
= typeof value
;
5944 // convert relative number strings (+= or -=) to relative numbers. #7345
5945 if ( type
=== "string" && (ret
= rrelNum
.exec( value
)) ) {
5946 value
= ( ret
[1] + 1 ) * ret
[2] + parseFloat( jQuery
.css( elem
, name
) );
5951 // Make sure that null and NaN values aren't set. See: #7116
5952 if ( value
== null || value
!== value
) {
5956 // If a number was passed in, add 'px' to the (except for certain CSS properties)
5957 if ( type
=== "number" && !jQuery
.cssNumber
[ origName
] ) {
5961 // Fixes #8908, it can be done more correctly by specifying setters in cssHooks,
5962 // but it would mean to define eight (for every problematic property) identical functions
5963 if ( !support
.clearCloneStyle
&& value
=== "" && name
.indexOf( "background" ) === 0 ) {
5964 style
[ name
] = "inherit";
5967 // If a hook was provided, use that value, otherwise just set the specified value
5968 if ( !hooks
|| !("set" in hooks
) || (value
= hooks
.set( elem
, value
, extra
)) !== undefined ) {
5969 style
[ name
] = value
;
5973 // If a hook was provided get the non-computed value from there
5974 if ( hooks
&& "get" in hooks
&& (ret
= hooks
.get( elem
, false, extra
)) !== undefined ) {
5978 // Otherwise just get the value from the style object
5979 return style
[ name
];
5983 css: function( elem
, name
, extra
, styles
) {
5984 var val
, num
, hooks
,
5985 origName
= jQuery
.camelCase( name
);
5987 // Make sure that we're working with the right name
5988 name
= jQuery
.cssProps
[ origName
] || ( jQuery
.cssProps
[ origName
] = vendorPropName( elem
.style
, origName
) );
5990 // gets hook for the prefixed version
5991 // followed by the unprefixed version
5992 hooks
= jQuery
.cssHooks
[ name
] || jQuery
.cssHooks
[ origName
];
5994 // If a hook was provided get the computed value from there
5995 if ( hooks
&& "get" in hooks
) {
5996 val
= hooks
.get( elem
, true, extra
);
5999 // Otherwise, if a way to get the computed value exists, use that
6000 if ( val
=== undefined ) {
6001 val
= curCSS( elem
, name
, styles
);
6004 //convert "normal" to computed value
6005 if ( val
=== "normal" && name
in cssNormalTransform
) {
6006 val
= cssNormalTransform
[ name
];
6009 // Return, converting to number if forced or a qualifier was provided and val looks numeric
6010 if ( extra
=== "" || extra
) {
6011 num
= parseFloat( val
);
6012 return extra
=== true || jQuery
.isNumeric( num
) ? num
|| 0 : val
;
6018 jQuery
.each([ "height", "width" ], function( i
, name
) {
6019 jQuery
.cssHooks
[ name
] = {
6020 get: function( elem
, computed
, extra
) {
6022 // certain elements can have dimension info if we invisibly show them
6023 // however, it must have a current display style that would benefit from this
6024 return rdisplayswap
.test( jQuery
.css( elem
, "display" ) ) && elem
.offsetWidth
=== 0 ?
6025 jQuery
.swap( elem
, cssShow
, function() {
6026 return getWidthOrHeight( elem
, name
, extra
);
6028 getWidthOrHeight( elem
, name
, extra
);
6032 set: function( elem
, value
, extra
) {
6033 var styles
= extra
&& getStyles( elem
);
6034 return setPositiveNumber( elem
, value
, extra
?
6035 augmentWidthOrHeight(
6039 jQuery
.css( elem
, "boxSizing", false, styles
) === "border-box",
6047 // Support: Android 2.3
6048 jQuery
.cssHooks
.marginRight
= addGetHookIf( support
.reliableMarginRight
,
6049 function( elem
, computed
) {
6051 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
6052 // Work around by temporarily setting element display to inline-block
6053 return jQuery
.swap( elem
, { "display": "inline-block" },
6054 curCSS
, [ elem
, "marginRight" ] );
6059 // These hooks are used by animate to expand properties
6064 }, function( prefix
, suffix
) {
6065 jQuery
.cssHooks
[ prefix
+ suffix
] = {
6066 expand: function( value
) {
6070 // assumes a single number if not a string
6071 parts
= typeof value
=== "string" ? value
.split(" ") : [ value
];
6073 for ( ; i
< 4; i
++ ) {
6074 expanded
[ prefix
+ cssExpand
[ i
] + suffix
] =
6075 parts
[ i
] || parts
[ i
- 2 ] || parts
[ 0 ];
6082 if ( !rmargin
.test( prefix
) ) {
6083 jQuery
.cssHooks
[ prefix
+ suffix
].set = setPositiveNumber
;
6088 css: function( name
, value
) {
6089 return access( this, function( elem
, name
, value
) {
6094 if ( jQuery
.isArray( name
) ) {
6095 styles
= getStyles( elem
);
6098 for ( ; i
< len
; i
++ ) {
6099 map
[ name
[ i
] ] = jQuery
.css( elem
, name
[ i
], false, styles
);
6105 return value
!== undefined ?
6106 jQuery
.style( elem
, name
, value
) :
6107 jQuery
.css( elem
, name
);
6108 }, name
, value
, arguments
.length
> 1 );
6111 return showHide( this, true );
6114 return showHide( this );
6116 toggle: function( state
) {
6117 if ( typeof state
=== "boolean" ) {
6118 return state
? this.show() : this.hide();
6121 return this.each(function() {
6122 if ( isHidden( this ) ) {
6123 jQuery( this ).show();
6125 jQuery( this ).hide();
6132 function Tween( elem
, options
, prop
, end
, easing
) {
6133 return new Tween
.prototype.init( elem
, options
, prop
, end
, easing
);
6135 jQuery
.Tween
= Tween
;
6139 init: function( elem
, options
, prop
, end
, easing
, unit
) {
6142 this.easing
= easing
|| "swing";
6143 this.options
= options
;
6144 this.start
= this.now
= this.cur();
6146 this.unit
= unit
|| ( jQuery
.cssNumber
[ prop
] ? "" : "px" );
6149 var hooks
= Tween
.propHooks
[ this.prop
];
6151 return hooks
&& hooks
.get ?
6153 Tween
.propHooks
._default
.get( this );
6155 run: function( percent
) {
6157 hooks
= Tween
.propHooks
[ this.prop
];
6159 if ( this.options
.duration
) {
6160 this.pos
= eased
= jQuery
.easing
[ this.easing
](
6161 percent
, this.options
.duration
* percent
, 0, 1, this.options
.duration
6164 this.pos
= eased
= percent
;
6166 this.now
= ( this.end
- this.start
) * eased
+ this.start
;
6168 if ( this.options
.step
) {
6169 this.options
.step
.call( this.elem
, this.now
, this );
6172 if ( hooks
&& hooks
.set ) {
6175 Tween
.propHooks
._default
.set( this );
6181 Tween
.prototype.init
.prototype = Tween
.prototype;
6185 get: function( tween
) {
6188 if ( tween
.elem
[ tween
.prop
] != null &&
6189 (!tween
.elem
.style
|| tween
.elem
.style
[ tween
.prop
] == null) ) {
6190 return tween
.elem
[ tween
.prop
];
6193 // passing an empty string as a 3rd parameter to .css will automatically
6194 // attempt a parseFloat and fallback to a string if the parse fails
6195 // so, simple values such as "10px" are parsed to Float.
6196 // complex values such as "rotate(1rad)" are returned as is.
6197 result
= jQuery
.css( tween
.elem
, tween
.prop
, "" );
6198 // Empty strings, null, undefined and "auto" are converted to 0.
6199 return !result
|| result
=== "auto" ? 0 : result
;
6201 set: function( tween
) {
6202 // use step hook for back compat - use cssHook if its there - use .style if its
6203 // available and use plain properties where available
6204 if ( jQuery
.fx
.step
[ tween
.prop
] ) {
6205 jQuery
.fx
.step
[ tween
.prop
]( tween
);
6206 } else if ( tween
.elem
.style
&& ( tween
.elem
.style
[ jQuery
.cssProps
[ tween
.prop
] ] != null || jQuery
.cssHooks
[ tween
.prop
] ) ) {
6207 jQuery
.style( tween
.elem
, tween
.prop
, tween
.now
+ tween
.unit
);
6209 tween
.elem
[ tween
.prop
] = tween
.now
;
6216 // Panic based approach to setting things on disconnected nodes
6218 Tween
.propHooks
.scrollTop
= Tween
.propHooks
.scrollLeft
= {
6219 set: function( tween
) {
6220 if ( tween
.elem
.nodeType
&& tween
.elem
.parentNode
) {
6221 tween
.elem
[ tween
.prop
] = tween
.now
;
6227 linear: function( p
) {
6230 swing: function( p
) {
6231 return 0.5 - Math
.cos( p
* Math
.PI
) / 2;
6235 jQuery
.fx
= Tween
.prototype.init
;
6237 // Back Compat <1.8 extension point
6238 jQuery
.fx
.step
= {};
6245 rfxtypes
= /^(?:toggle|show|hide)$/,
6246 rfxnum
= new RegExp( "^(?:([+-])=|)(" + pnum
+ ")([a-z%]*)$", "i" ),
6247 rrun
= /queueHooks$/,
6248 animationPrefilters
= [ defaultPrefilter
],
6250 "*": [ function( prop
, value
) {
6251 var tween
= this.createTween( prop
, value
),
6252 target
= tween
.cur(),
6253 parts
= rfxnum
.exec( value
),
6254 unit
= parts
&& parts
[ 3 ] || ( jQuery
.cssNumber
[ prop
] ? "" : "px" ),
6256 // Starting value computation is required for potential unit mismatches
6257 start
= ( jQuery
.cssNumber
[ prop
] || unit
!== "px" && +target
) &&
6258 rfxnum
.exec( jQuery
.css( tween
.elem
, prop
) ),
6262 if ( start
&& start
[ 3 ] !== unit
) {
6263 // Trust units reported by jQuery.css
6264 unit
= unit
|| start
[ 3 ];
6266 // Make sure we update the tween properties later on
6267 parts
= parts
|| [];
6269 // Iteratively approximate from a nonzero starting point
6270 start
= +target
|| 1;
6273 // If previous iteration zeroed out, double until we get *something*
6274 // Use a string for doubling factor so we don't accidentally see scale as unchanged below
6275 scale
= scale
|| ".5";
6278 start
= start
/ scale
;
6279 jQuery
.style( tween
.elem
, prop
, start
+ unit
);
6281 // Update scale, tolerating zero or NaN from tween.cur()
6282 // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
6283 } while ( scale
!== (scale
= tween
.cur() / target
) && scale
!== 1 && --maxIterations
);
6286 // Update tween properties
6288 start
= tween
.start
= +start
|| +target
|| 0;
6290 // If a +=/-= token was provided, we're doing a relative animation
6291 tween
.end
= parts
[ 1 ] ?
6292 start
+ ( parts
[ 1 ] + 1 ) * parts
[ 2 ] :
6300 // Animations created synchronously will run synchronously
6301 function createFxNow() {
6302 setTimeout(function() {
6305 return ( fxNow
= jQuery
.now() );
6308 // Generate parameters to create a standard animation
6309 function genFx( type
, includeWidth
) {
6312 attrs
= { height: type
};
6314 // if we include width, step value is 1 to do all cssExpand values,
6315 // if we don't include width, step value is 2 to skip over Left and Right
6316 includeWidth
= includeWidth
? 1 : 0;
6317 for ( ; i
< 4 ; i
+= 2 - includeWidth
) {
6318 which
= cssExpand
[ i
];
6319 attrs
[ "margin" + which
] = attrs
[ "padding" + which
] = type
;
6322 if ( includeWidth
) {
6323 attrs
.opacity
= attrs
.width
= type
;
6329 function createTween( value
, prop
, animation
) {
6331 collection
= ( tweeners
[ prop
] || [] ).concat( tweeners
[ "*" ] ),
6333 length
= collection
.length
;
6334 for ( ; index
< length
; index
++ ) {
6335 if ( (tween
= collection
[ index
].call( animation
, prop
, value
)) ) {
6337 // we're done with this property
6343 function defaultPrefilter( elem
, props
, opts
) {
6344 /* jshint validthis: true */
6345 var prop
, value
, toggle
, tween
, hooks
, oldfire
, display
, checkDisplay
,
6349 hidden
= elem
.nodeType
&& isHidden( elem
),
6350 dataShow
= data_priv
.get( elem
, "fxshow" );
6352 // handle queue: false promises
6353 if ( !opts
.queue
) {
6354 hooks
= jQuery
._queueHooks( elem
, "fx" );
6355 if ( hooks
.unqueued
== null ) {
6357 oldfire
= hooks
.empty
.fire
;
6358 hooks
.empty
.fire = function() {
6359 if ( !hooks
.unqueued
) {
6366 anim
.always(function() {
6367 // doing this makes sure that the complete handler will be called
6368 // before this completes
6369 anim
.always(function() {
6371 if ( !jQuery
.queue( elem
, "fx" ).length
) {
6378 // height/width overflow pass
6379 if ( elem
.nodeType
=== 1 && ( "height" in props
|| "width" in props
) ) {
6380 // Make sure that nothing sneaks out
6381 // Record all 3 overflow attributes because IE9-10 do not
6382 // change the overflow attribute when overflowX and
6383 // overflowY are set to the same value
6384 opts
.overflow
= [ style
.overflow
, style
.overflowX
, style
.overflowY
];
6386 // Set display property to inline-block for height/width
6387 // animations on inline elements that are having width/height animated
6388 display
= jQuery
.css( elem
, "display" );
6390 // Test default display if display is currently "none"
6391 checkDisplay
= display
=== "none" ?
6392 data_priv
.get( elem
, "olddisplay" ) || defaultDisplay( elem
.nodeName
) : display
;
6394 if ( checkDisplay
=== "inline" && jQuery
.css( elem
, "float" ) === "none" ) {
6395 style
.display
= "inline-block";
6399 if ( opts
.overflow
) {
6400 style
.overflow
= "hidden";
6401 anim
.always(function() {
6402 style
.overflow
= opts
.overflow
[ 0 ];
6403 style
.overflowX
= opts
.overflow
[ 1 ];
6404 style
.overflowY
= opts
.overflow
[ 2 ];
6409 for ( prop
in props
) {
6410 value
= props
[ prop
];
6411 if ( rfxtypes
.exec( value
) ) {
6412 delete props
[ prop
];
6413 toggle
= toggle
|| value
=== "toggle";
6414 if ( value
=== ( hidden
? "hide" : "show" ) ) {
6416 // 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
6417 if ( value
=== "show" && dataShow
&& dataShow
[ prop
] !== undefined ) {
6423 orig
[ prop
] = dataShow
&& dataShow
[ prop
] || jQuery
.style( elem
, prop
);
6425 // Any non-fx value stops us from restoring the original display value
6427 display
= undefined;
6431 if ( !jQuery
.isEmptyObject( orig
) ) {
6433 if ( "hidden" in dataShow
) {
6434 hidden
= dataShow
.hidden
;
6437 dataShow
= data_priv
.access( elem
, "fxshow", {} );
6440 // store state if its toggle - enables .stop().toggle() to "reverse"
6442 dataShow
.hidden
= !hidden
;
6445 jQuery( elem
).show();
6447 anim
.done(function() {
6448 jQuery( elem
).hide();
6451 anim
.done(function() {
6454 data_priv
.remove( elem
, "fxshow" );
6455 for ( prop
in orig
) {
6456 jQuery
.style( elem
, prop
, orig
[ prop
] );
6459 for ( prop
in orig
) {
6460 tween
= createTween( hidden
? dataShow
[ prop
] : 0, prop
, anim
);
6462 if ( !( prop
in dataShow
) ) {
6463 dataShow
[ prop
] = tween
.start
;
6465 tween
.end
= tween
.start
;
6466 tween
.start
= prop
=== "width" || prop
=== "height" ? 1 : 0;
6471 // If this is a noop like .hide().hide(), restore an overwritten display value
6472 } else if ( (display
=== "none" ? defaultDisplay( elem
.nodeName
) : display
) === "inline" ) {
6473 style
.display
= display
;
6477 function propFilter( props
, specialEasing
) {
6478 var index
, name
, easing
, value
, hooks
;
6480 // camelCase, specialEasing and expand cssHook pass
6481 for ( index
in props
) {
6482 name
= jQuery
.camelCase( index
);
6483 easing
= specialEasing
[ name
];
6484 value
= props
[ index
];
6485 if ( jQuery
.isArray( value
) ) {
6486 easing
= value
[ 1 ];
6487 value
= props
[ index
] = value
[ 0 ];
6490 if ( index
!== name
) {
6491 props
[ name
] = value
;
6492 delete props
[ index
];
6495 hooks
= jQuery
.cssHooks
[ name
];
6496 if ( hooks
&& "expand" in hooks
) {
6497 value
= hooks
.expand( value
);
6498 delete props
[ name
];
6500 // not quite $.extend, this wont overwrite keys already present.
6501 // also - reusing 'index' from above because we have the correct "name"
6502 for ( index
in value
) {
6503 if ( !( index
in props
) ) {
6504 props
[ index
] = value
[ index
];
6505 specialEasing
[ index
] = easing
;
6509 specialEasing
[ name
] = easing
;
6514 function Animation( elem
, properties
, options
) {
6518 length
= animationPrefilters
.length
,
6519 deferred
= jQuery
.Deferred().always( function() {
6520 // don't match elem in the :animated selector
6527 var currentTime
= fxNow
|| createFxNow(),
6528 remaining
= Math
.max( 0, animation
.startTime
+ animation
.duration
- currentTime
),
6529 // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
6530 temp
= remaining
/ animation
.duration
|| 0,
6533 length
= animation
.tweens
.length
;
6535 for ( ; index
< length
; index
++ ) {
6536 animation
.tweens
[ index
].run( percent
);
6539 deferred
.notifyWith( elem
, [ animation
, percent
, remaining
]);
6541 if ( percent
< 1 && length
) {
6544 deferred
.resolveWith( elem
, [ animation
] );
6548 animation
= deferred
.promise({
6550 props: jQuery
.extend( {}, properties
),
6551 opts: jQuery
.extend( true, { specialEasing: {} }, options
),
6552 originalProperties: properties
,
6553 originalOptions: options
,
6554 startTime: fxNow
|| createFxNow(),
6555 duration: options
.duration
,
6557 createTween: function( prop
, end
) {
6558 var tween
= jQuery
.Tween( elem
, animation
.opts
, prop
, end
,
6559 animation
.opts
.specialEasing
[ prop
] || animation
.opts
.easing
);
6560 animation
.tweens
.push( tween
);
6563 stop: function( gotoEnd
) {
6565 // if we are going to the end, we want to run all the tweens
6566 // otherwise we skip this part
6567 length
= gotoEnd
? animation
.tweens
.length : 0;
6572 for ( ; index
< length
; index
++ ) {
6573 animation
.tweens
[ index
].run( 1 );
6576 // resolve when we played the last frame
6577 // otherwise, reject
6579 deferred
.resolveWith( elem
, [ animation
, gotoEnd
] );
6581 deferred
.rejectWith( elem
, [ animation
, gotoEnd
] );
6586 props
= animation
.props
;
6588 propFilter( props
, animation
.opts
.specialEasing
);
6590 for ( ; index
< length
; index
++ ) {
6591 result
= animationPrefilters
[ index
].call( animation
, elem
, props
, animation
.opts
);
6597 jQuery
.map( props
, createTween
, animation
);
6599 if ( jQuery
.isFunction( animation
.opts
.start
) ) {
6600 animation
.opts
.start
.call( elem
, animation
);
6604 jQuery
.extend( tick
, {
6607 queue: animation
.opts
.queue
6611 // attach callbacks from options
6612 return animation
.progress( animation
.opts
.progress
)
6613 .done( animation
.opts
.done
, animation
.opts
.complete
)
6614 .fail( animation
.opts
.fail
)
6615 .always( animation
.opts
.always
);
6618 jQuery
.Animation
= jQuery
.extend( Animation
, {
6620 tweener: function( props
, callback
) {
6621 if ( jQuery
.isFunction( props
) ) {
6625 props
= props
.split(" ");
6630 length
= props
.length
;
6632 for ( ; index
< length
; index
++ ) {
6633 prop
= props
[ index
];
6634 tweeners
[ prop
] = tweeners
[ prop
] || [];
6635 tweeners
[ prop
].unshift( callback
);
6639 prefilter: function( callback
, prepend
) {
6641 animationPrefilters
.unshift( callback
);
6643 animationPrefilters
.push( callback
);
6648 jQuery
.speed = function( speed
, easing
, fn
) {
6649 var opt
= speed
&& typeof speed
=== "object" ? jQuery
.extend( {}, speed
) : {
6650 complete: fn
|| !fn
&& easing
||
6651 jQuery
.isFunction( speed
) && speed
,
6653 easing: fn
&& easing
|| easing
&& !jQuery
.isFunction( easing
) && easing
6656 opt
.duration
= jQuery
.fx
.off
? 0 : typeof opt
.duration
=== "number" ? opt
.duration :
6657 opt
.duration
in jQuery
.fx
.speeds
? jQuery
.fx
.speeds
[ opt
.duration
] : jQuery
.fx
.speeds
._default
;
6659 // normalize opt.queue - true/undefined/null -> "fx"
6660 if ( opt
.queue
== null || opt
.queue
=== true ) {
6665 opt
.old
= opt
.complete
;
6667 opt
.complete = function() {
6668 if ( jQuery
.isFunction( opt
.old
) ) {
6669 opt
.old
.call( this );
6673 jQuery
.dequeue( this, opt
.queue
);
6681 fadeTo: function( speed
, to
, easing
, callback
) {
6683 // show any hidden elements after setting opacity to 0
6684 return this.filter( isHidden
).css( "opacity", 0 ).show()
6686 // animate to the value specified
6687 .end().animate({ opacity: to
}, speed
, easing
, callback
);
6689 animate: function( prop
, speed
, easing
, callback
) {
6690 var empty
= jQuery
.isEmptyObject( prop
),
6691 optall
= jQuery
.speed( speed
, easing
, callback
),
6692 doAnimation = function() {
6693 // Operate on a copy of prop so per-property easing won't be lost
6694 var anim
= Animation( this, jQuery
.extend( {}, prop
), optall
);
6696 // Empty animations, or finishing resolves immediately
6697 if ( empty
|| data_priv
.get( this, "finish" ) ) {
6701 doAnimation
.finish
= doAnimation
;
6703 return empty
|| optall
.queue
=== false ?
6704 this.each( doAnimation
) :
6705 this.queue( optall
.queue
, doAnimation
);
6707 stop: function( type
, clearQueue
, gotoEnd
) {
6708 var stopQueue = function( hooks
) {
6709 var stop
= hooks
.stop
;
6714 if ( typeof type
!== "string" ) {
6715 gotoEnd
= clearQueue
;
6719 if ( clearQueue
&& type
!== false ) {
6720 this.queue( type
|| "fx", [] );
6723 return this.each(function() {
6725 index
= type
!= null && type
+ "queueHooks",
6726 timers
= jQuery
.timers
,
6727 data
= data_priv
.get( this );
6730 if ( data
[ index
] && data
[ index
].stop
) {
6731 stopQueue( data
[ index
] );
6734 for ( index
in data
) {
6735 if ( data
[ index
] && data
[ index
].stop
&& rrun
.test( index
) ) {
6736 stopQueue( data
[ index
] );
6741 for ( index
= timers
.length
; index
--; ) {
6742 if ( timers
[ index
].elem
=== this && (type
== null || timers
[ index
].queue
=== type
) ) {
6743 timers
[ index
].anim
.stop( gotoEnd
);
6745 timers
.splice( index
, 1 );
6749 // start the next in the queue if the last step wasn't forced
6750 // timers currently will call their complete callbacks, which will dequeue
6751 // but only if they were gotoEnd
6752 if ( dequeue
|| !gotoEnd
) {
6753 jQuery
.dequeue( this, type
);
6757 finish: function( type
) {
6758 if ( type
!== false ) {
6759 type
= type
|| "fx";
6761 return this.each(function() {
6763 data
= data_priv
.get( this ),
6764 queue
= data
[ type
+ "queue" ],
6765 hooks
= data
[ type
+ "queueHooks" ],
6766 timers
= jQuery
.timers
,
6767 length
= queue
? queue
.length : 0;
6769 // enable finishing flag on private data
6772 // empty the queue first
6773 jQuery
.queue( this, type
, [] );
6775 if ( hooks
&& hooks
.stop
) {
6776 hooks
.stop
.call( this, true );
6779 // look for any active animations, and finish them
6780 for ( index
= timers
.length
; index
--; ) {
6781 if ( timers
[ index
].elem
=== this && timers
[ index
].queue
=== type
) {
6782 timers
[ index
].anim
.stop( true );
6783 timers
.splice( index
, 1 );
6787 // look for any animations in the old queue and finish them
6788 for ( index
= 0; index
< length
; index
++ ) {
6789 if ( queue
[ index
] && queue
[ index
].finish
) {
6790 queue
[ index
].finish
.call( this );
6794 // turn off finishing flag
6800 jQuery
.each([ "toggle", "show", "hide" ], function( i
, name
) {
6801 var cssFn
= jQuery
.fn
[ name
];
6802 jQuery
.fn
[ name
] = function( speed
, easing
, callback
) {
6803 return speed
== null || typeof speed
=== "boolean" ?
6804 cssFn
.apply( this, arguments
) :
6805 this.animate( genFx( name
, true ), speed
, easing
, callback
);
6809 // Generate shortcuts for custom animations
6811 slideDown: genFx("show"),
6812 slideUp: genFx("hide"),
6813 slideToggle: genFx("toggle"),
6814 fadeIn: { opacity: "show" },
6815 fadeOut: { opacity: "hide" },
6816 fadeToggle: { opacity: "toggle" }
6817 }, function( name
, props
) {
6818 jQuery
.fn
[ name
] = function( speed
, easing
, callback
) {
6819 return this.animate( props
, speed
, easing
, callback
);
6824 jQuery
.fx
.tick = function() {
6827 timers
= jQuery
.timers
;
6829 fxNow
= jQuery
.now();
6831 for ( ; i
< timers
.length
; i
++ ) {
6832 timer
= timers
[ i
];
6833 // Checks the timer has not already been removed
6834 if ( !timer() && timers
[ i
] === timer
) {
6835 timers
.splice( i
--, 1 );
6839 if ( !timers
.length
) {
6845 jQuery
.fx
.timer = function( timer
) {
6846 jQuery
.timers
.push( timer
);
6850 jQuery
.timers
.pop();
6854 jQuery
.fx
.interval
= 13;
6856 jQuery
.fx
.start = function() {
6858 timerId
= setInterval( jQuery
.fx
.tick
, jQuery
.fx
.interval
);
6862 jQuery
.fx
.stop = function() {
6863 clearInterval( timerId
);
6867 jQuery
.fx
.speeds
= {
6875 // Based off of the plugin by Clint Helfers, with permission.
6876 // http://blindsignals.com/index.php/2009/07/jquery-delay/
6877 jQuery
.fn
.delay = function( time
, type
) {
6878 time
= jQuery
.fx
? jQuery
.fx
.speeds
[ time
] || time : time
;
6879 type
= type
|| "fx";
6881 return this.queue( type
, function( next
, hooks
) {
6882 var timeout
= setTimeout( next
, time
);
6883 hooks
.stop = function() {
6884 clearTimeout( timeout
);
6891 var input
= document
.createElement( "input" ),
6892 select
= document
.createElement( "select" ),
6893 opt
= select
.appendChild( document
.createElement( "option" ) );
6895 input
.type
= "checkbox";
6897 // Support: iOS 5.1, Android 4.x, Android 2.3
6898 // Check the default checkbox/radio value ("" on old WebKit; "on" elsewhere)
6899 support
.checkOn
= input
.value
!== "";
6901 // Must access the parent to make an option select properly
6902 // Support: IE9, IE10
6903 support
.optSelected
= opt
.selected
;
6905 // Make sure that the options inside disabled selects aren't marked as disabled
6906 // (WebKit marks them as disabled)
6907 select
.disabled
= true;
6908 support
.optDisabled
= !opt
.disabled
;
6910 // Check if an input maintains its value after becoming a radio
6911 // Support: IE9, IE10
6912 input
= document
.createElement( "input" );
6914 input
.type
= "radio";
6915 support
.radioValue
= input
.value
=== "t";
6919 var nodeHook
, boolHook
,
6920 attrHandle
= jQuery
.expr
.attrHandle
;
6923 attr: function( name
, value
) {
6924 return access( this, jQuery
.attr
, name
, value
, arguments
.length
> 1 );
6927 removeAttr: function( name
) {
6928 return this.each(function() {
6929 jQuery
.removeAttr( this, name
);
6935 attr: function( elem
, name
, value
) {
6937 nType
= elem
.nodeType
;
6939 // don't get/set attributes on text, comment and attribute nodes
6940 if ( !elem
|| nType
=== 3 || nType
=== 8 || nType
=== 2 ) {
6944 // Fallback to prop when attributes are not supported
6945 if ( typeof elem
.getAttribute
=== strundefined
) {
6946 return jQuery
.prop( elem
, name
, value
);
6949 // All attributes are lowercase
6950 // Grab necessary hook if one is defined
6951 if ( nType
!== 1 || !jQuery
.isXMLDoc( elem
) ) {
6952 name
= name
.toLowerCase();
6953 hooks
= jQuery
.attrHooks
[ name
] ||
6954 ( jQuery
.expr
.match
.bool
.test( name
) ? boolHook : nodeHook
);
6957 if ( value
!== undefined ) {
6959 if ( value
=== null ) {
6960 jQuery
.removeAttr( elem
, name
);
6962 } else if ( hooks
&& "set" in hooks
&& (ret
= hooks
.set( elem
, value
, name
)) !== undefined ) {
6966 elem
.setAttribute( name
, value
+ "" );
6970 } else if ( hooks
&& "get" in hooks
&& (ret
= hooks
.get( elem
, name
)) !== null ) {
6974 ret
= jQuery
.find
.attr( elem
, name
);
6976 // Non-existent attributes return null, we normalize to undefined
6977 return ret
== null ?
6983 removeAttr: function( elem
, value
) {
6986 attrNames
= value
&& value
.match( rnotwhite
);
6988 if ( attrNames
&& elem
.nodeType
=== 1 ) {
6989 while ( (name
= attrNames
[i
++]) ) {
6990 propName
= jQuery
.propFix
[ name
] || name
;
6992 // Boolean attributes get special treatment (#10870)
6993 if ( jQuery
.expr
.match
.bool
.test( name
) ) {
6994 // Set corresponding property to false
6995 elem
[ propName
] = false;
6998 elem
.removeAttribute( name
);
7005 set: function( elem
, value
) {
7006 if ( !support
.radioValue
&& value
=== "radio" &&
7007 jQuery
.nodeName( elem
, "input" ) ) {
7008 // Setting the type on a radio button after the value resets the value in IE6-9
7009 // Reset value to default in case type is set after value during creation
7010 var val
= elem
.value
;
7011 elem
.setAttribute( "type", value
);
7022 // Hooks for boolean attributes
7024 set: function( elem
, value
, name
) {
7025 if ( value
=== false ) {
7026 // Remove boolean attributes when set to false
7027 jQuery
.removeAttr( elem
, name
);
7029 elem
.setAttribute( name
, name
);
7034 jQuery
.each( jQuery
.expr
.match
.bool
.source
.match( /\w+/g ), function( i
, name
) {
7035 var getter
= attrHandle
[ name
] || jQuery
.find
.attr
;
7037 attrHandle
[ name
] = function( elem
, name
, isXML
) {
7040 // Avoid an infinite loop by temporarily removing this function from the getter
7041 handle
= attrHandle
[ name
];
7042 attrHandle
[ name
] = ret
;
7043 ret
= getter( elem
, name
, isXML
) != null ?
7044 name
.toLowerCase() :
7046 attrHandle
[ name
] = handle
;
7055 var rfocusable
= /^(?:input|select|textarea|button)$/i;
7058 prop: function( name
, value
) {
7059 return access( this, jQuery
.prop
, name
, value
, arguments
.length
> 1 );
7062 removeProp: function( name
) {
7063 return this.each(function() {
7064 delete this[ jQuery
.propFix
[ name
] || name
];
7072 "class": "className"
7075 prop: function( elem
, name
, value
) {
7076 var ret
, hooks
, notxml
,
7077 nType
= elem
.nodeType
;
7079 // don't get/set properties on text, comment and attribute nodes
7080 if ( !elem
|| nType
=== 3 || nType
=== 8 || nType
=== 2 ) {
7084 notxml
= nType
!== 1 || !jQuery
.isXMLDoc( elem
);
7087 // Fix name and attach hooks
7088 name
= jQuery
.propFix
[ name
] || name
;
7089 hooks
= jQuery
.propHooks
[ name
];
7092 if ( value
!== undefined ) {
7093 return hooks
&& "set" in hooks
&& (ret
= hooks
.set( elem
, value
, name
)) !== undefined ?
7095 ( elem
[ name
] = value
);
7098 return hooks
&& "get" in hooks
&& (ret
= hooks
.get( elem
, name
)) !== null ?
7106 get: function( elem
) {
7107 return elem
.hasAttribute( "tabindex" ) || rfocusable
.test( elem
.nodeName
) || elem
.href
?
7116 // Selectedness for an option in an optgroup can be inaccurate
7117 if ( !support
.optSelected
) {
7118 jQuery
.propHooks
.selected
= {
7119 get: function( elem
) {
7120 var parent
= elem
.parentNode
;
7121 if ( parent
&& parent
.parentNode
) {
7122 parent
.parentNode
.selectedIndex
;
7141 jQuery
.propFix
[ this.toLowerCase() ] = this;
7147 var rclass
= /[\t\r\n\f]/g;
7150 addClass: function( value
) {
7151 var classes
, elem
, cur
, clazz
, j
, finalValue
,
7152 proceed
= typeof value
=== "string" && value
,
7156 if ( jQuery
.isFunction( value
) ) {
7157 return this.each(function( j
) {
7158 jQuery( this ).addClass( value
.call( this, j
, this.className
) );
7163 // The disjunction here is for better compressibility (see removeClass)
7164 classes
= ( value
|| "" ).match( rnotwhite
) || [];
7166 for ( ; i
< len
; i
++ ) {
7168 cur
= elem
.nodeType
=== 1 && ( elem
.className
?
7169 ( " " + elem
.className
+ " " ).replace( rclass
, " " ) :
7175 while ( (clazz
= classes
[j
++]) ) {
7176 if ( cur
.indexOf( " " + clazz
+ " " ) < 0 ) {
7181 // only assign if different to avoid unneeded rendering.
7182 finalValue
= jQuery
.trim( cur
);
7183 if ( elem
.className
!== finalValue
) {
7184 elem
.className
= finalValue
;
7193 removeClass: function( value
) {
7194 var classes
, elem
, cur
, clazz
, j
, finalValue
,
7195 proceed
= arguments
.length
=== 0 || typeof value
=== "string" && value
,
7199 if ( jQuery
.isFunction( value
) ) {
7200 return this.each(function( j
) {
7201 jQuery( this ).removeClass( value
.call( this, j
, this.className
) );
7205 classes
= ( value
|| "" ).match( rnotwhite
) || [];
7207 for ( ; i
< len
; i
++ ) {
7209 // This expression is here for better compressibility (see addClass)
7210 cur
= elem
.nodeType
=== 1 && ( elem
.className
?
7211 ( " " + elem
.className
+ " " ).replace( rclass
, " " ) :
7217 while ( (clazz
= classes
[j
++]) ) {
7218 // Remove *all* instances
7219 while ( cur
.indexOf( " " + clazz
+ " " ) >= 0 ) {
7220 cur
= cur
.replace( " " + clazz
+ " ", " " );
7224 // only assign if different to avoid unneeded rendering.
7225 finalValue
= value
? jQuery
.trim( cur
) : "";
7226 if ( elem
.className
!== finalValue
) {
7227 elem
.className
= finalValue
;
7236 toggleClass: function( value
, stateVal
) {
7237 var type
= typeof value
;
7239 if ( typeof stateVal
=== "boolean" && type
=== "string" ) {
7240 return stateVal
? this.addClass( value
) : this.removeClass( value
);
7243 if ( jQuery
.isFunction( value
) ) {
7244 return this.each(function( i
) {
7245 jQuery( this ).toggleClass( value
.call(this, i
, this.className
, stateVal
), stateVal
);
7249 return this.each(function() {
7250 if ( type
=== "string" ) {
7251 // toggle individual class names
7254 self
= jQuery( this ),
7255 classNames
= value
.match( rnotwhite
) || [];
7257 while ( (className
= classNames
[ i
++ ]) ) {
7258 // check each className given, space separated list
7259 if ( self
.hasClass( className
) ) {
7260 self
.removeClass( className
);
7262 self
.addClass( className
);
7266 // Toggle whole class name
7267 } else if ( type
=== strundefined
|| type
=== "boolean" ) {
7268 if ( this.className
) {
7269 // store className if set
7270 data_priv
.set( this, "__className__", this.className
);
7273 // If the element has a class name or if we're passed "false",
7274 // then remove the whole classname (if there was one, the above saved it).
7275 // Otherwise bring back whatever was previously saved (if anything),
7276 // falling back to the empty string if nothing was stored.
7277 this.className
= this.className
|| value
=== false ? "" : data_priv
.get( this, "__className__" ) || "";
7282 hasClass: function( selector
) {
7283 var className
= " " + selector
+ " ",
7286 for ( ; i
< l
; i
++ ) {
7287 if ( this[i
].nodeType
=== 1 && (" " + this[i
].className
+ " ").replace(rclass
, " ").indexOf( className
) >= 0 ) {
7299 var rreturn
= /\r/g;
7302 val: function( value
) {
7303 var hooks
, ret
, isFunction
,
7306 if ( !arguments
.length
) {
7308 hooks
= jQuery
.valHooks
[ elem
.type
] || jQuery
.valHooks
[ elem
.nodeName
.toLowerCase() ];
7310 if ( hooks
&& "get" in hooks
&& (ret
= hooks
.get( elem
, "value" )) !== undefined ) {
7316 return typeof ret
=== "string" ?
7317 // handle most common string cases
7318 ret
.replace(rreturn
, "") :
7319 // handle cases where value is null/undef or number
7320 ret
== null ? "" : ret
;
7326 isFunction
= jQuery
.isFunction( value
);
7328 return this.each(function( i
) {
7331 if ( this.nodeType
!== 1 ) {
7336 val
= value
.call( this, i
, jQuery( this ).val() );
7341 // Treat null/undefined as ""; convert numbers to string
7342 if ( val
== null ) {
7345 } else if ( typeof val
=== "number" ) {
7348 } else if ( jQuery
.isArray( val
) ) {
7349 val
= jQuery
.map( val
, function( value
) {
7350 return value
== null ? "" : value
+ "";
7354 hooks
= jQuery
.valHooks
[ this.type
] || jQuery
.valHooks
[ this.nodeName
.toLowerCase() ];
7356 // If set returns undefined, fall back to normal setting
7357 if ( !hooks
|| !("set" in hooks
) || hooks
.set( this, val
, "value" ) === undefined ) {
7367 get: function( elem
) {
7368 var val
= jQuery
.find
.attr( elem
, "value" );
7369 return val
!= null ?
7371 // Support: IE10-11+
7372 // option.text throws exceptions (#14686, #14858)
7373 jQuery
.trim( jQuery
.text( elem
) );
7377 get: function( elem
) {
7379 options
= elem
.options
,
7380 index
= elem
.selectedIndex
,
7381 one
= elem
.type
=== "select-one" || index
< 0,
7382 values
= one
? null : [],
7383 max
= one
? index
+ 1 : options
.length
,
7388 // Loop through all the selected options
7389 for ( ; i
< max
; i
++ ) {
7390 option
= options
[ i
];
7392 // IE6-9 doesn't update selected after form reset (#2551)
7393 if ( ( option
.selected
|| i
=== index
) &&
7394 // Don't return options that are disabled or in a disabled optgroup
7395 ( support
.optDisabled
? !option
.disabled : option
.getAttribute( "disabled" ) === null ) &&
7396 ( !option
.parentNode
.disabled
|| !jQuery
.nodeName( option
.parentNode
, "optgroup" ) ) ) {
7398 // Get the specific value for the option
7399 value
= jQuery( option
).val();
7401 // We don't need an array for one selects
7406 // Multi-Selects return an array
7407 values
.push( value
);
7414 set: function( elem
, value
) {
7415 var optionSet
, option
,
7416 options
= elem
.options
,
7417 values
= jQuery
.makeArray( value
),
7421 option
= options
[ i
];
7422 if ( (option
.selected
= jQuery
.inArray( option
.value
, values
) >= 0) ) {
7427 // force browsers to behave consistently when non-matching value is set
7429 elem
.selectedIndex
= -1;
7437 // Radios and checkboxes getter/setter
7438 jQuery
.each([ "radio", "checkbox" ], function() {
7439 jQuery
.valHooks
[ this ] = {
7440 set: function( elem
, value
) {
7441 if ( jQuery
.isArray( value
) ) {
7442 return ( elem
.checked
= jQuery
.inArray( jQuery(elem
).val(), value
) >= 0 );
7446 if ( !support
.checkOn
) {
7447 jQuery
.valHooks
[ this ].get = function( elem
) {
7449 // "" is returned instead of "on" if a value isn't specified
7450 return elem
.getAttribute("value") === null ? "on" : elem
.value
;
7458 // Return jQuery for attributes-only inclusion
7461 jQuery
.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
7462 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
7463 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i
, name
) {
7465 // Handle event binding
7466 jQuery
.fn
[ name
] = function( data
, fn
) {
7467 return arguments
.length
> 0 ?
7468 this.on( name
, null, data
, fn
) :
7469 this.trigger( name
);
7474 hover: function( fnOver
, fnOut
) {
7475 return this.mouseenter( fnOver
).mouseleave( fnOut
|| fnOver
);
7478 bind: function( types
, data
, fn
) {
7479 return this.on( types
, null, data
, fn
);
7481 unbind: function( types
, fn
) {
7482 return this.off( types
, null, fn
);
7485 delegate: function( selector
, types
, data
, fn
) {
7486 return this.on( types
, selector
, data
, fn
);
7488 undelegate: function( selector
, types
, fn
) {
7489 // ( namespace ) or ( selector, types [, fn] )
7490 return arguments
.length
=== 1 ? this.off( selector
, "**" ) : this.off( types
, selector
|| "**", fn
);
7495 var nonce
= jQuery
.now();
7497 var rquery
= (/\?/);
7501 // Support: Android 2.3
7502 // Workaround failure to string-cast null input
7503 jQuery
.parseJSON = function( data
) {
7504 return JSON
.parse( data
+ "" );
7508 // Cross-browser xml parsing
7509 jQuery
.parseXML = function( data
) {
7511 if ( !data
|| typeof data
!== "string" ) {
7517 tmp
= new DOMParser();
7518 xml
= tmp
.parseFromString( data
, "text/xml" );
7523 if ( !xml
|| xml
.getElementsByTagName( "parsererror" ).length
) {
7524 jQuery
.error( "Invalid XML: " + data
);
7531 // Document location
7536 rts
= /([?&])_=[^&]*/,
7537 rheaders
= /^(.*?):[ \t]*([^\r\n]*)$/mg
,
7538 // #7653, #8125, #8152: local protocol detection
7539 rlocalProtocol
= /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
7540 rnoContent
= /^(?:GET|HEAD)$/,
7541 rprotocol
= /^\/\//,
7542 rurl
= /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
7545 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
7546 * 2) These are called:
7547 * - BEFORE asking for a transport
7548 * - AFTER param serialization (s.data is a string if s.processData is true)
7549 * 3) key is the dataType
7550 * 4) the catchall symbol "*" can be used
7551 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
7555 /* Transports bindings
7556 * 1) key is the dataType
7557 * 2) the catchall symbol "*" can be used
7558 * 3) selection will start with transport dataType and THEN go to "*" if needed
7562 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
7563 allTypes
= "*/".concat("*");
7565 // #8138, IE may throw an exception when accessing
7566 // a field from window.location if document.domain has been set
7568 ajaxLocation
= location
.href
;
7570 // Use the href attribute of an A element
7571 // since IE will modify it given document.location
7572 ajaxLocation
= document
.createElement( "a" );
7573 ajaxLocation
.href
= "";
7574 ajaxLocation
= ajaxLocation
.href
;
7577 // Segment location into parts
7578 ajaxLocParts
= rurl
.exec( ajaxLocation
.toLowerCase() ) || [];
7580 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
7581 function addToPrefiltersOrTransports( structure
) {
7583 // dataTypeExpression is optional and defaults to "*"
7584 return function( dataTypeExpression
, func
) {
7586 if ( typeof dataTypeExpression
!== "string" ) {
7587 func
= dataTypeExpression
;
7588 dataTypeExpression
= "*";
7593 dataTypes
= dataTypeExpression
.toLowerCase().match( rnotwhite
) || [];
7595 if ( jQuery
.isFunction( func
) ) {
7596 // For each dataType in the dataTypeExpression
7597 while ( (dataType
= dataTypes
[i
++]) ) {
7598 // Prepend if requested
7599 if ( dataType
[0] === "+" ) {
7600 dataType
= dataType
.slice( 1 ) || "*";
7601 (structure
[ dataType
] = structure
[ dataType
] || []).unshift( func
);
7605 (structure
[ dataType
] = structure
[ dataType
] || []).push( func
);
7612 // Base inspection function for prefilters and transports
7613 function inspectPrefiltersOrTransports( structure
, options
, originalOptions
, jqXHR
) {
7616 seekingTransport
= ( structure
=== transports
);
7618 function inspect( dataType
) {
7620 inspected
[ dataType
] = true;
7621 jQuery
.each( structure
[ dataType
] || [], function( _
, prefilterOrFactory
) {
7622 var dataTypeOrTransport
= prefilterOrFactory( options
, originalOptions
, jqXHR
);
7623 if ( typeof dataTypeOrTransport
=== "string" && !seekingTransport
&& !inspected
[ dataTypeOrTransport
] ) {
7624 options
.dataTypes
.unshift( dataTypeOrTransport
);
7625 inspect( dataTypeOrTransport
);
7627 } else if ( seekingTransport
) {
7628 return !( selected
= dataTypeOrTransport
);
7634 return inspect( options
.dataTypes
[ 0 ] ) || !inspected
[ "*" ] && inspect( "*" );
7637 // A special extend for ajax options
7638 // that takes "flat" options (not to be deep extended)
7640 function ajaxExtend( target
, src
) {
7642 flatOptions
= jQuery
.ajaxSettings
.flatOptions
|| {};
7644 for ( key
in src
) {
7645 if ( src
[ key
] !== undefined ) {
7646 ( flatOptions
[ key
] ? target : ( deep
|| (deep
= {}) ) )[ key
] = src
[ key
];
7650 jQuery
.extend( true, target
, deep
);
7656 /* Handles responses to an ajax request:
7657 * - finds the right dataType (mediates between content-type and expected dataType)
7658 * - returns the corresponding response
7660 function ajaxHandleResponses( s
, jqXHR
, responses
) {
7662 var ct
, type
, finalDataType
, firstDataType
,
7663 contents
= s
.contents
,
7664 dataTypes
= s
.dataTypes
;
7666 // Remove auto dataType and get content-type in the process
7667 while ( dataTypes
[ 0 ] === "*" ) {
7669 if ( ct
=== undefined ) {
7670 ct
= s
.mimeType
|| jqXHR
.getResponseHeader("Content-Type");
7674 // Check if we're dealing with a known content-type
7676 for ( type
in contents
) {
7677 if ( contents
[ type
] && contents
[ type
].test( ct
) ) {
7678 dataTypes
.unshift( type
);
7684 // Check to see if we have a response for the expected dataType
7685 if ( dataTypes
[ 0 ] in responses
) {
7686 finalDataType
= dataTypes
[ 0 ];
7688 // Try convertible dataTypes
7689 for ( type
in responses
) {
7690 if ( !dataTypes
[ 0 ] || s
.converters
[ type
+ " " + dataTypes
[0] ] ) {
7691 finalDataType
= type
;
7694 if ( !firstDataType
) {
7695 firstDataType
= type
;
7698 // Or just use first one
7699 finalDataType
= finalDataType
|| firstDataType
;
7702 // If we found a dataType
7703 // We add the dataType to the list if needed
7704 // and return the corresponding response
7705 if ( finalDataType
) {
7706 if ( finalDataType
!== dataTypes
[ 0 ] ) {
7707 dataTypes
.unshift( finalDataType
);
7709 return responses
[ finalDataType
];
7713 /* Chain conversions given the request and the original response
7714 * Also sets the responseXXX fields on the jqXHR instance
7716 function ajaxConvert( s
, response
, jqXHR
, isSuccess
) {
7717 var conv2
, current
, conv
, tmp
, prev
,
7719 // Work with a copy of dataTypes in case we need to modify it for conversion
7720 dataTypes
= s
.dataTypes
.slice();
7722 // Create converters map with lowercased keys
7723 if ( dataTypes
[ 1 ] ) {
7724 for ( conv
in s
.converters
) {
7725 converters
[ conv
.toLowerCase() ] = s
.converters
[ conv
];
7729 current
= dataTypes
.shift();
7731 // Convert to each sequential dataType
7734 if ( s
.responseFields
[ current
] ) {
7735 jqXHR
[ s
.responseFields
[ current
] ] = response
;
7738 // Apply the dataFilter if provided
7739 if ( !prev
&& isSuccess
&& s
.dataFilter
) {
7740 response
= s
.dataFilter( response
, s
.dataType
);
7744 current
= dataTypes
.shift();
7748 // There's only work to do if current dataType is non-auto
7749 if ( current
=== "*" ) {
7753 // Convert response if prev dataType is non-auto and differs from current
7754 } else if ( prev
!== "*" && prev
!== current
) {
7756 // Seek a direct converter
7757 conv
= converters
[ prev
+ " " + current
] || converters
[ "* " + current
];
7759 // If none found, seek a pair
7761 for ( conv2
in converters
) {
7763 // If conv2 outputs current
7764 tmp
= conv2
.split( " " );
7765 if ( tmp
[ 1 ] === current
) {
7767 // If prev can be converted to accepted input
7768 conv
= converters
[ prev
+ " " + tmp
[ 0 ] ] ||
7769 converters
[ "* " + tmp
[ 0 ] ];
7771 // Condense equivalence converters
7772 if ( conv
=== true ) {
7773 conv
= converters
[ conv2
];
7775 // Otherwise, insert the intermediate dataType
7776 } else if ( converters
[ conv2
] !== true ) {
7778 dataTypes
.unshift( tmp
[ 1 ] );
7786 // Apply converter (if not an equivalence)
7787 if ( conv
!== true ) {
7789 // Unless errors are allowed to bubble, catch and return them
7790 if ( conv
&& s
[ "throws" ] ) {
7791 response
= conv( response
);
7794 response
= conv( response
);
7796 return { state: "parsererror", error: conv
? e : "No conversion from " + prev
+ " to " + current
};
7804 return { state: "success", data: response
};
7809 // Counter for holding the number of active queries
7812 // Last-Modified header cache for next request
7819 isLocal: rlocalProtocol
.test( ajaxLocParts
[ 1 ] ),
7823 contentType: "application/x-www-form-urlencoded; charset=UTF-8",
7840 xml: "application/xml, text/xml",
7841 json: "application/json, text/javascript"
7852 text: "responseText",
7853 json: "responseJSON"
7857 // Keys separate source (or catchall "*") and destination types with a single space
7860 // Convert anything to text
7863 // Text to html (true = no transformation)
7866 // Evaluate text as a json expression
7867 "text json": jQuery
.parseJSON
,
7869 // Parse text as xml
7870 "text xml": jQuery
.parseXML
7873 // For options that shouldn't be deep extended:
7874 // you can add your own custom options here if
7875 // and when you create one that shouldn't be
7876 // deep extended (see ajaxExtend)
7883 // Creates a full fledged settings object into target
7884 // with both ajaxSettings and settings fields.
7885 // If target is omitted, writes into ajaxSettings.
7886 ajaxSetup: function( target
, settings
) {
7889 // Building a settings object
7890 ajaxExtend( ajaxExtend( target
, jQuery
.ajaxSettings
), settings
) :
7892 // Extending ajaxSettings
7893 ajaxExtend( jQuery
.ajaxSettings
, target
);
7896 ajaxPrefilter: addToPrefiltersOrTransports( prefilters
),
7897 ajaxTransport: addToPrefiltersOrTransports( transports
),
7900 ajax: function( url
, options
) {
7902 // If url is an object, simulate pre-1.5 signature
7903 if ( typeof url
=== "object" ) {
7908 // Force options to be an object
7909 options
= options
|| {};
7912 // URL without anti-cache param
7915 responseHeadersString
,
7919 // Cross-domain detection vars
7921 // To know if global events are to be dispatched
7925 // Create the final options object
7926 s
= jQuery
.ajaxSetup( {}, options
),
7927 // Callbacks context
7928 callbackContext
= s
.context
|| s
,
7929 // Context for global events is callbackContext if it is a DOM node or jQuery collection
7930 globalEventContext
= s
.context
&& ( callbackContext
.nodeType
|| callbackContext
.jquery
) ?
7931 jQuery( callbackContext
) :
7934 deferred
= jQuery
.Deferred(),
7935 completeDeferred
= jQuery
.Callbacks("once memory"),
7936 // Status-dependent callbacks
7937 statusCode
= s
.statusCode
|| {},
7938 // Headers (they are sent all at once)
7939 requestHeaders
= {},
7940 requestHeadersNames
= {},
7943 // Default abort message
7944 strAbort
= "canceled",
7949 // Builds headers hashtable if needed
7950 getResponseHeader: function( key
) {
7952 if ( state
=== 2 ) {
7953 if ( !responseHeaders
) {
7954 responseHeaders
= {};
7955 while ( (match
= rheaders
.exec( responseHeadersString
)) ) {
7956 responseHeaders
[ match
[1].toLowerCase() ] = match
[ 2 ];
7959 match
= responseHeaders
[ key
.toLowerCase() ];
7961 return match
== null ? null : match
;
7965 getAllResponseHeaders: function() {
7966 return state
=== 2 ? responseHeadersString : null;
7969 // Caches the header
7970 setRequestHeader: function( name
, value
) {
7971 var lname
= name
.toLowerCase();
7973 name
= requestHeadersNames
[ lname
] = requestHeadersNames
[ lname
] || name
;
7974 requestHeaders
[ name
] = value
;
7979 // Overrides response content-type header
7980 overrideMimeType: function( type
) {
7987 // Status-dependent callbacks
7988 statusCode: function( map
) {
7992 for ( code
in map
) {
7993 // Lazy-add the new callback in a way that preserves old ones
7994 statusCode
[ code
] = [ statusCode
[ code
], map
[ code
] ];
7997 // Execute the appropriate callbacks
7998 jqXHR
.always( map
[ jqXHR
.status
] );
8004 // Cancel the request
8005 abort: function( statusText
) {
8006 var finalText
= statusText
|| strAbort
;
8008 transport
.abort( finalText
);
8010 done( 0, finalText
);
8016 deferred
.promise( jqXHR
).complete
= completeDeferred
.add
;
8017 jqXHR
.success
= jqXHR
.done
;
8018 jqXHR
.error
= jqXHR
.fail
;
8020 // Remove hash character (#7531: and string promotion)
8021 // Add protocol if not provided (prefilters might expect it)
8022 // Handle falsy url in the settings object (#10093: consistency with old signature)
8023 // We also use the url parameter if available
8024 s
.url
= ( ( url
|| s
.url
|| ajaxLocation
) + "" ).replace( rhash
, "" )
8025 .replace( rprotocol
, ajaxLocParts
[ 1 ] + "//" );
8027 // Alias method option to type as per ticket #12004
8028 s
.type
= options
.method
|| options
.type
|| s
.method
|| s
.type
;
8030 // Extract dataTypes list
8031 s
.dataTypes
= jQuery
.trim( s
.dataType
|| "*" ).toLowerCase().match( rnotwhite
) || [ "" ];
8033 // A cross-domain request is in order when we have a protocol:host:port mismatch
8034 if ( s
.crossDomain
== null ) {
8035 parts
= rurl
.exec( s
.url
.toLowerCase() );
8036 s
.crossDomain
= !!( parts
&&
8037 ( parts
[ 1 ] !== ajaxLocParts
[ 1 ] || parts
[ 2 ] !== ajaxLocParts
[ 2 ] ||
8038 ( parts
[ 3 ] || ( parts
[ 1 ] === "http:" ? "80" : "443" ) ) !==
8039 ( ajaxLocParts
[ 3 ] || ( ajaxLocParts
[ 1 ] === "http:" ? "80" : "443" ) ) )
8043 // Convert data if not already a string
8044 if ( s
.data
&& s
.processData
&& typeof s
.data
!== "string" ) {
8045 s
.data
= jQuery
.param( s
.data
, s
.traditional
);
8049 inspectPrefiltersOrTransports( prefilters
, s
, options
, jqXHR
);
8051 // If request was aborted inside a prefilter, stop there
8052 if ( state
=== 2 ) {
8056 // We can fire global events as of now if asked to
8057 fireGlobals
= s
.global
;
8059 // Watch for a new set of requests
8060 if ( fireGlobals
&& jQuery
.active
++ === 0 ) {
8061 jQuery
.event
.trigger("ajaxStart");
8064 // Uppercase the type
8065 s
.type
= s
.type
.toUpperCase();
8067 // Determine if request has content
8068 s
.hasContent
= !rnoContent
.test( s
.type
);
8070 // Save the URL in case we're toying with the If-Modified-Since
8071 // and/or If-None-Match header later on
8074 // More options handling for requests with no content
8075 if ( !s
.hasContent
) {
8077 // If data is available, append data to url
8079 cacheURL
= ( s
.url
+= ( rquery
.test( cacheURL
) ? "&" : "?" ) + s
.data
);
8080 // #9682: remove data so that it's not used in an eventual retry
8084 // Add anti-cache in url if needed
8085 if ( s
.cache
=== false ) {
8086 s
.url
= rts
.test( cacheURL
) ?
8088 // If there is already a '_' parameter, set its value
8089 cacheURL
.replace( rts
, "$1_=" + nonce
++ ) :
8091 // Otherwise add one to the end
8092 cacheURL
+ ( rquery
.test( cacheURL
) ? "&" : "?" ) + "_=" + nonce
++;
8096 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
8097 if ( s
.ifModified
) {
8098 if ( jQuery
.lastModified
[ cacheURL
] ) {
8099 jqXHR
.setRequestHeader( "If-Modified-Since", jQuery
.lastModified
[ cacheURL
] );
8101 if ( jQuery
.etag
[ cacheURL
] ) {
8102 jqXHR
.setRequestHeader( "If-None-Match", jQuery
.etag
[ cacheURL
] );
8106 // Set the correct header, if data is being sent
8107 if ( s
.data
&& s
.hasContent
&& s
.contentType
!== false || options
.contentType
) {
8108 jqXHR
.setRequestHeader( "Content-Type", s
.contentType
);
8111 // Set the Accepts header for the server, depending on the dataType
8112 jqXHR
.setRequestHeader(
8114 s
.dataTypes
[ 0 ] && s
.accepts
[ s
.dataTypes
[0] ] ?
8115 s
.accepts
[ s
.dataTypes
[0] ] + ( s
.dataTypes
[ 0 ] !== "*" ? ", " + allTypes
+ "; q=0.01" : "" ) :
8119 // Check for headers option
8120 for ( i
in s
.headers
) {
8121 jqXHR
.setRequestHeader( i
, s
.headers
[ i
] );
8124 // Allow custom headers/mimetypes and early abort
8125 if ( s
.beforeSend
&& ( s
.beforeSend
.call( callbackContext
, jqXHR
, s
) === false || state
=== 2 ) ) {
8126 // Abort if not done already and return
8127 return jqXHR
.abort();
8130 // aborting is no longer a cancellation
8133 // Install callbacks on deferreds
8134 for ( i
in { success: 1, error: 1, complete: 1 } ) {
8135 jqXHR
[ i
]( s
[ i
] );
8139 transport
= inspectPrefiltersOrTransports( transports
, s
, options
, jqXHR
);
8141 // If no transport, we auto-abort
8143 done( -1, "No Transport" );
8145 jqXHR
.readyState
= 1;
8147 // Send global event
8148 if ( fireGlobals
) {
8149 globalEventContext
.trigger( "ajaxSend", [ jqXHR
, s
] );
8152 if ( s
.async
&& s
.timeout
> 0 ) {
8153 timeoutTimer
= setTimeout(function() {
8154 jqXHR
.abort("timeout");
8160 transport
.send( requestHeaders
, done
);
8162 // Propagate exception as error if not done
8165 // Simply rethrow otherwise
8172 // Callback for when everything is done
8173 function done( status
, nativeStatusText
, responses
, headers
) {
8174 var isSuccess
, success
, error
, response
, modified
,
8175 statusText
= nativeStatusText
;
8178 if ( state
=== 2 ) {
8182 // State is "done" now
8185 // Clear timeout if it exists
8186 if ( timeoutTimer
) {
8187 clearTimeout( timeoutTimer
);
8190 // Dereference transport for early garbage collection
8191 // (no matter how long the jqXHR object will be used)
8192 transport
= undefined;
8194 // Cache response headers
8195 responseHeadersString
= headers
|| "";
8198 jqXHR
.readyState
= status
> 0 ? 4 : 0;
8200 // Determine if successful
8201 isSuccess
= status
>= 200 && status
< 300 || status
=== 304;
8203 // Get response data
8205 response
= ajaxHandleResponses( s
, jqXHR
, responses
);
8208 // Convert no matter what (that way responseXXX fields are always set)
8209 response
= ajaxConvert( s
, response
, jqXHR
, isSuccess
);
8211 // If successful, handle type chaining
8214 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
8215 if ( s
.ifModified
) {
8216 modified
= jqXHR
.getResponseHeader("Last-Modified");
8218 jQuery
.lastModified
[ cacheURL
] = modified
;
8220 modified
= jqXHR
.getResponseHeader("etag");
8222 jQuery
.etag
[ cacheURL
] = modified
;
8227 if ( status
=== 204 || s
.type
=== "HEAD" ) {
8228 statusText
= "nocontent";
8231 } else if ( status
=== 304 ) {
8232 statusText
= "notmodified";
8234 // If we have data, let's convert it
8236 statusText
= response
.state
;
8237 success
= response
.data
;
8238 error
= response
.error
;
8242 // We extract error from statusText
8243 // then normalize statusText and status for non-aborts
8245 if ( status
|| !statusText
) {
8246 statusText
= "error";
8253 // Set data for the fake xhr object
8254 jqXHR
.status
= status
;
8255 jqXHR
.statusText
= ( nativeStatusText
|| statusText
) + "";
8259 deferred
.resolveWith( callbackContext
, [ success
, statusText
, jqXHR
] );
8261 deferred
.rejectWith( callbackContext
, [ jqXHR
, statusText
, error
] );
8264 // Status-dependent callbacks
8265 jqXHR
.statusCode( statusCode
);
8266 statusCode
= undefined;
8268 if ( fireGlobals
) {
8269 globalEventContext
.trigger( isSuccess
? "ajaxSuccess" : "ajaxError",
8270 [ jqXHR
, s
, isSuccess
? success : error
] );
8274 completeDeferred
.fireWith( callbackContext
, [ jqXHR
, statusText
] );
8276 if ( fireGlobals
) {
8277 globalEventContext
.trigger( "ajaxComplete", [ jqXHR
, s
] );
8278 // Handle the global AJAX counter
8279 if ( !( --jQuery
.active
) ) {
8280 jQuery
.event
.trigger("ajaxStop");
8288 getJSON: function( url
, data
, callback
) {
8289 return jQuery
.get( url
, data
, callback
, "json" );
8292 getScript: function( url
, callback
) {
8293 return jQuery
.get( url
, undefined, callback
, "script" );
8297 jQuery
.each( [ "get", "post" ], function( i
, method
) {
8298 jQuery
[ method
] = function( url
, data
, callback
, type
) {
8299 // shift arguments if data argument was omitted
8300 if ( jQuery
.isFunction( data
) ) {
8301 type
= type
|| callback
;
8306 return jQuery
.ajax({
8316 // Attach a bunch of functions for handling common AJAX events
8317 jQuery
.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i
, type
) {
8318 jQuery
.fn
[ type
] = function( fn
) {
8319 return this.on( type
, fn
);
8324 jQuery
._evalUrl = function( url
) {
8325 return jQuery
.ajax({
8337 wrapAll: function( html
) {
8340 if ( jQuery
.isFunction( html
) ) {
8341 return this.each(function( i
) {
8342 jQuery( this ).wrapAll( html
.call(this, i
) );
8348 // The elements to wrap the target around
8349 wrap
= jQuery( html
, this[ 0 ].ownerDocument
).eq( 0 ).clone( true );
8351 if ( this[ 0 ].parentNode
) {
8352 wrap
.insertBefore( this[ 0 ] );
8355 wrap
.map(function() {
8358 while ( elem
.firstElementChild
) {
8359 elem
= elem
.firstElementChild
;
8369 wrapInner: function( html
) {
8370 if ( jQuery
.isFunction( html
) ) {
8371 return this.each(function( i
) {
8372 jQuery( this ).wrapInner( html
.call(this, i
) );
8376 return this.each(function() {
8377 var self
= jQuery( this ),
8378 contents
= self
.contents();
8380 if ( contents
.length
) {
8381 contents
.wrapAll( html
);
8384 self
.append( html
);
8389 wrap: function( html
) {
8390 var isFunction
= jQuery
.isFunction( html
);
8392 return this.each(function( i
) {
8393 jQuery( this ).wrapAll( isFunction
? html
.call(this, i
) : html
);
8397 unwrap: function() {
8398 return this.parent().each(function() {
8399 if ( !jQuery
.nodeName( this, "body" ) ) {
8400 jQuery( this ).replaceWith( this.childNodes
);
8407 jQuery
.expr
.filters
.hidden = function( elem
) {
8408 // Support: Opera <= 12.12
8409 // Opera reports offsetWidths and offsetHeights less than zero on some elements
8410 return elem
.offsetWidth
<= 0 && elem
.offsetHeight
<= 0;
8412 jQuery
.expr
.filters
.visible = function( elem
) {
8413 return !jQuery
.expr
.filters
.hidden( elem
);
8422 rsubmitterTypes
= /^(?:submit|button|image|reset|file)$/i,
8423 rsubmittable
= /^(?:input|select|textarea|keygen)/i;
8425 function buildParams( prefix
, obj
, traditional
, add
) {
8428 if ( jQuery
.isArray( obj
) ) {
8429 // Serialize array item.
8430 jQuery
.each( obj
, function( i
, v
) {
8431 if ( traditional
|| rbracket
.test( prefix
) ) {
8432 // Treat each array item as a scalar.
8436 // Item is non-scalar (array or object), encode its numeric index.
8437 buildParams( prefix
+ "[" + ( typeof v
=== "object" ? i : "" ) + "]", v
, traditional
, add
);
8441 } else if ( !traditional
&& jQuery
.type( obj
) === "object" ) {
8442 // Serialize object item.
8443 for ( name
in obj
) {
8444 buildParams( prefix
+ "[" + name
+ "]", obj
[ name
], traditional
, add
);
8448 // Serialize scalar item.
8453 // Serialize an array of form elements or a set of
8454 // key/values into a query string
8455 jQuery
.param = function( a
, traditional
) {
8458 add = function( key
, value
) {
8459 // If value is a function, invoke it and return its value
8460 value
= jQuery
.isFunction( value
) ? value() : ( value
== null ? "" : value
);
8461 s
[ s
.length
] = encodeURIComponent( key
) + "=" + encodeURIComponent( value
);
8464 // Set traditional to true for jQuery <= 1.3.2 behavior.
8465 if ( traditional
=== undefined ) {
8466 traditional
= jQuery
.ajaxSettings
&& jQuery
.ajaxSettings
.traditional
;
8469 // If an array was passed in, assume that it is an array of form elements.
8470 if ( jQuery
.isArray( a
) || ( a
.jquery
&& !jQuery
.isPlainObject( a
) ) ) {
8471 // Serialize the form elements
8472 jQuery
.each( a
, function() {
8473 add( this.name
, this.value
);
8477 // If traditional, encode the "old" way (the way 1.3.2 or older
8478 // did it), otherwise encode params recursively.
8479 for ( prefix
in a
) {
8480 buildParams( prefix
, a
[ prefix
], traditional
, add
);
8484 // Return the resulting serialization
8485 return s
.join( "&" ).replace( r20
, "+" );
8489 serialize: function() {
8490 return jQuery
.param( this.serializeArray() );
8492 serializeArray: function() {
8493 return this.map(function() {
8494 // Can add propHook for "elements" to filter or add form elements
8495 var elements
= jQuery
.prop( this, "elements" );
8496 return elements
? jQuery
.makeArray( elements
) : this;
8498 .filter(function() {
8499 var type
= this.type
;
8501 // Use .is( ":disabled" ) so that fieldset[disabled] works
8502 return this.name
&& !jQuery( this ).is( ":disabled" ) &&
8503 rsubmittable
.test( this.nodeName
) && !rsubmitterTypes
.test( type
) &&
8504 ( this.checked
|| !rcheckableType
.test( type
) );
8506 .map(function( i
, elem
) {
8507 var val
= jQuery( this ).val();
8509 return val
== null ?
8511 jQuery
.isArray( val
) ?
8512 jQuery
.map( val
, function( val
) {
8513 return { name: elem
.name
, value: val
.replace( rCRLF
, "\r\n" ) };
8515 { name: elem
.name
, value: val
.replace( rCRLF
, "\r\n" ) };
8521 jQuery
.ajaxSettings
.xhr = function() {
8523 return new XMLHttpRequest();
8529 xhrSuccessStatus
= {
8530 // file protocol always yields status code 0, assume 200
8533 // #1450: sometimes IE returns 1223 when it should be 204
8536 xhrSupported
= jQuery
.ajaxSettings
.xhr();
8539 // Open requests must be manually aborted on unload (#5280)
8540 if ( window
.ActiveXObject
) {
8541 jQuery( window
).on( "unload", function() {
8542 for ( var key
in xhrCallbacks
) {
8543 xhrCallbacks
[ key
]();
8548 support
.cors
= !!xhrSupported
&& ( "withCredentials" in xhrSupported
);
8549 support
.ajax
= xhrSupported
= !!xhrSupported
;
8551 jQuery
.ajaxTransport(function( options
) {
8554 // Cross domain only allowed if supported through XMLHttpRequest
8555 if ( support
.cors
|| xhrSupported
&& !options
.crossDomain
) {
8557 send: function( headers
, complete
) {
8559 xhr
= options
.xhr(),
8562 xhr
.open( options
.type
, options
.url
, options
.async
, options
.username
, options
.password
);
8564 // Apply custom fields if provided
8565 if ( options
.xhrFields
) {
8566 for ( i
in options
.xhrFields
) {
8567 xhr
[ i
] = options
.xhrFields
[ i
];
8571 // Override mime type if needed
8572 if ( options
.mimeType
&& xhr
.overrideMimeType
) {
8573 xhr
.overrideMimeType( options
.mimeType
);
8576 // X-Requested-With header
8577 // For cross-domain requests, seeing as conditions for a preflight are
8578 // akin to a jigsaw puzzle, we simply never set it to be sure.
8579 // (it can always be set on a per-request basis or even using ajaxSetup)
8580 // For same-domain requests, won't change header if already provided.
8581 if ( !options
.crossDomain
&& !headers
["X-Requested-With"] ) {
8582 headers
["X-Requested-With"] = "XMLHttpRequest";
8586 for ( i
in headers
) {
8587 xhr
.setRequestHeader( i
, headers
[ i
] );
8591 callback = function( type
) {
8594 delete xhrCallbacks
[ id
];
8595 callback
= xhr
.onload
= xhr
.onerror
= null;
8597 if ( type
=== "abort" ) {
8599 } else if ( type
=== "error" ) {
8601 // file: protocol always yields status 0; see #8605, #14207
8607 xhrSuccessStatus
[ xhr
.status
] || xhr
.status
,
8610 // Accessing binary-data responseText throws an exception
8612 typeof xhr
.responseText
=== "string" ? {
8613 text: xhr
.responseText
8615 xhr
.getAllResponseHeaders()
8623 xhr
.onload
= callback();
8624 xhr
.onerror
= callback("error");
8626 // Create the abort callback
8627 callback
= xhrCallbacks
[ id
] = callback("abort");
8630 // Do send the request (this may raise an exception)
8631 xhr
.send( options
.hasContent
&& options
.data
|| null );
8633 // #14683: Only rethrow if this hasn't been notified as an error yet
8652 // Install script dataType
8655 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
8658 script: /(?:java|ecma)script/
8661 "text script": function( text
) {
8662 jQuery
.globalEval( text
);
8668 // Handle cache's special case and crossDomain
8669 jQuery
.ajaxPrefilter( "script", function( s
) {
8670 if ( s
.cache
=== undefined ) {
8673 if ( s
.crossDomain
) {
8678 // Bind script tag hack transport
8679 jQuery
.ajaxTransport( "script", function( s
) {
8680 // This transport only deals with cross domain requests
8681 if ( s
.crossDomain
) {
8682 var script
, callback
;
8684 send: function( _
, complete
) {
8685 script
= jQuery("<script>").prop({
8687 charset: s
.scriptCharset
,
8691 callback = function( evt
) {
8695 complete( evt
.type
=== "error" ? 404 : 200, evt
.type
);
8699 document
.head
.appendChild( script
[ 0 ] );
8713 var oldCallbacks
= [],
8714 rjsonp
= /(=)\?(?=&|$)|\?\?/;
8716 // Default jsonp settings
8719 jsonpCallback: function() {
8720 var callback
= oldCallbacks
.pop() || ( jQuery
.expando
+ "_" + ( nonce
++ ) );
8721 this[ callback
] = true;
8726 // Detect, normalize options and install callbacks for jsonp requests
8727 jQuery
.ajaxPrefilter( "json jsonp", function( s
, originalSettings
, jqXHR
) {
8729 var callbackName
, overwritten
, responseContainer
,
8730 jsonProp
= s
.jsonp
!== false && ( rjsonp
.test( s
.url
) ?
8732 typeof s
.data
=== "string" && !( s
.contentType
|| "" ).indexOf("application/x-www-form-urlencoded") && rjsonp
.test( s
.data
) && "data"
8735 // Handle iff the expected data type is "jsonp" or we have a parameter to set
8736 if ( jsonProp
|| s
.dataTypes
[ 0 ] === "jsonp" ) {
8738 // Get callback name, remembering preexisting value associated with it
8739 callbackName
= s
.jsonpCallback
= jQuery
.isFunction( s
.jsonpCallback
) ?
8743 // Insert callback into url or form data
8745 s
[ jsonProp
] = s
[ jsonProp
].replace( rjsonp
, "$1" + callbackName
);
8746 } else if ( s
.jsonp
!== false ) {
8747 s
.url
+= ( rquery
.test( s
.url
) ? "&" : "?" ) + s
.jsonp
+ "=" + callbackName
;
8750 // Use data converter to retrieve json after script execution
8751 s
.converters
["script json"] = function() {
8752 if ( !responseContainer
) {
8753 jQuery
.error( callbackName
+ " was not called" );
8755 return responseContainer
[ 0 ];
8758 // force json dataType
8759 s
.dataTypes
[ 0 ] = "json";
8762 overwritten
= window
[ callbackName
];
8763 window
[ callbackName
] = function() {
8764 responseContainer
= arguments
;
8767 // Clean-up function (fires after converters)
8768 jqXHR
.always(function() {
8769 // Restore preexisting value
8770 window
[ callbackName
] = overwritten
;
8772 // Save back as free
8773 if ( s
[ callbackName
] ) {
8774 // make sure that re-using the options doesn't screw things around
8775 s
.jsonpCallback
= originalSettings
.jsonpCallback
;
8777 // save the callback name for future use
8778 oldCallbacks
.push( callbackName
);
8781 // Call if it was a function and we have a response
8782 if ( responseContainer
&& jQuery
.isFunction( overwritten
) ) {
8783 overwritten( responseContainer
[ 0 ] );
8786 responseContainer
= overwritten
= undefined;
8789 // Delegate to script
8797 // data: string of html
8798 // context (optional): If specified, the fragment will be created in this context, defaults to document
8799 // keepScripts (optional): If true, will include scripts passed in the html string
8800 jQuery
.parseHTML = function( data
, context
, keepScripts
) {
8801 if ( !data
|| typeof data
!== "string" ) {
8804 if ( typeof context
=== "boolean" ) {
8805 keepScripts
= context
;
8808 context
= context
|| document
;
8810 var parsed
= rsingleTag
.exec( data
),
8811 scripts
= !keepScripts
&& [];
8815 return [ context
.createElement( parsed
[1] ) ];
8818 parsed
= jQuery
.buildFragment( [ data
], context
, scripts
);
8820 if ( scripts
&& scripts
.length
) {
8821 jQuery( scripts
).remove();
8824 return jQuery
.merge( [], parsed
.childNodes
);
8828 // Keep a copy of the old load method
8829 var _load
= jQuery
.fn
.load
;
8832 * Load a url into a page
8834 jQuery
.fn
.load = function( url
, params
, callback
) {
8835 if ( typeof url
!== "string" && _load
) {
8836 return _load
.apply( this, arguments
);
8839 var selector
, type
, response
,
8841 off
= url
.indexOf(" ");
8844 selector
= jQuery
.trim( url
.slice( off
) );
8845 url
= url
.slice( 0, off
);
8848 // If it's a function
8849 if ( jQuery
.isFunction( params
) ) {
8851 // We assume that it's the callback
8855 // Otherwise, build a param string
8856 } else if ( params
&& typeof params
=== "object" ) {
8860 // If we have elements to modify, make the request
8861 if ( self
.length
> 0 ) {
8865 // if "type" variable is undefined, then "GET" method will be used
8869 }).done(function( responseText
) {
8871 // Save response for use in complete callback
8872 response
= arguments
;
8874 self
.html( selector
?
8876 // If a selector was specified, locate the right elements in a dummy div
8877 // Exclude scripts to avoid IE 'Permission Denied' errors
8878 jQuery("<div>").append( jQuery
.parseHTML( responseText
) ).find( selector
) :
8880 // Otherwise use the full result
8883 }).complete( callback
&& function( jqXHR
, status
) {
8884 self
.each( callback
, response
|| [ jqXHR
.responseText
, status
, jqXHR
] );
8894 jQuery
.expr
.filters
.animated = function( elem
) {
8895 return jQuery
.grep(jQuery
.timers
, function( fn
) {
8896 return elem
=== fn
.elem
;
8903 var docElem
= window
.document
.documentElement
;
8906 * Gets a window from an element
8908 function getWindow( elem
) {
8909 return jQuery
.isWindow( elem
) ? elem : elem
.nodeType
=== 9 && elem
.defaultView
;
8913 setOffset: function( elem
, options
, i
) {
8914 var curPosition
, curLeft
, curCSSTop
, curTop
, curOffset
, curCSSLeft
, calculatePosition
,
8915 position
= jQuery
.css( elem
, "position" ),
8916 curElem
= jQuery( elem
),
8919 // Set position first, in-case top/left are set even on static elem
8920 if ( position
=== "static" ) {
8921 elem
.style
.position
= "relative";
8924 curOffset
= curElem
.offset();
8925 curCSSTop
= jQuery
.css( elem
, "top" );
8926 curCSSLeft
= jQuery
.css( elem
, "left" );
8927 calculatePosition
= ( position
=== "absolute" || position
=== "fixed" ) &&
8928 ( curCSSTop
+ curCSSLeft
).indexOf("auto") > -1;
8930 // Need to be able to calculate position if either top or left is auto and position is either absolute or fixed
8931 if ( calculatePosition
) {
8932 curPosition
= curElem
.position();
8933 curTop
= curPosition
.top
;
8934 curLeft
= curPosition
.left
;
8937 curTop
= parseFloat( curCSSTop
) || 0;
8938 curLeft
= parseFloat( curCSSLeft
) || 0;
8941 if ( jQuery
.isFunction( options
) ) {
8942 options
= options
.call( elem
, i
, curOffset
);
8945 if ( options
.top
!= null ) {
8946 props
.top
= ( options
.top
- curOffset
.top
) + curTop
;
8948 if ( options
.left
!= null ) {
8949 props
.left
= ( options
.left
- curOffset
.left
) + curLeft
;
8952 if ( "using" in options
) {
8953 options
.using
.call( elem
, props
);
8956 curElem
.css( props
);
8962 offset: function( options
) {
8963 if ( arguments
.length
) {
8964 return options
=== undefined ?
8966 this.each(function( i
) {
8967 jQuery
.offset
.setOffset( this, options
, i
);
8973 box
= { top: 0, left: 0 },
8974 doc
= elem
&& elem
.ownerDocument
;
8980 docElem
= doc
.documentElement
;
8982 // Make sure it's not a disconnected DOM node
8983 if ( !jQuery
.contains( docElem
, elem
) ) {
8987 // If we don't have gBCR, just use 0,0 rather than error
8988 // BlackBerry 5, iOS 3 (original iPhone)
8989 if ( typeof elem
.getBoundingClientRect
!== strundefined
) {
8990 box
= elem
.getBoundingClientRect();
8992 win
= getWindow( doc
);
8994 top: box
.top
+ win
.pageYOffset
- docElem
.clientTop
,
8995 left: box
.left
+ win
.pageXOffset
- docElem
.clientLeft
8999 position: function() {
9004 var offsetParent
, offset
,
9006 parentOffset
= { top: 0, left: 0 };
9008 // Fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent
9009 if ( jQuery
.css( elem
, "position" ) === "fixed" ) {
9010 // We assume that getBoundingClientRect is available when computed position is fixed
9011 offset
= elem
.getBoundingClientRect();
9014 // Get *real* offsetParent
9015 offsetParent
= this.offsetParent();
9017 // Get correct offsets
9018 offset
= this.offset();
9019 if ( !jQuery
.nodeName( offsetParent
[ 0 ], "html" ) ) {
9020 parentOffset
= offsetParent
.offset();
9023 // Add offsetParent borders
9024 parentOffset
.top
+= jQuery
.css( offsetParent
[ 0 ], "borderTopWidth", true );
9025 parentOffset
.left
+= jQuery
.css( offsetParent
[ 0 ], "borderLeftWidth", true );
9028 // Subtract parent offsets and element margins
9030 top: offset
.top
- parentOffset
.top
- jQuery
.css( elem
, "marginTop", true ),
9031 left: offset
.left
- parentOffset
.left
- jQuery
.css( elem
, "marginLeft", true )
9035 offsetParent: function() {
9036 return this.map(function() {
9037 var offsetParent
= this.offsetParent
|| docElem
;
9039 while ( offsetParent
&& ( !jQuery
.nodeName( offsetParent
, "html" ) && jQuery
.css( offsetParent
, "position" ) === "static" ) ) {
9040 offsetParent
= offsetParent
.offsetParent
;
9043 return offsetParent
|| docElem
;
9048 // Create scrollLeft and scrollTop methods
9049 jQuery
.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method
, prop
) {
9050 var top
= "pageYOffset" === prop
;
9052 jQuery
.fn
[ method
] = function( val
) {
9053 return access( this, function( elem
, method
, val
) {
9054 var win
= getWindow( elem
);
9056 if ( val
=== undefined ) {
9057 return win
? win
[ prop
] : elem
[ method
];
9062 !top
? val : window
.pageXOffset
,
9063 top
? val : window
.pageYOffset
9067 elem
[ method
] = val
;
9069 }, method
, val
, arguments
.length
, null );
9073 // Add the top/left cssHooks using jQuery.fn.position
9074 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
9075 // getComputedStyle returns percent when specified for top/left/bottom/right
9076 // rather than make the css module depend on the offset module, we just check for it here
9077 jQuery
.each( [ "top", "left" ], function( i
, prop
) {
9078 jQuery
.cssHooks
[ prop
] = addGetHookIf( support
.pixelPosition
,
9079 function( elem
, computed
) {
9081 computed
= curCSS( elem
, prop
);
9082 // if curCSS returns percentage, fallback to offset
9083 return rnumnonpx
.test( computed
) ?
9084 jQuery( elem
).position()[ prop
] + "px" :
9092 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
9093 jQuery
.each( { Height: "height", Width: "width" }, function( name
, type
) {
9094 jQuery
.each( { padding: "inner" + name
, content: type
, "": "outer" + name
}, function( defaultExtra
, funcName
) {
9095 // margin is only for outerHeight, outerWidth
9096 jQuery
.fn
[ funcName
] = function( margin
, value
) {
9097 var chainable
= arguments
.length
&& ( defaultExtra
|| typeof margin
!== "boolean" ),
9098 extra
= defaultExtra
|| ( margin
=== true || value
=== true ? "margin" : "border" );
9100 return access( this, function( elem
, type
, value
) {
9103 if ( jQuery
.isWindow( elem
) ) {
9104 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
9105 // isn't a whole lot we can do. See pull request at this URL for discussion:
9106 // https://github.com/jquery/jquery/pull/764
9107 return elem
.document
.documentElement
[ "client" + name
];
9110 // Get document width or height
9111 if ( elem
.nodeType
=== 9 ) {
9112 doc
= elem
.documentElement
;
9114 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
9115 // whichever is greatest
9117 elem
.body
[ "scroll" + name
], doc
[ "scroll" + name
],
9118 elem
.body
[ "offset" + name
], doc
[ "offset" + name
],
9119 doc
[ "client" + name
]
9123 return value
=== undefined ?
9124 // Get width or height on the element, requesting but not forcing parseFloat
9125 jQuery
.css( elem
, type
, extra
) :
9127 // Set width or height on the element
9128 jQuery
.style( elem
, type
, value
, extra
);
9129 }, type
, chainable
? margin : undefined, chainable
, null );
9135 // The number of elements contained in the matched element set
9136 jQuery
.fn
.size = function() {
9140 jQuery
.fn
.andSelf
= jQuery
.fn
.addBack
;
9145 // Register as a named AMD module, since jQuery can be concatenated with other
9146 // files that may use define, but not via a proper concatenation script that
9147 // understands anonymous AMD modules. A named AMD is safest and most robust
9148 // way to register. Lowercase jquery is used because AMD module names are
9149 // derived from file names, and jQuery is normally delivered in a lowercase
9150 // file name. Do this after creating the global so that if an AMD module wants
9151 // to call noConflict to hide this version of jQuery, it will work.
9153 // Note that for maximum portability, libraries that are not jQuery should
9154 // declare themselves as anonymous modules, and avoid setting a global if an
9155 // AMD loader is present. jQuery is a special case. For more information, see
9156 // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
9158 if ( typeof define
=== "function" && define
.amd
) {
9159 define( "jquery", [], function() {
9168 // Map over jQuery in case of overwrite
9169 _jQuery
= window
.jQuery
,
9171 // Map over the $ in case of overwrite
9174 jQuery
.noConflict = function( deep
) {
9175 if ( window
.$ === jQuery
) {
9179 if ( deep
&& window
.jQuery
=== jQuery
) {
9180 window
.jQuery
= _jQuery
;
9186 // Expose jQuery and $ identifiers, even in
9187 // AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
9188 // and CommonJS for browser emulators (#13566)
9189 if ( typeof noGlobal
=== strundefined
) {
9190 window
.jQuery
= window
.$ = jQuery
;
9200 // HashiCorp Mega Nav
9201 // --------------------------------------------------
9203 var HashiMegaNav = function() {
9204 var productClass
= 'mega-nav-grid-item',
9205 productActiveClass
= 'is-active',
9206 url
= window
.location
.hostname
,
9216 for (var i
= 0; i
< products
.length
; i
++) {
9217 if (url
.indexOf(products
[i
]) !== -1) {
9218 $('.' + productClass
+ '-' + products
[i
]).addClass(productActiveClass
);
9222 var $body
= $('#mega-nav-body-ct');
9223 var $arrow
= $('#mega-nav-ctrl');
9224 var $nav
= $arrow
.parent();
9225 var $close
= $('#mega-nav-close');
9227 function matchesBreakpoint() {
9228 return window
.matchMedia("(min-width: 980px)").matches
;
9231 function openNav() {
9232 if(matchesBreakpoint()) {
9233 $body
.slideDown('fast');
9234 $nav
.addClass('open');
9236 $body
.fadeIn('fast');
9240 function closeNav() {
9241 if(matchesBreakpoint()) {
9242 $body
.slideUp('fast');
9243 $nav
.removeClass('open');
9245 $body
.fadeOut('fast');
9249 function isNavOpen() {
9250 return $nav
.hasClass('open');
9253 $arrow
.unbind().on('click', function(e
) {
9254 e
.preventDefault(); // Don't jump page to "#"
9263 $close
.unbind().on('click', function() {
9268 // Handle document ready function and the turbolinks load.
9269 $(document
).on("ready turbolinks:load", HashiMegaNav
);
9270 // HashiSidebar is the sidebar implementation for mobile websites. It
9271 // appears at a configurable breakpoint in the CSS.
9272 var HashiSidebar = function() {
9273 var $sidebar
= $('.sidebar');
9274 var $toggle
= $('.navbar-toggle');
9275 var $overlay
= $('.sidebar-overlay');
9277 function sidebarActive() {
9278 return $sidebar
.hasClass('open');
9281 function hideSidebar() {
9282 if(sidebarActive()) {
9283 $sidebar
.removeClass('open');
9284 $overlay
.removeClass('active');
9288 // Hide the sidebar when the user clicks on the overlay. The overlay is
9289 // only "clickable" when it's active.
9290 $overlay
.unbind().on('click', function(e
){
9294 // Show the sidebar when the user clicks the hamburger menu.
9295 $toggle
.unbind().on('click', function(e
) {
9296 e
.preventDefault(); // Don't jump page to "#"
9298 // Only activate the sidebar if it's not already active. Since these
9299 // are class selectors, it's possible that we are watching multiple
9301 if(!sidebarActive()) {
9302 $overlay
.addClass('active');
9303 $sidebar
.toggleClass('open');
9308 // Handle document ready function and the turbolinks load.
9309 $(document
).on("ready turbolinks:load", HashiSidebar
);
9313 * Wrapper for segment's track function that will track multiple elements,
9314 * normalize parameters, and easily switch between tracking links or events.
9315 * @param {String} selector - query selector, multi element compatible
9316 * @param {Function} cb - optional function that should return params, and will receive the element as a parameter
9317 * @param {Boolean} [link] - if true, tracks a link click
9319 function track(selector
, cb
, link
) {
9320 each(document
.querySelectorAll(selector
), function(el
) {
9322 if (typeof cb
=== 'function') {
9325 var event
= params
.event
9328 analytics
.trackLink(el
, event
, params
)
9330 el
.addEventListener('click', function() {
9331 analytics
.track(event
, params
)
9338 * Iterates through a NodeList, not built-in for all browsers.
9339 * (https://developer.mozilla.org/en-US/docs/Web/API/NodeList)
9340 * @param {NodeList} list a NodeList instance
9341 * @param {Function} cb a function to execute for each node
9343 function each(list
, cb
) {
9344 for (var i
= 0; i
< list
.length
; i
++) {
9349 // Expose as commonjs for module bundlers if needed
9350 if (typeof module
!== 'undefined' && module
.exports
) {
9351 module
.exports
= { track: track
}
9354 document
.addEventListener('turbolinks:load', function() {
9357 track('.downloads .download .details li a', function(el
) {
9358 var m
= el
.href
.match(/terraform_(.*?)_(.*?)_(.*?)\.zip/)
9362 label: 'Terraform | v' + m
[1] + ' | ' + m
[2] + ' | ' + m
[3],
9366 product: 'terraform'
9370 track('a.notification', function(el
) {
9372 name: 'Alert Banner',
9373 variant: el
.innerText
.replace(/\s+/g, ' ').trim()
9375 // Create a stringified `label` prop of the event for GA tracking purposes
9376 params
.label
= JSON
.stringify(params
)
9377 params
.event
= 'CTA Clicked'
9391 // Set up terraform.io UI helpers
9392 document
.addEventListener("turbolinks:load", function() {
9396 // - "subNavs" are <li> elements with a nested <ul> as a direct child.
9397 // - The <a> child is the "header" of the subnav, and the <ul> is its "content."
9398 // - Subnavs are collapsed (<ul> hidden) or expanded (<ul> visible).
9399 // - Collapse/expand is managed by the "active" class on the <li>.
9401 // Collapse most subnavs, but reveal any that contain the
9402 // current page. The a.current-page class is added during build by
9403 // layouts/inner.erb.
9404 var docsSidebar
= $("#docs-sidebar ul.nav.docs-sidenav");
9405 var subNavs
= docsSidebar
.find("ul").addClass("nav-hidden").parent("li");
9406 // we leave the nav-hidden class alone after this.
9407 function resetActiveSubnavs() {
9408 subNavs
.removeClass("active");
9409 // Activate current page, locked-open navs, and all their ancestors:
9410 docsSidebar
.find("li").has(".current-page, .nav-visible").addClass("active");
9411 // Activate auto-expand navs, but leave their ancestors alone:
9412 docsSidebar
.find(".nav-auto-expand").parent("li").addClass("active");
9413 // Colored links for current page and its ancestors
9414 docsSidebar
.find("li").has(".current-page").addClass("current");
9416 resetActiveSubnavs();
9418 // CSS class that adds toggle controls:
9419 subNavs
.addClass("has-subnav");
9420 // Toggle subnav expansion when clicking an area that isn't claimed by the
9421 // header or content (usually the :before pseudo-element)
9422 subNavs
.on("click", function(e
) {
9423 if (e
.target
== this) {
9424 $(this).toggleClass("active");
9426 e
.stopPropagation();
9428 // If the subnav header doesn't link to a different page, use it as a toggle.
9429 docsSidebar
.find("a[href^='#']").on("click", function(e
) {
9431 $(this).parent("li").trigger("click");
9434 // If this is a Very Large Sidebar, add extra controls to expand/collapse
9436 var sidebarLinks
= docsSidebar
.find("a");
9437 if (sidebarLinks
.length
> 30) {
9438 if ($("#sidebar-controls").length
=== 0) { // then add it!
9439 var sidebarControlsHTML
=
9440 '<div id="sidebar-controls">' +
9441 '<div id="sidebar-filter">' +
9442 '<span class="glyphicon glyphicon-search"></span>' +
9443 '<label for="sidebar-filter-field" class="sr-only sr-only-focusable">Filter page titles in sidebar navigation</label>' +
9444 '<input type="search" id="sidebar-filter-field" class="form-control" name="sidebar-filter-field" role="search" placeholder="Filter page titles" />' +
9445 '<button id="filter-close" class="glyphicon glyphicon-remove-circle" title="Reset filter"><span class="sr-only sr-only-focusable">Reset sidebar filter</span></button>' +
9447 '<div id="sidebar-buttons">' +
9448 '<button id="toggle-button">Expand all</button>' +
9450 '<button id="filter-button" title="Shortcut: type the / key">Filter</button>' +
9453 var sidebarHeader
= $("#docs-sidebar").children("h1,h2,h3,h4,h5,h6").not("#otherdocs").first();
9454 if (sidebarHeader
.length
=== 1) { // under first header
9455 sidebarHeader
.after(sidebarControlsHTML
);
9456 } else { // under skip link
9457 $("#docs-sidebar #controls-placeholder").replaceWith(sidebarControlsHTML
);
9461 var filterDiv
= $("div#sidebar-filter");
9462 var buttonsDiv
= $("div#sidebar-buttons");
9463 var subnavToggle
= $("#sidebar-controls #toggle-button");
9464 var filterField
= $("#sidebar-controls input#sidebar-filter-field");
9465 var filterButton
= $("#filter-button");
9469 filterButton
.on("click", function(e
) {
9472 filterField
.focus();
9475 // Filter field's close button: defer to reset button.
9476 $("#filter-close").on("click", function(e
) {
9477 subnavToggle
.trigger("reset");
9480 // Expand/reset button behavior:
9482 "taint": function(e
) {
9483 $(this).html("Reset");
9485 "reset": function(e
) {
9486 filterField
.val("");
9487 filterField
.trigger("blur");
9488 sidebarLinks
.parent("li").show();
9489 resetActiveSubnavs();
9490 $(this).html("Expand all");
9494 "click": function(e
) {
9496 if ($(this).text() === "Expand all") {
9497 subNavs
.addClass("active");
9498 $(this).trigger("taint");
9500 $(this).trigger("reset");
9505 // Filter as you type. This alters three things:
9506 // - "active" class on subnavs
9507 // - direct show/hide of <li>s
9508 // - state of subnavToggle button
9509 // We rely on subnavToggle's "reset" event to clean up when done.
9510 filterField
.on('keyup', function(e
) {
9511 if (e
.keyCode
=== 27) { // escape key
9512 subnavToggle
.trigger("reset");
9514 subnavToggle
.trigger("taint");
9515 var filterRegexp
= new RegExp(filterField
.val(), 'i');
9516 var matchingLinks
= sidebarLinks
.filter(function(index
) {
9517 return $(this).text().match(filterRegexp
);
9519 sidebarLinks
.parent('li').hide();
9520 subNavs
.removeClass('active'); // cleans up partial as-you-type searches
9521 // make matches and their parents visible and expanded:
9522 matchingLinks
.parents('li').show().filter(subNavs
).addClass('active');
9523 // make direct children visible (if your search caught a subnav directly):
9524 matchingLinks
.parent('li').find('li').show();
9527 // Type slash to focus sidebar filter:
9528 $("body").keydown(function(e
) {
9529 // 191 = / (forward slash) key
9530 if (e
.keyCode
!== 191) {
9533 var focusedElementType
= $(document
.activeElement
).get(0).tagName
.toLowerCase();
9534 if (focusedElementType
!== "textarea" && focusedElementType
!== "input") {
9536 filterButton
.trigger("click");
9542 // On docs/content pages, add a hierarchical quick nav menu if there are
9543 // more than two H2/H3/H4 headers.
9544 var headers
= $('#inner').find('h2, h3, h4');
9545 if (headers
.length
> 2 && $("div#inner-quicknav").length
=== 0) {
9546 // Build the quick-nav HTML:
9547 $("#inner h1").first().after(
9548 '<div id="inner-quicknav">' +
9549 '<span id="inner-quicknav-trigger">' +
9551 '<svg width="9" height="5" xmlns="http://www.w3.org/2000/svg"><path d="M8.811 1.067a.612.612 0 0 0 0-.884.655.655 0 0 0-.908 0L4.5 3.491 1.097.183a.655.655 0 0 0-.909 0 .615.615 0 0 0 0 .884l3.857 3.75a.655.655 0 0 0 .91 0l3.856-3.75z" fill-rule="evenodd"/></svg>' +
9553 '<ul class="dropdown"></ul>' +
9556 var quickNav
= $('#inner-quicknav > ul.dropdown');
9557 headers
.each(function(index
, element
) {
9558 var level
= element
.nodeName
.toLowerCase();
9559 var header_text
= $(element
).text();
9560 var header_id
= $(element
).attr('id');
9561 quickNav
.append('<li class="level-' + level
+ '"><a href="#' + header_id
+ '">' + header_text
+ '</a></li>');
9563 // Attach event listeners:
9564 // Trigger opens and closes.
9565 $('#inner-quicknav #inner-quicknav-trigger').on('click', function(e
) {
9566 $(this).siblings('ul').toggleClass('active');
9567 e
.stopPropagation();
9569 // Clicking inside the quick-nav doesn't close it.
9570 quickNav
.on('click', function(e
) {
9571 e
.stopPropagation();
9573 // Jumping to a section means you're done with the quick-nav.
9574 quickNav
.find('li a').on('click', function() {
9575 quickNav
.removeClass('active');
9577 // Clicking outside the quick-nav closes it.
9578 $('body').on('click', function() {
9579 quickNav
.removeClass('active');