Sha256: 9f778f3cddabbff3da95edc41986ac4c53576e0d9183812a9d7db8a5f97744be

Contents?: true

Size: 677 Bytes

Versions: 49

Compression:

Stored size: 677 Bytes

Contents

import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
  static targets = [ "button" ]

  connect() {
    this.hasButtonTarget && this.#hideButtonIfNotSupported()
  }

  toggle() {
    this.#fullScreenMode ? this.#exitFullscreen() : this.#requestFullscreen()
  }

  #hideButtonIfNotSupported() {
    this.buttonTarget.hidden = !this.#supportsFullScreen
  }

  #exitFullscreen() {
    document.exitFullscreen()
  }

  #requestFullscreen() {
    document.documentElement.requestFullscreen()
  }

  get #supportsFullScreen() {
    return this.element.requestFullscreen
  }

  get #fullScreenMode() {
    return document.fullscreenElement
  }
}

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
css-zero-0.0.93 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.92 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.91 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.90 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.89 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.88 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.87 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.86 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.85 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.84 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.83 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.82 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.81 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.80 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.79 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.78 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.77 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.76 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.75 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.74 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js