1import {Turbo} from '@hotwired/turbo-rails' 2import {BootstrapWrapper} from 'sites/bootstrap_wrapper' 3import {ApplyUrl} from 'sites/apply_url' 4 5Turbo.StreamActions.focus = function () { 6 if (this.targetElements) { 7 this.targetElements[0].focus() 8 } 9} 10 11// based on https://onrails.blog/2024/04/01/hotwire-turbo-tutorial-animated-deletions-and-insertions/ 12Turbo.StreamActions.animatedRemove = async function () { 13 for (const target of this.targetElements) { 14 target.animate( 15 [ 16 {transform: 'scale(1)', transformOrigin: 'top', height: 'auto', opacity: 1.0}, 17 {transform: 'scale(0.8)', opacity: 0.2, height: '80%', offset: 0.8}, 18 {transform: 'scale(0)', transformOrigin: 'top', height: 0, opacity: 0}, 19 ], 20 {duration: 150, easing: 'ease-out'} 21 ) 22 await Promise.all(target.getAnimations().map((animation) => animation.finished)) 23 target.remove() 24 } 25} 26 27Turbo.StreamActions.closeModal = function () { 28 const target = this.targetElements[0] 29 if (target) { 30 BootstrapWrapper.hideModal(target) 31 } 32} 33 34Turbo.StreamActions.submitForm = function () { 35 const form = this.targetElements[0] 36 if (form) { 37 form.requestSubmit() 38 } 39} 40 41Turbo.StreamActions.fireAuthenticated = function () { 42 document.dispatchEvent(new CustomEvent('clinch:authenticated')) 43} 44 45Turbo.StreamActions.openSigninModal = function () { 46 const frame = document.querySelector('turbo-frame#web_identity_session') 47 frame?.addEventListener('turbo:frame-load', () => { 48 BootstrapWrapper.modal(frame.querySelector('#web_identity_session_modal')) 49 }, {once: true}) 50} 51 52Turbo.StreamActions.redirectTo = function () { 53 if (this.dataset.url) { 54 if (this.dataset.newTab === 'true') { 55 window.open(this.dataset.url, js_vars.cta_redirection_target) 56 } else { 57 window.location.href = this.dataset.url 58 } 59 } 60} 61 62Turbo.StreamActions.postToApplyUrl = function () { 63 ApplyUrl.postToApplyUrl(JSON.parse(this.dataset.applyUrlData)) 64} 65 66Turbo.StreamActions.openWindow = function () { 67 if (this.dataset.url) { 68 const width = 800 69 const height = 600 70 const thisWindow = window.open(this.dataset.url, 'newwindow', `popup,width=${width},height=${height}`,) 71 thisWindow.moveTo((thisWindow.screen.width - width) / 2, (thisWindow.screen.height - height) / 3) 72 thisWindow.window.focus() 73 } 74}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.