Sha256: 9f778f3cddabbff3da95edc41986ac4c53576e0d9183812a9d7db8a5f97744be

Contents?: true

Size: 677 Bytes

Versions: 59

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

59 entries across 59 versions & 1 rubygems

Version Path
css-zero-0.0.63 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.62 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.61 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.60 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.59 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.58 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.57 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.56 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.55 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.54 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.53 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.52 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.51 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.50 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.49 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.48 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.47 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.46 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js
css-zero-0.0.45 lib/generators/css_zero/add/templates/app/javascript/controllers/fullscreen_controller.js