Sha256: 12b3deb93126a1c17b9a9359ce766f9ee080a12a052ff4dab70d7ff81a01de7a

Contents?: true

Size: 858 Bytes

Versions: 94

Compression:

Stored size: 858 Bytes

Contents

export default class Format {
  constructor() {
    this.formatSelector = $('.js-format-selector')[0]
    if (this.formatSelector) {
      this.formatChanged(this.formatSelector.value, false)
      $(this.formatSelector).change((event) => this.formatChanged(event.target.value))

      this.restoreFormat()
    }
  }

  formatChanged(format, persist = true) {
    $('.js-format').hide()
    $(`.js-format[data-format='${format}']`).show()

    if (persist) {
      this.persistFormat(format)
    }
  }

  persistFormat(format) {
    if (window.localStorage) {
      window.localStorage.setItem('format', format)
    }
  }

  restoreFormat() {
    if (window.localStorage) {
      const format = window.localStorage.getItem('format')
      if (format) {
        $(this.formatSelector).val(format)
        this.formatChanged(format, false)
      }
    }
  }
}

Version data entries

94 entries across 94 versions & 1 rubygems

Version Path
station-0.5.16 lib/nexmo_developer/app/webpacker/javascript/format/index.js
station-0.5.15 lib/nexmo_developer/app/webpacker/javascript/format/index.js
station-0.5.14 lib/nexmo_developer/app/webpacker/javascript/format/index.js
station-0.5.13 lib/nexmo_developer/app/webpacker/javascript/format/index.js
station-0.5.12 lib/nexmo_developer/app/webpacker/javascript/format/index.js
station-0.5.11 lib/nexmo_developer/app/webpacker/javascript/format/index.js
station-0.5.10 lib/nexmo_developer/app/webpacker/javascript/format/index.js
station-0.5.9 lib/nexmo_developer/app/webpacker/javascript/format/index.js
station-0.5.8 lib/nexmo_developer/app/webpacker/javascript/format/index.js
station-0.5.7 lib/nexmo_developer/app/webpacker/javascript/format/index.js
station-0.5.6 lib/nexmo_developer/app/webpacker/javascript/format/index.js
station-0.5.5 lib/nexmo_developer/app/webpacker/javascript/format/index.js
station-0.5.4 lib/nexmo_developer/app/webpacker/javascript/format/index.js
station-0.5.3 lib/nexmo_developer/app/webpacker/javascript/format/index.js
station-0.5.2 lib/nexmo_developer/app/webpacker/javascript/format/index.js
station-0.5.1 lib/nexmo_developer/app/webpacker/javascript/format/index.js
station-0.5.0 lib/nexmo_developer/app/webpacker/javascript/format/index.js
station-0.4.9 lib/nexmo_developer/app/webpacker/javascript/format/index.js
station-0.4.8 lib/nexmo_developer/app/webpacker/javascript/format/index.js
station-0.4.7 lib/nexmo_developer/app/webpacker/javascript/format/index.js