aboutsummaryrefslogtreecommitdiffhomepage
path: root/assets/javascripts/application.js
diff options
context:
space:
mode:
Diffstat (limited to 'assets/javascripts/application.js')
-rw-r--r--assets/javascripts/application.js9567
1 files changed, 9567 insertions, 0 deletions
diff --git a/assets/javascripts/application.js b/assets/javascripts/application.js
new file mode 100644
index 0000000..53004d2
--- /dev/null
+++ b/assets/javascripts/application.js
@@ -0,0 +1,9567 @@
1/*
2Turbolinks 5.2.0
3Copyright © 2018 Basecamp, LLC
4 */
5
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);
8/*!
9 * jQuery JavaScript Library v2.1.1
10 * http://jquery.com/
11 *
12 * Includes Sizzle.js
13 * http://sizzlejs.com/
14 *
15 * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
16 * Released under the MIT license
17 * http://jquery.org/license
18 *
19 * Date: 2014-05-01T17:11Z
20 */
21
22
23(function( global, factory ) {
24
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 ) :
35 function( w ) {
36 if ( !w.document ) {
37 throw new Error( "jQuery requires a window with a document" );
38 }
39 return factory( w );
40 };
41 } else {
42 factory( global );
43 }
44
45// Pass this if window is not defined yet
46}(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
47
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+
52//
53
54var arr = [];
55
56var slice = arr.slice;
57
58var concat = arr.concat;
59
60var push = arr.push;
61
62var indexOf = arr.indexOf;
63
64var class2type = {};
65
66var toString = class2type.toString;
67
68var hasOwn = class2type.hasOwnProperty;
69
70var support = {};
71
72
73
74var
75 // Use the correct document accordingly with window argument (sandbox)
76 document = window.document,
77
78 version = "2.1.1",
79
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 );
85 },
86
87 // Support: Android<4.1
88 // Make sure we trim BOM and NBSP
89 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
90
91 // Matches dashed string for camelizing
92 rmsPrefix = /^-ms-/,
93 rdashAlpha = /-([\da-z])/gi,
94
95 // Used by jQuery.camelCase as callback to replace()
96 fcamelCase = function( all, letter ) {
97 return letter.toUpperCase();
98 };
99
100jQuery.fn = jQuery.prototype = {
101 // The current version of jQuery being used
102 jquery: version,
103
104 constructor: jQuery,
105
106 // Start with an empty selector
107 selector: "",
108
109 // The default length of a jQuery object is 0
110 length: 0,
111
112 toArray: function() {
113 return slice.call( this );
114 },
115
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 ) {
119 return num != null ?
120
121 // Return just the one element from the set
122 ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
123
124 // Return all the elements in a clean array
125 slice.call( this );
126 },
127
128 // Take an array of elements and push it onto the stack
129 // (returning the new matched element set)
130 pushStack: function( elems ) {
131
132 // Build a new jQuery matched element set
133 var ret = jQuery.merge( this.constructor(), elems );
134
135 // Add the old object onto the stack (as a reference)
136 ret.prevObject = this;
137 ret.context = this.context;
138
139 // Return the newly-formed element set
140 return ret;
141 },
142
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 );
148 },
149
150 map: function( callback ) {
151 return this.pushStack( jQuery.map(this, function( elem, i ) {
152 return callback.call( elem, i, elem );
153 }));
154 },
155
156 slice: function() {
157 return this.pushStack( slice.apply( this, arguments ) );
158 },
159
160 first: function() {
161 return this.eq( 0 );
162 },
163
164 last: function() {
165 return this.eq( -1 );
166 },
167
168 eq: function( i ) {
169 var len = this.length,
170 j = +i + ( i < 0 ? len : 0 );
171 return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
172 },
173
174 end: function() {
175 return this.prevObject || this.constructor(null);
176 },
177
178 // For internal use only.
179 // Behaves like an Array's method, not like a jQuery method.
180 push: push,
181 sort: arr.sort,
182 splice: arr.splice
183};
184
185jQuery.extend = jQuery.fn.extend = function() {
186 var options, name, src, copy, copyIsArray, clone,
187 target = arguments[0] || {},
188 i = 1,
189 length = arguments.length,
190 deep = false;
191
192 // Handle a deep copy situation
193 if ( typeof target === "boolean" ) {
194 deep = target;
195
196 // skip the boolean and the target
197 target = arguments[ i ] || {};
198 i++;
199 }
200
201 // Handle case when target is a string or something (possible in deep copy)
202 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
203 target = {};
204 }
205
206 // extend jQuery itself if only one argument is passed
207 if ( i === length ) {
208 target = this;
209 i--;
210 }
211
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 ];
219
220 // Prevent never-ending loop
221 if ( target === copy ) {
222 continue;
223 }
224
225 // Recurse if we're merging plain objects or arrays
226 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
227 if ( copyIsArray ) {
228 copyIsArray = false;
229 clone = src && jQuery.isArray(src) ? src : [];
230
231 } else {
232 clone = src && jQuery.isPlainObject(src) ? src : {};
233 }
234
235 // Never move original objects, clone them
236 target[ name ] = jQuery.extend( deep, clone, copy );
237
238 // Don't bring in undefined values
239 } else if ( copy !== undefined ) {
240 target[ name ] = copy;
241 }
242 }
243 }
244 }
245
246 // Return the modified object
247 return target;
248};
249
250jQuery.extend({
251 // Unique for each copy of jQuery on the page
252 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
253
254 // Assume jQuery is ready without the ready module
255 isReady: true,
256
257 error: function( msg ) {
258 throw new Error( msg );
259 },
260
261 noop: function() {},
262
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";
268 },
269
270 isArray: Array.isArray,
271
272 isWindow: function( obj ) {
273 return obj != null && obj === obj.window;
274 },
275
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;
281 },
282
283 isPlainObject: function( obj ) {
284 // Not plain objects:
285 // - Any object or value whose internal [[Class]] property is not "[object Object]"
286 // - DOM nodes
287 // - window
288 if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
289 return false;
290 }
291
292 if ( obj.constructor &&
293 !hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
294 return false;
295 }
296
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
299 return true;
300 },
301
302 isEmptyObject: function( obj ) {
303 var name;
304 for ( name in obj ) {
305 return false;
306 }
307 return true;
308 },
309
310 type: function( obj ) {
311 if ( obj == null ) {
312 return obj + "";
313 }
314 // Support: Android < 4.0, iOS < 6 (functionish RegExp)
315 return typeof obj === "object" || typeof obj === "function" ?
316 class2type[ toString.call(obj) ] || "object" :
317 typeof obj;
318 },
319
320 // Evaluates a script in a global context
321 globalEval: function( code ) {
322 var script,
323 indirect = eval;
324
325 code = jQuery.trim( code );
326
327 if ( 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");
333 script.text = code;
334 document.head.appendChild( script ).parentNode.removeChild( script );
335 } else {
336 // Otherwise, avoid the DOM node creation, insertion
337 // and removal by using an indirect global eval
338 indirect( code );
339 }
340 }
341 },
342
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 );
347 },
348
349 nodeName: function( elem, name ) {
350 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
351 },
352
353 // args is for internal usage only
354 each: function( obj, callback, args ) {
355 var value,
356 i = 0,
357 length = obj.length,
358 isArray = isArraylike( obj );
359
360 if ( args ) {
361 if ( isArray ) {
362 for ( ; i < length; i++ ) {
363 value = callback.apply( obj[ i ], args );
364
365 if ( value === false ) {
366 break;
367 }
368 }
369 } else {
370 for ( i in obj ) {
371 value = callback.apply( obj[ i ], args );
372
373 if ( value === false ) {
374 break;
375 }
376 }
377 }
378
379 // A special, fast, case for the most common use of each
380 } else {
381 if ( isArray ) {
382 for ( ; i < length; i++ ) {
383 value = callback.call( obj[ i ], i, obj[ i ] );
384
385 if ( value === false ) {
386 break;
387 }
388 }
389 } else {
390 for ( i in obj ) {
391 value = callback.call( obj[ i ], i, obj[ i ] );
392
393 if ( value === false ) {
394 break;
395 }
396 }
397 }
398 }
399
400 return obj;
401 },
402
403 // Support: Android<4.1
404 trim: function( text ) {
405 return text == null ?
406 "" :
407 ( text + "" ).replace( rtrim, "" );
408 },
409
410 // results is for internal usage only
411 makeArray: function( arr, results ) {
412 var ret = results || [];
413
414 if ( arr != null ) {
415 if ( isArraylike( Object(arr) ) ) {
416 jQuery.merge( ret,
417 typeof arr === "string" ?
418 [ arr ] : arr
419 );
420 } else {
421 push.call( ret, arr );
422 }
423 }
424
425 return ret;
426 },
427
428 inArray: function( elem, arr, i ) {
429 return arr == null ? -1 : indexOf.call( arr, elem, i );
430 },
431
432 merge: function( first, second ) {
433 var len = +second.length,
434 j = 0,
435 i = first.length;
436
437 for ( ; j < len; j++ ) {
438 first[ i++ ] = second[ j ];
439 }
440
441 first.length = i;
442
443 return first;
444 },
445
446 grep: function( elems, callback, invert ) {
447 var callbackInverse,
448 matches = [],
449 i = 0,
450 length = elems.length,
451 callbackExpect = !invert;
452
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 ] );
459 }
460 }
461
462 return matches;
463 },
464
465 // arg is for internal usage only
466 map: function( elems, callback, arg ) {
467 var value,
468 i = 0,
469 length = elems.length,
470 isArray = isArraylike( elems ),
471 ret = [];
472
473 // Go through the array, translating each of the items to their new values
474 if ( isArray ) {
475 for ( ; i < length; i++ ) {
476 value = callback( elems[ i ], i, arg );
477
478 if ( value != null ) {
479 ret.push( value );
480 }
481 }
482
483 // Go through every key on the object,
484 } else {
485 for ( i in elems ) {
486 value = callback( elems[ i ], i, arg );
487
488 if ( value != null ) {
489 ret.push( value );
490 }
491 }
492 }
493
494 // Flatten any nested arrays
495 return concat.apply( [], ret );
496 },
497
498 // A global GUID counter for objects
499 guid: 1,
500
501 // Bind a function to a context, optionally partially applying any
502 // arguments.
503 proxy: function( fn, context ) {
504 var tmp, args, proxy;
505
506 if ( typeof context === "string" ) {
507 tmp = fn[ context ];
508 context = fn;
509 fn = tmp;
510 }
511
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 ) ) {
515 return undefined;
516 }
517
518 // Simulated bind
519 args = slice.call( arguments, 2 );
520 proxy = function() {
521 return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
522 };
523
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++;
526
527 return proxy;
528 },
529
530 now: Date.now,
531
532 // jQuery.support is not used in Core but other projects attach their
533 // properties to it so it needs to exist.
534 support: support
535});
536
537// Populate the class2type map
538jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
539 class2type[ "[object " + name + "]" ] = name.toLowerCase();
540});
541
542function isArraylike( obj ) {
543 var length = obj.length,
544 type = jQuery.type( obj );
545
546 if ( type === "function" || jQuery.isWindow( obj ) ) {
547 return false;
548 }
549
550 if ( obj.nodeType === 1 && length ) {
551 return true;
552 }
553
554 return type === "array" || length === 0 ||
555 typeof length === "number" && length > 0 && ( length - 1 ) in obj;
556}
557var Sizzle =
558/*!
559 * Sizzle CSS Selector Engine v1.10.19
560 * http://sizzlejs.com/
561 *
562 * Copyright 2013 jQuery Foundation, Inc. and other contributors
563 * Released under the MIT license
564 * http://jquery.org/license
565 *
566 * Date: 2014-04-18
567 */
568(function( window ) {
569
570var i,
571 support,
572 Expr,
573 getText,
574 isXML,
575 tokenize,
576 compile,
577 select,
578 outermostContext,
579 sortInput,
580 hasDuplicate,
581
582 // Local document vars
583 setDocument,
584 document,
585 docElem,
586 documentIsHTML,
587 rbuggyQSA,
588 rbuggyMatches,
589 matches,
590 contains,
591
592 // Instance-specific data
593 expando = "sizzle" + -(new Date()),
594 preferredDoc = window.document,
595 dirruns = 0,
596 done = 0,
597 classCache = createCache(),
598 tokenCache = createCache(),
599 compilerCache = createCache(),
600 sortOrder = function( a, b ) {
601 if ( a === b ) {
602 hasDuplicate = true;
603 }
604 return 0;
605 },
606
607 // General-purpose constants
608 strundefined = typeof undefined,
609 MAX_NEGATIVE = 1 << 31,
610
611 // Instance methods
612 hasOwn = ({}).hasOwnProperty,
613 arr = [],
614 pop = arr.pop,
615 push_native = arr.push,
616 push = arr.push,
617 slice = arr.slice,
618 // Use a stripped-down indexOf if we can't use a native one
619 indexOf = arr.indexOf || function( elem ) {
620 var i = 0,
621 len = this.length;
622 for ( ; i < len; i++ ) {
623 if ( this[i] === elem ) {
624 return i;
625 }
626 }
627 return -1;
628 },
629
630 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
631
632 // Regular expressions
633
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])+",
638
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#" ),
643
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 +
650 "*\\]",
651
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)
659 ".*" +
660 ")\\)|)",
661
662 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
663 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
664
665 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
666 rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
667
668 rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
669
670 rpseudo = new RegExp( pseudos ),
671 ridentifier = new RegExp( "^" + identifier + "$" ),
672
673 matchExpr = {
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" )
687 },
688
689 rinputs = /^(?:input|select|textarea|button)$/i,
690 rheader = /^h\d$/i,
691
692 rnative = /^[^{]+\{\s*\[native \w/,
693
694 // Easily-parseable/retrievable ID or TAG or CLASS selectors
695 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
696
697 rsibling = /[+~]/,
698 rescape = /'|\\/g,
699
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 ?
708 escaped :
709 high < 0 ?
710 // BMP codepoint
711 String.fromCharCode( high + 0x10000 ) :
712 // Supplemental Plane codepoint (surrogate pair)
713 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
714 };
715
716// Optimize for push.apply( _, NodeList )
717try {
718 push.apply(
719 (arr = slice.call( preferredDoc.childNodes )),
720 preferredDoc.childNodes
721 );
722 // Support: Android<4.0
723 // Detect silently failing push.apply
724 arr[ preferredDoc.childNodes.length ].nodeType;
725} catch ( e ) {
726 push = { apply: arr.length ?
727
728 // Leverage slice if possible
729 function( target, els ) {
730 push_native.apply( target, slice.call(els) );
731 } :
732
733 // Support: IE<9
734 // Otherwise append directly
735 function( target, els ) {
736 var j = target.length,
737 i = 0;
738 // Can't trust NodeList.length
739 while ( (target[j++] = els[i++]) ) {}
740 target.length = j - 1;
741 }
742 };
743}
744
745function Sizzle( selector, context, results, seed ) {
746 var match, elem, m, nodeType,
747 // QSA vars
748 i, groups, old, nid, newContext, newSelector;
749
750 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
751 setDocument( context );
752 }
753
754 context = context || document;
755 results = results || [];
756
757 if ( !selector || typeof selector !== "string" ) {
758 return results;
759 }
760
761 if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
762 return [];
763 }
764
765 if ( documentIsHTML && !seed ) {
766
767 // Shortcuts
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 );
780 return results;
781 }
782 } else {
783 return results;
784 }
785 } else {
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 );
790 return results;
791 }
792 }
793
794 // Speed-up: Sizzle("TAG")
795 } else if ( match[2] ) {
796 push.apply( results, context.getElementsByTagName( selector ) );
797 return results;
798
799 // Speed-up: Sizzle(".CLASS")
800 } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) {
801 push.apply( results, context.getElementsByClassName( m ) );
802 return results;
803 }
804 }
805
806 // QSA path
807 if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
808 nid = old = expando;
809 newContext = context;
810 newSelector = nodeType === 9 && selector;
811
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 );
818
819 if ( (old = context.getAttribute("id")) ) {
820 nid = old.replace( rescape, "\\$&" );
821 } else {
822 context.setAttribute( "id", nid );
823 }
824 nid = "[id='" + nid + "'] ";
825
826 i = groups.length;
827 while ( i-- ) {
828 groups[i] = nid + toSelector( groups[i] );
829 }
830 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
831 newSelector = groups.join(",");
832 }
833
834 if ( newSelector ) {
835 try {
836 push.apply( results,
837 newContext.querySelectorAll( newSelector )
838 );
839 return results;
840 } catch(qsaError) {
841 } finally {
842 if ( !old ) {
843 context.removeAttribute("id");
844 }
845 }
846 }
847 }
848 }
849
850 // All others
851 return select( selector.replace( rtrim, "$1" ), context, results, seed );
852}
853
854/**
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
859 */
860function createCache() {
861 var keys = [];
862
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() ];
868 }
869 return (cache[ key + " " ] = value);
870 }
871 return cache;
872}
873
874/**
875 * Mark a function for special use by Sizzle
876 * @param {Function} fn The function to mark
877 */
878function markFunction( fn ) {
879 fn[ expando ] = true;
880 return fn;
881}
882
883/**
884 * Support testing using an element
885 * @param {Function} fn Passed the created div and expects a boolean result
886 */
887function assert( fn ) {
888 var div = document.createElement("div");
889
890 try {
891 return !!fn( div );
892 } catch (e) {
893 return false;
894 } finally {
895 // Remove from its parent by default
896 if ( div.parentNode ) {
897 div.parentNode.removeChild( div );
898 }
899 // release memory in IE
900 div = null;
901 }
902}
903
904/**
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
908 */
909function addHandle( attrs, handler ) {
910 var arr = attrs.split("|"),
911 i = attrs.length;
912
913 while ( i-- ) {
914 Expr.attrHandle[ arr[i] ] = handler;
915 }
916}
917
918/**
919 * Checks document order of two siblings
920 * @param {Element} a
921 * @param {Element} b
922 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
923 */
924function siblingCheck( a, b ) {
925 var cur = b && a,
926 diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
927 ( ~b.sourceIndex || MAX_NEGATIVE ) -
928 ( ~a.sourceIndex || MAX_NEGATIVE );
929
930 // Use IE sourceIndex if available on both nodes
931 if ( diff ) {
932 return diff;
933 }
934
935 // Check if b follows a
936 if ( cur ) {
937 while ( (cur = cur.nextSibling) ) {
938 if ( cur === b ) {
939 return -1;
940 }
941 }
942 }
943
944 return a ? 1 : -1;
945}
946
947/**
948 * Returns a function to use in pseudos for input types
949 * @param {String} type
950 */
951function createInputPseudo( type ) {
952 return function( elem ) {
953 var name = elem.nodeName.toLowerCase();
954 return name === "input" && elem.type === type;
955 };
956}
957
958/**
959 * Returns a function to use in pseudos for buttons
960 * @param {String} type
961 */
962function createButtonPseudo( type ) {
963 return function( elem ) {
964 var name = elem.nodeName.toLowerCase();
965 return (name === "input" || name === "button") && elem.type === type;
966 };
967}
968
969/**
970 * Returns a function to use in pseudos for positionals
971 * @param {Function} fn
972 */
973function createPositionalPseudo( fn ) {
974 return markFunction(function( argument ) {
975 argument = +argument;
976 return markFunction(function( seed, matches ) {
977 var j,
978 matchIndexes = fn( [], seed.length, argument ),
979 i = matchIndexes.length;
980
981 // Match elements found at the specified indexes
982 while ( i-- ) {
983 if ( seed[ (j = matchIndexes[i]) ] ) {
984 seed[j] = !(matches[j] = seed[j]);
985 }
986 }
987 });
988 });
989}
990
991/**
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
995 */
996function testContext( context ) {
997 return context && typeof context.getElementsByTagName !== strundefined && context;
998}
999
1000// Expose support vars for convenience
1001support = Sizzle.support = {};
1002
1003/**
1004 * Detects XML nodes
1005 * @param {Element|Object} elem An element or a document
1006 * @returns {Boolean} True iff elem is a non-HTML XML node
1007 */
1008isXML = 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;
1013};
1014
1015/**
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
1019 */
1020setDocument = Sizzle.setDocument = function( node ) {
1021 var hasCompare,
1022 doc = node ? node.ownerDocument || node : preferredDoc,
1023 parent = doc.defaultView;
1024
1025 // If no document and documentElement is available, return
1026 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
1027 return document;
1028 }
1029
1030 // Set our document
1031 document = doc;
1032 docElem = doc.documentElement;
1033
1034 // Support tests
1035 documentIsHTML = !isXML( doc );
1036
1037 // Support: IE>8
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() {
1045 setDocument();
1046 }, false );
1047 } else if ( parent.attachEvent ) {
1048 parent.attachEvent( "onunload", function() {
1049 setDocument();
1050 });
1051 }
1052 }
1053
1054 /* Attributes
1055 ---------------------------------------------------------------------- */
1056
1057 // Support: IE<8
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");
1062 });
1063
1064 /* getElement(s)By*
1065 ---------------------------------------------------------------------- */
1066
1067 // Check if getElementsByTagName("*") returns only elements
1068 support.getElementsByTagName = assert(function( div ) {
1069 div.appendChild( doc.createComment("") );
1070 return !div.getElementsByTagName("*").length;
1071 });
1072
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>";
1076
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;
1083 });
1084
1085 // Support: IE<10
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;
1092 });
1093
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 ] : [];
1102 }
1103 };
1104 Expr.filter["ID"] = function( id ) {
1105 var attrId = id.replace( runescape, funescape );
1106 return function( elem ) {
1107 return elem.getAttribute("id") === attrId;
1108 };
1109 };
1110 } else {
1111 // Support: IE6/7
1112 // getElementById is not reliable as a find shortcut
1113 delete Expr.find["ID"];
1114
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;
1120 };
1121 };
1122 }
1123
1124 // Tag
1125 Expr.find["TAG"] = support.getElementsByTagName ?
1126 function( tag, context ) {
1127 if ( typeof context.getElementsByTagName !== strundefined ) {
1128 return context.getElementsByTagName( tag );
1129 }
1130 } :
1131 function( tag, context ) {
1132 var elem,
1133 tmp = [],
1134 i = 0,
1135 results = context.getElementsByTagName( tag );
1136
1137 // Filter out possible comments
1138 if ( tag === "*" ) {
1139 while ( (elem = results[i++]) ) {
1140 if ( elem.nodeType === 1 ) {
1141 tmp.push( elem );
1142 }
1143 }
1144
1145 return tmp;
1146 }
1147 return results;
1148 };
1149
1150 // Class
1151 Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
1152 if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) {
1153 return context.getElementsByClassName( className );
1154 }
1155 };
1156
1157 /* QSA/matchesSelector
1158 ---------------------------------------------------------------------- */
1159
1160 // QSA and matchesSelector support
1161
1162 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
1163 rbuggyMatches = [];
1164
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
1170 rbuggyQSA = [];
1171
1172 if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
1173 // Build QSA regex
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>";
1182
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 + "*(?:''|\"\")" );
1189 }
1190
1191 // Support: IE8
1192 // Boolean attributes and "value" are not treated correctly
1193 if ( !div.querySelectorAll("[selected]").length ) {
1194 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
1195 }
1196
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");
1202 }
1203 });
1204
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" );
1211
1212 // Support: IE8
1213 // Enforce case-sensitivity of name attribute
1214 if ( div.querySelectorAll("[name=d]").length ) {
1215 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
1216 }
1217
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" );
1222 }
1223
1224 // Opera 10-11 does not throw on post-comma invalid pseudos
1225 div.querySelectorAll("*,:x");
1226 rbuggyQSA.push(",.*:");
1227 });
1228 }
1229
1230 if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
1231 docElem.webkitMatchesSelector ||
1232 docElem.mozMatchesSelector ||
1233 docElem.oMatchesSelector ||
1234 docElem.msMatchesSelector) )) ) {
1235
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" );
1240
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 );
1245 });
1246 }
1247
1248 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
1249 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
1250
1251 /* Contains
1252 ---------------------------------------------------------------------- */
1253 hasCompare = rnative.test( docElem.compareDocumentPosition );
1254
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 ) ?
1259 function( a, b ) {
1260 var adown = a.nodeType === 9 ? a.documentElement : a,
1261 bup = b && b.parentNode;
1262 return a === bup || !!( bup && bup.nodeType === 1 && (
1263 adown.contains ?
1264 adown.contains( bup ) :
1265 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
1266 ));
1267 } :
1268 function( a, b ) {
1269 if ( b ) {
1270 while ( (b = b.parentNode) ) {
1271 if ( b === a ) {
1272 return true;
1273 }
1274 }
1275 }
1276 return false;
1277 };
1278
1279 /* Sorting
1280 ---------------------------------------------------------------------- */
1281
1282 // Document order sorting
1283 sortOrder = hasCompare ?
1284 function( a, b ) {
1285
1286 // Flag for duplicate removal
1287 if ( a === b ) {
1288 hasDuplicate = true;
1289 return 0;
1290 }
1291
1292 // Sort on method existence if only one input has compareDocumentPosition
1293 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
1294 if ( compare ) {
1295 return compare;
1296 }
1297
1298 // Calculate position if both inputs belong to the same document
1299 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
1300 a.compareDocumentPosition( b ) :
1301
1302 // Otherwise we know they are disconnected
1303 1;
1304
1305 // Disconnected nodes
1306 if ( compare & 1 ||
1307 (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
1308
1309 // Choose the first element that is related to our preferred document
1310 if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
1311 return -1;
1312 }
1313 if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
1314 return 1;
1315 }
1316
1317 // Maintain original order
1318 return sortInput ?
1319 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
1320 0;
1321 }
1322
1323 return compare & 4 ? -1 : 1;
1324 } :
1325 function( a, b ) {
1326 // Exit early if the nodes are identical
1327 if ( a === b ) {
1328 hasDuplicate = true;
1329 return 0;
1330 }
1331
1332 var cur,
1333 i = 0,
1334 aup = a.parentNode,
1335 bup = b.parentNode,
1336 ap = [ a ],
1337 bp = [ b ];
1338
1339 // Parentless nodes are either documents or disconnected
1340 if ( !aup || !bup ) {
1341 return a === doc ? -1 :
1342 b === doc ? 1 :
1343 aup ? -1 :
1344 bup ? 1 :
1345 sortInput ?
1346 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
1347 0;
1348
1349 // If the nodes are siblings, we can do a quick check
1350 } else if ( aup === bup ) {
1351 return siblingCheck( a, b );
1352 }
1353
1354 // Otherwise we need full lists of their ancestors for comparison
1355 cur = a;
1356 while ( (cur = cur.parentNode) ) {
1357 ap.unshift( cur );
1358 }
1359 cur = b;
1360 while ( (cur = cur.parentNode) ) {
1361 bp.unshift( cur );
1362 }
1363
1364 // Walk down the tree looking for a discrepancy
1365 while ( ap[i] === bp[i] ) {
1366 i++;
1367 }
1368
1369 return i ?
1370 // Do a sibling check if the nodes have a common ancestor
1371 siblingCheck( ap[i], bp[i] ) :
1372
1373 // Otherwise nodes in our document sort first
1374 ap[i] === preferredDoc ? -1 :
1375 bp[i] === preferredDoc ? 1 :
1376 0;
1377 };
1378
1379 return doc;
1380};
1381
1382Sizzle.matches = function( expr, elements ) {
1383 return Sizzle( expr, null, null, elements );
1384};
1385
1386Sizzle.matchesSelector = function( elem, expr ) {
1387 // Set document vars if needed
1388 if ( ( elem.ownerDocument || elem ) !== document ) {
1389 setDocument( elem );
1390 }
1391
1392 // Make sure that attribute selectors are quoted
1393 expr = expr.replace( rattributeQuotes, "='$1']" );
1394
1395 if ( support.matchesSelector && documentIsHTML &&
1396 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
1397 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
1398
1399 try {
1400 var ret = matches.call( elem, expr );
1401
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
1405 // fragment in IE 9
1406 elem.document && elem.document.nodeType !== 11 ) {
1407 return ret;
1408 }
1409 } catch(e) {}
1410 }
1411
1412 return Sizzle( expr, document, null, [ elem ] ).length > 0;
1413};
1414
1415Sizzle.contains = function( context, elem ) {
1416 // Set document vars if needed
1417 if ( ( context.ownerDocument || context ) !== document ) {
1418 setDocument( context );
1419 }
1420 return contains( context, elem );
1421};
1422
1423Sizzle.attr = function( elem, name ) {
1424 // Set document vars if needed
1425 if ( ( elem.ownerDocument || elem ) !== document ) {
1426 setDocument( elem );
1427 }
1428
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 ) :
1433 undefined;
1434
1435 return val !== undefined ?
1436 val :
1437 support.attributes || !documentIsHTML ?
1438 elem.getAttribute( name ) :
1439 (val = elem.getAttributeNode(name)) && val.specified ?
1440 val.value :
1441 null;
1442};
1443
1444Sizzle.error = function( msg ) {
1445 throw new Error( "Syntax error, unrecognized expression: " + msg );
1446};
1447
1448/**
1449 * Document sorting and removing duplicates
1450 * @param {ArrayLike} results
1451 */
1452Sizzle.uniqueSort = function( results ) {
1453 var elem,
1454 duplicates = [],
1455 j = 0,
1456 i = 0;
1457
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 );
1462
1463 if ( hasDuplicate ) {
1464 while ( (elem = results[i++]) ) {
1465 if ( elem === results[ i ] ) {
1466 j = duplicates.push( i );
1467 }
1468 }
1469 while ( j-- ) {
1470 results.splice( duplicates[ j ], 1 );
1471 }
1472 }
1473
1474 // Clear input after sorting to release objects
1475 // See https://github.com/jquery/sizzle/pull/225
1476 sortInput = null;
1477
1478 return results;
1479};
1480
1481/**
1482 * Utility function for retrieving the text value of an array of DOM nodes
1483 * @param {Array|Element} elem
1484 */
1485getText = Sizzle.getText = function( elem ) {
1486 var node,
1487 ret = "",
1488 i = 0,
1489 nodeType = elem.nodeType;
1490
1491 if ( !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 );
1496 }
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;
1502 } else {
1503 // Traverse its children
1504 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
1505 ret += getText( elem );
1506 }
1507 }
1508 } else if ( nodeType === 3 || nodeType === 4 ) {
1509 return elem.nodeValue;
1510 }
1511 // Do not include comment or processing instruction nodes
1512
1513 return ret;
1514};
1515
1516Expr = Sizzle.selectors = {
1517
1518 // Can be adjusted by the user
1519 cacheLength: 50,
1520
1521 createPseudo: markFunction,
1522
1523 match: matchExpr,
1524
1525 attrHandle: {},
1526
1527 find: {},
1528
1529 relative: {
1530 ">": { dir: "parentNode", first: true },
1531 " ": { dir: "parentNode" },
1532 "+": { dir: "previousSibling", first: true },
1533 "~": { dir: "previousSibling" }
1534 },
1535
1536 preFilter: {
1537 "ATTR": function( match ) {
1538 match[1] = match[1].replace( runescape, funescape );
1539
1540 // Move the given value to match[3] whether quoted or unquoted
1541 match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
1542
1543 if ( match[2] === "~=" ) {
1544 match[3] = " " + match[3] + " ";
1545 }
1546
1547 return match.slice( 0, 4 );
1548 },
1549
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
1557 6 x of xn-component
1558 7 sign of y-component
1559 8 y of y-component
1560 */
1561 match[1] = match[1].toLowerCase();
1562
1563 if ( match[1].slice( 0, 3 ) === "nth" ) {
1564 // nth-* requires argument
1565 if ( !match[3] ) {
1566 Sizzle.error( match[0] );
1567 }
1568
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" );
1573
1574 // other types prohibit arguments
1575 } else if ( match[3] ) {
1576 Sizzle.error( match[0] );
1577 }
1578
1579 return match;
1580 },
1581
1582 "PSEUDO": function( match ) {
1583 var excess,
1584 unquoted = !match[6] && match[2];
1585
1586 if ( matchExpr["CHILD"].test( match[0] ) ) {
1587 return null;
1588 }
1589
1590 // Accept quoted arguments as-is
1591 if ( match[3] ) {
1592 match[2] = match[4] || match[5] || "";
1593
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) ) {
1600
1601 // excess is a negative index
1602 match[0] = match[0].slice( 0, excess );
1603 match[2] = unquoted.slice( 0, excess );
1604 }
1605
1606 // Return only captures needed by the pseudo filter method (type and argument)
1607 return match.slice( 0, 3 );
1608 }
1609 },
1610
1611 filter: {
1612
1613 "TAG": function( nodeNameSelector ) {
1614 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
1615 return nodeNameSelector === "*" ?
1616 function() { return true; } :
1617 function( elem ) {
1618 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
1619 };
1620 },
1621
1622 "CLASS": function( className ) {
1623 var pattern = classCache[ className + " " ];
1624
1625 return pattern ||
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") || "" );
1629 });
1630 },
1631
1632 "ATTR": function( name, operator, check ) {
1633 return function( elem ) {
1634 var result = Sizzle.attr( elem, name );
1635
1636 if ( result == null ) {
1637 return operator === "!=";
1638 }
1639 if ( !operator ) {
1640 return true;
1641 }
1642
1643 result += "";
1644
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 + "-" :
1652 false;
1653 };
1654 },
1655
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";
1660
1661 return first === 1 && last === 0 ?
1662
1663 // Shortcut for :nth-*(n)
1664 function( elem ) {
1665 return !!elem.parentNode;
1666 } :
1667
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;
1674
1675 if ( parent ) {
1676
1677 // :(first|last|only)-(child|of-type)
1678 if ( simple ) {
1679 while ( dir ) {
1680 node = elem;
1681 while ( (node = node[ dir ]) ) {
1682 if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
1683 return false;
1684 }
1685 }
1686 // Reverse direction for :only-* (if we haven't yet done so)
1687 start = dir = type === "only" && !start && "nextSibling";
1688 }
1689 return true;
1690 }
1691
1692 start = [ forward ? parent.firstChild : parent.lastChild ];
1693
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 ];
1702
1703 while ( (node = ++nodeIndex && node && node[ dir ] ||
1704
1705 // Fallback to seeking `elem` from the start
1706 (diff = nodeIndex = 0) || start.pop()) ) {
1707
1708 // When found, cache indexes on `parent` and break
1709 if ( node.nodeType === 1 && ++diff && node === elem ) {
1710 outerCache[ type ] = [ dirruns, nodeIndex, diff ];
1711 break;
1712 }
1713 }
1714
1715 // Use previously-cached element index if available
1716 } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
1717 diff = cache[1];
1718
1719 // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
1720 } else {
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()) ) {
1724
1725 if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
1726 // Cache the index of each encountered element
1727 if ( useCache ) {
1728 (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
1729 }
1730
1731 if ( node === elem ) {
1732 break;
1733 }
1734 }
1735 }
1736 }
1737
1738 // Incorporate the offset, then check against cycle size
1739 diff -= last;
1740 return diff === first || ( diff % first === 0 && diff / first >= 0 );
1741 }
1742 };
1743 },
1744
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
1750 var args,
1751 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
1752 Sizzle.error( "unsupported pseudo: " + pseudo );
1753
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 );
1759 }
1760
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 ) {
1766 var idx,
1767 matched = fn( seed, argument ),
1768 i = matched.length;
1769 while ( i-- ) {
1770 idx = indexOf.call( seed, matched[i] );
1771 seed[ idx ] = !( matches[ idx ] = matched[i] );
1772 }
1773 }) :
1774 function( elem ) {
1775 return fn( elem, 0, args );
1776 };
1777 }
1778
1779 return fn;
1780 }
1781 },
1782
1783 pseudos: {
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
1789 var input = [],
1790 results = [],
1791 matcher = compile( selector.replace( rtrim, "$1" ) );
1792
1793 return matcher[ expando ] ?
1794 markFunction(function( seed, matches, context, xml ) {
1795 var elem,
1796 unmatched = matcher( seed, null, xml, [] ),
1797 i = seed.length;
1798
1799 // Match elements unmatched by `matcher`
1800 while ( i-- ) {
1801 if ( (elem = unmatched[i]) ) {
1802 seed[i] = !(matches[i] = elem);
1803 }
1804 }
1805 }) :
1806 function( elem, context, xml ) {
1807 input[0] = elem;
1808 matcher( input, null, xml, results );
1809 return !results.pop();
1810 };
1811 }),
1812
1813 "has": markFunction(function( selector ) {
1814 return function( elem ) {
1815 return Sizzle( selector, elem ).length > 0;
1816 };
1817 }),
1818
1819 "contains": markFunction(function( text ) {
1820 return function( elem ) {
1821 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
1822 };
1823 }),
1824
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 );
1836 }
1837 lang = lang.replace( runescape, funescape ).toLowerCase();
1838 return function( elem ) {
1839 var elemLang;
1840 do {
1841 if ( (elemLang = documentIsHTML ?
1842 elem.lang :
1843 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
1844
1845 elemLang = elemLang.toLowerCase();
1846 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
1847 }
1848 } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
1849 return false;
1850 };
1851 }),
1852
1853 // Miscellaneous
1854 "target": function( elem ) {
1855 var hash = window.location && window.location.hash;
1856 return hash && hash.slice( 1 ) === elem.id;
1857 },
1858
1859 "root": function( elem ) {
1860 return elem === docElem;
1861 },
1862
1863 "focus": function( elem ) {
1864 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
1865 },
1866
1867 // Boolean properties
1868 "enabled": function( elem ) {
1869 return elem.disabled === false;
1870 },
1871
1872 "disabled": function( elem ) {
1873 return elem.disabled === true;
1874 },
1875
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);
1881 },
1882
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;
1888 }
1889
1890 return elem.selected === true;
1891 },
1892
1893 // Contents
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 ) {
1901 return false;
1902 }
1903 }
1904 return true;
1905 },
1906
1907 "parent": function( elem ) {
1908 return !Expr.pseudos["empty"]( elem );
1909 },
1910
1911 // Element/input types
1912 "header": function( elem ) {
1913 return rheader.test( elem.nodeName );
1914 },
1915
1916 "input": function( elem ) {
1917 return rinputs.test( elem.nodeName );
1918 },
1919
1920 "button": function( elem ) {
1921 var name = elem.nodeName.toLowerCase();
1922 return name === "input" && elem.type === "button" || name === "button";
1923 },
1924
1925 "text": function( elem ) {
1926 var attr;
1927 return elem.nodeName.toLowerCase() === "input" &&
1928 elem.type === "text" &&
1929
1930 // Support: IE<8
1931 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
1932 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
1933 },
1934
1935 // Position-in-collection
1936 "first": createPositionalPseudo(function() {
1937 return [ 0 ];
1938 }),
1939
1940 "last": createPositionalPseudo(function( matchIndexes, length ) {
1941 return [ length - 1 ];
1942 }),
1943
1944 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
1945 return [ argument < 0 ? argument + length : argument ];
1946 }),
1947
1948 "even": createPositionalPseudo(function( matchIndexes, length ) {
1949 var i = 0;
1950 for ( ; i < length; i += 2 ) {
1951 matchIndexes.push( i );
1952 }
1953 return matchIndexes;
1954 }),
1955
1956 "odd": createPositionalPseudo(function( matchIndexes, length ) {
1957 var i = 1;
1958 for ( ; i < length; i += 2 ) {
1959 matchIndexes.push( i );
1960 }
1961 return matchIndexes;
1962 }),
1963
1964 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
1965 var i = argument < 0 ? argument + length : argument;
1966 for ( ; --i >= 0; ) {
1967 matchIndexes.push( i );
1968 }
1969 return matchIndexes;
1970 }),
1971
1972 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
1973 var i = argument < 0 ? argument + length : argument;
1974 for ( ; ++i < length; ) {
1975 matchIndexes.push( i );
1976 }
1977 return matchIndexes;
1978 })
1979 }
1980};
1981
1982Expr.pseudos["nth"] = Expr.pseudos["eq"];
1983
1984// Add button/input type pseudos
1985for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
1986 Expr.pseudos[ i ] = createInputPseudo( i );
1987}
1988for ( i in { submit: true, reset: true } ) {
1989 Expr.pseudos[ i ] = createButtonPseudo( i );
1990}
1991
1992// Easy API for creating new setFilters
1993function setFilters() {}
1994setFilters.prototype = Expr.filters = Expr.pseudos;
1995Expr.setFilters = new setFilters();
1996
1997tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
1998 var matched, match, tokens, type,
1999 soFar, groups, preFilters,
2000 cached = tokenCache[ selector + " " ];
2001
2002 if ( cached ) {
2003 return parseOnly ? 0 : cached.slice( 0 );
2004 }
2005
2006 soFar = selector;
2007 groups = [];
2008 preFilters = Expr.preFilter;
2009
2010 while ( soFar ) {
2011
2012 // Comma and first run
2013 if ( !matched || (match = rcomma.exec( soFar )) ) {
2014 if ( match ) {
2015 // Don't consume trailing commas as valid
2016 soFar = soFar.slice( match[0].length ) || soFar;
2017 }
2018 groups.push( (tokens = []) );
2019 }
2020
2021 matched = false;
2022
2023 // Combinators
2024 if ( (match = rcombinators.exec( soFar )) ) {
2025 matched = match.shift();
2026 tokens.push({
2027 value: matched,
2028 // Cast descendant combinators to space
2029 type: match[0].replace( rtrim, " " )
2030 });
2031 soFar = soFar.slice( matched.length );
2032 }
2033
2034 // Filters
2035 for ( type in Expr.filter ) {
2036 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
2037 (match = preFilters[ type ]( match ))) ) {
2038 matched = match.shift();
2039 tokens.push({
2040 value: matched,
2041 type: type,
2042 matches: match
2043 });
2044 soFar = soFar.slice( matched.length );
2045 }
2046 }
2047
2048 if ( !matched ) {
2049 break;
2050 }
2051 }
2052
2053 // Return the length of the invalid excess
2054 // if we're just parsing
2055 // Otherwise, throw an error or return tokens
2056 return parseOnly ?
2057 soFar.length :
2058 soFar ?
2059 Sizzle.error( selector ) :
2060 // Cache the tokens
2061 tokenCache( selector, groups ).slice( 0 );
2062};
2063
2064function toSelector( tokens ) {
2065 var i = 0,
2066 len = tokens.length,
2067 selector = "";
2068 for ( ; i < len; i++ ) {
2069 selector += tokens[i].value;
2070 }
2071 return selector;
2072}
2073
2074function addCombinator( matcher, combinator, base ) {
2075 var dir = combinator.dir,
2076 checkNonElements = base && dir === "parentNode",
2077 doneName = done++;
2078
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 );
2085 }
2086 }
2087 } :
2088
2089 // Check against all ancestor/preceding elements
2090 function( elem, context, xml ) {
2091 var oldCache, outerCache,
2092 newCache = [ dirruns, doneName ];
2093
2094 // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
2095 if ( xml ) {
2096 while ( (elem = elem[ dir ]) ) {
2097 if ( elem.nodeType === 1 || checkNonElements ) {
2098 if ( matcher( elem, context, xml ) ) {
2099 return true;
2100 }
2101 }
2102 }
2103 } else {
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 ) {
2109
2110 // Assign to newCache so results back-propagate to previous elements
2111 return (newCache[ 2 ] = oldCache[ 2 ]);
2112 } else {
2113 // Reuse newcache so results back-propagate to previous elements
2114 outerCache[ dir ] = newCache;
2115
2116 // A match means we're done; a fail means we have to keep checking
2117 if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
2118 return true;
2119 }
2120 }
2121 }
2122 }
2123 }
2124 };
2125}
2126
2127function elementMatcher( matchers ) {
2128 return matchers.length > 1 ?
2129 function( elem, context, xml ) {
2130 var i = matchers.length;
2131 while ( i-- ) {
2132 if ( !matchers[i]( elem, context, xml ) ) {
2133 return false;
2134 }
2135 }
2136 return true;
2137 } :
2138 matchers[0];
2139}
2140
2141function multipleContexts( selector, contexts, results ) {
2142 var i = 0,
2143 len = contexts.length;
2144 for ( ; i < len; i++ ) {
2145 Sizzle( selector, contexts[i], results );
2146 }
2147 return results;
2148}
2149
2150function condense( unmatched, map, filter, context, xml ) {
2151 var elem,
2152 newUnmatched = [],
2153 i = 0,
2154 len = unmatched.length,
2155 mapped = map != null;
2156
2157 for ( ; i < len; i++ ) {
2158 if ( (elem = unmatched[i]) ) {
2159 if ( !filter || filter( elem, context, xml ) ) {
2160 newUnmatched.push( elem );
2161 if ( mapped ) {
2162 map.push( i );
2163 }
2164 }
2165 }
2166 }
2167
2168 return newUnmatched;
2169}
2170
2171function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
2172 if ( postFilter && !postFilter[ expando ] ) {
2173 postFilter = setMatcher( postFilter );
2174 }
2175 if ( postFinder && !postFinder[ expando ] ) {
2176 postFinder = setMatcher( postFinder, postSelector );
2177 }
2178 return markFunction(function( seed, results, context, xml ) {
2179 var temp, i, elem,
2180 preMap = [],
2181 postMap = [],
2182 preexisting = results.length,
2183
2184 // Get initial elements from seed or context
2185 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
2186
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 ) :
2190 elems,
2191
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 ) ?
2195
2196 // ...intermediate processing is necessary
2197 [] :
2198
2199 // ...otherwise use results directly
2200 results :
2201 matcherIn;
2202
2203 // Find primary matches
2204 if ( matcher ) {
2205 matcher( matcherIn, matcherOut, context, xml );
2206 }
2207
2208 // Apply postFilter
2209 if ( postFilter ) {
2210 temp = condense( matcherOut, postMap );
2211 postFilter( temp, [], context, xml );
2212
2213 // Un-match failing elements by moving them back to matcherIn
2214 i = temp.length;
2215 while ( i-- ) {
2216 if ( (elem = temp[i]) ) {
2217 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
2218 }
2219 }
2220 }
2221
2222 if ( seed ) {
2223 if ( postFinder || preFilter ) {
2224 if ( postFinder ) {
2225 // Get the final matcherOut by condensing this intermediate into postFinder contexts
2226 temp = [];
2227 i = matcherOut.length;
2228 while ( i-- ) {
2229 if ( (elem = matcherOut[i]) ) {
2230 // Restore matcherIn since elem is not yet a final match
2231 temp.push( (matcherIn[i] = elem) );
2232 }
2233 }
2234 postFinder( null, (matcherOut = []), temp, xml );
2235 }
2236
2237 // Move matched elements from seed to results to keep them synchronized
2238 i = matcherOut.length;
2239 while ( i-- ) {
2240 if ( (elem = matcherOut[i]) &&
2241 (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
2242
2243 seed[temp] = !(results[temp] = elem);
2244 }
2245 }
2246 }
2247
2248 // Add elements to results, through postFinder if defined
2249 } else {
2250 matcherOut = condense(
2251 matcherOut === results ?
2252 matcherOut.splice( preexisting, matcherOut.length ) :
2253 matcherOut
2254 );
2255 if ( postFinder ) {
2256 postFinder( null, results, matcherOut, xml );
2257 } else {
2258 push.apply( results, matcherOut );
2259 }
2260 }
2261 });
2262}
2263
2264function 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,
2270
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 ) );
2283 } ];
2284
2285 for ( ; i < len; i++ ) {
2286 if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
2287 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
2288 } else {
2289 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
2290
2291 // Return special upon seeing a positional matcher
2292 if ( matcher[ expando ] ) {
2293 // Find the next relative operator (if any) for proper handling
2294 j = ++i;
2295 for ( ; j < len; j++ ) {
2296 if ( Expr.relative[ tokens[j].type ] ) {
2297 break;
2298 }
2299 }
2300 return setMatcher(
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" ),
2306 matcher,
2307 i < j && matcherFromTokens( tokens.slice( i, j ) ),
2308 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
2309 j < len && toSelector( tokens )
2310 );
2311 }
2312 matchers.push( matcher );
2313 }
2314 }
2315
2316 return elementMatcher( matchers );
2317}
2318
2319function 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,
2324 matchedCount = 0,
2325 i = "0",
2326 unmatched = seed && [],
2327 setMatched = [],
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),
2333 len = elems.length;
2334
2335 if ( outermost ) {
2336 outermostContext = context !== document && context;
2337 }
2338
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 ) {
2345 j = 0;
2346 while ( (matcher = elementMatchers[j++]) ) {
2347 if ( matcher( elem, context, xml ) ) {
2348 results.push( elem );
2349 break;
2350 }
2351 }
2352 if ( outermost ) {
2353 dirruns = dirrunsUnique;
2354 }
2355 }
2356
2357 // Track unmatched elements for set filters
2358 if ( bySet ) {
2359 // They will have gone through all possible matchers
2360 if ( (elem = !matcher && elem) ) {
2361 matchedCount--;
2362 }
2363
2364 // Lengthen the array for every element, matched or not
2365 if ( seed ) {
2366 unmatched.push( elem );
2367 }
2368 }
2369 }
2370
2371 // Apply set filters to unmatched elements
2372 matchedCount += i;
2373 if ( bySet && i !== matchedCount ) {
2374 j = 0;
2375 while ( (matcher = setMatchers[j++]) ) {
2376 matcher( unmatched, setMatched, context, xml );
2377 }
2378
2379 if ( seed ) {
2380 // Reintegrate element matches to eliminate the need for sorting
2381 if ( matchedCount > 0 ) {
2382 while ( i-- ) {
2383 if ( !(unmatched[i] || setMatched[i]) ) {
2384 setMatched[i] = pop.call( results );
2385 }
2386 }
2387 }
2388
2389 // Discard index placeholder values to get only actual matches
2390 setMatched = condense( setMatched );
2391 }
2392
2393 // Add matches to results
2394 push.apply( results, setMatched );
2395
2396 // Seedless set matches succeeding multiple successful matchers stipulate sorting
2397 if ( outermost && !seed && setMatched.length > 0 &&
2398 ( matchedCount + setMatchers.length ) > 1 ) {
2399
2400 Sizzle.uniqueSort( results );
2401 }
2402 }
2403
2404 // Override manipulation of globals by nested matchers
2405 if ( outermost ) {
2406 dirruns = dirrunsUnique;
2407 outermostContext = contextBackup;
2408 }
2409
2410 return unmatched;
2411 };
2412
2413 return bySet ?
2414 markFunction( superMatcher ) :
2415 superMatcher;
2416}
2417
2418compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
2419 var i,
2420 setMatchers = [],
2421 elementMatchers = [],
2422 cached = compilerCache[ selector + " " ];
2423
2424 if ( !cached ) {
2425 // Generate a function of recursive functions that can be used to check each element
2426 if ( !match ) {
2427 match = tokenize( selector );
2428 }
2429 i = match.length;
2430 while ( i-- ) {
2431 cached = matcherFromTokens( match[i] );
2432 if ( cached[ expando ] ) {
2433 setMatchers.push( cached );
2434 } else {
2435 elementMatchers.push( cached );
2436 }
2437 }
2438
2439 // Cache the compiled function
2440 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
2441
2442 // Save selector and tokenization
2443 cached.selector = selector;
2444 }
2445 return cached;
2446};
2447
2448/**
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
2456 */
2457select = 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) );
2461
2462 results = results || [];
2463
2464 // Try to minimize operations if there is no seed and only one group
2465 if ( match.length === 1 ) {
2466
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 ] ) {
2472
2473 context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
2474 if ( !context ) {
2475 return results;
2476
2477 // Precompiled matchers will still verify ancestry, so step up a level
2478 } else if ( compiled ) {
2479 context = context.parentNode;
2480 }
2481
2482 selector = selector.slice( tokens.shift().value.length );
2483 }
2484
2485 // Fetch a seed set for right-to-left matching
2486 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
2487 while ( i-- ) {
2488 token = tokens[i];
2489
2490 // Abort if we hit a combinator
2491 if ( Expr.relative[ (type = token.type) ] ) {
2492 break;
2493 }
2494 if ( (find = Expr.find[ type ]) ) {
2495 // Search, expanding context for leading sibling combinators
2496 if ( (seed = find(
2497 token.matches[0].replace( runescape, funescape ),
2498 rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
2499 )) ) {
2500
2501 // If seed is empty or no tokens remain, we can return early
2502 tokens.splice( i, 1 );
2503 selector = seed.length && toSelector( tokens );
2504 if ( !selector ) {
2505 push.apply( results, seed );
2506 return results;
2507 }
2508
2509 break;
2510 }
2511 }
2512 }
2513 }
2514
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 ) )(
2518 seed,
2519 context,
2520 !documentIsHTML,
2521 results,
2522 rsibling.test( selector ) && testContext( context.parentNode ) || context
2523 );
2524 return results;
2525};
2526
2527// One-time assignments
2528
2529// Sort stability
2530support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
2531
2532// Support: Chrome<14
2533// Always assume duplicates if they aren't passed to the comparison function
2534support.detectDuplicates = !!hasDuplicate;
2535
2536// Initialize against the default document
2537setDocument();
2538
2539// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
2540// Detached nodes confoundingly follow *each other*
2541support.sortDetached = assert(function( div1 ) {
2542 // Should return 1, but returns 4 (following)
2543 return div1.compareDocumentPosition( document.createElement("div") ) & 1;
2544});
2545
2546// Support: IE<8
2547// Prevent attribute/property "interpolation"
2548// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
2549if ( !assert(function( div ) {
2550 div.innerHTML = "<a href='#'></a>";
2551 return div.firstChild.getAttribute("href") === "#" ;
2552}) ) {
2553 addHandle( "type|href|height|width", function( elem, name, isXML ) {
2554 if ( !isXML ) {
2555 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
2556 }
2557 });
2558}
2559
2560// Support: IE<9
2561// Use defaultValue in place of getAttribute("value")
2562if ( !support.attributes || !assert(function( div ) {
2563 div.innerHTML = "<input/>";
2564 div.firstChild.setAttribute( "value", "" );
2565 return div.firstChild.getAttribute( "value" ) === "";
2566}) ) {
2567 addHandle( "value", function( elem, name, isXML ) {
2568 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
2569 return elem.defaultValue;
2570 }
2571 });
2572}
2573
2574// Support: IE<9
2575// Use getAttributeNode to fetch booleans when getAttribute lies
2576if ( !assert(function( div ) {
2577 return div.getAttribute("disabled") == null;
2578}) ) {
2579 addHandle( booleans, function( elem, name, isXML ) {
2580 var val;
2581 if ( !isXML ) {
2582 return elem[ name ] === true ? name.toLowerCase() :
2583 (val = elem.getAttributeNode( name )) && val.specified ?
2584 val.value :
2585 null;
2586 }
2587 });
2588}
2589
2590return Sizzle;
2591
2592})( window );
2593
2594
2595
2596jQuery.find = Sizzle;
2597jQuery.expr = Sizzle.selectors;
2598jQuery.expr[":"] = jQuery.expr.pseudos;
2599jQuery.unique = Sizzle.uniqueSort;
2600jQuery.text = Sizzle.getText;
2601jQuery.isXMLDoc = Sizzle.isXML;
2602jQuery.contains = Sizzle.contains;
2603
2604
2605
2606var rneedsContext = jQuery.expr.match.needsContext;
2607
2608var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
2609
2610
2611
2612var risSimple = /^.[^:#\[\.,]*$/;
2613
2614// Implement the identical functionality for filter and not
2615function winnow( elements, qualifier, not ) {
2616 if ( jQuery.isFunction( qualifier ) ) {
2617 return jQuery.grep( elements, function( elem, i ) {
2618 /* jshint -W018 */
2619 return !!qualifier.call( elem, i, elem ) !== not;
2620 });
2621
2622 }
2623
2624 if ( qualifier.nodeType ) {
2625 return jQuery.grep( elements, function( elem ) {
2626 return ( elem === qualifier ) !== not;
2627 });
2628
2629 }
2630
2631 if ( typeof qualifier === "string" ) {
2632 if ( risSimple.test( qualifier ) ) {
2633 return jQuery.filter( qualifier, elements, not );
2634 }
2635
2636 qualifier = jQuery.filter( qualifier, elements );
2637 }
2638
2639 return jQuery.grep( elements, function( elem ) {
2640 return ( indexOf.call( qualifier, elem ) >= 0 ) !== not;
2641 });
2642}
2643
2644jQuery.filter = function( expr, elems, not ) {
2645 var elem = elems[ 0 ];
2646
2647 if ( not ) {
2648 expr = ":not(" + expr + ")";
2649 }
2650
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;
2655 }));
2656};
2657
2658jQuery.fn.extend({
2659 find: function( selector ) {
2660 var i,
2661 len = this.length,
2662 ret = [],
2663 self = this;
2664
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 ) ) {
2669 return true;
2670 }
2671 }
2672 }) );
2673 }
2674
2675 for ( i = 0; i < len; i++ ) {
2676 jQuery.find( selector, self[ i ], ret );
2677 }
2678
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;
2682 return ret;
2683 },
2684 filter: function( selector ) {
2685 return this.pushStack( winnow(this, selector || [], false) );
2686 },
2687 not: function( selector ) {
2688 return this.pushStack( winnow(this, selector || [], true) );
2689 },
2690 is: function( selector ) {
2691 return !!winnow(
2692 this,
2693
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 ) :
2698 selector || [],
2699 false
2700 ).length;
2701 }
2702});
2703
2704
2705// Initialize a jQuery object
2706
2707
2708// A central reference to the root jQuery(document)
2709var rootjQuery,
2710
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-]*))$/,
2715
2716 init = jQuery.fn.init = function( selector, context ) {
2717 var match, elem;
2718
2719 // HANDLE: $(""), $(null), $(undefined), $(false)
2720 if ( !selector ) {
2721 return this;
2722 }
2723
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 ];
2729
2730 } else {
2731 match = rquickExpr.exec( selector );
2732 }
2733
2734 // Match html or make sure no context is specified for #id
2735 if ( match && (match[1] || !context) ) {
2736
2737 // HANDLE: $(html) -> $(array)
2738 if ( match[1] ) {
2739 context = context instanceof jQuery ? context[0] : context;
2740
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(
2744 match[1],
2745 context && context.nodeType ? context.ownerDocument || context : document,
2746 true
2747 ) );
2748
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 ] );
2755
2756 // ...and otherwise set as attributes
2757 } else {
2758 this.attr( match, context[ match ] );
2759 }
2760 }
2761 }
2762
2763 return this;
2764
2765 // HANDLE: $(#id)
2766 } else {
2767 elem = document.getElementById( match[2] );
2768
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
2773 this.length = 1;
2774 this[0] = elem;
2775 }
2776
2777 this.context = document;
2778 this.selector = selector;
2779 return this;
2780 }
2781
2782 // HANDLE: $(expr, $(...))
2783 } else if ( !context || context.jquery ) {
2784 return ( context || rootjQuery ).find( selector );
2785
2786 // HANDLE: $(expr, context)
2787 // (which is just equivalent to: $(context).find(expr)
2788 } else {
2789 return this.constructor( context ).find( selector );
2790 }
2791
2792 // HANDLE: $(DOMElement)
2793 } else if ( selector.nodeType ) {
2794 this.context = this[0] = selector;
2795 this.length = 1;
2796 return this;
2797
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
2804 selector( jQuery );
2805 }
2806
2807 if ( selector.selector !== undefined ) {
2808 this.selector = selector.selector;
2809 this.context = selector.context;
2810 }
2811
2812 return jQuery.makeArray( selector, this );
2813 };
2814
2815// Give the init function the jQuery prototype for later instantiation
2816init.prototype = jQuery.fn;
2817
2818// Initialize central reference
2819rootjQuery = jQuery( document );
2820
2821
2822var rparentsprev = /^(?:parents|prev(?:Until|All))/,
2823 // methods guaranteed to produce a unique set when starting from a unique set
2824 guaranteedUnique = {
2825 children: true,
2826 contents: true,
2827 next: true,
2828 prev: true
2829 };
2830
2831jQuery.extend({
2832 dir: function( elem, dir, until ) {
2833 var matched = [],
2834 truncate = until !== undefined;
2835
2836 while ( (elem = elem[ dir ]) && elem.nodeType !== 9 ) {
2837 if ( elem.nodeType === 1 ) {
2838 if ( truncate && jQuery( elem ).is( until ) ) {
2839 break;
2840 }
2841 matched.push( elem );
2842 }
2843 }
2844 return matched;
2845 },
2846
2847 sibling: function( n, elem ) {
2848 var matched = [];
2849
2850 for ( ; n; n = n.nextSibling ) {
2851 if ( n.nodeType === 1 && n !== elem ) {
2852 matched.push( n );
2853 }
2854 }
2855
2856 return matched;
2857 }
2858});
2859
2860jQuery.fn.extend({
2861 has: function( target ) {
2862 var targets = jQuery( target, this ),
2863 l = targets.length;
2864
2865 return this.filter(function() {
2866 var i = 0;
2867 for ( ; i < l; i++ ) {
2868 if ( jQuery.contains( this, targets[i] ) ) {
2869 return true;
2870 }
2871 }
2872 });
2873 },
2874
2875 closest: function( selectors, context ) {
2876 var cur,
2877 i = 0,
2878 l = this.length,
2879 matched = [],
2880 pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
2881 jQuery( selectors, context || this.context ) :
2882 0;
2883
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 :
2889
2890 // Don't pass non-elements to Sizzle
2891 cur.nodeType === 1 &&
2892 jQuery.find.matchesSelector(cur, selectors)) ) {
2893
2894 matched.push( cur );
2895 break;
2896 }
2897 }
2898 }
2899
2900 return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched );
2901 },
2902
2903 // Determine the position of an element within
2904 // the matched set of elements
2905 index: function( elem ) {
2906
2907 // No argument, return index in parent
2908 if ( !elem ) {
2909 return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
2910 }
2911
2912 // index in selector
2913 if ( typeof elem === "string" ) {
2914 return indexOf.call( jQuery( elem ), this[ 0 ] );
2915 }
2916
2917 // Locate the position of the desired element
2918 return indexOf.call( this,
2919
2920 // If it receives a jQuery object, the first element is used
2921 elem.jquery ? elem[ 0 ] : elem
2922 );
2923 },
2924
2925 add: function( selector, context ) {
2926 return this.pushStack(
2927 jQuery.unique(
2928 jQuery.merge( this.get(), jQuery( selector, context ) )
2929 )
2930 );
2931 },
2932
2933 addBack: function( selector ) {
2934 return this.add( selector == null ?
2935 this.prevObject : this.prevObject.filter(selector)
2936 );
2937 }
2938});
2939
2940function sibling( cur, dir ) {
2941 while ( (cur = cur[dir]) && cur.nodeType !== 1 ) {}
2942 return cur;
2943}
2944
2945jQuery.each({
2946 parent: function( elem ) {
2947 var parent = elem.parentNode;
2948 return parent && parent.nodeType !== 11 ? parent : null;
2949 },
2950 parents: function( elem ) {
2951 return jQuery.dir( elem, "parentNode" );
2952 },
2953 parentsUntil: function( elem, i, until ) {
2954 return jQuery.dir( elem, "parentNode", until );
2955 },
2956 next: function( elem ) {
2957 return sibling( elem, "nextSibling" );
2958 },
2959 prev: function( elem ) {
2960 return sibling( elem, "previousSibling" );
2961 },
2962 nextAll: function( elem ) {
2963 return jQuery.dir( elem, "nextSibling" );
2964 },
2965 prevAll: function( elem ) {
2966 return jQuery.dir( elem, "previousSibling" );
2967 },
2968 nextUntil: function( elem, i, until ) {
2969 return jQuery.dir( elem, "nextSibling", until );
2970 },
2971 prevUntil: function( elem, i, until ) {
2972 return jQuery.dir( elem, "previousSibling", until );
2973 },
2974 siblings: function( elem ) {
2975 return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
2976 },
2977 children: function( elem ) {
2978 return jQuery.sibling( elem.firstChild );
2979 },
2980 contents: function( elem ) {
2981 return elem.contentDocument || jQuery.merge( [], elem.childNodes );
2982 }
2983}, function( name, fn ) {
2984 jQuery.fn[ name ] = function( until, selector ) {
2985 var matched = jQuery.map( this, fn, until );
2986
2987 if ( name.slice( -5 ) !== "Until" ) {
2988 selector = until;
2989 }
2990
2991 if ( selector && typeof selector === "string" ) {
2992 matched = jQuery.filter( selector, matched );
2993 }
2994
2995 if ( this.length > 1 ) {
2996 // Remove duplicates
2997 if ( !guaranteedUnique[ name ] ) {
2998 jQuery.unique( matched );
2999 }
3000
3001 // Reverse order for parents* and prev-derivatives
3002 if ( rparentsprev.test( name ) ) {
3003 matched.reverse();
3004 }
3005 }
3006
3007 return this.pushStack( matched );
3008 };
3009});
3010var rnotwhite = (/\S+/g);
3011
3012
3013
3014// String to Object options format cache
3015var optionsCache = {};
3016
3017// Convert String-formatted options into Object-formatted ones and store in cache
3018function createOptions( options ) {
3019 var object = optionsCache[ options ] = {};
3020 jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
3021 object[ flag ] = true;
3022 });
3023 return object;
3024}
3025
3026/*
3027 * Create a callback list using the following parameters:
3028 *
3029 * options: an optional list of space-separated options that will change how
3030 * the callback list behaves or a more traditional option object
3031 *
3032 * By default a callback list will act like an event callback list and can be
3033 * "fired" multiple times.
3034 *
3035 * Possible options:
3036 *
3037 * once: will ensure the callback list can only be fired once (like a Deferred)
3038 *
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)
3042 *
3043 * unique: will ensure a callback can only be added once (no duplicate in the list)
3044 *
3045 * stopOnFalse: interrupt callings when a callback returns false
3046 *
3047 */
3048jQuery.Callbacks = function( options ) {
3049
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 );
3055
3056 var // Last fire value (for non-forgettable lists)
3057 memory,
3058 // Flag to know if list was already fired
3059 fired,
3060 // Flag to know if list is currently firing
3061 firing,
3062 // First callback to fire (used internally by add and fireWith)
3063 firingStart,
3064 // End of the loop when firing
3065 firingLength,
3066 // Index of currently firing callback (modified by remove if needed)
3067 firingIndex,
3068 // Actual callback list
3069 list = [],
3070 // Stack of fire calls for repeatable lists
3071 stack = !options.once && [],
3072 // Fire callbacks
3073 fire = function( data ) {
3074 memory = options.memory && data;
3075 fired = true;
3076 firingIndex = firingStart || 0;
3077 firingStart = 0;
3078 firingLength = list.length;
3079 firing = true;
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
3083 break;
3084 }
3085 }
3086 firing = false;
3087 if ( list ) {
3088 if ( stack ) {
3089 if ( stack.length ) {
3090 fire( stack.shift() );
3091 }
3092 } else if ( memory ) {
3093 list = [];
3094 } else {
3095 self.disable();
3096 }
3097 }
3098 },
3099 // Actual Callbacks object
3100 self = {
3101 // Add a callback or a collection of callbacks to the list
3102 add: function() {
3103 if ( 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 ) ) {
3111 list.push( arg );
3112 }
3113 } else if ( arg && arg.length && type !== "string" ) {
3114 // Inspect recursively
3115 add( arg );
3116 }
3117 });
3118 })( arguments );
3119 // Do we need to add the callbacks to the
3120 // current firing batch?
3121 if ( firing ) {
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;
3127 fire( memory );
3128 }
3129 }
3130 return this;
3131 },
3132 // Remove a callback from the list
3133 remove: function() {
3134 if ( list ) {
3135 jQuery.each( arguments, function( _, arg ) {
3136 var index;
3137 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
3138 list.splice( index, 1 );
3139 // Handle firing indexes
3140 if ( firing ) {
3141 if ( index <= firingLength ) {
3142 firingLength--;
3143 }
3144 if ( index <= firingIndex ) {
3145 firingIndex--;
3146 }
3147 }
3148 }
3149 });
3150 }
3151 return this;
3152 },
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 );
3157 },
3158 // Remove all callbacks from the list
3159 empty: function() {
3160 list = [];
3161 firingLength = 0;
3162 return this;
3163 },
3164 // Have the list do nothing anymore
3165 disable: function() {
3166 list = stack = memory = undefined;
3167 return this;
3168 },
3169 // Is it disabled?
3170 disabled: function() {
3171 return !list;
3172 },
3173 // Lock the list in its current state
3174 lock: function() {
3175 stack = undefined;
3176 if ( !memory ) {
3177 self.disable();
3178 }
3179 return this;
3180 },
3181 // Is it locked?
3182 locked: function() {
3183 return !stack;
3184 },
3185 // Call all callbacks with the given context and arguments
3186 fireWith: function( context, args ) {
3187 if ( list && ( !fired || stack ) ) {
3188 args = args || [];
3189 args = [ context, args.slice ? args.slice() : args ];
3190 if ( firing ) {
3191 stack.push( args );
3192 } else {
3193 fire( args );
3194 }
3195 }
3196 return this;
3197 },
3198 // Call all the callbacks with the given arguments
3199 fire: function() {
3200 self.fireWith( this, arguments );
3201 return this;
3202 },
3203 // To know if the callbacks have already been called at least once
3204 fired: function() {
3205 return !!fired;
3206 }
3207 };
3208
3209 return self;
3210};
3211
3212
3213jQuery.extend({
3214
3215 Deferred: function( func ) {
3216 var tuples = [
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") ]
3221 ],
3222 state = "pending",
3223 promise = {
3224 state: function() {
3225 return state;
3226 },
3227 always: function() {
3228 deferred.done( arguments ).fail( arguments );
3229 return this;
3230 },
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 ) ) {
3240 returned.promise()
3241 .done( newDefer.resolve )
3242 .fail( newDefer.reject )
3243 .progress( newDefer.notify );
3244 } else {
3245 newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
3246 }
3247 });
3248 });
3249 fns = null;
3250 }).promise();
3251 },
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;
3256 }
3257 },
3258 deferred = {};
3259
3260 // Keep pipe for back-compat
3261 promise.pipe = promise.then;
3262
3263 // Add list-specific methods
3264 jQuery.each( tuples, function( i, tuple ) {
3265 var list = tuple[ 2 ],
3266 stateString = tuple[ 3 ];
3267
3268 // promise[ done | fail | progress ] = list.add
3269 promise[ tuple[1] ] = list.add;
3270
3271 // Handle state
3272 if ( stateString ) {
3273 list.add(function() {
3274 // state = [ resolved | rejected ]
3275 state = stateString;
3276
3277 // [ reject_list | resolve_list ].disable; progress_list.lock
3278 }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
3279 }
3280
3281 // deferred[ resolve | reject | notify ]
3282 deferred[ tuple[0] ] = function() {
3283 deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
3284 return this;
3285 };
3286 deferred[ tuple[0] + "With" ] = list.fireWith;
3287 });
3288
3289 // Make the deferred a promise
3290 promise.promise( deferred );
3291
3292 // Call given func if any
3293 if ( func ) {
3294 func.call( deferred, deferred );
3295 }
3296
3297 // All done!
3298 return deferred;
3299 },
3300
3301 // Deferred helper
3302 when: function( subordinate /* , ..., subordinateN */ ) {
3303 var i = 0,
3304 resolveValues = slice.call( arguments ),
3305 length = resolveValues.length,
3306
3307 // the count of uncompleted subordinates
3308 remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
3309
3310 // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
3311 deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
3312
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 );
3322 }
3323 };
3324 },
3325
3326 progressValues, progressContexts, resolveContexts;
3327
3328 // add listeners to Deferred subordinates; treat others as resolved
3329 if ( length > 1 ) {
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 ) );
3339 } else {
3340 --remaining;
3341 }
3342 }
3343 }
3344
3345 // if we're not waiting on anything, resolve the master
3346 if ( !remaining ) {
3347 deferred.resolveWith( resolveContexts, resolveValues );
3348 }
3349
3350 return deferred.promise();
3351 }
3352});
3353
3354
3355// The deferred used on DOM ready
3356var readyList;
3357
3358jQuery.fn.ready = function( fn ) {
3359 // Add the callback
3360 jQuery.ready.promise().done( fn );
3361
3362 return this;
3363};
3364
3365jQuery.extend({
3366 // Is the DOM ready to be used? Set to true once it occurs.
3367 isReady: false,
3368
3369 // A counter to track how many items to wait for before
3370 // the ready event fires. See #6781
3371 readyWait: 1,
3372
3373 // Hold (or release) the ready event
3374 holdReady: function( hold ) {
3375 if ( hold ) {
3376 jQuery.readyWait++;
3377 } else {
3378 jQuery.ready( true );
3379 }
3380 },
3381
3382 // Handle when the DOM is ready
3383 ready: function( wait ) {
3384
3385 // Abort if there are pending holds or we're already ready
3386 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
3387 return;
3388 }
3389
3390 // Remember that the DOM is ready
3391 jQuery.isReady = true;
3392
3393 // If a normal DOM Ready event fired, decrement, and wait if need be
3394 if ( wait !== true && --jQuery.readyWait > 0 ) {
3395 return;
3396 }
3397
3398 // If there are functions bound, to execute
3399 readyList.resolveWith( document, [ jQuery ] );
3400
3401 // Trigger any bound ready events
3402 if ( jQuery.fn.triggerHandler ) {
3403 jQuery( document ).triggerHandler( "ready" );
3404 jQuery( document ).off( "ready" );
3405 }
3406 }
3407});
3408
3409/**
3410 * The ready event handler and self cleanup method
3411 */
3412function completed() {
3413 document.removeEventListener( "DOMContentLoaded", completed, false );
3414 window.removeEventListener( "load", completed, false );
3415 jQuery.ready();
3416}
3417
3418jQuery.ready.promise = function( obj ) {
3419 if ( !readyList ) {
3420
3421 readyList = jQuery.Deferred();
3422
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 );
3429
3430 } else {
3431
3432 // Use the handy event callback
3433 document.addEventListener( "DOMContentLoaded", completed, false );
3434
3435 // A fallback to window.onload, that will always work
3436 window.addEventListener( "load", completed, false );
3437 }
3438 }
3439 return readyList.promise( obj );
3440};
3441
3442// Kick off the DOM ready check even if the user does not
3443jQuery.ready.promise();
3444
3445
3446
3447
3448// Multifunctional method to get and set values of a collection
3449// The value/s can optionally be executed if it's a function
3450var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
3451 var i = 0,
3452 len = elems.length,
3453 bulk = key == null;
3454
3455 // Sets many values
3456 if ( jQuery.type( key ) === "object" ) {
3457 chainable = true;
3458 for ( i in key ) {
3459 jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
3460 }
3461
3462 // Sets one value
3463 } else if ( value !== undefined ) {
3464 chainable = true;
3465
3466 if ( !jQuery.isFunction( value ) ) {
3467 raw = true;
3468 }
3469
3470 if ( bulk ) {
3471 // Bulk operations run against the entire set
3472 if ( raw ) {
3473 fn.call( elems, value );
3474 fn = null;
3475
3476 // ...except when executing function values
3477 } else {
3478 bulk = fn;
3479 fn = function( elem, key, value ) {
3480 return bulk.call( jQuery( elem ), value );
3481 };
3482 }
3483 }
3484
3485 if ( fn ) {
3486 for ( ; i < len; i++ ) {
3487 fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
3488 }
3489 }
3490 }
3491
3492 return chainable ?
3493 elems :
3494
3495 // Gets
3496 bulk ?
3497 fn.call( elems ) :
3498 len ? fn( elems[0], key ) : emptyGet;
3499};
3500
3501
3502/**
3503 * Determines whether an object can have data
3504 */
3505jQuery.acceptData = function( owner ) {
3506 // Accepts only:
3507 // - Node
3508 // - Node.ELEMENT_NODE
3509 // - Node.DOCUMENT_NODE
3510 // - Object
3511 // - Any
3512 /* jshint -W018 */
3513 return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
3514};
3515
3516
3517function Data() {
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, {
3522 get: function() {
3523 return {};
3524 }
3525 });
3526
3527 this.expando = jQuery.expando + Math.random();
3528}
3529
3530Data.uid = 1;
3531Data.accepts = jQuery.acceptData;
3532
3533Data.prototype = {
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 ) ) {
3539 return 0;
3540 }
3541
3542 var descriptor = {},
3543 // Check if the owner object already has a cache key
3544 unlock = owner[ this.expando ];
3545
3546 // If not, create one
3547 if ( !unlock ) {
3548 unlock = Data.uid++;
3549
3550 // Secure it in a non-enumerable, non-writable property
3551 try {
3552 descriptor[ this.expando ] = { value: unlock };
3553 Object.defineProperties( owner, descriptor );
3554
3555 // Support: Android < 4
3556 // Fallback to a less secure definition
3557 } catch ( e ) {
3558 descriptor[ this.expando ] = unlock;
3559 jQuery.extend( owner, descriptor );
3560 }
3561 }
3562
3563 // Ensure the cache object
3564 if ( !this.cache[ unlock ] ) {
3565 this.cache[ unlock ] = {};
3566 }
3567
3568 return unlock;
3569 },
3570 set: function( owner, data, value ) {
3571 var prop,
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 ];
3577
3578 // Handle: [ owner, key, value ] args
3579 if ( typeof data === "string" ) {
3580 cache[ data ] = value;
3581
3582 // Handle: [ owner, { properties } ] args
3583 } else {
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
3588 } else {
3589 for ( prop in data ) {
3590 cache[ prop ] = data[ prop ];
3591 }
3592 }
3593 }
3594 return cache;
3595 },
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 ) ];
3602
3603 return key === undefined ?
3604 cache : cache[ key ];
3605 },
3606 access: function( owner, key, value ) {
3607 var stored;
3608 // In cases where either:
3609 //
3610 // 1. No key was specified
3611 // 2. A string key was specified, but no value provided
3612 //
3613 // Take the "read" path and allow the get method to determine
3614 // which value to return, respectively either:
3615 //
3616 // 1. The entire cache object
3617 // 2. The data stored at the key
3618 //
3619 if ( key === undefined ||
3620 ((key && typeof key === "string") && value === undefined) ) {
3621
3622 stored = this.get( owner, key );
3623
3624 return stored !== undefined ?
3625 stored : this.get( owner, jQuery.camelCase(key) );
3626 }
3627
3628 // [*]When the key is not a string, or both a key and value
3629 // are specified, set or extend (existing objects) with either:
3630 //
3631 // 1. An object of properties
3632 // 2. A key and value
3633 //
3634 this.set( owner, key, value );
3635
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;
3639 },
3640 remove: function( owner, key ) {
3641 var i, name, camel,
3642 unlock = this.key( owner ),
3643 cache = this.cache[ unlock ];
3644
3645 if ( key === undefined ) {
3646 this.cache[ unlock ] = {};
3647
3648 } else {
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 ) );
3658 } else {
3659 camel = jQuery.camelCase( key );
3660 // Try the string as a key before any manipulation
3661 if ( key in cache ) {
3662 name = [ key, camel ];
3663 } else {
3664 // If a key with the spaces exists, use it.
3665 // Otherwise, create an array by matching non-whitespace
3666 name = camel;
3667 name = name in cache ?
3668 [ name ] : ( name.match( rnotwhite ) || [] );
3669 }
3670 }
3671
3672 i = name.length;
3673 while ( i-- ) {
3674 delete cache[ name[ i ] ];
3675 }
3676 }
3677 },
3678 hasData: function( owner ) {
3679 return !jQuery.isEmptyObject(
3680 this.cache[ owner[ this.expando ] ] || {}
3681 );
3682 },
3683 discard: function( owner ) {
3684 if ( owner[ this.expando ] ) {
3685 delete this.cache[ owner[ this.expando ] ];
3686 }
3687 }
3688};
3689var data_priv = new Data();
3690
3691var data_user = new Data();
3692
3693
3694
3695/*
3696 Implementation Summary
3697
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
3705*/
3706var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
3707 rmultiDash = /([A-Z])/g;
3708
3709function dataAttr( elem, key, data ) {
3710 var name;
3711
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 );
3717
3718 if ( typeof data === "string" ) {
3719 try {
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 ) :
3726 data;
3727 } catch( e ) {}
3728
3729 // Make sure we set the data so it isn't changed later
3730 data_user.set( elem, key, data );
3731 } else {
3732 data = undefined;
3733 }
3734 }
3735 return data;
3736}
3737
3738jQuery.extend({
3739 hasData: function( elem ) {
3740 return data_user.hasData( elem ) || data_priv.hasData( elem );
3741 },
3742
3743 data: function( elem, name, data ) {
3744 return data_user.access( elem, name, data );
3745 },
3746
3747 removeData: function( elem, name ) {
3748 data_user.remove( elem, name );
3749 },
3750
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 );
3755 },
3756
3757 _removeData: function( elem, name ) {
3758 data_priv.remove( elem, name );
3759 }
3760});
3761
3762jQuery.fn.extend({
3763 data: function( key, value ) {
3764 var i, name, data,
3765 elem = this[ 0 ],
3766 attrs = elem && elem.attributes;
3767
3768 // Gets all values
3769 if ( key === undefined ) {
3770 if ( this.length ) {
3771 data = data_user.get( elem );
3772
3773 if ( elem.nodeType === 1 && !data_priv.get( elem, "hasDataAttrs" ) ) {
3774 i = attrs.length;
3775 while ( i-- ) {
3776
3777 // Support: IE11+
3778 // The attrs elements can be null (#14894)
3779 if ( attrs[ i ] ) {
3780 name = attrs[ i ].name;
3781 if ( name.indexOf( "data-" ) === 0 ) {
3782 name = jQuery.camelCase( name.slice(5) );
3783 dataAttr( elem, name, data[ name ] );
3784 }
3785 }
3786 }
3787 data_priv.set( elem, "hasDataAttrs", true );
3788 }
3789 }
3790
3791 return data;
3792 }
3793
3794 // Sets multiple values
3795 if ( typeof key === "object" ) {
3796 return this.each(function() {
3797 data_user.set( this, key );
3798 });
3799 }
3800
3801 return access( this, function( value ) {
3802 var data,
3803 camelKey = jQuery.camelCase( key );
3804
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 ) {
3815 return data;
3816 }
3817
3818 // Attempt to get data from the cache
3819 // with the key camelized
3820 data = data_user.get( elem, camelKey );
3821 if ( data !== undefined ) {
3822 return data;
3823 }
3824
3825 // Attempt to "discover" the data in
3826 // HTML5 custom data-* attrs
3827 data = dataAttr( elem, camelKey, undefined );
3828 if ( data !== undefined ) {
3829 return data;
3830 }
3831
3832 // We tried really hard, but the data doesn't exist.
3833 return;
3834 }
3835
3836 // Set the data...
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 );
3841
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 );
3846
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 );
3852 }
3853 });
3854 }, null, value, arguments.length > 1, null, true );
3855 },
3856
3857 removeData: function( key ) {
3858 return this.each(function() {
3859 data_user.remove( this, key );
3860 });
3861 }
3862});
3863
3864
3865jQuery.extend({
3866 queue: function( elem, type, data ) {
3867 var queue;
3868
3869 if ( elem ) {
3870 type = ( type || "fx" ) + "queue";
3871 queue = data_priv.get( elem, type );
3872
3873 // Speed up dequeue by getting out quickly if this is just a lookup
3874 if ( data ) {
3875 if ( !queue || jQuery.isArray( data ) ) {
3876 queue = data_priv.access( elem, type, jQuery.makeArray(data) );
3877 } else {
3878 queue.push( data );
3879 }
3880 }
3881 return queue || [];
3882 }
3883 },
3884
3885 dequeue: function( elem, type ) {
3886 type = type || "fx";
3887
3888 var queue = jQuery.queue( elem, type ),
3889 startLength = queue.length,
3890 fn = queue.shift(),
3891 hooks = jQuery._queueHooks( elem, type ),
3892 next = function() {
3893 jQuery.dequeue( elem, type );
3894 };
3895
3896 // If the fx queue is dequeued, always remove the progress sentinel
3897 if ( fn === "inprogress" ) {
3898 fn = queue.shift();
3899 startLength--;
3900 }
3901
3902 if ( fn ) {
3903
3904 // Add a progress sentinel to prevent the fx queue from being
3905 // automatically dequeued
3906 if ( type === "fx" ) {
3907 queue.unshift( "inprogress" );
3908 }
3909
3910 // clear up the last queue stop function
3911 delete hooks.stop;
3912 fn.call( elem, next, hooks );
3913 }
3914
3915 if ( !startLength && hooks ) {
3916 hooks.empty.fire();
3917 }
3918 },
3919
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 ] );
3926 })
3927 });
3928 }
3929});
3930
3931jQuery.fn.extend({
3932 queue: function( type, data ) {
3933 var setter = 2;
3934
3935 if ( typeof type !== "string" ) {
3936 data = type;
3937 type = "fx";
3938 setter--;
3939 }
3940
3941 if ( arguments.length < setter ) {
3942 return jQuery.queue( this[0], type );
3943 }
3944
3945 return data === undefined ?
3946 this :
3947 this.each(function() {
3948 var queue = jQuery.queue( this, type, data );
3949
3950 // ensure a hooks for this queue
3951 jQuery._queueHooks( this, type );
3952
3953 if ( type === "fx" && queue[0] !== "inprogress" ) {
3954 jQuery.dequeue( this, type );
3955 }
3956 });
3957 },
3958 dequeue: function( type ) {
3959 return this.each(function() {
3960 jQuery.dequeue( this, type );
3961 });
3962 },
3963 clearQueue: function( type ) {
3964 return this.queue( type || "fx", [] );
3965 },
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 ) {
3969 var tmp,
3970 count = 1,
3971 defer = jQuery.Deferred(),
3972 elements = this,
3973 i = this.length,
3974 resolve = function() {
3975 if ( !( --count ) ) {
3976 defer.resolveWith( elements, [ elements ] );
3977 }
3978 };
3979
3980 if ( typeof type !== "string" ) {
3981 obj = type;
3982 type = undefined;
3983 }
3984 type = type || "fx";
3985
3986 while ( i-- ) {
3987 tmp = data_priv.get( elements[ i ], type + "queueHooks" );
3988 if ( tmp && tmp.empty ) {
3989 count++;
3990 tmp.empty.add( resolve );
3991 }
3992 }
3993 resolve();
3994 return defer.promise( obj );
3995 }
3996});
3997var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source;
3998
3999var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
4000
4001var isHidden = function( elem, el ) {
4002 // isHidden might be called from jQuery#filter function;
4003 // in that case, element will be second argument
4004 elem = el || elem;
4005 return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
4006 };
4007
4008var rcheckableType = (/^(?:checkbox|radio)$/i);
4009
4010
4011
4012(function() {
4013 var fragment = document.createDocumentFragment(),
4014 div = fragment.appendChild( document.createElement( "div" ) ),
4015 input = document.createElement( "input" );
4016
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" );
4023
4024 div.appendChild( input );
4025
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;
4029
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;
4034})();
4035var strundefined = typeof undefined;
4036
4037
4038
4039support.focusinBubbles = "onfocusin" in window;
4040
4041
4042var
4043 rkeyEvent = /^key/,
4044 rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/,
4045 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
4046 rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
4047
4048function returnTrue() {
4049 return true;
4050}
4051
4052function returnFalse() {
4053 return false;
4054}
4055
4056function safeActiveElement() {
4057 try {
4058 return document.activeElement;
4059 } catch ( err ) { }
4060}
4061
4062/*
4063 * Helper functions for managing events -- not part of the public interface.
4064 * Props to Dean Edwards' addEvent library for many of the ideas.
4065 */
4066jQuery.event = {
4067
4068 global: {},
4069
4070 add: function( elem, types, handler, data, selector ) {
4071
4072 var handleObjIn, eventHandle, tmp,
4073 events, t, handleObj,
4074 special, handlers, type, namespaces, origType,
4075 elemData = data_priv.get( elem );
4076
4077 // Don't attach events to noData or text/comment nodes (but allow plain objects)
4078 if ( !elemData ) {
4079 return;
4080 }
4081
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;
4087 }
4088
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++;
4092 }
4093
4094 // Init the element's event structure and main handler, if this is the first
4095 if ( !(events = elemData.events) ) {
4096 events = elemData.events = {};
4097 }
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;
4104 };
4105 }
4106
4107 // Handle multiple events separated by a space
4108 types = ( types || "" ).match( rnotwhite ) || [ "" ];
4109 t = types.length;
4110 while ( t-- ) {
4111 tmp = rtypenamespace.exec( types[t] ) || [];
4112 type = origType = tmp[1];
4113 namespaces = ( tmp[2] || "" ).split( "." ).sort();
4114
4115 // There *must* be a type, no attaching namespace-only handlers
4116 if ( !type ) {
4117 continue;
4118 }
4119
4120 // If event changes its type, use the special event handlers for the changed type
4121 special = jQuery.event.special[ type ] || {};
4122
4123 // If selector defined, determine special event api type, otherwise given type
4124 type = ( selector ? special.delegateType : special.bindType ) || type;
4125
4126 // Update special based on newly reset type
4127 special = jQuery.event.special[ type ] || {};
4128
4129 // handleObj is passed to all event handlers
4130 handleObj = jQuery.extend({
4131 type: type,
4132 origType: origType,
4133 data: data,
4134 handler: handler,
4135 guid: handler.guid,
4136 selector: selector,
4137 needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
4138 namespace: namespaces.join(".")
4139 }, handleObjIn );
4140
4141 // Init the event handler queue if we're the first
4142 if ( !(handlers = events[ type ]) ) {
4143 handlers = events[ type ] = [];
4144 handlers.delegateCount = 0;
4145
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 );
4150 }
4151 }
4152 }
4153
4154 if ( special.add ) {
4155 special.add.call( elem, handleObj );
4156
4157 if ( !handleObj.handler.guid ) {
4158 handleObj.handler.guid = handler.guid;
4159 }
4160 }
4161
4162 // Add to the element's handler list, delegates in front
4163 if ( selector ) {
4164 handlers.splice( handlers.delegateCount++, 0, handleObj );
4165 } else {
4166 handlers.push( handleObj );
4167 }
4168
4169 // Keep track of which events have ever been used, for event optimization
4170 jQuery.event.global[ type ] = true;
4171 }
4172
4173 },
4174
4175 // Detach an event or set of events from an element
4176 remove: function( elem, types, handler, selector, mappedTypes ) {
4177
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 );
4182
4183 if ( !elemData || !(events = elemData.events) ) {
4184 return;
4185 }
4186
4187 // Once for each type.namespace in types; type may be omitted
4188 types = ( types || "" ).match( rnotwhite ) || [ "" ];
4189 t = types.length;
4190 while ( t-- ) {
4191 tmp = rtypenamespace.exec( types[t] ) || [];
4192 type = origType = tmp[1];
4193 namespaces = ( tmp[2] || "" ).split( "." ).sort();
4194
4195 // Unbind all events (on this namespace, if provided) for the element
4196 if ( !type ) {
4197 for ( type in events ) {
4198 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
4199 }
4200 continue;
4201 }
4202
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("\\.(?:.*\\.|)") + "(\\.|$)" );
4207
4208 // Remove matching events
4209 origCount = j = handlers.length;
4210 while ( j-- ) {
4211 handleObj = handlers[ j ];
4212
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 );
4218
4219 if ( handleObj.selector ) {
4220 handlers.delegateCount--;
4221 }
4222 if ( special.remove ) {
4223 special.remove.call( elem, handleObj );
4224 }
4225 }
4226 }
4227
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 );
4233 }
4234
4235 delete events[ type ];
4236 }
4237 }
4238
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" );
4243 }
4244 },
4245
4246 trigger: function( event, data, elem, onlyHandlers ) {
4247
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(".") : [];
4252
4253 cur = tmp = elem = elem || document;
4254
4255 // Don't do events on text and comment nodes
4256 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
4257 return;
4258 }
4259
4260 // focus/blur morphs to focusin/out; ensure we're not firing them right now
4261 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
4262 return;
4263 }
4264
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();
4269 namespaces.sort();
4270 }
4271 ontype = type.indexOf(":") < 0 && "on" + type;
4272
4273 // Caller can pass in a jQuery.Event object, Object, or just an event type string
4274 event = event[ jQuery.expando ] ?
4275 event :
4276 new jQuery.Event( type, typeof event === "object" && event );
4277
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("\\.(?:.*\\.|)") + "(\\.|$)" ) :
4283 null;
4284
4285 // Clean up the event in case it is being reused
4286 event.result = undefined;
4287 if ( !event.target ) {
4288 event.target = elem;
4289 }
4290
4291 // Clone any incoming data and prepend the event, creating the handler arg list
4292 data = data == null ?
4293 [ event ] :
4294 jQuery.makeArray( data, [ event ] );
4295
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 ) {
4299 return;
4300 }
4301
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 ) ) {
4305
4306 bubbleType = special.delegateType || type;
4307 if ( !rfocusMorph.test( bubbleType + type ) ) {
4308 cur = cur.parentNode;
4309 }
4310 for ( ; cur; cur = cur.parentNode ) {
4311 eventPath.push( cur );
4312 tmp = cur;
4313 }
4314
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 );
4318 }
4319 }
4320
4321 // Fire handlers on the event path
4322 i = 0;
4323 while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
4324
4325 event.type = i > 1 ?
4326 bubbleType :
4327 special.bindType || type;
4328
4329 // jQuery handler
4330 handle = ( data_priv.get( cur, "events" ) || {} )[ event.type ] && data_priv.get( cur, "handle" );
4331 if ( handle ) {
4332 handle.apply( cur, data );
4333 }
4334
4335 // Native handler
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();
4341 }
4342 }
4343 }
4344 event.type = type;
4345
4346 // If nobody prevented the default action, do it now
4347 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
4348
4349 if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
4350 jQuery.acceptData( elem ) ) {
4351
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 ) ) {
4355
4356 // Don't re-trigger an onFOO event when we call its FOO() method
4357 tmp = elem[ ontype ];
4358
4359 if ( tmp ) {
4360 elem[ ontype ] = null;
4361 }
4362
4363 // Prevent re-triggering of the same event, since we already bubbled it above
4364 jQuery.event.triggered = type;
4365 elem[ type ]();
4366 jQuery.event.triggered = undefined;
4367
4368 if ( tmp ) {
4369 elem[ ontype ] = tmp;
4370 }
4371 }
4372 }
4373 }
4374
4375 return event.result;
4376 },
4377
4378 dispatch: function( event ) {
4379
4380 // Make a writable jQuery.Event from the native event object
4381 event = jQuery.event.fix( event );
4382
4383 var i, j, ret, matched, handleObj,
4384 handlerQueue = [],
4385 args = slice.call( arguments ),
4386 handlers = ( data_priv.get( this, "events" ) || {} )[ event.type ] || [],
4387 special = jQuery.event.special[ event.type ] || {};
4388
4389 // Use the fix-ed jQuery.Event rather than the (read-only) native event
4390 args[0] = event;
4391 event.delegateTarget = this;
4392
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 ) {
4395 return;
4396 }
4397
4398 // Determine handlers
4399 handlerQueue = jQuery.event.handlers.call( this, event, handlers );
4400
4401 // Run delegates first; they may want to stop propagation beneath us
4402 i = 0;
4403 while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
4404 event.currentTarget = matched.elem;
4405
4406 j = 0;
4407 while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
4408
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 ) ) {
4412
4413 event.handleObj = handleObj;
4414 event.data = handleObj.data;
4415
4416 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
4417 .apply( matched.elem, args );
4418
4419 if ( ret !== undefined ) {
4420 if ( (event.result = ret) === false ) {
4421 event.preventDefault();
4422 event.stopPropagation();
4423 }
4424 }
4425 }
4426 }
4427 }
4428
4429 // Call the postDispatch hook for the mapped type
4430 if ( special.postDispatch ) {
4431 special.postDispatch.call( this, event );
4432 }
4433
4434 return event.result;
4435 },
4436
4437 handlers: function( event, handlers ) {
4438 var i, matches, sel, handleObj,
4439 handlerQueue = [],
4440 delegateCount = handlers.delegateCount,
4441 cur = event.target;
4442
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") ) {
4447
4448 for ( ; cur !== this; cur = cur.parentNode || this ) {
4449
4450 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
4451 if ( cur.disabled !== true || event.type !== "click" ) {
4452 matches = [];
4453 for ( i = 0; i < delegateCount; i++ ) {
4454 handleObj = handlers[ i ];
4455
4456 // Don't conflict with Object.prototype properties (#13203)
4457 sel = handleObj.selector + " ";
4458
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;
4463 }
4464 if ( matches[ sel ] ) {
4465 matches.push( handleObj );
4466 }
4467 }
4468 if ( matches.length ) {
4469 handlerQueue.push({ elem: cur, handlers: matches });
4470 }
4471 }
4472 }
4473 }
4474
4475 // Add the remaining (directly-bound) handlers
4476 if ( delegateCount < handlers.length ) {
4477 handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
4478 }
4479
4480 return handlerQueue;
4481 },
4482
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(" "),
4485
4486 fixHooks: {},
4487
4488 keyHooks: {
4489 props: "char charCode key keyCode".split(" "),
4490 filter: function( event, original ) {
4491
4492 // Add which for key events
4493 if ( event.which == null ) {
4494 event.which = original.charCode != null ? original.charCode : original.keyCode;
4495 }
4496
4497 return event;
4498 }
4499 },
4500
4501 mouseHooks: {
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;
4506
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;
4512
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 );
4515 }
4516
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 ) ) );
4521 }
4522
4523 return event;
4524 }
4525 },
4526
4527 fix: function( event ) {
4528 if ( event[ jQuery.expando ] ) {
4529 return event;
4530 }
4531
4532 // Create a writable copy of the event object and normalize some properties
4533 var i, prop, copy,
4534 type = event.type,
4535 originalEvent = event,
4536 fixHook = this.fixHooks[ type ];
4537
4538 if ( !fixHook ) {
4539 this.fixHooks[ type ] = fixHook =
4540 rmouseEvent.test( type ) ? this.mouseHooks :
4541 rkeyEvent.test( type ) ? this.keyHooks :
4542 {};
4543 }
4544 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
4545
4546 event = new jQuery.Event( originalEvent );
4547
4548 i = copy.length;
4549 while ( i-- ) {
4550 prop = copy[ i ];
4551 event[ prop ] = originalEvent[ prop ];
4552 }
4553
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;
4558 }
4559
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;
4564 }
4565
4566 return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
4567 },
4568
4569 special: {
4570 load: {
4571 // Prevent triggered image.load events from bubbling to window.load
4572 noBubble: true
4573 },
4574 focus: {
4575 // Fire native event if possible so blur/focus sequence is correct
4576 trigger: function() {
4577 if ( this !== safeActiveElement() && this.focus ) {
4578 this.focus();
4579 return false;
4580 }
4581 },
4582 delegateType: "focusin"
4583 },
4584 blur: {
4585 trigger: function() {
4586 if ( this === safeActiveElement() && this.blur ) {
4587 this.blur();
4588 return false;
4589 }
4590 },
4591 delegateType: "focusout"
4592 },
4593 click: {
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" ) ) {
4597 this.click();
4598 return false;
4599 }
4600 },
4601
4602 // For cross-browser consistency, don't fire native .click() on links
4603 _default: function( event ) {
4604 return jQuery.nodeName( event.target, "a" );
4605 }
4606 },
4607
4608 beforeunload: {
4609 postDispatch: function( event ) {
4610
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;
4615 }
4616 }
4617 }
4618 },
4619
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(
4625 new jQuery.Event(),
4626 event,
4627 {
4628 type: type,
4629 isSimulated: true,
4630 originalEvent: {}
4631 }
4632 );
4633 if ( bubble ) {
4634 jQuery.event.trigger( e, null, elem );
4635 } else {
4636 jQuery.event.dispatch.call( elem, e );
4637 }
4638 if ( e.isDefaultPrevented() ) {
4639 event.preventDefault();
4640 }
4641 }
4642};
4643
4644jQuery.removeEvent = function( elem, type, handle ) {
4645 if ( elem.removeEventListener ) {
4646 elem.removeEventListener( type, handle, false );
4647 }
4648};
4649
4650jQuery.Event = function( src, props ) {
4651 // Allow instantiation without the 'new' keyword
4652 if ( !(this instanceof jQuery.Event) ) {
4653 return new jQuery.Event( src, props );
4654 }
4655
4656 // Event object
4657 if ( src && src.type ) {
4658 this.originalEvent = src;
4659 this.type = src.type;
4660
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 ?
4667 returnTrue :
4668 returnFalse;
4669
4670 // Event type
4671 } else {
4672 this.type = src;
4673 }
4674
4675 // Put explicitly provided properties onto the event object
4676 if ( props ) {
4677 jQuery.extend( this, props );
4678 }
4679
4680 // Create a timestamp if incoming event doesn't have one
4681 this.timeStamp = src && src.timeStamp || jQuery.now();
4682
4683 // Mark it as fixed
4684 this[ jQuery.expando ] = true;
4685};
4686
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
4689jQuery.Event.prototype = {
4690 isDefaultPrevented: returnFalse,
4691 isPropagationStopped: returnFalse,
4692 isImmediatePropagationStopped: returnFalse,
4693
4694 preventDefault: function() {
4695 var e = this.originalEvent;
4696
4697 this.isDefaultPrevented = returnTrue;
4698
4699 if ( e && e.preventDefault ) {
4700 e.preventDefault();
4701 }
4702 },
4703 stopPropagation: function() {
4704 var e = this.originalEvent;
4705
4706 this.isPropagationStopped = returnTrue;
4707
4708 if ( e && e.stopPropagation ) {
4709 e.stopPropagation();
4710 }
4711 },
4712 stopImmediatePropagation: function() {
4713 var e = this.originalEvent;
4714
4715 this.isImmediatePropagationStopped = returnTrue;
4716
4717 if ( e && e.stopImmediatePropagation ) {
4718 e.stopImmediatePropagation();
4719 }
4720
4721 this.stopPropagation();
4722 }
4723};
4724
4725// Create mouseenter/leave events using mouseover/out and event-time checks
4726// Support: Chrome 15+
4727jQuery.each({
4728 mouseenter: "mouseover",
4729 mouseleave: "mouseout",
4730 pointerenter: "pointerover",
4731 pointerleave: "pointerout"
4732}, function( orig, fix ) {
4733 jQuery.event.special[ orig ] = {
4734 delegateType: fix,
4735 bindType: fix,
4736
4737 handle: function( event ) {
4738 var ret,
4739 target = this,
4740 related = event.relatedTarget,
4741 handleObj = event.handleObj;
4742
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 );
4748 event.type = fix;
4749 }
4750 return ret;
4751 }
4752 };
4753});
4754
4755// Create "bubbling" focus and blur events
4756// Support: Firefox, Chrome, Safari
4757if ( !support.focusinBubbles ) {
4758 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
4759
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 );
4763 };
4764
4765 jQuery.event.special[ fix ] = {
4766 setup: function() {
4767 var doc = this.ownerDocument || this,
4768 attaches = data_priv.access( doc, fix );
4769
4770 if ( !attaches ) {
4771 doc.addEventListener( orig, handler, true );
4772 }
4773 data_priv.access( doc, fix, ( attaches || 0 ) + 1 );
4774 },
4775 teardown: function() {
4776 var doc = this.ownerDocument || this,
4777 attaches = data_priv.access( doc, fix ) - 1;
4778
4779 if ( !attaches ) {
4780 doc.removeEventListener( orig, handler, true );
4781 data_priv.remove( doc, fix );
4782
4783 } else {
4784 data_priv.access( doc, fix, attaches );
4785 }
4786 }
4787 };
4788 });
4789}
4790
4791jQuery.fn.extend({
4792
4793 on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
4794 var origFn, type;
4795
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;
4803 }
4804 for ( type in types ) {
4805 this.on( type, selector, data, types[ type ], one );
4806 }
4807 return this;
4808 }
4809
4810 if ( data == null && fn == null ) {
4811 // ( types, fn )
4812 fn = selector;
4813 data = selector = undefined;
4814 } else if ( fn == null ) {
4815 if ( typeof selector === "string" ) {
4816 // ( types, selector, fn )
4817 fn = data;
4818 data = undefined;
4819 } else {
4820 // ( types, data, fn )
4821 fn = data;
4822 data = selector;
4823 selector = undefined;
4824 }
4825 }
4826 if ( fn === false ) {
4827 fn = returnFalse;
4828 } else if ( !fn ) {
4829 return this;
4830 }
4831
4832 if ( one === 1 ) {
4833 origFn = fn;
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 );
4838 };
4839 // Use same guid so caller can remove using origFn
4840 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
4841 }
4842 return this.each( function() {
4843 jQuery.event.add( this, types, fn, data, selector );
4844 });
4845 },
4846 one: function( types, selector, data, fn ) {
4847 return this.on( types, selector, data, fn, 1 );
4848 },
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,
4856 handleObj.selector,
4857 handleObj.handler
4858 );
4859 return this;
4860 }
4861 if ( typeof types === "object" ) {
4862 // ( types-object [, selector] )
4863 for ( type in types ) {
4864 this.off( type, selector, types[ type ] );
4865 }
4866 return this;
4867 }
4868 if ( selector === false || typeof selector === "function" ) {
4869 // ( types [, fn] )
4870 fn = selector;
4871 selector = undefined;
4872 }
4873 if ( fn === false ) {
4874 fn = returnFalse;
4875 }
4876 return this.each(function() {
4877 jQuery.event.remove( this, types, fn, selector );
4878 });
4879 },
4880
4881 trigger: function( type, data ) {
4882 return this.each(function() {
4883 jQuery.event.trigger( type, data, this );
4884 });
4885 },
4886 triggerHandler: function( type, data ) {
4887 var elem = this[0];
4888 if ( elem ) {
4889 return jQuery.event.trigger( type, data, elem, true );
4890 }
4891 }
4892});
4893
4894
4895var
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,
4905
4906 // We have to close these tags to support XHTML (#13200)
4907 wrapMap = {
4908
4909 // Support: IE 9
4910 option: [ 1, "<select multiple='multiple'>", "</select>" ],
4911
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>" ],
4916
4917 _default: [ 0, "", "" ]
4918 };
4919
4920// Support: IE 9
4921wrapMap.optgroup = wrapMap.option;
4922
4923wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
4924wrapMap.th = wrapMap.td;
4925
4926// Support: 1.x compatibility
4927// Manipulating tables requires a tbody
4928function manipulationTarget( elem, content ) {
4929 return jQuery.nodeName( elem, "table" ) &&
4930 jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ?
4931
4932 elem.getElementsByTagName("tbody")[0] ||
4933 elem.appendChild( elem.ownerDocument.createElement("tbody") ) :
4934 elem;
4935}
4936
4937// Replace/restore the type attribute of script elements for safe DOM manipulation
4938function disableScript( elem ) {
4939 elem.type = (elem.getAttribute("type") !== null) + "/" + elem.type;
4940 return elem;
4941}
4942function restoreScript( elem ) {
4943 var match = rscriptTypeMasked.exec( elem.type );
4944
4945 if ( match ) {
4946 elem.type = match[ 1 ];
4947 } else {
4948 elem.removeAttribute("type");
4949 }
4950
4951 return elem;
4952}
4953
4954// Mark scripts as having already been evaluated
4955function setGlobalEval( elems, refElements ) {
4956 var i = 0,
4957 l = elems.length;
4958
4959 for ( ; i < l; i++ ) {
4960 data_priv.set(
4961 elems[ i ], "globalEval", !refElements || data_priv.get( refElements[ i ], "globalEval" )
4962 );
4963 }
4964}
4965
4966function cloneCopyEvent( src, dest ) {
4967 var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
4968
4969 if ( dest.nodeType !== 1 ) {
4970 return;
4971 }
4972
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;
4978
4979 if ( events ) {
4980 delete pdataCur.handle;
4981 pdataCur.events = {};
4982
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 ] );
4986 }
4987 }
4988 }
4989 }
4990
4991 // 2. Copy user data
4992 if ( data_user.hasData( src ) ) {
4993 udataOld = data_user.access( src );
4994 udataCur = jQuery.extend( {}, udataOld );
4995
4996 data_user.set( dest, udataCur );
4997 }
4998}
4999
5000function getAll( context, tag ) {
5001 var ret = context.getElementsByTagName ? context.getElementsByTagName( tag || "*" ) :
5002 context.querySelectorAll ? context.querySelectorAll( tag || "*" ) :
5003 [];
5004
5005 return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
5006 jQuery.merge( [ context ], ret ) :
5007 ret;
5008}
5009
5010// Support: IE >= 9
5011function fixInput( src, dest ) {
5012 var nodeName = dest.nodeName.toLowerCase();
5013
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;
5017
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;
5021 }
5022}
5023
5024jQuery.extend({
5025 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
5026 var i, l, srcElements, destElements,
5027 clone = elem.cloneNode( true ),
5028 inPage = jQuery.contains( elem.ownerDocument, elem );
5029
5030 // Support: IE >= 9
5031 // Fix Cloning issues
5032 if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
5033 !jQuery.isXMLDoc( elem ) ) {
5034
5035 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
5036 destElements = getAll( clone );
5037 srcElements = getAll( elem );
5038
5039 for ( i = 0, l = srcElements.length; i < l; i++ ) {
5040 fixInput( srcElements[ i ], destElements[ i ] );
5041 }
5042 }
5043
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 );
5049
5050 for ( i = 0, l = srcElements.length; i < l; i++ ) {
5051 cloneCopyEvent( srcElements[ i ], destElements[ i ] );
5052 }
5053 } else {
5054 cloneCopyEvent( elem, clone );
5055 }
5056 }
5057
5058 // Preserve script evaluation history
5059 destElements = getAll( clone, "script" );
5060 if ( destElements.length > 0 ) {
5061 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
5062 }
5063
5064 // Return the cloned set
5065 return clone;
5066 },
5067
5068 buildFragment: function( elems, context, scripts, selection ) {
5069 var elem, tmp, tag, wrap, contains, j,
5070 fragment = context.createDocumentFragment(),
5071 nodes = [],
5072 i = 0,
5073 l = elems.length;
5074
5075 for ( ; i < l; i++ ) {
5076 elem = elems[ i ];
5077
5078 if ( elem || elem === 0 ) {
5079
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 );
5085
5086 // Convert non-html into a text node
5087 } else if ( !rhtml.test( elem ) ) {
5088 nodes.push( context.createTextNode( elem ) );
5089
5090 // Convert html into DOM nodes
5091 } else {
5092 tmp = tmp || fragment.appendChild( context.createElement("div") );
5093
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 ];
5098
5099 // Descend through wrappers to the right content
5100 j = wrap[ 0 ];
5101 while ( j-- ) {
5102 tmp = tmp.lastChild;
5103 }
5104
5105 // Support: QtWebKit
5106 // jQuery.merge because push.apply(_, arraylike) throws
5107 jQuery.merge( nodes, tmp.childNodes );
5108
5109 // Remember the top-level container
5110 tmp = fragment.firstChild;
5111
5112 // Fixes #12346
5113 // Support: Webkit, IE
5114 tmp.textContent = "";
5115 }
5116 }
5117 }
5118
5119 // Remove wrapper from fragment
5120 fragment.textContent = "";
5121
5122 i = 0;
5123 while ( (elem = nodes[ i++ ]) ) {
5124
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 ) {
5128 continue;
5129 }
5130
5131 contains = jQuery.contains( elem.ownerDocument, elem );
5132
5133 // Append to fragment
5134 tmp = getAll( fragment.appendChild( elem ), "script" );
5135
5136 // Preserve script evaluation history
5137 if ( contains ) {
5138 setGlobalEval( tmp );
5139 }
5140
5141 // Capture executables
5142 if ( scripts ) {
5143 j = 0;
5144 while ( (elem = tmp[ j++ ]) ) {
5145 if ( rscriptType.test( elem.type || "" ) ) {
5146 scripts.push( elem );
5147 }
5148 }
5149 }
5150 }
5151
5152 return fragment;
5153 },
5154
5155 cleanData: function( elems ) {
5156 var data, elem, type, key,
5157 special = jQuery.event.special,
5158 i = 0;
5159
5160 for ( ; (elem = elems[ i ]) !== undefined; i++ ) {
5161 if ( jQuery.acceptData( elem ) ) {
5162 key = elem[ data_priv.expando ];
5163
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 );
5169
5170 // This is a shortcut to avoid jQuery.event.remove's overhead
5171 } else {
5172 jQuery.removeEvent( elem, type, data.handle );
5173 }
5174 }
5175 }
5176 if ( data_priv.cache[ key ] ) {
5177 // Discard any remaining `private` data
5178 delete data_priv.cache[ key ];
5179 }
5180 }
5181 }
5182 // Discard any remaining `user` data
5183 delete data_user.cache[ elem[ data_user.expando ] ];
5184 }
5185 }
5186});
5187
5188jQuery.fn.extend({
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;
5196 }
5197 });
5198 }, null, value, arguments.length );
5199 },
5200
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 );
5206 }
5207 });
5208 },
5209
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 );
5215 }
5216 });
5217 },
5218
5219 before: function() {
5220 return this.domManip( arguments, function( elem ) {
5221 if ( this.parentNode ) {
5222 this.parentNode.insertBefore( elem, this );
5223 }
5224 });
5225 },
5226
5227 after: function() {
5228 return this.domManip( arguments, function( elem ) {
5229 if ( this.parentNode ) {
5230 this.parentNode.insertBefore( elem, this.nextSibling );
5231 }
5232 });
5233 },
5234
5235 remove: function( selector, keepData /* Internal Use Only */ ) {
5236 var elem,
5237 elems = selector ? jQuery.filter( selector, this ) : this,
5238 i = 0;
5239
5240 for ( ; (elem = elems[i]) != null; i++ ) {
5241 if ( !keepData && elem.nodeType === 1 ) {
5242 jQuery.cleanData( getAll( elem ) );
5243 }
5244
5245 if ( elem.parentNode ) {
5246 if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
5247 setGlobalEval( getAll( elem, "script" ) );
5248 }
5249 elem.parentNode.removeChild( elem );
5250 }
5251 }
5252
5253 return this;
5254 },
5255
5256 empty: function() {
5257 var elem,
5258 i = 0;
5259
5260 for ( ; (elem = this[i]) != null; i++ ) {
5261 if ( elem.nodeType === 1 ) {
5262
5263 // Prevent memory leaks
5264 jQuery.cleanData( getAll( elem, false ) );
5265
5266 // Remove any remaining nodes
5267 elem.textContent = "";
5268 }
5269 }
5270
5271 return this;
5272 },
5273
5274 clone: function( dataAndEvents, deepDataAndEvents ) {
5275 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
5276 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
5277
5278 return this.map(function() {
5279 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
5280 });
5281 },
5282
5283 html: function( value ) {
5284 return access( this, function( value ) {
5285 var elem = this[ 0 ] || {},
5286 i = 0,
5287 l = this.length;
5288
5289 if ( value === undefined && elem.nodeType === 1 ) {
5290 return elem.innerHTML;
5291 }
5292
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() ] ) {
5296
5297 value = value.replace( rxhtmlTag, "<$1></$2>" );
5298
5299 try {
5300 for ( ; i < l; i++ ) {
5301 elem = this[ i ] || {};
5302
5303 // Remove element nodes and prevent memory leaks
5304 if ( elem.nodeType === 1 ) {
5305 jQuery.cleanData( getAll( elem, false ) );
5306 elem.innerHTML = value;
5307 }
5308 }
5309
5310 elem = 0;
5311
5312 // If using innerHTML throws an exception, use the fallback method
5313 } catch( e ) {}
5314 }
5315
5316 if ( elem ) {
5317 this.empty().append( value );
5318 }
5319 }, null, value, arguments.length );
5320 },
5321
5322 replaceWith: function() {
5323 var arg = arguments[ 0 ];
5324
5325 // Make the changes, replacing each context element with the new content
5326 this.domManip( arguments, function( elem ) {
5327 arg = this.parentNode;
5328
5329 jQuery.cleanData( getAll( this ) );
5330
5331 if ( arg ) {
5332 arg.replaceChild( elem, this );
5333 }
5334 });
5335
5336 // Force removal if there was no new content (e.g., from empty arguments)
5337 return arg && (arg.length || arg.nodeType) ? this : this.remove();
5338 },
5339
5340 detach: function( selector ) {
5341 return this.remove( selector, true );
5342 },
5343
5344 domManip: function( args, callback ) {
5345
5346 // Flatten any nested arrays
5347 args = concat.apply( [], args );
5348
5349 var fragment, first, scripts, hasScripts, node, doc,
5350 i = 0,
5351 l = this.length,
5352 set = this,
5353 iNoClone = l - 1,
5354 value = args[ 0 ],
5355 isFunction = jQuery.isFunction( value );
5356
5357 // We can't cloneNode fragments that contain checked, in WebKit
5358 if ( isFunction ||
5359 ( l > 1 && typeof value === "string" &&
5360 !support.checkClone && rchecked.test( value ) ) ) {
5361 return this.each(function( index ) {
5362 var self = set.eq( index );
5363 if ( isFunction ) {
5364 args[ 0 ] = value.call( this, index, self.html() );
5365 }
5366 self.domManip( args, callback );
5367 });
5368 }
5369
5370 if ( l ) {
5371 fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this );
5372 first = fragment.firstChild;
5373
5374 if ( fragment.childNodes.length === 1 ) {
5375 fragment = first;
5376 }
5377
5378 if ( first ) {
5379 scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
5380 hasScripts = scripts.length;
5381
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++ ) {
5385 node = fragment;
5386
5387 if ( i !== iNoClone ) {
5388 node = jQuery.clone( node, true, true );
5389
5390 // Keep references to cloned scripts for later restoration
5391 if ( hasScripts ) {
5392 // Support: QtWebKit
5393 // jQuery.merge because push.apply(_, arraylike) throws
5394 jQuery.merge( scripts, getAll( node, "script" ) );
5395 }
5396 }
5397
5398 callback.call( this[ i ], node, i );
5399 }
5400
5401 if ( hasScripts ) {
5402 doc = scripts[ scripts.length - 1 ].ownerDocument;
5403
5404 // Reenable scripts
5405 jQuery.map( scripts, restoreScript );
5406
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 ) ) {
5412
5413 if ( node.src ) {
5414 // Optional AJAX dependency, but won't run scripts if not present
5415 if ( jQuery._evalUrl ) {
5416 jQuery._evalUrl( node.src );
5417 }
5418 } else {
5419 jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) );
5420 }
5421 }
5422 }
5423 }
5424 }
5425 }
5426
5427 return this;
5428 }
5429});
5430
5431jQuery.each({
5432 appendTo: "append",
5433 prependTo: "prepend",
5434 insertBefore: "before",
5435 insertAfter: "after",
5436 replaceAll: "replaceWith"
5437}, function( name, original ) {
5438 jQuery.fn[ name ] = function( selector ) {
5439 var elems,
5440 ret = [],
5441 insert = jQuery( selector ),
5442 last = insert.length - 1,
5443 i = 0;
5444
5445 for ( ; i <= last; i++ ) {
5446 elems = i === last ? this : this.clone( true );
5447 jQuery( insert[ i ] )[ original ]( elems );
5448
5449 // Support: QtWebKit
5450 // .get() because push.apply(_, arraylike) throws
5451 push.apply( ret, elems.get() );
5452 }
5453
5454 return this.pushStack( ret );
5455 };
5456});
5457
5458
5459var iframe,
5460 elemdisplay = {};
5461
5462/**
5463 * Retrieve the actual display of a element
5464 * @param {String} name nodeName of the element
5465 * @param {Object} doc Document object
5466 */
5467// Called only from within defaultDisplay
5468function actualDisplay( name, doc ) {
5469 var style,
5470 elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
5471
5472 // getDefaultComputedStyle might be reliably used only on attached element
5473 display = window.getDefaultComputedStyle && ( style = window.getDefaultComputedStyle( elem[ 0 ] ) ) ?
5474
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" );
5478
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
5481 elem.detach();
5482
5483 return display;
5484}
5485
5486/**
5487 * Try to determine the default display value of an element
5488 * @param {String} nodeName
5489 */
5490function defaultDisplay( nodeName ) {
5491 var doc = document,
5492 display = elemdisplay[ nodeName ];
5493
5494 if ( !display ) {
5495 display = actualDisplay( nodeName, doc );
5496
5497 // If the simple way fails, read from inside an iframe
5498 if ( display === "none" || !display ) {
5499
5500 // Use the already-created iframe if possible
5501 iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement );
5502
5503 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
5504 doc = iframe[ 0 ].contentDocument;
5505
5506 // Support: IE
5507 doc.write();
5508 doc.close();
5509
5510 display = actualDisplay( nodeName, doc );
5511 iframe.detach();
5512 }
5513
5514 // Store the correct default display
5515 elemdisplay[ nodeName ] = display;
5516 }
5517
5518 return display;
5519}
5520var rmargin = (/^margin/);
5521
5522var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
5523
5524var getStyles = function( elem ) {
5525 return elem.ownerDocument.defaultView.getComputedStyle( elem, null );
5526 };
5527
5528
5529
5530function curCSS( elem, name, computed ) {
5531 var width, minWidth, maxWidth, ret,
5532 style = elem.style;
5533
5534 computed = computed || getStyles( elem );
5535
5536 // Support: IE9
5537 // getPropertyValue is only needed for .css('filter') in IE9, see #12537
5538 if ( computed ) {
5539 ret = computed.getPropertyValue( name ) || computed[ name ];
5540 }
5541
5542 if ( computed ) {
5543
5544 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
5545 ret = jQuery.style( elem, name );
5546 }
5547
5548 // Support: iOS < 6
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 ) ) {
5553
5554 // Remember the original values
5555 width = style.width;
5556 minWidth = style.minWidth;
5557 maxWidth = style.maxWidth;
5558
5559 // Put in the new values to get a computed value out
5560 style.minWidth = style.maxWidth = style.width = ret;
5561 ret = computed.width;
5562
5563 // Revert the changed values
5564 style.width = width;
5565 style.minWidth = minWidth;
5566 style.maxWidth = maxWidth;
5567 }
5568 }
5569
5570 return ret !== undefined ?
5571 // Support: IE
5572 // IE returns zIndex value as an integer.
5573 ret + "" :
5574 ret;
5575}
5576
5577
5578function addGetHookIf( conditionFn, hookFn ) {
5579 // Define the hook, we'll check on the first run if it's really needed.
5580 return {
5581 get: function() {
5582 if ( conditionFn() ) {
5583 // Hook not needed (or it's not possible to use it due to missing dependency),
5584 // remove it.
5585 // Since there are no other hooks for marginRight, remove the whole object.
5586 delete this.get;
5587 return;
5588 }
5589
5590 // Hook needed; redefine it so that the support test is not executed again.
5591
5592 return (this.get = hookFn).apply( this, arguments );
5593 }
5594 };
5595}
5596
5597
5598(function() {
5599 var pixelPositionVal, boxSizingReliableVal,
5600 docElem = document.documentElement,
5601 container = document.createElement( "div" ),
5602 div = document.createElement( "div" );
5603
5604 if ( !div.style ) {
5605 return;
5606 }
5607
5608 div.style.backgroundClip = "content-box";
5609 div.cloneNode( true ).style.backgroundClip = "";
5610 support.clearCloneStyle = div.style.backgroundClip === "content-box";
5611
5612 container.style.cssText = "border:0;width:0;height:0;top:0;left:-9999px;margin-top:1px;" +
5613 "position:absolute";
5614 container.appendChild( div );
5615
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() {
5619 div.style.cssText =
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";
5625 div.innerHTML = "";
5626 docElem.appendChild( container );
5627
5628 var divStyle = window.getComputedStyle( div, null );
5629 pixelPositionVal = divStyle.top !== "1%";
5630 boxSizingReliableVal = divStyle.width === "4px";
5631
5632 docElem.removeChild( container );
5633 }
5634
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;
5645 },
5646 boxSizingReliable: function() {
5647 if ( boxSizingReliableVal == null ) {
5648 computePixelPositionAndBoxSizingReliable();
5649 }
5650 return boxSizingReliableVal;
5651 },
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.
5658 var ret,
5659 marginDiv = div.appendChild( document.createElement( "div" ) );
5660
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 );
5670
5671 ret = !parseFloat( window.getComputedStyle( marginDiv, null ).marginRight );
5672
5673 docElem.removeChild( container );
5674
5675 return ret;
5676 }
5677 });
5678 }
5679})();
5680
5681
5682// A method for quickly swapping in/out CSS properties to get correct calculations.
5683jQuery.swap = function( elem, options, callback, args ) {
5684 var ret, name,
5685 old = {};
5686
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 ];
5691 }
5692
5693 ret = callback.apply( elem, args || [] );
5694
5695 // Revert the old values
5696 for ( name in options ) {
5697 elem.style[ name ] = old[ name ];
5698 }
5699
5700 return ret;
5701};
5702
5703
5704var
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" ),
5710
5711 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
5712 cssNormalTransform = {
5713 letterSpacing: "0",
5714 fontWeight: "400"
5715 },
5716
5717 cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
5718
5719// return a css property mapped to a potentially vendor prefixed property
5720function vendorPropName( style, name ) {
5721
5722 // shortcut for names that are not vendor prefixed
5723 if ( name in style ) {
5724 return name;
5725 }
5726
5727 // check for vendor prefixed names
5728 var capName = name[0].toUpperCase() + name.slice(1),
5729 origName = name,
5730 i = cssPrefixes.length;
5731
5732 while ( i-- ) {
5733 name = cssPrefixes[ i ] + capName;
5734 if ( name in style ) {
5735 return name;
5736 }
5737 }
5738
5739 return origName;
5740}
5741
5742function setPositiveNumber( elem, value, subtract ) {
5743 var matches = rnumsplit.exec( value );
5744 return matches ?
5745 // Guard against undefined "subtract", e.g., when used as in cssHooks
5746 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
5747 value;
5748}
5749
5750function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
5751 var i = extra === ( isBorderBox ? "border" : "content" ) ?
5752 // If we already have the right measurement, avoid augmentation
5753 4 :
5754 // Otherwise initialize for horizontal or vertical properties
5755 name === "width" ? 1 : 0,
5756
5757 val = 0;
5758
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 );
5763 }
5764
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 );
5769 }
5770
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 );
5774 }
5775 } else {
5776 // at this point, extra isn't content, so add padding
5777 val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
5778
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 );
5782 }
5783 }
5784 }
5785
5786 return val;
5787}
5788
5789function getWidthOrHeight( elem, name, extra ) {
5790
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";
5796
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 ];
5805 }
5806
5807 // Computed unit is not pixels. Stop here and return.
5808 if ( rnumnonpx.test(val) ) {
5809 return val;
5810 }
5811
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 ] );
5816
5817 // Normalize "", auto, and prepare for extra
5818 val = parseFloat( val ) || 0;
5819 }
5820
5821 // use the active box-sizing model to add/subtract irrelevant styles
5822 return ( val +
5823 augmentWidthOrHeight(
5824 elem,
5825 name,
5826 extra || ( isBorderBox ? "border" : "content" ),
5827 valueIsBorderBox,
5828 styles
5829 )
5830 ) + "px";
5831}
5832
5833function showHide( elements, show ) {
5834 var display, elem, hidden,
5835 values = [],
5836 index = 0,
5837 length = elements.length;
5838
5839 for ( ; index < length; index++ ) {
5840 elem = elements[ index ];
5841 if ( !elem.style ) {
5842 continue;
5843 }
5844
5845 values[ index ] = data_priv.get( elem, "olddisplay" );
5846 display = elem.style.display;
5847 if ( show ) {
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 = "";
5852 }
5853
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) );
5859 }
5860 } else {
5861 hidden = isHidden( elem );
5862
5863 if ( display !== "none" || !hidden ) {
5864 data_priv.set( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) );
5865 }
5866 }
5867 }
5868
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 ) {
5874 continue;
5875 }
5876 if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
5877 elem.style.display = show ? values[ index ] || "" : "none";
5878 }
5879 }
5880
5881 return elements;
5882}
5883
5884jQuery.extend({
5885 // Add in style property hooks for overriding the default
5886 // behavior of getting and setting a style property
5887 cssHooks: {
5888 opacity: {
5889 get: function( elem, computed ) {
5890 if ( computed ) {
5891 // We should always get a number back from opacity
5892 var ret = curCSS( elem, "opacity" );
5893 return ret === "" ? "1" : ret;
5894 }
5895 }
5896 }
5897 },
5898
5899 // Don't automatically add "px" to these possibly-unitless properties
5900 cssNumber: {
5901 "columnCount": true,
5902 "fillOpacity": true,
5903 "flexGrow": true,
5904 "flexShrink": true,
5905 "fontWeight": true,
5906 "lineHeight": true,
5907 "opacity": true,
5908 "order": true,
5909 "orphans": true,
5910 "widows": true,
5911 "zIndex": true,
5912 "zoom": true
5913 },
5914
5915 // Add in properties whose names you wish to fix before
5916 // setting or getting the value
5917 cssProps: {
5918 // normalize float css property
5919 "float": "cssFloat"
5920 },
5921
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 ) {
5926 return;
5927 }
5928
5929 // Make sure that we're working with the right name
5930 var ret, type, hooks,
5931 origName = jQuery.camelCase( name ),
5932 style = elem.style;
5933
5934 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
5935
5936 // gets hook for the prefixed version
5937 // followed by the unprefixed version
5938 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
5939
5940 // Check if we're setting a value
5941 if ( value !== undefined ) {
5942 type = typeof value;
5943
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 ) );
5947 // Fixes bug #9237
5948 type = "number";
5949 }
5950
5951 // Make sure that null and NaN values aren't set. See: #7116
5952 if ( value == null || value !== value ) {
5953 return;
5954 }
5955
5956 // If a number was passed in, add 'px' to the (except for certain CSS properties)
5957 if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
5958 value += "px";
5959 }
5960
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";
5965 }
5966
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;
5970 }
5971
5972 } else {
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 ) {
5975 return ret;
5976 }
5977
5978 // Otherwise just get the value from the style object
5979 return style[ name ];
5980 }
5981 },
5982
5983 css: function( elem, name, extra, styles ) {
5984 var val, num, hooks,
5985 origName = jQuery.camelCase( name );
5986
5987 // Make sure that we're working with the right name
5988 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
5989
5990 // gets hook for the prefixed version
5991 // followed by the unprefixed version
5992 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
5993
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 );
5997 }
5998
5999 // Otherwise, if a way to get the computed value exists, use that
6000 if ( val === undefined ) {
6001 val = curCSS( elem, name, styles );
6002 }
6003
6004 //convert "normal" to computed value
6005 if ( val === "normal" && name in cssNormalTransform ) {
6006 val = cssNormalTransform[ name ];
6007 }
6008
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;
6013 }
6014 return val;
6015 }
6016});
6017
6018jQuery.each([ "height", "width" ], function( i, name ) {
6019 jQuery.cssHooks[ name ] = {
6020 get: function( elem, computed, extra ) {
6021 if ( computed ) {
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 );
6027 }) :
6028 getWidthOrHeight( elem, name, extra );
6029 }
6030 },
6031
6032 set: function( elem, value, extra ) {
6033 var styles = extra && getStyles( elem );
6034 return setPositiveNumber( elem, value, extra ?
6035 augmentWidthOrHeight(
6036 elem,
6037 name,
6038 extra,
6039 jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
6040 styles
6041 ) : 0
6042 );
6043 }
6044 };
6045});
6046
6047// Support: Android 2.3
6048jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
6049 function( elem, computed ) {
6050 if ( 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" ] );
6055 }
6056 }
6057);
6058
6059// These hooks are used by animate to expand properties
6060jQuery.each({
6061 margin: "",
6062 padding: "",
6063 border: "Width"
6064}, function( prefix, suffix ) {
6065 jQuery.cssHooks[ prefix + suffix ] = {
6066 expand: function( value ) {
6067 var i = 0,
6068 expanded = {},
6069
6070 // assumes a single number if not a string
6071 parts = typeof value === "string" ? value.split(" ") : [ value ];
6072
6073 for ( ; i < 4; i++ ) {
6074 expanded[ prefix + cssExpand[ i ] + suffix ] =
6075 parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
6076 }
6077
6078 return expanded;
6079 }
6080 };
6081
6082 if ( !rmargin.test( prefix ) ) {
6083 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
6084 }
6085});
6086
6087jQuery.fn.extend({
6088 css: function( name, value ) {
6089 return access( this, function( elem, name, value ) {
6090 var styles, len,
6091 map = {},
6092 i = 0;
6093
6094 if ( jQuery.isArray( name ) ) {
6095 styles = getStyles( elem );
6096 len = name.length;
6097
6098 for ( ; i < len; i++ ) {
6099 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
6100 }
6101
6102 return map;
6103 }
6104
6105 return value !== undefined ?
6106 jQuery.style( elem, name, value ) :
6107 jQuery.css( elem, name );
6108 }, name, value, arguments.length > 1 );
6109 },
6110 show: function() {
6111 return showHide( this, true );
6112 },
6113 hide: function() {
6114 return showHide( this );
6115 },
6116 toggle: function( state ) {
6117 if ( typeof state === "boolean" ) {
6118 return state ? this.show() : this.hide();
6119 }
6120
6121 return this.each(function() {
6122 if ( isHidden( this ) ) {
6123 jQuery( this ).show();
6124 } else {
6125 jQuery( this ).hide();
6126 }
6127 });
6128 }
6129});
6130
6131
6132function Tween( elem, options, prop, end, easing ) {
6133 return new Tween.prototype.init( elem, options, prop, end, easing );
6134}
6135jQuery.Tween = Tween;
6136
6137Tween.prototype = {
6138 constructor: Tween,
6139 init: function( elem, options, prop, end, easing, unit ) {
6140 this.elem = elem;
6141 this.prop = prop;
6142 this.easing = easing || "swing";
6143 this.options = options;
6144 this.start = this.now = this.cur();
6145 this.end = end;
6146 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
6147 },
6148 cur: function() {
6149 var hooks = Tween.propHooks[ this.prop ];
6150
6151 return hooks && hooks.get ?
6152 hooks.get( this ) :
6153 Tween.propHooks._default.get( this );
6154 },
6155 run: function( percent ) {
6156 var eased,
6157 hooks = Tween.propHooks[ this.prop ];
6158
6159 if ( this.options.duration ) {
6160 this.pos = eased = jQuery.easing[ this.easing ](
6161 percent, this.options.duration * percent, 0, 1, this.options.duration
6162 );
6163 } else {
6164 this.pos = eased = percent;
6165 }
6166 this.now = ( this.end - this.start ) * eased + this.start;
6167
6168 if ( this.options.step ) {
6169 this.options.step.call( this.elem, this.now, this );
6170 }
6171
6172 if ( hooks && hooks.set ) {
6173 hooks.set( this );
6174 } else {
6175 Tween.propHooks._default.set( this );
6176 }
6177 return this;
6178 }
6179};
6180
6181Tween.prototype.init.prototype = Tween.prototype;
6182
6183Tween.propHooks = {
6184 _default: {
6185 get: function( tween ) {
6186 var result;
6187
6188 if ( tween.elem[ tween.prop ] != null &&
6189 (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
6190 return tween.elem[ tween.prop ];
6191 }
6192
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;
6200 },
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 );
6208 } else {
6209 tween.elem[ tween.prop ] = tween.now;
6210 }
6211 }
6212 }
6213};
6214
6215// Support: IE9
6216// Panic based approach to setting things on disconnected nodes
6217
6218Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
6219 set: function( tween ) {
6220 if ( tween.elem.nodeType && tween.elem.parentNode ) {
6221 tween.elem[ tween.prop ] = tween.now;
6222 }
6223 }
6224};
6225
6226jQuery.easing = {
6227 linear: function( p ) {
6228 return p;
6229 },
6230 swing: function( p ) {
6231 return 0.5 - Math.cos( p * Math.PI ) / 2;
6232 }
6233};
6234
6235jQuery.fx = Tween.prototype.init;
6236
6237// Back Compat <1.8 extension point
6238jQuery.fx.step = {};
6239
6240
6241
6242
6243var
6244 fxNow, timerId,
6245 rfxtypes = /^(?:toggle|show|hide)$/,
6246 rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ),
6247 rrun = /queueHooks$/,
6248 animationPrefilters = [ defaultPrefilter ],
6249 tweeners = {
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" ),
6255
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 ) ),
6259 scale = 1,
6260 maxIterations = 20;
6261
6262 if ( start && start[ 3 ] !== unit ) {
6263 // Trust units reported by jQuery.css
6264 unit = unit || start[ 3 ];
6265
6266 // Make sure we update the tween properties later on
6267 parts = parts || [];
6268
6269 // Iteratively approximate from a nonzero starting point
6270 start = +target || 1;
6271
6272 do {
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";
6276
6277 // Adjust and apply
6278 start = start / scale;
6279 jQuery.style( tween.elem, prop, start + unit );
6280
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 );
6284 }
6285
6286 // Update tween properties
6287 if ( parts ) {
6288 start = tween.start = +start || +target || 0;
6289 tween.unit = unit;
6290 // If a +=/-= token was provided, we're doing a relative animation
6291 tween.end = parts[ 1 ] ?
6292 start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
6293 +parts[ 2 ];
6294 }
6295
6296 return tween;
6297 } ]
6298 };
6299
6300// Animations created synchronously will run synchronously
6301function createFxNow() {
6302 setTimeout(function() {
6303 fxNow = undefined;
6304 });
6305 return ( fxNow = jQuery.now() );
6306}
6307
6308// Generate parameters to create a standard animation
6309function genFx( type, includeWidth ) {
6310 var which,
6311 i = 0,
6312 attrs = { height: type };
6313
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;
6320 }
6321
6322 if ( includeWidth ) {
6323 attrs.opacity = attrs.width = type;
6324 }
6325
6326 return attrs;
6327}
6328
6329function createTween( value, prop, animation ) {
6330 var tween,
6331 collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
6332 index = 0,
6333 length = collection.length;
6334 for ( ; index < length; index++ ) {
6335 if ( (tween = collection[ index ].call( animation, prop, value )) ) {
6336
6337 // we're done with this property
6338 return tween;
6339 }
6340 }
6341}
6342
6343function defaultPrefilter( elem, props, opts ) {
6344 /* jshint validthis: true */
6345 var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay,
6346 anim = this,
6347 orig = {},
6348 style = elem.style,
6349 hidden = elem.nodeType && isHidden( elem ),
6350 dataShow = data_priv.get( elem, "fxshow" );
6351
6352 // handle queue: false promises
6353 if ( !opts.queue ) {
6354 hooks = jQuery._queueHooks( elem, "fx" );
6355 if ( hooks.unqueued == null ) {
6356 hooks.unqueued = 0;
6357 oldfire = hooks.empty.fire;
6358 hooks.empty.fire = function() {
6359 if ( !hooks.unqueued ) {
6360 oldfire();
6361 }
6362 };
6363 }
6364 hooks.unqueued++;
6365
6366 anim.always(function() {
6367 // doing this makes sure that the complete handler will be called
6368 // before this completes
6369 anim.always(function() {
6370 hooks.unqueued--;
6371 if ( !jQuery.queue( elem, "fx" ).length ) {
6372 hooks.empty.fire();
6373 }
6374 });
6375 });
6376 }
6377
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 ];
6385
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" );
6389
6390 // Test default display if display is currently "none"
6391 checkDisplay = display === "none" ?
6392 data_priv.get( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display;
6393
6394 if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) {
6395 style.display = "inline-block";
6396 }
6397 }
6398
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 ];
6405 });
6406 }
6407
6408 // show/hide pass
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" ) ) {
6415
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 ) {
6418 hidden = true;
6419 } else {
6420 continue;
6421 }
6422 }
6423 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
6424
6425 // Any non-fx value stops us from restoring the original display value
6426 } else {
6427 display = undefined;
6428 }
6429 }
6430
6431 if ( !jQuery.isEmptyObject( orig ) ) {
6432 if ( dataShow ) {
6433 if ( "hidden" in dataShow ) {
6434 hidden = dataShow.hidden;
6435 }
6436 } else {
6437 dataShow = data_priv.access( elem, "fxshow", {} );
6438 }
6439
6440 // store state if its toggle - enables .stop().toggle() to "reverse"
6441 if ( toggle ) {
6442 dataShow.hidden = !hidden;
6443 }
6444 if ( hidden ) {
6445 jQuery( elem ).show();
6446 } else {
6447 anim.done(function() {
6448 jQuery( elem ).hide();
6449 });
6450 }
6451 anim.done(function() {
6452 var prop;
6453
6454 data_priv.remove( elem, "fxshow" );
6455 for ( prop in orig ) {
6456 jQuery.style( elem, prop, orig[ prop ] );
6457 }
6458 });
6459 for ( prop in orig ) {
6460 tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
6461
6462 if ( !( prop in dataShow ) ) {
6463 dataShow[ prop ] = tween.start;
6464 if ( hidden ) {
6465 tween.end = tween.start;
6466 tween.start = prop === "width" || prop === "height" ? 1 : 0;
6467 }
6468 }
6469 }
6470
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;
6474 }
6475}
6476
6477function propFilter( props, specialEasing ) {
6478 var index, name, easing, value, hooks;
6479
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 ];
6488 }
6489
6490 if ( index !== name ) {
6491 props[ name ] = value;
6492 delete props[ index ];
6493 }
6494
6495 hooks = jQuery.cssHooks[ name ];
6496 if ( hooks && "expand" in hooks ) {
6497 value = hooks.expand( value );
6498 delete props[ name ];
6499
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;
6506 }
6507 }
6508 } else {
6509 specialEasing[ name ] = easing;
6510 }
6511 }
6512}
6513
6514function Animation( elem, properties, options ) {
6515 var result,
6516 stopped,
6517 index = 0,
6518 length = animationPrefilters.length,
6519 deferred = jQuery.Deferred().always( function() {
6520 // don't match elem in the :animated selector
6521 delete tick.elem;
6522 }),
6523 tick = function() {
6524 if ( stopped ) {
6525 return false;
6526 }
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,
6531 percent = 1 - temp,
6532 index = 0,
6533 length = animation.tweens.length;
6534
6535 for ( ; index < length ; index++ ) {
6536 animation.tweens[ index ].run( percent );
6537 }
6538
6539 deferred.notifyWith( elem, [ animation, percent, remaining ]);
6540
6541 if ( percent < 1 && length ) {
6542 return remaining;
6543 } else {
6544 deferred.resolveWith( elem, [ animation ] );
6545 return false;
6546 }
6547 },
6548 animation = deferred.promise({
6549 elem: elem,
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,
6556 tweens: [],
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 );
6561 return tween;
6562 },
6563 stop: function( gotoEnd ) {
6564 var index = 0,
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;
6568 if ( stopped ) {
6569 return this;
6570 }
6571 stopped = true;
6572 for ( ; index < length ; index++ ) {
6573 animation.tweens[ index ].run( 1 );
6574 }
6575
6576 // resolve when we played the last frame
6577 // otherwise, reject
6578 if ( gotoEnd ) {
6579 deferred.resolveWith( elem, [ animation, gotoEnd ] );
6580 } else {
6581 deferred.rejectWith( elem, [ animation, gotoEnd ] );
6582 }
6583 return this;
6584 }
6585 }),
6586 props = animation.props;
6587
6588 propFilter( props, animation.opts.specialEasing );
6589
6590 for ( ; index < length ; index++ ) {
6591 result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
6592 if ( result ) {
6593 return result;
6594 }
6595 }
6596
6597 jQuery.map( props, createTween, animation );
6598
6599 if ( jQuery.isFunction( animation.opts.start ) ) {
6600 animation.opts.start.call( elem, animation );
6601 }
6602
6603 jQuery.fx.timer(
6604 jQuery.extend( tick, {
6605 elem: elem,
6606 anim: animation,
6607 queue: animation.opts.queue
6608 })
6609 );
6610
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 );
6616}
6617
6618jQuery.Animation = jQuery.extend( Animation, {
6619
6620 tweener: function( props, callback ) {
6621 if ( jQuery.isFunction( props ) ) {
6622 callback = props;
6623 props = [ "*" ];
6624 } else {
6625 props = props.split(" ");
6626 }
6627
6628 var prop,
6629 index = 0,
6630 length = props.length;
6631
6632 for ( ; index < length ; index++ ) {
6633 prop = props[ index ];
6634 tweeners[ prop ] = tweeners[ prop ] || [];
6635 tweeners[ prop ].unshift( callback );
6636 }
6637 },
6638
6639 prefilter: function( callback, prepend ) {
6640 if ( prepend ) {
6641 animationPrefilters.unshift( callback );
6642 } else {
6643 animationPrefilters.push( callback );
6644 }
6645 }
6646});
6647
6648jQuery.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,
6652 duration: speed,
6653 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
6654 };
6655
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;
6658
6659 // normalize opt.queue - true/undefined/null -> "fx"
6660 if ( opt.queue == null || opt.queue === true ) {
6661 opt.queue = "fx";
6662 }
6663
6664 // Queueing
6665 opt.old = opt.complete;
6666
6667 opt.complete = function() {
6668 if ( jQuery.isFunction( opt.old ) ) {
6669 opt.old.call( this );
6670 }
6671
6672 if ( opt.queue ) {
6673 jQuery.dequeue( this, opt.queue );
6674 }
6675 };
6676
6677 return opt;
6678};
6679
6680jQuery.fn.extend({
6681 fadeTo: function( speed, to, easing, callback ) {
6682
6683 // show any hidden elements after setting opacity to 0
6684 return this.filter( isHidden ).css( "opacity", 0 ).show()
6685
6686 // animate to the value specified
6687 .end().animate({ opacity: to }, speed, easing, callback );
6688 },
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 );
6695
6696 // Empty animations, or finishing resolves immediately
6697 if ( empty || data_priv.get( this, "finish" ) ) {
6698 anim.stop( true );
6699 }
6700 };
6701 doAnimation.finish = doAnimation;
6702
6703 return empty || optall.queue === false ?
6704 this.each( doAnimation ) :
6705 this.queue( optall.queue, doAnimation );
6706 },
6707 stop: function( type, clearQueue, gotoEnd ) {
6708 var stopQueue = function( hooks ) {
6709 var stop = hooks.stop;
6710 delete hooks.stop;
6711 stop( gotoEnd );
6712 };
6713
6714 if ( typeof type !== "string" ) {
6715 gotoEnd = clearQueue;
6716 clearQueue = type;
6717 type = undefined;
6718 }
6719 if ( clearQueue && type !== false ) {
6720 this.queue( type || "fx", [] );
6721 }
6722
6723 return this.each(function() {
6724 var dequeue = true,
6725 index = type != null && type + "queueHooks",
6726 timers = jQuery.timers,
6727 data = data_priv.get( this );
6728
6729 if ( index ) {
6730 if ( data[ index ] && data[ index ].stop ) {
6731 stopQueue( data[ index ] );
6732 }
6733 } else {
6734 for ( index in data ) {
6735 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
6736 stopQueue( data[ index ] );
6737 }
6738 }
6739 }
6740
6741 for ( index = timers.length; index--; ) {
6742 if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
6743 timers[ index ].anim.stop( gotoEnd );
6744 dequeue = false;
6745 timers.splice( index, 1 );
6746 }
6747 }
6748
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 );
6754 }
6755 });
6756 },
6757 finish: function( type ) {
6758 if ( type !== false ) {
6759 type = type || "fx";
6760 }
6761 return this.each(function() {
6762 var index,
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;
6768
6769 // enable finishing flag on private data
6770 data.finish = true;
6771
6772 // empty the queue first
6773 jQuery.queue( this, type, [] );
6774
6775 if ( hooks && hooks.stop ) {
6776 hooks.stop.call( this, true );
6777 }
6778
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 );
6784 }
6785 }
6786
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 );
6791 }
6792 }
6793
6794 // turn off finishing flag
6795 delete data.finish;
6796 });
6797 }
6798});
6799
6800jQuery.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 );
6806 };
6807});
6808
6809// Generate shortcuts for custom animations
6810jQuery.each({
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 );
6820 };
6821});
6822
6823jQuery.timers = [];
6824jQuery.fx.tick = function() {
6825 var timer,
6826 i = 0,
6827 timers = jQuery.timers;
6828
6829 fxNow = jQuery.now();
6830
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 );
6836 }
6837 }
6838
6839 if ( !timers.length ) {
6840 jQuery.fx.stop();
6841 }
6842 fxNow = undefined;
6843};
6844
6845jQuery.fx.timer = function( timer ) {
6846 jQuery.timers.push( timer );
6847 if ( timer() ) {
6848 jQuery.fx.start();
6849 } else {
6850 jQuery.timers.pop();
6851 }
6852};
6853
6854jQuery.fx.interval = 13;
6855
6856jQuery.fx.start = function() {
6857 if ( !timerId ) {
6858 timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
6859 }
6860};
6861
6862jQuery.fx.stop = function() {
6863 clearInterval( timerId );
6864 timerId = null;
6865};
6866
6867jQuery.fx.speeds = {
6868 slow: 600,
6869 fast: 200,
6870 // Default speed
6871 _default: 400
6872};
6873
6874
6875// Based off of the plugin by Clint Helfers, with permission.
6876// http://blindsignals.com/index.php/2009/07/jquery-delay/
6877jQuery.fn.delay = function( time, type ) {
6878 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
6879 type = type || "fx";
6880
6881 return this.queue( type, function( next, hooks ) {
6882 var timeout = setTimeout( next, time );
6883 hooks.stop = function() {
6884 clearTimeout( timeout );
6885 };
6886 });
6887};
6888
6889
6890(function() {
6891 var input = document.createElement( "input" ),
6892 select = document.createElement( "select" ),
6893 opt = select.appendChild( document.createElement( "option" ) );
6894
6895 input.type = "checkbox";
6896
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 !== "";
6900
6901 // Must access the parent to make an option select properly
6902 // Support: IE9, IE10
6903 support.optSelected = opt.selected;
6904
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;
6909
6910 // Check if an input maintains its value after becoming a radio
6911 // Support: IE9, IE10
6912 input = document.createElement( "input" );
6913 input.value = "t";
6914 input.type = "radio";
6915 support.radioValue = input.value === "t";
6916})();
6917
6918
6919var nodeHook, boolHook,
6920 attrHandle = jQuery.expr.attrHandle;
6921
6922jQuery.fn.extend({
6923 attr: function( name, value ) {
6924 return access( this, jQuery.attr, name, value, arguments.length > 1 );
6925 },
6926
6927 removeAttr: function( name ) {
6928 return this.each(function() {
6929 jQuery.removeAttr( this, name );
6930 });
6931 }
6932});
6933
6934jQuery.extend({
6935 attr: function( elem, name, value ) {
6936 var hooks, ret,
6937 nType = elem.nodeType;
6938
6939 // don't get/set attributes on text, comment and attribute nodes
6940 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
6941 return;
6942 }
6943
6944 // Fallback to prop when attributes are not supported
6945 if ( typeof elem.getAttribute === strundefined ) {
6946 return jQuery.prop( elem, name, value );
6947 }
6948
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 );
6955 }
6956
6957 if ( value !== undefined ) {
6958
6959 if ( value === null ) {
6960 jQuery.removeAttr( elem, name );
6961
6962 } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
6963 return ret;
6964
6965 } else {
6966 elem.setAttribute( name, value + "" );
6967 return value;
6968 }
6969
6970 } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
6971 return ret;
6972
6973 } else {
6974 ret = jQuery.find.attr( elem, name );
6975
6976 // Non-existent attributes return null, we normalize to undefined
6977 return ret == null ?
6978 undefined :
6979 ret;
6980 }
6981 },
6982
6983 removeAttr: function( elem, value ) {
6984 var name, propName,
6985 i = 0,
6986 attrNames = value && value.match( rnotwhite );
6987
6988 if ( attrNames && elem.nodeType === 1 ) {
6989 while ( (name = attrNames[i++]) ) {
6990 propName = jQuery.propFix[ name ] || name;
6991
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;
6996 }
6997
6998 elem.removeAttribute( name );
6999 }
7000 }
7001 },
7002
7003 attrHooks: {
7004 type: {
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 );
7012 if ( val ) {
7013 elem.value = val;
7014 }
7015 return value;
7016 }
7017 }
7018 }
7019 }
7020});
7021
7022// Hooks for boolean attributes
7023boolHook = {
7024 set: function( elem, value, name ) {
7025 if ( value === false ) {
7026 // Remove boolean attributes when set to false
7027 jQuery.removeAttr( elem, name );
7028 } else {
7029 elem.setAttribute( name, name );
7030 }
7031 return name;
7032 }
7033};
7034jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
7035 var getter = attrHandle[ name ] || jQuery.find.attr;
7036
7037 attrHandle[ name ] = function( elem, name, isXML ) {
7038 var ret, handle;
7039 if ( !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() :
7045 null;
7046 attrHandle[ name ] = handle;
7047 }
7048 return ret;
7049 };
7050});
7051
7052
7053
7054
7055var rfocusable = /^(?:input|select|textarea|button)$/i;
7056
7057jQuery.fn.extend({
7058 prop: function( name, value ) {
7059 return access( this, jQuery.prop, name, value, arguments.length > 1 );
7060 },
7061
7062 removeProp: function( name ) {
7063 return this.each(function() {
7064 delete this[ jQuery.propFix[ name ] || name ];
7065 });
7066 }
7067});
7068
7069jQuery.extend({
7070 propFix: {
7071 "for": "htmlFor",
7072 "class": "className"
7073 },
7074
7075 prop: function( elem, name, value ) {
7076 var ret, hooks, notxml,
7077 nType = elem.nodeType;
7078
7079 // don't get/set properties on text, comment and attribute nodes
7080 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
7081 return;
7082 }
7083
7084 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
7085
7086 if ( notxml ) {
7087 // Fix name and attach hooks
7088 name = jQuery.propFix[ name ] || name;
7089 hooks = jQuery.propHooks[ name ];
7090 }
7091
7092 if ( value !== undefined ) {
7093 return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
7094 ret :
7095 ( elem[ name ] = value );
7096
7097 } else {
7098 return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
7099 ret :
7100 elem[ name ];
7101 }
7102 },
7103
7104 propHooks: {
7105 tabIndex: {
7106 get: function( elem ) {
7107 return elem.hasAttribute( "tabindex" ) || rfocusable.test( elem.nodeName ) || elem.href ?
7108 elem.tabIndex :
7109 -1;
7110 }
7111 }
7112 }
7113});
7114
7115// Support: IE9+
7116// Selectedness for an option in an optgroup can be inaccurate
7117if ( !support.optSelected ) {
7118 jQuery.propHooks.selected = {
7119 get: function( elem ) {
7120 var parent = elem.parentNode;
7121 if ( parent && parent.parentNode ) {
7122 parent.parentNode.selectedIndex;
7123 }
7124 return null;
7125 }
7126 };
7127}
7128
7129jQuery.each([
7130 "tabIndex",
7131 "readOnly",
7132 "maxLength",
7133 "cellSpacing",
7134 "cellPadding",
7135 "rowSpan",
7136 "colSpan",
7137 "useMap",
7138 "frameBorder",
7139 "contentEditable"
7140], function() {
7141 jQuery.propFix[ this.toLowerCase() ] = this;
7142});
7143
7144
7145
7146
7147var rclass = /[\t\r\n\f]/g;
7148
7149jQuery.fn.extend({
7150 addClass: function( value ) {
7151 var classes, elem, cur, clazz, j, finalValue,
7152 proceed = typeof value === "string" && value,
7153 i = 0,
7154 len = this.length;
7155
7156 if ( jQuery.isFunction( value ) ) {
7157 return this.each(function( j ) {
7158 jQuery( this ).addClass( value.call( this, j, this.className ) );
7159 });
7160 }
7161
7162 if ( proceed ) {
7163 // The disjunction here is for better compressibility (see removeClass)
7164 classes = ( value || "" ).match( rnotwhite ) || [];
7165
7166 for ( ; i < len; i++ ) {
7167 elem = this[ i ];
7168 cur = elem.nodeType === 1 && ( elem.className ?
7169 ( " " + elem.className + " " ).replace( rclass, " " ) :
7170 " "
7171 );
7172
7173 if ( cur ) {
7174 j = 0;
7175 while ( (clazz = classes[j++]) ) {
7176 if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
7177 cur += clazz + " ";
7178 }
7179 }
7180
7181 // only assign if different to avoid unneeded rendering.
7182 finalValue = jQuery.trim( cur );
7183 if ( elem.className !== finalValue ) {
7184 elem.className = finalValue;
7185 }
7186 }
7187 }
7188 }
7189
7190 return this;
7191 },
7192
7193 removeClass: function( value ) {
7194 var classes, elem, cur, clazz, j, finalValue,
7195 proceed = arguments.length === 0 || typeof value === "string" && value,
7196 i = 0,
7197 len = this.length;
7198
7199 if ( jQuery.isFunction( value ) ) {
7200 return this.each(function( j ) {
7201 jQuery( this ).removeClass( value.call( this, j, this.className ) );
7202 });
7203 }
7204 if ( proceed ) {
7205 classes = ( value || "" ).match( rnotwhite ) || [];
7206
7207 for ( ; i < len; i++ ) {
7208 elem = this[ i ];
7209 // This expression is here for better compressibility (see addClass)
7210 cur = elem.nodeType === 1 && ( elem.className ?
7211 ( " " + elem.className + " " ).replace( rclass, " " ) :
7212 ""
7213 );
7214
7215 if ( cur ) {
7216 j = 0;
7217 while ( (clazz = classes[j++]) ) {
7218 // Remove *all* instances
7219 while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
7220 cur = cur.replace( " " + clazz + " ", " " );
7221 }
7222 }
7223
7224 // only assign if different to avoid unneeded rendering.
7225 finalValue = value ? jQuery.trim( cur ) : "";
7226 if ( elem.className !== finalValue ) {
7227 elem.className = finalValue;
7228 }
7229 }
7230 }
7231 }
7232
7233 return this;
7234 },
7235
7236 toggleClass: function( value, stateVal ) {
7237 var type = typeof value;
7238
7239 if ( typeof stateVal === "boolean" && type === "string" ) {
7240 return stateVal ? this.addClass( value ) : this.removeClass( value );
7241 }
7242
7243 if ( jQuery.isFunction( value ) ) {
7244 return this.each(function( i ) {
7245 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
7246 });
7247 }
7248
7249 return this.each(function() {
7250 if ( type === "string" ) {
7251 // toggle individual class names
7252 var className,
7253 i = 0,
7254 self = jQuery( this ),
7255 classNames = value.match( rnotwhite ) || [];
7256
7257 while ( (className = classNames[ i++ ]) ) {
7258 // check each className given, space separated list
7259 if ( self.hasClass( className ) ) {
7260 self.removeClass( className );
7261 } else {
7262 self.addClass( className );
7263 }
7264 }
7265
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 );
7271 }
7272
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__" ) || "";
7278 }
7279 });
7280 },
7281
7282 hasClass: function( selector ) {
7283 var className = " " + selector + " ",
7284 i = 0,
7285 l = this.length;
7286 for ( ; i < l; i++ ) {
7287 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
7288 return true;
7289 }
7290 }
7291
7292 return false;
7293 }
7294});
7295
7296
7297
7298
7299var rreturn = /\r/g;
7300
7301jQuery.fn.extend({
7302 val: function( value ) {
7303 var hooks, ret, isFunction,
7304 elem = this[0];
7305
7306 if ( !arguments.length ) {
7307 if ( elem ) {
7308 hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
7309
7310 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
7311 return ret;
7312 }
7313
7314 ret = elem.value;
7315
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;
7321 }
7322
7323 return;
7324 }
7325
7326 isFunction = jQuery.isFunction( value );
7327
7328 return this.each(function( i ) {
7329 var val;
7330
7331 if ( this.nodeType !== 1 ) {
7332 return;
7333 }
7334
7335 if ( isFunction ) {
7336 val = value.call( this, i, jQuery( this ).val() );
7337 } else {
7338 val = value;
7339 }
7340
7341 // Treat null/undefined as ""; convert numbers to string
7342 if ( val == null ) {
7343 val = "";
7344
7345 } else if ( typeof val === "number" ) {
7346 val += "";
7347
7348 } else if ( jQuery.isArray( val ) ) {
7349 val = jQuery.map( val, function( value ) {
7350 return value == null ? "" : value + "";
7351 });
7352 }
7353
7354 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
7355
7356 // If set returns undefined, fall back to normal setting
7357 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
7358 this.value = val;
7359 }
7360 });
7361 }
7362});
7363
7364jQuery.extend({
7365 valHooks: {
7366 option: {
7367 get: function( elem ) {
7368 var val = jQuery.find.attr( elem, "value" );
7369 return val != null ?
7370 val :
7371 // Support: IE10-11+
7372 // option.text throws exceptions (#14686, #14858)
7373 jQuery.trim( jQuery.text( elem ) );
7374 }
7375 },
7376 select: {
7377 get: function( elem ) {
7378 var value, option,
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,
7384 i = index < 0 ?
7385 max :
7386 one ? index : 0;
7387
7388 // Loop through all the selected options
7389 for ( ; i < max; i++ ) {
7390 option = options[ i ];
7391
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" ) ) ) {
7397
7398 // Get the specific value for the option
7399 value = jQuery( option ).val();
7400
7401 // We don't need an array for one selects
7402 if ( one ) {
7403 return value;
7404 }
7405
7406 // Multi-Selects return an array
7407 values.push( value );
7408 }
7409 }
7410
7411 return values;
7412 },
7413
7414 set: function( elem, value ) {
7415 var optionSet, option,
7416 options = elem.options,
7417 values = jQuery.makeArray( value ),
7418 i = options.length;
7419
7420 while ( i-- ) {
7421 option = options[ i ];
7422 if ( (option.selected = jQuery.inArray( option.value, values ) >= 0) ) {
7423 optionSet = true;
7424 }
7425 }
7426
7427 // force browsers to behave consistently when non-matching value is set
7428 if ( !optionSet ) {
7429 elem.selectedIndex = -1;
7430 }
7431 return values;
7432 }
7433 }
7434 }
7435});
7436
7437// Radios and checkboxes getter/setter
7438jQuery.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 );
7443 }
7444 }
7445 };
7446 if ( !support.checkOn ) {
7447 jQuery.valHooks[ this ].get = function( elem ) {
7448 // Support: Webkit
7449 // "" is returned instead of "on" if a value isn't specified
7450 return elem.getAttribute("value") === null ? "on" : elem.value;
7451 };
7452 }
7453});
7454
7455
7456
7457
7458// Return jQuery for attributes-only inclusion
7459
7460
7461jQuery.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 ) {
7464
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 );
7470 };
7471});
7472
7473jQuery.fn.extend({
7474 hover: function( fnOver, fnOut ) {
7475 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
7476 },
7477
7478 bind: function( types, data, fn ) {
7479 return this.on( types, null, data, fn );
7480 },
7481 unbind: function( types, fn ) {
7482 return this.off( types, null, fn );
7483 },
7484
7485 delegate: function( selector, types, data, fn ) {
7486 return this.on( types, selector, data, fn );
7487 },
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 );
7491 }
7492});
7493
7494
7495var nonce = jQuery.now();
7496
7497var rquery = (/\?/);
7498
7499
7500
7501// Support: Android 2.3
7502// Workaround failure to string-cast null input
7503jQuery.parseJSON = function( data ) {
7504 return JSON.parse( data + "" );
7505};
7506
7507
7508// Cross-browser xml parsing
7509jQuery.parseXML = function( data ) {
7510 var xml, tmp;
7511 if ( !data || typeof data !== "string" ) {
7512 return null;
7513 }
7514
7515 // Support: IE9
7516 try {
7517 tmp = new DOMParser();
7518 xml = tmp.parseFromString( data, "text/xml" );
7519 } catch ( e ) {
7520 xml = undefined;
7521 }
7522
7523 if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
7524 jQuery.error( "Invalid XML: " + data );
7525 }
7526 return xml;
7527};
7528
7529
7530var
7531 // Document location
7532 ajaxLocParts,
7533 ajaxLocation,
7534
7535 rhash = /#.*$/,
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+)|)|)/,
7543
7544 /* Prefilters
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
7552 */
7553 prefilters = {},
7554
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
7559 */
7560 transports = {},
7561
7562 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
7563 allTypes = "*/".concat("*");
7564
7565// #8138, IE may throw an exception when accessing
7566// a field from window.location if document.domain has been set
7567try {
7568 ajaxLocation = location.href;
7569} catch( e ) {
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;
7575}
7576
7577// Segment location into parts
7578ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
7579
7580// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
7581function addToPrefiltersOrTransports( structure ) {
7582
7583 // dataTypeExpression is optional and defaults to "*"
7584 return function( dataTypeExpression, func ) {
7585
7586 if ( typeof dataTypeExpression !== "string" ) {
7587 func = dataTypeExpression;
7588 dataTypeExpression = "*";
7589 }
7590
7591 var dataType,
7592 i = 0,
7593 dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
7594
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 );
7602
7603 // Otherwise append
7604 } else {
7605 (structure[ dataType ] = structure[ dataType ] || []).push( func );
7606 }
7607 }
7608 }
7609 };
7610}
7611
7612// Base inspection function for prefilters and transports
7613function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
7614
7615 var inspected = {},
7616 seekingTransport = ( structure === transports );
7617
7618 function inspect( dataType ) {
7619 var selected;
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 );
7626 return false;
7627 } else if ( seekingTransport ) {
7628 return !( selected = dataTypeOrTransport );
7629 }
7630 });
7631 return selected;
7632 }
7633
7634 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
7635}
7636
7637// A special extend for ajax options
7638// that takes "flat" options (not to be deep extended)
7639// Fixes #9887
7640function ajaxExtend( target, src ) {
7641 var key, deep,
7642 flatOptions = jQuery.ajaxSettings.flatOptions || {};
7643
7644 for ( key in src ) {
7645 if ( src[ key ] !== undefined ) {
7646 ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
7647 }
7648 }
7649 if ( deep ) {
7650 jQuery.extend( true, target, deep );
7651 }
7652
7653 return target;
7654}
7655
7656/* Handles responses to an ajax request:
7657 * - finds the right dataType (mediates between content-type and expected dataType)
7658 * - returns the corresponding response
7659 */
7660function ajaxHandleResponses( s, jqXHR, responses ) {
7661
7662 var ct, type, finalDataType, firstDataType,
7663 contents = s.contents,
7664 dataTypes = s.dataTypes;
7665
7666 // Remove auto dataType and get content-type in the process
7667 while ( dataTypes[ 0 ] === "*" ) {
7668 dataTypes.shift();
7669 if ( ct === undefined ) {
7670 ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
7671 }
7672 }
7673
7674 // Check if we're dealing with a known content-type
7675 if ( ct ) {
7676 for ( type in contents ) {
7677 if ( contents[ type ] && contents[ type ].test( ct ) ) {
7678 dataTypes.unshift( type );
7679 break;
7680 }
7681 }
7682 }
7683
7684 // Check to see if we have a response for the expected dataType
7685 if ( dataTypes[ 0 ] in responses ) {
7686 finalDataType = dataTypes[ 0 ];
7687 } else {
7688 // Try convertible dataTypes
7689 for ( type in responses ) {
7690 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
7691 finalDataType = type;
7692 break;
7693 }
7694 if ( !firstDataType ) {
7695 firstDataType = type;
7696 }
7697 }
7698 // Or just use first one
7699 finalDataType = finalDataType || firstDataType;
7700 }
7701
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 );
7708 }
7709 return responses[ finalDataType ];
7710 }
7711}
7712
7713/* Chain conversions given the request and the original response
7714 * Also sets the responseXXX fields on the jqXHR instance
7715 */
7716function ajaxConvert( s, response, jqXHR, isSuccess ) {
7717 var conv2, current, conv, tmp, prev,
7718 converters = {},
7719 // Work with a copy of dataTypes in case we need to modify it for conversion
7720 dataTypes = s.dataTypes.slice();
7721
7722 // Create converters map with lowercased keys
7723 if ( dataTypes[ 1 ] ) {
7724 for ( conv in s.converters ) {
7725 converters[ conv.toLowerCase() ] = s.converters[ conv ];
7726 }
7727 }
7728
7729 current = dataTypes.shift();
7730
7731 // Convert to each sequential dataType
7732 while ( current ) {
7733
7734 if ( s.responseFields[ current ] ) {
7735 jqXHR[ s.responseFields[ current ] ] = response;
7736 }
7737
7738 // Apply the dataFilter if provided
7739 if ( !prev && isSuccess && s.dataFilter ) {
7740 response = s.dataFilter( response, s.dataType );
7741 }
7742
7743 prev = current;
7744 current = dataTypes.shift();
7745
7746 if ( current ) {
7747
7748 // There's only work to do if current dataType is non-auto
7749 if ( current === "*" ) {
7750
7751 current = prev;
7752
7753 // Convert response if prev dataType is non-auto and differs from current
7754 } else if ( prev !== "*" && prev !== current ) {
7755
7756 // Seek a direct converter
7757 conv = converters[ prev + " " + current ] || converters[ "* " + current ];
7758
7759 // If none found, seek a pair
7760 if ( !conv ) {
7761 for ( conv2 in converters ) {
7762
7763 // If conv2 outputs current
7764 tmp = conv2.split( " " );
7765 if ( tmp[ 1 ] === current ) {
7766
7767 // If prev can be converted to accepted input
7768 conv = converters[ prev + " " + tmp[ 0 ] ] ||
7769 converters[ "* " + tmp[ 0 ] ];
7770 if ( conv ) {
7771 // Condense equivalence converters
7772 if ( conv === true ) {
7773 conv = converters[ conv2 ];
7774
7775 // Otherwise, insert the intermediate dataType
7776 } else if ( converters[ conv2 ] !== true ) {
7777 current = tmp[ 0 ];
7778 dataTypes.unshift( tmp[ 1 ] );
7779 }
7780 break;
7781 }
7782 }
7783 }
7784 }
7785
7786 // Apply converter (if not an equivalence)
7787 if ( conv !== true ) {
7788
7789 // Unless errors are allowed to bubble, catch and return them
7790 if ( conv && s[ "throws" ] ) {
7791 response = conv( response );
7792 } else {
7793 try {
7794 response = conv( response );
7795 } catch ( e ) {
7796 return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
7797 }
7798 }
7799 }
7800 }
7801 }
7802 }
7803
7804 return { state: "success", data: response };
7805}
7806
7807jQuery.extend({
7808
7809 // Counter for holding the number of active queries
7810 active: 0,
7811
7812 // Last-Modified header cache for next request
7813 lastModified: {},
7814 etag: {},
7815
7816 ajaxSettings: {
7817 url: ajaxLocation,
7818 type: "GET",
7819 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
7820 global: true,
7821 processData: true,
7822 async: true,
7823 contentType: "application/x-www-form-urlencoded; charset=UTF-8",
7824 /*
7825 timeout: 0,
7826 data: null,
7827 dataType: null,
7828 username: null,
7829 password: null,
7830 cache: null,
7831 throws: false,
7832 traditional: false,
7833 headers: {},
7834 */
7835
7836 accepts: {
7837 "*": allTypes,
7838 text: "text/plain",
7839 html: "text/html",
7840 xml: "application/xml, text/xml",
7841 json: "application/json, text/javascript"
7842 },
7843
7844 contents: {
7845 xml: /xml/,
7846 html: /html/,
7847 json: /json/
7848 },
7849
7850 responseFields: {
7851 xml: "responseXML",
7852 text: "responseText",
7853 json: "responseJSON"
7854 },
7855
7856 // Data converters
7857 // Keys separate source (or catchall "*") and destination types with a single space
7858 converters: {
7859
7860 // Convert anything to text
7861 "* text": String,
7862
7863 // Text to html (true = no transformation)
7864 "text html": true,
7865
7866 // Evaluate text as a json expression
7867 "text json": jQuery.parseJSON,
7868
7869 // Parse text as xml
7870 "text xml": jQuery.parseXML
7871 },
7872
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)
7877 flatOptions: {
7878 url: true,
7879 context: true
7880 }
7881 },
7882
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 ) {
7887 return settings ?
7888
7889 // Building a settings object
7890 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
7891
7892 // Extending ajaxSettings
7893 ajaxExtend( jQuery.ajaxSettings, target );
7894 },
7895
7896 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
7897 ajaxTransport: addToPrefiltersOrTransports( transports ),
7898
7899 // Main method
7900 ajax: function( url, options ) {
7901
7902 // If url is an object, simulate pre-1.5 signature
7903 if ( typeof url === "object" ) {
7904 options = url;
7905 url = undefined;
7906 }
7907
7908 // Force options to be an object
7909 options = options || {};
7910
7911 var transport,
7912 // URL without anti-cache param
7913 cacheURL,
7914 // Response headers
7915 responseHeadersString,
7916 responseHeaders,
7917 // timeout handle
7918 timeoutTimer,
7919 // Cross-domain detection vars
7920 parts,
7921 // To know if global events are to be dispatched
7922 fireGlobals,
7923 // Loop variable
7924 i,
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 ) :
7932 jQuery.event,
7933 // Deferreds
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 = {},
7941 // The jqXHR state
7942 state = 0,
7943 // Default abort message
7944 strAbort = "canceled",
7945 // Fake xhr
7946 jqXHR = {
7947 readyState: 0,
7948
7949 // Builds headers hashtable if needed
7950 getResponseHeader: function( key ) {
7951 var match;
7952 if ( state === 2 ) {
7953 if ( !responseHeaders ) {
7954 responseHeaders = {};
7955 while ( (match = rheaders.exec( responseHeadersString )) ) {
7956 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
7957 }
7958 }
7959 match = responseHeaders[ key.toLowerCase() ];
7960 }
7961 return match == null ? null : match;
7962 },
7963
7964 // Raw string
7965 getAllResponseHeaders: function() {
7966 return state === 2 ? responseHeadersString : null;
7967 },
7968
7969 // Caches the header
7970 setRequestHeader: function( name, value ) {
7971 var lname = name.toLowerCase();
7972 if ( !state ) {
7973 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
7974 requestHeaders[ name ] = value;
7975 }
7976 return this;
7977 },
7978
7979 // Overrides response content-type header
7980 overrideMimeType: function( type ) {
7981 if ( !state ) {
7982 s.mimeType = type;
7983 }
7984 return this;
7985 },
7986
7987 // Status-dependent callbacks
7988 statusCode: function( map ) {
7989 var code;
7990 if ( map ) {
7991 if ( state < 2 ) {
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 ] ];
7995 }
7996 } else {
7997 // Execute the appropriate callbacks
7998 jqXHR.always( map[ jqXHR.status ] );
7999 }
8000 }
8001 return this;
8002 },
8003
8004 // Cancel the request
8005 abort: function( statusText ) {
8006 var finalText = statusText || strAbort;
8007 if ( transport ) {
8008 transport.abort( finalText );
8009 }
8010 done( 0, finalText );
8011 return this;
8012 }
8013 };
8014
8015 // Attach deferreds
8016 deferred.promise( jqXHR ).complete = completeDeferred.add;
8017 jqXHR.success = jqXHR.done;
8018 jqXHR.error = jqXHR.fail;
8019
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 ] + "//" );
8026
8027 // Alias method option to type as per ticket #12004
8028 s.type = options.method || options.type || s.method || s.type;
8029
8030 // Extract dataTypes list
8031 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
8032
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" ) ) )
8040 );
8041 }
8042
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 );
8046 }
8047
8048 // Apply prefilters
8049 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
8050
8051 // If request was aborted inside a prefilter, stop there
8052 if ( state === 2 ) {
8053 return jqXHR;
8054 }
8055
8056 // We can fire global events as of now if asked to
8057 fireGlobals = s.global;
8058
8059 // Watch for a new set of requests
8060 if ( fireGlobals && jQuery.active++ === 0 ) {
8061 jQuery.event.trigger("ajaxStart");
8062 }
8063
8064 // Uppercase the type
8065 s.type = s.type.toUpperCase();
8066
8067 // Determine if request has content
8068 s.hasContent = !rnoContent.test( s.type );
8069
8070 // Save the URL in case we're toying with the If-Modified-Since
8071 // and/or If-None-Match header later on
8072 cacheURL = s.url;
8073
8074 // More options handling for requests with no content
8075 if ( !s.hasContent ) {
8076
8077 // If data is available, append data to url
8078 if ( s.data ) {
8079 cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
8080 // #9682: remove data so that it's not used in an eventual retry
8081 delete s.data;
8082 }
8083
8084 // Add anti-cache in url if needed
8085 if ( s.cache === false ) {
8086 s.url = rts.test( cacheURL ) ?
8087
8088 // If there is already a '_' parameter, set its value
8089 cacheURL.replace( rts, "$1_=" + nonce++ ) :
8090
8091 // Otherwise add one to the end
8092 cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
8093 }
8094 }
8095
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 ] );
8100 }
8101 if ( jQuery.etag[ cacheURL ] ) {
8102 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
8103 }
8104 }
8105
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 );
8109 }
8110
8111 // Set the Accepts header for the server, depending on the dataType
8112 jqXHR.setRequestHeader(
8113 "Accept",
8114 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
8115 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
8116 s.accepts[ "*" ]
8117 );
8118
8119 // Check for headers option
8120 for ( i in s.headers ) {
8121 jqXHR.setRequestHeader( i, s.headers[ i ] );
8122 }
8123
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();
8128 }
8129
8130 // aborting is no longer a cancellation
8131 strAbort = "abort";
8132
8133 // Install callbacks on deferreds
8134 for ( i in { success: 1, error: 1, complete: 1 } ) {
8135 jqXHR[ i ]( s[ i ] );
8136 }
8137
8138 // Get transport
8139 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
8140
8141 // If no transport, we auto-abort
8142 if ( !transport ) {
8143 done( -1, "No Transport" );
8144 } else {
8145 jqXHR.readyState = 1;
8146
8147 // Send global event
8148 if ( fireGlobals ) {
8149 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
8150 }
8151 // Timeout
8152 if ( s.async && s.timeout > 0 ) {
8153 timeoutTimer = setTimeout(function() {
8154 jqXHR.abort("timeout");
8155 }, s.timeout );
8156 }
8157
8158 try {
8159 state = 1;
8160 transport.send( requestHeaders, done );
8161 } catch ( e ) {
8162 // Propagate exception as error if not done
8163 if ( state < 2 ) {
8164 done( -1, e );
8165 // Simply rethrow otherwise
8166 } else {
8167 throw e;
8168 }
8169 }
8170 }
8171
8172 // Callback for when everything is done
8173 function done( status, nativeStatusText, responses, headers ) {
8174 var isSuccess, success, error, response, modified,
8175 statusText = nativeStatusText;
8176
8177 // Called once
8178 if ( state === 2 ) {
8179 return;
8180 }
8181
8182 // State is "done" now
8183 state = 2;
8184
8185 // Clear timeout if it exists
8186 if ( timeoutTimer ) {
8187 clearTimeout( timeoutTimer );
8188 }
8189
8190 // Dereference transport for early garbage collection
8191 // (no matter how long the jqXHR object will be used)
8192 transport = undefined;
8193
8194 // Cache response headers
8195 responseHeadersString = headers || "";
8196
8197 // Set readyState
8198 jqXHR.readyState = status > 0 ? 4 : 0;
8199
8200 // Determine if successful
8201 isSuccess = status >= 200 && status < 300 || status === 304;
8202
8203 // Get response data
8204 if ( responses ) {
8205 response = ajaxHandleResponses( s, jqXHR, responses );
8206 }
8207
8208 // Convert no matter what (that way responseXXX fields are always set)
8209 response = ajaxConvert( s, response, jqXHR, isSuccess );
8210
8211 // If successful, handle type chaining
8212 if ( isSuccess ) {
8213
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");
8217 if ( modified ) {
8218 jQuery.lastModified[ cacheURL ] = modified;
8219 }
8220 modified = jqXHR.getResponseHeader("etag");
8221 if ( modified ) {
8222 jQuery.etag[ cacheURL ] = modified;
8223 }
8224 }
8225
8226 // if no content
8227 if ( status === 204 || s.type === "HEAD" ) {
8228 statusText = "nocontent";
8229
8230 // if not modified
8231 } else if ( status === 304 ) {
8232 statusText = "notmodified";
8233
8234 // If we have data, let's convert it
8235 } else {
8236 statusText = response.state;
8237 success = response.data;
8238 error = response.error;
8239 isSuccess = !error;
8240 }
8241 } else {
8242 // We extract error from statusText
8243 // then normalize statusText and status for non-aborts
8244 error = statusText;
8245 if ( status || !statusText ) {
8246 statusText = "error";
8247 if ( status < 0 ) {
8248 status = 0;
8249 }
8250 }
8251 }
8252
8253 // Set data for the fake xhr object
8254 jqXHR.status = status;
8255 jqXHR.statusText = ( nativeStatusText || statusText ) + "";
8256
8257 // Success/Error
8258 if ( isSuccess ) {
8259 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
8260 } else {
8261 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
8262 }
8263
8264 // Status-dependent callbacks
8265 jqXHR.statusCode( statusCode );
8266 statusCode = undefined;
8267
8268 if ( fireGlobals ) {
8269 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
8270 [ jqXHR, s, isSuccess ? success : error ] );
8271 }
8272
8273 // Complete
8274 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
8275
8276 if ( fireGlobals ) {
8277 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
8278 // Handle the global AJAX counter
8279 if ( !( --jQuery.active ) ) {
8280 jQuery.event.trigger("ajaxStop");
8281 }
8282 }
8283 }
8284
8285 return jqXHR;
8286 },
8287
8288 getJSON: function( url, data, callback ) {
8289 return jQuery.get( url, data, callback, "json" );
8290 },
8291
8292 getScript: function( url, callback ) {
8293 return jQuery.get( url, undefined, callback, "script" );
8294 }
8295});
8296
8297jQuery.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;
8302 callback = data;
8303 data = undefined;
8304 }
8305
8306 return jQuery.ajax({
8307 url: url,
8308 type: method,
8309 dataType: type,
8310 data: data,
8311 success: callback
8312 });
8313 };
8314});
8315
8316// Attach a bunch of functions for handling common AJAX events
8317jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) {
8318 jQuery.fn[ type ] = function( fn ) {
8319 return this.on( type, fn );
8320 };
8321});
8322
8323
8324jQuery._evalUrl = function( url ) {
8325 return jQuery.ajax({
8326 url: url,
8327 type: "GET",
8328 dataType: "script",
8329 async: false,
8330 global: false,
8331 "throws": true
8332 });
8333};
8334
8335
8336jQuery.fn.extend({
8337 wrapAll: function( html ) {
8338 var wrap;
8339
8340 if ( jQuery.isFunction( html ) ) {
8341 return this.each(function( i ) {
8342 jQuery( this ).wrapAll( html.call(this, i) );
8343 });
8344 }
8345
8346 if ( this[ 0 ] ) {
8347
8348 // The elements to wrap the target around
8349 wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
8350
8351 if ( this[ 0 ].parentNode ) {
8352 wrap.insertBefore( this[ 0 ] );
8353 }
8354
8355 wrap.map(function() {
8356 var elem = this;
8357
8358 while ( elem.firstElementChild ) {
8359 elem = elem.firstElementChild;
8360 }
8361
8362 return elem;
8363 }).append( this );
8364 }
8365
8366 return this;
8367 },
8368
8369 wrapInner: function( html ) {
8370 if ( jQuery.isFunction( html ) ) {
8371 return this.each(function( i ) {
8372 jQuery( this ).wrapInner( html.call(this, i) );
8373 });
8374 }
8375
8376 return this.each(function() {
8377 var self = jQuery( this ),
8378 contents = self.contents();
8379
8380 if ( contents.length ) {
8381 contents.wrapAll( html );
8382
8383 } else {
8384 self.append( html );
8385 }
8386 });
8387 },
8388
8389 wrap: function( html ) {
8390 var isFunction = jQuery.isFunction( html );
8391
8392 return this.each(function( i ) {
8393 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
8394 });
8395 },
8396
8397 unwrap: function() {
8398 return this.parent().each(function() {
8399 if ( !jQuery.nodeName( this, "body" ) ) {
8400 jQuery( this ).replaceWith( this.childNodes );
8401 }
8402 }).end();
8403 }
8404});
8405
8406
8407jQuery.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;
8411};
8412jQuery.expr.filters.visible = function( elem ) {
8413 return !jQuery.expr.filters.hidden( elem );
8414};
8415
8416
8417
8418
8419var r20 = /%20/g,
8420 rbracket = /\[\]$/,
8421 rCRLF = /\r?\n/g,
8422 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
8423 rsubmittable = /^(?:input|select|textarea|keygen)/i;
8424
8425function buildParams( prefix, obj, traditional, add ) {
8426 var name;
8427
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.
8433 add( prefix, v );
8434
8435 } else {
8436 // Item is non-scalar (array or object), encode its numeric index.
8437 buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
8438 }
8439 });
8440
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 );
8445 }
8446
8447 } else {
8448 // Serialize scalar item.
8449 add( prefix, obj );
8450 }
8451}
8452
8453// Serialize an array of form elements or a set of
8454// key/values into a query string
8455jQuery.param = function( a, traditional ) {
8456 var prefix,
8457 s = [],
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 );
8462 };
8463
8464 // Set traditional to true for jQuery <= 1.3.2 behavior.
8465 if ( traditional === undefined ) {
8466 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
8467 }
8468
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 );
8474 });
8475
8476 } else {
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 );
8481 }
8482 }
8483
8484 // Return the resulting serialization
8485 return s.join( "&" ).replace( r20, "+" );
8486};
8487
8488jQuery.fn.extend({
8489 serialize: function() {
8490 return jQuery.param( this.serializeArray() );
8491 },
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;
8497 })
8498 .filter(function() {
8499 var type = this.type;
8500
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 ) );
8505 })
8506 .map(function( i, elem ) {
8507 var val = jQuery( this ).val();
8508
8509 return val == null ?
8510 null :
8511 jQuery.isArray( val ) ?
8512 jQuery.map( val, function( val ) {
8513 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
8514 }) :
8515 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
8516 }).get();
8517 }
8518});
8519
8520
8521jQuery.ajaxSettings.xhr = function() {
8522 try {
8523 return new XMLHttpRequest();
8524 } catch( e ) {}
8525};
8526
8527var xhrId = 0,
8528 xhrCallbacks = {},
8529 xhrSuccessStatus = {
8530 // file protocol always yields status code 0, assume 200
8531 0: 200,
8532 // Support: IE9
8533 // #1450: sometimes IE returns 1223 when it should be 204
8534 1223: 204
8535 },
8536 xhrSupported = jQuery.ajaxSettings.xhr();
8537
8538// Support: IE9
8539// Open requests must be manually aborted on unload (#5280)
8540if ( window.ActiveXObject ) {
8541 jQuery( window ).on( "unload", function() {
8542 for ( var key in xhrCallbacks ) {
8543 xhrCallbacks[ key ]();
8544 }
8545 });
8546}
8547
8548support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
8549support.ajax = xhrSupported = !!xhrSupported;
8550
8551jQuery.ajaxTransport(function( options ) {
8552 var callback;
8553
8554 // Cross domain only allowed if supported through XMLHttpRequest
8555 if ( support.cors || xhrSupported && !options.crossDomain ) {
8556 return {
8557 send: function( headers, complete ) {
8558 var i,
8559 xhr = options.xhr(),
8560 id = ++xhrId;
8561
8562 xhr.open( options.type, options.url, options.async, options.username, options.password );
8563
8564 // Apply custom fields if provided
8565 if ( options.xhrFields ) {
8566 for ( i in options.xhrFields ) {
8567 xhr[ i ] = options.xhrFields[ i ];
8568 }
8569 }
8570
8571 // Override mime type if needed
8572 if ( options.mimeType && xhr.overrideMimeType ) {
8573 xhr.overrideMimeType( options.mimeType );
8574 }
8575
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";
8583 }
8584
8585 // Set headers
8586 for ( i in headers ) {
8587 xhr.setRequestHeader( i, headers[ i ] );
8588 }
8589
8590 // Callback
8591 callback = function( type ) {
8592 return function() {
8593 if ( callback ) {
8594 delete xhrCallbacks[ id ];
8595 callback = xhr.onload = xhr.onerror = null;
8596
8597 if ( type === "abort" ) {
8598 xhr.abort();
8599 } else if ( type === "error" ) {
8600 complete(
8601 // file: protocol always yields status 0; see #8605, #14207
8602 xhr.status,
8603 xhr.statusText
8604 );
8605 } else {
8606 complete(
8607 xhrSuccessStatus[ xhr.status ] || xhr.status,
8608 xhr.statusText,
8609 // Support: IE9
8610 // Accessing binary-data responseText throws an exception
8611 // (#11426)
8612 typeof xhr.responseText === "string" ? {
8613 text: xhr.responseText
8614 } : undefined,
8615 xhr.getAllResponseHeaders()
8616 );
8617 }
8618 }
8619 };
8620 };
8621
8622 // Listen to events
8623 xhr.onload = callback();
8624 xhr.onerror = callback("error");
8625
8626 // Create the abort callback
8627 callback = xhrCallbacks[ id ] = callback("abort");
8628
8629 try {
8630 // Do send the request (this may raise an exception)
8631 xhr.send( options.hasContent && options.data || null );
8632 } catch ( e ) {
8633 // #14683: Only rethrow if this hasn't been notified as an error yet
8634 if ( callback ) {
8635 throw e;
8636 }
8637 }
8638 },
8639
8640 abort: function() {
8641 if ( callback ) {
8642 callback();
8643 }
8644 }
8645 };
8646 }
8647});
8648
8649
8650
8651
8652// Install script dataType
8653jQuery.ajaxSetup({
8654 accepts: {
8655 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
8656 },
8657 contents: {
8658 script: /(?:java|ecma)script/
8659 },
8660 converters: {
8661 "text script": function( text ) {
8662 jQuery.globalEval( text );
8663 return text;
8664 }
8665 }
8666});
8667
8668// Handle cache's special case and crossDomain
8669jQuery.ajaxPrefilter( "script", function( s ) {
8670 if ( s.cache === undefined ) {
8671 s.cache = false;
8672 }
8673 if ( s.crossDomain ) {
8674 s.type = "GET";
8675 }
8676});
8677
8678// Bind script tag hack transport
8679jQuery.ajaxTransport( "script", function( s ) {
8680 // This transport only deals with cross domain requests
8681 if ( s.crossDomain ) {
8682 var script, callback;
8683 return {
8684 send: function( _, complete ) {
8685 script = jQuery("<script>").prop({
8686 async: true,
8687 charset: s.scriptCharset,
8688 src: s.url
8689 }).on(
8690 "load error",
8691 callback = function( evt ) {
8692 script.remove();
8693 callback = null;
8694 if ( evt ) {
8695 complete( evt.type === "error" ? 404 : 200, evt.type );
8696 }
8697 }
8698 );
8699 document.head.appendChild( script[ 0 ] );
8700 },
8701 abort: function() {
8702 if ( callback ) {
8703 callback();
8704 }
8705 }
8706 };
8707 }
8708});
8709
8710
8711
8712
8713var oldCallbacks = [],
8714 rjsonp = /(=)\?(?=&|$)|\?\?/;
8715
8716// Default jsonp settings
8717jQuery.ajaxSetup({
8718 jsonp: "callback",
8719 jsonpCallback: function() {
8720 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
8721 this[ callback ] = true;
8722 return callback;
8723 }
8724});
8725
8726// Detect, normalize options and install callbacks for jsonp requests
8727jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
8728
8729 var callbackName, overwritten, responseContainer,
8730 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
8731 "url" :
8732 typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
8733 );
8734
8735 // Handle iff the expected data type is "jsonp" or we have a parameter to set
8736 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
8737
8738 // Get callback name, remembering preexisting value associated with it
8739 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
8740 s.jsonpCallback() :
8741 s.jsonpCallback;
8742
8743 // Insert callback into url or form data
8744 if ( jsonProp ) {
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;
8748 }
8749
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" );
8754 }
8755 return responseContainer[ 0 ];
8756 };
8757
8758 // force json dataType
8759 s.dataTypes[ 0 ] = "json";
8760
8761 // Install callback
8762 overwritten = window[ callbackName ];
8763 window[ callbackName ] = function() {
8764 responseContainer = arguments;
8765 };
8766
8767 // Clean-up function (fires after converters)
8768 jqXHR.always(function() {
8769 // Restore preexisting value
8770 window[ callbackName ] = overwritten;
8771
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;
8776
8777 // save the callback name for future use
8778 oldCallbacks.push( callbackName );
8779 }
8780
8781 // Call if it was a function and we have a response
8782 if ( responseContainer && jQuery.isFunction( overwritten ) ) {
8783 overwritten( responseContainer[ 0 ] );
8784 }
8785
8786 responseContainer = overwritten = undefined;
8787 });
8788
8789 // Delegate to script
8790 return "script";
8791 }
8792});
8793
8794
8795
8796
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
8800jQuery.parseHTML = function( data, context, keepScripts ) {
8801 if ( !data || typeof data !== "string" ) {
8802 return null;
8803 }
8804 if ( typeof context === "boolean" ) {
8805 keepScripts = context;
8806 context = false;
8807 }
8808 context = context || document;
8809
8810 var parsed = rsingleTag.exec( data ),
8811 scripts = !keepScripts && [];
8812
8813 // Single tag
8814 if ( parsed ) {
8815 return [ context.createElement( parsed[1] ) ];
8816 }
8817
8818 parsed = jQuery.buildFragment( [ data ], context, scripts );
8819
8820 if ( scripts && scripts.length ) {
8821 jQuery( scripts ).remove();
8822 }
8823
8824 return jQuery.merge( [], parsed.childNodes );
8825};
8826
8827
8828// Keep a copy of the old load method
8829var _load = jQuery.fn.load;
8830
8831/**
8832 * Load a url into a page
8833 */
8834jQuery.fn.load = function( url, params, callback ) {
8835 if ( typeof url !== "string" && _load ) {
8836 return _load.apply( this, arguments );
8837 }
8838
8839 var selector, type, response,
8840 self = this,
8841 off = url.indexOf(" ");
8842
8843 if ( off >= 0 ) {
8844 selector = jQuery.trim( url.slice( off ) );
8845 url = url.slice( 0, off );
8846 }
8847
8848 // If it's a function
8849 if ( jQuery.isFunction( params ) ) {
8850
8851 // We assume that it's the callback
8852 callback = params;
8853 params = undefined;
8854
8855 // Otherwise, build a param string
8856 } else if ( params && typeof params === "object" ) {
8857 type = "POST";
8858 }
8859
8860 // If we have elements to modify, make the request
8861 if ( self.length > 0 ) {
8862 jQuery.ajax({
8863 url: url,
8864
8865 // if "type" variable is undefined, then "GET" method will be used
8866 type: type,
8867 dataType: "html",
8868 data: params
8869 }).done(function( responseText ) {
8870
8871 // Save response for use in complete callback
8872 response = arguments;
8873
8874 self.html( selector ?
8875
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 ) :
8879
8880 // Otherwise use the full result
8881 responseText );
8882
8883 }).complete( callback && function( jqXHR, status ) {
8884 self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
8885 });
8886 }
8887
8888 return this;
8889};
8890
8891
8892
8893
8894jQuery.expr.filters.animated = function( elem ) {
8895 return jQuery.grep(jQuery.timers, function( fn ) {
8896 return elem === fn.elem;
8897 }).length;
8898};
8899
8900
8901
8902
8903var docElem = window.document.documentElement;
8904
8905/**
8906 * Gets a window from an element
8907 */
8908function getWindow( elem ) {
8909 return jQuery.isWindow( elem ) ? elem : elem.nodeType === 9 && elem.defaultView;
8910}
8911
8912jQuery.offset = {
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 ),
8917 props = {};
8918
8919 // Set position first, in-case top/left are set even on static elem
8920 if ( position === "static" ) {
8921 elem.style.position = "relative";
8922 }
8923
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;
8929
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;
8935
8936 } else {
8937 curTop = parseFloat( curCSSTop ) || 0;
8938 curLeft = parseFloat( curCSSLeft ) || 0;
8939 }
8940
8941 if ( jQuery.isFunction( options ) ) {
8942 options = options.call( elem, i, curOffset );
8943 }
8944
8945 if ( options.top != null ) {
8946 props.top = ( options.top - curOffset.top ) + curTop;
8947 }
8948 if ( options.left != null ) {
8949 props.left = ( options.left - curOffset.left ) + curLeft;
8950 }
8951
8952 if ( "using" in options ) {
8953 options.using.call( elem, props );
8954
8955 } else {
8956 curElem.css( props );
8957 }
8958 }
8959};
8960
8961jQuery.fn.extend({
8962 offset: function( options ) {
8963 if ( arguments.length ) {
8964 return options === undefined ?
8965 this :
8966 this.each(function( i ) {
8967 jQuery.offset.setOffset( this, options, i );
8968 });
8969 }
8970
8971 var docElem, win,
8972 elem = this[ 0 ],
8973 box = { top: 0, left: 0 },
8974 doc = elem && elem.ownerDocument;
8975
8976 if ( !doc ) {
8977 return;
8978 }
8979
8980 docElem = doc.documentElement;
8981
8982 // Make sure it's not a disconnected DOM node
8983 if ( !jQuery.contains( docElem, elem ) ) {
8984 return box;
8985 }
8986
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();
8991 }
8992 win = getWindow( doc );
8993 return {
8994 top: box.top + win.pageYOffset - docElem.clientTop,
8995 left: box.left + win.pageXOffset - docElem.clientLeft
8996 };
8997 },
8998
8999 position: function() {
9000 if ( !this[ 0 ] ) {
9001 return;
9002 }
9003
9004 var offsetParent, offset,
9005 elem = this[ 0 ],
9006 parentOffset = { top: 0, left: 0 };
9007
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();
9012
9013 } else {
9014 // Get *real* offsetParent
9015 offsetParent = this.offsetParent();
9016
9017 // Get correct offsets
9018 offset = this.offset();
9019 if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
9020 parentOffset = offsetParent.offset();
9021 }
9022
9023 // Add offsetParent borders
9024 parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
9025 parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
9026 }
9027
9028 // Subtract parent offsets and element margins
9029 return {
9030 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
9031 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
9032 };
9033 },
9034
9035 offsetParent: function() {
9036 return this.map(function() {
9037 var offsetParent = this.offsetParent || docElem;
9038
9039 while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position" ) === "static" ) ) {
9040 offsetParent = offsetParent.offsetParent;
9041 }
9042
9043 return offsetParent || docElem;
9044 });
9045 }
9046});
9047
9048// Create scrollLeft and scrollTop methods
9049jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
9050 var top = "pageYOffset" === prop;
9051
9052 jQuery.fn[ method ] = function( val ) {
9053 return access( this, function( elem, method, val ) {
9054 var win = getWindow( elem );
9055
9056 if ( val === undefined ) {
9057 return win ? win[ prop ] : elem[ method ];
9058 }
9059
9060 if ( win ) {
9061 win.scrollTo(
9062 !top ? val : window.pageXOffset,
9063 top ? val : window.pageYOffset
9064 );
9065
9066 } else {
9067 elem[ method ] = val;
9068 }
9069 }, method, val, arguments.length, null );
9070 };
9071});
9072
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
9077jQuery.each( [ "top", "left" ], function( i, prop ) {
9078 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
9079 function( elem, computed ) {
9080 if ( 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" :
9085 computed;
9086 }
9087 }
9088 );
9089});
9090
9091
9092// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
9093jQuery.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" );
9099
9100 return access( this, function( elem, type, value ) {
9101 var doc;
9102
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 ];
9108 }
9109
9110 // Get document width or height
9111 if ( elem.nodeType === 9 ) {
9112 doc = elem.documentElement;
9113
9114 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
9115 // whichever is greatest
9116 return Math.max(
9117 elem.body[ "scroll" + name ], doc[ "scroll" + name ],
9118 elem.body[ "offset" + name ], doc[ "offset" + name ],
9119 doc[ "client" + name ]
9120 );
9121 }
9122
9123 return value === undefined ?
9124 // Get width or height on the element, requesting but not forcing parseFloat
9125 jQuery.css( elem, type, extra ) :
9126
9127 // Set width or height on the element
9128 jQuery.style( elem, type, value, extra );
9129 }, type, chainable ? margin : undefined, chainable, null );
9130 };
9131 });
9132});
9133
9134
9135// The number of elements contained in the matched element set
9136jQuery.fn.size = function() {
9137 return this.length;
9138};
9139
9140jQuery.fn.andSelf = jQuery.fn.addBack;
9141
9142
9143
9144
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.
9152
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
9157
9158if ( typeof define === "function" && define.amd ) {
9159 define( "jquery", [], function() {
9160 return jQuery;
9161 });
9162}
9163
9164
9165
9166
9167var
9168 // Map over jQuery in case of overwrite
9169 _jQuery = window.jQuery,
9170
9171 // Map over the $ in case of overwrite
9172 _$ = window.$;
9173
9174jQuery.noConflict = function( deep ) {
9175 if ( window.$ === jQuery ) {
9176 window.$ = _$;
9177 }
9178
9179 if ( deep && window.jQuery === jQuery ) {
9180 window.jQuery = _jQuery;
9181 }
9182
9183 return jQuery;
9184};
9185
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)
9189if ( typeof noGlobal === strundefined ) {
9190 window.jQuery = window.$ = jQuery;
9191}
9192
9193
9194
9195
9196return jQuery;
9197
9198}));
9199//
9200// HashiCorp Mega Nav
9201// --------------------------------------------------
9202
9203var HashiMegaNav = function() {
9204 var productClass = 'mega-nav-grid-item',
9205 productActiveClass = 'is-active',
9206 url = window.location.hostname,
9207 products = [
9208 'vagrant',
9209 'packer',
9210 'terraform',
9211 'vault',
9212 'nomad',
9213 'consul'
9214 ];
9215
9216 for (var i = 0; i < products.length; i++) {
9217 if (url.indexOf(products[i]) !== -1) {
9218 $('.' + productClass + '-' + products[i]).addClass(productActiveClass);
9219 }
9220 }
9221
9222 var $body = $('#mega-nav-body-ct');
9223 var $arrow = $('#mega-nav-ctrl');
9224 var $nav = $arrow.parent();
9225 var $close = $('#mega-nav-close');
9226
9227 function matchesBreakpoint() {
9228 return window.matchMedia("(min-width: 980px)").matches;
9229 }
9230
9231 function openNav() {
9232 if(matchesBreakpoint()) {
9233 $body.slideDown('fast');
9234 $nav.addClass('open');
9235 } else {
9236 $body.fadeIn('fast');
9237 }
9238 }
9239
9240 function closeNav() {
9241 if(matchesBreakpoint()) {
9242 $body.slideUp('fast');
9243 $nav.removeClass('open');
9244 } else {
9245 $body.fadeOut('fast');
9246 }
9247 }
9248
9249 function isNavOpen() {
9250 return $nav.hasClass('open');
9251 }
9252
9253 $arrow.unbind().on('click', function(e) {
9254 e.preventDefault(); // Don't jump page to "#"
9255
9256 if(isNavOpen()) {
9257 closeNav();
9258 } else {
9259 openNav();
9260 }
9261 });
9262
9263 $close.unbind().on('click', function() {
9264 closeNav();
9265 });
9266}
9267
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.
9272var HashiSidebar = function() {
9273 var $sidebar = $('.sidebar');
9274 var $toggle = $('.navbar-toggle');
9275 var $overlay = $('.sidebar-overlay');
9276
9277 function sidebarActive() {
9278 return $sidebar.hasClass('open');
9279 }
9280
9281 function hideSidebar() {
9282 if(sidebarActive()) {
9283 $sidebar.removeClass('open');
9284 $overlay.removeClass('active');
9285 }
9286 }
9287
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){
9291 hideSidebar();
9292 });
9293
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 "#"
9297
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
9300 // elements.
9301 if(!sidebarActive()) {
9302 $overlay.addClass('active');
9303 $sidebar.toggleClass('open');
9304 }
9305 });
9306}
9307
9308// Handle document ready function and the turbolinks load.
9309$(document).on("ready turbolinks:load", HashiSidebar);
9310'use strict'
9311
9312/**
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
9318 */
9319function track(selector, cb, link) {
9320 each(document.querySelectorAll(selector), function(el) {
9321 var params = cb
9322 if (typeof cb === 'function') {
9323 params = cb(el)
9324 }
9325 var event = params.event
9326 delete params.event
9327 if (link) {
9328 analytics.trackLink(el, event, params)
9329 } else {
9330 el.addEventListener('click', function() {
9331 analytics.track(event, params)
9332 })
9333 }
9334 })
9335}
9336
9337/**
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
9342 */
9343function each(list, cb) {
9344 for (var i = 0; i < list.length; i++) {
9345 cb(list[i], i)
9346 }
9347}
9348
9349// Expose as commonjs for module bundlers if needed
9350if (typeof module !== 'undefined' && module.exports) {
9351 module.exports = { track: track }
9352}
9353;
9354document.addEventListener('turbolinks:load', function() {
9355 analytics.page()
9356
9357 track('.downloads .download .details li a', function(el) {
9358 var m = el.href.match(/terraform_(.*?)_(.*?)_(.*?)\.zip/)
9359 return {
9360 event: 'Download',
9361 category: 'Button',
9362 label: 'Terraform | v' + m[1] + ' | ' + m[2] + ' | ' + m[3],
9363 version: m[1],
9364 os: m[2],
9365 architecture: m[3],
9366 product: 'terraform'
9367 }
9368 })
9369})
9370;
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380// Set up terraform.io UI helpers
9381document.addEventListener("turbolinks:load", function() {
9382 "use strict";
9383
9384 // SIDEBAR STUFF:
9385 // - "subNavs" are <li> elements with a nested <ul> as a direct child.
9386 // - The <a> child is the "header" of the subnav, and the <ul> is its "content."
9387 // - Subnavs are collapsed (<ul> hidden) or expanded (<ul> visible).
9388 // - Collapse/expand is managed by the "active" class on the <li>.
9389
9390 // Collapse most subnavs, but reveal any that contain the
9391 // current page. The a.current-page class is added during build by
9392 // layouts/inner.erb.
9393 var docsSidebar = $("#docs-sidebar ul.nav.docs-sidenav");
9394 var subNavs = docsSidebar.find("ul").addClass("nav-hidden").parent("li");
9395 // we leave the nav-hidden class alone after this.
9396 function resetActiveSubnavs() {
9397 subNavs.removeClass("active");
9398 // Activate current page, locked-open navs, and all their parents:
9399 docsSidebar.find("li").has(".current-page, .nav-visible").addClass("active");
9400 }
9401 resetActiveSubnavs();
9402
9403 // CSS class that adds toggle controls:
9404 subNavs.addClass("has-subnav");
9405 // Toggle subnav expansion when clicking an area that isn't claimed by the
9406 // header or content (usually the :before pseudo-element)
9407 subNavs.on("click", function(e) {
9408 if (e.target == this) {
9409 $(this).toggleClass("active");
9410 }
9411 e.stopPropagation();
9412 });
9413 // If the subnav header doesn't link to a different page, use it as a toggle.
9414 docsSidebar.find("a[href^='#']").on("click", function(e) {
9415 e.preventDefault();
9416 $(this).parent("li").trigger("click");
9417 });
9418
9419 // If this is a Very Large Sidebar, add extra controls to expand/collapse
9420 // and filter it.
9421 var sidebarLinks = docsSidebar.find("a");
9422 if (sidebarLinks.length > 30) {
9423 if ($("#sidebar-controls").length === 0) { // then add it!
9424 var sidebarControlsHTML =
9425 '<div id="sidebar-controls">' +
9426 '<div id="sidebar-filter">' +
9427 '<span class="glyphicon glyphicon-search"></span>' +
9428 '<label for="sidebar-filter-field" class="sr-only sr-only-focusable">Filter page titles in sidebar navigation</label>' +
9429 '<input type="search" id="sidebar-filter-field" class="form-control" name="sidebar-filter-field" role="search" placeholder="Filter page titles" />' +
9430 '<button id="filter-close" class="glyphicon glyphicon-remove-circle" title="Reset filter"><span class="sr-only sr-only-focusable">Reset sidebar filter</span></button>' +
9431 '</div>' +
9432 '<div id="sidebar-buttons">' +
9433 '<button id="toggle-button">Expand all</button>' +
9434 ' | ' +
9435 '<button id="filter-button" title="Shortcut: type the / key">Filter</button>' +
9436 '</div>' +
9437 '</div>';
9438 var sidebarHeader = $("#docs-sidebar").children("h1,h2,h3,h4,h5,h6").not("#otherdocs").first();
9439 if (sidebarHeader.length === 1) { // under first header
9440 sidebarHeader.after(sidebarControlsHTML);
9441 } else { // under skip link
9442 $("#docs-sidebar #controls-placeholder").replaceWith(sidebarControlsHTML);
9443 }
9444 }
9445
9446 var filterDiv = $("div#sidebar-filter");
9447 var buttonsDiv = $("div#sidebar-buttons");
9448 var subnavToggle = $("#sidebar-controls #toggle-button");
9449 var filterField = $("#sidebar-controls input#sidebar-filter-field");
9450 var filterButton = $("#filter-button");
9451
9452 filterDiv.hide();
9453
9454 filterButton.on("click", function(e) {
9455 buttonsDiv.hide();
9456 filterDiv.show();
9457 filterField.focus();
9458 });
9459
9460 // Filter field's close button: defer to reset button.
9461 $("#filter-close").on("click", function(e) {
9462 subnavToggle.trigger("reset");
9463 });
9464
9465 // Expand/reset button behavior:
9466 subnavToggle.on({
9467 "taint": function(e) {
9468 $(this).html("Reset");
9469 },
9470 "reset": function(e) {
9471 filterField.val("");
9472 filterField.trigger("blur");
9473 sidebarLinks.parent("li").show();
9474 resetActiveSubnavs();
9475 $(this).html("Expand all");
9476 buttonsDiv.show();
9477 filterDiv.hide();
9478 },
9479 "click": function(e) {
9480 e.preventDefault();
9481 if ($(this).text() === "Expand all") {
9482 subNavs.addClass("active");
9483 $(this).trigger("taint");
9484 } else {
9485 $(this).trigger("reset");
9486 }
9487 }
9488 });
9489
9490 // Filter as you type. This alters three things:
9491 // - "active" class on subnavs
9492 // - direct show/hide of <li>s
9493 // - state of subnavToggle button
9494 // We rely on subnavToggle's "reset" event to clean up when done.
9495 filterField.on('keyup', function(e) {
9496 if (e.keyCode === 27) { // escape key
9497 subnavToggle.trigger("reset");
9498 } else {
9499 subnavToggle.trigger("taint");
9500 var filterRegexp = new RegExp(filterField.val(), 'i');
9501 var matchingLinks = sidebarLinks.filter(function(index) {
9502 return $(this).text().match(filterRegexp);
9503 });
9504 sidebarLinks.parent('li').hide();
9505 subNavs.removeClass('active'); // cleans up partial as-you-type searches
9506 // make matches and their parents visible and expanded:
9507 matchingLinks.parents('li').show().filter(subNavs).addClass('active');
9508 // make direct children visible (if your search caught a subnav directly):
9509 matchingLinks.parent('li').find('li').show();
9510 }
9511 });
9512 // Type slash to focus sidebar filter:
9513 $("body").keydown(function(e) {
9514 // 191 = / (forward slash) key
9515 if (e.keyCode !== 191) {
9516 return;
9517 }
9518 var focusedElementType = $(document.activeElement).get(0).tagName.toLowerCase();
9519 if (focusedElementType !== "textarea" && focusedElementType !== "input") {
9520 e.preventDefault();
9521 filterButton.trigger("click");
9522 }
9523 });
9524 }
9525
9526
9527 // On docs/content pages, add a hierarchical quick nav menu if there are
9528 // more than two H2/H3/H4 headers.
9529 var headers = $('#inner').find('h2, h3, h4');
9530 if (headers.length > 2 && $("div#inner-quicknav").length === 0) {
9531 // Build the quick-nav HTML:
9532 $("#inner h1").first().after(
9533 '<div id="inner-quicknav">' +
9534 '<span id="inner-quicknav-trigger">' +
9535 'Jump to Section' +
9536 '<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>' +
9537 '</span>' +
9538 '<ul class="dropdown"></ul>' +
9539 '</div>'
9540 );
9541 var quickNav = $('#inner-quicknav > ul.dropdown');
9542 headers.each(function(index, element) {
9543 var level = element.nodeName.toLowerCase();
9544 var header_text = $(element).text();
9545 var header_id = $(element).attr('id');
9546 quickNav.append('<li class="level-' + level + '"><a href="#' + header_id + '">' + header_text + '</a></li>');
9547 });
9548 // Attach event listeners:
9549 // Trigger opens and closes.
9550 $('#inner-quicknav #inner-quicknav-trigger').on('click', function(e) {
9551 $(this).siblings('ul').toggleClass('active');
9552 e.stopPropagation();
9553 });
9554 // Clicking inside the quick-nav doesn't close it.
9555 quickNav.on('click', function(e) {
9556 e.stopPropagation();
9557 });
9558 // Jumping to a section means you're done with the quick-nav.
9559 quickNav.find('li a').on('click', function() {
9560 quickNav.removeClass('active');
9561 });
9562 // Clicking outside the quick-nav closes it.
9563 $('body').on('click', function() {
9564 quickNav.removeClass('active');
9565 });
9566 }
9567});