Sha256: b9ada36d21c360ef24ed67de83dc87c86ca7a4aecea84ba445d763608ab34e34
Contents?: true
Size: 636 Bytes
Versions: 76
Compression:
Stored size: 636 Bytes
Contents
import { Controller } from '@hotwired/stimulus' // DEPRECATED. // // Connects to data-controller="switcher" export default class extends Controller { originalText = null textEl = null connect () { this.textEl = this.element.querySelector('.text') this.originalText = this.textEl.textContent this.element.addEventListener('click', () => { this.cambiarTexto() }) this.cambiarTexto() } cambiarTexto () { if (this.element.getAttribute('aria-expanded') === 'true') { this.textEl.textContent = this.element.dataset.expandedText } else { this.textEl.textContent = this.originalText } } }
Version data entries
76 entries across 76 versions & 1 rubygems