24 lines
99 KiB
JavaScript
24 lines
99 KiB
JavaScript
![]() |
(function(global,factory){typeof exports==='object'&&typeof module!=='undefined'?factory(exports):typeof define==='function'&&define.amd?define(['exports'],factory):(global=typeof globalThis!=='undefined'?globalThis:global||self,factory(global.Turbo={}))})(this,(function(exports){'use strict';(function(){if(window.Reflect===undefined||window.customElements===undefined||window.customElements.polyfillWrapFlushCallback){return}const BuiltInHTMLElement=HTMLElement;const wrapperForTheName={HTMLElement:function HTMLElement(){return Reflect.construct(BuiltInHTMLElement,[],this.constructor)}};window.HTMLElement=wrapperForTheName["HTMLElement"];HTMLElement.prototype=BuiltInHTMLElement.prototype;HTMLElement.prototype.constructor=HTMLElement;Object.setPrototypeOf(HTMLElement,BuiltInHTMLElement)})();(function(prototype){if(typeof prototype.requestSubmit=="function"){return}prototype.requestSubmit=function(submitter){if(submitter){validateSubmitter(submitter,this);submitter.click()}else{submitter=document.createElement("input");submitter.type="submit";submitter.hidden=true;this.appendChild(submitter);submitter.click();this.removeChild(submitter)}};function validateSubmitter(submitter,form){submitter instanceof HTMLElement||raise(TypeError,"parameter 1 is not of type 'HTMLElement'");submitter.type=="submit"||raise(TypeError,"The specified element is not a submit button");submitter.form==form||raise(DOMException,"The specified element is not owned by this form element","NotFoundError")}function raise(errorConstructor,message,name){throw new errorConstructor("Failed to execute 'requestSubmit' on 'HTMLFormElement': "+message+".",name)}})(HTMLFormElement.prototype);const submittersByForm=new WeakMap();function findSubmitterFromClickTarget(target){const element=target instanceof Element?target:target instanceof Node?target.parentElement:null;const candidate=element?element.closest("input, button"):null;return(candidate===null||candidate===void 0?void 0:candidate.type)=="submit"?candidate:null}function clickCaptured(event){const submitter=findSubmitterFromClickTarget(event.target);if(submitter&&submitter.form){submittersByForm.set(submitter.form,submitter)}}(function(){if("submitter"in Event.prototype){return}let prototype=window.Event.prototype;if("SubmitEvent"in window&&/Apple Computer/.test(navigator.vendor)){prototype=window.SubmitEvent.prototype}else if("SubmitEvent"in window){return}addEventListener("click",clickCaptured,true);Object.defineProperty(prototype,"submitter",{get(){if(this.type=="submit"&&this.target instanceof HTMLFormElement){return submittersByForm.get(this.target)}}})})();exports.FrameLoadingStyle=void 0;(function(FrameLoadingStyle){FrameLoadingStyle["eager"]="eager";FrameLoadingStyle["lazy"]="lazy"})(exports.FrameLoadingStyle||(exports.FrameLoadingStyle={}));class FrameElement extends HTMLElement{static get observedAttributes(){return["disabled","complete","loading","src"]}constructor(){super();this.loaded=Promise.resolve();this.delegate=new FrameElement.delegateConstructor(this)}connectedCallback(){this.delegate.connect()}disconnectedCallback(){this.delegate.disconnect()}reload(){return this.delegate.sourceURLReloaded()}attributeChangedCallback(name){if(name=="loading"){this.delegate.loadingStyleChanged()}else if(name=="complete"){this.delegate.completeChanged()}else if(name=="src"){this.delegate.sourceURLChanged()}else{this.delegate.disabledChanged()}}get src(){return this.getAttribute("src")}set src(value){if(value){this.setAttribute("src",value)}else{this.removeAttribute("src")}}get loading(){return frameLoadingStyleFromString(this.getAttribute("loading")||"")}set loading(value){if(value){this.setAttribute("loading",value)}else{this.removeAttribute("loading")}}get disabled(){return this.hasAttribute("disabled")}set disabled(value){if(value){this.setAttribute("disabled","")}else{this.removeAttribute("disabled")}}get autoscroll(){return this.hasAttribute("autoscroll")}set autoscroll(value){if(value){this.setAttribute("autoscroll","")}else{this.removeAttribute("autoscroll")}}get complete(){return!this.delegate.isLoa
|
|||
|
.turbo-progress-bar {
|
|||
|
position: fixed;
|
|||
|
display: block;
|
|||
|
top: 0;
|
|||
|
left: 0;
|
|||
|
height: 3px;
|
|||
|
background: #0076ff;
|
|||
|
z-index: 2147483647;
|
|||
|
transition:
|
|||
|
width ${ProgressBar.animationDuration }ms ease-out,
|
|||
|
opacity ${ProgressBar.animationDuration/2}ms ${ProgressBar.animationDuration/2}ms ease-in;
|
|||
|
transform: translate3d(0, 0, 0);
|
|||
|
}
|
|||
|
`}constructor(){this.hiding=false;this.value=0;this.visible=false;this.trickle=()=>{this.setValue(this.value+Math.random()/100)};this.stylesheetElement=this.createStylesheetElement();this.progressElement=this.createProgressElement();this.installStylesheetElement();this.setValue(0)}show(){if(!this.visible){this.visible=true;this.installProgressElement();this.startTrickling()}}hide(){if(this.visible&&!this.hiding){this.hiding=true;this.fadeProgressElement(()=>{this.uninstallProgressElement();this.stopTrickling();this.visible=false;this.hiding=false})}}setValue(value){this.value=value;this.refresh()}installStylesheetElement(){document.head.insertBefore(this.stylesheetElement,document.head.firstChild)}installProgressElement(){this.progressElement.style.width="0";this.progressElement.style.opacity="1";document.documentElement.insertBefore(this.progressElement,document.body);this.refresh()}fadeProgressElement(callback){this.progressElement.style.opacity="0";setTimeout(callback,ProgressBar.animationDuration*1.5)}uninstallProgressElement(){if(this.progressElement.parentNode){document.documentElement.removeChild(this.progressElement)}}startTrickling(){if(!this.trickleInterval){this.trickleInterval=window.setInterval(this.trickle,ProgressBar.animationDuration)}}stopTrickling(){window.clearInterval(this.trickleInterval);delete this.trickleInterval}refresh(){requestAnimationFrame(()=>{this.progressElement.style.width=`${10+this.value*90}%`})}createStylesheetElement(){const element=document.createElement("style");element.type="text/css";element.textContent=ProgressBar.defaultCSS;if(this.cspNonce){element.nonce=this.cspNonce}return element}createProgressElement(){const element=document.createElement("div");element.className="turbo-progress-bar";return element}get cspNonce(){return getMetaContent("csp-nonce")}}ProgressBar.animationDuration=300;class HeadSnapshot extends Snapshot{constructor(){super(...arguments);this.detailsByOuterHTML=this.children.filter((element)=>!elementIsNoscript(element)).map((element)=>elementWithoutNonce(element)).reduce((result,element)=>{const{outerHTML}=element;const details=outerHTML in result?result[outerHTML]:{type:elementType(element),tracked:elementIsTracked(element),elements:[]};return Object.assign(Object.assign({},result),{[outerHTML]:Object.assign(Object.assign({},details),{elements:[...details.elements,element]})})},{})}get trackedElementSignature(){return Object.keys(this.detailsByOuterHTML).filter((outerHTML)=>this.detailsByOuterHTML[outerHTML].tracked).join("")}getScriptElementsNotInSnapshot(snapshot){return this.getElementsMatchingTypeNotInSnapshot("script",snapshot)}getStylesheetElementsNotInSnapshot(snapshot){return this.getElementsMatchingTypeNotInSnapshot("stylesheet",snapshot)}getElementsMatchingTypeNotInSnapshot(matchedType,snapshot){return Object.keys(this.detailsByOuterHTML).filter((outerHTML)=>!(outerHTML in snapshot.detailsByOuterHTML)).map((outerHTML)=>this.detailsByOuterHTML[outerHTML]).filter(({type})=>type==matchedType).map(({elements:[element]})=>element)}get provisionalElements(){return Object.keys(this.detailsByOuterHTML).reduce((result,outerHTML)=>{const{type,tracked,elements}=this.detailsByOuterHTML[outerHTML];if(type==null&&!tracked){return[...result,...elements]}else if(elements.length>1){return[...result,...elements.slice(1)]}else{return result}},[])}getMetaValue(name){const element=this.findMetaElementByName(name);return element?element.getAttribute("content"):null}findMetaElementByName(name){return Object.keys(this.detailsByOuterHTML).reduce((result,outerHTML)=>{const{elements:[element]}=this.detailsByOuterHTML[outerHTML];return elementIsMetaElementWithName(element,name)?element:result},undefined)}}function elementType(element){if(elementIsScript(element)){return "script"}else if(elementIsStylesheet(element)){return "stylesheet"}}function elementIsTracked(element){return element.getAttribute("data-turbo-track")=="reload"}function elementIsScript(element){const tagName=element.localName;return tagName=="script"}function elementIsNoscript(element){const tagName=eleme
|
|||
|
You are loading Turbo from a <script> element inside the <body> element. This is probably not what you meant to do!
|
|||
|
|
|||
|
Load your application’s JavaScript bundle inside the <head> element instead. <script> elements in <body> are evaluated with each page change.
|
|||
|
|
|||
|
For more information, see: https://turbo.hotwired.dev/handbook/building#working-with-script-elements
|
|||
|
|
|||
|
——
|
|||
|
Suppress this warning by adding a "data-turbo-suppress-warning" attribute to: %s
|
|||
|
`,element.outerHTML)}element=element.parentElement}})();window.Turbo=Turbo;start();exports.FrameElement=FrameElement;exports.FrameRenderer=FrameRenderer;exports.PageRenderer=PageRenderer;exports.PageSnapshot=PageSnapshot;exports.StreamActions=StreamActions;exports.StreamElement=StreamElement;exports.StreamSourceElement=StreamSourceElement;exports.cache=cache;exports.clearCache=clearCache;exports.connectStreamSource=connectStreamSource;exports.disconnectStreamSource=disconnectStreamSource;exports.navigator=navigator$1;exports.registerAdapter=registerAdapter;exports.renderStreamMessage=renderStreamMessage;exports.session=session;exports.setConfirmMethod=setConfirmMethod;exports.setFormMode=setFormMode;exports.setProgressBarDelay=setProgressBarDelay;exports.start=start;exports.visit=visit;Object.defineProperty(exports,'__esModule',{value:true})}));
|